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