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:
Anthony Van de Gejuchte
2016-10-19 15:34:26 +02:00
parent 7e80a979a7
commit 5f6825f9ec
3 changed files with 53 additions and 11 deletions

View File

@@ -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;