611e909d73b51b529837d033f9627d192f741a21
[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                         
365                         this.ts.nextTok(); /// ,
366                         this.ts.nextTok(); // {
367                         scopeName = fixAlias(scopeName);
368                         var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName);
369                         this.indexedScopes[this.ts.cursor] = fnScope;
370                         scope = fnScope;
371                         this.scopesIn(fnScope);
372                          
373                         locBraceNest++;
374                         //print(">>" +locBraceNest);
375                         continue; // no more processing..
376                     }
377                     
378                     
379                     // xxx = new yyy ( {
380                         
381                     // change scope to xxxx
382                     /*
383                     print(JSON.stringify([
384                         this.ts.lookTok(1).data ,
385                         this.ts.lookTok(2).name ,
386                         this.ts.lookTok(3).type ,
387                         this.ts.lookTok(4).data ,
388                         this.ts.lookTok(5).data 
389                     ], null, 4));
390                     */
391                     if ( this.ts.lookTok(1).data == '=' &&
392                         this.ts.lookTok(2).name == 'NEW' &&
393                         this.ts.lookTok(3).type == 'NAME' &&
394                         this.ts.lookTok(4).data == '(' &&
395                         this.ts.lookTok(5).data == '{' 
396                         ) {
397                         scopeName = token.data;
398                         if (this.currentDoc) {
399                             this.addSymbol(scopeName,false,'OBJECT');
400                             
401                         }
402                         
403                         this.ts.nextTok(); /// =
404                         this.ts.nextTok(); /// new
405                         this.ts.nextTok(); /// yyy
406                         this.ts.nextTok(); /// (
407                         this.ts.nextTok(); /// {
408                             
409                         scopeName = fixAlias(scopeName);
410                         var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName);
411                         this.indexedScopes[this.ts.cursor] = fnScope;
412                         scope = fnScope;
413                         this.scopesIn(fnScope);
414                          
415                         locBraceNest++;
416                         //print(">>" +locBraceNest);
417                         
418                         continue; // no more processing..
419                     }
420                     
421
422                     
423                     
424                     
425                     
426                     
427                     
428                     
429                     
430                     
431                     
432                     
433                     
434                     
435                     
436                     
437                     
438                     
439                     // eval can be prefixed with a hint hider for the compresser..
440                     if ((token.data == 'eval') || /\.eval$/.test(token.data)) {
441                         this.currentDoc = false;
442                         continue;
443                     }
444                     
445                     if (this.currentDoc) {
446                         //print(token.toString());
447                         
448                         // ident : function ()
449                         // ident = function ()
450                         var atype = 'OBJECT';
451                         
452                         if (((this.ts.lookTok(1).data == ':' )|| (this.ts.lookTok(1).data == '=')) &&
453                             (this.ts.lookTok(2).name == "FUNCTION")
454                             ) {
455                                 atype = 'FUNCTION';
456                         }
457                         
458                         //print("ADD SYM:" + atype + ":" + token.toString() + this.ts.lookTok(1).toString() + this.ts.lookTok(2).toString());
459                         
460                         this.addSymbol(
461                             this.ts.lookTok(-1).tokN == Script.TOKdot ? token.data :    fixAlias(token.data),
462                             false,
463                             atype);
464                         
465                     }
466                  
467                     
468                     continue; // dont care about other idents..
469                     
470                 }        
471                 if (token.type == "STRN")   {
472                     if (this.currentDoc) {
473                         this.addSymbol(token.data.substring(1,token.data.length-1),false,'OBJECT');
474
475                     }
476                 }
477             
478                 // really we only have to deal with object constructs and function calls that change the scope...
479                 
480                 
481                  if (token.name == 'FUNCTION') {
482                      
483                     // see if we have an unconsumed doc...
484                     
485                     if (this.currentDoc) {
486                             print(this.ts.dumpToCur());
487                             throw "Unhandled doc (TOKfunction)" + token.toString();
488                             //this.addSymbol(this.currentDoc.getTag('class')[0].name, true);
489
490                             //throw "Unconsumed Doc: (TOKrbrace)" + this.currentDoc.toSource();
491                     }
492                     
493                      
494                      
495                      
496                      
497                     /// foo = function() {} << really it set's the 'this' scope to foo.prototype
498                     //$this$=foo.prototype|$private$|foo.prototype
499         
500                     if (
501                             (this.ts.lookTok(-1).data == '=') && 
502                             (this.ts.lookTok(-2).type == 'NAME')
503                         ) {
504                         scopeName = this.ts.lookTok(-2).data;
505                         this.ts.balanceN('(');
506                         token = this.ts.nextTok(); // should be {
507                         //print("FOO=FUNCITON() {}" + this.ts.context() + "\n" + token.toString());
508                         
509                         
510                         scopeName = fixAlias(scopeName);
511                         var fnScope = new Scope(this.braceNesting, scope, token.n, 
512                             '$this$='+scopeName+'.prototype|$private$|'+scopeName+'.prototype');
513                             
514                         this.indexedScopes[this.ts.cursor] = fnScope;
515                         //scope = fnScope;
516                         //this.scopesIn(fnScope);
517                         this.parseScope(fnScope, aliases);
518                         
519                         
520                        
521                         locBraceNest++;
522                         //print(">>" +locBraceNest);
523                         continue; // no more processing..    
524                           
525                         
526                     }
527                         
528                 
529                 // foo = new function() {}
530                         // is this actually used much!?!?!
531                         //$private$
532                         
533                     if (
534                             (this.ts.lookTok(-1).name == 'NEW') && 
535                             (this.ts.lookTok(-2).data == '=') &&
536                             (this.ts.lookTok(-3).type = 'FUNCTION')
537                         ) {
538                         //scopeName = this.ts.look(-3).data;
539                         this.ts.balanceN(Script.TOKlparen);
540                         token = this.ts.nextTok(); // should be {
541                             scopeName = fixAlias(scopeName);
542                         var fnScope = new Scope(this.braceNesting, scope, token.n, '$private$');
543                         this.indexedScopes[this.ts.cursor] = fnScope;
544                         //scope = fnScope;
545                         //this.scopesIn(fnScope);
546                         this.parseScope(fnScope, aliases);
547                         
548                         locBraceNest++;
549                         //print(">>" +locBraceNest);
550                         continue; // no more processing..    
551                           
552                         
553                     }    
554                    
555                     
556     ///==== check/set isObjectLitAr ??                
557                     
558                     
559                  // foo: function() {}
560                         // no change to scoping..
561                         
562                     //print("checking for : function() {"); 
563                     //print( [this.ts.lookTok(-3).type , this.ts.lookTok(-2).type , this.ts.lookTok(-1).type ].join(":"));
564                     if (
565                             (this.ts.lookTok(-1).data == ':') && 
566                             (this.ts.lookTok(-2).type == 'NAME') &&
567                             (this.ts.lookTok(-3).data == '(' || this.ts.lookTok(-3).data== ',') 
568                         ) {
569                         //print("got for : function() {"); 
570                             
571                         //scopeName = this.ts.look(-3).data;
572                         this.ts.balanceN(Script.TOKlparen);
573                         //print(token.toString())
574                         token = this.ts.nextTok(); // should be {
575                         //print(token.toString())
576                         scopeName = fixAlias(scopeName);
577                         var fnScope = new Scope(this.braceNesting, scope, token.n, '');
578                         this.indexedScopes[this.ts.cursor] = fnScope;
579                         //scope = fnScope;
580                         //this.scopesIn(fnScope);
581                          this.parseScope(fnScope, aliases);
582                         locBraceNest++;
583                         //print(">>" +locBraceNest);
584                         continue; // no more processing..    
585                           
586                     } 
587                /// function foo() {} << really it set's the 'this' scope to foo.prototype
588                         //$this$=foo|$private$
589                         //$this$=foo
590                         
591                     if (
592                             (this.ts.lookTok(1).type == 'NAME') 
593                         ) {
594                         //scopeName = this.ts.look(-3).data;
595                         this.ts.balanceN('(');
596                         token = this.ts.nextTok(); // should be {
597                             
598                         var fnScope = new Scope(this.braceNesting, scope, token.n, '');
599                         this.indexedScopes[this.ts.cursor] = fnScope;
600                         //scope = fnScope;
601                         //this.scopesIn(fnScope);
602                         this.parseScope(fnScope, aliases);
603                         locBraceNest++;
604                         //print(">>" +locBraceNest);
605                         continue; // no more processing..    
606                           
607                     }
608                     
609                      
610                 // foo = new (function() { }
611                 // (function() { }
612                 // RETURN function(...) {
613                     
614                     if (
615                            // (this.ts.lookTok(-1).tokN == Script.TOKlparen) && 
616                             (this.ts.lookTok(1).name != 'NAME')   
617                             
618                         //    (this.ts.lookTok(-2).tokN == Script.TOKnew) &&
619                          //   (this.ts.lookTok(-3).tokN == Script.TOKassign) &&
620                          //   (this.ts.lookTok(-4).tokN == Script.TOKidentifier)
621                         ) {
622                         //scopeName = this.ts.look(-3).data;
623                         this.ts.balanceN('(');
624                         token = this.ts.nextTok(); // should be {
625                         var fnScope = new Scope(this.braceNesting, scope, token.n, '$private$');
626                         this.indexedScopes[this.ts.cursor] = fnScope;
627                         //scope = ;
628                         //this.scopesIn(fnScope);
629                          this.parseScope(fnScope, aliases);
630                         locBraceNest++;
631                         //print(">>" +locBraceNest);
632                         continue; // no more processing..    
633                           
634                         
635                     }
636                     
637                     
638                     print(this.ts.context());
639                     throw "dont know how to handle function syntax??";
640                     
641                     continue;
642                     
643                     
644                     
645                     
646                 } // end checking for TOKfunction
647                     
648                 if (token.data == '{') {
649                     
650                      // foo = { // !var!!!
651                         //$this$=foo|Foo
652                
653                 
654                     if (
655                             (this.ts.lookTok(-1).data == '=') &&
656                             (this.ts.lookTok(-2).type == 'NAME') &&
657                             (this.ts.lookTok(-3).nane != 'VAR')  
658                         ) {
659                             
660                             scopeName = this.ts.look(-2).data;
661                             scopeName = fixAlias(scopeName);
662                             var fnScope = new Scope(this.braceNesting, scope, token.n, 
663                                 '$this$='+scopeName + '|'+scopeName
664                             );
665                             this.indexedScopes[this.ts.cursor] = fnScope;
666                             scope = fnScope;
667                             this.scopesIn(fnScope);
668                             
669                               
670                             locBraceNest++;
671                             //print(">>" +locBraceNest);
672                             continue; // no more processing..   
673                     }
674                     // foo : {
675                     // ?? add |foo| ????
676                       
677                     //print("GOT LBRACE : check for :");
678                     if (
679                             (this.ts.lookTok(-1).data == ':') &&
680                             (this.ts.lookTok(-2).type == 'NAME') &&
681                             (this.ts.lookTok(-3).name != 'VAR') 
682                         ) {
683                             
684                             scopeName = this.ts.lookTok(-2).data;
685                             scopeName = fixAlias(scopeName);
686                             var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName);
687                             this.indexedScopes[this.ts.cursor] = fnScope;
688                             scope = fnScope;
689                             this.scopesIn(fnScope);
690                             
691                             locBraceNest++;
692                             //print(">>" +locBraceNest);
693                             continue; // no more processing..   
694                     }
695                     var fnScope = new Scope(this.braceNesting, scope, token.n, '');
696                     this.indexedScopes[this.ts.cursor] = fnScope;
697                     scope = fnScope;
698                     this.scopesIn(fnScope);
699                    
700                     locBraceNest++;
701                     //print(">>" +locBraceNest);
702                     continue;
703                     
704                 }
705                 if (token.data == '{') {
706                     
707                      
708                         if (this.currentDoc) {
709                             this.addSymbol('', true);
710
711                             //throw "Unconsumed Doc: (TOKrbrace)" + this.currentDoc.toSource();
712                         }
713                         
714                        
715                         locBraceNest--;
716                         
717                             //assert braceNesting >= scope.getBraceNesting();
718                         var closescope = this.scopeOut();   
719                         scope = this.scopes[this.scopes.length-1];
720                         //print("<<:" +  locBraceNest)
721                         //print("<<<<<< " + locBraceNest );
722                         if (locBraceNest < 0) {
723                            // print("POPED OF END OF SCOPE!");
724                             ///this.scopeOut();   
725                             //var ls = this.scopeOut();
726                             //ls.getUsedSymbols();
727                             return;
728                         }
729                         continue;
730                 }
731               
732                 
733             }
734             
735             
736         },
737      
738          
739         addSymbol: function(lastIdent, appendIt, atype )
740         {
741             
742             /*if (!this.currentDoc.tags.length) {
743                 
744               
745                 //print(this.currentDoc.toSource());
746                 //  this.currentDoc = false;
747                 
748                 print("SKIP ADD SYM: no tags");
749                 print(this.currentDoc.src);
750                 return;
751             }
752             */
753             if (this.currentDoc.getTag('private').length) {
754                 
755               
756                 //print(this.currentDoc.toSource());
757                  this.currentDoc = false;
758                 print("SKIP ADD SYM:  it's private");
759                 return;
760             }
761             
762             var token = this.ts.cur();
763             if (typeof(appendIt) == 'undefined') {
764                 appendIt= false;
765             }
766           //  print(this.currentDoc.toSource(););
767             if (this.currentDoc.getTag('event').length) {
768                 //?? why does it end up in desc - and not name/...
769                 print(this.currentDoc.getTag('event')[0]);
770                 lastIdent = '*' + this.currentDoc.getTag('event')[0].desc;
771                 //lastIdent = '*' + lastIdent ;
772             }
773             if (!lastIdent.length && this.currentDoc.getTag('property').length) {
774                 lastIdent = this.currentDoc.getTag('property')[0].name;
775                 //lastIdent = '*' + lastIdent ;
776             }
777             
778             var _s = lastIdent;
779             if (!/\./.test(_s)) {
780                     
781                 //print("WALKER ADDsymbol: " + lastIdent);
782                 
783                 var s = [];
784                 for (var i = 0; i < this.scopes.length;i++) {
785                     s.push(this.scopes[i].ident);
786                 }
787                 s.push(lastIdent);
788                 
789                 var s = s.join('|').split('|');
790                print("Walker:ADDSymbol: " + s.join('|') );
791                 var _t = '';
792                  _s = '';
793                 
794                 /// fixme - needs
795                 for (var i = 0; i < s.length;i++) {
796                     
797                     if (!s[i].length) {
798                         continue;
799                     }
800                     if ((s[i] == '$private$') || (s[i] == '$global$')) {
801                         _s = '';
802                         continue;
803                     }
804                     if (s[i].substring(0,6) == '$this$') {
805                         var ts = s[i].split('=');
806                         _t = ts[1];
807                         continue;
808                     }
809                     // when to use $this$ (probabl for events)
810                     _s += _s.length ? '.' : '';
811                     _s += s[i];
812                 }
813                     
814                 
815                 /// calc scope!!
816                 //print("ADDING SYMBOL: "+ s.join('|') +"\n"+ _s + "\n" +Script.prettyDump(this.currentDoc.toSource()));
817                 
818                 if (appendIt && !lastIdent.length) {
819                     
820                     // append, and no symbol???
821                     
822                     // see if it's a @class
823                     if (this.currentDoc.getTag('class').length) {
824                         _s = this.currentDoc.getTag('class')[0].desc;
825                         var symbol = new Symbol(_s, [], "CONSTRUCTOR", this.currentDoc);
826                         Parser.addSymbol(symbol);
827                         this.symbols[_s] = symbol;
828                         return;
829                     }
830                     
831                    // if (this.currentDoc.getTag('property').length) {
832                      //   print(Script.pretStringtyDump(this.currentDoc.toSource));
833                     //    throw "Add Prop?";
834                     //}
835                     
836                     _s = _s.replace(/\.prototype.*$/, '');
837                     if (typeof(this.symbols[_s]) == 'undefined') {
838                         print("Symbol:" + _s);
839                         print(this.currentDoc.src);
840                         
841                         throw "Trying to append symbol, but no doc available";
842                     }
843                         
844                     for (var i =0; i < this.currentDoc.tags.length;i++) {
845                         this.symbols[_s].addDocTag(this.currentDoc.tags[i]);
846                     }
847                     this.currentDoc = false;
848                     return;
849                 }
850             }    
851             if (typeof(this.symbols[_s]) != 'undefined') {
852                 
853                 if (this.symbols[_s].comment.hasTags) {
854                     // then existing comment doesnt has tags 
855                      throw "DUPLICATE Symbol " + _s;
856                 }
857                 // otherwise existing comment has tags - overwrite..
858                 
859                 
860             }
861             if (typeof(atype) == "undefined") {
862                 atype = 'OBJECT'; //this.currentDoc.getTag('class').length ? 'OBJECT' : 'FUNCTION';;
863                }
864             
865             var symbol = new Symbol(_s, [], atype, this.currentDoc);
866             
867             Parser.addSymbol(symbol);
868             this.symbols[_s] = symbol;
869             
870              this.currentDoc = false;
871             
872         },
873         
874         
875         
876         
877         scopesIn : function(s)
878         {
879             this.scopes.push(s);
880             //print(">>>" + this.ts.context()  + "\n>>>"+this.scopes.length+":" +this.scopeListToStr());
881             
882         },
883         scopeOut : function()
884         {
885             
886            // print("<<<" + this.ts.context()  + "\n<<<"+this.scopes.length+":" +this.scopeListToStr());
887             return this.scopes.pop();
888             
889         },
890         
891         scopeListToStr : function()
892         {
893             var s = [];
894             for (var i = 0; i < this.scopes.length;i++) {
895                 s.push(this.scopes[i].ident);
896             }
897             return  s.join('\n\t');
898             
899         }
900         
901     
902     
903      
904 });