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
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('COMM')) {
163                       
164                  
165                     if (token.name != 'JSDOC') {
166                         //print("Walker2 : spce is not JSDOC");
167                         continue; //skip.
168                     }
169                     if (this.currentDoc) {
170                         // add it to the current scope????
171                         
172                         this.addSymbol('', true);
173                         print ( "Unconsumed Doc: " + token.toString())
174                         //throw "Unconsumed Doc (TOKwhitespace): " + this.currentDoc.toSource();
175                     }
176                     
177                     print ( "NEW COMMENT: " + token.toString())
178                     var newDoc = new DocComment(token.data);
179                     
180                     // it's a scope changer..
181                     if (newDoc.getTag("scope").length) {
182                         //print("Walker2 : doctag changes scope");
183                         //throw "done";
184                         scope.ident = '$private$|' + newDoc.getTag("scope")[0].desc;
185                         continue;
186                     }
187                     
188                     // it's a scope changer..
189                     if (newDoc.getTag("scopeAlias").length) {
190                         //print(newDoc.getTag("scopeAlias").toSource());
191                         // @scopeAlias a=b
192                         //print("Walker2 : doctag changes scope (alias)");
193                         var sal = newDoc.getTag("scopeAlias")[0].desc.split("=");
194                         aliases[sal[0]] = sal[1];
195                         
196                         continue;
197                     }
198                     
199                     
200                     /// got a  doc comment..
201                     //token.data might be this.??? (not sure though)
202                     //print("Walker2 : setting currentDoc");
203                     this.currentDoc = newDoc;
204                     continue;
205                 }
206                 
207                 // catch the various issues .. - scoe changes or doc actions..
208                 
209               
210                 
211                 // things that stop comments carrying on...??
212                 
213                 if (this.currentDoc && (
214                         token.data == ';' || 
215                         token.data == '}')) {
216                     this.addSymbol('', true);
217                     //throw "Unconsumed Doc ("+ token.toString() +"): " + this.currentDoc.toSource();
218                 }
219                     
220                 
221                 // the rest are scoping issues...
222                 
223                 // var a = b;
224                 
225                  if (token.name == 'VAR' &&
226                  
227                         this.ts.lookTok(1).type == 'NAME' &&
228                         this.ts.lookTok(2).data == '-' &&
229                         this.ts.lookTok(3).type == 'NAME'  &&
230                         this.ts.lookTok(4).data == ';'  
231                         
232                  
233                  ) {
234                     //print("SET ALIAS:" + this.ts.lookTok(1).data +'=' + this.ts.lookTok(3).data);
235                      
236                     aliases[this.ts.lookTok(1).data] = this.ts.lookTok(3).data;
237                     
238                 
239                 }
240                 
241                 
242               
243                 // extends scoping  *** not sure if the can be x = Roo.apply(....)
244                 // xxx.extends(a,b, {
245                     // $this$=b|b.prototype
246                 // xxx.apply(a, {
247                     // a  << scope
248                 // xxx.applyIf(a, {
249                     // a  << scope
250                 if (token.type == 'NAME') {
251                     
252                     //print("TOK(ident)"+ token.toString());
253                      
254                     if (/\.extend$/.test(token.data) &&
255                         this.ts.lookTok(1).data == '(' &&
256                         this.ts.lookTok(2).type == 'NAME' &&
257                         this.ts.lookTok(3).data == ',' &&
258                         this.ts.lookTok(4).type == 'NAME' &&
259                         this.ts.lookTok(5).data == ',' &&
260                         this.ts.lookTok(6).data == '{' 
261                            
262                         ) {
263                         // ignore test for ( a and ,
264                         this.ts.nextTok(); /// (
265                         token = this.ts.nextTok(); // a
266                         scopeName = token.data;
267                         
268                         if (this.currentDoc) {
269                             this.addSymbol(scopeName,false,'OBJECT');
270
271                         }
272                         this.ts.nextTok(); // ,
273                         this.ts.nextTok(); // b
274                         
275                         
276                         this.ts.nextTok(); // ,
277                         token = this.ts.nextTok(); // {
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.lookTok(-2).type == 'NAME'  &&
297                         this.ts.lookTok(-1).data == '=' &&
298                         this.ts.lookTok(1).data == '(' &&
299                         this.ts.lookTok(2).type == 'NAME' &&
300                         this.ts.lookTok(3).data == ',' &&
301                         this.ts.lookTok(4).data == '{' 
302                         ) {
303                         // ignore test for ( a and ,
304                         token = this.ts.lookTok(-2);
305                         scopeName = token.data;
306                         if (this.currentDoc) {
307                             this.addSymbol(scopeName,false,'OBJECT');
308
309                         }
310                         this.ts.nextTok(); /// (
311                         this.ts.nextTok(); // parent
312                         
313                         this.ts.nextTok(); // ,
314                         token =  this.ts.nextTok(); // {
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                      // apply ( XXXX,  {
332                     /*
333                     print(JSON.stringify([
334                         token.data,
335                         this.ts.lookTok(1).data ,
336                         this.ts.lookTok(2).type ,
337                         this.ts.lookTok(3).data ,
338                         this.ts.lookTok(4).data 
339                     ], null, 4));
340                     */
341                     
342                     if (/\.(applyIf|apply)$/.test(token.data) && 
343                         this.ts.lookTok(1).data == '('  &&
344                         this.ts.lookTok(2).type == 'NAME' &&
345                         this.ts.lookTok(3).data == ','  &&
346                         this.ts.lookTok(4).data == '{' 
347                         
348                         ) {
349                         this.ts.nextTok(); /// (
350                          
351                         //print("GOT : applyIF!"); 
352                          
353                         token = this.ts.nextTok(); // b
354                         scopeName = token.data;
355                         
356                                       
357                         if (this.currentDoc) {
358                             this.addSymbol(scopeName,false,'OBJECT');
359                         }
360                      
361
362                         
363                         this.ts.nextTok(); /// ,
364                         this.ts.nextTok(); // {
365                         scopeName = fixAlias(scopeName);
366                         var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName);
367                         this.indexedScopes[this.ts.cursor] = fnScope;
368                         scope = fnScope;
369                         this.scopesIn(fnScope);
370                          
371                         locBraceNest++;
372                         //print(">>" +locBraceNest);
373                         continue; // no more processing..
374                     }
375                     
376                     
377                     // xxx = new yyy ( {
378                         
379                     // change scope to xxxx
380                     /*
381                     print(JSON.stringify([
382                         this.ts.lookTok(1).data ,
383                         this.ts.lookTok(2).name ,
384                         this.ts.lookTok(3).type ,
385                         this.ts.lookTok(4).data ,
386                         this.ts.lookTok(5).data 
387                     ], null, 4));
388                     */
389                     if ( this.ts.lookTok(1).data == '=' &&
390                         this.ts.lookTok(2).name == 'NEW' &&
391                         this.ts.lookTok(3).type == 'NAME' &&
392                         this.ts.lookTok(4).data == '(' &&
393                         this.ts.lookTok(5).data == '{' 
394                         ) {
395                         scopeName = token.data;
396                         if (this.currentDoc) {
397                             this.addSymbol(scopeName,false,'OBJECT');
398                             
399                         }
400                         
401                         this.ts.nextTok(); /// =
402                         this.ts.nextTok(); /// new
403                         this.ts.nextTok(); /// yyy
404                         this.ts.nextTok(); /// (
405                         this.ts.nextTok(); /// {
406                             
407                         scopeName = fixAlias(scopeName);
408                         var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName);
409                         this.indexedScopes[this.ts.cursor] = fnScope;
410                         scope = fnScope;
411                         this.scopesIn(fnScope);
412                          
413                         locBraceNest++;
414                         //print(">>" +locBraceNest);
415                         
416                         continue; // no more processing..
417                     }
418                     
419
420                      
421                     
422                     
423                     
424                     
425                     // eval can be prefixed with a hint hider for the compresser..
426                     if ((token.data == 'eval') || /\.eval$/.test(token.data)) {
427                         this.currentDoc = false;
428                         continue;
429                     }
430                     
431                     if (this.currentDoc) {
432                         //print(token.toString());
433                         
434                         // ident : function ()
435                         // ident = function ()
436                         var atype = 'OBJECT';
437                         
438                         if (((this.ts.lookTok(1).data == ':' )|| (this.ts.lookTok(1).data == '=')) &&
439                             (this.ts.lookTok(2).name == "FUNCTION")
440                             ) {
441                                 this.ts.nextTok();
442                                 this.ts.nextTok();
443                                 atype = 'FUNCTION';
444                         }
445                         
446                         //print("ADD SYM:" + atype + ":" + token.toString() + this.ts.lookTok(1).toString() + this.ts.lookTok(2).toString());
447                         
448                         this.addSymbol(
449                             this.ts.lookTok(-1).data == '.' ? token.data :    fixAlias(token.data),
450                             false,
451                             atype);
452                         
453                         
454                         
455                         
456                     }
457                  
458                     
459                     continue; // dont care about other idents..
460                     
461                 }
462                 
463                 //print ("NOT NAME");
464                 
465                 
466                 if (token.type == "STRN")   { // THIS WILL NOT HAPPEN HERE?!!?
467                     if (this.currentDoc) {
468                         this.addSymbol(token.data.substring(1,token.data.length-1),false,'OBJECT');
469
470                     }
471                 }
472             
473                 // really we only have to deal with object constructs and function calls that change the scope...
474                 
475                 
476                 if (token.name == 'FUNCTION') {
477                     //print("GOT FUNCTION");
478                     // see if we have an unconsumed doc...
479                     
480                     if (this.currentDoc) {
481                             throw {
482                                 name: "ArgumentError", 
483                                 message: "Unhandled doc (TOKfunction)" + token.toString()
484                             };
485                             
486                             //this.addSymbol(this.currentDoc.getTag('class')[0].name, true);
487
488                             //throw "Unconsumed Doc: (TOKrbrace)" + this.currentDoc.toSource();
489                     }
490                     
491                      
492                      
493                      
494                      
495                     /// foo = function() {} << really it set's the 'this' scope to foo.prototype
496                     //$this$=foo.prototype|$private$|foo.prototype
497         
498                     if (
499                             (this.ts.lookTok(-1).data == '=') && 
500                             (this.ts.lookTok(-2).type == 'NAME')
501                         ) {
502                         scopeName = this.ts.lookTok(-2).data;
503                         this.ts.balance('(');
504                         token = this.ts.nextTok(); // should be {
505                         //print("FOO=FUNCITON() {}" + this.ts.context() + "\n" + token.toString());
506                         
507                         
508                         scopeName = fixAlias(scopeName);
509                         var fnScope = new Scope(this.braceNesting, scope, token.n, 
510                             '$this$='+scopeName+'.prototype|$private$|'+scopeName+'.prototype');
511                             
512                         this.indexedScopes[this.ts.cursor] = fnScope;
513                         //scope = fnScope;
514                         //this.scopesIn(fnScope);
515                         this.parseScope(fnScope, aliases);
516                         
517                         
518                        
519                         locBraceNest++;
520                         //print(">>" +locBraceNest);
521                         continue; // no more processing..    
522                           
523                         
524                     }
525                         
526                 
527                 // foo = new function() {}
528                         // is this actually used much!?!?!
529                         //$private$
530                         
531                     if (
532                             (this.ts.lookTok(-1).name == 'NEW') && 
533                             (this.ts.lookTok(-2).data == '=') &&
534                             (this.ts.lookTok(-3).type = 'FUNCTION')
535                         ) {
536                         //scopeName = this.ts.look(-3).data;
537                         this.ts.balanceN(Script.TOKlparen);
538                         token = this.ts.nextTok(); // should be {
539                             scopeName = fixAlias(scopeName);
540                         var fnScope = new Scope(this.braceNesting, scope, token.n, '$private$');
541                         this.indexedScopes[this.ts.cursor] = fnScope;
542                         //scope = fnScope;
543                         //this.scopesIn(fnScope);
544                         this.parseScope(fnScope, aliases);
545                         
546                         locBraceNest++;
547                         //print(">>" +locBraceNest);
548                         continue; // no more processing..    
549                           
550                         
551                     }    
552                    
553                     
554     ///==== check/set isObjectLitAr ??                
555                     
556                     
557                  // foo: function() {}
558                         // no change to scoping..
559                         
560                     //print("checking for : function() {"); 
561                     //print( [this.ts.lookTok(-3).type , this.ts.lookTok(-2).type , this.ts.lookTok(-1).type ].join(":"));
562                     if (
563                             (this.ts.lookTok(-1).data == ':') && 
564                             (this.ts.lookTok(-2).type == 'NAME') &&
565                             (this.ts.lookTok(-3).data == '(' || this.ts.lookTok(-3).data== ',') 
566                         ) {
567                         //print("got for : function() {"); 
568                             
569                         //scopeName = this.ts.look(-3).data;
570                         this.ts.balance('(');
571                         //print(token.toString())
572                         token = this.ts.nextTok(); // should be {
573                         //print(token.toString())
574                         scopeName = fixAlias(scopeName);
575                         var fnScope = new Scope(this.braceNesting, scope, token.n, '');
576                         this.indexedScopes[this.ts.cursor] = fnScope;
577                         //scope = fnScope;
578                         //this.scopesIn(fnScope);
579                          this.parseScope(fnScope, aliases);
580                         locBraceNest++;
581                         //print(">>" +locBraceNest);
582                         continue; // no more processing..    
583                           
584                     } 
585                /// function foo() {} << really it set's the 'this' scope to foo.prototype
586                         //$this$=foo|$private$
587                         //$this$=foo
588                         
589                     if (
590                             (this.ts.lookTok(1).type == 'NAME') 
591                         ) {
592                         //scopeName = this.ts.look(-3).data;
593                         this.ts.balance('(');
594                         token = this.ts.nextTok(); // should be {
595                             
596                         var fnScope = new Scope(this.braceNesting, scope, token.n, '');
597                         this.indexedScopes[this.ts.cursor] = fnScope;
598                         //scope = fnScope;
599                         //this.scopesIn(fnScope);
600                         this.parseScope(fnScope, aliases);
601                         locBraceNest++;
602                         //print(">>" +locBraceNest);
603                         continue; // no more processing..    
604                           
605                     }
606                     
607                      
608                 // foo = new (function() { }
609                 // (function() { }
610                 // RETURN function(...) {
611                     
612                     if (
613                            // (this.ts.lookTok(-1).tokN == Script.TOKlparen) && 
614                             (this.ts.lookTok(1).name != 'NAME')   
615                             
616                         //    (this.ts.lookTok(-2).tokN == Script.TOKnew) &&
617                          //   (this.ts.lookTok(-3).tokN == Script.TOKassign) &&
618                          //   (this.ts.lookTok(-4).tokN == Script.TOKidentifier)
619                         ) {
620                         //scopeName = this.ts.look(-3).data;
621                         this.ts.balance('(');
622                         token = this.ts.nextTok(); // should be {
623                         var fnScope = new Scope(this.braceNesting, scope, token.n, '$private$');
624                         this.indexedScopes[this.ts.cursor] = fnScope;
625                         //scope = ;
626                         //this.scopesIn(fnScope);
627                          this.parseScope(fnScope, aliases);
628                         locBraceNest++;
629                         //print(">>" +locBraceNest);
630                         continue; // no more processing..    
631                           
632                         
633                     }
634                     
635                     
636                     throw {
637                         name: "ArgumentError", 
638                         message: "dont know how to handle function syntax??\n" +
639                                 token.toString()
640                     };
641             
642                     
643                     continue;
644                     
645                     
646                     
647                     
648                 } // end checking for TOKfunction
649                     
650                 if (token.data == '{') {
651                     
652                      // foo = { // !var!!!
653                         //$this$=foo|Foo
654                
655                 
656                     if (
657                             (this.ts.lookTok(-1).data == '=') &&
658                             (this.ts.lookTok(-2).type == 'NAME') &&
659                             (this.ts.lookTok(-3).nane != 'VAR')  
660                         ) {
661                             
662                             scopeName = this.ts.look(-2).data;
663                             scopeName = fixAlias(scopeName);
664                             var fnScope = new Scope(this.braceNesting, scope, token.n, 
665                                 '$this$='+scopeName + '|'+scopeName
666                             );
667                             this.indexedScopes[this.ts.cursor] = fnScope;
668                             scope = fnScope;
669                             this.scopesIn(fnScope);
670                             
671                               
672                             locBraceNest++;
673                             //print(">>" +locBraceNest);
674                             continue; // no more processing..   
675                     }
676                     // foo : {
677                     // ?? add |foo| ????
678                       
679                     //print("GOT LBRACE : check for :");
680                     if (
681                             (this.ts.lookTok(-1).data == ':') &&
682                             (this.ts.lookTok(-2).type == 'NAME') &&
683                             (this.ts.lookTok(-3).name != 'VAR') 
684                         ) {
685                             
686                             scopeName = this.ts.lookTok(-2).data;
687                             scopeName = fixAlias(scopeName);
688                             var fnScope = new Scope(this.braceNesting, scope, token.n, scopeName);
689                             this.indexedScopes[this.ts.cursor] = fnScope;
690                             scope = fnScope;
691                             this.scopesIn(fnScope);
692                             
693                             locBraceNest++;
694                             //print(">>" +locBraceNest);
695                             continue; // no more processing..   
696                     }
697                     var fnScope = new Scope(this.braceNesting, scope, token.n, '');
698                     this.indexedScopes[this.ts.cursor] = fnScope;
699                     scope = fnScope;
700                     this.scopesIn(fnScope);
701                    
702                     locBraceNest++;
703                     //print(">>" +locBraceNest);
704                     continue;
705                     
706                 }
707                 if (token.data == '{') {
708                     
709                      
710                         if (this.currentDoc) {
711                             this.addSymbol('', true);
712
713                             //throw "Unconsumed Doc: (TOKrbrace)" + this.currentDoc.toSource();
714                         }
715                         
716                        
717                         locBraceNest--;
718                         
719                             //assert braceNesting >= scope.getBraceNesting();
720                         var closescope = this.scopeOut();   
721                         scope = this.scopes[this.scopes.length-1];
722                         //print("<<:" +  locBraceNest)
723                         //print("<<<<<< " + locBraceNest );
724                         if (locBraceNest < 0) {
725                            // print("POPED OF END OF SCOPE!");
726                             ///this.scopeOut();   
727                             //var ls = this.scopeOut();
728                             //ls.getUsedSymbols();
729                             return;
730                         }
731                         continue;
732                 }
733               
734                 
735             }
736             
737             
738         },
739      
740          
741         addSymbol: function(lastIdent, appendIt, atype )
742         {
743             print("Walker.addSymbol : " + lastIdent);
744             print("Walker.curdoc: " + JSON.stringify(this.currentDoc));
745             
746             /*if (!this.currentDoc.tags.length) {
747                 
748               
749                 //print(this.currentDoc.toSource());
750                 //  this.currentDoc = false;
751                 
752                 print("SKIP ADD SYM: no tags");
753                 print(this.currentDoc.src);
754                 return;
755             }
756             */
757             if (this.currentDoc.getTag('private').length) {
758                 
759               
760                 //print(this.currentDoc.toSource());
761                  this.currentDoc = false;
762                 //print("SKIP ADD SYM:  it's private");
763                 return;
764             }
765             
766             var token = this.ts.lookTok(0);
767             if (typeof(appendIt) == 'undefined') {
768                 appendIt= false;
769             }
770           //  print(this.currentDoc.toSource(););
771             if (this.currentDoc.getTag('event').length) {
772                 //?? why does it end up in desc - and not name/...
773                 //print(this.currentDoc.getTag('event')[0]);
774                 lastIdent = '*' + this.currentDoc.getTag('event')[0].desc;
775                 //lastIdent = '*' + lastIdent ;
776             }
777             if (!lastIdent.length && this.currentDoc.getTag('property').length) {
778                 lastIdent = this.currentDoc.getTag('property')[0].name;
779                 //lastIdent = '*' + lastIdent ;
780             }
781             
782             var _s = lastIdent;
783             if (!/\./.test(_s)) {
784                     
785                 //print("WALKER ADDsymbol: " + lastIdent);
786                 
787                 var s = [];
788                 for (var i = 0; i < this.scopes.length;i++) {
789                     s.push(this.scopes[i].ident);
790                 }
791                 s.push(lastIdent);
792                 
793                 var s = s.join('|').split('|');
794                //print("Walker:ADDSymbol: " + s.join('|') );
795                 var _t = '';
796                  _s = '';
797                 
798                 /// fixme - needs
799                 for (var i = 0; i < s.length;i++) {
800                     
801                     if (!s[i].length) {
802                         continue;
803                     }
804                     if ((s[i] == '$private$') || (s[i] == '$global$')) {
805                         _s = '';
806                         continue;
807                     }
808                     if (s[i].substring(0,6) == '$this$') {
809                         var ts = s[i].split('=');
810                         _t = ts[1];
811                         continue;
812                     }
813                     // when to use $this$ (probabl for events)
814                     _s += _s.length ? '.' : '';
815                     _s += s[i];
816                 }
817                     
818                 
819                 /// calc scope!!
820                 //print("ADDING SYMBOL: "+ s.join('|') +"\n"+ _s + "\n" +Script.prettyDump(this.currentDoc.toSource()));
821                 //print("Walker.addsymbol - add : " + _s);
822                 if (appendIt && !lastIdent.length) {
823                     
824                     // append, and no symbol???
825                     
826                     // see if it's a @class
827                     if (this.currentDoc.getTag('class').length) {
828                         _s = this.currentDoc.getTag('class')[0].desc;
829                         var symbol = new Symbol(_s, [], "CONSTRUCTOR", this.currentDoc);
830                         Parser       = imports.Parser.Parser;
831                         Parser.addSymbol(symbol);
832                         this.symbols[_s] = symbol;
833                         return;
834                     }
835                     
836                    // if (this.currentDoc.getTag('property').length) {
837                      //   print(Script.pretStringtyDump(this.currentDoc.toSource));
838                     //    throw "Add Prop?";
839                     //}
840                     
841                     _s = _s.replace(/\.prototype.*$/, '');
842                     if (typeof(this.symbols[_s]) == 'undefined') {
843                         //print("Symbol:" + _s);
844                     //print(this.currentDoc.src);
845                         
846                         throw {
847                             name: "ArgumentError", 
848                             message: "Trying to append symbol '" + _s + "', but no doc available\n" +
849                                 this.ts.lookTok(0).toString()
850                         };
851
852                      
853                     }
854                         
855                     for (var i =0; i < this.currentDoc.tags.length;i++) {
856                         this.symbols[_s].addDocTag(this.currentDoc.tags[i]);
857                     }
858                     this.currentDoc = false;
859                     return;
860                 }
861             }    
862             //print("Walker.addsymbol - chkdup: " + _s);
863             if (typeof(this.symbols[_s]) != 'undefined') {
864                 
865                 if (this.symbols[_s].comment.hasTags) {
866                     // then existing comment doesnt has tags 
867                     //throw {
868                     //    name: "ArgumentError", 
869                      //   message:"DUPLICATE Symbol " + _s + "\n" + token.toString()
870                     //};
871                     return;
872                 }
873                 // otherwise existing comment has tags - overwrite..
874                 
875                 
876             }
877             //print("Walker.addsymbol - ATYPE: " + _s);
878
879             if (typeof(atype) == "undefined") {
880                 atype = 'OBJECT'; //this.currentDoc.getTag('class').length ? 'OBJECT' : 'FUNCTION';;
881                }
882             
883             //print("Walker.addsymbol - add : ");
884             var symbol = new Symbol(_s, [], atype, this.currentDoc);
885             Parser       = imports.Parser.Parser;
886             Parser.addSymbol(symbol);
887             this.symbols[_s] = symbol;
888             
889              this.currentDoc = false;
890             
891         },
892         
893         
894         
895         
896         scopesIn : function(s)
897         {
898             this.scopes.push(s);
899             //print(">>>" + this.ts.context()  + "\n>>>"+this.scopes.length+":" +this.scopeListToStr());
900             
901         },
902         scopeOut : function()
903         {
904             
905            // print("<<<" + this.ts.context()  + "\n<<<"+this.scopes.length+":" +this.scopeListToStr());
906             return this.scopes.pop();
907             
908         },
909         
910         scopeListToStr : function()
911         {
912             var s = [];
913             for (var i = 0; i < this.scopes.length;i++) {
914                 s.push(this.scopes[i].ident);
915             }
916             return  s.join('\n\t');
917             
918         }
919         
920     
921     
922      
923 });