95bd7d4180b5f87687233a2e944be024304969a3
[gnome.introspection-doc-generator] / JSDOC / Walker2.js
1 //<Script type="text/javascript">
2 XObject
3 Scope
4 DocComment
5 Symbol
6 Parser
7 /**
8 * Scope stuff
9
10 * // FIXME - I need this to do next() without doccomments..
11 */
12
13 Walker2 = XObject.define(
14     function(ts) {
15         this.ts = ts;
16         this.warnings = [];
17         this.scopes = [];
18         this.indexedScopes = {};
19         this.symbols = {};
20         //this.timer = new Date() * 1;
21        
22     },
23     Object,
24     
25     {
26     /*
27         timer: 0,
28         timerPrint: function (str) {
29             var ntime = new Date() * 1;
30             var tdif =  ntime -this.timer;
31             this.timer = ntime;
32             var pref = '';
33             if (tdif > 100) { //slower ones..
34                 pref = '***';
35             }
36             print(pref+'['+tdif+']'+str);
37             
38         },
39         */
40         warn: function(s) {
41             //this.warnings.push(s);
42             print("WARNING:" + htmlescape(s) + "<BR>");
43         },
44         // defaults should not be initialized here =- otherwise they get duped on new, rather than initalized..
45         warnings : false,
46         ts : false,
47         scopes : false,
48         global : false,
49         mode : "", //"BUILDING_SYMBOL_TREE",
50         braceNesting : 0,
51         indexedScopes : false,
52         munge: true,
53         symbols: false, /// object store of sumbols..
54
55
56
57
58         buildSymbolTree : function()
59         {
60             //print("<PRE>");
61             
62             this.ts.rewind();
63             this.braceNesting = 0;
64             this.scopes = [];
65             this.aliases = {};
66              
67             this.globalScope = new Scope(-1, false, -1, '$global$');
68             indexedScopes = { 0 : this.globalScope };
69             
70             this.mode = 'BUILDING_SYMBOL_TREE';
71             this.parseScope(this.globalScope);
72         },
73         
74
75
76         log : function(str)
77         {
78               //print("<B>LOG:</B>" + htmlescape(str) + "<BR/>\n");
79         },
80         logR : function(str)
81         {
82                 //print("<B>LOG:</B>" + str + "<BR/>");
83         },
84
85        
86         currentDoc: false,
87
88
89         parseScope : function(scope, ealiases) // parse a token stream..
90         {
91             //this.timerPrint("parseScope EnterScope"); 
92             
93             var aliases = {};
94             var fixAlias = function(str, nomore)
95             {
96                 var ar = str.split('.');
97                 var m = ar.shift();
98                 
99                 //print(str +"?=" +aliases.toSource());
100                 if (aliases[m] == undefined) {
101                     return str;
102                 }
103                 var ret = aliases[m] + (ar.length? '.' : '' )+ ar.join('.');
104                 if (nomore !== true) {
105                     ret = fixAlias(ret, true);
106                 }
107                 
108                 
109                 
110                 return ret;
111             };
112
113             
114             
115             if (ealiases != undefined) {
116                 // copy it down..
117                 for(var i in ealiases) {
118                     aliases[i] = ealiases[i];
119                 }
120                 
121                 
122             } else {
123                 ealiases = {};
124             }
125             //print("STARTING SCOPE WITH: " + ealiases.toSource());
126             var symbol;
127             var token;
128             
129             var identifier;
130
131             var expressionBraceNesting = this.braceNesting;
132             var bracketNesting = 0;
133             var parensNesting = 0;
134            
135             
136             var l1 = '', l2 = '';
137             var scopeName ='';
138             
139             
140             var locBraceNest = 0;
141             // determines if we are in object literals...
142             
143             var isObjectLitAr = [ false ];
144             //print("SCOPE: ------------------START ----------------");
145             this.scopesIn(scope);
146             var scopeLen = this.scopes.length;
147             
148             if (this.ts.cursor < 1) {
149                 this.ts.cursor--; // hopeflly this kludge will work
150                }
151             
152             
153             
154             
155             while (false != (token = this.ts.next())) {
156                 //print("TOK"+ token.toString());
157                 //  this.timerPrint("parseScope AFTER lookT: " + token.toString()); 
158                   
159                 if (token.tokN == Script.TOKwhitespace) {
160                       
161                  
162                     if (!token._isDoc) {
163                         continue; //skip.
164                     }
165                     if (this.currentDoc) {
166                         // add it to the current scope????
167                         
168                         this.addSymbol('', true);
169
170                         
171                         //throw "Unconsumed Doc (TOKwhitespace): " + this.currentDoc.toSource();
172                     }
173                     
174                     
175                     var newDoc = new DocComment(token.data);
176                     
177                     // it's a scope changer..
178                     if (newDoc.getTag("scope").length) {
179                         //print(newDoc.getTag("scope").toSource());
180                         //throw "done";
181                         scope.ident = '$private$|' + newDoc.getTag("scope")[0].desc;
182                         continue;
183                     }
184                     
185                     // it's a scope changer..
186                     if (newDoc.getTag("scopeAlias").length) {
187                         //print(newDoc.getTag("scopeAlias").toSource());
188                         // @scopeAlias a=b
189                         var sal = newDoc.getTag("scopeAlias")[0].desc.split("=");
190                         aliases[sal[0]] = sal[1];
191                         
192                         continue;
193                     }
194                     
195                     
196                     /// got a  doc comment..
197                     //token.data might be this.??? (not sure though)
198                     this.currentDoc = newDoc;
199                     continue;
200                 }
201                 
202                 // catch the various issues .. - scoe changes or doc actions..
203                 
204               
205                 
206                 // things that stop comments carrying on...??
207                 
208                 if (this.currentDoc && (
209                         token.tokN == Script.TOKsemicolon || 
210                         token.tokN == Script.TOKrbrace)) {
211                     this.addSymbol('', true);
212                     //throw "Unconsumed Doc ("+ token.toString() +"): " + this.currentDoc.toSource();
213                 }
214                     
215                 
216                 // the rest are scoping issues...
217                 
218                 // var a = b;
219                 
220                  if (token.tokN == Script.TOKvar &&
221                  
222                         this.ts.lookT(1).tokN == Script.TOKidentifier &&
223                         this.ts.lookT(2).tokN == Script.TOKassign &&
224                         this.ts.lookT(3).tokN == Script.TOKidentifier  &&
225                         this.ts.lookT(4).tokN == Script.TOKsemicolon 
226                         
227                  
228                  ) {
229                     //print("SET ALIAS:" + this.ts.lookT(1).data +'=' + this.ts.lookT(3).data);
230                      
231                     aliases[this.ts.lookT(1).data] = this.ts.lookT(3).data;
232                     
233                 
234                 }
235                 
236                 
237               
238                 // extends scoping  *** not sure if the can be x = Roo.apply(....)
239                 // xxx.extends(a,b, {
240                     // $this$=b|b.prototype
241                 // xxx.apply(a, {
242                     // a  << scope
243                 // xxx.applyIf(a, {
244                     // a  << scope
245                 if (token.tokN == Script.TOKidentifier) {
246                     
247                     //print("TOK(ident)"+ token.toString());
248                     
249                     
250                        
251                     
252                     
253                     if (/\.extend$/.test(token.data) &&
254                         this.ts.lookT(1).tokN == Script.TOKlparen &&
255                         this.ts.lookT(2).tokN == Script.TOKidentifier &&
256                         this.ts.lookT(3).tokN == Script.TOKcomma &&
257                         this.ts.lookT(4).tokN == Script.TOKidentifier &&
258                         this.ts.lookT(5).tokN == Script.TOKcomma &&
259                         this.ts.lookT(6).tokN == Script.TOKlbrace  
260                         ) {
261                         // ignore test for ( a and ,
262                         this.ts.nextT(); /// (
263                         token = this.ts.nextT(); // a
264                         scopeName = token.data;
265                         
266                         if (this.currentDoc) {
267                             this.addSymbol(scopeName,false,'OBJECT');
268
269                         }
270                         this.ts.nextT(); // ,
271                         this.ts.nextT(); // b
272                         
273                         
274                         this.ts.nextT(); // ,
275                         token = this.ts.nextT(); // {
276                             
277                         scopeName = fixAlias(scopeName);
278                         
279                         var fnScope = new Scope(this.braceNesting, scope, token.n, 
280                             '$this$=' + scopeName  + '|'+scopeName+'.prototype');
281                         this.indexedScopes[this.ts.cursor] = fnScope;
282                         scope = fnScope;
283                         this.scopesIn(fnScope);
284                        
285                         locBraceNest++;
286                         //print(">>" +locBraceNest);
287                         continue; // no more processing..
288                         
289                     }
290                     
291                     // a = Roo.extend(parentname, {
292                         
293                      if (/\.extend$/.test(token.data) &&
294                         this.ts.lookT(-2).tokN == Script.TOKidentifier &&
295                         this.ts.lookT(-1).tokN == Script.TOKassign &&
296                         this.ts.lookT(1).tokN == Script.TOKlparen &&
297                         this.ts.lookT(2).tokN == Script.TOKidentifier &&
298                         this.ts.lookT(3).tokN == Script.TOKcomma &&
299                         this.ts.lookT(4).tokN == Script.TOKlbrace  
300                         ) {
301                         // ignore test for ( a and ,
302                         token = this.ts.lookT(-2);
303                         scopeName = token.data;
304                         if (this.currentDoc) {
305                             this.addSymbol(scopeName,false,'OBJECT');
306
307                         }
308                         this.ts.nextT(); /// (
309                         this.ts.nextT(); // parent
310                         
311                         this.ts.nextT(); // ,
312                         token =  this.ts.nextT(); // {
313                              
314                         
315                         scopeName = fixAlias(scopeName);
316                         var fnScope = new Scope(this.braceNesting, scope, token.n, 
317                             '$this$=' + scopeName  + '|'+scopeName+'.prototype');
318                         this.indexedScopes[this.ts.cursor] = fnScope;
319                         scope = fnScope;
320                         this.scopesIn(fnScope);
321                        
322                         locBraceNest++;
323                         //print(">>" +locBraceNest);
324                         continue; // no more processing..
325                         
326                     }
327                     
328                     
329                     
330                     if (/\.(applyIf|apply)$/.test(token.data) && 
331                         this.ts.lookT(1).tokN == Script.TOKlparen &&
332                         this.ts.lookT(2).tokN == Script.TOKidentifier &&
333                         this.ts.lookT(3).tokN == Script.TOKcomma &&
334                         this.ts.lookT(4).tokN == Script.TOKlbrace
335                         
336                         ) {
337                         this.ts.nextT(); /// (
338                          
339                         //print("GOT : applyIF!"); 
340                          
341                         token = this.ts.nextT(); // b
342                         scopeName = token.data;
343                         
344                                       
345                         if (this.currentDoc) {
346                             this.addSymbol(scopeName,false,'OBJECT');
347
348                         }
349                      
350
351                         
352                         this.ts.nextT(); /// ,
353                         this.ts.nextT(); // {
354                             scopeName = fixAlias(scopeName);
355                         var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName);
356                         this.indexedScopes[this.ts.cursor] = fnScope;
357                         scope = fnScope;
358                         this.scopesIn(fnScope);
359                          
360                         locBraceNest++;
361                         //print(">>" +locBraceNest);
362                         continue; // no more processing..
363                     }
364                     
365                     
366                     // xxx = new yyy ( {
367                         
368                     // change scope to xxxx
369                     
370                     if ( this.ts.lookT(1).tokN == Script.TOKassign &&
371                         this.ts.lookT(2).tokN == Script.TOKnew &&
372                         this.ts.lookT(3).tokN == Script.TOKidentifier &&
373                         this.ts.lookT(4).tokN == Script.TOKlparen &&
374                         this.ts.lookT(5).tokN == Script.TOKlbrace
375                         ) {
376                         scopeName = token.data;
377                         if (this.currentDoc) {
378                             this.addSymbol(scopeName,false,'OBJECT');
379                             
380                         }
381                         
382                         this.ts.nextT(); /// =
383                         this.ts.nextT(); /// new
384                         this.ts.nextT(); /// yyy
385                         this.ts.nextT(); /// (
386                         this.ts.nextT(); /// {
387                             
388                         scopeName = fixAlias(scopeName);
389                         var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName);
390                         this.indexedScopes[this.ts.cursor] = fnScope;
391                         scope = fnScope;
392                         this.scopesIn(fnScope);
393                          
394                         locBraceNest++;
395                         //print(">>" +locBraceNest);
396                         
397                         continue; // no more processing..
398                     }
399                     
400
401                     
402                     
403                     
404                     
405                     
406                     
407                     
408                     
409                     
410                     
411                     
412                     
413                     
414                     
415                     
416                     
417                     
418                     // eval can be prefixed with a hint hider for the compresser..
419                     if ((token.data == 'eval') || /\.eval$/.test(token.data)) {
420                         this.currentDoc = false;
421                         continue;
422                     }
423                     
424                     if (this.currentDoc) {
425                         //print(token.toString());
426                         
427                         // ident : function ()
428                         // ident = function ()
429                         var atype = 'OBJECT';
430                         
431                         if (((this.ts.lookT(1).tokN == Script.TOKcolon )|| (this.ts.lookT(1).tokN == Script.TOKassign)) &&
432                             (this.ts.lookT(2).tokN == Script.TOKfunction)
433                             ) {
434                                 atype = 'FUNCTION';
435                         }
436                         
437                         //print("ADD SYM:" + atype + ":" + token.toString() + this.ts.lookT(1).toString() + this.ts.lookT(2).toString());
438                         
439                         this.addSymbol(
440                             this.ts.lookT(-1).tokN == Script.TOKdot ? token.data :    fixAlias(token.data),
441                             false,
442                             atype);
443                         
444                     }
445                  
446                     
447                     continue; // dont care about other idents..
448                     
449                 }        
450                 if (token.tokN == Script.TOKstring)   {
451                     if (this.currentDoc) {
452                         this.addSymbol(token.data.substring(1,token.data.length-1),false,'OBJECT');
453
454                     }
455                 }
456             
457                 // really we only have to deal with object constructs and function calls that change the scope...
458                 
459                 
460                  if (token.tokN == Script.TOKfunction) {
461                      
462                     // see if we have an unconsumed doc...
463                     
464                     if (this.currentDoc) {
465                             print(this.ts.dumpToCur());
466                             throw "Unhandled doc (TOKfunction)" + token.toString();
467                             //this.addSymbol(this.currentDoc.getTag('class')[0].name, true);
468
469                             //throw "Unconsumed Doc: (TOKrbrace)" + this.currentDoc.toSource();
470                     }
471                     
472                      
473                      
474                      
475                      
476                     /// foo = function() {} << really it set's the 'this' scope to foo.prototype
477                     //$this$=foo.prototype|$private$|foo.prototype
478         
479                     if (
480                             (this.ts.lookT(-1).tokN == Script.TOKassign) && 
481                             (this.ts.lookT(-2).tokN == Script.TOKidentifier)
482                         ) {
483                         scopeName = this.ts.lookT(-2).data;
484                         this.ts.balanceN(Script.TOKlparen);
485                         token = this.ts.nextT(); // should be {
486                         //print("FOO=FUNCITON() {}" + this.ts.context() + "\n" + token.toString());
487                         
488                         
489                         scopeName = fixAlias(scopeName);
490                         var fnScope = new Scope(this.braceNesting, scope, token.n, 
491                             '$this$='+scopeName+'.prototype|$private$|'+scopeName+'.prototype');
492                         this.indexedScopes[this.ts.cursor] = fnScope;
493                         //scope = fnScope;
494                         //this.scopesIn(fnScope);
495                         this.parseScope(fnScope, aliases);
496                         
497                         
498                        
499                         locBraceNest++;
500                         //print(">>" +locBraceNest);
501                         continue; // no more processing..    
502                           
503                         
504                     }
505                         
506                 
507                 // foo = new function() {}
508                         // is this actually used much!?!?!
509                         //$private$
510                         
511                     if (
512                             (this.ts.lookT(-1).tokN == Script.TOKnew) && 
513                             (this.ts.lookT(-2).tokN == Script.TOKassign)
514                             (this.ts.lookT(-3).tokN == Script.TOKidentifier)
515                         ) {
516                         //scopeName = this.ts.look(-3).data;
517                         this.ts.balanceN(Script.TOKlparen);
518                         token = this.ts.nextT(); // should be {
519                             scopeName = fixAlias(scopeName);
520                         var fnScope = new Scope(this.braceNesting, scope, token.n, '$private$');
521                         this.indexedScopes[this.ts.cursor] = fnScope;
522                         //scope = fnScope;
523                         //this.scopesIn(fnScope);
524                         this.parseScope(fnScope, aliases);
525                         
526                         locBraceNest++;
527                         //print(">>" +locBraceNest);
528                         continue; // no more processing..    
529                           
530                         
531                     }    
532                    
533                     
534     ///==== check/set isObjectLitAr ??                
535                     
536                     
537                  // foo: function() {}
538                         // no change to scoping..
539                         
540                     //print("checking for : function() {"); 
541                     //print( [this.ts.lookT(-3).type , this.ts.lookT(-2).type , this.ts.lookT(-1).type ].join(":"));
542                     if (
543                             (this.ts.lookT(-1).tokN == Script.TOKcolon) && 
544                             (this.ts.lookT(-2).tokN == Script.TOKidentifier) &&
545                             (this.ts.lookT(-3).tokN == Script.TOKlbrace || this.ts.lookT(-3).tokN == Script.TOKcomma) 
546                         ) {
547                         //print("got for : function() {"); 
548                             
549                         //scopeName = this.ts.look(-3).data;
550                         this.ts.balanceN(Script.TOKlparen);
551                         //print(token.toString())
552                         token = this.ts.nextT(); // should be {
553                         //print(token.toString())
554                         scopeName = fixAlias(scopeName);
555                         var fnScope = new Scope(this.braceNesting, scope, token.n, '');
556                         this.indexedScopes[this.ts.cursor] = fnScope;
557                         //scope = fnScope;
558                         //this.scopesIn(fnScope);
559                          this.parseScope(fnScope, aliases);
560                         locBraceNest++;
561                         //print(">>" +locBraceNest);
562                         continue; // no more processing..    
563                           
564                     } 
565                /// function foo() {} << really it set's the 'this' scope to foo.prototype
566                         //$this$=foo|$private$
567                         //$this$=foo
568                         
569                     if (
570                             (this.ts.lookT(1).tokN == Script.TOKidentifier) 
571                         ) {
572                         //scopeName = this.ts.look(-3).data;
573                         this.ts.balanceN(Script.TOKlparen);
574                         token = this.ts.nextT(); // should be {
575                             
576                         var fnScope = new Scope(this.braceNesting, scope, token.n, '');
577                         this.indexedScopes[this.ts.cursor] = fnScope;
578                         //scope = fnScope;
579                         //this.scopesIn(fnScope);
580                         this.parseScope(fnScope, aliases);
581                         locBraceNest++;
582                         //print(">>" +locBraceNest);
583                         continue; // no more processing..    
584                           
585                     }
586                     
587                      
588                 // foo = new (function() { }
589                 // (function() { }
590                 // RETURN function(...) {
591                     
592                     if (
593                            // (this.ts.lookT(-1).tokN == Script.TOKlparen) && 
594                             (this.ts.lookT(1).tokN != Script.TOKidentifier)   
595                             
596                         //    (this.ts.lookT(-2).tokN == Script.TOKnew) &&
597                          //   (this.ts.lookT(-3).tokN == Script.TOKassign) &&
598                          //   (this.ts.lookT(-4).tokN == Script.TOKidentifier)
599                         ) {
600                         //scopeName = this.ts.look(-3).data;
601                         this.ts.balanceN(Script.TOKlparen);
602                         token = this.ts.nextT(); // should be {
603                         var fnScope = new Scope(this.braceNesting, scope, token.n, '$private$');
604                         this.indexedScopes[this.ts.cursor] = fnScope;
605                         //scope = ;
606                         //this.scopesIn(fnScope);
607                          this.parseScope(fnScope, aliases);
608                         locBraceNest++;
609                         //print(">>" +locBraceNest);
610                         continue; // no more processing..    
611                           
612                         
613                     }
614                     
615                     
616                     print(this.ts.context());
617                     throw "dont know how to handle function syntax??";
618                     
619                     continue;
620                     
621                     
622                     
623                     
624                 } // end checking for TOKfunction
625                     
626                 if (token.tokN == Script.TOKlbrace) {
627                     
628                      // foo = { // !var!!!
629                         //$this$=foo|Foo
630                
631                 
632                     if (
633                             (this.ts.lookT(-1).tokN == Script.TOKassign) &&
634                             (this.ts.lookT(-2).tokN == Script.TOKidentifier) &&
635                             (this.ts.lookT(-3).tokN != Script.TOKvar)  
636                         ) {
637                             
638                             scopeName = this.ts.look(-2).data;
639                             scopeName = fixAlias(scopeName);
640                             var fnScope = new Scope(this.braceNesting, scope, token.n, 
641                                 '$this$='+scopeName + '|'+scopeName
642                             );
643                             this.indexedScopes[this.ts.cursor] = fnScope;
644                             scope = fnScope;
645                             this.scopesIn(fnScope);
646                             
647                               
648                             locBraceNest++;
649                             //print(">>" +locBraceNest);
650                             continue; // no more processing..   
651                     }
652                     // foo : {
653                     // ?? add |foo| ????
654                       
655                     //print("GOT LBRACE : check for :");
656                     if (
657                             (this.ts.lookT(-1).tokN == Script.TOKcolon) &&
658                             (this.ts.lookT(-2).tokN == Script.TOKidentifier) &&
659                             (this.ts.lookT(-3).tokN != Script.TOKvar) 
660                         ) {
661                             
662                             scopeName = this.ts.lookT(-2).data;
663                             scopeName = fixAlias(scopeName);
664                             var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName);
665                             this.indexedScopes[this.ts.cursor] = fnScope;
666                             scope = fnScope;
667                             this.scopesIn(fnScope);
668                             
669                             locBraceNest++;
670                             //print(">>" +locBraceNest);
671                             continue; // no more processing..   
672                     }
673                     var fnScope = new Scope(this.braceNesting, scope, token.n, '');
674                     this.indexedScopes[this.ts.cursor] = fnScope;
675                     scope = fnScope;
676                     this.scopesIn(fnScope);
677                    
678                     locBraceNest++;
679                     //print(">>" +locBraceNest);
680                     continue;
681                     
682                 }
683                 if (token.tokN == Script.TOKrbrace) {
684                     
685                      
686                         if (this.currentDoc) {
687                             this.addSymbol('', true);
688
689                             //throw "Unconsumed Doc: (TOKrbrace)" + this.currentDoc.toSource();
690                         }
691                         
692                        
693                         locBraceNest--;
694                         
695                             //assert braceNesting >= scope.getBraceNesting();
696                         var closescope = this.scopeOut();   
697                         scope = this.scopes[this.scopes.length-1];
698                         //print("<<:" +  locBraceNest)
699                         //print("<<<<<< " + locBraceNest );
700                         if (locBraceNest < 0) {
701                            // print("POPED OF END OF SCOPE!");
702                             ///this.scopeOut();   
703                             //var ls = this.scopeOut();
704                             //ls.getUsedSymbols();
705                             return;
706                         }
707                         continue;
708                 }
709               
710                 
711             }
712             
713             
714         },
715      
716          
717         addSymbol: function(lastIdent, appendIt, atype )
718         {
719             
720             /*if (!this.currentDoc.tags.length) {
721                 
722               
723                 //print(this.currentDoc.toSource());
724                 //  this.currentDoc = false;
725                 
726                 print("SKIP ADD SYM: no tags");
727                 print(this.currentDoc.src);
728                 return;
729             }
730             */
731             if (this.currentDoc.getTag('private').length) {
732                 
733               
734                 //print(this.currentDoc.toSource());
735                  this.currentDoc = false;
736                 print("SKIP ADD SYM:  it's private");
737                 return;
738             }
739             
740             var token = this.ts.cur();
741             if (typeof(appendIt) == 'undefined') {
742                 appendIt= false;
743             }
744           //  print(this.currentDoc.toSource(););
745             if (this.currentDoc.getTag('event').length) {
746                 //?? why does it end up in desc - and not name/...
747                 print(this.currentDoc.getTag('event')[0]);
748                 lastIdent = '*' + this.currentDoc.getTag('event')[0].desc;
749                 //lastIdent = '*' + lastIdent ;
750             }
751             if (!lastIdent.length && this.currentDoc.getTag('property').length) {
752                 lastIdent = this.currentDoc.getTag('property')[0].name;
753                 //lastIdent = '*' + lastIdent ;
754             }
755             
756             var _s = lastIdent;
757             if (!/\./.test(_s)) {
758                     
759                 //print("WALKER ADDsymbol: " + lastIdent);
760                 
761                 var s = [];
762                 for (var i = 0; i < this.scopes.length;i++) {
763                     s.push(this.scopes[i].ident);
764                 }
765                 s.push(lastIdent);
766                 
767                 var s = s.join('|').split('|');
768                print("Walker:ADDSymbol: " + s.join('|') );
769                 var _t = '';
770                  _s = '';
771                 
772                 /// fixme - needs
773                 for (var i = 0; i < s.length;i++) {
774                     
775                     if (!s[i].length) {
776                         continue;
777                     }
778                     if ((s[i] == '$private$') || (s[i] == '$global$')) {
779                         _s = '';
780                         continue;
781                     }
782                     if (s[i].substring(0,6) == '$this$') {
783                         var ts = s[i].split('=');
784                         _t = ts[1];
785                         continue;
786                     }
787                     // when to use $this$ (probabl for events)
788                     _s += _s.length ? '.' : '';
789                     _s += s[i];
790                 }
791                     
792                 
793                 /// calc scope!!
794                 //print("ADDING SYMBOL: "+ s.join('|') +"\n"+ _s + "\n" +Script.prettyDump(this.currentDoc.toSource()));
795                 
796                 if (appendIt && !lastIdent.length) {
797                     
798                     // append, and no symbol???
799                     
800                     // see if it's a @class
801                     if (this.currentDoc.getTag('class').length) {
802                         _s = this.currentDoc.getTag('class')[0].desc;
803                         var symbol = new Symbol(_s, [], "CONSTRUCTOR", this.currentDoc);
804                         Parser.addSymbol(symbol);
805                         this.symbols[_s] = symbol;
806                         return;
807                     }
808                     
809                    // if (this.currentDoc.getTag('property').length) {
810                      //   print(Script.pretStringtyDump(this.currentDoc.toSource));
811                     //    throw "Add Prop?";
812                     //}
813                     
814                     _s = _s.replace(/\.prototype.*$/, '');
815                     if (typeof(this.symbols[_s]) == 'undefined') {
816                         print("Symbol:" + _s);
817                         print(this.currentDoc.src);
818                         
819                         throw "Trying to append symbol, but no doc available";
820                     }
821                         
822                     for (var i =0; i < this.currentDoc.tags.length;i++) {
823                         this.symbols[_s].addDocTag(this.currentDoc.tags[i]);
824                     }
825                     this.currentDoc = false;
826                     return;
827                 }
828             }    
829             if (typeof(this.symbols[_s]) != 'undefined') {
830                 
831                 if (this.symbols[_s].comment.hasTags) {
832                     // then existing comment doesnt has tags 
833                      throw "DUPLICATE Symbol " + _s;
834                 }
835                 // otherwise existing comment has tags - overwrite..
836                 
837                 
838             }
839             if (typeof(atype) == "undefined") {
840                 atype = 'OBJECT'; //this.currentDoc.getTag('class').length ? 'OBJECT' : 'FUNCTION';;
841                }
842             
843             var symbol = new Symbol(_s, [], atype, this.currentDoc);
844             
845             Parser.addSymbol(symbol);
846             this.symbols[_s] = symbol;
847             
848              this.currentDoc = false;
849             
850         },
851         
852         
853         
854         
855         scopesIn : function(s)
856         {
857             this.scopes.push(s);
858             //print(">>>" + this.ts.context()  + "\n>>>"+this.scopes.length+":" +this.scopeListToStr());
859             
860         },
861         scopeOut : function()
862         {
863             
864            // print("<<<" + this.ts.context()  + "\n<<<"+this.scopes.length+":" +this.scopeListToStr());
865             return this.scopes.pop();
866             
867         },
868         
869         scopeListToStr : function()
870         {
871             var s = [];
872             for (var i = 0; i < this.scopes.length;i++) {
873                 s.push(this.scopes[i].ident);
874             }
875             return  s.join('\n\t');
876             
877         }
878         
879     
880     
881      
882 });