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