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