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