aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai.bazon@gmail.com>2015-11-11 22:15:25 +0200
committerMihai Bazon <mihai.bazon@gmail.com>2015-11-11 22:15:25 +0200
commit7691bebea525e96cb74d52e0bb8f294cf778c966 (patch)
treed2485ce55b215edb1846cbbe9cc3e4e3ad28725d /lib/scope.js
parent3c4346728e5067608b6393ba98e24849ac22adea (diff)
downloadtracifyjs-7691bebea525e96cb74d52e0bb8f294cf778c966.tar.gz
tracifyjs-7691bebea525e96cb74d52e0bb8f294cf778c966.zip
Rework has_directive
It's now available during tree walking, i.e. walker.has_directive("use asm"), rather than as part of the scope. It's thus no longer necessary to call `figure_out_scope` before codegen. Added special bits in the code generator to overcome the fact that it doesn't inherit from TreeWalker. Fix #861
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js19
1 files changed, 0 insertions, 19 deletions
diff --git a/lib/scope.js b/lib/scope.js
index 06bd65ae..4a3739c4 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -114,15 +114,6 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
defun = save_defun;
return true; // don't descend again in TreeWalker
}
- if (node instanceof AST_Directive) {
- node.scope = scope;
- push_uniq(scope.directives, node.value);
- return true;
- }
- if (node instanceof AST_Number) {
- node.scope = scope;
- return true;
- }
if (node instanceof AST_With) {
for (var s = scope; s; s = s.parent_scope)
s.uses_with = true;
@@ -202,7 +193,6 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
});
AST_Scope.DEFMETHOD("init_scope_vars", function(nesting){
- this.directives = []; // contains the directives defined in this scope, i.e. "use strict"
this.variables = new Dictionary(); // map name to AST_SymbolVar (variables defined in this scope; includes functions)
this.functions = new Dictionary(); // map name to AST_SymbolDefun (functions defined in this scope)
this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement
@@ -213,10 +203,6 @@ AST_Scope.DEFMETHOD("init_scope_vars", function(nesting){
this.nesting = nesting; // the nesting level of this scope (0 means toplevel)
});
-AST_Scope.DEFMETHOD("strict", function(){
- return this.has_directive("use strict");
-});
-
AST_Lambda.DEFMETHOD("init_scope_vars", function(){
AST_Scope.prototype.init_scope_vars.apply(this, arguments);
this.uses_arguments = false;
@@ -240,11 +226,6 @@ AST_Scope.DEFMETHOD("find_variable", function(name){
|| (this.parent_scope && this.parent_scope.find_variable(name));
});
-AST_Scope.DEFMETHOD("has_directive", function(value){
- return this.parent_scope && this.parent_scope.has_directive(value)
- || (this.directives.indexOf(value) >= 0 ? this : null);
-});
-
AST_Scope.DEFMETHOD("def_function", function(symbol){
this.functions.set(symbol.name, this.def_variable(symbol));
});