aboutsummaryrefslogtreecommitdiff
path: root/src/js_ast.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-09 02:21:31 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-09 02:21:31 -0700
commitf74771144e71e77969fe50d250818e2fcc0800bd (patch)
tree85b18e33fc8a7d5c8a8438d8af23439cef74b949 /src/js_ast.zig
parent687b22908f15020d254eb90672bcdddbdaad7f06 (diff)
downloadbun-f74771144e71e77969fe50d250818e2fcc0800bd.tar.gz
bun-f74771144e71e77969fe50d250818e2fcc0800bd.tar.zst
bun-f74771144e71e77969fe50d250818e2fcc0800bd.zip
Split up + generate client & server bundles, support framework +router in GenerateNodeModulesBundle , read framework from package.json + rename "publicURL" to "origin" + add import.meta.filepath
Former-commit-id: 1e76ebb5375247231181ec19a6396c6acf4684fb
Diffstat (limited to 'src/js_ast.zig')
-rw-r--r--src/js_ast.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/js_ast.zig b/src/js_ast.zig
index 1890f972f..3f032e075 100644
--- a/src/js_ast.zig
+++ b/src/js_ast.zig
@@ -1946,6 +1946,27 @@ pub const Expr = struct {
return null;
}
+ pub const ArrayIterator = struct {
+ array: *const E.Array,
+ index: u32,
+
+ pub fn next(this: *ArrayIterator) ?Expr {
+ if (this.index >= this.array.items.len) {
+ return null;
+ }
+ defer this.index += 1;
+ return this.array.items[this.index];
+ }
+ };
+
+ pub fn asArray(expr: *const Expr) ?ArrayIterator {
+ if (std.meta.activeTag(expr.data) != .e_array) return null;
+ const array = expr.data.e_array;
+ if (array.items.len == 0 or @ptrToInt(array.items.ptr) == 0) return null;
+
+ return ArrayIterator{ .array = array, .index = 0 };
+ }
+
pub fn asString(expr: *const Expr, allocator: *std.mem.Allocator) ?string {
if (std.meta.activeTag(expr.data) != .e_string) return null;