* // FIXME - I need this to do next() without doccomments..
*/
-Identifier = imports.Identifier.Identifier
-XObject = imports.XObject.XObject;
+const Identifier = imports.Identifier.Identifier
+const XObject = imports.XObject.XObject;
function Scope(braceN, parent, startTokN, lastIdent, token)
this.hints = { };
this.ident = lastIdent;
this.gid = Scope.gid++;
-
- print("ADD SCOPE(" + this.gid + ") TO "+ (parent ? this.parent.gid : 'TOP') + ' : ' +
- (token ? token.toString() : ''));
+ this.token = token;
+ //print("ADD SCOPE(" + this.gid + ") TO "+ (parent ? this.parent.gid : 'TOP') + ' : ' +
+ // (token ? token.toString() : ''));
if (parent) {
this.parent.subScopes.push(this);
munged : false,
protectedVars : {}, // only used by to parent..
- declareIdentifier : function(symbol, token) {
+
+ /**
+ * dump the scope to StdOut...
+ *
+ */
+ dump : function(indent)
+ {
+ indent = indent || '';
+ print(
+ indent + "Scope: " + this.id + "\n" +
+ indent + "Started: " + ( this.token ? this.token.line : 'TOP' ) + "\n" +
+ indent + "- " + XObject.keys(this.identifiers).join(", ") + "\n"
+ );
+ this.subScopes.forEach(function(s) {
+ s.dump(indent + ' ');
+ });
- print("SCOPE : " + this.gid + " : " + token.toString()+"");
+
+ },
+
+
+ declareIdentifier : function(symbol, token)
+ {
+
+ //print("SCOPE : " + this.gid + " :SYM: " + symbol + " " + token.toString()+"");
if (typeof(this.identifiers[symbol])== 'undefined') {
// then it's global...
this.identifiers[symbol].toMunge = false;
}
+
+
this.addToParentScope(symbol);
return this.identifiers[symbol];
},
return false;
}
- print("SCOPE : " + this.gid +" = SYMBOL NOT FOUND?" + token.toString());
+ //print("SCOPE : " + this.gid +" = SYMBOL NOT FOUND?" + token.toString());
return false;
}
- print("SCOPE : " + this.gid +" = FOUND:" + token.toString());
+ //print("SCOPE : " + this.gid +" = FOUND:" + token.toString());
return this.identifiers[symbol];
},
if (!repsym.length) {
if (!freeSymbols.length) {
- addSyms(JSDOC.Scope.twos);
+ addSyms(Scope.twos);
}
repsym = freeSymbols.shift(); // pop off beginngin???
}