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