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