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