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