src/jsdoc/Symbol.vala
[roojspacker] / src / jsdoc / Symbol.vala
1  
2 /**
3         Create a new Symbol.
4         @class Represents a symbol in the source code.
5  */
6  
7  
8 namespace JSDOC {
9
10
11         public  class Symbol : Object
12         {
13         
14         
15 //              public Symbol() {
16 //                  this.init();
17 //              },
18
19 // probably needs vairous CTORS..
20
21         
22         string name : "",
23         string defaultValue : "",
24         
25         
26         
27         params : [],
28         augments : [], // Doctag[]
29         exceptions : [],  // Doctag[]
30         inherits : [],  // Doctag[]
31         methods : [], // Symbol[]
32                 //??
33         _params : [], //Doctag[]
34                  properties : [], //Doctag[]
35         requires : [],  //Doctag[]
36         returns : [], //Doctag[]
37         see : [], //Doctag[]
38
39         srcFile : {}, //??
40         childClasses : [],
41         cfgs : {},
42         
43         
44         DocComment comment;
45                 
46         //$args : [], // original arguments used when constructing.
47         string addOn = "";
48         public string alias = "";
49         
50         string author = "";
51         string classDesc = "";
52
53         string deprecated = "";
54         string desc = "";
55         //events : false,
56         string example = "";
57         
58         //inheritsFrom : [],
59         string isa = "OBJECT"; // OBJECT//FUNCTION
60         
61         public bool isEvent = false;
62         public bool isConstant = false;
63         public bool isIgnored = false;
64         public bool isInner = false;
65         public bool isNamespace = false;
66         public bool isPrivate = false;
67         public bool isStatic = false;
68         
69         string memberOf : "",
70
71         string _name : "",
72
73        
74         string since : "",
75
76         string type : "",
77         string version : "",
78         
79         string srcFile = ""
80         
81         
82         
83         public Symbol() 
84         {
85             // only initialize arrays / objects..
86             this.srcFile = DocParser.currentSourceFile;
87             
88             //this.params = [];
89             this.$args = [];
90             
91             //this.events = [];
92             this.exceptions = [];
93             this.inherits = [];
94             //
95             this.isa = "OBJECT"; // OBJECT//FUNCTION
96             this.methods = [];
97             this._params = [];
98             this.properties = [];
99             this.requires = [];
100             this.returns = [];
101             this.see = [];
102  
103             
104             
105             this.cfgs = {};
106             // derived later?
107             this.inheritsFrom = [];
108             this.childClasses = [];
109             
110             this.comment = new DocComment();
111             this.comment.isUserComment =  false;
112             
113                
114         },
115                 
116                 Public Symbol.new_builtin(string name)
117                 {
118                         this.setName( name );
119                         this.alias = this.getName();
120                         this.isa = "CONSTRUCTOR";
121                         this.comment = new DocComment("");
122                         this.isNamespace = false;
123                         this.srcFile = "";
124                         this.isPrivate = false;
125                 }
126                 
127
128         //__defineSetter__("name",
129         setName  : function(n) { 
130                 n = n.replace(/^_global_[.#-]/, ""); 
131                 n = n.replace(/\.prototype\.?/g, '#'); 
132                  n = n.replace(/#$/g, ''); 
133                 this._name = n;
134                 this.name = n; // real!
135             },
136         //);
137         //__defineGetter__("name",
138         getName : function() { return this._name; },
139         //);
140         //__defineSetter__("params", 
141         setParams  :function(v) {
142                 for (var i = 0, l = v.length; i < l; i++) {
143                     if (v[i].constructor != DocTag) { // may be a generic object parsed from signature, like {type:..., name:...}
144                         var ty = v[i].hasOwnProperty('type') ? v[i].type : '';
145                         this._params[i] = new DocTag(
146                             "param"+((ty)?" {"+ty+"}":"")+" "+v[i].name);
147                     }
148                     else {
149                         this._params[i] = v[i];
150                     }
151                 }
152                 this.params = this._params;
153             },
154         //);
155
156
157         //__defineGetter__("params",
158         getParams : function() { return this._params; },
159         //);
160
161         populate : function(
162                 /** String */ name,
163                 /** Object[] */ params,
164                 /** String */ isa,
165                 /** DocComment */ comment
166         ) {
167             this.$args = arguments;
168             //println("Symbol created: " + isa + ":" + name);
169             this.setName(name);
170             this.alias = this.getName();
171             this.setParams(params);
172             this.isa = (isa == "VIRTUAL")? "OBJECT":isa;
173             this.comment = comment || new DocComment("");
174             this.srcFile = Symbol.srcFile;
175             
176            
177             
178             if (this.is("FILE") && !this.alias) this.alias = this.srcFile;
179
180             this.setTags();
181             
182             //if (typeof PluginManager != "undefined") {
183             //    PluginManager.run("onSymbol", this);
184             //}
185         },
186
187         setTags : function() {
188             // @author
189             var authors = this.comment.getTag("author");
190             if (authors.length) {
191                 this.author = authors.map(function($){return $.desc;}).join(", ");
192             }
193             
194             /*~t
195                 assert("testing Symbol");
196                 
197                 requires("../lib/JSDOC/DocComment.js");
198                 requires("../frame/String.js");
199                 requires("../lib/JSDOC/DocTag.js");
200
201                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@author Joe Smith*"+"/"));
202                 assertEqual(sym.author, "Joe Smith", "@author tag, author is found.");
203             */
204             // @desc
205             var mth = this.comment.getTag("method");
206             if (mth.length) {
207                 this.isa = "FUNCTION";
208             }
209             // @desc
210             var descs = this.comment.getTag("desc");
211             if (descs.length) {
212                 this.desc = descs.map(function($){return $.desc;}).join("\n"); // multiple descriptions are concatenated into one
213             }
214             
215             /*~t
216                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@desc This is a description.*"+"/"));
217                 assertEqual(sym.desc, "This is a description.", "@desc tag, description is found.");
218             */
219             
220             // @overview
221             if (this.is("FILE")) {
222                 if (!this.alias) this.alias = this.srcFile;
223                 
224                 var overviews = this.comment.getTag("overview");
225                 if (overviews.length) {
226                     this.desc = [this.desc].concat(overviews.map(function($){return $.desc;})).join("\n");
227                 }
228             }
229             
230             /*~t
231                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@overview This is an overview.*"+"/"));
232                 assertEqual(sym.desc, "\nThis is an overview.", "@overview tag, description is found.");
233             */
234             
235             // @since
236             var sinces = this.comment.getTag("since");
237             if (sinces.length) {
238                 this.since = sinces.map(function($){return $.desc;}).join(", ");
239             }
240             
241             /*~t
242                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@since 1.01*"+"/"));
243                 assertEqual(sym.since, "1.01", "@since tag, description is found.");
244             */
245             
246             // @constant
247             if (this.comment.getTag("constant").length) {
248                 this.isConstant = true;
249                 this.isa = 'OBJECT';
250             }
251             
252             /*~t
253                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@constant*"+"/"));
254                 assertEqual(sym.isConstant, true, "@constant tag, isConstant set.");
255             */
256             
257             // @version
258             var versions = this.comment.getTag("version");
259             if (versions.length) {
260                 this.version = versions.map(function($){return $.desc;}).join(", ");
261             }
262             
263             /*~t
264                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@version 2.0x*"+"/"));
265                 assertEqual(sym.version, "2.0x", "@version tag, version is found.");
266             */
267             
268             // @deprecated
269             var deprecateds = this.comment.getTag("deprecated");
270             if (deprecateds.length) {
271                 this.deprecated = deprecateds.map(function($){return $.desc;}).join("\n");
272             }
273             
274             /*~t
275                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@deprecated Use other method.*"+"/"));
276                 assertEqual(sym.deprecated, "Use other method.", "@deprecated tag, desc is found.");
277             */
278             
279             // @example
280             var examples = this.comment.getTag("example");
281             if (examples.length) {
282                 this.example = examples[0];
283             }
284             
285             /*~t
286                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@example This\n  is an example.*"+"/"));
287                 assertEqual(sym.example, "This\n  is an example.", "@deprecated tag, desc is found.");
288             */
289             
290             // @see
291             var sees = this.comment.getTag("see");
292             if (sees.length) {
293                 var thisSee = this.see;
294                 sees.map(function($){thisSee.push($.desc);});
295             }
296             
297             /*~t
298                 var sym = new Symbol("foo", [], "FILE", new DocComment("/**@see The other thing.*"+"/"));
299                 assertEqual(sym.see, "The other thing.", "@see tag, desc is found.");
300             */
301             
302             // @class
303             var classes = this.comment.getTag("class");
304             if (classes.length) {
305                 //print(JSON.stringify(this,null,4));
306                 this.isa = "CONSTRUCTOR";
307                 this.classDesc = classes[0].desc; // desc can't apply to the constructor as there is none.
308                 if (!this.classDesc) {
309                     this.classDesc = this.desc;
310                    }
311                 
312                 
313             }
314             
315             /*~t
316                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@class This describes the class.*"+"/"));
317                 assertEqual(sym.isa, "CONSTRUCTOR", "@class tag, makes symbol a constructor.");
318                 assertEqual(sym.classDesc, "This describes the class.", "@class tag, class description is found.");
319             */
320             
321             // @namespace
322             var namespaces = this.comment.getTag("namespace");
323             if (namespaces.length) {
324                 this.classDesc = namespaces[0].desc+"\n"+this.desc; // desc can't apply to the constructor as there is none.
325                 this.isNamespace = true;
326             }
327             
328             /*~t
329                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@namespace This describes the namespace.*"+"/"));
330                 assertEqual(sym.classDesc, "This describes the namespace.\n", "@namespace tag, class description is found.");
331             */
332             
333             // @param
334             var params = this.comment.getTag("param");
335             if (params.length) {
336                 // user-defined params overwrite those with same name defined by the parser
337                 var thisParams = this.getParams();
338
339                 if (thisParams.length == 0) { // none exist yet, so just bung all these user-defined params straight in
340                     this.setParams(params);
341                 }
342                 else { // need to overlay these user-defined params on to existing parser-defined params
343                     for (var i = 0, l = params.length; i < l; i++) {
344                         if (thisParams[i]) {
345                             if (params[i].type) thisParams[i].type = params[i].type;
346                             thisParams[i].name = params[i].name;
347                             thisParams[i].desc = params[i].desc;
348                             thisParams[i].isOptional = params[i].isOptional;
349                             thisParams[i].defaultValue = params[i].defaultValue;
350                         }
351                         else thisParams[i] = params[i];
352                     }
353                 }
354             }
355             
356             /*~t
357                 var sym = new Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new DocComment("/**Description.*"+"/"));
358                 assertEqual(sym.params.length, 1, "parser defined param is found.");
359                 
360                 sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**Description.\n@param {array} pages*"+"/"));
361                 assertEqual(sym.params.length, 1, "user defined param is found.");
362                 assertEqual(sym.params[0].type, "array", "user defined param type is found.");
363                 assertEqual(sym.params[0].name, "pages", "user defined param name is found.");
364                 
365                 sym = new Symbol("foo", [{type: "array", name: "pages"}], "FUNCTION", new DocComment("/**Description.\n@param {string} uid*"+"/"));
366                 assertEqual(sym.params.length, 1, "user defined param overwrites parser defined param.");
367                 assertEqual(sym.params[0].type, "string", "user defined param type overwrites parser defined param type.");
368                 assertEqual(sym.params[0].name, "uid", "user defined param name overwrites parser defined param name.");
369             
370                 sym = new Symbol("foo", [{type: "array", name: "pages"}, {type: "number", name: "count"}], "FUNCTION", new DocComment("/**Description.\n@param {string} uid*"+"/"));
371                 assertEqual(sym.params.length, 2, "user defined params  overlay parser defined params.");
372                 assertEqual(sym.params[1].type, "number", "user defined param type overlays parser defined param type.");
373                 assertEqual(sym.params[1].name, "count", "user defined param name overlays parser defined param name.");
374
375                 sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**Description.\n@param {array} pages The pages description.*"+"/"));
376                 assertEqual(sym.params.length, 1, "user defined param with description is found.");
377                 assertEqual(sym.params[0].desc, "The pages description.", "user defined param description is found.");
378             */
379             
380             // @constructor
381             if (this.comment.getTag("constructor").length) {
382                 this.isa = "CONSTRUCTOR";
383             }
384             
385             /*~t
386                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@constructor*"+"/"));
387                 assertEqual(sym.isa, "CONSTRUCTOR", "@constructor tag, makes symbol a constructor.");
388             */
389             
390             // @static
391             if (this.comment.getTag("static").length) {
392                 this.isStatic = true;
393                 if (this.isa == "CONSTRUCTOR") {
394                     this.isNamespace = true;
395                 }
396             }
397             
398                 // @static
399             if (this.comment.getTag("singleton").length) {
400                 this.isStatic = true;
401                 //print('------------- got singleton ---------------' + this.isa);
402                 //if (this.isa == "CONSTRUCTOR") {
403                 //      this.isNamespace = true;
404                 //}
405             }
406             
407             
408             
409             /*~t
410                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@static\n@constructor*"+"/"));
411                 assertEqual(sym.isStatic, true, "@static tag, makes isStatic true.");
412                 assertEqual(sym.isNamespace, true, "@static and @constructor tag, makes isNamespace true.");
413             */
414             
415             // @inner
416             if (this.comment.getTag("inner").length) {
417                 this.isInner = true;
418                 this.isStatic = false;
419             }
420             
421             /*~t
422                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@inner*"+"/"));
423                 assertEqual(sym.isStatic, false, "@inner tag, makes isStatic false.");
424                 assertEqual(sym.isInner, true, "@inner makes isInner true.");
425             */
426             
427             // @field
428             if (this.comment.getTag("field").length) {
429                 this.isa = "OBJECT";
430             }
431             
432             /*~t
433                 var sym = new Symbol("foo", [], "FUNCTION", new DocComment("/**@field*"+"/"));
434                 assertEqual(sym.isa, "OBJECT", "@field tag, makes symbol an object.");
435             */
436             
437             // @function
438             if (this.comment.getTag("function").length) {
439                 this.isa = "FUNCTION";
440             }
441             
442             // @param
443             if (this.comment.getTag("param").length && this.isa == "OBJECT" ) {
444                 // change a property to a function..
445                 this.isa = "FUNCTION";
446             }
447             
448             
449             /*~t
450                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@function*"+"/"));
451                 assertEqual(sym.isa, "FUNCTION", "@function tag, makes symbol a function.");
452             */
453             
454             // @event
455             var events = this.comment.getTag("event");
456             if (events.length) {
457                 this.isa = "FUNCTION";
458                 this.isEvent = true;
459             }
460             
461             /*~t
462                 var sym = new Symbol("foo", [], "OBJECT", new DocComment("/**@event*"+"/"));
463                 assertEqual(sym.isa, "FUNCTION", "@event tag, makes symbol a function.");
464                 assertEqual(sym.isEvent, true, "@event makes isEvent true.");
465             */
466             
467             // @name
468             var names = this.comment.getTag("name");
469             if (names.length) {
470                 this.setName(names[0].desc);
471             }
472             
473             /*~t
474                 // todo
475             */
476             
477             // @property
478             var properties = this.comment.getTag("property");
479             if (properties.length) {
480                 thisProperties = this.properties;
481                 for (var i = 0; i < properties.length; i++) {
482                     var property = new Symbol(this.alias+"#"+properties[i].name, [], "OBJECT", new DocComment("/**"+properties[i].desc+"\n@name "+properties[i].name+"\n@memberOf "+this.alias+"#*/"));
483                     // TODO: shouldn't the following happen in the addProperty method of Symbol?
484                     property.name = properties[i].name;
485                     property.memberOf = this.alias;
486                     if (properties[i].type) property.type = properties[i].type;
487                     if (properties[i].defaultValue) property.defaultValue = properties[i].defaultValue;
488                     this.addProperty(property);
489                     imports.Parser.Parser.addSymbol(property);
490                 }
491             }
492             
493             // config..
494             var conf = this.comment.getTag("cfg");
495             if (conf.length) {
496                 for (var i = 0; i < conf.length; i++) {
497                     this.addConfig(conf[i]);
498                 }
499             }
500             
501             /*~t
502                 // todo
503             */
504
505             // @return
506             var returns = this.comment.getTag("return");
507             if (returns.length) { // there can be many return tags in a single doclet
508                 this.returns = returns;
509                 this.type = returns.map(function($){return $.type}).join(", ");
510             }
511             
512             /*~t
513                 // todo
514             */
515             
516             // @exception
517             this.exceptions = this.comment.getTag("throws");
518             
519             /*~t
520                 // todo
521             */
522             
523             // @requires
524             var requires = this.comment.getTag("requires");
525             if (requires.length) {
526                 this.requires = requires.map(function($){return $.desc});
527             }
528             
529             /*~t
530                 // todo
531             */
532             
533             // @type
534             var types = this.comment.getTag("type");
535             if (types.length) {
536                 this.type = types[0].desc; //multiple type tags are ignored
537             }
538             
539             /*~t
540                 // todo
541             */
542             
543             // @private
544             if (this.comment.getTag("private").length || this.isInner) {
545                 this.isPrivate = true;
546             }
547             
548             // @ignore
549             if (this.comment.getTag("ignore").length) {
550                 this.isIgnored = true;
551             }
552             
553             /*~t
554                 // todo
555             */
556             
557             // @inherits ... as ...
558             var inherits = this.comment.getTag("inherits");
559             if (inherits.length) {
560                 for (var i = 0; i < inherits.length; i++) {
561                     if (/^\s*([a-z$0-9_.#-]+)(?:\s+as\s+([a-z$0-9_.#]+))?/i.test(inherits[i].desc)) {
562                         var inAlias = RegExp.$1;
563                         var inAs = RegExp.$2 || inAlias;
564
565                         if (inAlias) inAlias = inAlias.replace(/\.prototype\.?/g, "#");
566                         
567                         if (inAs) {
568                             inAs = inAs.replace(/\.prototype\.?/g, "#");
569                             inAs = inAs.replace(/^this\.?/, "#");
570                         }
571
572                         if (inAs.indexOf(inAlias) != 0) { //not a full namepath
573                             var joiner = ".";
574                             if (this.alias.charAt(this.alias.length-1) == "#" || inAs.charAt(0) == "#") {
575                                 joiner = "";
576                             }
577                             inAs = this.alias + joiner + inAs;
578                         }
579                     }
580                     this.inherits.push({alias: inAlias, as: inAs});
581                 }
582             }
583             
584             /*~t
585                 // todo
586             */
587
588             // @augments
589             this.augments = this.comment.getTag("augments");
590             
591             //@extends - Ext
592             if (this.comment.getTag("extends")) {   
593                 this.augments = this.comment.getTag("extends");
594             }
595             
596             
597             // @default
598             var defaults = this.comment.getTag("default");
599             if (defaults.length) {
600                 if (this.is("OBJECT")) {
601                     this.defaultValue = defaults[0].desc;
602                 }
603             }
604             
605             /*~t
606                 // todo
607             */
608             
609             // @memberOf
610             var memberOfs = this.comment.getTag("memberOf");
611             if (memberOfs.length) {
612                 this.memberOf = memberOfs[0].desc;
613                 this.memberOf = this.memberOf.replace(/\.prototype\.?/g, "#");
614                 this.name = this.name.split('.').pop();
615                 this.name = this.name.split('#').pop();
616                 this.name = this.memberOf + this.name;
617                 this._name = this.name
618                 this.alias = this.name;
619             }
620
621             /*~t
622                 // todo
623             */
624             
625             // @public
626             if (this.comment.getTag("public").length) {
627                 this.isPrivate = false;
628             }
629             
630             /*~t
631                 // todo
632             */
633         },
634
635         is : function(what) {
636             return this.isa === what;
637         },
638
639         isBuiltin : function() {
640             return SymbolSet.isBuiltin(this.alias);
641         },
642
643         setType : function(/**String*/comment, /**Boolean*/overwrite) {
644             if (!overwrite && this.type) return;
645             var typeComment = DocComment.unwrapComment(comment);
646             this.type = typeComment;
647         },
648
649         inherit : function(symbol) {
650             if (!this.hasMember(symbol.name) && !symbol.isInner) {
651                 if (symbol.is("FUNCTION"))
652                     this.methods.push(symbol);
653                 else if (symbol.is("OBJECT"))
654                     this.properties.push(symbol);
655             }
656         },
657
658         hasMember : function(name) {
659             return (this.hasMethod(name) || this.hasProperty(name));
660         },
661
662         addMember : function(symbol) {
663             //println("ADDMEMBER: " + this.name +  " ++ " + symbol.name);
664             
665             if (symbol.comment.getTag("cfg").length == 1) { 
666                 symbol.comment.getTag("cfg")[0].memberOf = this.alias;
667                 this.addConfig(symbol.comment.getTag("cfg")[0]);
668                 return;
669             }
670             
671             if (symbol.is("FUNCTION")) { this.addMethod(symbol); }
672             else if (symbol.is("OBJECT")) { this.addProperty(symbol); }
673         },
674
675         hasMethod : function(name) {
676             var thisMethods = this.methods;
677             for (var i = 0, l = thisMethods.length; i < l; i++) {
678                 if (thisMethods[i].name == name) return true;
679                 if (thisMethods[i].alias == name) return true;
680             }
681             return false;
682         },
683
684         addMethod : function(symbol) {
685             var methodAlias = symbol.alias;
686             var thisMethods = this.methods;
687             for (var i = 0, l = thisMethods.length; i < l; i++) {
688                 if (thisMethods[i].alias == methodAlias) {
689                     thisMethods[i] = symbol; // overwriting previous method
690                     return;
691                 }
692             }
693             thisMethods.push(symbol); // new method with this alias
694         },
695
696         hasProperty : function(name) {
697             var thisProperties = this.properties;
698             for (var i = 0, l = thisProperties.length; i < l; i++) {
699                 if (thisProperties[i].name == name) return true;
700                 if (thisProperties[i].alias == name) return true;
701             }
702             return false;
703         },
704
705         addProperty : function(symbol) {
706             var propertyAlias = symbol.alias;
707             var thisProperties = this.properties;
708             for (var i = 0, l = thisProperties.length; i < l; i++) {
709                 if (thisProperties[i].alias == propertyAlias) {
710                     thisProperties[i] = symbol; // overwriting previous property
711                     return;
712                 }
713             }
714
715             thisProperties.push(symbol); // new property with this alias
716         },
717         
718         addDocTag : function(docTag)
719         {
720             this.comment.tags.push(docTag);
721             if (docTag.title == 'cfg') {
722                 this.addConfig(docTag);
723             }
724             
725         },
726         
727         addConfig : function(docTag)
728         {
729             if (typeof(docTag['memberOf']) == 'undefined') {
730                 // remove prototype data...
731                 //var a = this.alias.split('#')[0];
732                 //docTag.memberOf = a;
733                 docTag.memberOf = this.alias;
734             }
735             if (typeof(this.cfgs[docTag.name]) == 'undefined') {
736                 this.cfgs[docTag.name] = docTag;
737             }
738             
739         },
740         configToArray: function()
741         {
742             var r = [];
743             for(var ci in this.cfgs) {
744                 // dont show hidden!!
745                 if (this.cfgs[ci].desc.match(/@hide/)) {
746                     continue;
747                 }
748                 r.push(this.cfgs[ci]); 
749                
750             }
751             return r;
752         }
753 });
754
755 /**
756  * Elements that are not serialized
757  * 
758  */
759 Symbol.hide = [ 
760     '$args' // not needed AFAIK
761 ]
762
763 Symbol.srcFile = ""; //running reference to the current file being parsed
764
765
766 Symbol.fromDump = function(t)
767 {
768     var ns = new Symbol();
769     for (var i in t) {
770         if (typeof(ns[i]) == "undefined") {
771             println("ERR:no default for Symbol:"+ i);
772         }
773         ns[i] = t[i];
774     }
775     return ns;
776 }