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