JSDOC/ScopeParser.js
[gnome.introspection-doc-generator] / JSDOC / ScopeParser.js
1 //<Script type="text/javascript">
2
3 Scope = imports['JSDOC/Scope.js'].Scope;
4
5 /**
6 * Scope stuff
7
8 * // FIXME - I need this to do next() without doccomments..
9 */
10
11 ScopeParser = function(ts) {
12     this.ts = ts; // {TokenStream}
13     this.warnings = [];
14     this.scopes = [];
15     this.indexedScopes = {};
16     this.timer = new Date() * 1;
17     this.debug = false;
18 }
19
20 // list of keywords that should not be used in object literals.
21 ScopeParser.idents = [
22         "break",         
23         "case",          
24         "continue",     
25         "default",      
26         "delete",       
27         "do",            
28         "else",         
29         "export",       
30         "false",        
31         "for",          
32         "function",     
33         "if",           
34         "import",       
35         "in",           
36         "new",          
37         "null",         
38         "return",       
39         "switch",       
40         "this",         
41         "true",         
42         "typeof",       
43         "var",          
44         "void",         
45         "while",        
46         "with",         
47
48         "catch",        
49         "class",        
50         "const",        
51         "debugger",     
52         "enum",         
53         "extends",      
54         "finally",      
55         "super",        
56         "throw",         
57         "try",          
58
59         "abstract",     
60         "boolean",      
61         "byte",         
62         "char",         
63         "double",       
64         "final",        
65         "float",        
66         "goto",         
67         "implements", 
68         "instanceof",
69         "int",           
70         "interface",     
71         "long",          
72         "native",       
73         "package",      
74         "private",      
75         "protected",     
76         "public",        
77         "short",        
78         "static",       
79         "synchronized",  
80         "throws",        
81         "transient",     
82                 "include",       
83                 "undefined"
84 ];
85
86
87 ScopeParser.prototype = {
88     timer: 0,
89     timerPrint: function (str) {
90         var ntime = new Date() * 1;
91         var tdif =  ntime -this.timer;
92         this.timer = ntime;
93         var pref = '';
94         if (tdif > 100) { //slower ones..
95             pref = '***';
96         }
97         println(pref+'['+tdif+']'+str);
98         
99     },
100     warn: function(s) {
101         !this.debug || print('****************' + s);
102         this.warnings.push(s);
103         //println("WARNING:" + htmlescape(s) + "<BR>");
104     },
105     // defaults should not be initialized here =- otherwise they get duped on new, rather than initalized..
106     warnings : false,
107     ts : false,
108     scopes : false,
109     global : false,
110     mode : "", //"BUILDING_SYMBOL_TREE",
111     braceNesting : 0,
112     indexedScopes : false,
113     munge: true,
114
115
116
117
118
119     buildSymbolTree : function()
120     {
121         //println("<PRE>");
122         
123         this.ts.rewind();
124         this.braceNesting = 0;
125         this.scopes = [];
126         
127         
128         
129         
130         this.globalScope = new  Scope(-1, false, -1, '');
131         indexedScopes = { 0 : this.globalScope };
132         
133         this.mode = 'BUILDING_SYMBOL_TREE';
134         this.parseScope(this.globalScope);
135     },
136     mungeSymboltree : function()
137     {
138
139         if (!this.munge) {
140             return;
141         }
142
143         // One problem with obfuscation resides in the use of undeclared
144         // and un-namespaced global symbols that are 3 characters or less
145         // in length. Here is an example:
146         //
147         //     var declaredGlobalVar;
148         //
149         //     function declaredGlobalFn() {
150         //         var localvar;
151         //         localvar = abc; // abc is an undeclared global symbol
152         //     }
153         //
154         // In the example above, there is a slim chance that localvar may be
155         // munged to 'abc', conflicting with the undeclared global symbol
156         // abc, creating a potential bug. The following code detects such
157         // global symbols. This must be done AFTER the entire file has been
158         // parsed, and BEFORE munging the symbol tree. Note that declaring
159         // extra symbols in the global scope won't hurt.
160         //
161         // Note: Since we go through all the tokens to do this, we also use
162         // the opportunity to count how many times each identifier is used.
163
164         this.ts.rewind();
165         this.braceNesting = 0;
166         this.scopes= [];
167         this.mode = 'PASS2_SYMBOL_TREE';
168         
169         //println("MUNGING?");
170         
171         this.parseScope(this.globalScope);
172         this.globalScope.munge();
173     },
174
175
176     log : function(str)
177     {
178           //println("<B>LOG:</B>" + htmlescape(str) + "<BR/>\n");
179     },
180     logR : function(str)
181     {
182             //println("<B>LOG:</B>" + str + "<BR/>");
183     },
184
185
186
187
188
189
190     parseScope : function(scope) // parse a token stream..
191     {
192         //this.timerPrint("parseScope EnterScope"); 
193         var symbol;
194         var token;
195         
196         var identifier;
197
198         var expressionBraceNesting = this.braceNesting;
199         var bracketNesting = 0;
200         var parensNesting = 0;
201         
202         var isObjectLitAr = [ false ];
203         var isInObjectLitAr;
204         this.scopes.push(scope);
205         token = this.ts.lookTok(1);
206         while (token) {
207           //  this.timerPrint("parseScope AFTER lookT: " + token.toString()); 
208              
209             !this.debug|| print(token.type + '.' + token.name+ ":" + token.data);
210             switch(token.type + '.' + token.name) {
211                 case "KEYW.VAR":
212                 case "KEYW.CONST": // not really relivant as it's only mozzy that does this.
213                     
214                     //this.log("parseScope GOT VAR/CONST : " + token.toString()); 
215                     while (true) {
216                         token = this.ts.nextTok();
217                         !this.debug|| print( token.toString());
218                       
219                         if (!token) { // can return false at EOF!
220                             break;
221                         }
222                         if (token.name == "VAR") { // kludge..
223                             continue;
224                         }
225                         //this.logR("parseScope GOT VAR  : <B>" + token.toString() + "</B>"); 
226                         if (token.type !="NAME") {
227                             print(token.toString());
228                             print( "var without ident");
229                             Seed.quit()
230                         }
231                         
232
233                         if (this.mode == "BUILDING_SYMBOL_TREE") {
234                             identifier = scope.getIdentifier(token.data) ;
235                             
236                             if (identifier == false) {
237                                 scope.declareIdentifier(token.data, token);
238                             } else {
239                                 token.identifier = identifier;
240                                 this.warn("The variable " + token.data  + ' (line:' + token.line + ")  has already been declared in the same scope...");
241                             }
242                         }
243
244                         token = this.ts.nextTok();
245                         !this.debug|| print(token.toString());
246                         /*
247                         assert token.getType() == Token.SEMI ||
248                                 token.getType() == Token.ASSIGN ||
249                                 token.getType() == Token.COMMA ||
250                                 token.getType() == Token.IN;
251                         */
252                         if (token.name == "IN") {
253                             break;
254                         } else {
255                             this.parseExpression();
256                             //this.logR("parseScope DONE  : <B>ParseExpression</B> - tok is:" + this.ts.lookT(0).toString()); 
257                             
258                             token = this.ts.lookTok(1);
259                             !this.debug|| print("AFTER EXP: " + token.toString());
260                             if (token.data == ';') {
261                                 break;
262                             }
263                         }
264                     }
265                     break;
266                 case "KEYW.FUNCTION":
267                     //println("<i>"+token.data+"</i>");
268                     this.parseFunctionDeclaration();
269                     break;
270
271                 case "KEYW.LEFT_CURLY": // {
272                     //println("<i>"+token.data+"</i>");
273                     isObjectLitAr.push(false);
274                     this.braceNesting++;
275                     break;
276
277                 case "KEYW.RIGHT_CURLY": // }
278                     //println("<i>"+token.data+"</i>");
279                     this.braceNesting--;
280                     isObjectLitAr.pop();
281                         //assert braceNesting >= scope.getBraceNesting();
282                     if (this.braceNesting == scope.braceN) {
283                         var ls = this.scopes.pop();
284                         ls.getUsedSymbols();
285                         return;
286                     }
287                     break;
288
289                 case "KEYW.WITH":
290                     //println("<i>"+token.data+"</i>");   
291                     if (this.mode == "BUILDING_SYMBOL_TREE") {
292                         // Inside a 'with' block, it is impossible to figure out
293                         // statically whether a symbol is a local variable or an
294                         // object member. As a consequence, the only thing we can
295                         // do is turn the obfuscation off for the highest scope
296                         // containing the 'with' block.
297                         this.protectScopeFromObfuscation(scope);
298                         this.warn("Using 'with' is not recommended." + (this.munge ? " Moreover, using 'with' reduces the level of compression!" : ""), true);
299                     }
300                     break;
301
302                 case "KEYW.CATCH":
303                     //println("<i>"+token.data+"</i>");
304                     this.parseCatch();
305                     break;
306                 /*
307                 case Token.SPECIALCOMMENT:
308                         if (mode == BUILDING_SYMBOL_TREE) {
309                             protectScopeFromObfuscation(scope);
310                             this.warn("Using JScript conditional comments is not recommended." + (munge ? " Moreover, using JScript conditional comments reduces the level of compression." : ""), true);
311                         }
312                         break;
313                 */
314                 
315                 case "STRN.DOUBLE_QUOTE": // used for object lit detection..
316                 case "STRN.SINGLE_QUOTE":
317                     //println("<i>"+token.data+"</i>");
318                     if (this.ts.lookTok(-1).data == '{' && this.ts.lookTok(1).data == ':') {
319                         // then we are in an object lit.. -> we need to flag the brace as such...
320                         isObjectLitAr.pop();
321                         isObjectLitAr.push(true);
322                     }
323                     isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
324                     
325                     if (isInObjectLitAr &&  this.ts.lookTok(1).data == ':' &&
326                         ( this.ts.lookTok(-1).data == '{'  ||  this.ts.lookTok(-1).data == ':' )) {
327                         // see if we can replace..
328                         // remove the quotes..
329                         // should do a bit more checking!!!! (what about wierd char's in the string..
330                         var str = token.data.substring(1,token.data.length-1);
331                         if (/^[a-z_]+$/i.test(str) && ScopeParser.idents.indexOf(str) < 0) {
332                             token.outData = str;
333                         }
334                         
335                          
336                         
337                     }
338                     
339                     
340                     
341                     break;
342                 
343                 case "NAME.NAME":
344                 
345                     //print("DEAL WITH NAME:");
346                     // got identifier..
347                     
348                     // look for  { ** : <- indicates obj literal.. ** this could occur with numbers ..
349                     if ((this.ts.lookTok(-1).data == "{") && (this.ts.lookTok(1).data == ":")) {
350                         isObjectLitAr.pop();
351                         isObjectLitAr.push(true);
352                         //println("<i>"+token.data+"</i>");
353                         break;
354                     }
355                    // print("DEAL WITH obj lit:");
356                     isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
357                     
358                     if (isInObjectLitAr && (this.ts.lookTok(1).data == ":") && (this.ts.lookTok(-1).data == ",")) {
359                         // skip, it's an object lit key..
360                         //println("<i>"+token.data+"</i>");
361                         break;
362                     }
363                     
364                     
365                     // skip anyting with "." before it..!!
366                      
367                     if (this.ts.lookTok(-1).data == ".") {
368                         // skip, it's an object prop.
369                         //println("<i>"+token.data+"</i>");
370                         break;
371                     }
372                     symbol = token.data;
373                     if (this.mode == 'PASS2_SYMBOL_TREE') {
374                         
375                         //println("GOT IDENT: -2 : " + this.ts.lookT(-2).toString() + " <BR> ..... -1 :  " +  this.ts.lookT(-1).toString() + " <BR> "); 
376                         
377                         //print ("MUNGE?" + symbol);
378                         
379                         //println("GOT IDENT: <B>" + symbol + "</B><BR/>");
380                              
381                             //println("GOT IDENT (2): <B>" + symbol + "</B><BR/>");
382                         identifier = this.getIdentifier(symbol, scope);
383                         
384                         if (identifier == false) {
385 // BUG!find out where builtin is defined...
386                             if (symbol.length <= 3 &&  Scope.builtin.indexOf(symbol) < 0) {
387                                 // Here, we found an undeclared and un-namespaced symbol that is
388                                 // 3 characters or less in length. Declare it in the global scope.
389                                 // We don't need to declare longer symbols since they won't cause
390                                 // any conflict with other munged symbols.
391                                 this.globalScope.declareIdentifier(symbol, token);
392                                 this.warn("Found an undeclared symbol: " + symbol + ' (line:' + token.line + ')', true);
393                             }
394                             
395                             //println("GOT IDENT IGNORE(3): <B>" + symbol + "</B><BR/>");
396                         } else {
397                             token.identifier = identifier;
398                             identifier.refcount++;
399                         }
400                     }   
401                     
402                     break;
403                     //println("<B>SID</B>");
404                 default:
405                     if (token.type != 'KEYW') {
406                         break;
407                     }
408                    // print("Check eval:");
409                 
410                     symbol = token.data;
411                     
412                      if (this.mode == 'BUILDING_SYMBOL_TREE') {
413
414                         if (symbol == "eval") {
415                             // look back one and see if we can find a comment!!!
416                             if (this.ts.look(-1).type == "COMM") {
417                                 // look for eval:var:noreplace\n
418                                 var _t = this;
419                                 this.ts.look(-1).data.replace(/eval:var:([a-z_]+)/ig, function(m, a) {
420                                     
421                                     var hi = _t.getIdentifier(a, scope);
422                                    // println("PROTECT "+a+" from munge" + (hi ? "FOUND" : "MISSING"));
423                                     if (hi) {
424                                      //   println("PROTECT "+a+" from munge");
425                                         hi.toMunge = false;
426                                     }
427                                     
428                                 });
429                                 
430                                 
431                             } else {
432                                 
433                             
434                                 this.protectScopeFromObfuscation(scope);
435                                 this.warn("Using 'eval' is not recommended. (use  eval:var:noreplace in comments to optimize) " + (this.munge ? " Moreover, using 'eval' reduces the level of compression!" : ""), true);
436                             }
437
438                         }
439
440                     }
441                     break;
442                 
443                 
444             } // end switch
445             
446             
447             //this.timerPrint("parseScope TOK : " + token.toString()); 
448             token = this.ts.nextTok();
449             //if (this.ts.nextT()) break;
450             
451         }
452     },
453
454
455     parseExpression : function() {
456
457         // Parse the expression until we encounter a comma or a semi-colon
458         // in the same brace nesting, bracket nesting and paren nesting.
459         // Parse functions if any...
460         //println("<i>EXP</i><BR/>");
461         !this.debug || print("PARSE EXPR");
462         var symbol;
463         var token;
464         var currentScope;
465         var identifier;
466
467         var expressionBraceNesting = this.braceNesting;
468         var bracketNesting = 0;
469         var parensNesting = 0;
470         var isInObjectLitAr;
471         var isObjectLitAr = [ false ];
472         while (token = this.ts.lookTok()) {
473      
474
475             
476             currentScope = this.scopes[this.scopes.length-1];
477             
478             //println("<i>"+token.data+"</i>");
479             !this.debug|| print ("EXP" + token.toString());
480             switch (token.type) {
481                 case 'PUNC':
482                     switch(token.data) {
483                          
484                         case ';':
485                         case ',':
486                             if (this.braceNesting == expressionBraceNesting &&
487                                     bracketNesting == 0 &&
488                                     parensNesting == 0) {
489                                 
490                                 return;
491                             }
492                             break;
493
494                        
495
496                         case '{': //Token.LC:
497                             isObjectLitAr.push(false);
498                             
499                             this.braceNesting++;
500                             break;
501
502                         case '}': //Token.RC:
503                             this.braceNesting--;
504                             isObjectLitAr.pop();
505                             
506                            // assert braceNesting >= expressionBraceNesting;
507                             break;
508
509                         case '[': //Token.LB:
510                             bracketNesting++;
511                             break;
512
513                         case ']': //Token.RB:
514                             bracketNesting--;
515                             break;
516
517                         case '(': //Token.LP:
518                             parensNesting++;
519                             break;
520
521                         case ')': //Token.RP:
522                             parensNesting--;
523                             break;
524                     }
525                     break;
526                     
527                 case 'STRN': // used for object lit detection..
528                     if (this.ts.lookTok(-1).data == "{" && this.ts.lookTok(1).data == ":" ) {
529                         // then we are in an object lit.. -> we need to flag the brace as such...
530                         isObjectLitAr.pop();
531                         isObjectLitAr.push(true);
532                     }
533                     
534                     
535                      
536                     isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
537                     if (isInObjectLitAr &&  this.ts.lookTok(1).data == ":"  &&
538                         ( this.ts.lookTok(-1).data == "{"  ||  this.ts.lookTok(-1).data == "," )) {
539                         // see if we can replace..
540                         // remove the quotes..
541                         var str = token.data.substring(1,token.data.length-1);
542                         if (/^[a-z_]+$/i.test(str) && ScopeParser.idents.indexOf(str) < 0) {
543                             token.outData = str;
544                         }
545                         
546                          
547                         
548                     }
549                     
550                     break;
551                 
552                       
553              
554                 case 'NAME':
555                
556                     symbol = token.data;
557                     if (this.ts.lookTok(-1).data == "{"  && this.ts.lookTok(1).data == ":") {
558                         // then we are in an object lit.. -> we need to flag the brace as such...
559                         isObjectLitAr.pop();
560                         isObjectLitAr.push(true);
561                         break;
562                     }
563                     isInObjectLitAr = isObjectLitAr[isObjectLitAr.length-1];
564                     if (isInObjectLitAr && this.ts.lookTok(-1).data == "," && this.ts.lookTok(1).data == ":") {
565                         break;
566                     }
567                     
568                     if (this.ts.lookTok(-1).data == ".") {
569                         //skip '.'
570                         break;
571                     }
572                     
573                      if (this.mode == 'PASS2_SYMBOL_TREE') {
574
575                         identifier = this.getIdentifier(symbol, currentScope);
576                         //println("<B>??</B>");
577                         if (identifier == false) {
578
579                             if (symbol.length <= 3 &&  Scope.builtin.indexOf(symbol) < 0) {
580                                 // Here, we found an undeclared and un-namespaced symbol that is
581                                 // 3 characters or less in length. Declare it in the global scope.
582                                 // We don't need to declare longer symbols since they won't cause
583                                 // any conflict with other munged symbols.
584                                 this.globalScope.declareIdentifier(symbol, token);
585                                 this.warn("Found an undeclared symbol: " + symbol + ' (line:' + token.line + ')', true);
586                             } else {
587                                 //println("undeclared")
588                             }
589                             
590                             
591                         } else {
592                             //println("<B>++</B>");
593                             token.identifier = identifier;
594                             identifier.refcount++;
595                         }
596                         
597                     }
598                     break;
599                     
600                     
601                     
602                     
603                     //println("<B>EID</B>");
604                  case 'KEYW':   
605                  
606                     if (token.name == "FUNCTION") {
607                         
608                         this.parseFunctionDeclaration();
609                         break;
610                     }
611                
612                     
613              
614                     symbol = token.data;
615                     if (this.mode == 'BUILDING_SYMBOL_TREE') {
616
617                         if (symbol == "eval") {
618                             if (this.ts.look(-1).type == 'COMM') {
619                                 // look for eval:var:noreplace\n
620                                 var _t = this;
621                                 this.ts.look(-1).data.replace(/eval:var:([a-z]+)/ig, function(m, a) {
622                                     var hi = _t.getIdentifier(a, currentScope);
623                                    //println("PROTECT "+a+" from munge" + (hi ? "FOUND" : "MISSING"));
624                                     if (hi) {
625                                       //  println("PROTECT "+a+" from munge");
626                                         hi.toMunge = false;
627                                     }
628                                     
629                                     
630                                 });
631                                 
632                             } else {
633                                 this.protectScopeFromObfuscation(currentScope);
634                                 this.warn("Using 'eval' is not recommended." + (this.munge ? " Moreover, using 'eval' reduces the level of compression!" : ""), true);
635                             }
636                             
637
638                         }
639                         break;
640                     } 
641                    
642             }
643             if (!this.ts.nextTok()) break;
644         }
645     },
646
647
648     parseCatch : function() {
649
650         var symbol;
651         var token;
652         var currentScope;
653         var identifier;
654
655         //token = getToken(-1);
656         //assert token.getType() == Token.CATCH;
657         token = this.ts.nextTok();
658         //assert token.getType() == Token.LP; (
659         token = this.ts.nextTok();
660         //assert token.getType() == Token.NAME;
661         
662         symbol = token.data;
663         currentScope = this.scopes[this.scopes.length-1];
664
665         if (this.mode == 'BUILDING_SYMBOL_TREE') {
666             // We must declare the exception identifier in the containing function
667             // scope to avoid errors related to the obfuscation process. No need to
668             // display a warning if the symbol was already declared here...
669             currentScope.declareIdentifier(symbol, token);
670         } else {
671             //?? why inc the refcount?? - that should be set when building the tree???
672             identifier = this.getIdentifier(symbol, currentScope);
673             identifier.refcount++;
674         }
675
676         token = this.ts.nextTok();
677         //assert token.getType() == Token.RP; // )
678     },
679     
680     parseFunctionDeclaration : function() 
681     {
682        // print("PARSE FUNCTION");
683         var symbol;
684         var token;
685         var currentScope  = false; 
686         var fnScope = false;
687         var identifier;
688         //this.logR("<B>PARSING FUNCTION</B>");
689         currentScope = this.scopes[this.scopes.length-1];
690
691         token = this.ts.nextTok();
692         if (token.type == "NAME") {
693             if (this.mode == 'BUILDING_SYMBOL_TREE') {
694                 // Get the name of the function and declare it in the current scope.
695                 symbol = token.data;
696                 if (currentScope.getIdentifier(symbol) != false) {
697                     this.warn("The function " + symbol + " has already been declared in the same scope...", true);
698                 }
699                 currentScope.declareIdentifier(symbol,token);
700             }
701             token =  this.ts.nextTok();
702         }
703
704         //assert token.getType() == Token.LP;
705         if (this.mode == 'BUILDING_SYMBOL_TREE') {
706             fnScope = new Scope(this.braceNesting, currentScope, token.n, '');
707             
708             //println("STORING SCOPE" + this.ts.cursor);
709             
710             this.indexedScopes[this.ts.cursor] = fnScope;
711             
712         } else {
713             //println("FETCHING SCOPE" + this.ts.cursor);
714             fnScope = this.indexedScopes[this.ts.cursor];
715         }
716         
717         // Parse function arguments.
718         var argpos = 0;
719         while (this.ts.lookTok().data != ')') { //(token = consumeToken()).getType() != Token.RP) {
720             token = this.ts.nextTok();
721            // print ("FUNC ARGS: " + token.toString())
722             //assert token.getType() == Token.NAME ||
723             //        token.getType() == Token.COMMA;
724             if (token.type == 'NAME' && this.mode == 'BUILDING_SYMBOL_TREE') {
725                 symbol = token.data;
726                 identifier = fnScope.declareIdentifier(symbol,token);
727                 if (symbol == "$super" && argpos == 0) {
728                     // Exception for Prototype 1.6...
729                     identifier.preventMunging();
730                 }
731                 argpos++;
732             }
733         }
734
735         token = this.ts.nextTok();
736         // assert token.getType() == Token.LC;
737         this.braceNesting++;
738
739         token = this.ts.nextTok();
740         if (token.type == "STRN" && this.ts.lookTok(1).data == ';') {
741             /*
742             
743             NOT SUPPORTED YET!?!!?!
744             
745             // This is a hint. Hints are empty statements that look like
746             // "localvar1:nomunge, localvar2:nomunge"; They allow developers
747             // to prevent specific symbols from getting obfuscated (some heretic
748             // implementations, such as Prototype 1.6, require specific variable
749             // names, such as $super for example, in order to work appropriately.
750             // Note: right now, only "nomunge" is supported in the right hand side
751             // of a hint. However, in the future, the right hand side may contain
752             // other values.
753             consumeToken();
754             String hints = token.getValue();
755             // Remove the leading and trailing quotes...
756             hints = hints.substring(1, hints.length() - 1).trim();
757             StringTokenizer st1 = new StringTokenizer(hints, ",");
758             while (st1.hasMoreTokens()) {
759                 String hint = st1.nextToken();
760                 int idx = hint.indexOf(':');
761                 if (idx <= 0 || idx >= hint.length() - 1) {
762                     if (mode == BUILDING_SYMBOL_TREE) {
763                         // No need to report the error twice, hence the test...
764                         this.warn("Invalid hint syntax: " + hint, true);
765                     }
766                     break;
767                 }
768                 String variableName = hint.substring(0, idx).trim();
769                 String variableType = hint.substring(idx + 1).trim();
770                 if (mode == BUILDING_SYMBOL_TREE) {
771                     fnScope.addHint(variableName, variableType);
772                 } else if (mode == CHECKING_SYMBOL_TREE) {
773                     identifier = fnScope.getIdentifier(variableName);
774                     if (identifier != null) {
775                         if (variableType.equals("nomunge")) {
776                             identifier.preventMunging();
777                         } else {
778                             this.warn("Unsupported hint value: " + hint, true);
779                         }
780                     } else {
781                         this.warn("Hint refers to an unknown identifier: " + hint, true);
782                     }
783                 }
784             }
785             */
786         }
787
788         this.parseScope(fnScope);
789         // now pop it off the stack!!!
790        
791         
792         
793     },
794     
795     protectScopeFromObfuscation : function(scope) {
796             //assert scope != null;
797         
798         if (scope == this.globalScope) {
799             // The global scope does not get obfuscated,
800             // so we don't need to worry about it...
801             return;
802         }
803
804         // Find the highest local scope containing the specified scope.
805         while (scope && scope.parent != this.globalScope) {
806             scope = scope.parent;
807         }
808
809         //assert scope.getParentScope() == globalScope;
810         scope.preventMunging();
811     },
812     
813     getIdentifier: function(symbol, scope) {
814         var identifier;
815         while (scope != false) {
816             identifier = scope.getIdentifier(symbol);
817             //println("ScopeParser.getIdentgetUsedSymbols("+symbol+")=" + scope.getUsedSymbols().join(','));
818             if (identifier) {
819                 return identifier;
820             }
821             scope = scope.parent;
822         }
823         return false;
824     }
825 };