X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=JSDOC%2FScopeParser.vala;h=28e95ba0c58a7c9d5ff41c4e224115fcaf00c30d;hb=430645d02c9e7322f0a39b14027e2b2337ab1f9d;hp=968100d435c977a2b2c4a7143bc4fbc50dfa103b;hpb=537b657f4c39fa281ab01249fe1b997228f491d0;p=gnome.introspection-doc-generator diff --git a/JSDOC/ScopeParser.vala b/JSDOC/ScopeParser.vala index 968100d..28e95ba 100644 --- a/JSDOC/ScopeParser.vala +++ b/JSDOC/ScopeParser.vala @@ -515,12 +515,15 @@ namespace JSDOC { //print("MATCH!?"); var _t = this; + var regex = new GLib.Regex ("eval:var:([a-z_]+)",GLib.RegexCompileFlags.CASELESS ); + + - token.prefix.replace(/eval:var:([a-z_]+)/ig, function(m, a) { - //print("GOT: " + a); - var hi = _t.getIdentifier(a, scope, token); - // println("PROTECT "+a+" from munge" + (hi ? "FOUND" : "MISSING")); - if (hi) { + regex.replace_eval (token.prefix, token.prefix.length, 0, 0, (match_info, result) => { + var a = match_info.fetch(0); + var hi = this.getIdentifier(a, scope, token); + // println("PROTECT "+a+" from munge" + (hi ? "FOUND" : "MISSING")); + if (hi.length > 0) { // print("PROTECT "+a+" from munge"); //print(JSON.stringify(hi,null,4)); hi.toMunge = false; @@ -708,7 +711,7 @@ namespace JSDOC { } else { //print("EXPR-NAME:" + token.toString()); } - symbol = token.data; + var symbol = token.data; //print("in NAME = " + token.toString()); //print("in NAME 0: " + this.ts.look(0).toString()); //print("in NAME 2: " + this.ts.lookTok(2).toString()); @@ -725,7 +728,7 @@ namespace JSDOC { if (this.mode == ScopeParserMode.PASS2_SYMBOL_TREE) { - identifier = this.getIdentifier(symbol, scope, token); + var identifier = this.getIdentifier(symbol, scope, token); //println("??"); if (identifier == false) { @@ -756,7 +759,7 @@ namespace JSDOC { //println("EID"); - case 'KEYW': + case "KEYW": //if (this.mode == 'BUILDING_SYMBOL_TREE') // print("EXPR-KEYW:" + JSON.stringify(token, null, 4)); @@ -768,8 +771,8 @@ namespace JSDOC { } - symbol = token.data; - if (this.mode == 'BUILDING_SYMBOL_TREE') { + var symbol = token.data; + if (this.mode == ScopeParserMode.BUILDING_SYMBOL_TREE) { if (token.name == "EVAL") { //print(JSON.stringify(token,null,4)); @@ -810,19 +813,15 @@ namespace JSDOC { } //print("<< EXIT EXPRESSION"); this.expN--; - }, + } - parseCatch : function(scope) { + void parseCatch(scope) { - var symbol; - var token; - - var identifier; //token = getToken(-1); //assert token.getType() == Token.CATCH; - token = this.ts.nextTok(1); + var token = this.ts.nextTok(1); token = this.ts.nextTok(1); @@ -831,40 +830,38 @@ namespace JSDOC { //token = this.ts.nextTok(); //assert token.getType() == Token.NAME; - symbol = token.items[0][0].data; + var symbol = token.items[0][0].data; - if (this.mode == 'BUILDING_SYMBOL_TREE') { + if (this.mode == ScopeParserMode.BUILDING_SYMBOL_TREE) { // We must declare the exception identifier in the containing function // scope to avoid errors related to the obfuscation process. No need to // display a warning if the symbol was already declared here... scope.declareIdentifier(symbol, token.items[0][0]); } else { //?? why inc the refcount?? - that should be set when building the tree??? - identifier = this.getIdentifier(symbol, scope, token.items[0][0]); + var identifier = this.getIdentifier(symbol, scope, token.items[0][0]); identifier.refcount++; } //token = this.ts.nextTok(); //assert token.getType() == Token.RP; // ) - }, + } - parseFunctionDeclaration : function(scope) + void parseFunctionDeclaration (Scope scope) { //print("PARSE FUNCTION"); - var symbol; - var token; var fnScope = false; - var identifier; + var b4braceNesting = this.braceNesting + 0; //this.logR("PARSING FUNCTION"); - token = this.ts.nextTok(); + var token = this.ts.nextTok(); if (token.type == "NAME") { - if (this.mode == 'BUILDING_SYMBOL_TREE') { + if (this.mode == ScopeParserMode.BUILDING_SYMBOL_TREE) { // Get the name of the function and declare it in the current scope. symbol = token.data; if (scope.getIdentifier(symbol,token) != false) { @@ -883,9 +880,9 @@ namespace JSDOC { } - + Scope fnScope; //assert token.getType() == Token.LP; - if (this.mode == 'BUILDING_SYMBOL_TREE') { + if (this.mode == ScopeParserMode.BUILDING_SYMBOL_TREE) { fnScope = new Scope(1, scope, token.n, '', token); //println("STORING SCOPE" + this.ts.cursor); @@ -900,15 +897,15 @@ namespace JSDOC { // print('FUNC-PARSE:' + JSON.stringify(token,null,4)); // Parse function arguments. var args = token.items; - for (var argpos =0; argpos < args.length; argpos++) { + for (var argpos =0; argpos < args.size; argpos++) { - token = args[argpos][0]; + token = args.get(argpos).get(0); //print ("FUNC ARGS: " + token.toString()) //assert token.getType() == Token.NAME || // token.getType() == Token.COMMA; - if (token.type == 'NAME' && this.mode == 'BUILDING_SYMBOL_TREE') { - symbol = token.data; - identifier = fnScope.declareIdentifier(symbol,token); + if (token.type == "NAME" && this.mode == ScopeParserMode.BUILDING_SYMBOL_TREE) { + var symbol = token.data; + var identifier = fnScope.declareIdentifier(symbol,token); if (symbol == "$super" && argpos == 0) { // Exception for Prototype 1.6... identifier.preventMunging(); @@ -927,11 +924,9 @@ namespace JSDOC { //token = this.ts.nextTok(); //print(token.toString()); var outTS = this.ts; - var _this = this; - token.items.forEach(function(tar) { - _this.ts = new TokenStream(tar); - _this.parseScope(fnScope); - + foreach(var tar in token.items) { + this.ts = new TokenStream(tar); + this.parseScope(fnScope); }); @@ -944,9 +939,9 @@ namespace JSDOC { //print("ENDFN -1: " + this.ts.lookTok(-1).toString()); //print("ENDFN 0: " + this.ts.lookTok(0).toString()); //print("ENDFN 1: " + this.ts.lookTok(1).toString()); - }, + } - protectScopeFromObfuscation : function(scope) { + void protectScopeFromObfuscation (scope) { //assert scope != null; if (scope == this.globalScope) { @@ -962,18 +957,20 @@ namespace JSDOC { //assert scope.getParentScope() == globalScope; scope.preventMunging(); - }, + } - getIdentifier: function(symbol, scope, token) { - var identifier; - while (scope != false) { + Token getIdentifier(string symbol, Scope in_scope, Token token) + { + string identifier; + var scope = in_scope; + while (scope != null) { identifier = scope.getIdentifier(symbol, token); //println("ScopeParser.getIdentgetUsedSymbols("+symbol+")=" + scope.getUsedSymbols().join(',')); - if (identifier) { + if (identifier.length) { return identifier; } scope = scope.parent; } - return false; + return ""; } -}; +}