Introduce is_block_scope to AST_Node to determine block scope.
Will return false if AST_Node is instance of AST_Scope for now.
This commit is contained in:
@@ -282,10 +282,9 @@ var AST_With = DEFNODE("With", "expression", {
|
||||
|
||||
/* -----[ scope and functions ]----- */
|
||||
|
||||
var AST_Scope = DEFNODE("Scope", "is_block_scope directives variables functions uses_with uses_eval parent_scope enclosed cname", {
|
||||
var AST_Scope = DEFNODE("Scope", "directives variables functions uses_with uses_eval parent_scope enclosed cname", {
|
||||
$documentation: "Base class for all statements introducing a lexical scope",
|
||||
$propdoc: {
|
||||
is_block_scope: "[boolean] identifies a block scope",
|
||||
directives: "[string*/S] an array of directives declared in this scope",
|
||||
variables: "[Object/S] a map of name -> SymbolDef for all variables/functions defined in this scope",
|
||||
functions: "[Object/S] like `variables`, but only lists function declarations",
|
||||
@@ -297,7 +296,7 @@ var AST_Scope = DEFNODE("Scope", "is_block_scope directives variables functions
|
||||
},
|
||||
get_defun_scope: function () {
|
||||
var self = this;
|
||||
while (self.is_block_scope && self.parent_scope) {
|
||||
while (self.is_block_scope() && self.parent_scope) {
|
||||
self = self.parent_scope;
|
||||
}
|
||||
return self;
|
||||
|
||||
Reference in New Issue
Block a user