1.1 --- a/src/sys/js/fan/Type.js Wed Feb 15 10:56:19 2012 -0500
1.2 +++ b/src/sys/js/fan/Type.js Wed Feb 15 12:10:45 2012 -0500
1.3 @@ -129,18 +129,16 @@
1.4 return this.m_pod.m_name === "sys" && this.m_name.length === 1;
1.5 }
1.6
1.7 -/*
1.8 -fan.sys.Type.prototype.getRawType = function()
1.9 -{
1.10 - if (!isGenericParameter()) return this;
1.11 - if (this == Sys.LType) return Sys.ListType;
1.12 - if (this == Sys.MType) return Sys.MapType;
1.13 - if (this instanceof ListType) return Sys.ListType;
1.14 - if (this instanceof MapType) return Sys.MapType;
1.15 - if (this instanceof FuncType) return Sys.FuncType;
1.16 - return Sys.ObjType;
1.17 -}
1.18 -*/
1.19 +// fan.sys.Type.prototype.getRawType = function()
1.20 +// {
1.21 +// if (!isGenericParameter()) return this;
1.22 +// if (this == Sys.LType) return Sys.ListType;
1.23 +// if (this == Sys.MType) return Sys.MapType;
1.24 +// if (this instanceof ListType) return Sys.ListType;
1.25 +// if (this instanceof MapType) return Sys.MapType;
1.26 +// if (this instanceof FuncType) return Sys.FuncType;
1.27 +// return Sys.ObjType;
1.28 +// }
1.29
1.30 fan.sys.Type.prototype.isGeneric = function() { return this.isGenericType(); }
1.31
1.32 @@ -290,9 +288,6 @@
1.33 // addField
1.34 fan.sys.Type.prototype.$af = function(name, flags, of, facets)
1.35 {
1.36 - // TODO: Map.def - not sure how to handle this yet
1.37 - if (of == 'sys::V?') return this;
1.38 -
1.39 var t = fanx_TypeParser.load(of);
1.40 var f = new fan.sys.Field(this, name, flags, t, facets);
1.41 this.m_slots[name] = f;
1.42 @@ -552,16 +547,21 @@
1.43 {
1.44 this.m_root = root;
1.45 this.m_signature = root.signature() + "?";
1.46 + this.m_qname = root.m_qname;
1.47 + this.m_pod = root.m_pod;
1.48 + this.m_name = root.m_name;
1.49 + this.m_base = root.m_base;
1.50 + this.m_mixins = root.m_mixins;
1.51 +
1.52 + this.m_slots = root.m_slots;
1.53 + this.m_slotList = root.m_slotList;
1.54 + this.m_fieldList = root.m_fieldList;
1.55 + this.m_methodList = root.m_methodList;
1.56 }
1.57
1.58 -fan.sys.NullableType.prototype.pod = function() { return this.m_root.pod(); }
1.59 -fan.sys.NullableType.prototype.$name = function() { return this.m_root.$name(); }
1.60 -fan.sys.NullableType.prototype.qname = function() { return this.m_root.qname(); }
1.61 fan.sys.NullableType.prototype.signature = function() { return this.m_signature; }
1.62 fan.sys.NullableType.prototype.flags = function() { return this.m_root.flags(); }
1.63
1.64 -fan.sys.NullableType.prototype.base = function() { return this.m_root.base(); }
1.65 -fan.sys.NullableType.prototype.mixins = function() { return this.m_root.mixins(); }
1.66 fan.sys.NullableType.prototype.inheritance = function() { return this.m_root.inheritance(); }
1.67 fan.sys.NullableType.prototype.is = function(type) { return this.m_root.is(type); }
1.68
1.69 @@ -578,11 +578,6 @@
1.70 fan.sys.NullableType.prototype.params = function() { return this.m_root.params(); }
1.71 fan.sys.NullableType.prototype.parameterize = function(params) { return this.m_root.parameterize(params).toNullable(); }
1.72
1.73 -fan.sys.NullableType.prototype.fields = function() { return this.m_root.fields(); }
1.74 -fan.sys.NullableType.prototype.methods = function() { return this.m_root.methods(); }
1.75 -fan.sys.NullableType.prototype.slots = function() { return this.m_root.slots(); }
1.76 -fan.sys.NullableType.prototype.slot = function(name, checked) { return this.m_root.slot(name, checked); }
1.77 -
1.78 fan.sys.NullableType.prototype.facets = function() { return this.m_root.facets(); }
1.79 fan.sys.NullableType.prototype.facet = function(type, checked) { return this.m_root.facet(type, checked); }
1.80
1.81 @@ -597,9 +592,6 @@
1.82
1.83 fan.sys.GenericType.prototype.doReflect = function()
1.84 {
1.85 - try
1.86 - {
1.87 -
1.88 if (this.m_slotList != null) return;
1.89
1.90 // ensure master type is reflected
1.91 @@ -633,15 +625,6 @@
1.92 this.m_slotList = fan.sys.List.make(fan.sys.Slot.$type, slots);
1.93 this.m_fieldList = fan.sys.List.make(fan.sys.Field.$type, fields);
1.94 this.m_methodList = fan.sys.List.make(fan.sys.Method.$type, methods);
1.95 -
1.96 - }
1.97 - catch (err)
1.98 - {
1.99 - println(err);
1.100 - println(err.stack);
1.101 - println(err.stackTrace);
1.102 - println(err.javaException);
1.103 - }
1.104 }
1.105
1.106 fan.sys.GenericType.prototype.parameterizeField = function(f)
1.107 @@ -653,7 +636,7 @@
1.108 // create new parameterized version
1.109 t = this.parameterizeType(t);
1.110 //var pf = new Field(this, f.name, f.flags, f.facets, f.lineNum, t);
1.111 - var pf = new fan.sys.File(this, f.m_name, f.m_flags, f.m_type, f.m_facets);
1.112 + var pf = new fan.sys.Field(this, f.m_name, f.m_flags, t, f.m_facets);
1.113 //pf.reflect = f.reflect;
1.114 return pf;
1.115 }
1.116 @@ -804,6 +787,11 @@
1.117 fan.sys.ListType.prototype.facets = function() { return fan.sys.List.$type.facets(); }
1.118 fan.sys.ListType.prototype.facet = function(type, checked) { return fan.sys.List.$type.facet(type, checked); }
1.119
1.120 +fan.sys.ListType.prototype.isGenericParameter = function()
1.121 +{
1.122 + return this.v.isGenericParameter();
1.123 +}
1.124 +
1.125 fan.sys.ListType.prototype.doParameterize = function(t)
1.126 {
1.127 if (t == fan.sys.Sys.VType) return this.v;
1.128 @@ -815,8 +803,7 @@
1.129 * MapType
1.130 ************************************************************************/
1.131
1.132 -fan.sys.MapType = fan.sys.Obj.$extend(fan.sys.Type);
1.133 -
1.134 +fan.sys.MapType = fan.sys.Obj.$extend(fan.sys.GenericType);
1.135 fan.sys.MapType.prototype.$ctor = function(k, v)
1.136 {
1.137 this.k = k;
1.138 @@ -824,7 +811,9 @@
1.139 this.m_qname = "sys::Map";
1.140 this.m_pod = fan.sys.Pod.find("sys");
1.141 this.m_name = "Map";
1.142 + this.m_base = fan.sys.Map.$type;
1.143 this.m_mixins = fan.sys.Type.$type.emptyList();
1.144 + this.m_slots = {};
1.145 }
1.146
1.147 fan.sys.MapType.prototype.signature = function()
1.148 @@ -882,6 +871,19 @@
1.149 fan.sys.MapType.prototype.facets = function() { return fan.sys.Map.$type.facets(); }
1.150 fan.sys.MapType.prototype.facet = function(type, checked) { return fan.sys.Map.$type.facet(type, checked); }
1.151
1.152 +fan.sys.MapType.prototype.isGenericParameter = function()
1.153 +{
1.154 + return this.v.isGenericParameter() && this.k.isGenericParameter();
1.155 +}
1.156 +
1.157 +fan.sys.MapType.prototype.doParameterize = function(t)
1.158 +{
1.159 + if (t == fan.sys.Sys.KType) return this.k;
1.160 + if (t == fan.sys.Sys.VType) return this.v;
1.161 + if (t == fan.sys.Sys.MType) return this;
1.162 + throw new Error(t.toString());
1.163 +}
1.164 +
1.165 /*************************************************************************
1.166 * FuncType
1.167 ************************************************************************/