aboutsummaryrefslogtreecommitdiff
path: root/lib/ast.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ast.js')
-rw-r--r--lib/ast.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/ast.js b/lib/ast.js
index 331d340b..1a77a59d 100644
--- a/lib/ast.js
+++ b/lib/ast.js
@@ -335,6 +335,23 @@ var AST_Toplevel = DEFNODE("Toplevel", "globals", {
}
}));
return wrapped_tl;
+ },
+ wrap_enclose: function(args_values) {
+ if (typeof args_values != "string") args_values = "";
+ var index = args_values.indexOf(":");
+ if (index < 0) index = args_values.length;
+ var body = this.body;
+ return parse([
+ "(function(",
+ args_values.slice(0, index),
+ '){"$ORIG"})(',
+ args_values.slice(index + 1),
+ ")"
+ ].join("")).transform(new TreeTransformer(function(node) {
+ if (node instanceof AST_Directive && node.value == "$ORIG") {
+ return MAP.splice(body);
+ }
+ }));
}
}, AST_Scope);