OLD | NEW |
1 #!/usr/bin/env node | 1 #!/usr/bin/env node |
2 // ********** Library dart:core ************** | 2 // ********** Library dart:core ************** |
3 // ********** Natives dart:core ************** | 3 // ********** Natives dart:core ************** |
4 function $throw(e) { | 4 function $throw(e) { |
5 // If e is not a value, we can use V8's captureStackTrace utility method. | 5 // If e is not a value, we can use V8's captureStackTrace utility method. |
6 // TODO(jmesserly): capture the stack trace on other JS engines. | 6 // TODO(jmesserly): capture the stack trace on other JS engines. |
7 if (e && (typeof e == 'object') && Error.captureStackTrace) { | 7 if (e && (typeof e == 'object') && Error.captureStackTrace) { |
8 // TODO(jmesserly): this will clobber the e.stack property | 8 // TODO(jmesserly): this will clobber the e.stack property |
9 Error.captureStackTrace(e, $throw); | 9 Error.captureStackTrace(e, $throw); |
10 } | 10 } |
(...skipping 20 matching lines...) Expand all Loading... |
31 return this[i] = value; | 31 return this[i] = value; |
32 }, enumerable: false, writable: true, configurable: true}); | 32 }, enumerable: false, writable: true, configurable: true}); |
33 Object.defineProperty(Array.prototype, '$setindex', { value: function(i, value)
{ | 33 Object.defineProperty(Array.prototype, '$setindex', { value: function(i, value)
{ |
34 return this[i] = value; }, enumerable: false, writable: true, | 34 return this[i] = value; }, enumerable: false, writable: true, |
35 configurable: true}); | 35 configurable: true}); |
36 function $add(x, y) { | 36 function $add(x, y) { |
37 return ((typeof(x) == 'number' && typeof(y) == 'number') || | 37 return ((typeof(x) == 'number' && typeof(y) == 'number') || |
38 (typeof(x) == 'string')) | 38 (typeof(x) == 'string')) |
39 ? x + y : x.$add(y); | 39 ? x + y : x.$add(y); |
40 } | 40 } |
| 41 function $bit_xor(x, y) { |
| 42 return (typeof(x) == 'number' && typeof(y) == 'number') |
| 43 ? x ^ y : x.$bit_xor(y); |
| 44 } |
41 function $eq(x, y) { | 45 function $eq(x, y) { |
42 if (x == null) return y == null; | 46 if (x == null) return y == null; |
43 return (typeof(x) == 'number' && typeof(y) == 'number') || | 47 return (typeof(x) == 'number' && typeof(y) == 'number') || |
44 (typeof(x) == 'boolean' && typeof(y) == 'boolean') || | 48 (typeof(x) == 'boolean' && typeof(y) == 'boolean') || |
45 (typeof(x) == 'string' && typeof(y) == 'string') | 49 (typeof(x) == 'string' && typeof(y) == 'string') |
46 ? x == y : x.$eq(y); | 50 ? x == y : x.$eq(y); |
47 } | 51 } |
48 // TODO(jimhug): Should this or should it not match equals? | 52 // TODO(jimhug): Should this or should it not match equals? |
49 Object.defineProperty(Object.prototype, '$eq', { value: function(other) { | 53 Object.defineProperty(Object.prototype, '$eq', { value: function(other) { |
50 return this === other; | 54 return this === other; |
51 }, enumerable: false, writable: true, configurable: true }); | 55 }, enumerable: false, writable: true, configurable: true }); |
| 56 function $gt(x, y) { |
| 57 return (typeof(x) == 'number' && typeof(y) == 'number') |
| 58 ? x > y : x.$gt(y); |
| 59 } |
| 60 function $gte(x, y) { |
| 61 return (typeof(x) == 'number' && typeof(y) == 'number') |
| 62 ? x >= y : x.$gte(y); |
| 63 } |
| 64 function $lt(x, y) { |
| 65 return (typeof(x) == 'number' && typeof(y) == 'number') |
| 66 ? x < y : x.$lt(y); |
| 67 } |
| 68 function $lte(x, y) { |
| 69 return (typeof(x) == 'number' && typeof(y) == 'number') |
| 70 ? x <= y : x.$lte(y); |
| 71 } |
52 function $mod(x, y) { | 72 function $mod(x, y) { |
53 if (typeof(x) == 'number' && typeof(y) == 'number') { | 73 if (typeof(x) == 'number' && typeof(y) == 'number') { |
54 var result = x % y; | 74 var result = x % y; |
55 if (result == 0) { | 75 if (result == 0) { |
56 return 0; // Make sure we don't return -0.0. | 76 return 0; // Make sure we don't return -0.0. |
57 } else if (result < 0) { | 77 } else if (result < 0) { |
58 if (y < 0) { | 78 if (y < 0) { |
59 return result - y; | 79 return result - y; |
60 } else { | 80 } else { |
61 return result + y; | 81 return result + y; |
62 } | 82 } |
63 } | 83 } |
64 return result; | 84 return result; |
65 } else { | 85 } else { |
66 return x.$mod(y); | 86 return x.$mod(y); |
67 } | 87 } |
68 } | 88 } |
| 89 function $mul(x, y) { |
| 90 return (typeof(x) == 'number' && typeof(y) == 'number') |
| 91 ? x * y : x.$mul(y); |
| 92 } |
69 function $ne(x, y) { | 93 function $ne(x, y) { |
70 if (x == null) return y != null; | 94 if (x == null) return y != null; |
71 return (typeof(x) == 'number' && typeof(y) == 'number') || | 95 return (typeof(x) == 'number' && typeof(y) == 'number') || |
72 (typeof(x) == 'boolean' && typeof(y) == 'boolean') || | 96 (typeof(x) == 'boolean' && typeof(y) == 'boolean') || |
73 (typeof(x) == 'string' && typeof(y) == 'string') | 97 (typeof(x) == 'string' && typeof(y) == 'string') |
74 ? x != y : !x.$eq(y); | 98 ? x != y : !x.$eq(y); |
75 } | 99 } |
| 100 function $shl(x, y) { |
| 101 return (typeof(x) == 'number' && typeof(y) == 'number') |
| 102 ? x << y : x.$shl(y); |
| 103 } |
| 104 function $sub(x, y) { |
| 105 return (typeof(x) == 'number' && typeof(y) == 'number') |
| 106 ? x - y : x.$sub(y); |
| 107 } |
76 function $truncdiv(x, y) { | 108 function $truncdiv(x, y) { |
77 if (typeof(x) == 'number' && typeof(y) == 'number') { | 109 if (typeof(x) == 'number' && typeof(y) == 'number') { |
78 if (y == 0) $throw(new IntegerDivisionByZeroException()); | 110 if (y == 0) $throw(new IntegerDivisionByZeroException()); |
79 var tmp = x / y; | 111 var tmp = x / y; |
80 return (tmp < 0) ? Math.ceil(tmp) : Math.floor(tmp); | 112 return (tmp < 0) ? Math.ceil(tmp) : Math.floor(tmp); |
81 } else { | 113 } else { |
82 return x.$truncdiv(y); | 114 return x.$truncdiv(y); |
83 } | 115 } |
84 } | 116 } |
85 // ********** Code for Object ************** | 117 // ********** Code for Object ************** |
86 Object.defineProperty(Object.prototype, "get$dynamic", { value: function() { | 118 Object.defineProperty(Object.prototype, "get$dynamic", { value: function() { |
87 "use strict"; return this; | 119 "use strict"; return this; |
88 }, enumerable: false, writable: true, configurable: true }); | 120 }, enumerable: false, writable: true, configurable: true }); |
89 Object.defineProperty(Object.prototype, "noSuchMethod", { value: function(name,
args) { | 121 Object.defineProperty(Object.prototype, "noSuchMethod", { value: function(name,
args) { |
90 $throw(new NoSuchMethodException(this, name, args)); | 122 $throw(new NoSuchMethodException(this, name, args)); |
91 }, enumerable: false, writable: true, configurable: true }); | 123 }, enumerable: false, writable: true, configurable: true }); |
92 Object.defineProperty(Object.prototype, "_asNonSentinelEntry$0", { value: functi
on() { | 124 Object.defineProperty(Object.prototype, "_pushBlock$1", { value: function($0) { |
93 return this.noSuchMethod$2("_asNonSentinelEntry", []); | 125 return this.noSuchMethod("_pushBlock", [$0]); |
94 }, enumerable: false, writable: true, configurable: true }); | 126 }, enumerable: false, writable: true, configurable: true }); |
95 Object.defineProperty(Object.prototype, "_checkExtends$0", { value: function() { | 127 Object.defineProperty(Object.prototype, "analyze$1", { value: function($0) { |
96 return this.noSuchMethod$2("_checkExtends", []); | 128 return this.noSuchMethod("analyze", [$0]); |
97 }, enumerable: false, writable: true, configurable: true }); | |
98 Object.defineProperty(Object.prototype, "_checkNonStatic$1", { value: function($
0) { | |
99 return this.noSuchMethod$2("_checkNonStatic", [$0]); | |
100 }, enumerable: false, writable: true, configurable: true }); | |
101 Object.defineProperty(Object.prototype, "_evalConstConstructor$2", { value: func
tion($0, $1) { | |
102 return this.noSuchMethod$2("_evalConstConstructor", [$0, $1]); | |
103 }, enumerable: false, writable: true, configurable: true }); | |
104 Object.defineProperty(Object.prototype, "_get$3", { value: function($0, $1, $2)
{ | |
105 return this.noSuchMethod$2("_get", [$0, $1, $2]); | |
106 }, enumerable: false, writable: true, configurable: true }); | |
107 Object.defineProperty(Object.prototype, "_get$3$isDynamic", { value: function($0
, $1, $2, isDynamic) { | |
108 return this.noSuchMethod$2("_get", [$0, $1, $2, isDynamic]); | |
109 }, enumerable: false, writable: true, configurable: true }); | |
110 Object.defineProperty(Object.prototype, "_get$4", { value: function($0, $1, $2,
$3) { | |
111 return this.noSuchMethod$2("_get", [$0, $1, $2, $3]); | |
112 }, enumerable: false, writable: true, configurable: true }); | |
113 Object.defineProperty(Object.prototype, "_pushBlock$1", { value: function($0) { | |
114 return this.noSuchMethod$2("_pushBlock", [$0]); | |
115 }, enumerable: false, writable: true, configurable: true }); | |
116 Object.defineProperty(Object.prototype, "_set$4$isDynamic", { value: function($0
, $1, $2, $3, isDynamic) { | |
117 return this.noSuchMethod$2("_set", [$0, $1, $2, $3, isDynamic]); | |
118 }, enumerable: false, writable: true, configurable: true }); | |
119 Object.defineProperty(Object.prototype, "_set$5", { value: function($0, $1, $2,
$3, $4) { | |
120 return this.noSuchMethod$2("_set", [$0, $1, $2, $3, $4]); | |
121 }, enumerable: false, writable: true, configurable: true }); | |
122 Object.defineProperty(Object.prototype, "add$1", { value: function($0) { | |
123 return this.noSuchMethod$2("add", [$0]); | |
124 }, enumerable: false, writable: true, configurable: true }); | |
125 Object.defineProperty(Object.prototype, "addAll$1", { value: function($0) { | |
126 return this.noSuchMethod$2("addAll", [$0]); | |
127 }, enumerable: false, writable: true, configurable: true }); | |
128 Object.defineProperty(Object.prototype, "addDirectSubtype$1", { value: function(
$0) { | |
129 return this.noSuchMethod$2("addDirectSubtype", [$0]); | |
130 }, enumerable: false, writable: true, configurable: true }); | |
131 Object.defineProperty(Object.prototype, "addLast$1", { value: function($0) { | |
132 return this.noSuchMethod$2("addLast", [$0]); | |
133 }, enumerable: false, writable: true, configurable: true }); | |
134 Object.defineProperty(Object.prototype, "addMethod$2", { value: function($0, $1)
{ | |
135 return this.noSuchMethod$2("addMethod", [$0, $1]); | |
136 }, enumerable: false, writable: true, configurable: true }); | |
137 Object.defineProperty(Object.prototype, "addSource$1", { value: function($0) { | |
138 return this.noSuchMethod$2("addSource", [$0]); | |
139 }, enumerable: false, writable: true, configurable: true }); | |
140 Object.defineProperty(Object.prototype, "binop$4", { value: function($0, $1, $2,
$3) { | |
141 return this.noSuchMethod$2("binop", [$0, $1, $2, $3]); | |
142 }, enumerable: false, writable: true, configurable: true }); | |
143 Object.defineProperty(Object.prototype, "block$0", { value: function() { | |
144 return this.noSuchMethod$2("block", []); | |
145 }, enumerable: false, writable: true, configurable: true }); | |
146 Object.defineProperty(Object.prototype, "canInvoke$2", { value: function($0, $1)
{ | |
147 return this.noSuchMethod$2("canInvoke", [$0, $1]); | |
148 }, enumerable: false, writable: true, configurable: true }); | |
149 Object.defineProperty(Object.prototype, "checkFirstClass$1", { value: function($
0) { | |
150 return this.noSuchMethod$2("checkFirstClass", [$0]); | |
151 }, enumerable: false, writable: true, configurable: true }); | |
152 Object.defineProperty(Object.prototype, "compareTo$1", { value: function($0) { | |
153 return this.noSuchMethod$2("compareTo", [$0]); | |
154 }, enumerable: false, writable: true, configurable: true }); | |
155 Object.defineProperty(Object.prototype, "compilationUnit$0", { value: function()
{ | |
156 return this.noSuchMethod$2("compilationUnit", []); | |
157 }, enumerable: false, writable: true, configurable: true }); | |
158 Object.defineProperty(Object.prototype, "computeValue$0", { value: function() { | |
159 return this.noSuchMethod$2("computeValue", []); | |
160 }, enumerable: false, writable: true, configurable: true }); | 129 }, enumerable: false, writable: true, configurable: true }); |
161 Object.defineProperty(Object.prototype, "contains$1", { value: function($0) { | 130 Object.defineProperty(Object.prototype, "contains$1", { value: function($0) { |
162 return this.noSuchMethod$2("contains", [$0]); | 131 return this.noSuchMethod("contains", [$0]); |
163 }, enumerable: false, writable: true, configurable: true }); | |
164 Object.defineProperty(Object.prototype, "containsKey$1", { value: function($0) { | |
165 return this.noSuchMethod$2("containsKey", [$0]); | |
166 }, enumerable: false, writable: true, configurable: true }); | |
167 Object.defineProperty(Object.prototype, "convertTo$2", { value: function($0, $1)
{ | |
168 return this.noSuchMethod$2("convertTo", [$0, $1]); | |
169 }, enumerable: false, writable: true, configurable: true }); | |
170 Object.defineProperty(Object.prototype, "convertTo$3", { value: function($0, $1,
$2) { | |
171 return this.noSuchMethod$2("convertTo", [$0, $1, $2]); | |
172 }, enumerable: false, writable: true, configurable: true }); | |
173 Object.defineProperty(Object.prototype, "copyWithNewType$2", { value: function($
0, $1) { | |
174 return this.noSuchMethod$2("copyWithNewType", [$0, $1]); | |
175 }, enumerable: false, writable: true, configurable: true }); | 132 }, enumerable: false, writable: true, configurable: true }); |
176 Object.defineProperty(Object.prototype, "create$3$isFinal", { value: function($0
, $1, $2, isFinal) { | 133 Object.defineProperty(Object.prototype, "create$3$isFinal", { value: function($0
, $1, $2, isFinal) { |
177 return this.noSuchMethod$2("create", [$0, $1, $2, isFinal]); | 134 return this.noSuchMethod("create", [$0, $1, $2, isFinal]); |
178 }, enumerable: false, writable: true, configurable: true }); | |
179 Object.defineProperty(Object.prototype, "elapsedInMs$0", { value: function() { | |
180 return this.noSuchMethod$2("elapsedInMs", []); | |
181 }, enumerable: false, writable: true, configurable: true }); | 135 }, enumerable: false, writable: true, configurable: true }); |
182 Object.defineProperty(Object.prototype, "end$0", { value: function() { | 136 Object.defineProperty(Object.prototype, "end$0", { value: function() { |
183 return this.noSuchMethod$2("end", []); | 137 return this.noSuchMethod("end", []); |
184 }, enumerable: false, writable: true, configurable: true }); | |
185 Object.defineProperty(Object.prototype, "endsWith$1", { value: function($0) { | |
186 return this.noSuchMethod$2("endsWith", [$0]); | |
187 }, enumerable: false, writable: true, configurable: true }); | |
188 Object.defineProperty(Object.prototype, "ensureSubtypeOf$3", { value: function($
0, $1, $2) { | |
189 return this.noSuchMethod$2("ensureSubtypeOf", [$0, $1, $2]); | |
190 }, enumerable: false, writable: true, configurable: true }); | |
191 Object.defineProperty(Object.prototype, "evalBody$2", { value: function($0, $1)
{ | |
192 return this.noSuchMethod$2("evalBody", [$0, $1]); | |
193 }, enumerable: false, writable: true, configurable: true }); | |
194 Object.defineProperty(Object.prototype, "filter$1", { value: function($0) { | |
195 return this.noSuchMethod$2("filter", [$0]); | |
196 }, enumerable: false, writable: true, configurable: true }); | |
197 Object.defineProperty(Object.prototype, "findTypeByName$1", { value: function($0
) { | |
198 return this.noSuchMethod$2("findTypeByName", [$0]); | |
199 }, enumerable: false, writable: true, configurable: true }); | |
200 Object.defineProperty(Object.prototype, "forEach$1", { value: function($0) { | |
201 return this.noSuchMethod$2("forEach", [$0]); | |
202 }, enumerable: false, writable: true, configurable: true }); | |
203 Object.defineProperty(Object.prototype, "genValue$2", { value: function($0, $1)
{ | |
204 return this.noSuchMethod$2("genValue", [$0, $1]); | |
205 }, enumerable: false, writable: true, configurable: true }); | |
206 Object.defineProperty(Object.prototype, "generate$1", { value: function($0) { | |
207 return this.noSuchMethod$2("generate", [$0]); | |
208 }, enumerable: false, writable: true, configurable: true }); | |
209 Object.defineProperty(Object.prototype, "getColumn$2", { value: function($0, $1)
{ | |
210 return this.noSuchMethod$2("getColumn", [$0, $1]); | |
211 }, enumerable: false, writable: true, configurable: true }); | |
212 Object.defineProperty(Object.prototype, "getConstructor$1", { value: function($0
) { | |
213 return this.noSuchMethod$2("getConstructor", [$0]); | |
214 }, enumerable: false, writable: true, configurable: true }); | |
215 Object.defineProperty(Object.prototype, "getFactory$2", { value: function($0, $1
) { | |
216 return this.noSuchMethod$2("getFactory", [$0, $1]); | |
217 }, enumerable: false, writable: true, configurable: true }); | |
218 Object.defineProperty(Object.prototype, "getGlobalValue$0", { value: function()
{ | |
219 return this.noSuchMethod$2("getGlobalValue", []); | |
220 }, enumerable: false, writable: true, configurable: true }); | |
221 Object.defineProperty(Object.prototype, "getKeys$0", { value: function() { | |
222 return this.noSuchMethod$2("getKeys", []); | |
223 }, enumerable: false, writable: true, configurable: true }); | |
224 Object.defineProperty(Object.prototype, "getLine$1", { value: function($0) { | |
225 return this.noSuchMethod$2("getLine", [$0]); | |
226 }, enumerable: false, writable: true, configurable: true }); | |
227 Object.defineProperty(Object.prototype, "getMember$1", { value: function($0) { | |
228 return this.noSuchMethod$2("getMember", [$0]); | |
229 }, enumerable: false, writable: true, configurable: true }); | |
230 Object.defineProperty(Object.prototype, "getOrMakeConcreteType$1", { value: func
tion($0) { | |
231 return this.noSuchMethod$2("getOrMakeConcreteType", [$0]); | |
232 }, enumerable: false, writable: true, configurable: true }); | |
233 Object.defineProperty(Object.prototype, "getValues$0", { value: function() { | |
234 return this.noSuchMethod$2("getValues", []); | |
235 }, enumerable: false, writable: true, configurable: true }); | |
236 Object.defineProperty(Object.prototype, "get_$3", { value: function($0, $1, $2)
{ | |
237 return this.noSuchMethod$2("get_", [$0, $1, $2]); | |
238 }, enumerable: false, writable: true, configurable: true }); | |
239 Object.defineProperty(Object.prototype, "hasNext$0", { value: function() { | |
240 return this.noSuchMethod$2("hasNext", []); | |
241 }, enumerable: false, writable: true, configurable: true }); | |
242 Object.defineProperty(Object.prototype, "hashCode$0", { value: function() { | |
243 return this.noSuchMethod$2("hashCode", []); | |
244 }, enumerable: false, writable: true, configurable: true }); | 138 }, enumerable: false, writable: true, configurable: true }); |
245 Object.defineProperty(Object.prototype, "indexOf$1", { value: function($0) { | 139 Object.defineProperty(Object.prototype, "indexOf$1", { value: function($0) { |
246 return this.noSuchMethod$2("indexOf", [$0]); | 140 return this.noSuchMethod("indexOf", [$0]); |
247 }, enumerable: false, writable: true, configurable: true }); | |
248 Object.defineProperty(Object.prototype, "initFields$0", { value: function() { | |
249 return this.noSuchMethod$2("initFields", []); | |
250 }, enumerable: false, writable: true, configurable: true }); | 141 }, enumerable: false, writable: true, configurable: true }); |
251 Object.defineProperty(Object.prototype, "instanceOf$3$isTrue$forceCheck", { valu
e: function($0, $1, $2, isTrue, forceCheck) { | 142 Object.defineProperty(Object.prototype, "instanceOf$3$isTrue$forceCheck", { valu
e: function($0, $1, $2, isTrue, forceCheck) { |
252 return this.noSuchMethod$2("instanceOf", [$0, $1, $2, isTrue, forceCheck]); | 143 return this.noSuchMethod("instanceOf", [$0, $1, $2, isTrue, forceCheck]); |
253 }, enumerable: false, writable: true, configurable: true }); | 144 }, enumerable: false, writable: true, configurable: true }); |
254 Object.defineProperty(Object.prototype, "instanceOf$4", { value: function($0, $1
, $2, $3) { | 145 Object.defineProperty(Object.prototype, "instanceOf$4", { value: function($0, $1
, $2, $3) { |
255 return this.noSuchMethod$2("instanceOf", [$0, $1, $2, $3]); | 146 return this.noSuchMethod("instanceOf", [$0, $1, $2, $3]); |
256 }, enumerable: false, writable: true, configurable: true }); | |
257 Object.defineProperty(Object.prototype, "invoke$4", { value: function($0, $1, $2
, $3) { | |
258 return this.noSuchMethod$2("invoke", [$0, $1, $2, $3]); | |
259 }, enumerable: false, writable: true, configurable: true }); | |
260 Object.defineProperty(Object.prototype, "invoke$4$isDynamic", { value: function(
$0, $1, $2, $3, isDynamic) { | |
261 return this.noSuchMethod$2("invoke", [$0, $1, $2, $3, isDynamic]); | |
262 }, enumerable: false, writable: true, configurable: true }); | |
263 Object.defineProperty(Object.prototype, "invoke$5", { value: function($0, $1, $2
, $3, $4) { | |
264 return this.noSuchMethod$2("invoke", [$0, $1, $2, $3, $4]); | |
265 }, enumerable: false, writable: true, configurable: true }); | |
266 Object.defineProperty(Object.prototype, "invokeNoSuchMethod$4", { value: functio
n($0, $1, $2, $3) { | |
267 return this.noSuchMethod$2("invokeNoSuchMethod", [$0, $1, $2, $3]); | |
268 }, enumerable: false, writable: true, configurable: true }); | 147 }, enumerable: false, writable: true, configurable: true }); |
269 Object.defineProperty(Object.prototype, "is$List", { value: function() { | 148 Object.defineProperty(Object.prototype, "is$List", { value: function() { |
270 return false; | 149 return false; |
271 }, enumerable: false, writable: true, configurable: true }); | 150 }, enumerable: false, writable: true, configurable: true }); |
272 Object.defineProperty(Object.prototype, "is$RegExp", { value: function() { | 151 Object.defineProperty(Object.prototype, "is$RegExp", { value: function() { |
273 return false; | 152 return false; |
274 }, enumerable: false, writable: true, configurable: true }); | 153 }, enumerable: false, writable: true, configurable: true }); |
275 Object.defineProperty(Object.prototype, "isAssignable$1", { value: function($0)
{ | 154 Object.defineProperty(Object.prototype, "remove$1", { value: function($0) { |
276 return this.noSuchMethod$2("isAssignable", [$0]); | 155 return this.noSuchMethod("remove", [$0]); |
277 }, enumerable: false, writable: true, configurable: true }); | |
278 Object.defineProperty(Object.prototype, "isEmpty$0", { value: function() { | |
279 return this.noSuchMethod$2("isEmpty", []); | |
280 }, enumerable: false, writable: true, configurable: true }); | |
281 Object.defineProperty(Object.prototype, "isSubtypeOf$1", { value: function($0) { | |
282 return this.noSuchMethod$2("isSubtypeOf", [$0]); | |
283 }, enumerable: false, writable: true, configurable: true }); | |
284 Object.defineProperty(Object.prototype, "iterator$0", { value: function() { | |
285 return this.noSuchMethod$2("iterator", []); | |
286 }, enumerable: false, writable: true, configurable: true }); | |
287 Object.defineProperty(Object.prototype, "last$0", { value: function() { | |
288 return this.noSuchMethod$2("last", []); | |
289 }, enumerable: false, writable: true, configurable: true }); | |
290 Object.defineProperty(Object.prototype, "lookup$2", { value: function($0, $1) { | |
291 return this.noSuchMethod$2("lookup", [$0, $1]); | |
292 }, enumerable: false, writable: true, configurable: true }); | |
293 Object.defineProperty(Object.prototype, "markUsed$0", { value: function() { | |
294 return this.noSuchMethod$2("markUsed", []); | |
295 }, enumerable: false, writable: true, configurable: true }); | |
296 Object.defineProperty(Object.prototype, "namesInOrder$1", { value: function($0)
{ | |
297 return this.noSuchMethod$2("namesInOrder", [$0]); | |
298 }, enumerable: false, writable: true, configurable: true }); | |
299 Object.defineProperty(Object.prototype, "needsConversion$1", { value: function($
0) { | |
300 return this.noSuchMethod$2("needsConversion", [$0]); | |
301 }, enumerable: false, writable: true, configurable: true }); | |
302 Object.defineProperty(Object.prototype, "next$0", { value: function() { | |
303 return this.noSuchMethod$2("next", []); | |
304 }, enumerable: false, writable: true, configurable: true }); | |
305 Object.defineProperty(Object.prototype, "noSuchMethod$2", { value: function($0,
$1) { | |
306 return this.noSuchMethod($0, $1); | |
307 }, enumerable: false, writable: true, configurable: true }); | |
308 Object.defineProperty(Object.prototype, "postResolveChecks$0", { value: function
() { | |
309 return this.noSuchMethod$2("postResolveChecks", []); | |
310 }, enumerable: false, writable: true, configurable: true }); | |
311 Object.defineProperty(Object.prototype, "provideFieldSyntax$0", { value: functio
n() { | |
312 return this.noSuchMethod$2("provideFieldSyntax", []); | |
313 }, enumerable: false, writable: true, configurable: true }); | |
314 Object.defineProperty(Object.prototype, "providePropertySyntax$0", { value: func
tion() { | |
315 return this.noSuchMethod$2("providePropertySyntax", []); | |
316 }, enumerable: false, writable: true, configurable: true }); | |
317 Object.defineProperty(Object.prototype, "removeLast$0", { value: function() { | |
318 return this.noSuchMethod$2("removeLast", []); | |
319 }, enumerable: false, writable: true, configurable: true }); | |
320 Object.defineProperty(Object.prototype, "replaceFirst$2", { value: function($0,
$1) { | |
321 return this.noSuchMethod$2("replaceFirst", [$0, $1]); | |
322 }, enumerable: false, writable: true, configurable: true }); | |
323 Object.defineProperty(Object.prototype, "replaceValue$1", { value: function($0)
{ | |
324 return this.noSuchMethod$2("replaceValue", [$0]); | |
325 }, enumerable: false, writable: true, configurable: true }); | |
326 Object.defineProperty(Object.prototype, "resolve$0", { value: function() { | |
327 return this.noSuchMethod$2("resolve", []); | |
328 }, enumerable: false, writable: true, configurable: true }); | |
329 Object.defineProperty(Object.prototype, "resolveType$2", { value: function($0, $
1) { | |
330 return this.noSuchMethod$2("resolveType", [$0, $1]); | |
331 }, enumerable: false, writable: true, configurable: true }); | |
332 Object.defineProperty(Object.prototype, "resolveTypeParams$1", { value: function
($0) { | |
333 return this.noSuchMethod$2("resolveTypeParams", [$0]); | |
334 }, enumerable: false, writable: true, configurable: true }); | 156 }, enumerable: false, writable: true, configurable: true }); |
335 Object.defineProperty(Object.prototype, "run$0", { value: function() { | 157 Object.defineProperty(Object.prototype, "run$0", { value: function() { |
336 return this.noSuchMethod$2("run", []); | 158 return this.noSuchMethod("run", []); |
337 }, enumerable: false, writable: true, configurable: true }); | 159 }, enumerable: false, writable: true, configurable: true }); |
338 Object.defineProperty(Object.prototype, "setDefinition$1", { value: function($0)
{ | 160 Object.defineProperty(Object.prototype, "setIndex$4$kind", { value: function($0,
$1, $2, $3, kind) { |
339 return this.noSuchMethod$2("setDefinition", [$0]); | 161 return this.noSuchMethod("setIndex", [$0, $1, $2, $3, kind]); |
340 }, enumerable: false, writable: true, configurable: true }); | 162 }, enumerable: false, writable: true, configurable: true }); |
341 Object.defineProperty(Object.prototype, "setIndex$4$kind$returnKind", { value: f
unction($0, $1, $2, $3, kind, returnKind) { | 163 Object.defineProperty(Object.prototype, "setIndex$4$kind$returnKind", { value: f
unction($0, $1, $2, $3, kind, returnKind) { |
342 return this.noSuchMethod$2("setIndex", [$0, $1, $2, $3, kind, returnKind]); | 164 return this.noSuchMethod("setIndex", [$0, $1, $2, $3, kind, returnKind]); |
| 165 }, enumerable: false, writable: true, configurable: true }); |
| 166 Object.defineProperty(Object.prototype, "set_$4$kind", { value: function($0, $1,
$2, $3, kind) { |
| 167 return this.noSuchMethod("set_", [$0, $1, $2, $3, kind]); |
343 }, enumerable: false, writable: true, configurable: true }); | 168 }, enumerable: false, writable: true, configurable: true }); |
344 Object.defineProperty(Object.prototype, "set_$4$kind$returnKind", { value: funct
ion($0, $1, $2, $3, kind, returnKind) { | 169 Object.defineProperty(Object.prototype, "set_$4$kind$returnKind", { value: funct
ion($0, $1, $2, $3, kind, returnKind) { |
345 return this.noSuchMethod$2("set_", [$0, $1, $2, $3, kind, returnKind]); | 170 return this.noSuchMethod("set_", [$0, $1, $2, $3, kind, returnKind]); |
346 }, enumerable: false, writable: true, configurable: true }); | |
347 Object.defineProperty(Object.prototype, "sort$1", { value: function($0) { | |
348 return this.noSuchMethod$2("sort", [$0]); | |
349 }, enumerable: false, writable: true, configurable: true }); | |
350 Object.defineProperty(Object.prototype, "start$0", { value: function() { | |
351 return this.noSuchMethod$2("start", []); | |
352 }, enumerable: false, writable: true, configurable: true }); | |
353 Object.defineProperty(Object.prototype, "startsWith$1", { value: function($0) { | |
354 return this.noSuchMethod$2("startsWith", [$0]); | |
355 }, enumerable: false, writable: true, configurable: true }); | |
356 Object.defineProperty(Object.prototype, "stop$0", { value: function() { | |
357 return this.noSuchMethod$2("stop", []); | |
358 }, enumerable: false, writable: true, configurable: true }); | 171 }, enumerable: false, writable: true, configurable: true }); |
359 Object.defineProperty(Object.prototype, "substring$1", { value: function($0) { | 172 Object.defineProperty(Object.prototype, "substring$1", { value: function($0) { |
360 return this.noSuchMethod$2("substring", [$0]); | 173 return this.noSuchMethod("substring", [$0]); |
361 }, enumerable: false, writable: true, configurable: true }); | |
362 Object.defineProperty(Object.prototype, "substring$2", { value: function($0, $1)
{ | |
363 return this.noSuchMethod$2("substring", [$0, $1]); | |
364 }, enumerable: false, writable: true, configurable: true }); | |
365 Object.defineProperty(Object.prototype, "toRadixString$1", { value: function($0)
{ | |
366 return this.noSuchMethod$2("toRadixString", [$0]); | |
367 }, enumerable: false, writable: true, configurable: true }); | 174 }, enumerable: false, writable: true, configurable: true }); |
368 Object.defineProperty(Object.prototype, "toString$0", { value: function() { | 175 Object.defineProperty(Object.prototype, "toString$0", { value: function() { |
369 return this.toString(); | 176 return this.toString(); |
370 }, enumerable: false, writable: true, configurable: true }); | 177 }, enumerable: false, writable: true, configurable: true }); |
371 Object.defineProperty(Object.prototype, "unop$3", { value: function($0, $1, $2)
{ | |
372 return this.noSuchMethod$2("unop", [$0, $1, $2]); | |
373 }, enumerable: false, writable: true, configurable: true }); | |
374 Object.defineProperty(Object.prototype, "visit$1", { value: function($0) { | |
375 return this.noSuchMethod$2("visit", [$0]); | |
376 }, enumerable: false, writable: true, configurable: true }); | |
377 Object.defineProperty(Object.prototype, "visitAssertStatement$1", { value: funct
ion($0) { | |
378 return this.noSuchMethod$2("visitAssertStatement", [$0]); | |
379 }, enumerable: false, writable: true, configurable: true }); | |
380 Object.defineProperty(Object.prototype, "visitBinaryExpression$1", { value: func
tion($0) { | 178 Object.defineProperty(Object.prototype, "visitBinaryExpression$1", { value: func
tion($0) { |
381 return this.noSuchMethod$2("visitBinaryExpression", [$0]); | 179 return this.noSuchMethod("visitBinaryExpression", [$0]); |
382 }, enumerable: false, writable: true, configurable: true }); | |
383 Object.defineProperty(Object.prototype, "visitBlockStatement$1", { value: functi
on($0) { | |
384 return this.noSuchMethod$2("visitBlockStatement", [$0]); | |
385 }, enumerable: false, writable: true, configurable: true }); | |
386 Object.defineProperty(Object.prototype, "visitBreakStatement$1", { value: functi
on($0) { | |
387 return this.noSuchMethod$2("visitBreakStatement", [$0]); | |
388 }, enumerable: false, writable: true, configurable: true }); | |
389 Object.defineProperty(Object.prototype, "visitContinueStatement$1", { value: fun
ction($0) { | |
390 return this.noSuchMethod$2("visitContinueStatement", [$0]); | |
391 }, enumerable: false, writable: true, configurable: true }); | |
392 Object.defineProperty(Object.prototype, "visitDeclaredIdentifier$1", { value: fu
nction($0) { | |
393 return this.noSuchMethod$2("visitDeclaredIdentifier", [$0]); | |
394 }, enumerable: false, writable: true, configurable: true }); | |
395 Object.defineProperty(Object.prototype, "visitDietStatement$1", { value: functio
n($0) { | |
396 return this.noSuchMethod$2("visitDietStatement", [$0]); | |
397 }, enumerable: false, writable: true, configurable: true }); | |
398 Object.defineProperty(Object.prototype, "visitDoStatement$1", { value: function(
$0) { | |
399 return this.noSuchMethod$2("visitDoStatement", [$0]); | |
400 }, enumerable: false, writable: true, configurable: true }); | |
401 Object.defineProperty(Object.prototype, "visitEmptyStatement$1", { value: functi
on($0) { | |
402 return this.noSuchMethod$2("visitEmptyStatement", [$0]); | |
403 }, enumerable: false, writable: true, configurable: true }); | |
404 Object.defineProperty(Object.prototype, "visitExpressionStatement$1", { value: f
unction($0) { | |
405 return this.noSuchMethod$2("visitExpressionStatement", [$0]); | |
406 }, enumerable: false, writable: true, configurable: true }); | |
407 Object.defineProperty(Object.prototype, "visitForInStatement$1", { value: functi
on($0) { | |
408 return this.noSuchMethod$2("visitForInStatement", [$0]); | |
409 }, enumerable: false, writable: true, configurable: true }); | |
410 Object.defineProperty(Object.prototype, "visitForStatement$1", { value: function
($0) { | |
411 return this.noSuchMethod$2("visitForStatement", [$0]); | |
412 }, enumerable: false, writable: true, configurable: true }); | |
413 Object.defineProperty(Object.prototype, "visitFunctionDefinition$1", { value: fu
nction($0) { | |
414 return this.noSuchMethod$2("visitFunctionDefinition", [$0]); | |
415 }, enumerable: false, writable: true, configurable: true }); | |
416 Object.defineProperty(Object.prototype, "visitIfStatement$1", { value: function(
$0) { | |
417 return this.noSuchMethod$2("visitIfStatement", [$0]); | |
418 }, enumerable: false, writable: true, configurable: true }); | |
419 Object.defineProperty(Object.prototype, "visitIndexExpression$1", { value: funct
ion($0) { | |
420 return this.noSuchMethod$2("visitIndexExpression", [$0]); | |
421 }, enumerable: false, writable: true, configurable: true }); | |
422 Object.defineProperty(Object.prototype, "visitLabeledStatement$1", { value: func
tion($0) { | |
423 return this.noSuchMethod$2("visitLabeledStatement", [$0]); | |
424 }, enumerable: false, writable: true, configurable: true }); | |
425 Object.defineProperty(Object.prototype, "visitLambdaExpression$1", { value: func
tion($0) { | |
426 return this.noSuchMethod$2("visitLambdaExpression", [$0]); | |
427 }, enumerable: false, writable: true, configurable: true }); | |
428 Object.defineProperty(Object.prototype, "visitLiteralExpression$1", { value: fun
ction($0) { | |
429 return this.noSuchMethod$2("visitLiteralExpression", [$0]); | |
430 }, enumerable: false, writable: true, configurable: true }); | |
431 Object.defineProperty(Object.prototype, "visitMapExpression$1", { value: functio
n($0) { | |
432 return this.noSuchMethod$2("visitMapExpression", [$0]); | |
433 }, enumerable: false, writable: true, configurable: true }); | |
434 Object.defineProperty(Object.prototype, "visitNewExpression$1", { value: functio
n($0) { | |
435 return this.noSuchMethod$2("visitNewExpression", [$0]); | |
436 }, enumerable: false, writable: true, configurable: true }); | 180 }, enumerable: false, writable: true, configurable: true }); |
437 Object.defineProperty(Object.prototype, "visitPostfixExpression$1", { value: fun
ction($0) { | 181 Object.defineProperty(Object.prototype, "visitPostfixExpression$1", { value: fun
ction($0) { |
438 return this.noSuchMethod$2("visitPostfixExpression", [$0]); | 182 return this.noSuchMethod("visitPostfixExpression", [$0]); |
439 }, enumerable: false, writable: true, configurable: true }); | |
440 Object.defineProperty(Object.prototype, "visitReturnStatement$1", { value: funct
ion($0) { | |
441 return this.noSuchMethod$2("visitReturnStatement", [$0]); | |
442 }, enumerable: false, writable: true, configurable: true }); | |
443 Object.defineProperty(Object.prototype, "visitSources$0", { value: function() { | |
444 return this.noSuchMethod$2("visitSources", []); | |
445 }, enumerable: false, writable: true, configurable: true }); | |
446 Object.defineProperty(Object.prototype, "visitSwitchStatement$1", { value: funct
ion($0) { | |
447 return this.noSuchMethod$2("visitSwitchStatement", [$0]); | |
448 }, enumerable: false, writable: true, configurable: true }); | |
449 Object.defineProperty(Object.prototype, "visitThrowStatement$1", { value: functi
on($0) { | |
450 return this.noSuchMethod$2("visitThrowStatement", [$0]); | |
451 }, enumerable: false, writable: true, configurable: true }); | |
452 Object.defineProperty(Object.prototype, "visitTryStatement$1", { value: function
($0) { | |
453 return this.noSuchMethod$2("visitTryStatement", [$0]); | |
454 }, enumerable: false, writable: true, configurable: true }); | |
455 Object.defineProperty(Object.prototype, "visitVariableDefinition$1", { value: fu
nction($0) { | |
456 return this.noSuchMethod$2("visitVariableDefinition", [$0]); | |
457 }, enumerable: false, writable: true, configurable: true }); | |
458 Object.defineProperty(Object.prototype, "visitWhileStatement$1", { value: functi
on($0) { | |
459 return this.noSuchMethod$2("visitWhileStatement", [$0]); | |
460 }, enumerable: false, writable: true, configurable: true }); | 183 }, enumerable: false, writable: true, configurable: true }); |
461 Object.defineProperty(Object.prototype, "write$1", { value: function($0) { | 184 Object.defineProperty(Object.prototype, "write$1", { value: function($0) { |
462 return this.noSuchMethod$2("write", [$0]); | 185 return this.noSuchMethod("write", [$0]); |
463 }, enumerable: false, writable: true, configurable: true }); | |
464 Object.defineProperty(Object.prototype, "writeDefinition$2", { value: function($
0, $1) { | |
465 return this.noSuchMethod$2("writeDefinition", [$0, $1]); | |
466 }, enumerable: false, writable: true, configurable: true }); | 186 }, enumerable: false, writable: true, configurable: true }); |
467 // ********** Code for Clock ************** | 187 // ********** Code for Clock ************** |
468 function Clock() {} | 188 function Clock() {} |
469 Clock.now = function() { | 189 Clock.now = function() { |
470 return new Date().getTime(); | 190 return new Date().getTime(); |
471 } | 191 } |
472 Clock.frequency = function() { | 192 Clock.frequency = function() { |
473 return (1000); | 193 return (1000); |
474 } | 194 } |
475 // ********** Code for IllegalAccessException ************** | 195 // ********** Code for IllegalAccessException ************** |
(...skipping 10 matching lines...) Expand all Loading... |
486 this._functionName = _functionName; | 206 this._functionName = _functionName; |
487 this._arguments = _arguments; | 207 this._arguments = _arguments; |
488 } | 208 } |
489 NoSuchMethodException.prototype.toString = function() { | 209 NoSuchMethodException.prototype.toString = function() { |
490 var sb = new StringBufferImpl(""); | 210 var sb = new StringBufferImpl(""); |
491 for (var i = (0); | 211 for (var i = (0); |
492 i < this._arguments.get$length(); i++) { | 212 i < this._arguments.get$length(); i++) { |
493 if (i > (0)) { | 213 if (i > (0)) { |
494 sb.add(", "); | 214 sb.add(", "); |
495 } | 215 } |
496 sb.add(this._arguments[i]); | 216 sb.add(this._arguments.$index(i)); |
497 } | 217 } |
498 sb.add("]"); | 218 sb.add("]"); |
499 return ("NoSuchMethodException - receiver: '" + this._receiver + "' ") + ("fun
ction name: '" + this._functionName + "' arguments: [" + sb + "]"); | 219 return $add(("NoSuchMethodException - receiver: '" + this._receiver + "' "), (
"function name: '" + this._functionName + "' arguments: [" + sb + "]")); |
500 } | 220 } |
501 NoSuchMethodException.prototype.toString$0 = NoSuchMethodException.prototype.toS
tring; | 221 NoSuchMethodException.prototype.toString$0 = NoSuchMethodException.prototype.toS
tring; |
502 // ********** Code for ClosureArgumentMismatchException ************** | 222 // ********** Code for ClosureArgumentMismatchException ************** |
503 function ClosureArgumentMismatchException() { | 223 function ClosureArgumentMismatchException() { |
504 | 224 |
505 } | 225 } |
506 ClosureArgumentMismatchException.prototype.toString = function() { | 226 ClosureArgumentMismatchException.prototype.toString = function() { |
507 return "Closure argument mismatch"; | 227 return "Closure argument mismatch"; |
508 } | 228 } |
509 ClosureArgumentMismatchException.prototype.toString$0 = ClosureArgumentMismatchE
xception.prototype.toString; | 229 ClosureArgumentMismatchException.prototype.toString$0 = ClosureArgumentMismatchE
xception.prototype.toString; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 } | 395 } |
676 } | 396 } |
677 return e; | 397 return e; |
678 } | 398 } |
679 // ********** Library dart:coreimpl ************** | 399 // ********** Library dart:coreimpl ************** |
680 // ********** Code for ListFactory ************** | 400 // ********** Code for ListFactory ************** |
681 ListFactory = Array; | 401 ListFactory = Array; |
682 Object.defineProperty(ListFactory.prototype, "is$List", { value: function(){retu
rn true}, enumerable: false, writable: true, configurable: true }); | 402 Object.defineProperty(ListFactory.prototype, "is$List", { value: function(){retu
rn true}, enumerable: false, writable: true, configurable: true }); |
683 ListFactory.ListFactory$from$factory = function(other) { | 403 ListFactory.ListFactory$from$factory = function(other) { |
684 var list = []; | 404 var list = []; |
685 for (var $$i = other.iterator$0(); $$i.hasNext$0(); ) { | 405 for (var $$i = other.iterator(); $$i.hasNext(); ) { |
686 var e = $$i.next$0(); | 406 var e = $$i.next(); |
687 list.add$1(e); | 407 list.add(e); |
688 } | 408 } |
689 return list; | 409 return list; |
690 } | 410 } |
691 Object.defineProperty(ListFactory.prototype, "get$length", { value: function() {
return this.length; }, enumerable: false, writable: true, configurable: true })
; | 411 Object.defineProperty(ListFactory.prototype, "get$length", { value: function() {
return this.length; }, enumerable: false, writable: true, configurable: true })
; |
692 Object.defineProperty(ListFactory.prototype, "set$length", { value: function(val
ue) { return this.length = value; }, enumerable: false, writable: true, configur
able: true }); | 412 Object.defineProperty(ListFactory.prototype, "set$length", { value: function(val
ue) { return this.length = value; }, enumerable: false, writable: true, configur
able: true }); |
693 Object.defineProperty(ListFactory.prototype, "add", { value: function(value) { | 413 Object.defineProperty(ListFactory.prototype, "add", { value: function(value) { |
694 this.push(value); | 414 this.push(value); |
695 }, enumerable: false, writable: true, configurable: true }); | 415 }, enumerable: false, writable: true, configurable: true }); |
696 Object.defineProperty(ListFactory.prototype, "addLast", { value: function(value)
{ | 416 Object.defineProperty(ListFactory.prototype, "addLast", { value: function(value)
{ |
697 this.push(value); | 417 this.push(value); |
698 }, enumerable: false, writable: true, configurable: true }); | 418 }, enumerable: false, writable: true, configurable: true }); |
699 Object.defineProperty(ListFactory.prototype, "addAll", { value: function(collect
ion) { | 419 Object.defineProperty(ListFactory.prototype, "addAll", { value: function(collect
ion) { |
700 for (var $$i = collection.iterator$0(); $$i.hasNext$0(); ) { | 420 for (var $$i = collection.iterator(); $$i.hasNext(); ) { |
701 var item = $$i.next$0(); | 421 var item = $$i.next(); |
702 this.add(item); | 422 this.add(item); |
703 } | 423 } |
704 }, enumerable: false, writable: true, configurable: true }); | 424 }, enumerable: false, writable: true, configurable: true }); |
705 Object.defineProperty(ListFactory.prototype, "clear", { value: function() { | 425 Object.defineProperty(ListFactory.prototype, "clear", { value: function() { |
706 this.set$length((0)); | 426 this.set$length((0)); |
707 }, enumerable: false, writable: true, configurable: true }); | 427 }, enumerable: false, writable: true, configurable: true }); |
708 Object.defineProperty(ListFactory.prototype, "removeLast", { value: function() { | 428 Object.defineProperty(ListFactory.prototype, "removeLast", { value: function() { |
709 return this.pop(); | 429 return this.pop(); |
710 }, enumerable: false, writable: true, configurable: true }); | 430 }, enumerable: false, writable: true, configurable: true }); |
711 Object.defineProperty(ListFactory.prototype, "last", { value: function() { | 431 Object.defineProperty(ListFactory.prototype, "last", { value: function() { |
712 return this[this.get$length() - (1)]; | 432 return this[this.get$length() - (1)]; |
713 }, enumerable: false, writable: true, configurable: true }); | 433 }, enumerable: false, writable: true, configurable: true }); |
714 Object.defineProperty(ListFactory.prototype, "getRange", { value: function(start
, length) { | 434 Object.defineProperty(ListFactory.prototype, "getRange", { value: function(start
, length) { |
715 return this.slice(start, start + length); | 435 return this.slice(start, start + length); |
716 }, enumerable: false, writable: true, configurable: true }); | 436 }, enumerable: false, writable: true, configurable: true }); |
717 Object.defineProperty(ListFactory.prototype, "isEmpty", { value: function() { | 437 Object.defineProperty(ListFactory.prototype, "isEmpty", { value: function() { |
718 return this.get$length() == (0); | 438 return this.get$length() == (0); |
719 }, enumerable: false, writable: true, configurable: true }); | 439 }, enumerable: false, writable: true, configurable: true }); |
720 Object.defineProperty(ListFactory.prototype, "iterator", { value: function() { | 440 Object.defineProperty(ListFactory.prototype, "iterator", { value: function() { |
721 return new ListIterator(this); | 441 return new ListIterator(this); |
722 }, enumerable: false, writable: true, configurable: true }); | 442 }, enumerable: false, writable: true, configurable: true }); |
723 Object.defineProperty(ListFactory.prototype, "add$1", { value: ListFactory.proto
type.add, enumerable: false, writable: true, configurable: true }); | |
724 Object.defineProperty(ListFactory.prototype, "addAll$1", { value: ListFactory.pr
ototype.addAll, enumerable: false, writable: true, configurable: true }); | |
725 Object.defineProperty(ListFactory.prototype, "addLast$1", { value: ListFactory.p
rototype.addLast, enumerable: false, writable: true, configurable: true }); | |
726 Object.defineProperty(ListFactory.prototype, "filter$1", { value: function($0) { | |
727 return this.filter(to$call$1($0)); | |
728 }, enumerable: false, writable: true, configurable: true }); | |
729 Object.defineProperty(ListFactory.prototype, "forEach$1", { value: function($0)
{ | |
730 return this.forEach(to$call$1($0)); | |
731 }, enumerable: false, writable: true, configurable: true }); | |
732 Object.defineProperty(ListFactory.prototype, "indexOf$1", { value: ListFactory.p
rototype.indexOf, enumerable: false, writable: true, configurable: true }); | 443 Object.defineProperty(ListFactory.prototype, "indexOf$1", { value: ListFactory.p
rototype.indexOf, enumerable: false, writable: true, configurable: true }); |
733 Object.defineProperty(ListFactory.prototype, "isEmpty$0", { value: ListFactory.p
rototype.isEmpty, enumerable: false, writable: true, configurable: true }); | |
734 Object.defineProperty(ListFactory.prototype, "iterator$0", { value: ListFactory.
prototype.iterator, enumerable: false, writable: true, configurable: true }); | |
735 Object.defineProperty(ListFactory.prototype, "last$0", { value: ListFactory.prot
otype.last, enumerable: false, writable: true, configurable: true }); | |
736 Object.defineProperty(ListFactory.prototype, "removeLast$0", { value: ListFactor
y.prototype.removeLast, enumerable: false, writable: true, configurable: true })
; | |
737 Object.defineProperty(ListFactory.prototype, "sort$1", { value: function($0) { | |
738 return this.sort(to$call$2($0)); | |
739 }, enumerable: false, writable: true, configurable: true }); | |
740 ListFactory_E = ListFactory; | |
741 ListFactory_Expression = ListFactory; | |
742 ListFactory_K = ListFactory; | |
743 ListFactory_dart_core_String = ListFactory; | |
744 ListFactory_V = ListFactory; | |
745 ListFactory_VariableValue = ListFactory; | |
746 ListFactory_int = ListFactory; | |
747 // ********** Code for ListIterator ************** | 444 // ********** Code for ListIterator ************** |
748 function ListIterator(array) { | 445 function ListIterator(array) { |
749 this._array = array; | 446 this._array = array; |
750 this._pos = (0); | 447 this._pos = (0); |
751 } | 448 } |
752 ListIterator.prototype.hasNext = function() { | 449 ListIterator.prototype.hasNext = function() { |
753 return this._array.get$length() > this._pos; | 450 return this._array.get$length() > this._pos; |
754 } | 451 } |
755 ListIterator.prototype.next = function() { | 452 ListIterator.prototype.next = function() { |
756 if (!this.hasNext()) { | 453 if (!this.hasNext()) { |
757 $throw(const$0005); | 454 $throw(const$0001); |
758 } | 455 } |
759 return this._array[this._pos++]; | 456 return this._array.$index(this._pos++); |
760 } | 457 } |
761 ListIterator.prototype.hasNext$0 = ListIterator.prototype.hasNext; | |
762 ListIterator.prototype.next$0 = ListIterator.prototype.next; | |
763 // ********** Code for ImmutableList ************** | 458 // ********** Code for ImmutableList ************** |
764 /** Implements extends for Dart classes on JavaScript prototypes. */ | 459 /** Implements extends for Dart classes on JavaScript prototypes. */ |
765 function $inherits(child, parent) { | 460 function $inherits(child, parent) { |
766 if (child.prototype.__proto__) { | 461 if (child.prototype.__proto__) { |
767 child.prototype.__proto__ = parent.prototype; | 462 child.prototype.__proto__ = parent.prototype; |
768 } else { | 463 } else { |
769 function tmp() {}; | 464 function tmp() {}; |
770 tmp.prototype = parent.prototype; | 465 tmp.prototype = parent.prototype; |
771 child.prototype = new tmp(); | 466 child.prototype = new tmp(); |
772 child.prototype.constructor = child; | 467 child.prototype.constructor = child; |
773 } | 468 } |
774 } | 469 } |
775 $inherits(ImmutableList, ListFactory_E); | 470 $inherits(ImmutableList, ListFactory); |
776 function ImmutableList(length) { | 471 function ImmutableList(length) { |
777 Array.call(this, length); | 472 Array.call(this, length); |
778 } | 473 } |
779 ImmutableList.ImmutableList$from$factory = function(other) { | 474 ImmutableList.ImmutableList$from$factory = function(other) { |
780 return _constList(other); | 475 return _constList(other); |
781 } | 476 } |
782 ImmutableList.prototype.get$length = function() { | 477 ImmutableList.prototype.get$length = function() { |
783 return this.length; | 478 return this.length; |
784 } | 479 } |
785 ImmutableList.prototype.set$length = function(length) { | 480 ImmutableList.prototype.set$length = function(length) { |
786 $throw(const$0007); | 481 $throw(const$0006); |
787 } | 482 } |
788 ImmutableList.prototype.$setindex = function(index, value) { | 483 ImmutableList.prototype.$setindex = function(index, value) { |
789 $throw(const$0007); | 484 $throw(const$0006); |
790 } | 485 } |
791 ImmutableList.prototype.sort = function(compare) { | 486 ImmutableList.prototype.sort = function(compare) { |
792 $throw(const$0007); | 487 $throw(const$0006); |
793 } | 488 } |
794 ImmutableList.prototype.add = function(element) { | 489 ImmutableList.prototype.add = function(element) { |
795 $throw(const$0007); | 490 $throw(const$0006); |
796 } | 491 } |
797 ImmutableList.prototype.addLast = function(element) { | 492 ImmutableList.prototype.addLast = function(element) { |
798 $throw(const$0007); | 493 $throw(const$0006); |
799 } | 494 } |
800 ImmutableList.prototype.addAll = function(elements) { | 495 ImmutableList.prototype.addAll = function(elements) { |
801 $throw(const$0007); | 496 $throw(const$0006); |
802 } | 497 } |
803 ImmutableList.prototype.clear = function() { | 498 ImmutableList.prototype.clear = function() { |
804 $throw(const$0007); | 499 $throw(const$0006); |
805 } | 500 } |
806 ImmutableList.prototype.removeLast = function() { | 501 ImmutableList.prototype.removeLast = function() { |
807 $throw(const$0007); | 502 $throw(const$0006); |
808 } | 503 } |
809 ImmutableList.prototype.toString = function() { | 504 ImmutableList.prototype.toString = function() { |
810 return ListFactory.ListFactory$from$factory(this).toString$0(); | 505 return ListFactory.ListFactory$from$factory(this).toString$0(); |
811 } | 506 } |
812 ImmutableList.prototype.add$1 = ImmutableList.prototype.add; | |
813 ImmutableList.prototype.addAll$1 = ImmutableList.prototype.addAll; | |
814 ImmutableList.prototype.addLast$1 = ImmutableList.prototype.addLast; | |
815 ImmutableList.prototype.removeLast$0 = ImmutableList.prototype.removeLast; | |
816 ImmutableList.prototype.sort$1 = function($0) { | |
817 return this.sort(to$call$2($0)); | |
818 }; | |
819 ImmutableList.prototype.toString$0 = ImmutableList.prototype.toString; | 507 ImmutableList.prototype.toString$0 = ImmutableList.prototype.toString; |
820 // ********** Code for NumImplementation ************** | 508 // ********** Code for NumImplementation ************** |
821 NumImplementation = Number; | 509 NumImplementation = Number; |
822 NumImplementation.prototype.$negate = function() { | 510 NumImplementation.prototype.$negate = function() { |
823 'use strict'; return -this; | 511 'use strict'; return -this; |
824 } | 512 } |
825 NumImplementation.prototype.isNaN = function() { | 513 NumImplementation.prototype.isNaN = function() { |
826 'use strict'; return isNaN(this); | 514 'use strict'; return isNaN(this); |
827 } | 515 } |
828 NumImplementation.prototype.isNegative = function() { | 516 NumImplementation.prototype.isNegative = function() { |
(...skipping 29 matching lines...) Expand all Loading... |
858 else if (this.isNaN()) { | 546 else if (this.isNaN()) { |
859 if (other.isNaN()) { | 547 if (other.isNaN()) { |
860 return (0); | 548 return (0); |
861 } | 549 } |
862 return (1); | 550 return (1); |
863 } | 551 } |
864 else { | 552 else { |
865 return (-1); | 553 return (-1); |
866 } | 554 } |
867 } | 555 } |
868 NumImplementation.prototype.compareTo$1 = NumImplementation.prototype.compareTo; | |
869 NumImplementation.prototype.hashCode$0 = NumImplementation.prototype.hashCode; | |
870 NumImplementation.prototype.toRadixString$1 = NumImplementation.prototype.toRadi
xString; | |
871 // ********** Code for HashMapImplementation ************** | 556 // ********** Code for HashMapImplementation ************** |
872 function HashMapImplementation() { | 557 function HashMapImplementation() { |
873 this._numberOfEntries = (0); | 558 this._numberOfEntries = (0); |
874 this._numberOfDeleted = (0); | 559 this._numberOfDeleted = (0); |
875 this._loadLimit = HashMapImplementation._computeLoadLimit((8)); | 560 this._loadLimit = HashMapImplementation._computeLoadLimit((8)); |
876 this._keys = new Array((8)); | 561 this._keys = new Array((8)); |
877 this._values = new Array((8)); | 562 this._values = new Array((8)); |
878 } | 563 } |
879 HashMapImplementation.HashMapImplementation$from$factory = function(other) { | 564 HashMapImplementation.HashMapImplementation$from$factory = function(other) { |
880 var result = new HashMapImplementation_K$V(); | 565 var result = new HashMapImplementation(); |
881 other.forEach((function (key, value) { | 566 other.forEach((function (key, value) { |
882 result.$setindex(key, value); | 567 result.$setindex(key, value); |
883 }) | 568 }) |
884 ); | 569 ); |
885 return result; | 570 return result; |
886 } | 571 } |
887 HashMapImplementation._computeLoadLimit = function(capacity) { | 572 HashMapImplementation._computeLoadLimit = function(capacity) { |
888 return $truncdiv((capacity * (3)), (4)); | 573 return $truncdiv((capacity * (3)), (4)); |
889 } | 574 } |
890 HashMapImplementation._firstProbe = function(hashCode, length) { | 575 HashMapImplementation._firstProbe = function(hashCode, length) { |
891 return hashCode & (length - (1)); | 576 return hashCode & (length - (1)); |
892 } | 577 } |
893 HashMapImplementation._nextProbe = function(currentProbe, numberOfProbes, length
) { | 578 HashMapImplementation._nextProbe = function(currentProbe, numberOfProbes, length
) { |
894 return (currentProbe + numberOfProbes) & (length - (1)); | 579 return (currentProbe + numberOfProbes) & (length - (1)); |
895 } | 580 } |
896 HashMapImplementation.prototype._probeForAdding = function(key) { | 581 HashMapImplementation.prototype._probeForAdding = function(key) { |
897 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$
length()); | 582 var hash = HashMapImplementation._firstProbe(key.hashCode(), this._keys.get$le
ngth()); |
898 var numberOfProbes = (1); | 583 var numberOfProbes = (1); |
899 var initialHash = hash; | 584 var initialHash = hash; |
900 var insertionIndex = (-1); | 585 var insertionIndex = (-1); |
901 while (true) { | 586 while (true) { |
902 var existingKey = this._keys[hash]; | 587 var existingKey = this._keys.$index(hash); |
903 if (existingKey == null) { | 588 if (existingKey == null) { |
904 if (insertionIndex < (0)) return hash; | 589 if (insertionIndex < (0)) return hash; |
905 return insertionIndex; | 590 return insertionIndex; |
906 } | 591 } |
907 else if ($eq(existingKey, key)) { | 592 else if ($eq(existingKey, key)) { |
908 return hash; | 593 return hash; |
909 } | 594 } |
910 else if ((insertionIndex < (0)) && (const$0001 == existingKey)) { | 595 else if ((insertionIndex < (0)) && (const$0000 == existingKey)) { |
911 insertionIndex = hash; | 596 insertionIndex = hash; |
912 } | 597 } |
913 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g
et$length()); | 598 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g
et$length()); |
914 } | 599 } |
915 } | 600 } |
916 HashMapImplementation.prototype._probeForLookup = function(key) { | 601 HashMapImplementation.prototype._probeForLookup = function(key) { |
917 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$
length()); | 602 var hash = HashMapImplementation._firstProbe(key.hashCode(), this._keys.get$le
ngth()); |
918 var numberOfProbes = (1); | 603 var numberOfProbes = (1); |
919 var initialHash = hash; | 604 var initialHash = hash; |
920 while (true) { | 605 while (true) { |
921 var existingKey = this._keys[hash]; | 606 var existingKey = this._keys.$index(hash); |
922 if (existingKey == null) return (-1); | 607 if (existingKey == null) return (-1); |
923 if ($eq(existingKey, key)) return hash; | 608 if ($eq(existingKey, key)) return hash; |
924 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g
et$length()); | 609 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g
et$length()); |
925 } | 610 } |
926 } | 611 } |
927 HashMapImplementation.prototype._ensureCapacity = function() { | 612 HashMapImplementation.prototype._ensureCapacity = function() { |
928 var newNumberOfEntries = this._numberOfEntries + (1); | 613 var newNumberOfEntries = this._numberOfEntries + (1); |
929 if (newNumberOfEntries >= this._loadLimit) { | 614 if (newNumberOfEntries >= this._loadLimit) { |
930 this._grow(this._keys.get$length() * (2)); | 615 this._grow(this._keys.get$length() * (2)); |
931 return; | 616 return; |
(...skipping 10 matching lines...) Expand all Loading... |
942 } | 627 } |
943 HashMapImplementation.prototype._grow = function(newCapacity) { | 628 HashMapImplementation.prototype._grow = function(newCapacity) { |
944 var capacity = this._keys.get$length(); | 629 var capacity = this._keys.get$length(); |
945 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); | 630 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); |
946 var oldKeys = this._keys; | 631 var oldKeys = this._keys; |
947 var oldValues = this._values; | 632 var oldValues = this._values; |
948 this._keys = new Array(newCapacity); | 633 this._keys = new Array(newCapacity); |
949 this._values = new Array(newCapacity); | 634 this._values = new Array(newCapacity); |
950 for (var i = (0); | 635 for (var i = (0); |
951 i < capacity; i++) { | 636 i < capacity; i++) { |
952 var key = oldKeys[i]; | 637 var key = oldKeys.$index(i); |
953 if (key == null || key == const$0001) { | 638 if (key == null || key == const$0000) { |
954 continue; | 639 continue; |
955 } | 640 } |
956 var value = oldValues[i]; | 641 var value = oldValues.$index(i); |
957 var newIndex = this._probeForAdding(key); | 642 var newIndex = this._probeForAdding(key); |
958 this._keys.$setindex(newIndex, key); | 643 this._keys.$setindex(newIndex, key); |
959 this._values.$setindex(newIndex, value); | 644 this._values.$setindex(newIndex, value); |
960 } | 645 } |
961 this._numberOfDeleted = (0); | 646 this._numberOfDeleted = (0); |
962 } | 647 } |
963 HashMapImplementation.prototype.$setindex = function(key, value) { | 648 HashMapImplementation.prototype.$setindex = function(key, value) { |
964 this._ensureCapacity(); | 649 this._ensureCapacity(); |
965 var index = this._probeForAdding(key); | 650 var index = this._probeForAdding(key); |
966 if ((this._keys[index] == null) || (this._keys[index] == const$0001)) { | 651 if ((this._keys.$index(index) == null) || (this._keys.$index(index) == const$0
000)) { |
967 this._numberOfEntries++; | 652 this._numberOfEntries++; |
968 } | 653 } |
969 this._keys.$setindex(index, key); | 654 this._keys.$setindex(index, key); |
970 this._values.$setindex(index, value); | 655 this._values.$setindex(index, value); |
971 } | 656 } |
972 HashMapImplementation.prototype.$index = function(key) { | 657 HashMapImplementation.prototype.$index = function(key) { |
973 var index = this._probeForLookup(key); | 658 var index = this._probeForLookup(key); |
974 if (index < (0)) return null; | 659 if (index < (0)) return null; |
975 return this._values[index]; | 660 return this._values.$index(index); |
976 } | 661 } |
977 HashMapImplementation.prototype.putIfAbsent = function(key, ifAbsent) { | 662 HashMapImplementation.prototype.putIfAbsent = function(key, ifAbsent) { |
978 var index = this._probeForLookup(key); | 663 var index = this._probeForLookup(key); |
979 if (index >= (0)) return this._values[index]; | 664 if (index >= (0)) return this._values.$index(index); |
980 var value = ifAbsent.call$0(); | 665 var value = ifAbsent(); |
981 this.$setindex(key, value); | 666 this.$setindex(key, value); |
982 return value; | 667 return value; |
983 } | 668 } |
| 669 HashMapImplementation.prototype.remove = function(key) { |
| 670 var index = this._probeForLookup(key); |
| 671 if (index >= (0)) { |
| 672 this._numberOfEntries--; |
| 673 var value = this._values.$index(index); |
| 674 this._values.$setindex(index); |
| 675 this._keys.$setindex(index, const$0000); |
| 676 this._numberOfDeleted++; |
| 677 return value; |
| 678 } |
| 679 return null; |
| 680 } |
984 HashMapImplementation.prototype.isEmpty = function() { | 681 HashMapImplementation.prototype.isEmpty = function() { |
985 return this._numberOfEntries == (0); | 682 return this._numberOfEntries == (0); |
986 } | 683 } |
987 HashMapImplementation.prototype.get$length = function() { | 684 HashMapImplementation.prototype.get$length = function() { |
988 return this._numberOfEntries; | 685 return this._numberOfEntries; |
989 } | 686 } |
990 HashMapImplementation.prototype.forEach = function(f) { | 687 HashMapImplementation.prototype.forEach = function(f) { |
991 var length = this._keys.get$length(); | 688 var length = this._keys.get$length(); |
992 for (var i = (0); | 689 for (var i = (0); |
993 i < length; i++) { | 690 i < length; i++) { |
994 var key = this._keys[i]; | 691 var key = this._keys.$index(i); |
995 if ((key != null) && (key != const$0001)) { | 692 if ((key != null) && (key != const$0000)) { |
996 f.call$2(key, this._values[i]); | 693 f(key, this._values.$index(i)); |
997 } | 694 } |
998 } | 695 } |
999 } | 696 } |
1000 HashMapImplementation.prototype.getKeys = function() { | 697 HashMapImplementation.prototype.getKeys = function() { |
1001 var list = new Array(this.get$length()); | 698 var list = new Array(this.get$length()); |
1002 var i = (0); | 699 var i = (0); |
1003 this.forEach(function _(key, value) { | 700 this.forEach(function _(key, value) { |
1004 list.$setindex(i++, key); | 701 list.$setindex(i++, key); |
1005 } | 702 } |
1006 ); | 703 ); |
1007 return list; | 704 return list; |
1008 } | 705 } |
1009 HashMapImplementation.prototype.getValues = function() { | 706 HashMapImplementation.prototype.getValues = function() { |
1010 var list = new Array(this.get$length()); | 707 var list = new Array(this.get$length()); |
1011 var i = (0); | 708 var i = (0); |
1012 this.forEach(function _(key, value) { | 709 this.forEach(function _(key, value) { |
1013 list.$setindex(i++, value); | 710 list.$setindex(i++, value); |
1014 } | 711 } |
1015 ); | 712 ); |
1016 return list; | 713 return list; |
1017 } | 714 } |
1018 HashMapImplementation.prototype.containsKey = function(key) { | 715 HashMapImplementation.prototype.containsKey = function(key) { |
1019 return (this._probeForLookup(key) != (-1)); | 716 return (this._probeForLookup(key) != (-1)); |
1020 } | 717 } |
1021 HashMapImplementation.prototype.containsKey$1 = HashMapImplementation.prototype.
containsKey; | 718 HashMapImplementation.prototype.remove$1 = HashMapImplementation.prototype.remov
e; |
1022 HashMapImplementation.prototype.forEach$1 = function($0) { | 719 // ********** Code for HashMapImplementation_Dynamic$DoubleLinkedQueueEntry_KeyV
aluePair ************** |
1023 return this.forEach(to$call$2($0)); | 720 $inherits(HashMapImplementation_Dynamic$DoubleLinkedQueueEntry_KeyValuePair, Has
hMapImplementation); |
1024 }; | 721 function HashMapImplementation_Dynamic$DoubleLinkedQueueEntry_KeyValuePair() { |
1025 HashMapImplementation.prototype.getKeys$0 = HashMapImplementation.prototype.getK
eys; | |
1026 HashMapImplementation.prototype.getValues$0 = HashMapImplementation.prototype.ge
tValues; | |
1027 HashMapImplementation.prototype.isEmpty$0 = HashMapImplementation.prototype.isEm
pty; | |
1028 // ********** Code for HashMapImplementation_E$E ************** | |
1029 $inherits(HashMapImplementation_E$E, HashMapImplementation); | |
1030 function HashMapImplementation_E$E() { | |
1031 this._numberOfEntries = (0); | 722 this._numberOfEntries = (0); |
1032 this._numberOfDeleted = (0); | 723 this._numberOfDeleted = (0); |
1033 this._loadLimit = HashMapImplementation._computeLoadLimit((8)); | 724 this._loadLimit = HashMapImplementation._computeLoadLimit((8)); |
1034 this._keys = new Array((8)); | 725 this._keys = new Array((8)); |
1035 this._values = new Array((8)); | 726 this._values = new Array((8)); |
1036 } | 727 } |
1037 HashMapImplementation_E$E._computeLoadLimit = function(capacity) { | 728 HashMapImplementation_Dynamic$DoubleLinkedQueueEntry_KeyValuePair.prototype.remo
ve$1 = HashMapImplementation_Dynamic$DoubleLinkedQueueEntry_KeyValuePair.prototy
pe.remove; |
1038 return $truncdiv((capacity * (3)), (4)); | 729 // ********** Code for HashMapImplementation_Library$Library ************** |
1039 } | 730 $inherits(HashMapImplementation_Library$Library, HashMapImplementation); |
1040 HashMapImplementation_E$E._firstProbe = function(hashCode, length) { | 731 function HashMapImplementation_Library$Library() { |
1041 return hashCode & (length - (1)); | |
1042 } | |
1043 HashMapImplementation_E$E._nextProbe = function(currentProbe, numberOfProbes, le
ngth) { | |
1044 return (currentProbe + numberOfProbes) & (length - (1)); | |
1045 } | |
1046 HashMapImplementation_E$E.prototype._probeForAdding = function(key) { | |
1047 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$
length()); | |
1048 var numberOfProbes = (1); | |
1049 var initialHash = hash; | |
1050 var insertionIndex = (-1); | |
1051 while (true) { | |
1052 var existingKey = this._keys[hash]; | |
1053 if (existingKey == null) { | |
1054 if (insertionIndex < (0)) return hash; | |
1055 return insertionIndex; | |
1056 } | |
1057 else if ($eq(existingKey, key)) { | |
1058 return hash; | |
1059 } | |
1060 else if ((insertionIndex < (0)) && (const$0001 == existingKey)) { | |
1061 insertionIndex = hash; | |
1062 } | |
1063 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g
et$length()); | |
1064 } | |
1065 } | |
1066 HashMapImplementation_E$E.prototype._probeForLookup = function(key) { | |
1067 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$
length()); | |
1068 var numberOfProbes = (1); | |
1069 var initialHash = hash; | |
1070 while (true) { | |
1071 var existingKey = this._keys[hash]; | |
1072 if (existingKey == null) return (-1); | |
1073 if ($eq(existingKey, key)) return hash; | |
1074 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g
et$length()); | |
1075 } | |
1076 } | |
1077 HashMapImplementation_E$E.prototype._ensureCapacity = function() { | |
1078 var newNumberOfEntries = this._numberOfEntries + (1); | |
1079 if (newNumberOfEntries >= this._loadLimit) { | |
1080 this._grow(this._keys.get$length() * (2)); | |
1081 return; | |
1082 } | |
1083 var capacity = this._keys.get$length(); | |
1084 var numberOfFreeOrDeleted = capacity - newNumberOfEntries; | |
1085 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted; | |
1086 if (this._numberOfDeleted > numberOfFree) { | |
1087 this._grow(this._keys.get$length()); | |
1088 } | |
1089 } | |
1090 HashMapImplementation_E$E._isPowerOfTwo = function(x) { | |
1091 return ((x & (x - (1))) == (0)); | |
1092 } | |
1093 HashMapImplementation_E$E.prototype._grow = function(newCapacity) { | |
1094 var capacity = this._keys.get$length(); | |
1095 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); | |
1096 var oldKeys = this._keys; | |
1097 var oldValues = this._values; | |
1098 this._keys = new Array(newCapacity); | |
1099 this._values = new Array(newCapacity); | |
1100 for (var i = (0); | |
1101 i < capacity; i++) { | |
1102 var key = oldKeys[i]; | |
1103 if (key == null || key == const$0001) { | |
1104 continue; | |
1105 } | |
1106 var value = oldValues[i]; | |
1107 var newIndex = this._probeForAdding(key); | |
1108 this._keys.$setindex(newIndex, key); | |
1109 this._values.$setindex(newIndex, value); | |
1110 } | |
1111 this._numberOfDeleted = (0); | |
1112 } | |
1113 HashMapImplementation_E$E.prototype.$setindex = function(key, value) { | |
1114 this._ensureCapacity(); | |
1115 var index = this._probeForAdding(key); | |
1116 if ((this._keys[index] == null) || (this._keys[index] == const$0001)) { | |
1117 this._numberOfEntries++; | |
1118 } | |
1119 this._keys.$setindex(index, key); | |
1120 this._values.$setindex(index, value); | |
1121 } | |
1122 HashMapImplementation_E$E.prototype.isEmpty = function() { | |
1123 return this._numberOfEntries == (0); | |
1124 } | |
1125 HashMapImplementation_E$E.prototype.forEach = function(f) { | |
1126 var length = this._keys.get$length(); | |
1127 for (var i = (0); | |
1128 i < length; i++) { | |
1129 var key = this._keys[i]; | |
1130 if ((key != null) && (key != const$0001)) { | |
1131 f.call$2(key, this._values[i]); | |
1132 } | |
1133 } | |
1134 } | |
1135 HashMapImplementation_E$E.prototype.getKeys = function() { | |
1136 var list = new Array(this.get$length()); | |
1137 var i = (0); | |
1138 this.forEach(function _(key, value) { | |
1139 list.$setindex(i++, key); | |
1140 } | |
1141 ); | |
1142 return list; | |
1143 } | |
1144 HashMapImplementation_E$E.prototype.containsKey = function(key) { | |
1145 return (this._probeForLookup(key) != (-1)); | |
1146 } | |
1147 // ********** Code for HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePa
ir_K$V ************** | |
1148 $inherits(HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePair_K$V, HashM
apImplementation); | |
1149 function HashMapImplementation_K$DoubleLinkedQueueEntry_KeyValuePair_K$V() {} | |
1150 // ********** Code for HashMapImplementation_K$V ************** | |
1151 $inherits(HashMapImplementation_K$V, HashMapImplementation); | |
1152 function HashMapImplementation_K$V() { | |
1153 this._numberOfEntries = (0); | 732 this._numberOfEntries = (0); |
1154 this._numberOfDeleted = (0); | 733 this._numberOfDeleted = (0); |
1155 this._loadLimit = HashMapImplementation._computeLoadLimit((8)); | 734 this._loadLimit = HashMapImplementation._computeLoadLimit((8)); |
1156 this._keys = new Array((8)); | 735 this._keys = new Array((8)); |
1157 this._values = new Array((8)); | 736 this._values = new Array((8)); |
1158 } | 737 } |
1159 HashMapImplementation_K$V._computeLoadLimit = function(capacity) { | 738 // ********** Code for HashMapImplementation_Member$Member ************** |
1160 return $truncdiv((capacity * (3)), (4)); | 739 $inherits(HashMapImplementation_Member$Member, HashMapImplementation); |
| 740 function HashMapImplementation_Member$Member() { |
| 741 this._numberOfEntries = (0); |
| 742 this._numberOfDeleted = (0); |
| 743 this._loadLimit = HashMapImplementation._computeLoadLimit((8)); |
| 744 this._keys = new Array((8)); |
| 745 this._values = new Array((8)); |
1161 } | 746 } |
1162 HashMapImplementation_K$V._firstProbe = function(hashCode, length) { | 747 // ********** Code for HashMapImplementation_dart_core_String$dart_core_String *
************* |
1163 return hashCode & (length - (1)); | 748 $inherits(HashMapImplementation_dart_core_String$dart_core_String, HashMapImplem
entation); |
| 749 function HashMapImplementation_dart_core_String$dart_core_String() { |
| 750 this._numberOfEntries = (0); |
| 751 this._numberOfDeleted = (0); |
| 752 this._loadLimit = HashMapImplementation._computeLoadLimit((8)); |
| 753 this._keys = new Array((8)); |
| 754 this._values = new Array((8)); |
1164 } | 755 } |
1165 HashMapImplementation_K$V._nextProbe = function(currentProbe, numberOfProbes, le
ngth) { | 756 HashMapImplementation_dart_core_String$dart_core_String.prototype.remove$1 = Has
hMapImplementation_dart_core_String$dart_core_String.prototype.remove; |
1166 return (currentProbe + numberOfProbes) & (length - (1)); | |
1167 } | |
1168 HashMapImplementation_K$V.prototype._probeForAdding = function(key) { | |
1169 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$
length()); | |
1170 var numberOfProbes = (1); | |
1171 var initialHash = hash; | |
1172 var insertionIndex = (-1); | |
1173 while (true) { | |
1174 var existingKey = this._keys[hash]; | |
1175 if (existingKey == null) { | |
1176 if (insertionIndex < (0)) return hash; | |
1177 return insertionIndex; | |
1178 } | |
1179 else if ($eq(existingKey, key)) { | |
1180 return hash; | |
1181 } | |
1182 else if ((insertionIndex < (0)) && (const$0001 == existingKey)) { | |
1183 insertionIndex = hash; | |
1184 } | |
1185 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g
et$length()); | |
1186 } | |
1187 } | |
1188 HashMapImplementation_K$V.prototype._probeForLookup = function(key) { | |
1189 var hash = HashMapImplementation._firstProbe(key.hashCode$0(), this._keys.get$
length()); | |
1190 var numberOfProbes = (1); | |
1191 var initialHash = hash; | |
1192 while (true) { | |
1193 var existingKey = this._keys[hash]; | |
1194 if (existingKey == null) return (-1); | |
1195 if ($eq(existingKey, key)) return hash; | |
1196 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g
et$length()); | |
1197 } | |
1198 } | |
1199 HashMapImplementation_K$V.prototype._ensureCapacity = function() { | |
1200 var newNumberOfEntries = this._numberOfEntries + (1); | |
1201 if (newNumberOfEntries >= this._loadLimit) { | |
1202 this._grow(this._keys.get$length() * (2)); | |
1203 return; | |
1204 } | |
1205 var capacity = this._keys.get$length(); | |
1206 var numberOfFreeOrDeleted = capacity - newNumberOfEntries; | |
1207 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted; | |
1208 if (this._numberOfDeleted > numberOfFree) { | |
1209 this._grow(this._keys.get$length()); | |
1210 } | |
1211 } | |
1212 HashMapImplementation_K$V._isPowerOfTwo = function(x) { | |
1213 return ((x & (x - (1))) == (0)); | |
1214 } | |
1215 HashMapImplementation_K$V.prototype._grow = function(newCapacity) { | |
1216 var capacity = this._keys.get$length(); | |
1217 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); | |
1218 var oldKeys = this._keys; | |
1219 var oldValues = this._values; | |
1220 this._keys = new Array(newCapacity); | |
1221 this._values = new Array(newCapacity); | |
1222 for (var i = (0); | |
1223 i < capacity; i++) { | |
1224 var key = oldKeys[i]; | |
1225 if (key == null || key == const$0001) { | |
1226 continue; | |
1227 } | |
1228 var value = oldValues[i]; | |
1229 var newIndex = this._probeForAdding(key); | |
1230 this._keys.$setindex(newIndex, key); | |
1231 this._values.$setindex(newIndex, value); | |
1232 } | |
1233 this._numberOfDeleted = (0); | |
1234 } | |
1235 HashMapImplementation_K$V.prototype.$setindex = function(key, value) { | |
1236 this._ensureCapacity(); | |
1237 var index = this._probeForAdding(key); | |
1238 if ((this._keys[index] == null) || (this._keys[index] == const$0001)) { | |
1239 this._numberOfEntries++; | |
1240 } | |
1241 this._keys.$setindex(index, key); | |
1242 this._values.$setindex(index, value); | |
1243 } | |
1244 HashMapImplementation_K$V.prototype.$index = function(key) { | |
1245 var index = this._probeForLookup(key); | |
1246 if (index < (0)) return null; | |
1247 return this._values[index]; | |
1248 } | |
1249 HashMapImplementation_K$V.prototype.putIfAbsent = function(key, ifAbsent) { | |
1250 var index = this._probeForLookup(key); | |
1251 if (index >= (0)) return this._values[index]; | |
1252 var value = ifAbsent.call$0(); | |
1253 this.$setindex(key, value); | |
1254 return value; | |
1255 } | |
1256 HashMapImplementation_K$V.prototype.isEmpty = function() { | |
1257 return this._numberOfEntries == (0); | |
1258 } | |
1259 HashMapImplementation_K$V.prototype.forEach = function(f) { | |
1260 var length = this._keys.get$length(); | |
1261 for (var i = (0); | |
1262 i < length; i++) { | |
1263 var key = this._keys[i]; | |
1264 if ((key != null) && (key != const$0001)) { | |
1265 f.call$2(key, this._values[i]); | |
1266 } | |
1267 } | |
1268 } | |
1269 HashMapImplementation_K$V.prototype.getKeys = function() { | |
1270 var list = new Array(this.get$length()); | |
1271 var i = (0); | |
1272 this.forEach(function _(key, value) { | |
1273 list.$setindex(i++, key); | |
1274 } | |
1275 ); | |
1276 return list; | |
1277 } | |
1278 HashMapImplementation_K$V.prototype.getValues = function() { | |
1279 var list = new Array(this.get$length()); | |
1280 var i = (0); | |
1281 this.forEach(function _(key, value) { | |
1282 list.$setindex(i++, value); | |
1283 } | |
1284 ); | |
1285 return list; | |
1286 } | |
1287 HashMapImplementation_K$V.prototype.containsKey = function(key) { | |
1288 return (this._probeForLookup(key) != (-1)); | |
1289 } | |
1290 // ********** Code for HashMapImplementation_dart_core_String$VariableValue ****
********** | 757 // ********** Code for HashMapImplementation_dart_core_String$VariableValue ****
********** |
1291 $inherits(HashMapImplementation_dart_core_String$VariableValue, HashMapImplement
ation); | 758 $inherits(HashMapImplementation_dart_core_String$VariableValue, HashMapImplement
ation); |
1292 function HashMapImplementation_dart_core_String$VariableValue() { | 759 function HashMapImplementation_dart_core_String$VariableValue() { |
1293 this._numberOfEntries = (0); | 760 this._numberOfEntries = (0); |
1294 this._numberOfDeleted = (0); | 761 this._numberOfDeleted = (0); |
1295 this._loadLimit = HashMapImplementation._computeLoadLimit((8)); | 762 this._loadLimit = HashMapImplementation._computeLoadLimit((8)); |
1296 this._keys = new Array((8)); | 763 this._keys = new Array((8)); |
1297 this._values = new Array((8)); | 764 this._values = new Array((8)); |
1298 } | 765 } |
1299 HashMapImplementation_dart_core_String$VariableValue._computeLoadLimit = functio
n(capacity) { | 766 HashMapImplementation_dart_core_String$VariableValue.prototype.remove$1 = HashMa
pImplementation_dart_core_String$VariableValue.prototype.remove; |
1300 return $truncdiv((capacity * (3)), (4)); | 767 // ********** Code for HashMapImplementation_Type$Type ************** |
1301 } | 768 $inherits(HashMapImplementation_Type$Type, HashMapImplementation); |
1302 HashMapImplementation_dart_core_String$VariableValue._firstProbe = function(hash
Code, length) { | 769 function HashMapImplementation_Type$Type() { |
1303 return hashCode & (length - (1)); | 770 this._numberOfEntries = (0); |
1304 } | |
1305 HashMapImplementation_dart_core_String$VariableValue._nextProbe = function(curre
ntProbe, numberOfProbes, length) { | |
1306 return (currentProbe + numberOfProbes) & (length - (1)); | |
1307 } | |
1308 HashMapImplementation_dart_core_String$VariableValue.prototype._probeForAdding =
function(key) { | |
1309 var hash = HashMapImplementation._firstProbe(key.hashCode(), this._keys.get$le
ngth()); | |
1310 var numberOfProbes = (1); | |
1311 var initialHash = hash; | |
1312 var insertionIndex = (-1); | |
1313 while (true) { | |
1314 var existingKey = this._keys[hash]; | |
1315 if (existingKey == null) { | |
1316 if (insertionIndex < (0)) return hash; | |
1317 return insertionIndex; | |
1318 } | |
1319 else if ($eq(existingKey, key)) { | |
1320 return hash; | |
1321 } | |
1322 else if ((insertionIndex < (0)) && (const$0001 == existingKey)) { | |
1323 insertionIndex = hash; | |
1324 } | |
1325 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g
et$length()); | |
1326 } | |
1327 } | |
1328 HashMapImplementation_dart_core_String$VariableValue.prototype._probeForLookup =
function(key) { | |
1329 var hash = HashMapImplementation._firstProbe(key.hashCode(), this._keys.get$le
ngth()); | |
1330 var numberOfProbes = (1); | |
1331 var initialHash = hash; | |
1332 while (true) { | |
1333 var existingKey = this._keys[hash]; | |
1334 if (existingKey == null) return (-1); | |
1335 if ($eq(existingKey, key)) return hash; | |
1336 hash = HashMapImplementation._nextProbe(hash, numberOfProbes++, this._keys.g
et$length()); | |
1337 } | |
1338 } | |
1339 HashMapImplementation_dart_core_String$VariableValue.prototype._ensureCapacity =
function() { | |
1340 var newNumberOfEntries = this._numberOfEntries + (1); | |
1341 if (newNumberOfEntries >= this._loadLimit) { | |
1342 this._grow(this._keys.get$length() * (2)); | |
1343 return; | |
1344 } | |
1345 var capacity = this._keys.get$length(); | |
1346 var numberOfFreeOrDeleted = capacity - newNumberOfEntries; | |
1347 var numberOfFree = numberOfFreeOrDeleted - this._numberOfDeleted; | |
1348 if (this._numberOfDeleted > numberOfFree) { | |
1349 this._grow(this._keys.get$length()); | |
1350 } | |
1351 } | |
1352 HashMapImplementation_dart_core_String$VariableValue._isPowerOfTwo = function(x)
{ | |
1353 return ((x & (x - (1))) == (0)); | |
1354 } | |
1355 HashMapImplementation_dart_core_String$VariableValue.prototype._grow = function(
newCapacity) { | |
1356 var capacity = this._keys.get$length(); | |
1357 this._loadLimit = HashMapImplementation._computeLoadLimit(newCapacity); | |
1358 var oldKeys = this._keys; | |
1359 var oldValues = this._values; | |
1360 this._keys = new Array(newCapacity); | |
1361 this._values = new Array(newCapacity); | |
1362 for (var i = (0); | |
1363 i < capacity; i++) { | |
1364 var key = oldKeys[i]; | |
1365 if (key == null || key == const$0001) { | |
1366 continue; | |
1367 } | |
1368 var value = oldValues[i]; | |
1369 var newIndex = this._probeForAdding(key); | |
1370 this._keys.$setindex(newIndex, key); | |
1371 this._values.$setindex(newIndex, value); | |
1372 } | |
1373 this._numberOfDeleted = (0); | 771 this._numberOfDeleted = (0); |
1374 } | 772 this._loadLimit = HashMapImplementation._computeLoadLimit((8)); |
1375 HashMapImplementation_dart_core_String$VariableValue.prototype.$setindex = funct
ion(key, value) { | 773 this._keys = new Array((8)); |
1376 this._ensureCapacity(); | 774 this._values = new Array((8)); |
1377 var index = this._probeForAdding(key); | |
1378 if ((this._keys[index] == null) || (this._keys[index] == const$0001)) { | |
1379 this._numberOfEntries++; | |
1380 } | |
1381 this._keys.$setindex(index, key); | |
1382 this._values.$setindex(index, value); | |
1383 } | |
1384 HashMapImplementation_dart_core_String$VariableValue.prototype.$index = function
(key) { | |
1385 var index = this._probeForLookup(key); | |
1386 if (index < (0)) return null; | |
1387 return this._values[index]; | |
1388 } | |
1389 HashMapImplementation_dart_core_String$VariableValue.prototype.forEach = functio
n(f) { | |
1390 var length = this._keys.get$length(); | |
1391 for (var i = (0); | |
1392 i < length; i++) { | |
1393 var key = this._keys[i]; | |
1394 if ((key != null) && (key != const$0001)) { | |
1395 f.call$2(key, this._values[i]); | |
1396 } | |
1397 } | |
1398 } | |
1399 HashMapImplementation_dart_core_String$VariableValue.prototype.containsKey = fun
ction(key) { | |
1400 return (this._probeForLookup(key) != (-1)); | |
1401 } | 775 } |
1402 // ********** Code for HashSetImplementation ************** | 776 // ********** Code for HashSetImplementation ************** |
1403 function HashSetImplementation() { | 777 function HashSetImplementation() { |
1404 this._backingMap = new HashMapImplementation_E$E(); | 778 this._backingMap = new HashMapImplementation(); |
1405 } | 779 } |
1406 HashSetImplementation.HashSetImplementation$from$factory = function(other) { | 780 HashSetImplementation.HashSetImplementation$from$factory = function(other) { |
1407 var set = new HashSetImplementation_E(); | 781 var set = new HashSetImplementation(); |
1408 for (var $$i = other.iterator$0(); $$i.hasNext$0(); ) { | 782 for (var $$i = other.iterator(); $$i.hasNext(); ) { |
1409 var e = $$i.next$0(); | 783 var e = $$i.next(); |
1410 set.add(e); | 784 set.add(e); |
1411 } | 785 } |
1412 return set; | 786 return set; |
1413 } | 787 } |
1414 HashSetImplementation.prototype.add = function(value) { | 788 HashSetImplementation.prototype.add = function(value) { |
1415 this._backingMap.$setindex(value, value); | 789 this._backingMap.$setindex(value, value); |
1416 } | 790 } |
1417 HashSetImplementation.prototype.contains = function(value) { | 791 HashSetImplementation.prototype.contains = function(value) { |
1418 return this._backingMap.containsKey(value); | 792 return this._backingMap.containsKey(value); |
1419 } | 793 } |
| 794 HashSetImplementation.prototype.remove = function(value) { |
| 795 if (!this._backingMap.containsKey(value)) return false; |
| 796 this._backingMap.remove(value); |
| 797 return true; |
| 798 } |
1420 HashSetImplementation.prototype.addAll = function(collection) { | 799 HashSetImplementation.prototype.addAll = function(collection) { |
1421 var $this = this; // closure support | 800 var $this = this; // closure support |
1422 collection.forEach(function _(value) { | 801 collection.forEach(function _(value) { |
1423 $this.add(value); | 802 $this.add(value); |
1424 } | 803 } |
1425 ); | 804 ); |
1426 } | 805 } |
1427 HashSetImplementation.prototype.forEach = function(f) { | 806 HashSetImplementation.prototype.forEach = function(f) { |
1428 this._backingMap.forEach(function _(key, value) { | 807 this._backingMap.forEach(function _(key, value) { |
1429 f.call$1(key); | 808 f(key); |
1430 } | 809 } |
1431 ); | 810 ); |
1432 } | 811 } |
1433 HashSetImplementation.prototype.filter = function(f) { | 812 HashSetImplementation.prototype.filter = function(f) { |
1434 var result = new HashSetImplementation(); | 813 var result = new HashSetImplementation(); |
1435 this._backingMap.forEach(function _(key, value) { | 814 this._backingMap.forEach(function _(key, value) { |
1436 if (f.call$1(key)) result.add(key); | 815 if (f(key)) result.add(key); |
1437 } | 816 } |
1438 ); | 817 ); |
1439 return result; | 818 return result; |
1440 } | 819 } |
1441 HashSetImplementation.prototype.every = function(f) { | 820 HashSetImplementation.prototype.every = function(f) { |
1442 var keys = this._backingMap.getKeys(); | 821 var keys = this._backingMap.getKeys(); |
1443 return keys.every(f); | 822 return keys.every(f); |
1444 } | 823 } |
1445 HashSetImplementation.prototype.some = function(f) { | 824 HashSetImplementation.prototype.some = function(f) { |
1446 var keys = this._backingMap.getKeys(); | 825 var keys = this._backingMap.getKeys(); |
1447 return keys.some(f); | 826 return keys.some(f); |
1448 } | 827 } |
1449 HashSetImplementation.prototype.isEmpty = function() { | 828 HashSetImplementation.prototype.isEmpty = function() { |
1450 return this._backingMap.isEmpty(); | 829 return this._backingMap.isEmpty(); |
1451 } | 830 } |
1452 HashSetImplementation.prototype.get$length = function() { | 831 HashSetImplementation.prototype.get$length = function() { |
1453 return this._backingMap.get$length(); | 832 return this._backingMap.get$length(); |
1454 } | 833 } |
1455 HashSetImplementation.prototype.iterator = function() { | 834 HashSetImplementation.prototype.iterator = function() { |
1456 return new HashSetIterator_E(this); | 835 return new HashSetIterator(this); |
1457 } | 836 } |
1458 HashSetImplementation.prototype.add$1 = HashSetImplementation.prototype.add; | |
1459 HashSetImplementation.prototype.addAll$1 = HashSetImplementation.prototype.addAl
l; | |
1460 HashSetImplementation.prototype.contains$1 = HashSetImplementation.prototype.con
tains; | 837 HashSetImplementation.prototype.contains$1 = HashSetImplementation.prototype.con
tains; |
1461 HashSetImplementation.prototype.filter$1 = function($0) { | 838 HashSetImplementation.prototype.remove$1 = HashSetImplementation.prototype.remov
e; |
1462 return this.filter(to$call$1($0)); | |
1463 }; | |
1464 HashSetImplementation.prototype.forEach$1 = function($0) { | |
1465 return this.forEach(to$call$1($0)); | |
1466 }; | |
1467 HashSetImplementation.prototype.isEmpty$0 = HashSetImplementation.prototype.isEm
pty; | |
1468 HashSetImplementation.prototype.iterator$0 = HashSetImplementation.prototype.ite
rator; | |
1469 // ********** Code for HashSetImplementation_E ************** | |
1470 $inherits(HashSetImplementation_E, HashSetImplementation); | |
1471 function HashSetImplementation_E() { | |
1472 this._backingMap = new HashMapImplementation_E$E(); | |
1473 } | |
1474 // ********** Code for HashSetImplementation_Library ************** | 839 // ********** Code for HashSetImplementation_Library ************** |
1475 $inherits(HashSetImplementation_Library, HashSetImplementation); | 840 $inherits(HashSetImplementation_Library, HashSetImplementation); |
1476 function HashSetImplementation_Library() {} | 841 function HashSetImplementation_Library() { |
| 842 this._backingMap = new HashMapImplementation_Library$Library(); |
| 843 } |
| 844 HashSetImplementation_Library.prototype.contains$1 = HashSetImplementation_Libra
ry.prototype.contains; |
1477 // ********** Code for HashSetImplementation_Member ************** | 845 // ********** Code for HashSetImplementation_Member ************** |
1478 $inherits(HashSetImplementation_Member, HashSetImplementation); | 846 $inherits(HashSetImplementation_Member, HashSetImplementation); |
1479 function HashSetImplementation_Member() {} | 847 function HashSetImplementation_Member() { |
| 848 this._backingMap = new HashMapImplementation_Member$Member(); |
| 849 } |
1480 // ********** Code for HashSetImplementation_dart_core_String ************** | 850 // ********** Code for HashSetImplementation_dart_core_String ************** |
1481 $inherits(HashSetImplementation_dart_core_String, HashSetImplementation); | 851 $inherits(HashSetImplementation_dart_core_String, HashSetImplementation); |
1482 function HashSetImplementation_dart_core_String() {} | 852 function HashSetImplementation_dart_core_String() { |
| 853 this._backingMap = new HashMapImplementation_dart_core_String$dart_core_String
(); |
| 854 } |
| 855 HashSetImplementation_dart_core_String.prototype.contains$1 = HashSetImplementat
ion_dart_core_String.prototype.contains; |
1483 // ********** Code for HashSetImplementation_Type ************** | 856 // ********** Code for HashSetImplementation_Type ************** |
1484 $inherits(HashSetImplementation_Type, HashSetImplementation); | 857 $inherits(HashSetImplementation_Type, HashSetImplementation); |
1485 function HashSetImplementation_Type() {} | 858 function HashSetImplementation_Type() { |
| 859 this._backingMap = new HashMapImplementation_Type$Type(); |
| 860 } |
| 861 HashSetImplementation_Type.prototype.contains$1 = HashSetImplementation_Type.pro
totype.contains; |
1486 // ********** Code for HashSetIterator ************** | 862 // ********** Code for HashSetIterator ************** |
1487 function HashSetIterator(set_) { | 863 function HashSetIterator(set_) { |
1488 this._entries = set_._backingMap._keys; | 864 this._entries = set_._backingMap._keys; |
1489 this._nextValidIndex = (-1); | 865 this._nextValidIndex = (-1); |
1490 this._advance(); | 866 this._advance(); |
1491 } | 867 } |
1492 HashSetIterator.prototype.hasNext = function() { | 868 HashSetIterator.prototype.hasNext = function() { |
1493 if (this._nextValidIndex >= this._entries.get$length()) return false; | 869 if (this._nextValidIndex >= this._entries.get$length()) return false; |
1494 if (this._entries[this._nextValidIndex] == const$0001) { | 870 if (this._entries.$index(this._nextValidIndex) == const$0000) { |
1495 this._advance(); | 871 this._advance(); |
1496 } | 872 } |
1497 return this._nextValidIndex < this._entries.get$length(); | 873 return this._nextValidIndex < this._entries.get$length(); |
1498 } | 874 } |
1499 HashSetIterator.prototype.next = function() { | 875 HashSetIterator.prototype.next = function() { |
1500 if (!this.hasNext()) { | 876 if (!this.hasNext()) { |
1501 $throw(const$0005); | 877 $throw(const$0001); |
1502 } | 878 } |
1503 var res = this._entries[this._nextValidIndex]; | 879 var res = this._entries.$index(this._nextValidIndex); |
1504 this._advance(); | 880 this._advance(); |
1505 return res; | 881 return res; |
1506 } | 882 } |
1507 HashSetIterator.prototype._advance = function() { | 883 HashSetIterator.prototype._advance = function() { |
1508 var length = this._entries.get$length(); | 884 var length = this._entries.get$length(); |
1509 var entry; | 885 var entry; |
1510 var deletedKey = const$0001; | 886 var deletedKey = const$0000; |
1511 do { | 887 do { |
1512 if (++this._nextValidIndex >= length) break; | 888 if (++this._nextValidIndex >= length) break; |
1513 entry = this._entries[this._nextValidIndex]; | 889 entry = this._entries.$index(this._nextValidIndex); |
1514 } | 890 } |
1515 while ((entry == null) || (entry == deletedKey)) | 891 while ((entry == null) || (entry == deletedKey)) |
1516 } | 892 } |
1517 HashSetIterator.prototype.hasNext$0 = HashSetIterator.prototype.hasNext; | |
1518 HashSetIterator.prototype.next$0 = HashSetIterator.prototype.next; | |
1519 // ********** Code for HashSetIterator_E ************** | |
1520 $inherits(HashSetIterator_E, HashSetIterator); | |
1521 function HashSetIterator_E(set_) { | |
1522 this._nextValidIndex = (-1); | |
1523 this._entries = set_._backingMap._keys; | |
1524 this._advance(); | |
1525 } | |
1526 HashSetIterator_E.prototype._advance = function() { | |
1527 var length = this._entries.get$length(); | |
1528 var entry; | |
1529 var deletedKey = const$0001; | |
1530 do { | |
1531 if (++this._nextValidIndex >= length) break; | |
1532 entry = this._entries[this._nextValidIndex]; | |
1533 } | |
1534 while ((entry == null) || (entry == deletedKey)) | |
1535 } | |
1536 // ********** Code for _DeletedKeySentinel ************** | 893 // ********** Code for _DeletedKeySentinel ************** |
1537 function _DeletedKeySentinel() { | 894 function _DeletedKeySentinel() { |
1538 | 895 |
1539 } | 896 } |
1540 // ********** Code for KeyValuePair ************** | 897 // ********** Code for KeyValuePair ************** |
1541 function KeyValuePair(key, value) { | 898 function KeyValuePair(key, value) { |
1542 this.value = value; | 899 this.value = value; |
1543 this.key = key; | 900 this.key = key; |
1544 } | 901 } |
1545 KeyValuePair.prototype.get$value = function() { return this.value; }; | 902 KeyValuePair.prototype.get$value = function() { return this.value; }; |
1546 KeyValuePair.prototype.set$value = function(value) { return this.value = value;
}; | 903 KeyValuePair.prototype.set$value = function(value) { return this.value = value;
}; |
1547 // ********** Code for KeyValuePair_K$V ************** | |
1548 $inherits(KeyValuePair_K$V, KeyValuePair); | |
1549 function KeyValuePair_K$V(key, value) { | |
1550 this.key = key; | |
1551 this.value = value; | |
1552 } | |
1553 // ********** Code for LinkedHashMapImplementation ************** | 904 // ********** Code for LinkedHashMapImplementation ************** |
1554 function LinkedHashMapImplementation() { | 905 function LinkedHashMapImplementation() { |
1555 this._map = new HashMapImplementation(); | 906 this._map = new HashMapImplementation_Dynamic$DoubleLinkedQueueEntry_KeyValueP
air(); |
1556 this._list = new DoubleLinkedQueue_KeyValuePair_K$V(); | 907 this._list = new DoubleLinkedQueue_KeyValuePair(); |
1557 } | 908 } |
1558 LinkedHashMapImplementation.prototype.$setindex = function(key, value) { | 909 LinkedHashMapImplementation.prototype.$setindex = function(key, value) { |
1559 if (this._map.containsKey(key)) { | 910 if (this._map.containsKey(key)) { |
1560 this._map.$index(key).get$element().set$value(value); | 911 this._map.$index(key).get$element().set$value(value); |
1561 } | 912 } |
1562 else { | 913 else { |
1563 this._list.addLast(new KeyValuePair_K$V(key, value)); | 914 this._list.addLast(new KeyValuePair(key, value)); |
1564 this._map.$setindex(key, this._list.lastEntry()); | 915 this._map.$setindex(key, this._list.lastEntry()); |
1565 } | 916 } |
1566 } | 917 } |
1567 LinkedHashMapImplementation.prototype.$index = function(key) { | 918 LinkedHashMapImplementation.prototype.$index = function(key) { |
1568 var entry = this._map.$index(key); | 919 var entry = this._map.$index(key); |
1569 if (entry == null) return null; | 920 if (entry == null) return null; |
1570 return entry.get$element().get$value(); | 921 return entry.get$element().get$value(); |
1571 } | 922 } |
| 923 LinkedHashMapImplementation.prototype.remove = function(key) { |
| 924 var entry = this._map.remove(key); |
| 925 if (entry == null) return null; |
| 926 entry.remove(); |
| 927 return entry.get$element().get$value(); |
| 928 } |
1572 LinkedHashMapImplementation.prototype.putIfAbsent = function(key, ifAbsent) { | 929 LinkedHashMapImplementation.prototype.putIfAbsent = function(key, ifAbsent) { |
1573 var value = this.$index(key); | 930 var value = this.$index(key); |
1574 if ((this.$index(key) == null) && !(this.containsKey(key))) { | 931 if ((this.$index(key) == null) && !(this.containsKey(key))) { |
1575 value = ifAbsent.call$0(); | 932 value = ifAbsent(); |
1576 this.$setindex(key, value); | 933 this.$setindex(key, value); |
1577 } | 934 } |
1578 return value; | 935 return value; |
1579 } | 936 } |
1580 LinkedHashMapImplementation.prototype.getKeys = function() { | 937 LinkedHashMapImplementation.prototype.getKeys = function() { |
1581 var list = new Array(this.get$length()); | 938 var list = new Array(this.get$length()); |
1582 var index = (0); | 939 var index = (0); |
1583 this._list.forEach(function _(entry) { | 940 this._list.forEach(function _(entry) { |
1584 list.$setindex(index++, entry.key); | 941 list.$setindex(index++, entry.key); |
1585 } | 942 } |
1586 ); | 943 ); |
1587 return list; | 944 return list; |
1588 } | 945 } |
1589 LinkedHashMapImplementation.prototype.getValues = function() { | 946 LinkedHashMapImplementation.prototype.getValues = function() { |
1590 var list = new Array(this.get$length()); | 947 var list = new Array(this.get$length()); |
1591 var index = (0); | 948 var index = (0); |
1592 this._list.forEach(function _(entry) { | 949 this._list.forEach(function _(entry) { |
1593 list.$setindex(index++, entry.value); | 950 list.$setindex(index++, entry.value); |
1594 } | 951 } |
1595 ); | 952 ); |
1596 return list; | 953 return list; |
1597 } | 954 } |
1598 LinkedHashMapImplementation.prototype.forEach = function(f) { | 955 LinkedHashMapImplementation.prototype.forEach = function(f) { |
1599 this._list.forEach(function _(entry) { | 956 this._list.forEach(function _(entry) { |
1600 f.call$2(entry.key, entry.value); | 957 f(entry.key, entry.value); |
1601 } | 958 } |
1602 ); | 959 ); |
1603 } | 960 } |
1604 LinkedHashMapImplementation.prototype.containsKey = function(key) { | 961 LinkedHashMapImplementation.prototype.containsKey = function(key) { |
1605 return this._map.containsKey(key); | 962 return this._map.containsKey(key); |
1606 } | 963 } |
1607 LinkedHashMapImplementation.prototype.get$length = function() { | 964 LinkedHashMapImplementation.prototype.get$length = function() { |
1608 return this._map.get$length(); | 965 return this._map.get$length(); |
1609 } | 966 } |
1610 LinkedHashMapImplementation.prototype.isEmpty = function() { | 967 LinkedHashMapImplementation.prototype.isEmpty = function() { |
1611 return this.get$length() == (0); | 968 return this.get$length() == (0); |
1612 } | 969 } |
1613 LinkedHashMapImplementation.prototype.containsKey$1 = LinkedHashMapImplementatio
n.prototype.containsKey; | 970 LinkedHashMapImplementation.prototype.remove$1 = LinkedHashMapImplementation.pro
totype.remove; |
1614 LinkedHashMapImplementation.prototype.forEach$1 = function($0) { | |
1615 return this.forEach(to$call$2($0)); | |
1616 }; | |
1617 LinkedHashMapImplementation.prototype.getKeys$0 = LinkedHashMapImplementation.pr
ototype.getKeys; | |
1618 LinkedHashMapImplementation.prototype.getValues$0 = LinkedHashMapImplementation.
prototype.getValues; | |
1619 LinkedHashMapImplementation.prototype.isEmpty$0 = LinkedHashMapImplementation.pr
ototype.isEmpty; | |
1620 // ********** Code for DoubleLinkedQueueEntry ************** | 971 // ********** Code for DoubleLinkedQueueEntry ************** |
1621 function DoubleLinkedQueueEntry(e) { | 972 function DoubleLinkedQueueEntry(e) { |
1622 this._element = e; | 973 this._element = e; |
1623 } | 974 } |
1624 DoubleLinkedQueueEntry.prototype._link = function(p, n) { | 975 DoubleLinkedQueueEntry.prototype._link = function(p, n) { |
1625 this._next = n; | 976 this._next = n; |
1626 this._previous = p; | 977 this._previous = p; |
1627 p._next = this; | 978 p._next = this; |
1628 n._previous = this; | 979 n._previous = this; |
1629 } | 980 } |
1630 DoubleLinkedQueueEntry.prototype.prepend = function(e) { | 981 DoubleLinkedQueueEntry.prototype.prepend = function(e) { |
1631 new DoubleLinkedQueueEntry_E(e)._link(this._previous, this); | 982 new DoubleLinkedQueueEntry(e)._link(this._previous, this); |
1632 } | 983 } |
1633 DoubleLinkedQueueEntry.prototype.remove = function() { | 984 DoubleLinkedQueueEntry.prototype.remove = function() { |
1634 this._previous._next = this._next; | 985 this._previous._next = this._next; |
1635 this._next._previous = this._previous; | 986 this._next._previous = this._previous; |
1636 this._next = null; | 987 this._next = null; |
1637 this._previous = null; | 988 this._previous = null; |
1638 return this._element; | 989 return this._element; |
1639 } | 990 } |
1640 DoubleLinkedQueueEntry.prototype._asNonSentinelEntry = function() { | 991 DoubleLinkedQueueEntry.prototype._asNonSentinelEntry = function() { |
1641 return this; | 992 return this; |
1642 } | 993 } |
1643 DoubleLinkedQueueEntry.prototype.previousEntry = function() { | 994 DoubleLinkedQueueEntry.prototype.previousEntry = function() { |
1644 return this._previous._asNonSentinelEntry(); | 995 return this._previous._asNonSentinelEntry(); |
1645 } | 996 } |
1646 DoubleLinkedQueueEntry.prototype.get$element = function() { | 997 DoubleLinkedQueueEntry.prototype.get$element = function() { |
1647 return this._element; | 998 return this._element; |
1648 } | 999 } |
1649 DoubleLinkedQueueEntry.prototype._asNonSentinelEntry$0 = DoubleLinkedQueueEntry.
prototype._asNonSentinelEntry; | 1000 // ********** Code for DoubleLinkedQueueEntry_KeyValuePair ************** |
1650 // ********** Code for DoubleLinkedQueueEntry_E ************** | 1001 $inherits(DoubleLinkedQueueEntry_KeyValuePair, DoubleLinkedQueueEntry); |
1651 $inherits(DoubleLinkedQueueEntry_E, DoubleLinkedQueueEntry); | 1002 function DoubleLinkedQueueEntry_KeyValuePair(e) { |
1652 function DoubleLinkedQueueEntry_E(e) { | |
1653 this._element = e; | 1003 this._element = e; |
1654 } | 1004 } |
1655 DoubleLinkedQueueEntry_E.prototype._link = function(p, n) { | |
1656 this._next = n; | |
1657 this._previous = p; | |
1658 p._next = this; | |
1659 n._previous = this; | |
1660 } | |
1661 DoubleLinkedQueueEntry_E.prototype.prepend = function(e) { | |
1662 new DoubleLinkedQueueEntry_E(e)._link(this._previous, this); | |
1663 } | |
1664 DoubleLinkedQueueEntry_E.prototype.remove = function() { | |
1665 this._previous._next = this._next; | |
1666 this._next._previous = this._previous; | |
1667 this._next = null; | |
1668 this._previous = null; | |
1669 return this._element; | |
1670 } | |
1671 DoubleLinkedQueueEntry_E.prototype._asNonSentinelEntry = function() { | |
1672 return this; | |
1673 } | |
1674 DoubleLinkedQueueEntry_E.prototype.previousEntry = function() { | |
1675 return this._previous._asNonSentinelEntry(); | |
1676 } | |
1677 // ********** Code for DoubleLinkedQueueEntry_KeyValuePair_K$V ************** | |
1678 $inherits(DoubleLinkedQueueEntry_KeyValuePair_K$V, DoubleLinkedQueueEntry); | |
1679 function DoubleLinkedQueueEntry_KeyValuePair_K$V(e) { | |
1680 this._element = e; | |
1681 } | |
1682 DoubleLinkedQueueEntry_KeyValuePair_K$V.prototype._link = function(p, n) { | |
1683 this._next = n; | |
1684 this._previous = p; | |
1685 p._next = this; | |
1686 n._previous = this; | |
1687 } | |
1688 DoubleLinkedQueueEntry_KeyValuePair_K$V.prototype.prepend = function(e) { | |
1689 new DoubleLinkedQueueEntry_KeyValuePair_K$V(e)._link(this._previous, this); | |
1690 } | |
1691 DoubleLinkedQueueEntry_KeyValuePair_K$V.prototype._asNonSentinelEntry = function
() { | |
1692 return this; | |
1693 } | |
1694 DoubleLinkedQueueEntry_KeyValuePair_K$V.prototype.previousEntry = function() { | |
1695 return this._previous._asNonSentinelEntry$0(); | |
1696 } | |
1697 // ********** Code for _DoubleLinkedQueueEntrySentinel ************** | 1005 // ********** Code for _DoubleLinkedQueueEntrySentinel ************** |
1698 $inherits(_DoubleLinkedQueueEntrySentinel, DoubleLinkedQueueEntry_E); | 1006 $inherits(_DoubleLinkedQueueEntrySentinel, DoubleLinkedQueueEntry); |
1699 function _DoubleLinkedQueueEntrySentinel() { | 1007 function _DoubleLinkedQueueEntrySentinel() { |
1700 DoubleLinkedQueueEntry_E.call(this, null); | 1008 DoubleLinkedQueueEntry.call(this, null); |
1701 this._link(this, this); | 1009 this._link(this, this); |
1702 } | 1010 } |
1703 _DoubleLinkedQueueEntrySentinel.prototype.remove = function() { | 1011 _DoubleLinkedQueueEntrySentinel.prototype.remove = function() { |
1704 $throw(const$0000); | 1012 $throw(const$0002); |
1705 } | 1013 } |
1706 _DoubleLinkedQueueEntrySentinel.prototype._asNonSentinelEntry = function() { | 1014 _DoubleLinkedQueueEntrySentinel.prototype._asNonSentinelEntry = function() { |
1707 return null; | 1015 return null; |
1708 } | 1016 } |
1709 _DoubleLinkedQueueEntrySentinel.prototype.get$element = function() { | 1017 _DoubleLinkedQueueEntrySentinel.prototype.get$element = function() { |
1710 $throw(const$0000); | 1018 $throw(const$0002); |
1711 } | 1019 } |
1712 _DoubleLinkedQueueEntrySentinel.prototype._asNonSentinelEntry$0 = _DoubleLinkedQ
ueueEntrySentinel.prototype._asNonSentinelEntry; | 1020 // ********** Code for _DoubleLinkedQueueEntrySentinel_KeyValuePair ************
** |
1713 // ********** Code for _DoubleLinkedQueueEntrySentinel_E ************** | 1021 $inherits(_DoubleLinkedQueueEntrySentinel_KeyValuePair, _DoubleLinkedQueueEntryS
entinel); |
1714 $inherits(_DoubleLinkedQueueEntrySentinel_E, _DoubleLinkedQueueEntrySentinel); | 1022 function _DoubleLinkedQueueEntrySentinel_KeyValuePair() { |
1715 function _DoubleLinkedQueueEntrySentinel_E() { | 1023 DoubleLinkedQueueEntry_KeyValuePair.call(this, null); |
1716 DoubleLinkedQueueEntry_E.call(this, null); | |
1717 this._link(this, this); | |
1718 } | |
1719 // ********** Code for _DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V ********
****** | |
1720 $inherits(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, _DoubleLinkedQueueEn
trySentinel); | |
1721 function _DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V() { | |
1722 DoubleLinkedQueueEntry_KeyValuePair_K$V.call(this, null); | |
1723 this._link(this, this); | 1024 this._link(this, this); |
1724 } | 1025 } |
1725 // ********** Code for DoubleLinkedQueue ************** | 1026 // ********** Code for DoubleLinkedQueue ************** |
1726 function DoubleLinkedQueue() { | 1027 function DoubleLinkedQueue() { |
1727 this._sentinel = new _DoubleLinkedQueueEntrySentinel_E(); | 1028 this._sentinel = new _DoubleLinkedQueueEntrySentinel(); |
1728 } | 1029 } |
1729 DoubleLinkedQueue.DoubleLinkedQueue$from$factory = function(other) { | 1030 DoubleLinkedQueue.DoubleLinkedQueue$from$factory = function(other) { |
1730 var list = new DoubleLinkedQueue(); | 1031 var list = new DoubleLinkedQueue(); |
1731 for (var $$i = other.iterator$0(); $$i.hasNext$0(); ) { | 1032 for (var $$i = other.iterator(); $$i.hasNext(); ) { |
1732 var e = $$i.next$0(); | 1033 var e = $$i.next(); |
1733 list.addLast(e); | 1034 list.addLast(e); |
1734 } | 1035 } |
1735 return list; | 1036 return list; |
1736 } | 1037 } |
1737 DoubleLinkedQueue.prototype.addLast = function(value) { | 1038 DoubleLinkedQueue.prototype.addLast = function(value) { |
1738 this._sentinel.prepend(value); | 1039 this._sentinel.prepend(value); |
1739 } | 1040 } |
1740 DoubleLinkedQueue.prototype.add = function(value) { | 1041 DoubleLinkedQueue.prototype.add = function(value) { |
1741 this.addLast(value); | 1042 this.addLast(value); |
1742 } | 1043 } |
1743 DoubleLinkedQueue.prototype.addAll = function(collection) { | 1044 DoubleLinkedQueue.prototype.addAll = function(collection) { |
1744 for (var $$i = collection.iterator$0(); $$i.hasNext$0(); ) { | 1045 for (var $$i = collection.iterator(); $$i.hasNext(); ) { |
1745 var e = $$i.next$0(); | 1046 var e = $$i.next(); |
1746 this.add(e); | 1047 this.add(e); |
1747 } | 1048 } |
1748 } | 1049 } |
1749 DoubleLinkedQueue.prototype.removeLast = function() { | 1050 DoubleLinkedQueue.prototype.removeLast = function() { |
1750 return this._sentinel._previous.remove(); | 1051 return this._sentinel._previous.remove(); |
1751 } | 1052 } |
1752 DoubleLinkedQueue.prototype.removeFirst = function() { | 1053 DoubleLinkedQueue.prototype.removeFirst = function() { |
1753 return this._sentinel._next.remove(); | 1054 return this._sentinel._next.remove(); |
1754 } | 1055 } |
1755 DoubleLinkedQueue.prototype.last = function() { | 1056 DoubleLinkedQueue.prototype.last = function() { |
(...skipping 10 matching lines...) Expand all Loading... |
1766 ); | 1067 ); |
1767 return counter; | 1068 return counter; |
1768 } | 1069 } |
1769 DoubleLinkedQueue.prototype.isEmpty = function() { | 1070 DoubleLinkedQueue.prototype.isEmpty = function() { |
1770 return (this._sentinel._next == this._sentinel); | 1071 return (this._sentinel._next == this._sentinel); |
1771 } | 1072 } |
1772 DoubleLinkedQueue.prototype.forEach = function(f) { | 1073 DoubleLinkedQueue.prototype.forEach = function(f) { |
1773 var entry = this._sentinel._next; | 1074 var entry = this._sentinel._next; |
1774 while (entry != this._sentinel) { | 1075 while (entry != this._sentinel) { |
1775 var nextEntry = entry._next; | 1076 var nextEntry = entry._next; |
1776 f.call$1(entry._element); | 1077 f(entry._element); |
1777 entry = nextEntry; | 1078 entry = nextEntry; |
1778 } | 1079 } |
1779 } | 1080 } |
1780 DoubleLinkedQueue.prototype.every = function(f) { | 1081 DoubleLinkedQueue.prototype.every = function(f) { |
1781 var entry = this._sentinel._next; | 1082 var entry = this._sentinel._next; |
1782 while (entry != this._sentinel) { | 1083 while (entry != this._sentinel) { |
1783 var nextEntry = entry._next; | 1084 var nextEntry = entry._next; |
1784 if (!f.call$1(entry._element)) return false; | 1085 if (!f(entry._element)) return false; |
1785 entry = nextEntry; | 1086 entry = nextEntry; |
1786 } | 1087 } |
1787 return true; | 1088 return true; |
1788 } | 1089 } |
1789 DoubleLinkedQueue.prototype.some = function(f) { | 1090 DoubleLinkedQueue.prototype.some = function(f) { |
1790 var entry = this._sentinel._next; | 1091 var entry = this._sentinel._next; |
1791 while (entry != this._sentinel) { | 1092 while (entry != this._sentinel) { |
1792 var nextEntry = entry._next; | 1093 var nextEntry = entry._next; |
1793 if (f.call$1(entry._element)) return true; | 1094 if (f(entry._element)) return true; |
1794 entry = nextEntry; | 1095 entry = nextEntry; |
1795 } | 1096 } |
1796 return false; | 1097 return false; |
1797 } | 1098 } |
1798 DoubleLinkedQueue.prototype.filter = function(f) { | 1099 DoubleLinkedQueue.prototype.filter = function(f) { |
1799 var other = new DoubleLinkedQueue(); | 1100 var other = new DoubleLinkedQueue(); |
1800 var entry = this._sentinel._next; | 1101 var entry = this._sentinel._next; |
1801 while (entry != this._sentinel) { | 1102 while (entry != this._sentinel) { |
1802 var nextEntry = entry._next; | 1103 var nextEntry = entry._next; |
1803 if (f.call$1(entry._element)) other.addLast(entry._element); | 1104 if (f(entry._element)) other.addLast(entry._element); |
1804 entry = nextEntry; | 1105 entry = nextEntry; |
1805 } | 1106 } |
1806 return other; | 1107 return other; |
1807 } | 1108 } |
1808 DoubleLinkedQueue.prototype.iterator = function() { | 1109 DoubleLinkedQueue.prototype.iterator = function() { |
1809 return new _DoubleLinkedQueueIterator_E(this._sentinel); | 1110 return new _DoubleLinkedQueueIterator(this._sentinel); |
1810 } | 1111 } |
1811 DoubleLinkedQueue.prototype.add$1 = DoubleLinkedQueue.prototype.add; | 1112 // ********** Code for DoubleLinkedQueue_KeyValuePair ************** |
1812 DoubleLinkedQueue.prototype.addAll$1 = DoubleLinkedQueue.prototype.addAll; | 1113 $inherits(DoubleLinkedQueue_KeyValuePair, DoubleLinkedQueue); |
1813 DoubleLinkedQueue.prototype.addLast$1 = DoubleLinkedQueue.prototype.addLast; | 1114 function DoubleLinkedQueue_KeyValuePair() { |
1814 DoubleLinkedQueue.prototype.filter$1 = function($0) { | 1115 this._sentinel = new _DoubleLinkedQueueEntrySentinel_KeyValuePair(); |
1815 return this.filter(to$call$1($0)); | |
1816 }; | |
1817 DoubleLinkedQueue.prototype.forEach$1 = function($0) { | |
1818 return this.forEach(to$call$1($0)); | |
1819 }; | |
1820 DoubleLinkedQueue.prototype.isEmpty$0 = DoubleLinkedQueue.prototype.isEmpty; | |
1821 DoubleLinkedQueue.prototype.iterator$0 = DoubleLinkedQueue.prototype.iterator; | |
1822 DoubleLinkedQueue.prototype.last$0 = DoubleLinkedQueue.prototype.last; | |
1823 DoubleLinkedQueue.prototype.removeLast$0 = DoubleLinkedQueue.prototype.removeLas
t; | |
1824 // ********** Code for DoubleLinkedQueue_E ************** | |
1825 $inherits(DoubleLinkedQueue_E, DoubleLinkedQueue); | |
1826 function DoubleLinkedQueue_E() {} | |
1827 // ********** Code for DoubleLinkedQueue_KeyValuePair_K$V ************** | |
1828 $inherits(DoubleLinkedQueue_KeyValuePair_K$V, DoubleLinkedQueue); | |
1829 function DoubleLinkedQueue_KeyValuePair_K$V() { | |
1830 this._sentinel = new _DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V(); | |
1831 } | |
1832 DoubleLinkedQueue_KeyValuePair_K$V.prototype.addLast = function(value) { | |
1833 this._sentinel.prepend(value); | |
1834 } | |
1835 DoubleLinkedQueue_KeyValuePair_K$V.prototype.lastEntry = function() { | |
1836 return this._sentinel.previousEntry(); | |
1837 } | |
1838 DoubleLinkedQueue_KeyValuePair_K$V.prototype.forEach = function(f) { | |
1839 var entry = this._sentinel._next; | |
1840 while (entry != this._sentinel) { | |
1841 var nextEntry = entry._next; | |
1842 f.call$1(entry._element); | |
1843 entry = nextEntry; | |
1844 } | |
1845 } | 1116 } |
1846 // ********** Code for _DoubleLinkedQueueIterator ************** | 1117 // ********** Code for _DoubleLinkedQueueIterator ************** |
1847 function _DoubleLinkedQueueIterator(_sentinel) { | 1118 function _DoubleLinkedQueueIterator(_sentinel) { |
1848 this._sentinel = _sentinel; | 1119 this._sentinel = _sentinel; |
1849 this._currentEntry = this._sentinel; | 1120 this._currentEntry = this._sentinel; |
1850 } | 1121 } |
1851 _DoubleLinkedQueueIterator.prototype.hasNext = function() { | 1122 _DoubleLinkedQueueIterator.prototype.hasNext = function() { |
1852 return this._currentEntry._next != this._sentinel; | 1123 return this._currentEntry._next != this._sentinel; |
1853 } | 1124 } |
1854 _DoubleLinkedQueueIterator.prototype.next = function() { | 1125 _DoubleLinkedQueueIterator.prototype.next = function() { |
1855 if (!this.hasNext()) { | 1126 if (!this.hasNext()) { |
1856 $throw(const$0005); | 1127 $throw(const$0001); |
1857 } | 1128 } |
1858 this._currentEntry = this._currentEntry._next; | 1129 this._currentEntry = this._currentEntry._next; |
1859 return this._currentEntry.get$element(); | 1130 return this._currentEntry.get$element(); |
1860 } | 1131 } |
1861 _DoubleLinkedQueueIterator.prototype.hasNext$0 = _DoubleLinkedQueueIterator.prot
otype.hasNext; | |
1862 _DoubleLinkedQueueIterator.prototype.next$0 = _DoubleLinkedQueueIterator.prototy
pe.next; | |
1863 // ********** Code for _DoubleLinkedQueueIterator_E ************** | |
1864 $inherits(_DoubleLinkedQueueIterator_E, _DoubleLinkedQueueIterator); | |
1865 function _DoubleLinkedQueueIterator_E(_sentinel) { | |
1866 this._sentinel = _sentinel; | |
1867 this._currentEntry = this._sentinel; | |
1868 } | |
1869 // ********** Code for StopwatchImplementation ************** | 1132 // ********** Code for StopwatchImplementation ************** |
1870 function StopwatchImplementation() { | 1133 function StopwatchImplementation() { |
1871 this._start = null; | 1134 this._start = null; |
1872 this._stop = null; | 1135 this._stop = null; |
1873 } | 1136 } |
1874 StopwatchImplementation.prototype.start = function() { | 1137 StopwatchImplementation.prototype.start = function() { |
1875 if (this._start == null) { | 1138 if (this._start == null) { |
1876 this._start = Clock.now(); | 1139 this._start = Clock.now(); |
1877 } | 1140 } |
1878 else { | 1141 else { |
(...skipping 17 matching lines...) Expand all Loading... |
1896 return (0); | 1159 return (0); |
1897 } | 1160 } |
1898 return (this._stop == null) ? (Clock.now() - this._start) : (this._stop - this
._start); | 1161 return (this._stop == null) ? (Clock.now() - this._start) : (this._stop - this
._start); |
1899 } | 1162 } |
1900 StopwatchImplementation.prototype.elapsedInMs = function() { | 1163 StopwatchImplementation.prototype.elapsedInMs = function() { |
1901 return $truncdiv((this.elapsed() * (1000)), this.frequency()); | 1164 return $truncdiv((this.elapsed() * (1000)), this.frequency()); |
1902 } | 1165 } |
1903 StopwatchImplementation.prototype.frequency = function() { | 1166 StopwatchImplementation.prototype.frequency = function() { |
1904 return Clock.frequency(); | 1167 return Clock.frequency(); |
1905 } | 1168 } |
1906 StopwatchImplementation.prototype.elapsedInMs$0 = StopwatchImplementation.protot
ype.elapsedInMs; | |
1907 StopwatchImplementation.prototype.start$0 = StopwatchImplementation.prototype.st
art; | |
1908 StopwatchImplementation.prototype.stop$0 = StopwatchImplementation.prototype.sto
p; | |
1909 // ********** Code for StringBufferImpl ************** | 1169 // ********** Code for StringBufferImpl ************** |
1910 function StringBufferImpl(content) { | 1170 function StringBufferImpl(content) { |
1911 this.clear(); | 1171 this.clear(); |
1912 this.add(content); | 1172 this.add(content); |
1913 } | 1173 } |
1914 StringBufferImpl.prototype.get$length = function() { | 1174 StringBufferImpl.prototype.get$length = function() { |
1915 return this._length; | 1175 return this._length; |
1916 } | 1176 } |
1917 StringBufferImpl.prototype.isEmpty = function() { | 1177 StringBufferImpl.prototype.isEmpty = function() { |
1918 return this._length == (0); | 1178 return this._length == (0); |
1919 } | 1179 } |
1920 StringBufferImpl.prototype.add = function(obj) { | 1180 StringBufferImpl.prototype.add = function(obj) { |
1921 var str = obj.toString$0(); | 1181 var str = obj.toString$0(); |
1922 if (str == null || str.isEmpty()) return this; | 1182 if (str == null || str.isEmpty()) return this; |
1923 this._buffer.add(str); | 1183 this._buffer.add(str); |
1924 this._length = this._length + str.length; | 1184 this._length = this._length + str.length; |
1925 return this; | 1185 return this; |
1926 } | 1186 } |
1927 StringBufferImpl.prototype.addAll = function(objects) { | 1187 StringBufferImpl.prototype.addAll = function(objects) { |
1928 for (var $$i = objects.iterator$0(); $$i.hasNext$0(); ) { | 1188 for (var $$i = objects.iterator(); $$i.hasNext(); ) { |
1929 var obj = $$i.next$0(); | 1189 var obj = $$i.next(); |
1930 this.add(obj); | 1190 this.add(obj); |
1931 } | 1191 } |
1932 return this; | 1192 return this; |
1933 } | 1193 } |
1934 StringBufferImpl.prototype.clear = function() { | 1194 StringBufferImpl.prototype.clear = function() { |
1935 this._buffer = new Array(); | 1195 this._buffer = new Array(); |
1936 this._length = (0); | 1196 this._length = (0); |
1937 return this; | 1197 return this; |
1938 } | 1198 } |
1939 StringBufferImpl.prototype.toString = function() { | 1199 StringBufferImpl.prototype.toString = function() { |
1940 if (this._buffer.get$length() == (0)) return ""; | 1200 if (this._buffer.get$length() == (0)) return ""; |
1941 if (this._buffer.get$length() == (1)) return this._buffer[(0)]; | 1201 if (this._buffer.get$length() == (1)) return this._buffer[(0)]; |
1942 var result = StringBase.concatAll(this._buffer); | 1202 var result = StringBase.concatAll(this._buffer); |
1943 this._buffer.clear(); | 1203 this._buffer.clear(); |
1944 this._buffer.add(result); | 1204 this._buffer.add(result); |
1945 return result; | 1205 return result; |
1946 } | 1206 } |
1947 StringBufferImpl.prototype.add$1 = StringBufferImpl.prototype.add; | |
1948 StringBufferImpl.prototype.addAll$1 = StringBufferImpl.prototype.addAll; | |
1949 StringBufferImpl.prototype.isEmpty$0 = StringBufferImpl.prototype.isEmpty; | |
1950 StringBufferImpl.prototype.toString$0 = StringBufferImpl.prototype.toString; | 1207 StringBufferImpl.prototype.toString$0 = StringBufferImpl.prototype.toString; |
1951 // ********** Code for StringBase ************** | 1208 // ********** Code for StringBase ************** |
1952 function StringBase() {} | 1209 function StringBase() {} |
1953 StringBase.createFromCharCodes = function(charCodes) { | 1210 StringBase.createFromCharCodes = function(charCodes) { |
1954 if (Object.getPrototypeOf(charCodes) !== Array.prototype) { | 1211 if (Object.getPrototypeOf(charCodes) !== Array.prototype) { |
1955 charCodes = new ListFactory.ListFactory$from$factory(charCodes); | 1212 charCodes = new ListFactory.ListFactory$from$factory(charCodes); |
1956 } | 1213 } |
1957 return String.fromCharCode.apply(null, charCodes); | 1214 return String.fromCharCode.apply(null, charCodes); |
1958 } | 1215 } |
1959 StringBase.join = function(strings, separator) { | 1216 StringBase.join = function(strings, separator) { |
1960 if (strings.get$length() == (0)) return ""; | 1217 if (strings.get$length() == (0)) return ""; |
1961 var s = strings[(0)]; | 1218 var s = strings[(0)]; |
1962 for (var i = (1); | 1219 for (var i = (1); |
1963 i < strings.get$length(); i++) { | 1220 i < strings.get$length(); i++) { |
1964 s = s + separator + strings[i]; | 1221 s = $add($add(s, separator), strings[i]); |
1965 } | 1222 } |
1966 return s; | 1223 return s; |
1967 } | 1224 } |
1968 StringBase.concatAll = function(strings) { | 1225 StringBase.concatAll = function(strings) { |
1969 return StringBase.join(strings, ""); | 1226 return StringBase.join(strings, ""); |
1970 } | 1227 } |
1971 // ********** Code for StringImplementation ************** | 1228 // ********** Code for StringImplementation ************** |
1972 StringImplementation = String; | 1229 StringImplementation = String; |
1973 StringImplementation.prototype.get$length = function() { return this.length; }; | 1230 StringImplementation.prototype.get$length = function() { return this.length; }; |
1974 StringImplementation.prototype.endsWith = function(other) { | 1231 StringImplementation.prototype.endsWith = function(other) { |
1975 'use strict'; | 1232 'use strict'; |
1976 if (other.length > this.length) return false; | 1233 if (other.length > this.length) return false; |
1977 return other == this.substring(this.length - other.length); | 1234 return other == this.substring(this.length - other.length); |
1978 } | 1235 } |
1979 StringImplementation.prototype.startsWith = function(other) { | 1236 StringImplementation.prototype.startsWith = function(other) { |
1980 'use strict'; | 1237 'use strict'; |
1981 if (other.length > this.length) return false; | 1238 if (other.length > this.length) return false; |
1982 return other == this.substring(0, other.length); | 1239 return other == this.substring(0, other.length); |
1983 } | 1240 } |
1984 StringImplementation.prototype.isEmpty = function() { | 1241 StringImplementation.prototype.isEmpty = function() { |
1985 return this.length == (0); | 1242 return this.length == (0); |
1986 } | 1243 } |
1987 StringImplementation.prototype.contains = function(pattern, startIndex) { | 1244 StringImplementation.prototype.contains = function(pattern, startIndex) { |
1988 'use strict'; return this.indexOf(pattern, startIndex) >= 0; | 1245 'use strict'; return this.indexOf(pattern, startIndex) >= 0; |
1989 } | 1246 } |
1990 StringImplementation.prototype._replaceFirst = function(from, to) { | |
1991 'use strict';return this.replace(from, to); | |
1992 } | |
1993 StringImplementation.prototype._replaceRegExp = function(from, to) { | 1247 StringImplementation.prototype._replaceRegExp = function(from, to) { |
1994 'use strict';return this.replace(from.re, to); | 1248 'use strict';return this.replace(from.re, to); |
1995 } | 1249 } |
1996 StringImplementation.prototype.replaceFirst = function(from, to) { | |
1997 if ((typeof(from) == 'string')) return this._replaceFirst(from, to); | |
1998 if (!!(from && from.is$RegExp())) return this._replaceRegExp(from, to); | |
1999 var $$list = from.allMatches(this); | |
2000 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | |
2001 var match = $$i.next$0(); | |
2002 return this.substring((0), match.start$0()) + to + this.substring(match.end$
0()); | |
2003 } | |
2004 } | |
2005 StringImplementation.prototype._replaceAll = function(from, to) { | 1250 StringImplementation.prototype._replaceAll = function(from, to) { |
2006 'use strict'; | 1251 'use strict'; |
2007 from = new RegExp(from.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'g'); | 1252 from = new RegExp(from.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'g'); |
2008 to = to.replace(/\$/g, '$$$$'); // Escape sequences are fun! | 1253 to = to.replace(/\$/g, '$$$$'); // Escape sequences are fun! |
2009 return this.replace(from, to); | 1254 return this.replace(from, to); |
2010 } | 1255 } |
2011 StringImplementation.prototype.replaceAll = function(from, to) { | 1256 StringImplementation.prototype.replaceAll = function(from, to) { |
2012 if ((typeof(from) == 'string')) return this._replaceAll(from, to); | 1257 if ((typeof(from) == 'string')) return this._replaceAll(from, to); |
2013 if (!!(from && from.is$RegExp())) return this._replaceRegExp(from.get$dynamic(
).get$_global(), to); | 1258 if (!!(from && from.is$RegExp())) return this._replaceRegExp(from.get$dynamic(
).get$_global(), to); |
2014 var buffer = new StringBufferImpl(""); | 1259 var buffer = new StringBufferImpl(""); |
2015 var lastMatchEnd = (0); | 1260 var lastMatchEnd = (0); |
2016 var $$list = from.allMatches(this); | 1261 var $$list = from.allMatches(this); |
2017 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 1262 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
2018 var match = $$i.next$0(); | 1263 var match = $$i.next(); |
2019 buffer.add$1(this.substring(lastMatchEnd, match.start$0())); | 1264 buffer.add(this.substring(lastMatchEnd, match.start())); |
2020 buffer.add$1(to); | 1265 buffer.add(to); |
2021 lastMatchEnd = match.end$0(); | 1266 lastMatchEnd = match.end$0(); |
2022 } | 1267 } |
2023 buffer.add$1(this.substring(lastMatchEnd)); | 1268 buffer.add(this.substring(lastMatchEnd)); |
2024 } | 1269 } |
2025 StringImplementation.prototype.hashCode = function() { | 1270 StringImplementation.prototype.hashCode = function() { |
2026 'use strict'; | 1271 'use strict'; |
2027 var hash = 0; | 1272 var hash = 0; |
2028 for (var i = 0; i < this.length; i++) { | 1273 for (var i = 0; i < this.length; i++) { |
2029 hash = 0x1fffffff & (hash + this.charCodeAt(i)); | 1274 hash = 0x1fffffff & (hash + this.charCodeAt(i)); |
2030 hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); | 1275 hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); |
2031 hash ^= hash >> 6; | 1276 hash ^= hash >> 6; |
2032 } | 1277 } |
2033 | 1278 |
2034 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); | 1279 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); |
2035 hash ^= hash >> 11; | 1280 hash ^= hash >> 11; |
2036 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); | 1281 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); |
2037 } | 1282 } |
2038 StringImplementation.prototype.compareTo = function(other) { | 1283 StringImplementation.prototype.compareTo = function(other) { |
2039 'use strict'; return this == other ? 0 : this < other ? -1 : 1; | 1284 'use strict'; return this == other ? 0 : this < other ? -1 : 1; |
2040 } | 1285 } |
2041 StringImplementation.prototype.compareTo$1 = StringImplementation.prototype.comp
areTo; | |
2042 StringImplementation.prototype.contains$1 = StringImplementation.prototype.conta
ins; | 1286 StringImplementation.prototype.contains$1 = StringImplementation.prototype.conta
ins; |
2043 StringImplementation.prototype.endsWith$1 = StringImplementation.prototype.endsW
ith; | |
2044 StringImplementation.prototype.hashCode$0 = StringImplementation.prototype.hashC
ode; | |
2045 StringImplementation.prototype.indexOf$1 = StringImplementation.prototype.indexO
f; | 1287 StringImplementation.prototype.indexOf$1 = StringImplementation.prototype.indexO
f; |
2046 StringImplementation.prototype.isEmpty$0 = StringImplementation.prototype.isEmpt
y; | |
2047 StringImplementation.prototype.replaceFirst$2 = StringImplementation.prototype.r
eplaceFirst; | |
2048 StringImplementation.prototype.startsWith$1 = StringImplementation.prototype.sta
rtsWith; | |
2049 StringImplementation.prototype.substring$1 = StringImplementation.prototype.subs
tring; | 1288 StringImplementation.prototype.substring$1 = StringImplementation.prototype.subs
tring; |
2050 StringImplementation.prototype.substring$2 = StringImplementation.prototype.subs
tring; | |
2051 // ********** Code for Collections ************** | |
2052 function Collections() {} | |
2053 Collections.forEach = function(iterable, f) { | |
2054 for (var $$i = iterable.iterator$0(); $$i.hasNext$0(); ) { | |
2055 var e = $$i.next$0(); | |
2056 f.call$1(e); | |
2057 } | |
2058 } | |
2059 Collections.some = function(iterable, f) { | |
2060 for (var $$i = iterable.iterator$0(); $$i.hasNext$0(); ) { | |
2061 var e = $$i.next$0(); | |
2062 if (f.call$1(e)) return true; | |
2063 } | |
2064 return false; | |
2065 } | |
2066 Collections.every = function(iterable, f) { | |
2067 for (var $$i = iterable.iterator$0(); $$i.hasNext$0(); ) { | |
2068 var e = $$i.next$0(); | |
2069 if (!f.call$1(e)) return false; | |
2070 } | |
2071 return true; | |
2072 } | |
2073 Collections.filter = function(source, destination, f) { | |
2074 for (var $$i = source.iterator$0(); $$i.hasNext$0(); ) { | |
2075 var e = $$i.next$0(); | |
2076 if (f.call$1(e)) destination.add(e); | |
2077 } | |
2078 return destination; | |
2079 } | |
2080 // ********** Code for _Worker ************** | 1289 // ********** Code for _Worker ************** |
| 1290 var _Worker = {}; |
2081 // ********** Code for _ArgumentMismatchException ************** | 1291 // ********** Code for _ArgumentMismatchException ************** |
2082 $inherits(_ArgumentMismatchException, ClosureArgumentMismatchException); | 1292 $inherits(_ArgumentMismatchException, ClosureArgumentMismatchException); |
2083 function _ArgumentMismatchException(_message) { | 1293 function _ArgumentMismatchException(_message) { |
2084 this._dart_coreimpl_message = _message; | 1294 this._dart_coreimpl_message = _message; |
2085 ClosureArgumentMismatchException.call(this); | 1295 ClosureArgumentMismatchException.call(this); |
2086 } | 1296 } |
2087 _ArgumentMismatchException.prototype.toString = function() { | 1297 _ArgumentMismatchException.prototype.toString = function() { |
2088 return ("Closure argument mismatch: " + this._dart_coreimpl_message); | 1298 return ("Closure argument mismatch: " + this._dart_coreimpl_message); |
2089 } | 1299 } |
2090 _ArgumentMismatchException.prototype.toString$0 = _ArgumentMismatchException.pro
totype.toString; | 1300 _ArgumentMismatchException.prototype.toString$0 = _ArgumentMismatchException.pro
totype.toString; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 } | 1366 } |
2157 // ********** Code for top level ************** | 1367 // ********** Code for top level ************** |
2158 function _constList(other) { | 1368 function _constList(other) { |
2159 other.__proto__ = ImmutableList.prototype; | 1369 other.__proto__ = ImmutableList.prototype; |
2160 return other; | 1370 return other; |
2161 } | 1371 } |
2162 function _map(itemsAndKeys) { | 1372 function _map(itemsAndKeys) { |
2163 var ret = new LinkedHashMapImplementation(); | 1373 var ret = new LinkedHashMapImplementation(); |
2164 for (var i = (0); | 1374 for (var i = (0); |
2165 i < itemsAndKeys.get$length(); ) { | 1375 i < itemsAndKeys.get$length(); ) { |
2166 ret.$setindex(itemsAndKeys[i++], itemsAndKeys[i++]); | 1376 ret.$setindex(itemsAndKeys.$index(i++), itemsAndKeys.$index(i++)); |
2167 } | 1377 } |
2168 return ret; | 1378 return ret; |
2169 } | 1379 } |
2170 // ********** Library node ************** | 1380 // ********** Library node ************** |
2171 // ********** Code for Process ************** | 1381 // ********** Code for Process ************** |
2172 function Process(_process) { | 1382 function Process(_process) { |
2173 this.SIGSYS = "SIGSYS"; | 1383 this.SIGSYS = "SIGSYS"; |
2174 this.SIGALRM = "SIGALRM"; | 1384 this.SIGALRM = "SIGALRM"; |
2175 this.SIGXCPU = "SIGXCPU"; | 1385 this.SIGXCPU = "SIGXCPU"; |
2176 this.SIGTSTP = "SIGTSTP"; | 1386 this.SIGTSTP = "SIGTSTP"; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 this._process.exit(code); | 1426 this._process.exit(code); |
2217 } | 1427 } |
2218 // ********** Code for EnvMap ************** | 1428 // ********** Code for EnvMap ************** |
2219 function EnvMap(_process) { | 1429 function EnvMap(_process) { |
2220 this._process = _process; | 1430 this._process = _process; |
2221 } | 1431 } |
2222 EnvMap.prototype.$index = function(key) { | 1432 EnvMap.prototype.$index = function(key) { |
2223 return this._process.env[key]; | 1433 return this._process.env[key]; |
2224 } | 1434 } |
2225 // ********** Code for ReadableStream ************** | 1435 // ********** Code for ReadableStream ************** |
| 1436 var ReadableStream = {}; |
2226 // ********** Code for WritableStream ************** | 1437 // ********** Code for WritableStream ************** |
| 1438 var WritableStream = {}; |
2227 Object.defineProperty(Object.prototype, '$typeNameOf', { value: function() { | 1439 Object.defineProperty(Object.prototype, '$typeNameOf', { value: function() { |
2228 if ((typeof(window) != 'undefined' && window.constructor.name == 'DOMWindow') | 1440 if ((typeof(window) != 'undefined' && window.constructor.name == 'DOMWindow') |
2229 || typeof(process) != 'undefined') { // fast-path for Chrome and Node | 1441 || typeof(process) != 'undefined') { // fast-path for Chrome and Node |
2230 return this.constructor.name; | 1442 return this.constructor.name; |
2231 } | 1443 } |
2232 var str = Object.prototype.toString.call(this); | 1444 var str = Object.prototype.toString.call(this); |
2233 str = str.substring(8, str.length - 1); | 1445 str = str.substring(8, str.length - 1); |
2234 if (str == 'Window') { | 1446 if (str == 'Window') { |
2235 str = 'DOMWindow'; | 1447 str = 'DOMWindow'; |
2236 } else if (str == 'Document') { | 1448 } else if (str == 'Document') { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2284 var tags = inputTable[i][1]; | 1496 var tags = inputTable[i][1]; |
2285 var map = {}; | 1497 var map = {}; |
2286 var tagNames = tags.split('|'); | 1498 var tagNames = tags.split('|'); |
2287 for (var j = 0; j < tagNames.length; j++) { | 1499 for (var j = 0; j < tagNames.length; j++) { |
2288 map[tagNames[j]] = true; | 1500 map[tagNames[j]] = true; |
2289 } | 1501 } |
2290 table.push({tag: tag, tags: tags, map: map}); | 1502 table.push({tag: tag, tags: tags, map: map}); |
2291 } | 1503 } |
2292 $dynamicMetadata = table; | 1504 $dynamicMetadata = table; |
2293 } | 1505 } |
2294 $dynamic("get$end").WriteStream = function() { | |
2295 return this.end.bind(this); | |
2296 } | |
2297 $dynamic("end$0").WriteStream = function() { | 1506 $dynamic("end$0").WriteStream = function() { |
2298 return this.end(null, "utf8"); | 1507 return this.end(null, "utf8"); |
2299 }; | 1508 }; |
2300 $dynamic("write$1").WriteStream = function($0) { | 1509 $dynamic("write$1").WriteStream = function($0) { |
2301 return this.write($0, "utf8"); | 1510 return this.write($0, "utf8"); |
2302 }; | 1511 }; |
2303 // ********** Code for vm ************** | 1512 // ********** Code for vm ************** |
2304 vm = require('vm'); | 1513 vm = require('vm'); |
2305 // ********** Code for fs ************** | 1514 // ********** Code for fs ************** |
2306 fs = require('fs'); | 1515 fs = require('fs'); |
(...skipping 14 matching lines...) Expand all Loading... |
2321 // ********** Library file_system ************** | 1530 // ********** Library file_system ************** |
2322 // ********** Code for top level ************** | 1531 // ********** Code for top level ************** |
2323 function canonicalizePath(path) { | 1532 function canonicalizePath(path) { |
2324 return path.replaceAll("\\", "/"); | 1533 return path.replaceAll("\\", "/"); |
2325 } | 1534 } |
2326 function joinPaths(path1, path2) { | 1535 function joinPaths(path1, path2) { |
2327 path1 = canonicalizePath(path1); | 1536 path1 = canonicalizePath(path1); |
2328 path2 = canonicalizePath(path2); | 1537 path2 = canonicalizePath(path2); |
2329 var pieces = path1.split("/"); | 1538 var pieces = path1.split("/"); |
2330 var $$list = path2.split("/"); | 1539 var $$list = path2.split("/"); |
2331 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 1540 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
2332 var piece = $$list[$$i]; | 1541 var piece = $$i.next(); |
2333 if ($eq(piece, "..") && pieces.get$length() > (0) && $ne(pieces.last$0(), ".
") && $ne(pieces.last$0(), "..")) { | 1542 if ($eq(piece, "..") && pieces.get$length() > (0) && $ne(pieces.last(), ".")
&& $ne(pieces.last(), "..")) { |
2334 pieces.removeLast$0(); | 1543 pieces.removeLast(); |
2335 } | 1544 } |
2336 else if ($ne(piece, "")) { | 1545 else if ($ne(piece, "")) { |
2337 if (pieces.get$length() > (0) && $eq(pieces.last$0(), ".")) { | 1546 if (pieces.get$length() > (0) && $eq(pieces.last(), ".")) { |
2338 pieces.removeLast$0(); | 1547 pieces.removeLast(); |
2339 } | 1548 } |
2340 pieces.add$1(piece); | 1549 pieces.add(piece); |
2341 } | 1550 } |
2342 } | 1551 } |
2343 return Strings.join(pieces, "/"); | 1552 return Strings.join(pieces, "/"); |
2344 } | 1553 } |
2345 function dirname(path) { | 1554 function dirname(path) { |
2346 path = canonicalizePath(path); | 1555 path = canonicalizePath(path); |
2347 var lastSlash = path.lastIndexOf("/", path.length); | 1556 var lastSlash = path.lastIndexOf("/", path.length); |
2348 if (lastSlash == (-1)) { | 1557 if (lastSlash == (-1)) { |
2349 return "."; | 1558 return "."; |
2350 } | 1559 } |
(...skipping 20 matching lines...) Expand all Loading... |
2371 fs.writeFileSync(outfile, text); | 1580 fs.writeFileSync(outfile, text); |
2372 } | 1581 } |
2373 NodeFileSystem.prototype.readAll = function(filename) { | 1582 NodeFileSystem.prototype.readAll = function(filename) { |
2374 return fs.readFileSync(filename, "utf8"); | 1583 return fs.readFileSync(filename, "utf8"); |
2375 } | 1584 } |
2376 NodeFileSystem.prototype.fileExists = function(filename) { | 1585 NodeFileSystem.prototype.fileExists = function(filename) { |
2377 return path.existsSync(filename); | 1586 return path.existsSync(filename); |
2378 } | 1587 } |
2379 // ********** Code for top level ************** | 1588 // ********** Code for top level ************** |
2380 // ********** Library lang ************** | 1589 // ********** Library lang ************** |
| 1590 // ********** Code for MethodAnalyzer ************** |
| 1591 function MethodAnalyzer(method, body) { |
| 1592 this.method = method; |
| 1593 this.body = body; |
| 1594 this.hasTypeParams = false; |
| 1595 } |
| 1596 MethodAnalyzer.prototype.get$method = function() { return this.method; }; |
| 1597 MethodAnalyzer.prototype.set$method = function(value) { return this.method = val
ue; }; |
| 1598 MethodAnalyzer.prototype.get$body = function() { return this.body; }; |
| 1599 MethodAnalyzer.prototype.set$body = function(value) { return this.body = value;
}; |
| 1600 MethodAnalyzer.prototype.get$hasTypeParams = function() { return this.hasTypePar
ams; }; |
| 1601 MethodAnalyzer.prototype.set$hasTypeParams = function(value) { return this.hasTy
peParams = value; }; |
| 1602 MethodAnalyzer.prototype.analyze = function(context) { |
| 1603 var thisValue; |
| 1604 if (context != null) { |
| 1605 thisValue = context.thisValue; |
| 1606 } |
| 1607 else { |
| 1608 thisValue = new PureStaticValue(this.method.declaringType, null, false, fals
e); |
| 1609 } |
| 1610 var values = []; |
| 1611 var $$list = this.method.parameters; |
| 1612 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 1613 var p = $$i.next(); |
| 1614 values.add(new PureStaticValue(p.get$type(), null, false, false)); |
| 1615 } |
| 1616 var args = new Arguments(null, values); |
| 1617 this._frame = new CallFrame(this, this.method, thisValue, args, context); |
| 1618 this._bindArguments(this._frame.args); |
| 1619 this.body.visit(this); |
| 1620 } |
| 1621 MethodAnalyzer.prototype._hasTypeParams = function(node) { |
| 1622 if ((node instanceof NameTypeReference)) { |
| 1623 var name = node.get$name().get$name(); |
| 1624 return (this.method.declaringType.lookupTypeParam(name) != null); |
| 1625 } |
| 1626 else if ((node instanceof GenericTypeReference)) { |
| 1627 var $$list = node.get$typeArguments(); |
| 1628 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 1629 var typeArg = $$i.next(); |
| 1630 if (this._hasTypeParams(typeArg)) return true; |
| 1631 } |
| 1632 return false; |
| 1633 } |
| 1634 else { |
| 1635 return false; |
| 1636 } |
| 1637 } |
| 1638 MethodAnalyzer.prototype.resolveType = function(node, typeErrors, allowTypeParam
s) { |
| 1639 if (!this.hasTypeParams && this._hasTypeParams(node)) { |
| 1640 this.hasTypeParams = true; |
| 1641 } |
| 1642 return this.method.resolveType(node, typeErrors, allowTypeParams); |
| 1643 } |
| 1644 MethodAnalyzer.prototype.makeNeutral = function(inValue, span) { |
| 1645 return new PureStaticValue(inValue.get$type(), span, false, false); |
| 1646 } |
| 1647 MethodAnalyzer.prototype._bindArguments = function(args) { |
| 1648 for (var i = (0); |
| 1649 i < this.method.parameters.get$length(); i++) { |
| 1650 var p = this.method.parameters[i]; |
| 1651 var currentArg = null; |
| 1652 if (i < args.get$bareCount()) { |
| 1653 currentArg = args.values.$index(i); |
| 1654 } |
| 1655 else { |
| 1656 currentArg = args.getValue(p.get$name()); |
| 1657 if (currentArg == null) { |
| 1658 p.genValue(this.method, this._frame); |
| 1659 if (p.get$value() == null) { |
| 1660 $globals.world.warning("missing argument at call - does not match"); |
| 1661 } |
| 1662 currentArg = p.get$value(); |
| 1663 } |
| 1664 } |
| 1665 currentArg = this.makeNeutral(currentArg, p.get$definition().get$span()); |
| 1666 this._frame.declareParameter(p, currentArg); |
| 1667 } |
| 1668 } |
| 1669 MethodAnalyzer.prototype.visitBool = function(node) { |
| 1670 return this.visitTypedValue(node, $globals.world.boolType); |
| 1671 } |
| 1672 MethodAnalyzer.prototype.visitValue = function(node) { |
| 1673 if (node == null) return null; |
| 1674 var value = node.visit(this); |
| 1675 value.checkFirstClass(node.span); |
| 1676 return value; |
| 1677 } |
| 1678 MethodAnalyzer.prototype.visitTypedValue = function(node, expectedType) { |
| 1679 var val = this.visitValue(node); |
| 1680 return val; |
| 1681 } |
| 1682 MethodAnalyzer.prototype.visitVoid = function(node) { |
| 1683 return this.visitValue(node); |
| 1684 } |
| 1685 MethodAnalyzer.prototype._visitArgs = function(arguments) { |
| 1686 var args = []; |
| 1687 var seenLabel = false; |
| 1688 for (var $$i = arguments.iterator(); $$i.hasNext(); ) { |
| 1689 var arg = $$i.next(); |
| 1690 if (arg.get$label() != null) { |
| 1691 seenLabel = true; |
| 1692 } |
| 1693 else if (seenLabel) { |
| 1694 $globals.world.error("bare argument can not follow named arguments", arg.g
et$span()); |
| 1695 } |
| 1696 args.add(this.visitValue(arg.get$value())); |
| 1697 } |
| 1698 return new Arguments(arguments, args); |
| 1699 } |
| 1700 MethodAnalyzer.prototype._makeLambdaMethod = function(name, func) { |
| 1701 var meth = new MethodMember(name, this.method.declaringType, func); |
| 1702 meth.set$isLambda(true); |
| 1703 meth.set$enclosingElement(this.method); |
| 1704 meth.set$_methodData(new MethodData(meth, this._frame)); |
| 1705 meth.resolve(); |
| 1706 return meth; |
| 1707 } |
| 1708 MethodAnalyzer.prototype._pushBlock = function(node) { |
| 1709 this._frame.pushBlock(node); |
| 1710 } |
| 1711 MethodAnalyzer.prototype._popBlock = function(node) { |
| 1712 this._frame.popBlock(node); |
| 1713 } |
| 1714 MethodAnalyzer.prototype._resolveBare = function(name, node) { |
| 1715 var type = this._frame.method.declaringType; |
| 1716 var member = type.getMember(name); |
| 1717 if ($eq(member) || $ne(member.get$declaringType(), type)) { |
| 1718 var libMember = this._frame.get$library().lookup(name, node.span); |
| 1719 if (libMember != null) return libMember; |
| 1720 } |
| 1721 if (member != null && !member.get$isStatic() && this._frame.get$isStatic()) { |
| 1722 $globals.world.error("can not refer to instance member from static method",
node.span); |
| 1723 } |
| 1724 return member; |
| 1725 } |
| 1726 MethodAnalyzer.prototype.visitDietStatement = function(node) { |
| 1727 var parser = new Parser(node.span.file, false, false, false, node.span.start); |
| 1728 parser.block().visit(this); |
| 1729 } |
| 1730 MethodAnalyzer.prototype.visitVariableDefinition = function(node) { |
| 1731 var isFinal = false; |
| 1732 if (node.modifiers != null && node.modifiers[(0)].kind == (99)) { |
| 1733 isFinal = true; |
| 1734 } |
| 1735 var type = this.resolveType(node.type, false, true); |
| 1736 for (var i = (0); |
| 1737 i < node.names.get$length(); i++) { |
| 1738 var name = node.names[i].name; |
| 1739 var value = this.visitValue(node.values[i]); |
| 1740 this._frame.create(name, type, node.names[i], isFinal, value); |
| 1741 } |
| 1742 } |
| 1743 MethodAnalyzer.prototype.visitFunctionDefinition = function(node) { |
| 1744 var meth = this._makeLambdaMethod(node.name.name, node); |
| 1745 var funcValue = this._frame.create(meth.get$name(), meth.get$functionType(), t
his.method.definition, true, null); |
| 1746 meth.get$methodData().analyze(); |
| 1747 } |
| 1748 MethodAnalyzer.prototype.visitReturnStatement = function(node) { |
| 1749 if (node.value == null) { |
| 1750 this._frame.returns(Value.fromNull(node.span)); |
| 1751 } |
| 1752 else { |
| 1753 this._frame.returns(this.visitValue(node.value)); |
| 1754 } |
| 1755 } |
| 1756 MethodAnalyzer.prototype.visitThrowStatement = function(node) { |
| 1757 if (node.value != null) { |
| 1758 var value = this.visitValue(node.value); |
| 1759 } |
| 1760 else { |
| 1761 } |
| 1762 } |
| 1763 MethodAnalyzer.prototype.visitAssertStatement = function(node) { |
| 1764 var test = this.visitValue(node.test); |
| 1765 } |
| 1766 MethodAnalyzer.prototype.visitBreakStatement = function(node) { |
| 1767 |
| 1768 } |
| 1769 MethodAnalyzer.prototype.visitContinueStatement = function(node) { |
| 1770 |
| 1771 } |
| 1772 MethodAnalyzer.prototype.visitIfStatement = function(node) { |
| 1773 var test = this.visitBool(node.test); |
| 1774 node.trueBranch.visit(this); |
| 1775 if (node.falseBranch != null) { |
| 1776 node.falseBranch.visit(this); |
| 1777 } |
| 1778 } |
| 1779 MethodAnalyzer.prototype.visitWhileStatement = function(node) { |
| 1780 var test = this.visitBool(node.test); |
| 1781 node.body.visit(this); |
| 1782 } |
| 1783 MethodAnalyzer.prototype.visitDoStatement = function(node) { |
| 1784 node.body.visit(this); |
| 1785 var test = this.visitBool(node.test); |
| 1786 } |
| 1787 MethodAnalyzer.prototype.visitForStatement = function(node) { |
| 1788 this._pushBlock(node); |
| 1789 if (node.init != null) node.init.visit(this); |
| 1790 if (node.test != null) { |
| 1791 var test = this.visitBool(node.test); |
| 1792 } |
| 1793 var $$list = node.step; |
| 1794 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 1795 var s = $$i.next(); |
| 1796 var sv = this.visitVoid(s); |
| 1797 } |
| 1798 this._pushBlock(node.body); |
| 1799 node.body.visit(this); |
| 1800 this._popBlock(node.body); |
| 1801 this._popBlock(node); |
| 1802 } |
| 1803 MethodAnalyzer.prototype.visitForInStatement = function(node) { |
| 1804 var itemType = this.resolveType(node.item.type, false, true); |
| 1805 var list = node.list.visit(this); |
| 1806 this._visitForInBody(node, itemType, list); |
| 1807 } |
| 1808 MethodAnalyzer.prototype._isFinal = function(typeRef) { |
| 1809 if ((typeRef instanceof GenericTypeReference)) { |
| 1810 typeRef = typeRef.get$baseType(); |
| 1811 } |
| 1812 else if ((typeRef instanceof SimpleTypeReference)) { |
| 1813 return false; |
| 1814 } |
| 1815 return $ne(typeRef) && typeRef.get$isFinal(); |
| 1816 } |
| 1817 MethodAnalyzer.prototype._visitForInBody = function(node, itemType, list) { |
| 1818 this._pushBlock(node); |
| 1819 var isFinal = this._isFinal(node.item.type); |
| 1820 var itemName = node.item.name.name; |
| 1821 var item = this._frame.create(itemName, itemType, node.item.name, isFinal, nul
l); |
| 1822 var iterator = list.invoke(this._frame, "iterator", node.list, Arguments.get$E
MPTY()); |
| 1823 node.body.visit(this); |
| 1824 this._popBlock(node); |
| 1825 } |
| 1826 MethodAnalyzer.prototype._createDI = function(di) { |
| 1827 this._frame.create(di.name.name, this.resolveType(di.type, false, true), di.na
me, true, null); |
| 1828 } |
| 1829 MethodAnalyzer.prototype.visitTryStatement = function(node) { |
| 1830 this._pushBlock(node.body); |
| 1831 node.body.visit(this); |
| 1832 this._popBlock(node.body); |
| 1833 if (node.catches.get$length() > (0)) { |
| 1834 for (var i = (0); |
| 1835 i < node.catches.get$length(); i++) { |
| 1836 var catch_ = node.catches[i]; |
| 1837 this._pushBlock(catch_); |
| 1838 this._createDI(catch_.get$exception()); |
| 1839 if (catch_.get$trace() != null) { |
| 1840 this._createDI(catch_.get$trace()); |
| 1841 } |
| 1842 catch_.get$body().visit(this); |
| 1843 this._popBlock(catch_); |
| 1844 } |
| 1845 } |
| 1846 if (node.finallyBlock != null) { |
| 1847 node.finallyBlock.visit(this); |
| 1848 } |
| 1849 } |
| 1850 MethodAnalyzer.prototype.visitSwitchStatement = function(node) { |
| 1851 var test = this.visitValue(node.test); |
| 1852 var $$list = node.cases; |
| 1853 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 1854 var case_ = $$i.next(); |
| 1855 this._pushBlock(case_); |
| 1856 for (var i = (0); |
| 1857 i < case_.get$cases().get$length(); i++) { |
| 1858 var expr = case_.get$cases().$index(i); |
| 1859 if ($eq(expr)) { |
| 1860 } |
| 1861 else { |
| 1862 var value = this.visitValue(expr); |
| 1863 } |
| 1864 } |
| 1865 this._visitAllStatements(case_.get$statements()); |
| 1866 this._popBlock(case_); |
| 1867 } |
| 1868 } |
| 1869 MethodAnalyzer.prototype._visitAllStatements = function(statementList) { |
| 1870 for (var i = (0); |
| 1871 i < statementList.get$length(); i++) { |
| 1872 var stmt = statementList.$index(i); |
| 1873 stmt.visit(this); |
| 1874 } |
| 1875 } |
| 1876 MethodAnalyzer.prototype.visitBlockStatement = function(node) { |
| 1877 this._pushBlock(node); |
| 1878 this._visitAllStatements(node.body); |
| 1879 this._popBlock(node); |
| 1880 } |
| 1881 MethodAnalyzer.prototype.visitLabeledStatement = function(node) { |
| 1882 node.body.visit(this); |
| 1883 } |
| 1884 MethodAnalyzer.prototype.visitExpressionStatement = function(node) { |
| 1885 var value = this.visitVoid(node.body); |
| 1886 } |
| 1887 MethodAnalyzer.prototype.visitEmptyStatement = function(node) { |
| 1888 |
| 1889 } |
| 1890 MethodAnalyzer.prototype.visitLambdaExpression = function(node) { |
| 1891 var name = (node.func.name != null) ? node.func.name.name : ""; |
| 1892 var meth = this._makeLambdaMethod(name, node.func); |
| 1893 meth.get$methodData().analyze(); |
| 1894 return this._frame._makeValue($globals.world.functionType, node); |
| 1895 } |
| 1896 MethodAnalyzer.prototype.visitCallExpression = function(node) { |
| 1897 var target; |
| 1898 var position = node.target; |
| 1899 var name = ":call"; |
| 1900 if ((node.target instanceof DotExpression)) { |
| 1901 var dot = node.target; |
| 1902 target = dot.self.visit(this); |
| 1903 name = dot.name.name; |
| 1904 position = dot.name; |
| 1905 } |
| 1906 else if ((node.target instanceof VarExpression)) { |
| 1907 var varExpr = node.target; |
| 1908 name = varExpr.name.name; |
| 1909 target = this._frame.lookup(name); |
| 1910 if ($ne(target)) { |
| 1911 return target.get().invoke(this._frame, ":call", node, this._visitArgs(nod
e.arguments)); |
| 1912 } |
| 1913 var member = this._resolveBare(name, varExpr.name); |
| 1914 if (member != null) { |
| 1915 return member.invoke(this._frame, node, this._frame.makeThisValue(node), t
his._visitArgs(node.arguments)); |
| 1916 } |
| 1917 else { |
| 1918 $globals.world.warning(("can not find \"" + name + "\""), node.span); |
| 1919 return this._frame._makeValue($globals.world.varType, node); |
| 1920 } |
| 1921 } |
| 1922 else { |
| 1923 target = node.target.visit(this); |
| 1924 } |
| 1925 return target.invoke(this._frame, name, position, this._visitArgs(node.argumen
ts)); |
| 1926 } |
| 1927 MethodAnalyzer.prototype.visitIndexExpression = function(node) { |
| 1928 var target = this.visitValue(node.target); |
| 1929 var index = this.visitValue(node.index); |
| 1930 return target.invoke(this._frame, ":index", node, new Arguments(null, [index])
); |
| 1931 } |
| 1932 MethodAnalyzer.prototype.visitBinaryExpression = function(node, isVoid) { |
| 1933 var kind = node.op.kind; |
| 1934 if ($eq(kind, (35)) || $eq(kind, (34))) { |
| 1935 var xb = this.visitBool(node.x); |
| 1936 var yb = this.visitBool(node.y); |
| 1937 return xb.binop(kind, yb, this._frame, node); |
| 1938 } |
| 1939 var assignKind = TokenKind.kindFromAssign(node.op.kind); |
| 1940 if ($eq(assignKind, (-1))) { |
| 1941 var x = this.visitValue(node.x); |
| 1942 var y = this.visitValue(node.y); |
| 1943 return x.binop(kind, y, this._frame, node); |
| 1944 } |
| 1945 else { |
| 1946 return this._visitAssign(assignKind, node.x, node.y, node); |
| 1947 } |
| 1948 } |
| 1949 MethodAnalyzer.prototype._visitAssign = function(kind, xn, yn, position) { |
| 1950 if ((xn instanceof VarExpression)) { |
| 1951 return this._visitVarAssign(kind, xn, yn, position); |
| 1952 } |
| 1953 else if ((xn instanceof IndexExpression)) { |
| 1954 return this._visitIndexAssign(kind, xn, yn, position); |
| 1955 } |
| 1956 else if ((xn instanceof DotExpression)) { |
| 1957 return this._visitDotAssign(kind, xn, yn, position); |
| 1958 } |
| 1959 else { |
| 1960 $globals.world.error("illegal lhs", xn.span); |
| 1961 } |
| 1962 } |
| 1963 MethodAnalyzer.prototype._visitVarAssign = function(kind, xn, yn, node) { |
| 1964 var value = this.visitValue(yn); |
| 1965 var name = xn.name.name; |
| 1966 var slot = this._frame.lookup(name); |
| 1967 if ($ne(slot)) { |
| 1968 slot.set(value); |
| 1969 } |
| 1970 else { |
| 1971 var member = this._resolveBare(name, xn.name); |
| 1972 if (member != null) { |
| 1973 member._set(this._frame, node, this._frame.makeThisValue(node), value); |
| 1974 } |
| 1975 else { |
| 1976 $globals.world.warning(("can not find \"" + name + "\""), node.span); |
| 1977 } |
| 1978 } |
| 1979 return this._frame._makeValue(value.get$type(), node); |
| 1980 } |
| 1981 MethodAnalyzer.prototype._visitIndexAssign = function(kind, xn, yn, position) { |
| 1982 var target = this.visitValue(xn.target); |
| 1983 var index = this.visitValue(xn.index); |
| 1984 var y = this.visitValue(yn); |
| 1985 return target.setIndex$4$kind(this._frame, index, position, y, kind); |
| 1986 } |
| 1987 MethodAnalyzer.prototype._visitDotAssign = function(kind, xn, yn, position) { |
| 1988 var target = xn.self.visit(this); |
| 1989 var y = this.visitValue(yn); |
| 1990 return target.set_$4$kind(this._frame, xn.name.name, xn.name, y, kind); |
| 1991 } |
| 1992 MethodAnalyzer.prototype.visitUnaryExpression = function(node) { |
| 1993 var value = this.visitValue(node.self); |
| 1994 switch (node.op.kind) { |
| 1995 case (16): |
| 1996 case (17): |
| 1997 |
| 1998 return value.binop((42), this._frame._makeValue($globals.world.intType, no
de), this._frame, node); |
| 1999 |
| 2000 } |
| 2001 return value.unop(node.op.kind, this._frame, node); |
| 2002 } |
| 2003 MethodAnalyzer.prototype.visitDeclaredIdentifier = function(node) { |
| 2004 $globals.world.error("Expected expression", node.span); |
| 2005 } |
| 2006 MethodAnalyzer.prototype.visitAwaitExpression = function(node) { |
| 2007 $globals.world.internalError("Await expressions should have been eliminated be
fore code generation", node.span); |
| 2008 } |
| 2009 MethodAnalyzer.prototype.visitPostfixExpression = function(node, isVoid) { |
| 2010 var value = this.visitValue(node.body); |
| 2011 return this._frame._makeValue(value.get$type(), node); |
| 2012 } |
| 2013 MethodAnalyzer.prototype.visitNewExpression = function(node) { |
| 2014 var typeRef = node.type; |
| 2015 var constructorName = ""; |
| 2016 if (node.name != null) { |
| 2017 constructorName = node.name.name; |
| 2018 } |
| 2019 if ($eq(constructorName, "") && (typeRef instanceof NameTypeReference) && type
Ref.get$names() != null) { |
| 2020 var names = ListFactory.ListFactory$from$factory(typeRef.get$names()); |
| 2021 constructorName = names.removeLast().get$name(); |
| 2022 if (names.get$length() == (0)) names = null; |
| 2023 typeRef = new NameTypeReference(typeRef.get$isFinal(), typeRef.get$name(), n
ames, typeRef.get$span()); |
| 2024 } |
| 2025 var type = this.resolveType(typeRef, true, true); |
| 2026 if (type.get$isTop()) { |
| 2027 type = type.get$library().findTypeByName(constructorName); |
| 2028 constructorName = ""; |
| 2029 } |
| 2030 if ((type instanceof ParameterType)) { |
| 2031 $globals.world.error("cannot instantiate a type parameter", node.span); |
| 2032 return this._frame._makeValue($globals.world.varType, node); |
| 2033 } |
| 2034 var m = type.getConstructor(constructorName); |
| 2035 if ($eq(m)) { |
| 2036 var name = type.get$jsname(); |
| 2037 if (type.get$isVar()) { |
| 2038 name = typeRef.get$name().get$name(); |
| 2039 } |
| 2040 $globals.world.warning(("no matching constructor for " + name), node.span); |
| 2041 return this._frame._makeValue(type, node); |
| 2042 } |
| 2043 if (node.isConst) { |
| 2044 if (!m.get$isConst()) { |
| 2045 $globals.world.error("can't use const on a non-const constructor", node.sp
an); |
| 2046 } |
| 2047 var $$list = node.arguments; |
| 2048 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 2049 var arg = $$i.next(); |
| 2050 if (!this.visitValue(arg.get$value()).get$isConst()) { |
| 2051 $globals.world.error("const constructor expects const arguments", arg.ge
t$span()); |
| 2052 } |
| 2053 } |
| 2054 } |
| 2055 var args = this._visitArgs(node.arguments); |
| 2056 var target = new TypeValue(type, typeRef.get$span()); |
| 2057 return new PureStaticValue(type, node.span, node.isConst, false); |
| 2058 } |
| 2059 MethodAnalyzer.prototype.visitListExpression = function(node) { |
| 2060 var argValues = []; |
| 2061 var listType = $globals.world.listType; |
| 2062 var type = $globals.world.varType; |
| 2063 if (node.itemType != null) { |
| 2064 type = this.resolveType(node.itemType, true, !node.isConst); |
| 2065 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara
ms())) { |
| 2066 $globals.world.error("type parameter cannot be used in const list literals
"); |
| 2067 } |
| 2068 listType = listType.getOrMakeConcreteType([type]); |
| 2069 } |
| 2070 var $$list = node.values; |
| 2071 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 2072 var item = $$i.next(); |
| 2073 var arg = this.visitTypedValue(item, type); |
| 2074 argValues.add(arg); |
| 2075 } |
| 2076 $globals.world.listFactoryType.markUsed(); |
| 2077 return new PureStaticValue(listType, node.span, node.isConst, false); |
| 2078 } |
| 2079 MethodAnalyzer.prototype.visitMapExpression = function(node) { |
| 2080 var values = []; |
| 2081 var valueType = $globals.world.varType, keyType = $globals.world.stringType; |
| 2082 var mapType = $globals.world.mapType; |
| 2083 if (node.valueType != null) { |
| 2084 if (node.keyType != null) { |
| 2085 keyType = this.method.resolveType(node.keyType, true, !node.isConst); |
| 2086 if (!keyType.get$isString()) { |
| 2087 $globals.world.error("the key type of a map literal must be \"String\"",
keyType.get$span()); |
| 2088 } |
| 2089 if (node.isConst && ((keyType instanceof ParameterType) || keyType.get$has
TypeParams())) { |
| 2090 $globals.world.error("type parameter cannot be used in const map literal
s"); |
| 2091 } |
| 2092 } |
| 2093 valueType = this.resolveType(node.valueType, true, !node.isConst); |
| 2094 if (node.isConst && ((valueType instanceof ParameterType) || valueType.get$h
asTypeParams())) { |
| 2095 $globals.world.error("type parameter cannot be used in const map literals"
); |
| 2096 } |
| 2097 mapType = mapType.getOrMakeConcreteType([keyType, valueType]); |
| 2098 } |
| 2099 for (var i = (0); |
| 2100 i < node.items.get$length(); i += (2)) { |
| 2101 var key = this.visitTypedValue(node.items[i], keyType); |
| 2102 values.add(key); |
| 2103 var value = this.visitTypedValue(node.items[i + (1)], valueType); |
| 2104 if (node.isConst && !value.get$isConst()) { |
| 2105 $globals.world.error("const map can only contain const values", value.get$
span()); |
| 2106 } |
| 2107 values.add(value); |
| 2108 } |
| 2109 return new PureStaticValue(mapType, node.span, node.isConst, false); |
| 2110 } |
| 2111 MethodAnalyzer.prototype.visitConditionalExpression = function(node) { |
| 2112 var test = this.visitBool(node.test); |
| 2113 var trueBranch = this.visitValue(node.trueBranch); |
| 2114 var falseBranch = this.visitValue(node.falseBranch); |
| 2115 return this._frame._makeValue(Type.union(trueBranch.get$type(), falseBranch.ge
t$type()), node); |
| 2116 } |
| 2117 MethodAnalyzer.prototype.visitIsExpression = function(node) { |
| 2118 var value = this.visitValue(node.x); |
| 2119 var type = this.resolveType(node.type, false, true); |
| 2120 return this._frame._makeValue($globals.world.boolType, node); |
| 2121 } |
| 2122 MethodAnalyzer.prototype.visitParenExpression = function(node) { |
| 2123 return this.visitValue(node.body); |
| 2124 } |
| 2125 MethodAnalyzer.prototype.visitDotExpression = function(node) { |
| 2126 var target = node.self.visit(this); |
| 2127 return target.get_(this._frame, node.name.name, node); |
| 2128 } |
| 2129 MethodAnalyzer.prototype.visitVarExpression = function(node) { |
| 2130 var name = node.name.name; |
| 2131 var slot = this._frame.lookup(name); |
| 2132 if ($ne(slot)) { |
| 2133 return slot.get(); |
| 2134 } |
| 2135 var member = this._resolveBare(name, node.name); |
| 2136 if (member != null) { |
| 2137 if ((member instanceof TypeMember)) { |
| 2138 return new PureStaticValue(member.get$dynamic().get$type(), node.span, tru
e, true); |
| 2139 } |
| 2140 else { |
| 2141 return member._get(this._frame, node, this._frame.makeThisValue(node)); |
| 2142 } |
| 2143 } |
| 2144 else { |
| 2145 $globals.world.warning(("can not find \"" + name + "\""), node.span); |
| 2146 return this._frame._makeValue($globals.world.varType, node); |
| 2147 } |
| 2148 } |
| 2149 MethodAnalyzer.prototype.visitThisExpression = function(node) { |
| 2150 return this._frame.makeThisValue(node); |
| 2151 } |
| 2152 MethodAnalyzer.prototype.visitSuperExpression = function(node) { |
| 2153 return this._frame.makeSuperValue(node); |
| 2154 } |
| 2155 MethodAnalyzer.prototype.visitLiteralExpression = function(node) { |
| 2156 return new PureStaticValue(node.value.get$type(), node.span, true, false); |
| 2157 } |
| 2158 MethodAnalyzer.prototype.visitStringInterpExpression = function(node) { |
| 2159 return this._frame._makeValue($globals.world.stringType, node); |
| 2160 } |
| 2161 MethodAnalyzer.prototype._pushBlock$1 = MethodAnalyzer.prototype._pushBlock; |
| 2162 MethodAnalyzer.prototype.analyze$1 = MethodAnalyzer.prototype.analyze; |
| 2163 MethodAnalyzer.prototype.visitBinaryExpression$1 = function($0) { |
| 2164 return this.visitBinaryExpression($0, false); |
| 2165 }; |
| 2166 MethodAnalyzer.prototype.visitPostfixExpression$1 = function($0) { |
| 2167 return this.visitPostfixExpression($0, false); |
| 2168 }; |
| 2169 // ********** Code for CallFrame ************** |
| 2170 function CallFrame(analyzer, method, thisValue, args, enclosingFrame) { |
| 2171 this.args = args; |
| 2172 this.analyzer = analyzer; |
| 2173 this.enclosingFrame = enclosingFrame; |
| 2174 this.method = method; |
| 2175 this.thisValue = thisValue; |
| 2176 this._slots = []; |
| 2177 this._scope = new AnalyzeScope(null, this, this.analyzer.body); |
| 2178 this._returnSlot = new VariableSlot(this._scope, "return", this.method.returnT
ype, this.analyzer.body, false); |
| 2179 } |
| 2180 CallFrame.prototype.findMembers = function(name) { |
| 2181 return this.get$library()._findMembers(name); |
| 2182 } |
| 2183 CallFrame.prototype.get$counters = function() { |
| 2184 return $globals.world.counters; |
| 2185 } |
| 2186 CallFrame.prototype.get$library = function() { |
| 2187 return this.method.get$library(); |
| 2188 } |
| 2189 CallFrame.prototype.get$method = function() { return this.method; }; |
| 2190 CallFrame.prototype.set$method = function(value) { return this.method = value; }
; |
| 2191 CallFrame.prototype.get$needsCode = function() { |
| 2192 return false; |
| 2193 } |
| 2194 CallFrame.prototype.get$showWarnings = function() { |
| 2195 return true; |
| 2196 } |
| 2197 CallFrame.prototype._makeThisCode = function() { |
| 2198 return null; |
| 2199 } |
| 2200 CallFrame.prototype.getTemp = function(value) { |
| 2201 return null; |
| 2202 } |
| 2203 CallFrame.prototype.forceTemp = function(value) { |
| 2204 return null; |
| 2205 } |
| 2206 CallFrame.prototype.assignTemp = function(tmp, v) { |
| 2207 return null; |
| 2208 } |
| 2209 CallFrame.prototype.freeTemp = function(value) { |
| 2210 return null; |
| 2211 } |
| 2212 CallFrame.prototype.get$isStatic = function() { |
| 2213 return this.enclosingFrame != null ? this.enclosingFrame.get$isStatic() : this
.method.isStatic; |
| 2214 } |
| 2215 CallFrame.prototype.get$_slots = function() { return this._slots; }; |
| 2216 CallFrame.prototype.set$_slots = function(value) { return this._slots = value; }
; |
| 2217 CallFrame.prototype.get$_scope = function() { return this._scope; }; |
| 2218 CallFrame.prototype.set$_scope = function(value) { return this._scope = value; }
; |
| 2219 CallFrame.prototype.pushBlock = function(node) { |
| 2220 this._scope = new AnalyzeScope(this._scope, this, node); |
| 2221 } |
| 2222 CallFrame.prototype.popBlock = function(node) { |
| 2223 if ($ne(this._scope.node, node)) { |
| 2224 $globals.world.internalError("incorrect pop", node.span, this._scope.node.sp
an); |
| 2225 } |
| 2226 this._scope = this._scope.parent; |
| 2227 } |
| 2228 CallFrame.prototype.returns = function(value) { |
| 2229 this._returnSlot.set(value); |
| 2230 } |
| 2231 CallFrame.prototype.lookup = function(name) { |
| 2232 var slot = this._scope._lookup(name); |
| 2233 if ($eq(slot) && this.enclosingFrame != null) { |
| 2234 return this.enclosingFrame.lookup(name); |
| 2235 } |
| 2236 return slot; |
| 2237 } |
| 2238 CallFrame.prototype.create = function(name, staticType, node, isFinal, value) { |
| 2239 var slot = new VariableSlot(this._scope, name, staticType, node, isFinal, valu
e); |
| 2240 var existingSlot = this._scope._lookup(name); |
| 2241 if (existingSlot != null) { |
| 2242 if ($eq(existingSlot.get$scope(), this)) { |
| 2243 $globals.world.error(("duplicate name \"" + name + "\""), node.span); |
| 2244 } |
| 2245 else { |
| 2246 } |
| 2247 } |
| 2248 this._slots.add(slot); |
| 2249 this._scope._slots.add(slot); |
| 2250 } |
| 2251 CallFrame.prototype.declareParameter = function(p, value) { |
| 2252 return this.create(p.name, p.type, p.definition, false, value); |
| 2253 } |
| 2254 CallFrame.prototype._makeValue = function(type, node) { |
| 2255 return new PureStaticValue(type, node == null ? null : node.span, false, false
); |
| 2256 } |
| 2257 CallFrame.prototype.makeSuperValue = function(node) { |
| 2258 return this._makeValue(this.thisValue.get$type().get$parent(), node); |
| 2259 } |
| 2260 CallFrame.prototype.makeThisValue = function(node) { |
| 2261 return this._makeValue(this.thisValue.get$type(), node); |
| 2262 } |
| 2263 // ********** Code for VariableSlot ************** |
| 2264 function VariableSlot(scope, name, staticType, node, isFinal, value) { |
| 2265 this.value = value; |
| 2266 this.name = name; |
| 2267 this.scope = scope; |
| 2268 this.node = node; |
| 2269 this.staticType = staticType; |
| 2270 this.isFinal = isFinal; |
| 2271 } |
| 2272 VariableSlot.prototype.get$scope = function() { return this.scope; }; |
| 2273 VariableSlot.prototype.set$scope = function(value) { return this.scope = value;
}; |
| 2274 VariableSlot.prototype.get$name = function() { return this.name; }; |
| 2275 VariableSlot.prototype.get$staticType = function() { return this.staticType; }; |
| 2276 VariableSlot.prototype.set$staticType = function(value) { return this.staticType
= value; }; |
| 2277 VariableSlot.prototype.get$isFinal = function() { return this.isFinal; }; |
| 2278 VariableSlot.prototype.set$isFinal = function(value) { return this.isFinal = val
ue; }; |
| 2279 VariableSlot.prototype.get$value = function() { return this.value; }; |
| 2280 VariableSlot.prototype.set$value = function(value) { return this.value = value;
}; |
| 2281 VariableSlot.prototype.get = function() { |
| 2282 return this.scope.frame._makeValue(this.staticType, null); |
| 2283 } |
| 2284 VariableSlot.prototype.set = function(newValue) { |
| 2285 if (this.value == null) this.value = newValue; |
| 2286 else this.value = Value.union(this.value, newValue); |
| 2287 } |
| 2288 VariableSlot.prototype.toString = function() { |
| 2289 var valueString = this.value != null ? (" = " + this.value.get$type().name) :
""; |
| 2290 return ("" + this.staticType.name + " " + this.name + valueString); |
| 2291 } |
| 2292 VariableSlot.prototype.toString$0 = VariableSlot.prototype.toString; |
| 2293 // ********** Code for AnalyzeScope ************** |
| 2294 function AnalyzeScope(parent, frame, node) { |
| 2295 this.frame = frame; |
| 2296 this.parent = parent; |
| 2297 this.node = node; |
| 2298 this._slots = []; |
| 2299 } |
| 2300 AnalyzeScope.prototype.get$parent = function() { return this.parent; }; |
| 2301 AnalyzeScope.prototype.set$parent = function(value) { return this.parent = value
; }; |
| 2302 AnalyzeScope.prototype.get$_slots = function() { return this._slots; }; |
| 2303 AnalyzeScope.prototype.set$_slots = function(value) { return this._slots = value
; }; |
| 2304 AnalyzeScope.prototype._lookup = function(name) { |
| 2305 for (var s = this; |
| 2306 $ne(s); s = s.get$parent()) { |
| 2307 for (var i = (0); |
| 2308 i < s.get$_slots().get$length(); i++) { |
| 2309 var ret = s.get$_slots()[i]; |
| 2310 if ($eq(ret.get$name(), name)) return ret; |
| 2311 } |
| 2312 } |
| 2313 return null; |
| 2314 } |
2381 // ********** Code for BlockScope ************** | 2315 // ********** Code for BlockScope ************** |
2382 function BlockScope(enclosingMethod, parent, node, reentrant) { | 2316 function BlockScope(enclosingMethod, parent, node, reentrant) { |
2383 this.enclosingMethod = enclosingMethod; | 2317 this.enclosingMethod = enclosingMethod; |
2384 this._vars = new CopyOnWriteMap_dart_core_String$VariableValue(); | 2318 this._vars = new CopyOnWriteMap_dart_core_String$VariableValue(); |
2385 this.parent = parent; | 2319 this.parent = parent; |
2386 this.node = node; | 2320 this.node = node; |
2387 this.reentrant = reentrant; | 2321 this.reentrant = reentrant; |
2388 this._jsNames = new HashSetImplementation(); | 2322 this._jsNames = new HashSetImplementation_dart_core_String(); |
2389 if (this.get$isMethodScope()) { | 2323 if (this.get$isMethodScope()) { |
2390 this._closedOver = new HashSetImplementation(); | 2324 this._closedOver = new HashSetImplementation_dart_core_String(); |
2391 } | 2325 } |
2392 else { | 2326 else { |
2393 this.reentrant = reentrant || this.parent.reentrant; | 2327 this.reentrant = reentrant || this.parent.reentrant; |
2394 } | 2328 } |
2395 this.inferTypes = $globals.options.inferTypes && (this.parent == null || this.
parent.inferTypes); | 2329 this.inferTypes = $globals.options.inferTypes && (this.parent == null || this.
parent.inferTypes); |
2396 } | 2330 } |
2397 BlockScope._snapshot$ctor = function(original) { | 2331 BlockScope._snapshot$ctor = function(original) { |
2398 this.enclosingMethod = original.enclosingMethod; | 2332 this.enclosingMethod = original.enclosingMethod; |
2399 this._vars = original._vars.clone(); | 2333 this._vars = original._vars.clone(); |
2400 this.parent = original.parent == null ? null : original.parent.snapshot(); | 2334 this.parent = original.parent == null ? null : original.parent.snapshot(); |
(...skipping 19 matching lines...) Expand all Loading... |
2420 BlockScope.prototype.get$isMethodScope = function() { | 2354 BlockScope.prototype.get$isMethodScope = function() { |
2421 return this.parent == null || $ne(this.parent.enclosingMethod, this.enclosingM
ethod); | 2355 return this.parent == null || $ne(this.parent.enclosingMethod, this.enclosingM
ethod); |
2422 } | 2356 } |
2423 BlockScope.prototype.get$methodScope = function() { | 2357 BlockScope.prototype.get$methodScope = function() { |
2424 var s = this; | 2358 var s = this; |
2425 while (!s.get$isMethodScope()) s = s.get$parent(); | 2359 while (!s.get$isMethodScope()) s = s.get$parent(); |
2426 return s; | 2360 return s; |
2427 } | 2361 } |
2428 BlockScope.prototype.lookup = function(name) { | 2362 BlockScope.prototype.lookup = function(name) { |
2429 for (var s = this; | 2363 for (var s = this; |
2430 s != null; s = s.get$parent()) { | 2364 $ne(s); s = s.get$parent()) { |
2431 var ret = s.get$_vars().$index(name); | 2365 var ret = s.get$_vars().$index(name); |
2432 if (ret != null) return this._capture(s, ret); | 2366 if (ret != null) return this._capture(s, ret); |
2433 } | 2367 } |
2434 return null; | 2368 return null; |
2435 } | 2369 } |
2436 BlockScope.prototype.inferAssign = function(name, value) { | 2370 BlockScope.prototype.inferAssign = function(name, value) { |
2437 if (this.inferTypes) this.assign(name, value); | 2371 if (this.inferTypes) this.assign(name, value); |
2438 } | 2372 } |
2439 BlockScope.prototype.assign = function(name, value) { | 2373 BlockScope.prototype.assign = function(name, value) { |
2440 for (var s = this; | 2374 for (var s = this; |
2441 s != null; s = s.get$parent()) { | 2375 $ne(s); s = s.get$parent()) { |
2442 var existing = s.get$_vars().$index(name); | 2376 var existing = s.get$_vars().$index(name); |
2443 if (existing != null) { | 2377 if ($ne(existing)) { |
2444 s.get$_vars().$setindex(name, existing.replaceValue$1(value)); | 2378 s.get$_vars().$setindex(name, existing.replaceValue(value)); |
2445 return; | 2379 return; |
2446 } | 2380 } |
2447 } | 2381 } |
2448 $globals.world.internalError(("assigning variable '" + name + "' that doesn't
exist.")); | 2382 $globals.world.internalError(("assigning variable '" + name + "' that doesn't
exist.")); |
2449 } | 2383 } |
2450 BlockScope.prototype._capture = function(other, value) { | 2384 BlockScope.prototype._capture = function(other, value) { |
2451 if ($ne(other.enclosingMethod, this.enclosingMethod)) { | 2385 if ($ne(other.enclosingMethod, this.enclosingMethod)) { |
2452 other.get$methodScope()._closedOver.add(value.get$code()); | 2386 other.get$methodScope()._closedOver.add(value.get$code()); |
2453 if (this.enclosingMethod.captures != null && other.reentrant) { | 2387 if (this.enclosingMethod.captures != null && other.reentrant) { |
2454 this.enclosingMethod.captures.add(value.get$code()); | 2388 this.enclosingMethod.captures.add(value.get$code()); |
2455 } | 2389 } |
2456 } | 2390 } |
2457 return value; | 2391 return value; |
2458 } | 2392 } |
2459 BlockScope.prototype._isDefinedInParent = function(name) { | 2393 BlockScope.prototype._isDefinedInParent = function(name) { |
2460 if (this.get$isMethodScope() && this._closedOver.contains(name)) return true; | 2394 if (this.get$isMethodScope() && this._closedOver.contains(name)) return true; |
2461 for (var s = this.parent; | 2395 for (var s = this.parent; |
2462 s != null; s = s.get$parent()) { | 2396 $ne(s); s = s.get$parent()) { |
2463 if (s.get$_vars().containsKey$1(name)) return true; | 2397 if (s.get$_vars().containsKey(name)) return true; |
2464 if (s.get$_jsNames().contains$1(name)) return true; | 2398 if (s.get$_jsNames().contains(name)) return true; |
2465 if (s.get$isMethodScope() && s.get$_closedOver().contains$1(name)) return tr
ue; | 2399 if (s.get$isMethodScope() && s.get$_closedOver().contains(name)) return true
; |
2466 } | 2400 } |
2467 var type = this.enclosingMethod.method.declaringType; | 2401 var type = this.enclosingMethod.method.declaringType; |
2468 if (type.get$library().lookup$2(name) != null) return true; | 2402 if (type.get$library().lookup(name, null) != null) return true; |
2469 return false; | 2403 return false; |
2470 } | 2404 } |
2471 BlockScope.prototype.create = function(name, type, span, isFinal, isParameter) { | 2405 BlockScope.prototype.create = function(name, type, span, isFinal, isParameter) { |
2472 var jsName = $globals.world.toJsIdentifier(name); | 2406 var jsName = $globals.world.toJsIdentifier(name); |
2473 if (this._vars.containsKey(name)) { | 2407 if (this._vars.containsKey(name)) { |
2474 $globals.world.error(("duplicate name \"" + name + "\""), span); | 2408 $globals.world.error(("duplicate name \"" + name + "\""), span); |
2475 } | 2409 } |
2476 if (!isParameter) { | 2410 if (!isParameter) { |
2477 var index = (0); | 2411 var index = (0); |
2478 while (this._isDefinedInParent(jsName)) { | 2412 while (this._isDefinedInParent(jsName)) { |
2479 jsName = ("" + name + (index++)); | 2413 jsName = ("" + name + (index++)); |
2480 } | 2414 } |
2481 } | 2415 } |
2482 var ret = new VariableValue(type, jsName, span, isFinal); | 2416 var ret = new VariableValue(type, jsName, span, isFinal); |
2483 this._vars.$setindex(name, ret); | 2417 this._vars.$setindex(name, ret); |
2484 if (name != jsName) this._jsNames.add(jsName); | 2418 if (name != jsName) this._jsNames.add(jsName); |
2485 return ret; | 2419 return ret; |
2486 } | 2420 } |
2487 BlockScope.prototype.declareParameter = function(p) { | 2421 BlockScope.prototype.declareParameter = function(p) { |
2488 return this.create(p.name, p.type, p.definition.span, false, true); | 2422 return this.create(p.name, p.type, p.definition.span, false, true); |
2489 } | 2423 } |
2490 BlockScope.prototype.declare = function(id) { | 2424 BlockScope.prototype.declare = function(id) { |
2491 var type = this.enclosingMethod.method.resolveType$2(id.type, false); | 2425 var type = this.enclosingMethod.method.resolveType(id.type, false, true); |
2492 return this.create(id.name.name, type, id.span, false, false); | 2426 return this.create(id.name.name, type, id.span, false, false); |
2493 } | 2427 } |
2494 BlockScope.prototype.getRethrow = function() { | 2428 BlockScope.prototype.getRethrow = function() { |
2495 var scope = this; | 2429 var scope = this; |
2496 while (scope.get$rethrow() == null && scope.get$parent() != null) { | 2430 while (scope.get$rethrow() == null && $ne(scope.get$parent())) { |
2497 scope = scope.get$parent(); | 2431 scope = scope.get$parent(); |
2498 } | 2432 } |
2499 return scope.get$rethrow(); | 2433 return scope.get$rethrow(); |
2500 } | 2434 } |
2501 BlockScope.prototype.snapshot = function() { | 2435 BlockScope.prototype.snapshot = function() { |
2502 return new BlockScope._snapshot$ctor(this); | 2436 return new BlockScope._snapshot$ctor(this); |
2503 } | 2437 } |
2504 BlockScope.prototype.unionWith = function(other) { | 2438 BlockScope.prototype.unionWith = function(other) { |
2505 var $this = this; // closure support | 2439 var $this = this; // closure support |
2506 var changed = false; | 2440 var changed = false; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2597 this._generatedInherits = false; | 2531 this._generatedInherits = false; |
2598 this.useNotNullBool = false; | 2532 this.useNotNullBool = false; |
2599 this.writer = new CodeWriter(); | 2533 this.writer = new CodeWriter(); |
2600 this.useWrap0 = false; | 2534 this.useWrap0 = false; |
2601 this.useThrow = false; | 2535 this.useThrow = false; |
2602 this._generatedDynamicProto = false; | 2536 this._generatedDynamicProto = false; |
2603 this.useWrap1 = false; | 2537 this.useWrap1 = false; |
2604 this.useSetIndex = false; | 2538 this.useSetIndex = false; |
2605 this.useIndex = false; | 2539 this.useIndex = false; |
2606 } | 2540 } |
| 2541 CoreJs.prototype.get$writer = function() { return this.writer; }; |
| 2542 CoreJs.prototype.set$writer = function(value) { return this.writer = value; }; |
2607 CoreJs.prototype.useOperator = function(name) { | 2543 CoreJs.prototype.useOperator = function(name) { |
2608 if (this._usedOperators.$index(name) != null) return; | 2544 if ($ne(this._usedOperators.$index(name))) return; |
2609 var code; | 2545 var code; |
2610 switch (name) { | 2546 switch (name) { |
2611 case ":ne": | 2547 case ":ne": |
2612 | 2548 |
2613 code = "function $ne(x, y) {\n if (x == null) return y != null;\n return
(typeof(x) == 'number' && typeof(y) == 'number') ||\n (typeof(x) == 'bo
olean' && typeof(y) == 'boolean') ||\n (typeof(x) == 'string' && typeof(
y) == 'string')\n ? x != y : !x.$eq(y);\n}"; | 2549 code = "function $ne(x, y) {\n if (x == null) return y != null;\n return
(typeof(x) == 'number' && typeof(y) == 'number') ||\n (typeof(x) == 'bo
olean' && typeof(y) == 'boolean') ||\n (typeof(x) == 'string' && typeof(
y) == 'string')\n ? x != y : !x.$eq(y);\n}"; |
2614 break; | 2550 break; |
2615 | 2551 |
2616 case ":eq": | 2552 case ":eq": |
2617 | 2553 |
2618 code = "function $eq(x, y) {\n if (x == null) return y == null;\n return
(typeof(x) == 'number' && typeof(y) == 'number') ||\n (typeof(x) == 'bo
olean' && typeof(y) == 'boolean') ||\n (typeof(x) == 'string' && typeof(
y) == 'string')\n ? x == y : x.$eq(y);\n}\n// TODO(jimhug): Should this or sh
ould it not match equals?\nObject.defineProperty(Object.prototype, '$eq', { valu
e: function(other) { \n return this === other;\n}, enumerable: false, writable:
true, configurable: true });"; | 2554 code = "function $eq(x, y) {\n if (x == null) return y == null;\n return
(typeof(x) == 'number' && typeof(y) == 'number') ||\n (typeof(x) == 'bo
olean' && typeof(y) == 'boolean') ||\n (typeof(x) == 'string' && typeof(
y) == 'string')\n ? x == y : x.$eq(y);\n}\n// TODO(jimhug): Should this or sh
ould it not match equals?\nObject.defineProperty(Object.prototype, '$eq', { valu
e: function(other) { \n return this === other;\n}, enumerable: false, writable:
true, configurable: true });"; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2697 } | 2633 } |
2698 else { | 2634 else { |
2699 if (this.useWrap0) { | 2635 if (this.useWrap0) { |
2700 w.writeln("function $wrap_call$0(fn) { return fn; }"); | 2636 w.writeln("function $wrap_call$0(fn) { return fn; }"); |
2701 } | 2637 } |
2702 if (this.useWrap1) { | 2638 if (this.useWrap1) { |
2703 w.writeln("function $wrap_call$1(fn) { return fn; }"); | 2639 w.writeln("function $wrap_call$1(fn) { return fn; }"); |
2704 } | 2640 } |
2705 } | 2641 } |
2706 var $$list = orderValuesByKeys(this._usedOperators); | 2642 var $$list = orderValuesByKeys(this._usedOperators); |
2707 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 2643 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
2708 var opImpl = $$list[$$i]; | 2644 var opImpl = $$i.next(); |
2709 w.writeln(opImpl); | 2645 w.writeln(opImpl); |
2710 } | 2646 } |
2711 if ($globals.world.dom != null) { | 2647 if ($globals.world.dom != null) { |
2712 this.ensureTypeNameOf(); | 2648 this.ensureTypeNameOf(); |
2713 w.writeln("Object.defineProperty(Object.prototype, \"get$typeName\", { value
: Object.prototype.$typeNameOf, enumerable: false, writable: true, configurable:
true});"); | 2649 w.writeln("Object.defineProperty(Object.prototype, \"get$typeName\", { value
: Object.prototype.$typeNameOf, enumerable: false, writable: true, configurable:
true});"); |
2714 } | 2650 } |
2715 } | 2651 } |
2716 CoreJs.prototype.generate$1 = CoreJs.prototype.generate; | |
2717 // ********** Code for Element ************** | 2652 // ********** Code for Element ************** |
2718 function Element(name, _enclosingElement) { | 2653 function Element(name, _enclosingElement) { |
2719 this.name = name; | 2654 this.name = name; |
2720 this._enclosingElement = _enclosingElement; | 2655 this._enclosingElement = _enclosingElement; |
2721 this._jsname = $globals.world.toJsIdentifier(this.name); | 2656 this._jsname = $globals.world.toJsIdentifier(this.name); |
2722 } | 2657 } |
2723 Element.prototype.get$name = function() { return this.name; }; | 2658 Element.prototype.get$name = function() { return this.name; }; |
2724 Element.prototype.set$name = function(value) { return this.name = value; }; | 2659 Element.prototype.set$name = function(value) { return this.name = value; }; |
2725 Element.prototype.get$_jsname = function() { return this._jsname; }; | 2660 Element.prototype.get$_jsname = function() { return this._jsname; }; |
2726 Element.prototype.set$_jsname = function(value) { return this._jsname = value; }
; | 2661 Element.prototype.set$_jsname = function(value) { return this._jsname = value; }
; |
(...skipping 20 matching lines...) Expand all Loading... |
2747 } | 2682 } |
2748 Element.prototype.get$jsnamePriority = function() { | 2683 Element.prototype.get$jsnamePriority = function() { |
2749 return this.get$isNative() ? (2) : (this.get$library().get$isCore() ? (1) : (0
)); | 2684 return this.get$isNative() ? (2) : (this.get$library().get$isCore() ? (1) : (0
)); |
2750 } | 2685 } |
2751 Element.prototype.resolve = function() { | 2686 Element.prototype.resolve = function() { |
2752 | 2687 |
2753 } | 2688 } |
2754 Element.prototype.get$typeParameters = function() { | 2689 Element.prototype.get$typeParameters = function() { |
2755 return null; | 2690 return null; |
2756 } | 2691 } |
| 2692 Element.prototype.get$typeArgsInOrder = function() { |
| 2693 return const$0007; |
| 2694 } |
2757 Element.prototype.get$enclosingElement = function() { | 2695 Element.prototype.get$enclosingElement = function() { |
2758 return this._enclosingElement == null ? this.get$library() : this._enclosingEl
ement; | 2696 return this._enclosingElement == null ? this.get$library() : this._enclosingEl
ement; |
2759 } | 2697 } |
2760 Element.prototype.set$enclosingElement = function(e) { | 2698 Element.prototype.set$enclosingElement = function(e) { |
2761 var $0; | 2699 var $0; |
2762 return (this._enclosingElement = ($0 = e), $0); | 2700 return (this._enclosingElement = ($0 = e), $0); |
2763 } | 2701 } |
2764 Element.prototype.resolveType = function(node, typeErrors) { | 2702 Element.prototype.lookupTypeParam = function(name) { |
| 2703 if (this.get$typeParameters() == null) return null; |
| 2704 for (var i = (0); |
| 2705 i < this.get$typeParameters().get$length(); i++) { |
| 2706 if (this.get$typeParameters()[i].name == name) { |
| 2707 return this.get$typeArgsInOrder().$index(i); |
| 2708 } |
| 2709 } |
| 2710 return null; |
| 2711 } |
| 2712 Element.prototype.resolveType = function(node, typeErrors, allowTypeParams) { |
2765 if (node == null) return $globals.world.varType; | 2713 if (node == null) return $globals.world.varType; |
2766 if (node.type != null) return node.type; | 2714 if ((node instanceof SimpleTypeReference)) { |
2767 if ((node instanceof NameTypeReference)) { | 2715 var ret = node.get$dynamic().get$type(); |
| 2716 if ($eq(ret, $globals.world.voidType)) { |
| 2717 $globals.world.error("\"void\" only allowed as return type", node.span); |
| 2718 return $globals.world.varType; |
| 2719 } |
| 2720 return ret; |
| 2721 } |
| 2722 else if ((node instanceof NameTypeReference)) { |
2768 var typeRef = node; | 2723 var typeRef = node; |
2769 var name; | 2724 var name; |
2770 if (typeRef.names != null) { | 2725 if (typeRef.names != null) { |
2771 name = typeRef.names.last().get$name(); | 2726 name = typeRef.names.last().name; |
2772 } | 2727 } |
2773 else { | 2728 else { |
2774 name = typeRef.name.name; | 2729 name = typeRef.name.name; |
2775 } | 2730 } |
2776 if (this.get$typeParameters() != null) { | 2731 var typeParamType = this.lookupTypeParam(name); |
2777 var $$list = this.get$typeParameters(); | 2732 if ($ne(typeParamType)) { |
2778 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 2733 if (!allowTypeParams) { |
2779 var tp = $$list[$$i]; | 2734 $globals.world.error("using type parameter in illegal context.", node.sp
an); |
2780 if ($eq(tp.get$name(), name)) { | |
2781 typeRef.type = tp; | |
2782 } | |
2783 } | 2735 } |
| 2736 return typeParamType; |
2784 } | 2737 } |
2785 if (typeRef.type != null) { | 2738 return this.get$enclosingElement().resolveType(node, typeErrors, allowTypePa
rams); |
2786 return typeRef.type; | |
2787 } | |
2788 return this.get$enclosingElement().resolveType$2(node, typeErrors); | |
2789 } | 2739 } |
2790 else if ((node instanceof GenericTypeReference)) { | 2740 else if ((node instanceof GenericTypeReference)) { |
2791 var typeRef = node; | 2741 var typeRef = node; |
2792 var baseType = this.resolveType$2(typeRef.baseType, typeErrors); | 2742 var baseType = this.resolveType(typeRef.baseType, typeErrors, allowTypeParam
s); |
2793 if (!baseType.get$isGeneric()) { | 2743 if (!baseType.get$isGeneric()) { |
2794 $globals.world.error(("" + baseType.get$name() + " is not generic"), typeR
ef.span); | 2744 $globals.world.error(("" + baseType.get$name() + " is not generic"), typeR
ef.span); |
2795 return null; | 2745 return $globals.world.varType; |
2796 } | 2746 } |
2797 if (typeRef.typeArguments.get$length() != baseType.get$typeParameters().get$
length()) { | 2747 if (typeRef.typeArguments.get$length() != baseType.get$typeParameters().get$
length()) { |
2798 $globals.world.error("wrong number of type arguments", typeRef.span); | 2748 $globals.world.error("wrong number of type arguments", typeRef.span); |
2799 return null; | 2749 return $globals.world.varType; |
2800 } | 2750 } |
2801 var typeArgs = []; | 2751 var typeArgs = []; |
2802 for (var i = (0); | 2752 for (var i = (0); |
2803 i < typeRef.typeArguments.get$length(); i++) { | 2753 i < typeRef.typeArguments.get$length(); i++) { |
2804 typeArgs.add$1(this.resolveType$2(typeRef.typeArguments[i], typeErrors)); | 2754 typeArgs.add(this.resolveType(typeRef.typeArguments[i], typeErrors, allowT
ypeParams)); |
2805 } | 2755 } |
2806 typeRef.type = baseType.getOrMakeConcreteType$1(typeArgs); | 2756 return baseType.getOrMakeConcreteType(typeArgs); |
2807 } | 2757 } |
2808 else if ((node instanceof FunctionTypeReference)) { | 2758 else if ((node instanceof FunctionTypeReference)) { |
2809 var typeRef = node; | 2759 var typeRef = node; |
2810 var name = ""; | 2760 var name = ""; |
2811 if (typeRef.func.name != null) { | 2761 if (typeRef.func.name != null) { |
2812 name = typeRef.func.name.name; | 2762 name = typeRef.func.name.name; |
2813 } | 2763 } |
2814 typeRef.type = this.get$library().getOrAddFunctionType(this, name, typeRef.f
unc); | 2764 return this.get$library().getOrAddFunctionType(this, name, typeRef.func, nul
l); |
2815 } | 2765 } |
2816 else { | 2766 $globals.world.internalError("unexpected TypeReference", node.span); |
2817 $globals.world.internalError("unknown type reference", node.span); | |
2818 } | |
2819 return node.type; | |
2820 } | 2767 } |
2821 Element.prototype.hashCode$0 = Element.prototype.hashCode; | |
2822 Element.prototype.resolve$0 = Element.prototype.resolve; | |
2823 Element.prototype.resolveType$2 = Element.prototype.resolveType; | |
2824 // ********** Code for ExistingJsGlobal ************** | 2768 // ********** Code for ExistingJsGlobal ************** |
2825 $inherits(ExistingJsGlobal, Element); | 2769 $inherits(ExistingJsGlobal, Element); |
2826 function ExistingJsGlobal(name, declaringElement) { | 2770 function ExistingJsGlobal(name, declaringElement) { |
2827 this.declaringElement = declaringElement; | 2771 this.declaringElement = declaringElement; |
2828 Element.call(this, name, null); | 2772 Element.call(this, name, null); |
2829 } | 2773 } |
2830 ExistingJsGlobal.prototype.get$isNative = function() { | 2774 ExistingJsGlobal.prototype.get$isNative = function() { |
2831 return true; | 2775 return true; |
2832 } | 2776 } |
2833 ExistingJsGlobal.prototype.get$jsnamePriority = function() { | 2777 ExistingJsGlobal.prototype.get$jsnamePriority = function() { |
2834 return (10); | 2778 return (10); |
2835 } | 2779 } |
2836 ExistingJsGlobal.prototype.get$span = function() { | 2780 ExistingJsGlobal.prototype.get$span = function() { |
2837 return this.declaringElement.get$span(); | 2781 return this.declaringElement.get$span(); |
2838 } | 2782 } |
2839 ExistingJsGlobal.prototype.get$library = function() { | 2783 ExistingJsGlobal.prototype.get$library = function() { |
2840 return this.declaringElement.get$library(); | 2784 return this.declaringElement.get$library(); |
2841 } | 2785 } |
2842 // ********** Code for WorldGenerator ************** | 2786 // ********** Code for WorldGenerator ************** |
2843 function WorldGenerator(main, writer) { | 2787 function WorldGenerator(main, writer) { |
2844 this.main = main; | 2788 this.main = main; |
2845 this.hasStatics = false; | 2789 this.hasStatics = false; |
2846 this.corejs = new CoreJs(); | 2790 this.corejs = new CoreJs(); |
2847 this.globals = new HashMapImplementation(); | 2791 this.globals = new HashMapImplementation(); |
2848 this.writer = writer; | 2792 this.writer = writer; |
2849 } | 2793 } |
| 2794 WorldGenerator.prototype.get$writer = function() { return this.writer; }; |
| 2795 WorldGenerator.prototype.set$writer = function(value) { return this.writer = val
ue; }; |
| 2796 WorldGenerator.prototype.analyze = function() { |
| 2797 var nlibs = (0), ntypes = (0), nmems = (0), nnews = (0); |
| 2798 var $$list = $globals.world.libraries.getValues(); |
| 2799 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 2800 var lib = $$i.next(); |
| 2801 nlibs += (1); |
| 2802 var $list0 = lib.get$types().getValues(); |
| 2803 for (var $i0 = $list0.iterator(); $i0.hasNext(); ) { |
| 2804 var type = $i0.next(); |
| 2805 ntypes += (1); |
| 2806 var allMembers = []; |
| 2807 allMembers.addAll(type.get$constructors().getValues()); |
| 2808 allMembers.addAll(type.get$members().getValues()); |
| 2809 type.get$factories().forEach((function (allMembers, f) { |
| 2810 return allMembers.add(f); |
| 2811 }).bind(null, allMembers) |
| 2812 ); |
| 2813 for (var $i1 = allMembers.iterator(); $i1.hasNext(); ) { |
| 2814 var m = $i1.next(); |
| 2815 if (m.get$isAbstract() || !m.get$isMethod()) continue; |
| 2816 m.get$methodData().analyze(); |
| 2817 } |
| 2818 } |
| 2819 } |
| 2820 } |
2850 WorldGenerator.prototype.run = function() { | 2821 WorldGenerator.prototype.run = function() { |
2851 var metaGen = new MethodGenerator(this.main, null); | 2822 this.mainContext = new MethodGenerator(this.main, null); |
2852 var mainTarget = new TypeValue(this.main.declaringType, this.main.get$span()); | 2823 var mainTarget = new TypeValue(this.main.declaringType, this.main.get$span()); |
2853 var mainCall = this.main.invoke(metaGen, null, mainTarget, Arguments.get$EMPTY
(), false); | 2824 var mainCall = this.main.invoke(this.mainContext, null, mainTarget, Arguments.
get$EMPTY()); |
2854 this.main.declaringType.markUsed(); | 2825 this.main.declaringType.markUsed(); |
2855 if ($globals.options.compileAll) { | 2826 if ($globals.options.compileAll) { |
2856 this.markLibrariesUsed([$globals.world.coreimpl, $globals.world.corelib, thi
s.main.declaringType.get$library()]); | 2827 this.markLibrariesUsed([$globals.world.coreimpl, $globals.world.corelib, thi
s.main.declaringType.get$library()]); |
2857 } | 2828 } |
2858 $globals.world.numImplType.markUsed(); | 2829 $globals.world.numImplType.markUsed(); |
2859 $globals.world.stringImplType.markUsed(); | 2830 $globals.world.stringImplType.markUsed(); |
2860 if ($globals.world.corelib.types.$index("Isolate").get$isUsed() || $globals.wo
rld.coreimpl.types.$index("ReceivePortImpl").get$isUsed()) { | 2831 if ($globals.world.corelib.types.$index("Isolate").get$isUsed() || $globals.wo
rld.coreimpl.types.$index("ReceivePortImpl").get$isUsed()) { |
2861 if (this.corejs.useWrap0 || this.corejs.useWrap1) { | 2832 if (this.corejs.useWrap0 || this.corejs.useWrap1) { |
2862 this.genMethod($globals.world.coreimpl.types.$index("IsolateContext").getM
ember$1("eval")); | 2833 this.genMethod($globals.world.coreimpl.types.$index("IsolateContext").getM
ember("eval")); |
2863 this.genMethod($globals.world.coreimpl.types.$index("EventLoop").getMember
$1("run")); | 2834 this.genMethod($globals.world.coreimpl.types.$index("EventLoop").getMember
("run")); |
2864 } | 2835 } |
2865 this.corejs.useIsolates = true; | 2836 this.corejs.useIsolates = true; |
2866 var isolateMain = $globals.world.coreimpl.lookup("startRootIsolate", this.ma
in.get$span()); | 2837 var isolateMain = $globals.world.coreimpl.lookup("startRootIsolate", this.ma
in.get$span()); |
2867 var isolateMainTarget = new TypeValue($globals.world.coreimpl.topType, this.
main.get$span()); | 2838 var isolateMainTarget = new TypeValue($globals.world.coreimpl.topType, this.
main.get$span()); |
2868 mainCall = isolateMain.invoke(metaGen, null, isolateMainTarget, new Argument
s(null, [this.main._get(metaGen, this.main.definition, null, false)]), false); | 2839 mainCall = isolateMain.invoke(this.mainContext, null, isolateMainTarget, new
Arguments(null, [this.main._get(this.mainContext, this.main.definition, null)])
); |
2869 } | 2840 } |
2870 this.writeTypes($globals.world.coreimpl); | 2841 this.writeTypes($globals.world.coreimpl); |
2871 this.writeTypes($globals.world.corelib); | 2842 this.writeTypes($globals.world.corelib); |
2872 this.writeTypes(this.main.declaringType.get$library()); | 2843 this.writeTypes(this.main.declaringType.get$library()); |
2873 if (this._mixins != null) this.writer.write(this._mixins.get$text()); | 2844 if (this._mixins != null) this.writer.write(this._mixins.get$text()); |
2874 this.writeDynamicDispatchMetadata(); | 2845 this.writeDynamicDispatchMetadata(); |
2875 this.writeGlobals(); | 2846 this.writeGlobals(); |
2876 this.writer.writeln(("" + mainCall.get$code() + ";")); | 2847 this.writer.writeln(("" + mainCall.get$code() + ";")); |
2877 } | 2848 } |
2878 WorldGenerator.prototype.markLibrariesUsed = function(libs) { | 2849 WorldGenerator.prototype.markLibrariesUsed = function(libs) { |
2879 return this.getAllTypes(libs).forEach(this.get$markTypeUsed()); | 2850 return this.getAllTypes(libs).forEach(this.get$markTypeUsed()); |
2880 } | 2851 } |
2881 WorldGenerator.prototype.markTypeUsed = function(type) { | 2852 WorldGenerator.prototype.markTypeUsed = function(type) { |
2882 if (!type.get$isClass()) return; | 2853 if (!type.get$isClass()) return; |
2883 type.markUsed(); | 2854 type.markUsed(); |
2884 type.isTested = true; | 2855 type.isTested = true; |
2885 type.isTested = !type.get$isTop() && !(type.get$isNative() && type.get$members
().getValues().every((function (m) { | 2856 type.isTested = !type.get$isTop() && !(type.get$isNative() && type.get$members
().getValues().every((function (m) { |
2886 return m.get$isStatic() && !m.get$isFactory(); | 2857 return m.get$isStatic() && !m.get$isFactory(); |
2887 }) | 2858 }) |
2888 )); | 2859 )); |
2889 var members = ListFactory.ListFactory$from$factory(type.get$members().getValue
s()); | 2860 var members = ListFactory.ListFactory$from$factory(type.get$members().getValue
s()); |
2890 members.addAll$1(type.get$constructors().getValues()); | 2861 members.addAll(type.get$constructors().getValues()); |
2891 type.get$factories().forEach((function (f) { | 2862 type.get$factories().forEach((function (f) { |
2892 return members.add$1(f); | 2863 return members.add(f); |
2893 }) | 2864 }) |
2894 ); | 2865 ); |
2895 for (var $$i = members.iterator$0(); $$i.hasNext$0(); ) { | 2866 for (var $$i = members.iterator(); $$i.hasNext(); ) { |
2896 var member = $$i.next$0(); | 2867 var member = $$i.next(); |
2897 if ((member instanceof PropertyMember)) { | 2868 if ((member instanceof PropertyMember)) { |
2898 if (member.get$getter() != null) this.genMethod(member.get$getter()); | 2869 if (member.get$getter() != null) this.genMethod(member.get$getter()); |
2899 if (member.get$setter() != null) this.genMethod(member.get$setter()); | 2870 if (member.get$setter() != null) this.genMethod(member.get$setter()); |
2900 } | 2871 } |
2901 if ((member instanceof MethodMember)) this.genMethod(member); | 2872 if ((member instanceof MethodMember)) this.genMethod(member); |
2902 } | 2873 } |
2903 } | 2874 } |
2904 WorldGenerator.prototype.get$markTypeUsed = function() { | 2875 WorldGenerator.prototype.get$markTypeUsed = function() { |
2905 return this.markTypeUsed.bind(this); | 2876 return this.markTypeUsed.bind(this); |
2906 } | 2877 } |
2907 WorldGenerator.prototype.getAllTypes = function(libs) { | 2878 WorldGenerator.prototype.getAllTypes = function(libs) { |
2908 var types = []; | 2879 var types = []; |
2909 var seen = new HashSetImplementation(); | 2880 var seen = new HashSetImplementation_Library(); |
2910 for (var $$i = 0;$$i < libs.get$length(); $$i++) { | 2881 for (var $$i = libs.iterator(); $$i.hasNext(); ) { |
2911 var mainLib = libs[$$i]; | 2882 var mainLib = $$i.next(); |
2912 var toCheck = DoubleLinkedQueue.DoubleLinkedQueue$from$factory([mainLib]); | 2883 var toCheck = DoubleLinkedQueue.DoubleLinkedQueue$from$factory([mainLib]); |
2913 while (!toCheck.isEmpty()) { | 2884 while (!toCheck.isEmpty()) { |
2914 var lib = toCheck.removeFirst(); | 2885 var lib = toCheck.removeFirst(); |
2915 if (seen.contains(lib)) continue; | 2886 if (seen.contains(lib)) continue; |
2916 seen.add(lib); | 2887 seen.add(lib); |
2917 lib.get$imports().forEach$1((function (lib, toCheck, i) { | 2888 lib.get$imports().forEach((function (lib, toCheck, i) { |
2918 return toCheck.addLast(lib); | 2889 return toCheck.addLast(lib); |
2919 }).bind(null, lib, toCheck) | 2890 }).bind(null, lib, toCheck) |
2920 ); | 2891 ); |
2921 lib.get$types().getValues$0().forEach$1((function (t) { | 2892 lib.get$types().getValues().forEach((function (t) { |
2922 return types.add(t); | 2893 return types.add(t); |
2923 }) | 2894 }) |
2924 ); | 2895 ); |
2925 } | 2896 } |
2926 } | 2897 } |
2927 return types; | 2898 return types; |
2928 } | 2899 } |
2929 WorldGenerator.prototype.globalForStaticField = function(field, exp, dependencie
s) { | 2900 WorldGenerator.prototype.globalForStaticField = function(field, exp, dependencie
s) { |
2930 this.hasStatics = true; | 2901 this.hasStatics = true; |
2931 var key = ("" + field.declaringType.get$jsname() + "." + field.get$jsname()); | 2902 var key = ("" + field.declaringType.get$jsname() + "." + field.get$jsname()); |
2932 var ret = this.globals.$index(key); | 2903 var ret = this.globals.$index(key); |
2933 if (ret == null) { | 2904 if (ret == null) { |
2934 ret = new GlobalValue(exp.get$type(), exp.get$code(), field.isFinal, field,
null, exp, exp.span, dependencies); | 2905 ret = new GlobalValue(exp.get$type(), exp.get$code(), field.isFinal, field,
null, exp, exp.span, dependencies); |
2935 this.globals.$setindex(key, ret); | 2906 this.globals.$setindex(key, ret); |
2936 } | 2907 } |
2937 return ret; | 2908 return ret; |
2938 } | 2909 } |
2939 WorldGenerator.prototype.globalForConst = function(exp, dependencies) { | 2910 WorldGenerator.prototype.globalForConst = function(exp, dependencies) { |
2940 var key = exp.get$type().get$jsname() + ":" + exp.get$code(); | 2911 var key = $add($add(exp.get$type().get$jsname(), ":"), exp.get$code()); |
2941 var ret = this.globals.$index(key); | 2912 var ret = this.globals.$index(key); |
2942 if (ret == null) { | 2913 if (ret == null) { |
2943 var ns = this.globals.get$length().toString$0(); | 2914 var ns = this.globals.get$length().toString$0(); |
2944 while (ns.get$length() < (4)) ns = "0" + ns; | 2915 while (ns.get$length() < (4)) ns = $add("0", ns); |
2945 var name = ("const$" + ns); | 2916 var name = ("const$" + ns); |
2946 ret = new GlobalValue(exp.get$type(), name, true, null, name, exp, exp.span,
dependencies); | 2917 ret = new GlobalValue(exp.get$type(), name, true, null, name, exp, exp.span,
dependencies); |
2947 this.globals.$setindex(key, ret); | 2918 this.globals.$setindex(key, ret); |
2948 } | 2919 } |
2949 return ret; | 2920 return ret; |
2950 } | 2921 } |
2951 WorldGenerator.prototype.writeTypes = function(lib) { | 2922 WorldGenerator.prototype.writeTypes = function(lib) { |
2952 if (lib.isWritten) return; | 2923 if (lib.isWritten) return; |
2953 lib.isWritten = true; | 2924 lib.isWritten = true; |
2954 var $$list = lib.imports; | 2925 var $$list = lib.imports; |
2955 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 2926 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
2956 var import_ = $$list[$$i]; | 2927 var import_ = $$i.next(); |
2957 this.writeTypes(import_.get$library()); | 2928 this.writeTypes(import_.get$library()); |
2958 } | 2929 } |
2959 for (var i = (0); | 2930 for (var i = (0); |
2960 i < lib.sources.get$length(); i++) { | 2931 i < lib.sources.get$length(); i++) { |
2961 lib.sources[i].set$orderInLibrary(i); | 2932 lib.sources[i].orderInLibrary = i; |
2962 } | 2933 } |
2963 this.writer.comment(("// ********** Library " + lib.name + " **************")
); | 2934 this.writer.comment(("// ********** Library " + lib.name + " **************")
); |
2964 if (lib.get$isCore()) { | 2935 if (lib.get$isCore()) { |
2965 this.writer.comment("// ********** Natives dart:core **************"); | 2936 this.writer.comment("// ********** Natives dart:core **************"); |
2966 this.corejs.generate(this.writer); | 2937 this.corejs.generate(this.writer); |
2967 } | 2938 } |
2968 var $$list = lib.natives; | 2939 var $$list = lib.natives; |
2969 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 2940 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
2970 var file = $$list[$$i]; | 2941 var file = $$i.next(); |
2971 var filename = basename(file.get$filename()); | 2942 var filename = basename(file.get$filename()); |
2972 this.writer.comment(("// ********** Natives " + filename + " **************
")); | 2943 this.writer.comment(("// ********** Natives " + filename + " **************
")); |
2973 this.writer.writeln(file.get$text()); | 2944 this.writer.writeln(file.get$text()); |
2974 } | 2945 } |
2975 lib.topType.markUsed(); | 2946 lib.topType.markUsed(); |
2976 var orderedTypes = this._orderValues(lib.types); | 2947 var orderedTypes = this._orderValues(lib.types); |
2977 for (var $$i = orderedTypes.iterator$0(); $$i.hasNext$0(); ) { | 2948 for (var $$i = orderedTypes.iterator(); $$i.hasNext(); ) { |
2978 var type = $$i.next$0(); | 2949 var type = $$i.next(); |
2979 if ((type.get$library().get$isDom() || type.get$isHiddenNativeType()) && typ
e.get$isClass()) { | 2950 if ((type.get$library().get$isDom() || type.get$isHiddenNativeType()) && typ
e.get$isClass()) { |
2980 type.markUsed$0(); | 2951 type.markUsed(); |
2981 } | 2952 } |
2982 } | 2953 } |
2983 for (var $$i = orderedTypes.iterator$0(); $$i.hasNext$0(); ) { | 2954 for (var $$i = orderedTypes.iterator(); $$i.hasNext(); ) { |
2984 var type = $$i.next$0(); | 2955 var type = $$i.next(); |
2985 if (type.get$isUsed() && type.get$isClass()) { | 2956 if (type.get$isUsed() && type.get$isClass()) { |
2986 this.writeType(type); | 2957 this.writeType(type); |
2987 if (type.get$isGeneric()) { | 2958 if (type.get$isGeneric() && type != $globals.world.listFactoryType) { |
2988 var $$list = this._orderValues(type.get$_concreteTypes()); | 2959 var $$list = this._orderValues(type.get$_concreteTypes()); |
2989 for (var $i0 = 0;$i0 < $$list.get$length(); $i0++) { | 2960 for (var $i0 = $$list.iterator(); $i0.hasNext(); ) { |
2990 var ct = $$list[$i0]; | 2961 var ct = $i0.next(); |
2991 this.writeType(ct); | 2962 if (ct.get$isUsed()) this.writeType(ct); |
2992 } | 2963 } |
2993 } | 2964 } |
2994 } | 2965 } |
2995 else if (type.get$isFunction() && type.get$varStubs().get$length() > (0)) { | 2966 else if (type.get$isFunction() && type.get$varStubs().get$length() > (0)) { |
2996 this.writer.comment(("// ********** Code for " + type.get$jsname() + " ***
***********")); | 2967 this.writer.comment(("// ********** Code for " + type.get$jsname() + " ***
***********")); |
2997 this._writeDynamicStubs(type); | 2968 this._writeDynamicStubs(type); |
2998 } | 2969 } |
2999 if (type.get$typeCheckCode() != null) { | 2970 if (type.get$typeCheckCode() != null) { |
3000 this.writer.writeln(type.get$typeCheckCode()); | 2971 this.writer.writeln(type.get$typeCheckCode()); |
3001 } | 2972 } |
3002 } | 2973 } |
3003 } | 2974 } |
3004 WorldGenerator.prototype.genMethod = function(meth, enclosingMethod) { | 2975 WorldGenerator.prototype.genMethod = function(meth) { |
3005 if (!meth.isGenerated && !meth.get$isAbstract() && meth.get$definition() != nu
ll) { | 2976 meth.get$methodData().run(meth); |
3006 new MethodGenerator(meth, enclosingMethod).run(); | |
3007 } | |
3008 } | 2977 } |
3009 WorldGenerator.prototype._prototypeOf = function(type, name) { | 2978 WorldGenerator.prototype._prototypeOf = function(type, name) { |
3010 if (type.get$isSingletonNative()) { | 2979 if (type.get$isSingletonNative()) { |
3011 return ("" + type.get$jsname() + "." + name); | 2980 return ("" + type.get$jsname() + "." + name); |
3012 } | 2981 } |
3013 else if (type.get$isHiddenNativeType()) { | 2982 else if (type.get$isHiddenNativeType()) { |
3014 this.corejs.ensureDynamicProto(); | 2983 this.corejs.ensureDynamicProto(); |
3015 this._usedDynamicDispatchOnType(type); | 2984 this._usedDynamicDispatchOnType(type); |
3016 return ("$dynamic(\"" + name + "\")." + type.get$definition().get$nativeType
().get$name()); | 2985 return ("$dynamic(\"" + name + "\")." + type.get$definition().get$nativeType
().name); |
3017 } | 2986 } |
3018 else { | 2987 else { |
3019 return ("" + type.get$jsname() + ".prototype." + name); | 2988 return ("" + type.get$jsname() + ".prototype." + name); |
3020 } | 2989 } |
3021 } | 2990 } |
3022 WorldGenerator.prototype._writePrototypePatch = function(type, name, functionBod
y, writer, isOneLiner) { | 2991 WorldGenerator.prototype._writePrototypePatch = function(type, name, functionBod
y, writer, isOneLiner) { |
| 2992 var $0; |
3023 var writeFunction = writer.get$writeln(); | 2993 var writeFunction = writer.get$writeln(); |
3024 var ending = ";"; | 2994 var ending = ";"; |
3025 if (!isOneLiner) { | 2995 if (!isOneLiner) { |
3026 writeFunction = writer.get$enterBlock(); | 2996 writeFunction = writer.get$enterBlock(); |
3027 ending = ""; | 2997 ending = ""; |
3028 } | 2998 } |
3029 if (type.get$isObject()) { | 2999 if (type.get$isObject()) { |
3030 $globals.world.counters.objectProtoMembers++; | 3000 ($0 = $globals.world.counters).objectProtoMembers = $0.objectProtoMembers +
(1); |
3031 } | 3001 } |
3032 if (type.get$isObject() || $eq(type.get$genericType(), $globals.world.listFact
oryType)) { | 3002 if (type.get$isObject() || $eq(type.get$genericType(), $globals.world.listFact
oryType)) { |
3033 if (isOneLiner) { | 3003 if (isOneLiner) { |
3034 ending = ", enumerable: false, writable: true, configurable: true })" + en
ding; | 3004 ending = $add(", enumerable: false, writable: true, configurable: true })"
, ending); |
3035 } | 3005 } |
3036 writeFunction.call$1(("Object.defineProperty(" + type.get$jsname() + ".proto
type, \"" + name + "\",") + (" { value: " + functionBody + ending)); | 3006 writeFunction.call$1($add(("Object.defineProperty(" + type.get$jsname() + ".
prototype, \"" + name + "\","), (" { value: " + functionBody + ending))); |
3037 if (isOneLiner) return "}"; | 3007 if (isOneLiner) return "}"; |
3038 return "}, enumerable: false, writable: true, configurable: true });"; | 3008 return "}, enumerable: false, writable: true, configurable: true });"; |
3039 } | 3009 } |
3040 else { | 3010 else { |
3041 writeFunction.call$1(this._prototypeOf(type, name) + " = " + functionBody +
ending); | 3011 writeFunction.call$1($add($add($add(this._prototypeOf(type, name), " = "), f
unctionBody), ending)); |
3042 return isOneLiner ? "" : "}"; | 3012 return isOneLiner ? "" : "}"; |
3043 } | 3013 } |
3044 } | 3014 } |
3045 WorldGenerator.prototype._maybeIsTest = function(onType, checkType) { | 3015 WorldGenerator.prototype._maybeIsTest = function(onType, checkType) { |
3046 var isSubtype = onType.isSubtypeOf(checkType); | 3016 var isSubtype = onType.isSubtypeOf(checkType); |
3047 if (checkType.isTested) { | 3017 if (checkType.isTested) { |
3048 this._writePrototypePatch(onType, ("is$" + checkType.get$jsname()), ("functi
on(){return " + isSubtype + "}"), this.writer, true); | 3018 this._writePrototypePatch(onType, ("is$" + checkType.get$jsname()), ("functi
on(){return " + isSubtype + "}"), this.writer, true); |
3049 } | 3019 } |
3050 if (checkType.isChecked) { | 3020 if (checkType.isChecked) { |
3051 var body = "return this"; | 3021 var body = "return this"; |
3052 var checkName = ("assert$" + checkType.get$jsname()); | 3022 var checkName = ("assert$" + checkType.get$jsname()); |
3053 if (!isSubtype) { | 3023 if (!isSubtype) { |
3054 body = $globals.world.objectType.varStubs.$index(checkName).get$body(); | 3024 body = $globals.world.objectType.varStubs.$index(checkName).get$body(); |
3055 } | 3025 } |
3056 else if ($eq(onType, $globals.world.stringImplType) || $eq(onType, $globals.
world.numImplType)) { | 3026 else if ($eq(onType, $globals.world.stringImplType) || $eq(onType, $globals.
world.numImplType)) { |
3057 body = ("return " + onType.get$nativeType().name + "(this)"); | 3027 body = ("return " + onType.get$nativeType().name + "(this)"); |
3058 } | 3028 } |
3059 this._writePrototypePatch(onType, checkName, ("function(){" + body + "}"), t
his.writer, true); | 3029 this._writePrototypePatch(onType, checkName, ("function(){" + body + "}"), t
his.writer, true); |
3060 } | 3030 } |
3061 } | 3031 } |
3062 WorldGenerator.prototype.writeType = function(type) { | 3032 WorldGenerator.prototype.writeType = function(type) { |
3063 if (type.isWritten) return; | 3033 if (type.isWritten) return; |
3064 type.isWritten = true; | 3034 type.isWritten = true; |
3065 if (type.get$parent() != null && !type.get$isNative()) { | 3035 if (type.get$parent() != null && !type.get$isNative()) { |
3066 this.writeType(type.get$parent()); | 3036 this.writeType(type.get$parent()); |
3067 } | 3037 } |
3068 if (type.name != null && (type instanceof ConcreteType) && $eq(type.get$librar
y(), $globals.world.coreimpl) && type.name.startsWith("ListFactory")) { | |
3069 this.writer.writeln(("" + type.get$jsname() + " = " + type.get$genericType()
.get$jsname() + ";")); | |
3070 return; | |
3071 } | |
3072 var typeName = type.get$jsname() != null ? type.get$jsname() : "top level"; | 3038 var typeName = type.get$jsname() != null ? type.get$jsname() : "top level"; |
3073 this.writer.comment(("// ********** Code for " + typeName + " **************")
); | 3039 this.writer.comment(("// ********** Code for " + typeName + " **************")
); |
3074 if (type.get$isNative() && !type.get$isTop()) { | 3040 if (type.get$isNative() && !type.get$isTop() && !type.get$isConcreteGeneric())
{ |
3075 var nativeName = type.get$definition().get$nativeType().get$name(); | 3041 var nativeName = type.get$definition().get$nativeType().name; |
3076 if ($eq(nativeName, "")) { | 3042 if ($eq(nativeName, "")) { |
3077 this.writer.writeln(("function " + type.get$jsname() + "() {}")); | 3043 this.writer.writeln(("function " + type.get$jsname() + "() {}")); |
3078 } | 3044 } |
3079 else if (type.get$jsname() != nativeName) { | 3045 else if (type.get$jsname() != nativeName) { |
3080 if (type.get$isHiddenNativeType()) { | 3046 if (type.get$isHiddenNativeType()) { |
3081 if (this._typeNeedsHolderForStaticMethods(type)) { | 3047 if (this._typeNeedsHolderForStaticMethods(type)) { |
3082 this.writer.writeln(("var " + type.get$jsname() + " = {};")); | 3048 this.writer.writeln(("var " + type.get$jsname() + " = {};")); |
3083 } | 3049 } |
3084 } | 3050 } |
3085 else { | 3051 else { |
3086 this.writer.writeln(("" + type.get$jsname() + " = " + nativeName + ";"))
; | 3052 this.writer.writeln(("" + type.get$jsname() + " = " + nativeName + ";"))
; |
3087 } | 3053 } |
3088 } | 3054 } |
3089 } | 3055 } |
3090 if (!type.get$isTop()) { | 3056 if (!type.get$isTop()) { |
3091 if ((type instanceof ConcreteType)) { | 3057 if (type.get$genericType() != type) { |
3092 var c = type; | |
3093 this.corejs.ensureInheritsHelper(); | 3058 this.corejs.ensureInheritsHelper(); |
3094 this.writer.writeln(("$inherits(" + c.get$jsname() + ", " + c.genericType.
get$jsname() + ");")); | 3059 this.writer.writeln(("$inherits(" + type.get$jsname() + ", " + type.get$ge
nericType().get$jsname() + ");")); |
3095 for (var p = c._parent; | |
3096 (p instanceof ConcreteType); p = p.get$_parent()) { | |
3097 this._ensureInheritMembersHelper(); | |
3098 this._mixins.writeln(("$inheritsMembers(" + c.get$jsname() + ", " + p.ge
t$jsname() + ");")); | |
3099 } | |
3100 } | 3060 } |
3101 else if (!type.get$isNative()) { | 3061 else if (!type.get$isNative()) { |
3102 if (type.get$parent() != null && !type.get$parent().get$isObject()) { | 3062 if (type.get$parent() != null && !type.get$parent().get$isObject()) { |
3103 this.corejs.ensureInheritsHelper(); | 3063 this.corejs.ensureInheritsHelper(); |
3104 this.writer.writeln(("$inherits(" + type.get$jsname() + ", " + type.get$
parent().get$jsname() + ");")); | 3064 this.writer.writeln(("$inherits(" + type.get$jsname() + ", " + type.get$
parent().get$jsname() + ");")); |
3105 } | 3065 } |
3106 } | 3066 } |
3107 } | 3067 } |
3108 if (type.get$isTop()) { | 3068 if (type.get$isTop()) { |
3109 } | 3069 } |
3110 else if (type.get$constructors().get$length() == (0)) { | 3070 else if (type.get$constructors().get$length() == (0)) { |
3111 if (!type.get$isNative()) { | 3071 if (!type.get$isNative() || type.get$isConcreteGeneric()) { |
3112 this.writer.writeln(("function " + type.get$jsname() + "() {}")); | 3072 this.writer.writeln(("function " + type.get$jsname() + "() {}")); |
3113 } | 3073 } |
3114 } | 3074 } |
3115 else { | 3075 else { |
3116 var standardConstructor = type.get$constructors().$index(""); | 3076 var wroteStandard = false; |
3117 if (standardConstructor == null || standardConstructor.generator == null) { | 3077 var $$list = type.get$constructors().getValues(); |
3118 if (!type.get$isNative()) { | 3078 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3119 this.writer.writeln(("function " + type.get$jsname() + "() {}")); | 3079 var c = $$i.next(); |
| 3080 if (c.get$methodData().writeDefinition(c, this.writer)) { |
| 3081 if (c.get$isConstructor() && c.get$constructorName() == "") wroteStandar
d = true; |
3120 } | 3082 } |
3121 } | 3083 } |
3122 else { | 3084 if (!wroteStandard && (!type.get$isNative() || type.get$genericType() != typ
e)) { |
3123 standardConstructor.generator.writeDefinition(this.writer, null); | 3085 this.writer.writeln(("function " + type.get$jsname() + "() {}")); |
3124 } | |
3125 var $$list = type.get$constructors().getValues(); | |
3126 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | |
3127 var c = $$i.next$0(); | |
3128 if (c.get$generator() != null && $ne(c, standardConstructor)) { | |
3129 c.get$generator().writeDefinition$2(this.writer); | |
3130 } | |
3131 } | 3086 } |
3132 } | 3087 } |
3133 if (!(type instanceof ConcreteType)) { | 3088 if (!type.get$isConcreteGeneric()) { |
3134 this._maybeIsTest(type, type); | 3089 this._maybeIsTest(type, type); |
3135 } | 3090 } |
3136 if (type.get$genericType()._concreteTypes != null) { | 3091 if (type.get$genericType()._concreteTypes != null) { |
3137 var $$list = this._orderValues(type.get$genericType()._concreteTypes); | 3092 var $$list = this._orderValues(type.get$genericType()._concreteTypes); |
3138 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 3093 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3139 var ct = $$list[$$i]; | 3094 var ct = $$i.next(); |
3140 this._maybeIsTest(type, ct); | 3095 this._maybeIsTest(type, ct); |
3141 } | 3096 } |
3142 } | 3097 } |
3143 if (type.get$interfaces() != null) { | 3098 if (type.get$interfaces() != null) { |
3144 var seen = new HashSetImplementation(); | 3099 var seen = new HashSetImplementation(); |
3145 var worklist = []; | 3100 var worklist = []; |
3146 worklist.addAll$1(type.get$interfaces()); | 3101 worklist.addAll(type.get$interfaces()); |
3147 seen.addAll$1(type.get$interfaces()); | 3102 seen.addAll(type.get$interfaces()); |
3148 while (!worklist.isEmpty$0()) { | 3103 while (!worklist.isEmpty()) { |
3149 var interface_ = worklist.removeLast$0(); | 3104 var interface_ = worklist.removeLast(); |
3150 this._maybeIsTest(type, interface_.get$genericType()); | 3105 this._maybeIsTest(type, interface_.get$genericType()); |
3151 if (interface_.get$genericType().get$_concreteTypes() != null) { | 3106 if (interface_.get$genericType()._concreteTypes != null) { |
3152 var $$list = this._orderValues(interface_.get$genericType().get$_concret
eTypes()); | 3107 var $$list = this._orderValues(interface_.get$genericType()._concreteTyp
es); |
3153 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 3108 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3154 var ct = $$list[$$i]; | 3109 var ct = $$i.next(); |
3155 this._maybeIsTest(type, ct); | 3110 this._maybeIsTest(type, ct); |
3156 } | 3111 } |
3157 } | 3112 } |
3158 var $$list = interface_.get$interfaces(); | 3113 var $$list = interface_.get$interfaces(); |
3159 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 3114 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3160 var other = $$i.next$0(); | 3115 var other = $$i.next(); |
3161 if (!seen.contains$1(other)) { | 3116 if (!seen.contains$1(other)) { |
3162 worklist.addLast$1(other); | 3117 worklist.addLast(other); |
3163 seen.add$1(other); | 3118 seen.add(other); |
3164 } | 3119 } |
3165 } | 3120 } |
3166 } | 3121 } |
3167 } | 3122 } |
3168 type.get$factories().forEach(this.get$_writeMethod()); | 3123 type.get$factories().forEach(this.get$_writeMethod()); |
3169 var $$list = this._orderValues(type.get$members()); | 3124 var $$list = this._orderValues(type.get$members()); |
3170 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 3125 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3171 var member = $$list[$$i]; | 3126 var member = $$i.next(); |
3172 if ((member instanceof FieldMember)) { | 3127 if ((member instanceof FieldMember)) { |
3173 this._writeField(member); | 3128 this._writeField(member); |
3174 } | 3129 } |
3175 if ((member instanceof PropertyMember)) { | 3130 if ((member instanceof PropertyMember)) { |
3176 this._writeProperty(member); | 3131 this._writeProperty(member); |
3177 } | 3132 } |
3178 if (member.get$isMethod()) { | 3133 if (member.get$isMethod()) { |
3179 this._writeMethod(member); | 3134 this._writeMethod(member); |
3180 } | 3135 } |
3181 } | 3136 } |
3182 this._writeDynamicStubs(type); | 3137 this._writeDynamicStubs(type); |
3183 } | 3138 } |
3184 WorldGenerator.prototype._typeNeedsHolderForStaticMethods = function(type) { | 3139 WorldGenerator.prototype._typeNeedsHolderForStaticMethods = function(type) { |
3185 var $$list = type.get$members().getValues(); | 3140 return type.get$isUsed(); |
3186 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | |
3187 var member = $$i.next$0(); | |
3188 if (member.get$isMethod()) { | |
3189 if (member.get$isConstructor() || member.get$isStatic()) { | |
3190 if (member.get$isGenerated()) { | |
3191 return true; | |
3192 } | |
3193 } | |
3194 } | |
3195 } | |
3196 return false; | |
3197 } | |
3198 WorldGenerator.prototype._ensureInheritMembersHelper = function() { | |
3199 if (this._mixins != null) return; | |
3200 this._mixins = new CodeWriter(); | |
3201 this._mixins.comment("// ********** Generic Type Inheritance **************"); | |
3202 this._mixins.writeln("/** Implements extends for generic types. */\nfunction $
inheritsMembers(child, parent) {\n child = child.prototype;\n parent = parent.
prototype;\n Object.getOwnPropertyNames(parent).forEach(function(name) {\n i
f (typeof(child[name]) == 'undefined') child[name] = parent[name];\n });\n}"); | |
3203 } | 3141 } |
3204 WorldGenerator.prototype._writeDynamicStubs = function(type) { | 3142 WorldGenerator.prototype._writeDynamicStubs = function(type) { |
3205 var $$list = orderValuesByKeys(type.varStubs); | 3143 var $$list = orderValuesByKeys(type.varStubs); |
3206 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 3144 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3207 var stub = $$list[$$i]; | 3145 var stub = $$i.next(); |
3208 if (!stub.get$isGenerated()) stub.generate$1(this.writer); | 3146 if (!stub.get$isGenerated()) stub.generate(this.writer); |
3209 } | 3147 } |
3210 } | 3148 } |
3211 WorldGenerator.prototype._writeStaticField = function(field) { | 3149 WorldGenerator.prototype._writeStaticField = function(field) { |
3212 if (field.isFinal) return; | 3150 if (field.isFinal) return; |
3213 var fullname = ("" + field.declaringType.get$jsname() + "." + field.get$jsname
()); | 3151 var fullname = ("" + field.declaringType.get$jsname() + "." + field.get$jsname
()); |
3214 if (this.globals.containsKey(fullname)) { | 3152 if (this.globals.containsKey(fullname)) { |
3215 var value = this.globals.$index(fullname); | 3153 var value = this.globals.$index(fullname); |
3216 if (field.declaringType.get$isTop() && !field.isNative) { | 3154 if (field.declaringType.get$isTop() && !field.isNative) { |
3217 this.writer.writeln(("$globals." + field.get$jsname() + " = " + value.get$
exp().get$code() + ";")); | 3155 this.writer.writeln(("$globals." + field.get$jsname() + " = " + value.get$
exp().get$code() + ";")); |
3218 } | 3156 } |
3219 else { | 3157 else { |
3220 this.writer.writeln(("$globals." + field.declaringType.get$jsname() + "_"
+ field.get$jsname()) + (" = " + value.get$exp().get$code() + ";")); | 3158 this.writer.writeln($add(("$globals." + field.declaringType.get$jsname() +
"_" + field.get$jsname()), (" = " + value.get$exp().get$code() + ";"))); |
3221 } | 3159 } |
3222 } | 3160 } |
3223 } | 3161 } |
3224 WorldGenerator.prototype._writeField = function(field) { | 3162 WorldGenerator.prototype._writeField = function(field) { |
3225 if (field.declaringType.get$isTop() && !field.isNative && field.value == null)
{ | 3163 if (field.declaringType.get$isTop() && !field.isNative && field.value == null)
{ |
3226 this.writer.writeln(("var " + field.get$jsname() + ";")); | 3164 this.writer.writeln(("var " + field.get$jsname() + ";")); |
3227 } | 3165 } |
3228 if (field._providePropertySyntax) { | 3166 if (field._providePropertySyntax && !field.declaringType.get$isConcreteGeneric
()) { |
3229 this._writePrototypePatch(field.declaringType, ("get$" + field.get$jsname())
, ("function() { return this." + field.get$jsname() + "; }"), this.writer, true)
; | 3167 this._writePrototypePatch(field.declaringType, ("get$" + field.get$jsname())
, ("function() { return this." + field.get$jsname() + "; }"), this.writer, true)
; |
3230 if (!field.isFinal) { | 3168 if (!field.isFinal) { |
3231 this._writePrototypePatch(field.declaringType, ("set$" + field.get$jsname(
)), ("function(value) { return this." + field.get$jsname() + " = value; }"), thi
s.writer, true); | 3169 this._writePrototypePatch(field.declaringType, ("set$" + field.get$jsname(
)), ("function(value) { return this." + field.get$jsname() + " = value; }"), thi
s.writer, true); |
3232 } | 3170 } |
3233 } | 3171 } |
3234 } | 3172 } |
3235 WorldGenerator.prototype._writeProperty = function(property) { | 3173 WorldGenerator.prototype._writeProperty = function(property) { |
3236 if (property.getter != null) this._writeMethod(property.getter); | 3174 if (property.getter != null) this._writeMethod(property.getter); |
3237 if (property.setter != null) this._writeMethod(property.setter); | 3175 if (property.setter != null) this._writeMethod(property.setter); |
3238 if (property._provideFieldSyntax) { | 3176 if (property.get$needsFieldSyntax()) { |
3239 this.writer.enterBlock("Object.defineProperty(" + ("" + property.declaringTy
pe.get$jsname() + ".prototype, \"" + property.get$jsname() + "\", {")); | 3177 this.writer.enterBlock($add("Object.defineProperty(", ("" + property.declari
ngType.get$jsname() + ".prototype, \"" + property.get$jsname() + "\", {"))); |
3240 if (property.getter != null) { | 3178 if (property.getter != null) { |
3241 this.writer.write(("get: " + property.declaringType.get$jsname() + ".proto
type." + property.getter.get$jsname())); | 3179 this.writer.write(("get: " + property.declaringType.get$jsname() + ".proto
type." + property.getter.get$jsname())); |
3242 this.writer.writeln(property.setter == null ? "" : ","); | 3180 this.writer.writeln(property.setter == null ? "" : ","); |
3243 } | 3181 } |
3244 if (property.setter != null) { | 3182 if (property.setter != null) { |
3245 this.writer.writeln(("set: " + property.declaringType.get$jsname() + ".pro
totype." + property.setter.get$jsname())); | 3183 this.writer.writeln(("set: " + property.declaringType.get$jsname() + ".pro
totype." + property.setter.get$jsname())); |
3246 } | 3184 } |
3247 this.writer.exitBlock("});"); | 3185 this.writer.exitBlock("});"); |
3248 } | 3186 } |
3249 } | 3187 } |
3250 WorldGenerator.prototype._writeMethod = function(m) { | 3188 WorldGenerator.prototype._writeMethod = function(m) { |
3251 if (m.generator != null) { | 3189 m.get$methodData().writeDefinition(m, this.writer); |
3252 m.generator.writeDefinition(this.writer, null); | 3190 if (m.get$isNative() && m._providePropertySyntax) { |
3253 } | |
3254 else if ((m instanceof MethodMember) && m.get$isNative() && m._provideProperty
Syntax && !m._provideFieldSyntax) { | |
3255 MethodGenerator._maybeGenerateBoundGetter(m, this.writer); | 3191 MethodGenerator._maybeGenerateBoundGetter(m, this.writer); |
3256 } | 3192 } |
3257 } | 3193 } |
3258 WorldGenerator.prototype.get$_writeMethod = function() { | 3194 WorldGenerator.prototype.get$_writeMethod = function() { |
3259 return this._writeMethod.bind(this); | 3195 return this._writeMethod.bind(this); |
3260 } | 3196 } |
3261 WorldGenerator.prototype.writeGlobals = function() { | 3197 WorldGenerator.prototype.writeGlobals = function() { |
3262 if (this.globals.get$length() > (0)) { | 3198 if (this.globals.get$length() > (0)) { |
3263 this.writer.comment("// ********** Globals **************"); | 3199 this.writer.comment("// ********** Globals **************"); |
3264 var list = this.globals.getValues(); | 3200 var list = this.globals.getValues(); |
3265 list.sort$1((function (a, b) { | 3201 list.sort((function (a, b) { |
3266 return a.compareTo$1(b); | 3202 return a.compareTo(b); |
3267 }) | 3203 }) |
3268 ); | 3204 ); |
3269 this.writer.enterBlock("function $static_init(){"); | 3205 this.writer.enterBlock("function $static_init(){"); |
3270 for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) { | 3206 for (var $$i = list.iterator(); $$i.hasNext(); ) { |
3271 var global = $$i.next$0(); | 3207 var global = $$i.next(); |
3272 if (global.get$field() != null) { | 3208 if (global.get$field() != null) { |
3273 this._writeStaticField(global.get$field()); | 3209 this._writeStaticField(global.get$field()); |
3274 } | 3210 } |
3275 } | 3211 } |
3276 this.writer.exitBlock("}"); | 3212 this.writer.exitBlock("}"); |
3277 for (var $$i = list.iterator$0(); $$i.hasNext$0(); ) { | 3213 for (var $$i = list.iterator(); $$i.hasNext(); ) { |
3278 var global = $$i.next$0(); | 3214 var global = $$i.next(); |
3279 if (global.get$field() == null) { | 3215 if (global.get$field() == null) { |
3280 this.writer.writeln(("var " + global.get$name() + " = " + global.get$exp
().get$code() + ";")); | 3216 this.writer.writeln(("var " + global.get$name() + " = " + global.get$exp
().get$code() + ";")); |
3281 } | 3217 } |
3282 } | 3218 } |
3283 } | 3219 } |
3284 if (!this.corejs.useIsolates) { | 3220 if (!this.corejs.useIsolates) { |
3285 if (this.hasStatics) { | 3221 if (this.hasStatics) { |
3286 this.writer.writeln("var $globals = {};"); | 3222 this.writer.writeln("var $globals = {};"); |
3287 } | 3223 } |
3288 if (this.globals.get$length() > (0)) { | 3224 if (this.globals.get$length() > (0)) { |
3289 this.writer.writeln("$static_init();"); | 3225 this.writer.writeln("$static_init();"); |
3290 } | 3226 } |
3291 } | 3227 } |
3292 } | 3228 } |
3293 WorldGenerator.prototype._usedDynamicDispatchOnType = function(type) { | 3229 WorldGenerator.prototype._usedDynamicDispatchOnType = function(type) { |
3294 if (this.typesWithDynamicDispatch == null) this.typesWithDynamicDispatch = new
HashSetImplementation(); | 3230 if (this.typesWithDynamicDispatch == null) this.typesWithDynamicDispatch = new
HashSetImplementation(); |
3295 this.typesWithDynamicDispatch.add(type); | 3231 this.typesWithDynamicDispatch.add(type); |
3296 } | 3232 } |
3297 WorldGenerator.prototype.writeDynamicDispatchMetadata = function() { | 3233 WorldGenerator.prototype.writeDynamicDispatchMetadata = function() { |
3298 var $this = this; // closure support | 3234 var $this = this; // closure support |
3299 if (this.typesWithDynamicDispatch == null) return; | 3235 if (this.typesWithDynamicDispatch == null) return; |
3300 this.writer.comment(("// " + this.typesWithDynamicDispatch.get$length() + " dy
namic types.")); | 3236 this.writer.comment(("// " + this.typesWithDynamicDispatch.get$length() + " dy
namic types.")); |
3301 var seen = new HashSetImplementation(); | 3237 var seen = new HashSetImplementation(); |
3302 var types = []; | 3238 var types = []; |
3303 function visit(type) { | 3239 function visit(type) { |
3304 if (seen.contains$1(type)) return; | 3240 if (seen.contains$1(type)) return; |
3305 seen.add$1(type); | 3241 seen.add(type); |
3306 var $$list = $this._orderCollectionValues(type.get$directSubtypes()); | 3242 var $$list = $this._orderCollectionValues(type.get$directSubtypes()); |
3307 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 3243 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3308 var subtype = $$list[$$i]; | 3244 var subtype = $$i.next(); |
3309 visit.call$1(subtype); | 3245 visit(subtype); |
3310 } | 3246 } |
3311 types.add$1(type); | 3247 types.add(type); |
3312 } | 3248 } |
3313 var $$list = this._orderCollectionValues(this.typesWithDynamicDispatch); | 3249 var $$list = this._orderCollectionValues(this.typesWithDynamicDispatch); |
3314 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 3250 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3315 var type = $$list[$$i]; | 3251 var type = $$i.next(); |
3316 visit.call$1(type); | 3252 visit(type); |
3317 } | 3253 } |
3318 var dispatchTypes = types.filter$1((function (type) { | 3254 var dispatchTypes = types.filter((function (type) { |
3319 return !type.get$directSubtypes().isEmpty$0() && $this.typesWithDynamicDispa
tch.contains(type); | 3255 return !type.get$directSubtypes().isEmpty() && $this.typesWithDynamicDispatc
h.contains(type); |
3320 }) | 3256 }) |
3321 ); | 3257 ); |
3322 this.writer.comment(("// " + types.get$length() + " types")); | 3258 this.writer.comment(("// " + types.get$length() + " types")); |
3323 this.writer.comment(("// " + types.filter$1((function (t) { | 3259 this.writer.comment(("// " + types.filter((function (t) { |
3324 return !t.get$directSubtypes().isEmpty$0(); | 3260 return !t.get$directSubtypes().isEmpty(); |
3325 }) | 3261 }) |
3326 ).get$length() + " !leaf")); | 3262 ).get$length() + " !leaf")); |
3327 var varNames = []; | 3263 var varNames = []; |
3328 var varDefns = new HashMapImplementation(); | 3264 var varDefns = new HashMapImplementation(); |
3329 var tagDefns = new HashMapImplementation(); | 3265 var tagDefns = new HashMapImplementation(); |
3330 function makeExpression(type) { | 3266 function makeExpression(type) { |
3331 var expressions = []; | 3267 var expressions = []; |
3332 var subtags = [type.get$nativeName()]; | 3268 var subtags = [type.get$nativeName()]; |
3333 function walk(type) { | 3269 function walk(type) { |
3334 var $$list = $this._orderCollectionValues(type.get$directSubtypes()); | 3270 var $$list = $this._orderCollectionValues(type.get$directSubtypes()); |
3335 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 3271 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3336 var subtype = $$list[$$i]; | 3272 var subtype = $$i.next(); |
3337 var tag = subtype.get$nativeName(); | 3273 var tag = subtype.get$nativeName(); |
3338 var existing = tagDefns.$index(tag); | 3274 var existing = tagDefns.$index(tag); |
3339 if (existing == null) { | 3275 if ($eq(existing)) { |
3340 subtags.add$1(tag); | 3276 subtags.add(tag); |
3341 walk.call$1(subtype); | 3277 walk(subtype); |
3342 } | 3278 } |
3343 else { | 3279 else { |
3344 if (varDefns.containsKey$1(existing)) { | 3280 if (varDefns.containsKey(existing)) { |
3345 expressions.add$1(existing); | 3281 expressions.add(existing); |
3346 } | 3282 } |
3347 else { | 3283 else { |
3348 var varName = ("v" + varNames.get$length() + "/*" + tag + "*/"); | 3284 var varName = ("v" + varNames.get$length() + "/*" + tag + "*/"); |
3349 varNames.add$1(varName); | 3285 varNames.add(varName); |
3350 varDefns.$setindex(varName, existing); | 3286 varDefns.$setindex(varName, existing); |
3351 tagDefns.$setindex(tag, varName); | 3287 tagDefns.$setindex(tag, varName); |
3352 expressions.add$1(varName); | 3288 expressions.add(varName); |
3353 } | 3289 } |
3354 } | 3290 } |
3355 } | 3291 } |
3356 } | 3292 } |
3357 walk.call$1(type); | 3293 walk(type); |
3358 var constantPart = ("'" + Strings.join(subtags, "|") + "'"); | 3294 var constantPart = ("'" + Strings.join(subtags, "|") + "'"); |
3359 if ($ne(constantPart, "''")) expressions.add$1(constantPart); | 3295 if ($ne(constantPart, "''")) expressions.add(constantPart); |
3360 var expression; | 3296 var expression; |
3361 if ($eq(expressions.get$length(), (1))) { | 3297 if (expressions.get$length() == (1)) { |
3362 expression = expressions.$index((0)); | 3298 expression = expressions.$index((0)); |
3363 } | 3299 } |
3364 else { | 3300 else { |
3365 expression = ("[" + Strings.join(expressions, ",") + "].join('|')"); | 3301 expression = ("[" + Strings.join(expressions, ",") + "].join('|')"); |
3366 } | 3302 } |
3367 return expression; | 3303 return expression; |
3368 } | 3304 } |
3369 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) { | 3305 for (var $$i = dispatchTypes.iterator(); $$i.hasNext(); ) { |
3370 var type = $$i.next$0(); | 3306 var type = $$i.next(); |
3371 tagDefns.$setindex(type.get$nativeName(), makeExpression.call$1(type)); | 3307 tagDefns.$setindex(type.get$nativeName(), makeExpression(type)); |
3372 } | 3308 } |
3373 if (!tagDefns.isEmpty$0()) { | 3309 if (!tagDefns.isEmpty()) { |
3374 this.writer.enterBlock("(function(){"); | 3310 this.writer.enterBlock("(function(){"); |
3375 for (var $$i = varNames.iterator$0(); $$i.hasNext$0(); ) { | 3311 for (var $$i = varNames.iterator(); $$i.hasNext(); ) { |
3376 var varName = $$i.next$0(); | 3312 var varName = $$i.next(); |
3377 this.writer.writeln(("var " + varName + " = " + varDefns.$index(varName) +
";")); | 3313 this.writer.writeln(("var " + varName + " = " + varDefns.$index(varName) +
";")); |
3378 } | 3314 } |
3379 this.writer.enterBlock("var table = ["); | 3315 this.writer.enterBlock("var table = ["); |
3380 this.writer.comment("// [dynamic-dispatch-tag, tags of classes implementing
dynamic-dispatch-tag]"); | 3316 this.writer.comment("// [dynamic-dispatch-tag, tags of classes implementing
dynamic-dispatch-tag]"); |
3381 for (var $$i = dispatchTypes.iterator$0(); $$i.hasNext$0(); ) { | 3317 for (var $$i = dispatchTypes.iterator(); $$i.hasNext(); ) { |
3382 var type = $$i.next$0(); | 3318 var type = $$i.next(); |
3383 this.writer.writeln(("['" + type.get$nativeName() + "', " + tagDefns.$inde
x(type.get$nativeName()) + "],")); | 3319 this.writer.writeln(("['" + type.get$nativeName() + "', " + tagDefns.$inde
x(type.get$nativeName()) + "],")); |
3384 } | 3320 } |
3385 this.writer.exitBlock("];"); | 3321 this.writer.exitBlock("];"); |
3386 this.writer.writeln("$dynamicSetMetadata(table);"); | 3322 this.writer.writeln("$dynamicSetMetadata(table);"); |
3387 this.writer.exitBlock("})();"); | 3323 this.writer.exitBlock("})();"); |
3388 } | 3324 } |
3389 } | 3325 } |
3390 WorldGenerator.prototype._orderValues = function(map) { | 3326 WorldGenerator.prototype._orderValues = function(map) { |
3391 var values = map.getValues(); | 3327 var values = map.getValues(); |
3392 values.sort(this.get$_compareMembers()); | 3328 values.sort(this.get$_compareMembers()); |
3393 return values; | 3329 return values; |
3394 } | 3330 } |
3395 WorldGenerator.prototype._orderCollectionValues = function(collection) { | 3331 WorldGenerator.prototype._orderCollectionValues = function(collection) { |
3396 var values = ListFactory.ListFactory$from$factory(collection); | 3332 var values = ListFactory.ListFactory$from$factory(collection); |
3397 values.sort(this.get$_compareMembers()); | 3333 values.sort(this.get$_compareMembers()); |
3398 return values; | 3334 return values; |
3399 } | 3335 } |
3400 WorldGenerator.prototype._compareMembers = function(x, y) { | 3336 WorldGenerator.prototype._compareMembers = function(x, y) { |
3401 if (x.get$span() != null && y.get$span() != null) { | 3337 if (x.get$span() != null && y.get$span() != null) { |
3402 var spans = x.get$span().compareTo$1(y.get$span()); | 3338 var spans = x.get$span().compareTo(y.get$span()); |
3403 if (spans != (0)) return spans; | 3339 if (spans != (0)) return spans; |
3404 } | 3340 } |
3405 if (x.get$span() == null) return (1); | 3341 if (x.get$span() == null) return (1); |
3406 if (y.get$span() == null) return (-1); | 3342 if (y.get$span() == null) return (-1); |
3407 return x.get$name().compareTo$1(y.get$name()); | 3343 return x.get$name().compareTo(y.get$name()); |
3408 } | 3344 } |
3409 WorldGenerator.prototype.get$_compareMembers = function() { | 3345 WorldGenerator.prototype.get$_compareMembers = function() { |
3410 return this._compareMembers.bind(this); | 3346 return this._compareMembers.bind(this); |
3411 } | 3347 } |
3412 WorldGenerator.prototype.run$0 = WorldGenerator.prototype.run; | 3348 WorldGenerator.prototype.run$0 = WorldGenerator.prototype.run; |
3413 // ********** Code for MethodGenerator ************** | 3349 // ********** Code for MethodGenerator ************** |
3414 function MethodGenerator(method, enclosingMethod) { | 3350 function MethodGenerator(method, enclosingMethod) { |
3415 this.enclosingMethod = enclosingMethod; | 3351 this.enclosingMethod = enclosingMethod; |
3416 this.needsThis = false; | 3352 this.needsThis = false; |
3417 this.method = method; | 3353 this.method = method; |
3418 this.writer = new CodeWriter(); | 3354 this.writer = new CodeWriter(); |
3419 if (this.enclosingMethod != null) { | 3355 if (this.enclosingMethod != null) { |
3420 this._scope = new BlockScope(this, this.enclosingMethod._scope, this.method.
get$definition(), false); | 3356 this._scope = new BlockScope(this, this.enclosingMethod._scope, this.method.
get$definition(), false); |
3421 this.captures = new HashSetImplementation(); | 3357 this.captures = new HashSetImplementation(); |
3422 } | 3358 } |
3423 else { | 3359 else { |
3424 this._scope = new BlockScope(this, null, this.method.get$definition(), false
); | 3360 this._scope = new BlockScope(this, null, this.method.get$definition(), false
); |
3425 } | 3361 } |
3426 this._usedTemps = new HashSetImplementation(); | 3362 this._usedTemps = new HashSetImplementation(); |
3427 this._freeTemps = []; | 3363 this._freeTemps = []; |
3428 this.counters = $globals.world.counters; | 3364 this.counters = $globals.world.counters; |
3429 } | 3365 } |
3430 MethodGenerator.prototype.get$method = function() { return this.method; }; | 3366 MethodGenerator.prototype.get$method = function() { return this.method; }; |
3431 MethodGenerator.prototype.set$method = function(value) { return this.method = va
lue; }; | 3367 MethodGenerator.prototype.set$method = function(value) { return this.method = va
lue; }; |
| 3368 MethodGenerator.prototype.get$writer = function() { return this.writer; }; |
| 3369 MethodGenerator.prototype.set$writer = function(value) { return this.writer = va
lue; }; |
3432 MethodGenerator.prototype.get$_scope = function() { return this._scope; }; | 3370 MethodGenerator.prototype.get$_scope = function() { return this._scope; }; |
3433 MethodGenerator.prototype.set$_scope = function(value) { return this._scope = va
lue; }; | 3371 MethodGenerator.prototype.set$_scope = function(value) { return this._scope = va
lue; }; |
3434 MethodGenerator.prototype.get$enclosingMethod = function() { return this.enclosi
ngMethod; }; | 3372 MethodGenerator.prototype.get$enclosingMethod = function() { return this.enclosi
ngMethod; }; |
3435 MethodGenerator.prototype.set$enclosingMethod = function(value) { return this.en
closingMethod = value; }; | 3373 MethodGenerator.prototype.set$enclosingMethod = function(value) { return this.en
closingMethod = value; }; |
3436 MethodGenerator.prototype.get$needsThis = function() { return this.needsThis; }; | 3374 MethodGenerator.prototype.get$needsThis = function() { return this.needsThis; }; |
3437 MethodGenerator.prototype.set$needsThis = function(value) { return this.needsThi
s = value; }; | 3375 MethodGenerator.prototype.set$needsThis = function(value) { return this.needsThi
s = value; }; |
| 3376 MethodGenerator.prototype.get$_paramCode = function() { return this._paramCode;
}; |
| 3377 MethodGenerator.prototype.set$_paramCode = function(value) { return this._paramC
ode = value; }; |
| 3378 MethodGenerator.prototype.get$counters = function() { return this.counters; }; |
| 3379 MethodGenerator.prototype.set$counters = function(value) { return this.counters
= value; }; |
3438 MethodGenerator.prototype.get$library = function() { | 3380 MethodGenerator.prototype.get$library = function() { |
3439 return this.method.get$library(); | 3381 return this.method.get$library(); |
3440 } | 3382 } |
3441 MethodGenerator.prototype.findMembers = function(name) { | 3383 MethodGenerator.prototype.findMembers = function(name) { |
3442 return this.get$library()._findMembers(name); | 3384 return this.get$library()._findMembers(name); |
3443 } | 3385 } |
| 3386 MethodGenerator.prototype.get$needsCode = function() { |
| 3387 return true; |
| 3388 } |
| 3389 MethodGenerator.prototype.get$showWarnings = function() { |
| 3390 return false; |
| 3391 } |
3444 MethodGenerator.prototype.get$isClosure = function() { | 3392 MethodGenerator.prototype.get$isClosure = function() { |
3445 return (this.enclosingMethod != null); | 3393 return (this.enclosingMethod != null); |
3446 } | 3394 } |
3447 MethodGenerator.prototype.get$isStatic = function() { | 3395 MethodGenerator.prototype.get$isStatic = function() { |
3448 return this.method.get$isStatic(); | 3396 return this.method.get$isStatic(); |
3449 } | 3397 } |
3450 MethodGenerator.prototype.getTemp = function(value) { | 3398 MethodGenerator.prototype.getTemp = function(value) { |
3451 return value.get$needsTemp() ? this.forceTemp(value) : value; | 3399 return value.get$needsTemp() ? this.forceTemp(value) : value; |
3452 } | 3400 } |
3453 MethodGenerator.prototype.forceTemp = function(value) { | 3401 MethodGenerator.prototype.forceTemp = function(value) { |
(...skipping 12 matching lines...) Expand all Loading... |
3466 return v; | 3414 return v; |
3467 } | 3415 } |
3468 else { | 3416 else { |
3469 return new Value(v.get$type(), ("(" + tmp.get$code() + " = " + v.get$code()
+ ")"), v.span); | 3417 return new Value(v.get$type(), ("(" + tmp.get$code() + " = " + v.get$code()
+ ")"), v.span); |
3470 } | 3418 } |
3471 } | 3419 } |
3472 MethodGenerator.prototype.freeTemp = function(value) { | 3420 MethodGenerator.prototype.freeTemp = function(value) { |
3473 | 3421 |
3474 } | 3422 } |
3475 MethodGenerator.prototype.run = function() { | 3423 MethodGenerator.prototype.run = function() { |
3476 if (this.method.isGenerated) return; | |
3477 this.method.isGenerated = true; | |
3478 this.method.generator = this; | |
3479 var thisObject; | 3424 var thisObject; |
3480 if (this.method.get$isConstructor()) { | 3425 if (this.method.get$isConstructor()) { |
3481 thisObject = new ObjectValue(false, this.method.declaringType, this.method.g
et$span()); | 3426 thisObject = new ObjectValue(false, this.method.declaringType, this.method.g
et$span()); |
3482 thisObject.initFields$0(); | 3427 thisObject.initFields(); |
3483 } | 3428 } |
3484 else { | 3429 else { |
3485 thisObject = new Value(this.method.declaringType, "this", null); | 3430 thisObject = new Value(this.method.declaringType, "this", null); |
3486 } | 3431 } |
3487 var values = []; | 3432 var values = []; |
3488 var $$list = this.method.get$parameters(); | 3433 var $$list = this.method.get$parameters(); |
3489 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 3434 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3490 var p = $$list[$$i]; | 3435 var p = $$i.next(); |
3491 values.add$1(new Value(p.get$type(), p.get$name(), null)); | 3436 values.add(new Value(p.get$type(), p.get$name(), null)); |
3492 } | 3437 } |
3493 var args = new Arguments(null, values); | 3438 var args = new Arguments(null, values); |
3494 this.evalBody(thisObject, args); | 3439 this.evalBody(thisObject, args); |
3495 if (this.method.get$definition().get$nativeBody() != null) { | |
3496 this.writer = new CodeWriter(); | |
3497 if ($eq(this.method.get$definition().get$nativeBody(), "")) { | |
3498 this.method.generator = null; | |
3499 } | |
3500 else { | |
3501 this._paramCode = map(this.method.get$parameters(), (function (p) { | |
3502 return p.get$name(); | |
3503 }) | |
3504 ); | |
3505 this.writer.write(this.method.get$definition().get$nativeBody()); | |
3506 } | |
3507 } | |
3508 } | 3440 } |
3509 MethodGenerator.prototype.writeDefinition = function(defWriter, lambda) { | 3441 MethodGenerator.prototype.writeDefinition = function(defWriter, lambda) { |
3510 var paramCode = this._paramCode; | 3442 var paramCode = this._paramCode; |
3511 var names = null; | 3443 var names = null; |
3512 if (this.captures != null && this.captures.get$length() > (0)) { | 3444 if (this.captures != null && this.captures.get$length() > (0)) { |
3513 names = ListFactory.ListFactory$from$factory(this.captures); | 3445 names = ListFactory.ListFactory$from$factory(this.captures); |
3514 names.sort$1((function (x, y) { | 3446 names.sort((function (x, y) { |
3515 return x.compareTo$1(y); | 3447 return x.compareTo(y); |
3516 }) | 3448 }) |
3517 ); | 3449 ); |
3518 paramCode = ListFactory.ListFactory$from$factory(names); | 3450 paramCode = ListFactory.ListFactory$from$factory(names); |
3519 paramCode.addAll$1(this._paramCode); | 3451 paramCode.addAll(this._paramCode); |
3520 } | 3452 } |
3521 var _params = ("(" + Strings.join(this._paramCode, ", ") + ")"); | 3453 var _params = ("(" + Strings.join(this._paramCode, ", ") + ")"); |
3522 var params = ("(" + Strings.join(paramCode, ", ") + ")"); | 3454 var params = ("(" + Strings.join(paramCode, ", ") + ")"); |
3523 var suffix = "}"; | 3455 var suffix = "}"; |
3524 if (this.method.declaringType.get$isTop() && !this.get$isClosure()) { | 3456 if (this.method.declaringType.get$isTop() && !this.get$isClosure()) { |
3525 defWriter.enterBlock(("function " + this.method.get$jsname() + params + " {"
)); | 3457 defWriter.enterBlock(("function " + this.method.get$jsname() + params + " {"
)); |
3526 } | 3458 } |
3527 else if (this.get$isClosure()) { | 3459 else if (this.get$isClosure()) { |
3528 if (this.method.name == "") { | 3460 if (this.method.name == "") { |
3529 defWriter.enterBlock(("(function " + params + " {")); | 3461 defWriter.enterBlock(("(function " + params + " {")); |
3530 } | 3462 } |
3531 else if (names != null) { | 3463 else if ($ne(names)) { |
3532 if (lambda == null) { | 3464 if (lambda == null) { |
3533 defWriter.enterBlock(("var " + this.method.get$jsname() + " = (function"
+ params + " {")); | 3465 defWriter.enterBlock(("var " + this.method.get$jsname() + " = (function"
+ params + " {")); |
3534 } | 3466 } |
3535 else { | 3467 else { |
3536 defWriter.enterBlock(("(function " + this.method.get$jsname() + params +
" {")); | 3468 defWriter.enterBlock(("(function " + this.method.get$jsname() + params +
" {")); |
3537 } | 3469 } |
3538 } | 3470 } |
3539 else { | 3471 else { |
3540 defWriter.enterBlock(("function " + this.method.get$jsname() + params + "
{")); | 3472 defWriter.enterBlock(("function " + this.method.get$jsname() + params + "
{")); |
3541 } | 3473 } |
(...skipping 14 matching lines...) Expand all Loading... |
3556 } | 3488 } |
3557 else { | 3489 else { |
3558 suffix = $globals.world.gen._writePrototypePatch(this.method.declaringType,
this.method.get$jsname(), ("function" + _params + " {"), defWriter, false); | 3490 suffix = $globals.world.gen._writePrototypePatch(this.method.declaringType,
this.method.get$jsname(), ("function" + _params + " {"), defWriter, false); |
3559 } | 3491 } |
3560 if (this.needsThis) { | 3492 if (this.needsThis) { |
3561 defWriter.writeln("var $this = this; // closure support"); | 3493 defWriter.writeln("var $this = this; // closure support"); |
3562 } | 3494 } |
3563 if (this._usedTemps.get$length() > (0) || this._freeTemps.get$length() > (0))
{ | 3495 if (this._usedTemps.get$length() > (0) || this._freeTemps.get$length() > (0))
{ |
3564 this._freeTemps.addAll(this._usedTemps); | 3496 this._freeTemps.addAll(this._usedTemps); |
3565 this._freeTemps.sort((function (x, y) { | 3497 this._freeTemps.sort((function (x, y) { |
3566 return x.compareTo$1(y); | 3498 return x.compareTo(y); |
3567 }) | 3499 }) |
3568 ); | 3500 ); |
3569 defWriter.writeln(("var " + Strings.join(this._freeTemps, ", ") + ";")); | 3501 defWriter.writeln(("var " + Strings.join(this._freeTemps, ", ") + ";")); |
3570 } | 3502 } |
3571 defWriter.writeln(this.writer.get$text()); | 3503 defWriter.writeln(this.writer.get$text()); |
3572 if (names != null) { | 3504 if ($ne(names)) { |
3573 defWriter.exitBlock(("}).bind(null, " + Strings.join(names, ", ") + ")")); | 3505 defWriter.exitBlock(("}).bind(null, " + Strings.join(names, ", ") + ")")); |
3574 } | 3506 } |
3575 else if (this.get$isClosure() && this.method.name == "") { | 3507 else if (this.get$isClosure() && this.method.name == "") { |
3576 defWriter.exitBlock("})"); | 3508 defWriter.exitBlock("})"); |
3577 } | 3509 } |
3578 else { | 3510 else { |
3579 defWriter.exitBlock(suffix); | 3511 defWriter.exitBlock(suffix); |
3580 } | 3512 } |
3581 if (this.method.get$isConstructor() && this.method.get$constructorName() != ""
) { | 3513 if (this.method.get$isConstructor() && this.method.get$constructorName() != ""
) { |
3582 defWriter.writeln(("" + this.method.declaringType.get$jsname() + "." + this.
method.get$constructorName() + "$ctor.prototype = ") + ("" + this.method.declari
ngType.get$jsname() + ".prototype;")); | 3514 defWriter.writeln($add(("" + this.method.declaringType.get$jsname() + "." +
this.method.get$constructorName() + "$ctor.prototype = "), ("" + this.method.dec
laringType.get$jsname() + ".prototype;"))); |
3583 } | 3515 } |
3584 this._provideOptionalParamInfo(defWriter); | 3516 this._provideOptionalParamInfo(defWriter); |
3585 if ((this.method instanceof MethodMember)) { | 3517 if ((this.method instanceof MethodMember)) { |
3586 MethodGenerator._maybeGenerateBoundGetter(this.method, defWriter); | 3518 MethodGenerator._maybeGenerateBoundGetter(this.method, defWriter); |
3587 } | 3519 } |
3588 } | 3520 } |
3589 MethodGenerator._maybeGenerateBoundGetter = function(m, defWriter) { | 3521 MethodGenerator._maybeGenerateBoundGetter = function(m, defWriter) { |
3590 if (m._providePropertySyntax) { | 3522 if (m._providePropertySyntax) { |
3591 var suffix = $globals.world.gen._writePrototypePatch(m.declaringType, "get$"
+ m.get$jsname(), "function() {", defWriter, false); | 3523 var suffix = $globals.world.gen._writePrototypePatch(m.declaringType, $add("
get$", m.get$jsname()), "function() {", defWriter, false); |
3592 defWriter.writeln(("return this." + m.get$jsname() + ".bind(this);")); | 3524 defWriter.writeln(("return this." + m.get$jsname() + ".bind(this);")); |
3593 defWriter.exitBlock(suffix); | 3525 defWriter.exitBlock(suffix); |
3594 if (m._provideFieldSyntax) { | |
3595 $globals.world.internalError(("bound \"" + m.name + "\" accessed with fiel
d syntax"), m.definition.span); | |
3596 } | |
3597 } | 3526 } |
3598 } | 3527 } |
3599 MethodGenerator.prototype._provideOptionalParamInfo = function(defWriter) { | 3528 MethodGenerator.prototype._provideOptionalParamInfo = function(defWriter) { |
3600 if ((this.method instanceof MethodMember)) { | 3529 if ((this.method instanceof MethodMember)) { |
3601 var meth = this.method; | 3530 var meth = this.method; |
3602 if (meth._provideOptionalParamInfo) { | 3531 if (meth._provideOptionalParamInfo) { |
3603 var optNames = []; | 3532 var optNames = []; |
3604 var optValues = []; | 3533 var optValues = []; |
3605 meth.genParameterValues(); | 3534 meth.genParameterValues(this); |
3606 var $$list = meth.parameters; | 3535 var $$list = meth.parameters; |
3607 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 3536 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3608 var param = $$list[$$i]; | 3537 var param = $$i.next(); |
3609 if (param.get$isOptional()) { | 3538 if (param.get$isOptional()) { |
3610 optNames.add$1(param.get$name()); | 3539 optNames.add(param.get$name()); |
3611 optValues.add$1(MethodGenerator._escapeString(param.get$value().get$co
de())); | 3540 optValues.add(MethodGenerator._escapeString(param.get$value().get$code
())); |
3612 } | 3541 } |
3613 } | 3542 } |
3614 if (optNames.get$length() > (0)) { | 3543 if (optNames.get$length() > (0)) { |
3615 var start = ""; | 3544 var start = ""; |
3616 if (meth.isStatic) { | 3545 if (meth.isStatic) { |
3617 if (!meth.declaringType.get$isTop()) { | 3546 if (!meth.declaringType.get$isTop()) { |
3618 start = meth.declaringType.get$jsname() + "."; | 3547 start = $add(meth.declaringType.get$jsname(), "."); |
3619 } | 3548 } |
3620 } | 3549 } |
3621 else { | 3550 else { |
3622 start = meth.declaringType.get$jsname() + ".prototype."; | 3551 start = $add(meth.declaringType.get$jsname(), ".prototype."); |
3623 } | 3552 } |
3624 optNames.addAll$1(optValues); | 3553 optNames.addAll(optValues); |
3625 var optional = "['" + Strings.join(optNames, "', '") + "']"; | 3554 var optional = $add($add("['", Strings.join(optNames, "', '")), "']"); |
3626 defWriter.writeln(("" + start + meth.get$jsname() + ".$optional = " + op
tional)); | 3555 defWriter.writeln(("" + start + meth.get$jsname() + ".$optional = " + op
tional)); |
3627 } | 3556 } |
3628 } | 3557 } |
3629 } | 3558 } |
3630 } | 3559 } |
3631 MethodGenerator.prototype._initField = function(newObject, name, value, span) { | 3560 MethodGenerator.prototype._initField = function(newObject, name, value, span) { |
3632 var field = this.method.declaringType.getMember(name); | 3561 var field = this.method.declaringType.getMember(name); |
3633 if (field == null) { | 3562 if ($eq(field)) { |
3634 $globals.world.error("bad initializer - no matching field", span); | 3563 $globals.world.error("bad initializer - no matching field", span); |
3635 } | 3564 } |
3636 if (!field.get$isField()) { | 3565 if (!field.get$isField()) { |
3637 $globals.world.error(("\"this." + name + "\" does not refer to a field"), sp
an); | 3566 $globals.world.error(("\"this." + name + "\" does not refer to a field"), sp
an); |
3638 } | 3567 } |
3639 return newObject.setField(field, value, true); | 3568 return newObject.setField(field, value, true); |
3640 } | 3569 } |
3641 MethodGenerator.prototype.evalBody = function(newObject, args) { | 3570 MethodGenerator.prototype.evalBody = function(newObject, args) { |
3642 var fieldsSet = false; | 3571 var fieldsSet = false; |
3643 if (this.method.get$isNative() && this.method.get$isConstructor() && (newObjec
t instanceof ObjectValue)) { | 3572 if (this.method.get$isNative() && this.method.get$isConstructor() && (newObjec
t instanceof ObjectValue)) { |
3644 newObject.get$dynamic().set$seenNativeInitializer(true); | 3573 newObject.get$dynamic().set$seenNativeInitializer(true); |
3645 } | 3574 } |
3646 this._paramCode = []; | 3575 this._paramCode = []; |
3647 for (var i = (0); | 3576 for (var i = (0); |
3648 i < this.method.get$parameters().get$length(); i++) { | 3577 i < this.method.get$parameters().get$length(); i++) { |
3649 var p = this.method.get$parameters()[i]; | 3578 var p = this.method.get$parameters()[i]; |
3650 var currentArg = null; | 3579 var currentArg = null; |
3651 if (i < args.get$bareCount()) { | 3580 if (i < args.get$bareCount()) { |
3652 currentArg = args.values[i]; | 3581 currentArg = args.values.$index(i); |
3653 } | 3582 } |
3654 else { | 3583 else { |
3655 currentArg = args.getValue(p.get$name()); | 3584 currentArg = args.getValue(p.get$name()); |
3656 if (currentArg == null) { | 3585 if (currentArg == null) { |
3657 p.genValue$2(this.method, this.method.generator); | 3586 p.genValue(this.method, this); |
3658 currentArg = p.get$value(); | 3587 currentArg = p.get$value(); |
3659 } | 3588 } |
3660 } | 3589 } |
3661 if (p.get$isInitializer()) { | 3590 if (p.get$isInitializer()) { |
3662 this._paramCode.add(p.get$name()); | 3591 this._paramCode.add(p.get$name()); |
3663 fieldsSet = true; | 3592 fieldsSet = true; |
3664 this._initField(newObject, p.get$name(), currentArg, p.get$definition().ge
t$span()); | 3593 this._initField(newObject, p.get$name(), currentArg, p.get$definition().ge
t$span()); |
3665 } | 3594 } |
3666 else { | 3595 else { |
3667 var paramValue = this._scope.declareParameter(p); | 3596 var paramValue = this._scope.declareParameter(p); |
3668 this._paramCode.add(paramValue.get$code()); | 3597 this._paramCode.add(paramValue.get$code()); |
3669 if (newObject != null && newObject.get$isConst()) { | 3598 if (newObject != null && newObject.get$isConst()) { |
3670 this._scope.assign(p.get$name(), currentArg.convertTo(this, p.get$type()
, false)); | 3599 this._scope.assign(p.get$name(), currentArg.convertTo(this, p.get$type()
)); |
3671 } | 3600 } |
3672 } | 3601 } |
3673 } | 3602 } |
3674 var initializerCall = null; | 3603 var initializerCall = null; |
3675 var declaredInitializers = this.method.get$definition().get$initializers(); | 3604 var declaredInitializers = this.method.get$definition().get$dynamic().get$init
ializers(); |
3676 if (declaredInitializers != null) { | 3605 if ($ne(declaredInitializers)) { |
3677 for (var $$i = declaredInitializers.iterator$0(); $$i.hasNext$0(); ) { | 3606 for (var $$i = declaredInitializers.iterator(); $$i.hasNext(); ) { |
3678 var init = $$i.next$0(); | 3607 var init = $$i.next(); |
3679 if ((init instanceof CallExpression)) { | 3608 if ((init instanceof CallExpression)) { |
3680 if (initializerCall != null) { | 3609 if ($ne(initializerCall)) { |
3681 $globals.world.error("only one initializer redirecting call is allowed
", init.get$span()); | 3610 $globals.world.error("only one initializer redirecting call is allowed
", init.get$span()); |
3682 } | 3611 } |
3683 initializerCall = init; | 3612 initializerCall = init; |
3684 } | 3613 } |
3685 else if ((init instanceof BinaryExpression) && TokenKind.kindFromAssign(in
it.get$op().get$kind()) == (0)) { | 3614 else if ((init instanceof BinaryExpression) && TokenKind.kindFromAssign(in
it.get$op().kind) == (0)) { |
3686 var left = init.get$x(); | 3615 var left = init.get$x(); |
3687 if (!((left instanceof DotExpression) && (left.get$self() instanceof Thi
sExpression) || (left instanceof VarExpression))) { | 3616 if (!((left instanceof DotExpression) && (left.get$self() instanceof Thi
sExpression) || (left instanceof VarExpression))) { |
3688 $globals.world.error("invalid left side of initializer", left.get$span
()); | 3617 $globals.world.error("invalid left side of initializer", left.get$span
()); |
3689 continue; | 3618 continue; |
3690 } | 3619 } |
3691 var initValue = this.visitValue(init.get$y()); | 3620 var initValue = this.visitValue(init.get$y()); |
3692 fieldsSet = true; | 3621 fieldsSet = true; |
3693 this._initField(newObject, left.get$name().get$name(), initValue, left.g
et$span()); | 3622 this._initField(newObject, left.get$name().get$name(), initValue, left.g
et$span()); |
3694 } | 3623 } |
3695 else { | 3624 else { |
3696 $globals.world.error("invalid initializer", init.get$span()); | 3625 $globals.world.error("invalid initializer", init.get$span()); |
3697 } | 3626 } |
3698 } | 3627 } |
3699 } | 3628 } |
3700 if (this.method.get$isConstructor() && initializerCall == null && !this.method
.get$isNative()) { | 3629 if (this.method.get$isConstructor() && $eq(initializerCall) && !this.method.ge
t$isNative()) { |
3701 var parentType = this.method.declaringType.get$parent(); | 3630 var parentType = this.method.declaringType.get$parent(); |
3702 if (parentType != null && !parentType.get$isObject()) { | 3631 if ($ne(parentType) && !parentType.get$isObject()) { |
3703 initializerCall = new CallExpression(new SuperExpression(this.method.get$s
pan()), [], this.method.get$span()); | 3632 initializerCall = new CallExpression(new SuperExpression(this.method.get$s
pan()), [], this.method.get$span()); |
3704 } | 3633 } |
3705 } | 3634 } |
3706 if (this.method.get$isConstructor() && (newObject instanceof ObjectValue)) { | 3635 if (this.method.get$isConstructor() && (newObject instanceof ObjectValue)) { |
3707 var fields = newObject.get$dynamic().get$fields(); | 3636 var fields = newObject.get$dynamic().get$fields(); |
3708 var $$list = fields.getKeys$0(); | 3637 var $$list = fields.getKeys(); |
3709 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 3638 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3710 var field = $$i.next$0(); | 3639 var field = $$i.next(); |
3711 var value = fields.$index(field); | 3640 var value = fields.$index(field); |
3712 if (value != null) { | 3641 if (value != null) { |
3713 this.writer.writeln(("this." + field.get$jsname() + " = " + value.get$co
de() + ";")); | 3642 this.writer.writeln(("this." + field.get$jsname() + " = " + value.get$co
de() + ";")); |
3714 } | 3643 } |
3715 } | 3644 } |
3716 } | 3645 } |
3717 if (initializerCall != null) { | 3646 if ($ne(initializerCall)) { |
3718 this.evalInitializerCall(newObject, initializerCall, fieldsSet); | 3647 this.evalInitializerCall(newObject, initializerCall, fieldsSet); |
3719 } | 3648 } |
3720 if (this.method.get$isConstructor() && newObject != null && newObject.get$isCo
nst()) { | 3649 if (this.method.get$isConstructor() && newObject != null && newObject.get$isCo
nst()) { |
3721 newObject.validateInitialized(this.method.get$span()); | 3650 newObject.validateInitialized(this.method.get$span()); |
3722 } | 3651 } |
3723 else if (this.method.get$isConstructor()) { | 3652 else if (this.method.get$isConstructor()) { |
3724 var fields = newObject.get$dynamic().get$fields(); | 3653 var fields = newObject.get$dynamic().get$fields(); |
3725 var $$list = fields.getKeys$0(); | 3654 var $$list = fields.getKeys(); |
3726 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 3655 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3727 var field = $$i.next$0(); | 3656 var field = $$i.next(); |
3728 var value = fields.$index(field); | 3657 var value = fields.$index(field); |
3729 if (value == null && field.get$isFinal() && $eq(field.get$declaringType(),
this.method.declaringType) && !newObject.get$dynamic().get$seenNativeInitialize
r()) { | 3658 if (value == null && field.get$isFinal() && $eq(field.get$declaringType(),
this.method.declaringType) && !newObject.get$dynamic().get$seenNativeInitialize
r()) { |
3730 $globals.world.error(("uninitialized final field \"" + field.get$name()
+ "\""), field.get$span(), this.method.get$span()); | 3659 $globals.world.error(("uninitialized final field \"" + field.get$name()
+ "\""), field.get$span(), this.method.get$span()); |
3731 } | 3660 } |
3732 } | 3661 } |
3733 } | 3662 } |
3734 var body = this.method.get$definition().get$body(); | 3663 var body = this.method.get$definition().get$dynamic().get$body(); |
3735 if (body == null) { | 3664 if (body == null) { |
3736 if (!this.method.get$isConstructor() && !this.method.get$isNative()) { | 3665 if (!this.method.get$isConstructor() && !this.method.get$isNative()) { |
3737 $globals.world.error(("unexpected empty body for " + this.method.name), th
is.method.get$definition().get$span()); | 3666 $globals.world.error(("unexpected empty body for " + this.method.name), th
is.method.get$definition().get$span()); |
3738 } | 3667 } |
3739 } | 3668 } |
3740 else { | 3669 else { |
3741 this.visitStatementsInBlock(body); | 3670 this.visitStatementsInBlock(body); |
3742 } | 3671 } |
3743 } | 3672 } |
3744 MethodGenerator.prototype.evalInitializerCall = function(newObject, node, fields
Set) { | 3673 MethodGenerator.prototype.evalInitializerCall = function(newObject, node, fields
Set) { |
(...skipping 13 matching lines...) Expand all Loading... |
3758 else if ((targetExp instanceof ThisExpression)) { | 3687 else if ((targetExp instanceof ThisExpression)) { |
3759 targetType = this.method.declaringType; | 3688 targetType = this.method.declaringType; |
3760 target = this._makeThisValue(targetExp); | 3689 target = this._makeThisValue(targetExp); |
3761 if (fieldsSet) { | 3690 if (fieldsSet) { |
3762 $globals.world.error("no initialization allowed with redirecting construct
or", node.span); | 3691 $globals.world.error("no initialization allowed with redirecting construct
or", node.span); |
3763 } | 3692 } |
3764 } | 3693 } |
3765 else { | 3694 else { |
3766 $globals.world.error("bad call in initializers", node.span); | 3695 $globals.world.error("bad call in initializers", node.span); |
3767 } | 3696 } |
3768 var m = targetType.getConstructor$1(contructorName); | 3697 var m = targetType.getConstructor(contructorName); |
3769 if (m == null) { | 3698 if ($eq(m)) { |
3770 $globals.world.error(("no matching constructor for " + targetType.name), nod
e.span); | 3699 $globals.world.error(("no matching constructor for " + targetType.name), nod
e.span); |
3771 } | 3700 } |
3772 this.method.set$initDelegate(m); | 3701 this.method.set$initDelegate(m); |
3773 var other = m; | 3702 var other = m; |
3774 while (other != null) { | 3703 while ($ne(other)) { |
3775 if ($eq(other, this.method)) { | 3704 if ($eq(other, this.method)) { |
3776 $globals.world.error("initialization cycle", node.span); | 3705 $globals.world.error("initialization cycle", node.span); |
3777 break; | 3706 break; |
3778 } | 3707 } |
3779 other = other.get$initDelegate(); | 3708 other = other.get$initDelegate(); |
3780 } | 3709 } |
3781 var newArgs = this._makeArgs(node.arguments); | 3710 var newArgs = this._makeArgs(node.arguments); |
3782 $globals.world.gen.genMethod(m); | 3711 $globals.world.gen.genMethod(m); |
3783 m._evalConstConstructor$2(newObject, newArgs); | 3712 m._evalConstConstructor(newObject, newArgs); |
3784 if (!newObject.isConst) { | 3713 if (!newObject.isConst) { |
3785 var value = m.invoke$4(this, node, target, newArgs); | 3714 var value = m.invoke(this, node, target, newArgs); |
3786 if ($ne(target.get$type(), $globals.world.objectType)) { | 3715 if ($ne(target.get$type(), $globals.world.objectType)) { |
3787 this.writer.writeln(("" + value.get$code() + ";")); | 3716 this.writer.writeln(("" + value.get$code() + ";")); |
3788 } | 3717 } |
3789 } | 3718 } |
3790 } | 3719 } |
3791 MethodGenerator.prototype._makeArgs = function(arguments) { | 3720 MethodGenerator.prototype._makeArgs = function(arguments) { |
3792 var args = []; | 3721 var args = []; |
3793 var seenLabel = false; | 3722 var seenLabel = false; |
3794 for (var $$i = 0;$$i < arguments.get$length(); $$i++) { | 3723 for (var $$i = arguments.iterator(); $$i.hasNext(); ) { |
3795 var arg = arguments[$$i]; | 3724 var arg = $$i.next(); |
3796 if (arg.get$label() != null) { | 3725 if (arg.get$label() != null) { |
3797 seenLabel = true; | 3726 seenLabel = true; |
3798 } | 3727 } |
3799 else if (seenLabel) { | 3728 else if (seenLabel) { |
3800 $globals.world.error("bare argument can not follow named arguments", arg.g
et$span()); | 3729 $globals.world.error("bare argument can not follow named arguments", arg.g
et$span()); |
3801 } | 3730 } |
3802 args.add$1(this.visitValue(arg.get$value())); | 3731 args.add(this.visitValue(arg.get$value())); |
3803 } | 3732 } |
3804 return new Arguments(arguments, args); | 3733 return new Arguments(arguments, args); |
3805 } | 3734 } |
3806 MethodGenerator.prototype._invokeNative = function(name, arguments) { | 3735 MethodGenerator.prototype._invokeNative = function(name, arguments) { |
3807 var args = Arguments.get$EMPTY(); | 3736 var args = Arguments.get$EMPTY(); |
3808 if (arguments.get$length() > (0)) { | 3737 if (arguments.get$length() > (0)) { |
3809 args = new Arguments(null, arguments); | 3738 args = new Arguments(null, arguments); |
3810 } | 3739 } |
3811 var method = $globals.world.corelib.topType.members.$index(name); | 3740 var method = $globals.world.corelib.topType.members.$index(name); |
3812 return method.invoke$4(this, method.get$definition(), new Value($globals.world
.corelib.topType, null, null), args); | 3741 return method.invoke(this, method.get$definition(), new Value($globals.world.c
orelib.topType, null, null), args); |
3813 } | 3742 } |
3814 MethodGenerator._escapeString = function(text) { | 3743 MethodGenerator._escapeString = function(text) { |
3815 return text.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"").replaceAll("\n",
"\\n").replaceAll("\r", "\\r"); | 3744 return text.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"").replaceAll("\n",
"\\n").replaceAll("\r", "\\r"); |
3816 } | 3745 } |
3817 MethodGenerator.prototype.visitStatementsInBlock = function(body) { | 3746 MethodGenerator.prototype.visitStatementsInBlock = function(body) { |
3818 if ((body instanceof BlockStatement)) { | 3747 if ((body instanceof BlockStatement)) { |
3819 var block = body; | 3748 var block = body; |
3820 var $$list = block.body; | 3749 var $$list = block.body; |
3821 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 3750 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
3822 var stmt = $$list[$$i]; | 3751 var stmt = $$i.next(); |
3823 stmt.visit$1(this); | 3752 stmt.visit(this); |
3824 } | 3753 } |
3825 } | 3754 } |
3826 else { | 3755 else { |
3827 if (body != null) body.visit(this); | 3756 if (body != null) body.visit(this); |
3828 } | 3757 } |
3829 return false; | 3758 return false; |
3830 } | 3759 } |
3831 MethodGenerator.prototype._pushBlock = function(node, reentrant) { | 3760 MethodGenerator.prototype._pushBlock = function(node, reentrant) { |
3832 this._scope = new BlockScope(this, this._scope, node, reentrant); | 3761 this._scope = new BlockScope(this, this._scope, node, reentrant); |
3833 } | 3762 } |
3834 MethodGenerator.prototype._popBlock = function(node) { | 3763 MethodGenerator.prototype._popBlock = function(node) { |
3835 if (this._scope.node != node) { | 3764 if (this._scope.node != node) { |
3836 function spanOf(n) { | 3765 function spanOf(n) { |
3837 return n != null ? n.get$span() : null; | 3766 return $ne(n) ? n.get$span() : null; |
3838 } | 3767 } |
3839 $globals.world.internalError(("scope mismatch. Trying to pop \"" + node + "\
" but found ") + (" \"" + this._scope.node + "\""), spanOf.call$1(node), spanOf.
call$1(this._scope.node)); | 3768 $globals.world.internalError($add(("scope mismatch. Trying to pop \"" + node
+ "\" but found "), (" \"" + this._scope.node + "\"")), spanOf(node), spanOf(th
is._scope.node)); |
3840 } | 3769 } |
3841 this._scope = this._scope.parent; | 3770 this._scope = this._scope.parent; |
3842 } | 3771 } |
3843 MethodGenerator.prototype._visitLoop = function(node, visitBody) { | 3772 MethodGenerator.prototype._visitLoop = function(node, visitBody) { |
3844 if (this._scope.inferTypes) { | 3773 if (this._scope.inferTypes) { |
3845 this._loopFixedPoint(node, visitBody); | 3774 this._loopFixedPoint(node, visitBody); |
3846 } | 3775 } |
3847 else { | 3776 else { |
3848 this._pushBlock(node, true); | 3777 this._pushBlock(node, true); |
3849 visitBody.call$0(); | 3778 visitBody(); |
3850 this._popBlock(node); | 3779 this._popBlock(node); |
3851 } | 3780 } |
3852 } | 3781 } |
3853 MethodGenerator.prototype._loopFixedPoint = function(node, visitBody) { | 3782 MethodGenerator.prototype._loopFixedPoint = function(node, visitBody) { |
3854 var savedCounters = this.counters; | 3783 var savedCounters = this.counters; |
3855 var savedWriter = this.writer; | 3784 var savedWriter = this.writer; |
3856 var tries = (0); | 3785 var tries = (0); |
3857 var startScope = this._scope.snapshot(); | 3786 var startScope = this._scope.snapshot(); |
3858 var s = startScope; | 3787 var s = startScope; |
3859 while (true) { | 3788 while (true) { |
3860 this.writer = new CodeWriter(); | 3789 this.writer = new CodeWriter(); |
3861 this.counters = new CounterLog(); | 3790 this.counters = new CounterLog(); |
3862 this._pushBlock(node, true); | 3791 this._pushBlock(node, true); |
3863 if (tries++ >= $globals.options.maxInferenceIterations) { | 3792 if (tries++ >= $globals.options.maxInferenceIterations) { |
3864 this._scope.inferTypes = false; | 3793 this._scope.inferTypes = false; |
3865 } | 3794 } |
3866 visitBody.call$0(); | 3795 visitBody(); |
3867 this._popBlock(node); | 3796 this._popBlock(node); |
3868 if (!this._scope.inferTypes || !this._scope.unionWith(s)) { | 3797 if (!this._scope.inferTypes || !this._scope.unionWith(s)) { |
3869 break; | 3798 break; |
3870 } | 3799 } |
3871 s = this._scope.snapshot(); | 3800 s = this._scope.snapshot(); |
3872 } | 3801 } |
3873 savedWriter.write$1(this.writer.get$text()); | 3802 savedWriter.write$1(this.writer.get$text()); |
3874 this.writer = savedWriter; | 3803 this.writer = savedWriter; |
3875 savedCounters.add$1(this.counters); | 3804 savedCounters.add(this.counters); |
3876 this.counters = savedCounters; | 3805 this.counters = savedCounters; |
3877 } | 3806 } |
3878 MethodGenerator.prototype._makeLambdaMethod = function(name, func) { | 3807 MethodGenerator.prototype._makeLambdaMethod = function(name, func) { |
3879 var meth = new MethodMember(name, this.method.declaringType, func); | 3808 var meth = new MethodMember(name, this.method.declaringType, func); |
3880 meth.set$isLambda(true); | 3809 meth.set$isLambda(true); |
3881 meth.set$enclosingElement(this.method); | 3810 meth.set$enclosingElement(this.method); |
3882 meth.resolve$0(); | 3811 meth.set$_methodData(new MethodData(meth, this)); |
| 3812 meth.resolve(); |
3883 return meth; | 3813 return meth; |
3884 } | 3814 } |
3885 MethodGenerator.prototype.visitBool = function(node) { | 3815 MethodGenerator.prototype.visitBool = function(node) { |
3886 return this.visitValue(node).convertTo$2(this, $globals.world.nonNullBool); | 3816 return this.visitValue(node).convertTo(this, $globals.world.nonNullBool); |
3887 } | 3817 } |
3888 MethodGenerator.prototype.visitValue = function(node) { | 3818 MethodGenerator.prototype.visitValue = function(node) { |
3889 if (node == null) return null; | 3819 if (node == null) return null; |
3890 var value = node.visit(this); | 3820 var value = node.visit(this); |
3891 value.checkFirstClass$1(node.span); | 3821 value.checkFirstClass(node.span); |
3892 return value; | 3822 return value; |
3893 } | 3823 } |
3894 MethodGenerator.prototype.visitTypedValue = function(node, expectedType) { | 3824 MethodGenerator.prototype.visitTypedValue = function(node, expectedType) { |
3895 var val = this.visitValue(node); | 3825 var val = this.visitValue(node); |
3896 return expectedType == null ? val : val.convertTo$2(this, expectedType); | 3826 return expectedType == null ? val : val.convertTo(this, expectedType); |
3897 } | 3827 } |
3898 MethodGenerator.prototype.visitVoid = function(node) { | 3828 MethodGenerator.prototype.visitVoid = function(node) { |
3899 if ((node instanceof PostfixExpression)) { | 3829 if ((node instanceof PostfixExpression)) { |
3900 var value = this.visitPostfixExpression(node, true); | 3830 var value = this.visitPostfixExpression(node, true); |
3901 value.checkFirstClass$1(node.span); | 3831 value.checkFirstClass(node.span); |
3902 return value; | 3832 return value; |
3903 } | 3833 } |
3904 else if ((node instanceof BinaryExpression)) { | 3834 else if ((node instanceof BinaryExpression)) { |
3905 var value = this.visitBinaryExpression(node, true); | 3835 var value = this.visitBinaryExpression(node, true); |
3906 value.checkFirstClass$1(node.span); | 3836 value.checkFirstClass(node.span); |
3907 return value; | 3837 return value; |
3908 } | 3838 } |
3909 return this.visitValue(node); | 3839 return this.visitValue(node); |
3910 } | 3840 } |
3911 MethodGenerator.prototype.visitDietStatement = function(node) { | 3841 MethodGenerator.prototype.visitDietStatement = function(node) { |
3912 var parser = new Parser(node.span.file, false, false, false, node.span.start); | 3842 var parser = new Parser(node.span.file, false, false, false, node.span.start); |
3913 this.visitStatementsInBlock(parser.block$0()); | 3843 this.visitStatementsInBlock(parser.block()); |
3914 return false; | 3844 return false; |
3915 } | 3845 } |
3916 MethodGenerator.prototype.visitVariableDefinition = function(node) { | 3846 MethodGenerator.prototype.visitVariableDefinition = function(node) { |
3917 var isFinal = false; | 3847 var isFinal = false; |
3918 if (node.modifiers != null && $eq(node.modifiers[(0)].get$kind(), (99))) { | 3848 if (node.modifiers != null && node.modifiers[(0)].kind == (99)) { |
3919 isFinal = true; | 3849 isFinal = true; |
3920 } | 3850 } |
3921 this.writer.write("var "); | 3851 this.writer.write("var "); |
3922 var type = this.method.resolveType$2(node.type, false); | 3852 var type = this.method.resolveType(node.type, false, true); |
3923 for (var i = (0); | 3853 for (var i = (0); |
3924 i < node.names.get$length(); i++) { | 3854 i < node.names.get$length(); i++) { |
3925 if (i > (0)) { | 3855 if (i > (0)) { |
3926 this.writer.write(", "); | 3856 this.writer.write(", "); |
3927 } | 3857 } |
3928 var name = node.names[i].get$name(); | 3858 var name = node.names[i].name; |
3929 var value = this.visitValue(node.values[i]); | 3859 var value = this.visitValue(node.values[i]); |
3930 if (isFinal && value == null) { | 3860 if (isFinal && $eq(value)) { |
3931 $globals.world.error("no value specified for final variable", node.span); | 3861 $globals.world.error("no value specified for final variable", node.span); |
3932 } | 3862 } |
3933 var val = this._scope.create(name, type, node.names[i].get$span(), isFinal,
false); | 3863 var val = this._scope.create(name, type, node.names[i].span, isFinal, false)
; |
3934 if (value == null) { | 3864 if ($eq(value)) { |
3935 if (this._scope.reentrant) { | 3865 if (this._scope.reentrant) { |
3936 this.writer.write(("" + val.get$code() + " = null")); | 3866 this.writer.write(("" + val.get$code() + " = null")); |
3937 } | 3867 } |
3938 else { | 3868 else { |
3939 this.writer.write(("" + val.get$code())); | 3869 this.writer.write(("" + val.get$code())); |
3940 } | 3870 } |
3941 } | 3871 } |
3942 else { | 3872 else { |
3943 value = value.convertTo$2(this, type); | 3873 value = value.convertTo(this, type); |
3944 this._scope.inferAssign(name, value); | 3874 this._scope.inferAssign(name, value); |
3945 this.writer.write(("" + val.get$code() + " = " + value.get$code())); | 3875 this.writer.write(("" + val.get$code() + " = " + value.get$code())); |
3946 } | 3876 } |
3947 } | 3877 } |
3948 this.writer.writeln(";"); | 3878 this.writer.writeln(";"); |
3949 return false; | 3879 return false; |
3950 } | 3880 } |
3951 MethodGenerator.prototype.visitFunctionDefinition = function(node) { | 3881 MethodGenerator.prototype.visitFunctionDefinition = function(node) { |
3952 var meth = this._makeLambdaMethod(node.name.name, node); | 3882 var meth = this._makeLambdaMethod(node.name.name, node); |
3953 var funcValue = this._scope.create(meth.get$name(), meth.get$functionType(), t
his.method.get$definition().get$span(), true, false); | 3883 var funcValue = this._scope.create(meth.get$name(), meth.get$functionType(), t
his.method.get$definition().get$span(), true, false); |
3954 $globals.world.gen.genMethod(meth, this); | 3884 meth.get$methodData().createFunction(this.writer); |
3955 meth.get$generator().writeDefinition$2(this.writer); | |
3956 return false; | 3885 return false; |
3957 } | 3886 } |
3958 MethodGenerator.prototype.visitReturnStatement = function(node) { | 3887 MethodGenerator.prototype.visitReturnStatement = function(node) { |
3959 if (node.value == null) { | 3888 if (node.value == null) { |
3960 this.writer.writeln("return;"); | 3889 this.writer.writeln("return;"); |
3961 } | 3890 } |
3962 else { | 3891 else { |
3963 if (this.method.get$isConstructor()) { | 3892 if (this.method.get$isConstructor()) { |
3964 $globals.world.error("return of value not allowed from constructor", node.
span); | 3893 $globals.world.error("return of value not allowed from constructor", node.
span); |
3965 } | 3894 } |
3966 var value = this.visitTypedValue(node.value, this.method.get$returnType()); | 3895 var value = this.visitTypedValue(node.value, this.method.get$returnType()); |
3967 this.writer.writeln(("return " + value.get$code() + ";")); | 3896 this.writer.writeln(("return " + value.get$code() + ";")); |
3968 } | 3897 } |
3969 return true; | 3898 return true; |
3970 } | 3899 } |
3971 MethodGenerator.prototype.visitThrowStatement = function(node) { | 3900 MethodGenerator.prototype.visitThrowStatement = function(node) { |
3972 if (node.value != null) { | 3901 if (node.value != null) { |
3973 var value = this.visitValue(node.value); | 3902 var value = this.visitValue(node.value); |
3974 value.invoke$4(this, "toString", node, Arguments.get$EMPTY()); | 3903 value.invoke(this, "toString", node, Arguments.get$EMPTY()); |
3975 this.writer.writeln(("$throw(" + value.get$code() + ");")); | 3904 this.writer.writeln(("$throw(" + value.get$code() + ");")); |
3976 $globals.world.gen.corejs.useThrow = true; | 3905 $globals.world.gen.corejs.useThrow = true; |
3977 } | 3906 } |
3978 else { | 3907 else { |
3979 var rethrow = this._scope.getRethrow(); | 3908 var rethrow = this._scope.getRethrow(); |
3980 if (rethrow == null) { | 3909 if ($eq(rethrow)) { |
3981 $globals.world.error("rethrow outside of catch", node.span); | 3910 $globals.world.error("rethrow outside of catch", node.span); |
3982 } | 3911 } |
3983 else { | 3912 else { |
3984 this.writer.writeln(("throw " + rethrow + ";")); | 3913 this.writer.writeln(("throw " + rethrow + ";")); |
3985 } | 3914 } |
3986 } | 3915 } |
3987 return true; | 3916 return true; |
3988 } | 3917 } |
3989 MethodGenerator.prototype.visitAssertStatement = function(node) { | 3918 MethodGenerator.prototype.visitAssertStatement = function(node) { |
3990 var test = this.visitValue(node.test); | 3919 var test = this.visitValue(node.test); |
3991 if ($globals.options.enableAsserts) { | 3920 if ($globals.options.enableAsserts) { |
3992 var span = node.test.span; | 3921 var span = node.test.span; |
3993 var line = $add(span.get$file().getLine$1(span.get$start()), (1)); | 3922 var line = span.get$file().getLine(span.get$start()) + (1); |
3994 var column = $add(span.get$file().getColumn$2(line - (1), span.get$start()),
(1)); | 3923 var column = span.get$file().getColumn($sub(line, (1)), span.get$start()) +
(1); |
3995 var args = [test, Value.fromString(span.get$text(), node.span), Value.fromSt
ring(span.get$file().get$filename(), node.span), Value.fromInt(line, node.span),
Value.fromInt(column, node.span)]; | 3924 var args = [test, Value.fromString(span.get$text(), node.span), Value.fromSt
ring(span.get$file().filename, node.span), Value.fromInt(line, node.span), Value
.fromInt(column, node.span)]; |
3996 var tp = $globals.world.corelib.topType; | 3925 var tp = $globals.world.corelib.topType; |
3997 var f = tp.getMember$1("_assert"); | 3926 var f = tp.getMember("_assert"); |
3998 var value = f.invoke(this, node, new TypeValue(tp, null), new Arguments(null
, args), false); | 3927 var value = f.invoke(this, node, new TypeValue(tp, null), new Arguments(null
, args)); |
3999 this.writer.writeln(("" + value.get$code() + ";")); | 3928 this.writer.writeln(("" + value.get$code() + ";")); |
4000 } | 3929 } |
4001 return false; | 3930 return false; |
4002 } | 3931 } |
4003 MethodGenerator.prototype.visitBreakStatement = function(node) { | 3932 MethodGenerator.prototype.visitBreakStatement = function(node) { |
4004 if (node.label == null) { | 3933 if (node.label == null) { |
4005 this.writer.writeln("break;"); | 3934 this.writer.writeln("break;"); |
4006 } | 3935 } |
4007 else { | 3936 else { |
4008 this.writer.writeln(("break " + node.label.name + ";")); | 3937 this.writer.writeln(("break " + node.label.name + ";")); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4064 this._visitLoop(node, (function () { | 3993 this._visitLoop(node, (function () { |
4065 if (node.test != null) { | 3994 if (node.test != null) { |
4066 var test = $this.visitBool(node.test); | 3995 var test = $this.visitBool(node.test); |
4067 $this.writer.write((" " + test.get$code() + "; ")); | 3996 $this.writer.write((" " + test.get$code() + "; ")); |
4068 } | 3997 } |
4069 else { | 3998 else { |
4070 $this.writer.write("; "); | 3999 $this.writer.write("; "); |
4071 } | 4000 } |
4072 var needsComma = false; | 4001 var needsComma = false; |
4073 var $$list = node.step; | 4002 var $$list = node.step; |
4074 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 4003 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
4075 var s = $$list[$$i]; | 4004 var s = $$i.next(); |
4076 if (needsComma) $this.writer.write(", "); | 4005 if (needsComma) $this.writer.write(", "); |
4077 var sv = $this.visitVoid(s); | 4006 var sv = $this.visitVoid(s); |
4078 $this.writer.write(sv.get$code()); | 4007 $this.writer.write(sv.get$code()); |
4079 needsComma = true; | 4008 needsComma = true; |
4080 } | 4009 } |
4081 $this.writer.write(") "); | 4010 $this.writer.write(") "); |
4082 $this._pushBlock(node.body, false); | 4011 $this._pushBlock(node.body, false); |
4083 node.body.visit($this); | 4012 node.body.visit($this); |
4084 $this._popBlock(node.body); | 4013 $this._popBlock(node.body); |
4085 }) | 4014 }) |
4086 ); | 4015 ); |
4087 this._popBlock(node); | 4016 this._popBlock(node); |
4088 return false; | 4017 return false; |
4089 } | 4018 } |
4090 MethodGenerator.prototype._isFinal = function(typeRef) { | 4019 MethodGenerator.prototype._isFinal = function(typeRef) { |
4091 if ((typeRef instanceof GenericTypeReference)) { | 4020 if ((typeRef instanceof GenericTypeReference)) { |
4092 typeRef = typeRef.get$baseType(); | 4021 typeRef = typeRef.get$baseType(); |
4093 } | 4022 } |
4094 return typeRef != null && typeRef.get$isFinal(); | 4023 else if ((typeRef instanceof SimpleTypeReference)) { |
| 4024 return false; |
| 4025 } |
| 4026 return $ne(typeRef) && typeRef.get$isFinal(); |
4095 } | 4027 } |
4096 MethodGenerator.prototype.visitForInStatement = function(node) { | 4028 MethodGenerator.prototype.visitForInStatement = function(node) { |
4097 var $this = this; // closure support | 4029 var $this = this; // closure support |
4098 var itemType = this.method.resolveType$2(node.item.type, false); | 4030 var itemType = this.method.resolveType(node.item.type, false, true); |
4099 var list = node.list.visit(this); | 4031 var list = node.list.visit(this); |
4100 this._visitLoop(node, (function () { | 4032 this._visitLoop(node, (function () { |
4101 $this._visitForInBody(node, itemType, list); | 4033 $this._visitForInBody(node, itemType, list); |
4102 }) | 4034 }) |
4103 ); | 4035 ); |
4104 return false; | 4036 return false; |
4105 } | 4037 } |
4106 MethodGenerator.prototype._visitForInBody = function(node, itemType, list) { | 4038 MethodGenerator.prototype._visitForInBody = function(node, itemType, list) { |
4107 var isFinal = this._isFinal(node.item.type); | 4039 var isFinal = this._isFinal(node.item.type); |
4108 var itemName = node.item.name.name; | 4040 var itemName = node.item.name.name; |
4109 var item = this._scope.create(itemName, itemType, node.item.name.span, isFinal
, false); | 4041 var item = this._scope.create(itemName, itemType, node.item.name.span, isFinal
, false); |
4110 if (list.get$needsTemp()) { | 4042 if (list.get$needsTemp()) { |
4111 var listVar = this._scope.create("$list", list.get$type(), null, false, fals
e); | 4043 var listVar = this._scope.create("$list", list.get$type(), null, false, fals
e); |
4112 this.writer.writeln(("var " + listVar.get$code() + " = " + list.get$code() +
";")); | 4044 this.writer.writeln(("var " + listVar.get$code() + " = " + list.get$code() +
";")); |
4113 list = listVar; | 4045 list = listVar; |
4114 } | 4046 } |
4115 if (list.get$type().get$isList()) { | 4047 if ($eq(list.get$type().get$genericType(), $globals.world.listFactoryType)) { |
4116 var tmpi = this._scope.create("$i", $globals.world.numType, null, false, fal
se); | 4048 var tmpi = this._scope.create("$i", $globals.world.numType, null, false, fal
se); |
4117 var listLength = list.get_(this, "length", node.list); | 4049 var listLength = list.get_(this, "length", node.list); |
4118 this.writer.enterBlock(("for (var " + tmpi.get$code() + " = 0;") + ("" + tmp
i.get$code() + " < " + listLength.get$code() + "; " + tmpi.get$code() + "++) {")
); | 4050 this.writer.enterBlock($add(("for (var " + tmpi.get$code() + " = 0;"), ("" +
tmpi.get$code() + " < " + listLength.get$code() + "; " + tmpi.get$code() + "++)
{"))); |
4119 var value = list.invoke(this, ":index", node.list, new Arguments(null, [tmpi
]), false); | 4051 var value = list.invoke(this, ":index", node.list, new Arguments(null, [tmpi
])); |
4120 this.writer.writeln(("var " + item.get$code() + " = " + value.get$code() + "
;")); | 4052 this.writer.writeln(("var " + item.get$code() + " = " + value.get$code() + "
;")); |
4121 } | 4053 } |
4122 else { | 4054 else { |
4123 var iterator = list.invoke(this, "iterator", node.list, Arguments.get$EMPTY(
), false); | 4055 var iterator = list.invoke(this, "iterator", node.list, Arguments.get$EMPTY(
)); |
4124 var tmpi = this._scope.create("$i", iterator.get$type(), null, false, false)
; | 4056 var tmpi = this._scope.create("$i", iterator.get$type(), null, false, false)
; |
4125 var hasNext = tmpi.invoke$4(this, "hasNext", node.list, Arguments.get$EMPTY(
)); | 4057 var hasNext = tmpi.invoke(this, "hasNext", node.list, Arguments.get$EMPTY())
; |
4126 var next = tmpi.invoke$4(this, "next", node.list, Arguments.get$EMPTY()); | 4058 var next = tmpi.invoke(this, "next", node.list, Arguments.get$EMPTY()); |
4127 this.writer.enterBlock(("for (var " + tmpi.get$code() + " = " + iterator.get
$code() + "; " + hasNext.get$code() + "; ) {")); | 4059 this.writer.enterBlock(("for (var " + tmpi.get$code() + " = " + iterator.get
$code() + "; " + hasNext.get$code() + "; ) {")); |
4128 this.writer.writeln(("var " + item.get$code() + " = " + next.get$code() + ";
")); | 4060 this.writer.writeln(("var " + item.get$code() + " = " + next.get$code() + ";
")); |
4129 } | 4061 } |
4130 this.visitStatementsInBlock(node.body); | 4062 this.visitStatementsInBlock(node.body); |
4131 this.writer.exitBlock("}"); | 4063 this.writer.exitBlock("}"); |
4132 } | 4064 } |
4133 MethodGenerator.prototype._genToDartException = function(ex) { | 4065 MethodGenerator.prototype._genToDartException = function(ex) { |
4134 var result = this._invokeNative("_toDartException", [ex]); | 4066 var result = this._invokeNative("_toDartException", [ex]); |
4135 this.writer.writeln(("" + ex.get$code() + " = " + result.get$code() + ";")); | 4067 this.writer.writeln(("" + ex.get$code() + " = " + result.get$code() + ";")); |
4136 } | 4068 } |
4137 MethodGenerator.prototype._genStackTraceOf = function(trace, ex) { | 4069 MethodGenerator.prototype._genStackTraceOf = function(trace, ex) { |
4138 var result = this._invokeNative("_stackTraceOf", [ex]); | 4070 var result = this._invokeNative("_stackTraceOf", [ex]); |
4139 this.writer.writeln(("var " + trace.get$code() + " = " + result.get$code() + "
;")); | 4071 this.writer.writeln(("var " + trace.get$code() + " = " + result.get$code() + "
;")); |
4140 } | 4072 } |
4141 MethodGenerator.prototype.visitTryStatement = function(node) { | 4073 MethodGenerator.prototype.visitTryStatement = function(node) { |
4142 this.writer.enterBlock("try {"); | 4074 this.writer.enterBlock("try {"); |
4143 this._pushBlock(node.body, false); | 4075 this._pushBlock(node.body, false); |
4144 this.visitStatementsInBlock(node.body); | 4076 this.visitStatementsInBlock(node.body); |
4145 this._popBlock(node.body); | 4077 this._popBlock(node.body); |
4146 if (node.catches.get$length() == (1)) { | 4078 if (node.catches.get$length() == (1)) { |
4147 var catch_ = node.catches[(0)]; | 4079 var catch_ = node.catches[(0)]; |
4148 this._pushBlock(catch_, false); | 4080 this._pushBlock(catch_, false); |
4149 var exType = this.method.resolveType$2(catch_.get$exception().get$type(), fa
lse); | 4081 var exType = this.method.resolveType(catch_.get$exception().get$type(), fals
e, true); |
4150 var ex = this._scope.declare(catch_.get$exception()); | 4082 var ex = this._scope.declare(catch_.get$exception()); |
4151 this._scope.rethrow = ex.get$code(); | 4083 this._scope.rethrow = ex.get$code(); |
4152 this.writer.nextBlock(("} catch (" + ex.get$code() + ") {")); | 4084 this.writer.nextBlock(("} catch (" + ex.get$code() + ") {")); |
4153 if (catch_.get$trace() != null) { | 4085 if ($ne(catch_.get$trace())) { |
4154 var trace = this._scope.declare(catch_.get$trace()); | 4086 var trace = this._scope.declare(catch_.get$trace()); |
4155 this._genStackTraceOf(trace, ex); | 4087 this._genStackTraceOf(trace, ex); |
4156 } | 4088 } |
4157 this._genToDartException(ex); | 4089 this._genToDartException(ex); |
4158 if (!exType.get$isVarOrObject()) { | 4090 if (!exType.get$isVarOrObject()) { |
4159 var test = ex.instanceOf$3$isTrue$forceCheck(this, exType, catch_.get$exce
ption().get$span(), false, true); | 4091 var test = ex.instanceOf$3$isTrue$forceCheck(this, exType, catch_.get$exce
ption().get$span(), false, true); |
4160 this.writer.writeln(("if (" + test.get$code() + ") throw " + ex.get$code()
+ ";")); | 4092 this.writer.writeln(("if (" + test.get$code() + ") throw " + ex.get$code()
+ ";")); |
4161 } | 4093 } |
4162 this.visitStatementsInBlock(node.catches[(0)].get$body()); | 4094 this.visitStatementsInBlock(node.catches[(0)].body); |
4163 this._popBlock(catch_); | 4095 this._popBlock(catch_); |
4164 } | 4096 } |
4165 else if (node.catches.get$length() > (0)) { | 4097 else if (node.catches.get$length() > (0)) { |
4166 this._pushBlock(node, false); | 4098 this._pushBlock(node, false); |
4167 var ex = this._scope.create("$ex", $globals.world.varType, null, false, fals
e); | 4099 var ex = this._scope.create("$ex", $globals.world.varType, null, false, fals
e); |
4168 this._scope.rethrow = ex.get$code(); | 4100 this._scope.rethrow = ex.get$code(); |
4169 this.writer.nextBlock(("} catch (" + ex.get$code() + ") {")); | 4101 this.writer.nextBlock(("} catch (" + ex.get$code() + ") {")); |
4170 var trace = null; | 4102 var trace = null; |
4171 if (node.catches.some((function (c) { | 4103 if (node.catches.some((function (c) { |
4172 return c.get$trace() != null; | 4104 return $ne(c.get$trace()); |
4173 }) | 4105 }) |
4174 )) { | 4106 )) { |
4175 trace = this._scope.create("$trace", $globals.world.varType, null, false,
false); | 4107 trace = this._scope.create("$trace", $globals.world.varType, null, false,
false); |
4176 this._genStackTraceOf(trace, ex); | 4108 this._genStackTraceOf(trace, ex); |
4177 } | 4109 } |
4178 this._genToDartException(ex); | 4110 this._genToDartException(ex); |
4179 var needsRethrow = true; | 4111 var needsRethrow = true; |
4180 for (var i = (0); | 4112 for (var i = (0); |
4181 i < node.catches.get$length(); i++) { | 4113 i < node.catches.get$length(); i++) { |
4182 var catch_ = node.catches[i]; | 4114 var catch_ = node.catches[i]; |
4183 this._pushBlock(catch_, false); | 4115 this._pushBlock(catch_, false); |
4184 var tmpType = this.method.resolveType$2(catch_.get$exception().get$type(),
false); | 4116 var tmpType = this.method.resolveType(catch_.get$exception().get$type(), f
alse, true); |
4185 var tmp = this._scope.declare(catch_.get$exception()); | 4117 var tmp = this._scope.declare(catch_.get$exception()); |
4186 if (!tmpType.get$isVarOrObject()) { | 4118 if (!tmpType.get$isVarOrObject()) { |
4187 var test = ex.instanceOf$3$isTrue$forceCheck(this, tmpType, catch_.get$e
xception().get$span(), true, true); | 4119 var test = ex.instanceOf$3$isTrue$forceCheck(this, tmpType, catch_.get$e
xception().get$span(), true, true); |
4188 if (i == (0)) { | 4120 if (i == (0)) { |
4189 this.writer.enterBlock(("if (" + test.get$code() + ") {")); | 4121 this.writer.enterBlock(("if (" + test.get$code() + ") {")); |
4190 } | 4122 } |
4191 else { | 4123 else { |
4192 this.writer.nextBlock(("} else if (" + test.get$code() + ") {")); | 4124 this.writer.nextBlock(("} else if (" + test.get$code() + ") {")); |
4193 } | 4125 } |
4194 } | 4126 } |
4195 else if (i > (0)) { | 4127 else if (i > (0)) { |
4196 this.writer.nextBlock("} else {"); | 4128 this.writer.nextBlock("} else {"); |
4197 } | 4129 } |
4198 this.writer.writeln(("var " + tmp.get$code() + " = " + ex.get$code() + ";"
)); | 4130 this.writer.writeln(("var " + tmp.get$code() + " = " + ex.get$code() + ";"
)); |
4199 if (catch_.get$trace() != null) { | 4131 if ($ne(catch_.get$trace())) { |
4200 var tmptrace = this._scope.declare(catch_.get$trace()); | 4132 var tmptrace = this._scope.declare(catch_.get$trace()); |
4201 this.writer.writeln(("var " + tmptrace.get$code() + " = " + trace.get$co
de() + ";")); | 4133 this.writer.writeln(("var " + tmptrace.get$code() + " = " + trace.get$co
de() + ";")); |
4202 } | 4134 } |
4203 this.visitStatementsInBlock(catch_.get$body()); | 4135 this.visitStatementsInBlock(catch_.get$body()); |
4204 this._popBlock(catch_); | 4136 this._popBlock(catch_); |
4205 if (tmpType.get$isVarOrObject()) { | 4137 if (tmpType.get$isVarOrObject()) { |
4206 if (i + (1) < node.catches.get$length()) { | 4138 if (i + (1) < node.catches.get$length()) { |
4207 $globals.world.error("Unreachable catch clause", node.catches[i + (1)]
.get$span()); | 4139 $globals.world.error("Unreachable catch clause", node.catches[i + (1)]
.span); |
4208 } | 4140 } |
4209 if (i > (0)) { | 4141 if (i > (0)) { |
4210 this.writer.exitBlock("}"); | 4142 this.writer.exitBlock("}"); |
4211 } | 4143 } |
4212 needsRethrow = false; | 4144 needsRethrow = false; |
4213 break; | 4145 break; |
4214 } | 4146 } |
4215 } | 4147 } |
4216 if (needsRethrow) { | 4148 if (needsRethrow) { |
4217 this.writer.nextBlock("} else {"); | 4149 this.writer.nextBlock("} else {"); |
4218 this.writer.writeln(("throw " + ex.get$code() + ";")); | 4150 this.writer.writeln(("throw " + ex.get$code() + ";")); |
4219 this.writer.exitBlock("}"); | 4151 this.writer.exitBlock("}"); |
4220 } | 4152 } |
4221 this._popBlock(node); | 4153 this._popBlock(node); |
4222 } | 4154 } |
4223 if (node.finallyBlock != null) { | 4155 if (node.finallyBlock != null) { |
4224 this.writer.nextBlock("} finally {"); | 4156 this.writer.nextBlock("} finally {"); |
4225 this._pushBlock(node.finallyBlock, false); | 4157 this._pushBlock(node.finallyBlock, false); |
4226 this.visitStatementsInBlock(node.finallyBlock); | 4158 this.visitStatementsInBlock(node.finallyBlock); |
4227 this._popBlock(node.finallyBlock); | 4159 this._popBlock(node.finallyBlock); |
4228 } | 4160 } |
4229 this.writer.exitBlock("}"); | 4161 this.writer.exitBlock("}"); |
4230 return false; | 4162 return false; |
4231 } | 4163 } |
4232 MethodGenerator.prototype.visitSwitchStatement = function(node) { | 4164 MethodGenerator.prototype.visitSwitchStatement = function(node) { |
4233 var test = this.visitValue(node.test); | 4165 var test = this.visitValue(node.test); |
4234 this.writer.enterBlock(("switch (" + test.get$code() + ") {")); | 4166 this.writer.enterBlock(("switch (" + test.get$code() + ") {")); |
4235 var $$list = node.cases; | 4167 var $$list = node.cases; |
4236 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 4168 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
4237 var case_ = $$list[$$i]; | 4169 var case_ = $$i.next(); |
4238 if (case_.get$label() != null) { | 4170 if (case_.get$label() != null) { |
4239 $globals.world.error("unimplemented: labeled case statement", case_.get$sp
an()); | 4171 $globals.world.error("unimplemented: labeled case statement", case_.get$sp
an()); |
4240 } | 4172 } |
4241 this._pushBlock(case_, false); | 4173 this._pushBlock(case_, false); |
4242 for (var i = (0); | 4174 for (var i = (0); |
4243 i < case_.get$cases().get$length(); i++) { | 4175 i < case_.get$cases().get$length(); i++) { |
4244 var expr = case_.get$cases().$index(i); | 4176 var expr = case_.get$cases().$index(i); |
4245 if (expr == null) { | 4177 if ($eq(expr)) { |
4246 if (i < case_.get$cases().get$length() - (1)) { | 4178 if (i < case_.get$cases().get$length() - (1)) { |
4247 $globals.world.error("default clause must be the last case", case_.get
$span()); | 4179 $globals.world.error("default clause must be the last case", case_.get
$span()); |
4248 } | 4180 } |
4249 this.writer.writeln("default:"); | 4181 this.writer.writeln("default:"); |
4250 } | 4182 } |
4251 else { | 4183 else { |
4252 var value = this.visitValue(expr); | 4184 var value = this.visitValue(expr); |
4253 this.writer.writeln(("case " + value.get$code() + ":")); | 4185 this.writer.writeln(("case " + value.get$code() + ":")); |
4254 } | 4186 } |
4255 } | 4187 } |
4256 this.writer.enterBlock(""); | 4188 this.writer.enterBlock(""); |
4257 var caseExits = this._visitAllStatements(case_.get$statements(), false); | 4189 var caseExits = this._visitAllStatements(case_.get$statements(), false); |
4258 if ($ne(case_, node.cases[node.cases.get$length() - (1)]) && !caseExits) { | 4190 if ($ne(case_, node.cases[node.cases.get$length() - (1)]) && !caseExits) { |
4259 var span = case_.get$statements().$index(case_.get$statements().get$length
() - (1)).get$span(); | 4191 var span = case_.get$statements().$index(case_.get$statements().get$length
() - (1)).get$span(); |
4260 this.writer.writeln("$throw(new FallThroughError());"); | 4192 this.writer.writeln("$throw(new FallThroughError());"); |
4261 $globals.world.gen.corejs.useThrow = true; | 4193 $globals.world.gen.corejs.useThrow = true; |
4262 } | 4194 } |
4263 this.writer.exitBlock(""); | 4195 this.writer.exitBlock(""); |
4264 this._popBlock(case_); | 4196 this._popBlock(case_); |
4265 } | 4197 } |
4266 this.writer.exitBlock("}"); | 4198 this.writer.exitBlock("}"); |
4267 return false; | 4199 return false; |
4268 } | 4200 } |
4269 MethodGenerator.prototype._visitAllStatements = function(statementList, exits) { | 4201 MethodGenerator.prototype._visitAllStatements = function(statementList, exits) { |
4270 for (var i = (0); | 4202 for (var i = (0); |
4271 i < statementList.get$length(); i++) { | 4203 i < statementList.get$length(); i++) { |
4272 var stmt = statementList.$index(i); | 4204 var stmt = statementList.$index(i); |
4273 exits = stmt.visit$1(this); | 4205 exits = stmt.visit(this); |
4274 if ($ne(stmt, statementList.$index(statementList.get$length() - (1))) && exi
ts) { | 4206 if ($ne(stmt, statementList.$index(statementList.get$length() - (1))) && exi
ts) { |
4275 $globals.world.warning("unreachable code", statementList.$index(i + (1)).g
et$span()); | 4207 $globals.world.warning("unreachable code", statementList.$index(i + (1)).g
et$span()); |
4276 } | 4208 } |
4277 } | 4209 } |
4278 return exits; | 4210 return exits; |
4279 } | 4211 } |
4280 MethodGenerator.prototype.visitBlockStatement = function(node) { | 4212 MethodGenerator.prototype.visitBlockStatement = function(node) { |
4281 this._pushBlock(node, false); | 4213 this._pushBlock(node, false); |
4282 this.writer.enterBlock("{"); | 4214 this.writer.enterBlock("{"); |
4283 var exits = this._visitAllStatements(node.body, false); | 4215 var exits = this._visitAllStatements(node.body, false); |
(...skipping 19 matching lines...) Expand all Loading... |
4303 return false; | 4235 return false; |
4304 } | 4236 } |
4305 MethodGenerator.prototype._checkNonStatic = function(node) { | 4237 MethodGenerator.prototype._checkNonStatic = function(node) { |
4306 if (this.get$isStatic()) { | 4238 if (this.get$isStatic()) { |
4307 $globals.world.warning("not allowed in static method", node.span); | 4239 $globals.world.warning("not allowed in static method", node.span); |
4308 } | 4240 } |
4309 } | 4241 } |
4310 MethodGenerator.prototype._makeSuperValue = function(node) { | 4242 MethodGenerator.prototype._makeSuperValue = function(node) { |
4311 var parentType = this.method.declaringType.get$parent(); | 4243 var parentType = this.method.declaringType.get$parent(); |
4312 this._checkNonStatic(node); | 4244 this._checkNonStatic(node); |
4313 if (parentType == null) { | 4245 if ($eq(parentType)) { |
4314 $globals.world.error("no super class", node.span); | 4246 $globals.world.error("no super class", node.span); |
4315 } | 4247 } |
4316 return new SuperValue(parentType, node.span); | 4248 return new SuperValue(parentType, node.span); |
4317 } | 4249 } |
4318 MethodGenerator.prototype._getOutermostMethod = function() { | 4250 MethodGenerator.prototype._getOutermostMethod = function() { |
4319 var result = this; | 4251 var result = this; |
4320 while (result.get$enclosingMethod() != null) { | 4252 while (result.get$enclosingMethod() != null) { |
4321 result = result.get$enclosingMethod(); | 4253 result = result.get$enclosingMethod(); |
4322 } | 4254 } |
4323 return result; | 4255 return result; |
4324 } | 4256 } |
4325 MethodGenerator.prototype._makeThisCode = function() { | 4257 MethodGenerator.prototype._makeThisCode = function() { |
4326 if (this.enclosingMethod != null) { | 4258 if (this.enclosingMethod != null) { |
4327 this._getOutermostMethod().set$needsThis(true); | 4259 this._getOutermostMethod().set$needsThis(true); |
4328 return "$this"; | 4260 return "$this"; |
4329 } | 4261 } |
4330 else { | 4262 else { |
4331 return "this"; | 4263 return "this"; |
4332 } | 4264 } |
4333 } | 4265 } |
4334 MethodGenerator.prototype._makeThisValue = function(node) { | 4266 MethodGenerator.prototype._makeThisValue = function(node) { |
4335 if (this.enclosingMethod != null) { | 4267 if (this.enclosingMethod != null) { |
4336 var outermostMethod = this._getOutermostMethod(); | 4268 var outermostMethod = this._getOutermostMethod(); |
4337 outermostMethod._checkNonStatic$1(node); | 4269 outermostMethod._checkNonStatic(node); |
4338 outermostMethod.set$needsThis(true); | 4270 outermostMethod.set$needsThis(true); |
4339 return new ThisValue(outermostMethod.get$method().get$declaringType(), "$thi
s", node != null ? node.span : null); | 4271 return new ThisValue(outermostMethod.get$method().get$declaringType(), "$thi
s", node != null ? node.span : null); |
4340 } | 4272 } |
4341 else { | 4273 else { |
4342 this._checkNonStatic(node); | 4274 this._checkNonStatic(node); |
4343 return new ThisValue(this.method.declaringType, "this", node != null ? node.
span : null); | 4275 return new ThisValue(this.method.declaringType, "this", node != null ? node.
span : null); |
4344 } | 4276 } |
4345 } | 4277 } |
4346 MethodGenerator.prototype.visitLambdaExpression = function(node) { | 4278 MethodGenerator.prototype.visitLambdaExpression = function(node) { |
4347 var name = (node.func.name != null) ? node.func.name.name : ""; | 4279 var name = (node.func.name != null) ? node.func.name.name : ""; |
4348 var meth = this._makeLambdaMethod(name, node.func); | 4280 var meth = this._makeLambdaMethod(name, node.func); |
4349 var lambdaGen = new MethodGenerator(meth, this); | 4281 return meth.get$methodData().createLambda(node, this); |
4350 if ($ne(name, "")) { | |
4351 lambdaGen.get$_scope().create$3$isFinal(name, meth.get$functionType(), meth.
definition.span, true); | |
4352 lambdaGen._pushBlock$1(node); | |
4353 } | |
4354 lambdaGen.run$0(); | |
4355 var w = new CodeWriter(); | |
4356 meth.generator.writeDefinition(w, node); | |
4357 return new Value(meth.get$functionType(), w.get$text(), node.span); | |
4358 } | 4282 } |
4359 MethodGenerator.prototype.visitCallExpression = function(node) { | 4283 MethodGenerator.prototype.visitCallExpression = function(node) { |
4360 var target; | 4284 var target; |
4361 var position = node.target; | 4285 var position = node.target; |
4362 var name = ":call"; | 4286 var name = ":call"; |
4363 if ((node.target instanceof DotExpression)) { | 4287 if ((node.target instanceof DotExpression)) { |
4364 var dot = node.target; | 4288 var dot = node.target; |
4365 target = dot.self.visit(this); | 4289 target = dot.self.visit(this); |
4366 name = dot.name.name; | 4290 name = dot.name.name; |
4367 position = dot.name; | 4291 position = dot.name; |
4368 } | 4292 } |
4369 else if ((node.target instanceof VarExpression)) { | 4293 else if ((node.target instanceof VarExpression)) { |
4370 var varExpr = node.target; | 4294 var varExpr = node.target; |
4371 name = varExpr.name.name; | 4295 name = varExpr.name.name; |
4372 target = this._scope.lookup(name); | 4296 target = this._scope.lookup(name); |
4373 if (target != null) { | 4297 if ($ne(target)) { |
4374 return target.invoke$4(this, ":call", node, this._makeArgs(node.arguments)
); | 4298 return target.invoke(this, ":call", node, this._makeArgs(node.arguments)); |
4375 } | 4299 } |
4376 target = this._makeThisOrType(varExpr.span); | 4300 target = this._makeThisOrType(varExpr.span); |
4377 return target.invoke$4(this, name, node, this._makeArgs(node.arguments)); | 4301 return target.invoke(this, name, node, this._makeArgs(node.arguments)); |
4378 } | 4302 } |
4379 else { | 4303 else { |
4380 target = node.target.visit(this); | 4304 target = node.target.visit(this); |
4381 } | 4305 } |
4382 return target.invoke$4(this, name, position, this._makeArgs(node.arguments)); | 4306 return target.invoke(this, name, position, this._makeArgs(node.arguments)); |
4383 } | 4307 } |
4384 MethodGenerator.prototype.visitIndexExpression = function(node) { | 4308 MethodGenerator.prototype.visitIndexExpression = function(node) { |
4385 var target = this.visitValue(node.target); | 4309 var target = this.visitValue(node.target); |
4386 var index = this.visitValue(node.index); | 4310 var index = this.visitValue(node.index); |
4387 return target.invoke$4(this, ":index", node, new Arguments(null, [index])); | 4311 return target.invoke(this, ":index", node, new Arguments(null, [index])); |
4388 } | 4312 } |
4389 MethodGenerator.prototype._expressionNeedsParens = function(e) { | 4313 MethodGenerator.prototype._expressionNeedsParens = function(e) { |
4390 return ((e instanceof BinaryExpression) || (e instanceof ConditionalExpression
) || (e instanceof PostfixExpression) || this._isUnaryIncrement(e)); | 4314 return ((e instanceof BinaryExpression) || (e instanceof ConditionalExpression
) || (e instanceof PostfixExpression) || this._isUnaryIncrement(e)); |
4391 } | 4315 } |
4392 MethodGenerator.prototype.visitBinaryExpression = function(node, isVoid) { | 4316 MethodGenerator.prototype.visitBinaryExpression = function(node, isVoid) { |
4393 var kind = node.op.kind; | 4317 var kind = node.op.kind; |
4394 if ($eq(kind, (35)) || $eq(kind, (34))) { | 4318 if ($eq(kind, (35)) || $eq(kind, (34))) { |
4395 var x = this.visitTypedValue(node.x, $globals.world.nonNullBool); | 4319 var x = this.visitTypedValue(node.x, $globals.world.nonNullBool); |
4396 var y = this.visitTypedValue(node.y, $globals.world.nonNullBool); | 4320 var y = this.visitTypedValue(node.y, $globals.world.nonNullBool); |
4397 return x.binop$4(kind, y, this, node); | 4321 return x.binop(kind, y, this, node); |
4398 } | 4322 } |
4399 else if ($eq(kind, (50)) || $eq(kind, (51))) { | 4323 else if ($eq(kind, (50)) || $eq(kind, (51))) { |
4400 var x = this.visitValue(node.x); | 4324 var x = this.visitValue(node.x); |
4401 var y = this.visitValue(node.y); | 4325 var y = this.visitValue(node.y); |
4402 return x.binop$4(kind, y, this, node); | 4326 return x.binop(kind, y, this, node); |
4403 } | 4327 } |
4404 var assignKind = TokenKind.kindFromAssign(node.op.kind); | 4328 var assignKind = TokenKind.kindFromAssign(node.op.kind); |
4405 if ($eq(assignKind, (-1))) { | 4329 if ($eq(assignKind, (-1))) { |
4406 var x = this.visitValue(node.x); | 4330 var x = this.visitValue(node.x); |
4407 var y = this.visitValue(node.y); | 4331 var y = this.visitValue(node.y); |
4408 return x.binop$4(kind, y, this, node); | 4332 return x.binop(kind, y, this, node); |
4409 } | 4333 } |
4410 else if (($ne(assignKind, (0))) && this._expressionNeedsParens(node.y)) { | 4334 else if (($ne(assignKind, (0))) && this._expressionNeedsParens(node.y)) { |
4411 return this._visitAssign(assignKind, node.x, new ParenExpression(node.y, nod
e.y.span), node, isVoid ? (1) : (2)); | 4335 return this._visitAssign(assignKind, node.x, new ParenExpression(node.y, nod
e.y.span), node, isVoid ? (1) : (2)); |
4412 } | 4336 } |
4413 else { | 4337 else { |
4414 return this._visitAssign(assignKind, node.x, node.y, node, isVoid ? (1) : (2
)); | 4338 return this._visitAssign(assignKind, node.x, node.y, node, isVoid ? (1) : (2
)); |
4415 } | 4339 } |
4416 } | 4340 } |
4417 MethodGenerator.prototype._visitAssign = function(kind, xn, yn, position, return
Kind) { | 4341 MethodGenerator.prototype._visitAssign = function(kind, xn, yn, position, return
Kind) { |
4418 if ((xn instanceof VarExpression)) { | 4342 if ((xn instanceof VarExpression)) { |
4419 return this._visitVarAssign(kind, xn, yn, position, returnKind); | 4343 return this._visitVarAssign(kind, xn, yn, position, returnKind); |
4420 } | 4344 } |
4421 else if ((xn instanceof IndexExpression)) { | 4345 else if ((xn instanceof IndexExpression)) { |
4422 return this._visitIndexAssign(kind, xn, yn, position, returnKind); | 4346 return this._visitIndexAssign(kind, xn, yn, position, returnKind); |
4423 } | 4347 } |
4424 else if ((xn instanceof DotExpression)) { | 4348 else if ((xn instanceof DotExpression)) { |
4425 return this._visitDotAssign(kind, xn, yn, position, returnKind); | 4349 return this._visitDotAssign(kind, xn, yn, position, returnKind); |
4426 } | 4350 } |
4427 else { | 4351 else { |
4428 $globals.world.error("illegal lhs", xn.span); | 4352 $globals.world.error("illegal lhs", xn.span); |
4429 } | 4353 } |
4430 } | 4354 } |
4431 MethodGenerator.prototype._visitVarAssign = function(kind, xn, yn, position, ret
urnKind) { | 4355 MethodGenerator.prototype._visitVarAssign = function(kind, xn, yn, position, ret
urnKind) { |
4432 var name = xn.name.name; | 4356 var name = xn.name.name; |
4433 var x = this._scope.lookup(name); | 4357 var x = this._scope.lookup(name); |
4434 var y = this.visitValue(yn); | 4358 var y = this.visitValue(yn); |
4435 if (x != null) { | 4359 if ($ne(x)) { |
4436 y = y.convertTo$2(this, x.get$staticType()); | 4360 y = y.convertTo(this, x.get$staticType()); |
4437 this._scope.inferAssign(name, Value.union(x, y)); | 4361 this._scope.inferAssign(name, Value.union(x, y)); |
4438 if (x.get$isFinal()) { | 4362 if (x.get$isFinal()) { |
4439 $globals.world.error(("final variable \"" + x.get$code() + "\" is not assi
gnable"), position.span); | 4363 $globals.world.error(("final variable \"" + x.get$code() + "\" is not assi
gnable"), position.span); |
4440 } | 4364 } |
4441 if (kind == (0)) { | 4365 if (kind == (0)) { |
4442 return new Value(y.get$type(), ("" + x.get$code() + " = " + y.get$code()),
position.span); | 4366 return new Value(y.get$type(), ("" + x.get$code() + " = " + y.get$code()),
position.span); |
4443 } | 4367 } |
4444 else if (x.get$type().get$isNum() && y.get$type().get$isNum() && (kind != (4
6))) { | 4368 else if (x.get$type().get$isNum() && y.get$type().get$isNum() && (kind != (4
6))) { |
4445 if (returnKind == (3)) { | 4369 if (returnKind == (3)) { |
4446 $globals.world.internalError("should not be here", position.span); | 4370 $globals.world.internalError("should not be here", position.span); |
4447 } | 4371 } |
4448 var op = TokenKind.kindToString(kind); | 4372 var op = TokenKind.kindToString(kind); |
4449 return new Value(y.get$type(), ("" + x.get$code() + " " + op + "= " + y.ge
t$code()), position.span); | 4373 return new Value(y.get$type(), ("" + x.get$code() + " " + op + "= " + y.ge
t$code()), position.span); |
4450 } | 4374 } |
4451 else { | 4375 else { |
4452 var right = x; | 4376 var right = x; |
4453 y = right.binop$4(kind, y, this, position); | 4377 y = right.binop(kind, y, this, position); |
4454 if (returnKind == (3)) { | 4378 if (returnKind == (3)) { |
4455 var tmp = this.forceTemp(x); | 4379 var tmp = this.forceTemp(x); |
4456 var ret = new Value(x.get$type(), ("(" + tmp.get$code() + " = " + x.get$
code() + ", " + x.get$code() + " = " + y.get$code() + ", " + tmp.get$code() + ")
"), position.span); | 4380 var ret = new Value(x.get$type(), ("(" + tmp.get$code() + " = " + x.get$
code() + ", " + x.get$code() + " = " + y.get$code() + ", " + tmp.get$code() + ")
"), position.span); |
4457 this.freeTemp(tmp); | 4381 this.freeTemp(tmp); |
4458 return ret; | 4382 return ret; |
4459 } | 4383 } |
4460 else { | 4384 else { |
4461 return new Value(x.get$type(), ("" + x.get$code() + " = " + y.get$code()
), position.span); | 4385 return new Value(x.get$type(), ("" + x.get$code() + " = " + y.get$code()
), position.span); |
4462 } | 4386 } |
4463 } | 4387 } |
(...skipping 13 matching lines...) Expand all Loading... |
4477 var target = xn.self.visit(this); | 4401 var target = xn.self.visit(this); |
4478 var y = this.visitValue(yn); | 4402 var y = this.visitValue(yn); |
4479 return target.set_$4$kind$returnKind(this, xn.name.name, xn.name, y, kind, ret
urnKind); | 4403 return target.set_$4$kind$returnKind(this, xn.name.name, xn.name, y, kind, ret
urnKind); |
4480 } | 4404 } |
4481 MethodGenerator.prototype.visitUnaryExpression = function(node) { | 4405 MethodGenerator.prototype.visitUnaryExpression = function(node) { |
4482 var value = this.visitValue(node.self); | 4406 var value = this.visitValue(node.self); |
4483 switch (node.op.kind) { | 4407 switch (node.op.kind) { |
4484 case (16): | 4408 case (16): |
4485 case (17): | 4409 case (17): |
4486 | 4410 |
4487 if (value.get$type().get$isNum()) { | 4411 if (value.get$type().get$isNum() && !value.get$isFinal() && (node.self ins
tanceof VarExpression)) { |
4488 return new Value(value.get$type(), ("" + node.op + value.get$code()), no
de.span); | 4412 return new Value(value.get$type(), ("" + node.op + value.get$code()), no
de.span); |
4489 } | 4413 } |
4490 else { | 4414 else { |
4491 var kind = ((16) == node.op.kind ? (42) : (43)); | 4415 var kind = ((16) == node.op.kind ? (42) : (43)); |
4492 var operand = new LiteralExpression(Value.fromInt((1), node.span), node.
span); | 4416 var operand = new LiteralExpression(Value.fromInt((1), node.span), node.
span); |
4493 var assignValue = this._visitAssign(kind, node.self, operand, node, (2))
; | 4417 var assignValue = this._visitAssign(kind, node.self, operand, node, (2))
; |
4494 return new Value(assignValue.get$type(), ("(" + assignValue.get$code() +
")"), node.span); | 4418 return new Value(assignValue.get$type(), ("(" + assignValue.get$code() +
")"), node.span); |
4495 } | 4419 } |
4496 | 4420 |
4497 } | 4421 } |
4498 return value.unop$3(node.op.kind, this, node); | 4422 return value.unop(node.op.kind, this, node); |
4499 } | 4423 } |
4500 MethodGenerator.prototype.visitDeclaredIdentifier = function(node) { | 4424 MethodGenerator.prototype.visitDeclaredIdentifier = function(node) { |
4501 $globals.world.error("Expected expression", node.span); | 4425 $globals.world.error("Expected expression", node.span); |
4502 } | 4426 } |
4503 MethodGenerator.prototype.visitAwaitExpression = function(node) { | 4427 MethodGenerator.prototype.visitAwaitExpression = function(node) { |
4504 $globals.world.internalError("Await expressions should have been eliminated be
fore code generation", node.span); | 4428 $globals.world.internalError("Await expressions should have been eliminated be
fore code generation", node.span); |
4505 } | 4429 } |
4506 MethodGenerator.prototype.visitPostfixExpression = function(node, isVoid) { | 4430 MethodGenerator.prototype.visitPostfixExpression = function(node, isVoid) { |
4507 var value = this.visitValue(node.body); | 4431 var value = this.visitValue(node.body); |
4508 if (value.get$type().get$isNum() && !value.get$isFinal()) { | 4432 if (value.get$type().get$isNum() && !value.get$isFinal() && (node.body instanc
eof VarExpression)) { |
4509 return new Value(value.get$type(), ("" + value.get$code() + node.op), node.s
pan); | 4433 return new Value(value.get$type(), ("" + value.get$code() + node.op), node.s
pan); |
4510 } | 4434 } |
4511 var kind = ((16) == node.op.kind) ? (42) : (43); | 4435 var kind = ((16) == node.op.kind) ? (42) : (43); |
4512 var operand = new LiteralExpression(Value.fromInt((1), node.span), node.span); | 4436 var operand = new LiteralExpression(Value.fromInt((1), node.span), node.span); |
4513 var ret = this._visitAssign(kind, node.body, operand, node, isVoid ? (1) : (3)
); | 4437 var ret = this._visitAssign(kind, node.body, operand, node, isVoid ? (1) : (3)
); |
4514 return ret; | 4438 return ret; |
4515 } | 4439 } |
4516 MethodGenerator.prototype.visitNewExpression = function(node) { | 4440 MethodGenerator.prototype.visitNewExpression = function(node) { |
4517 var typeRef = node.type; | 4441 var typeRef = node.type; |
4518 var constructorName = ""; | 4442 var constructorName = ""; |
4519 if (node.name != null) { | 4443 if (node.name != null) { |
4520 constructorName = node.name.name; | 4444 constructorName = node.name.name; |
4521 } | 4445 } |
4522 if ($eq(constructorName, "") && !(typeRef instanceof GenericTypeReference) &&
typeRef.get$names() != null) { | 4446 if ($eq(constructorName, "") && (typeRef instanceof NameTypeReference) && type
Ref.get$names() != null) { |
4523 var names = ListFactory.ListFactory$from$factory(typeRef.get$names()); | 4447 var names = ListFactory.ListFactory$from$factory(typeRef.get$names()); |
4524 constructorName = names.removeLast$0().get$name(); | 4448 constructorName = names.removeLast().get$name(); |
4525 if ($eq(names.get$length(), (0))) names = null; | 4449 if (names.get$length() == (0)) names = null; |
4526 typeRef = new NameTypeReference(typeRef.get$isFinal(), typeRef.get$name(), n
ames, typeRef.get$span()); | 4450 typeRef = new NameTypeReference(typeRef.get$isFinal(), typeRef.get$name(), n
ames, typeRef.get$span()); |
4527 } | 4451 } |
4528 var type = this.method.resolveType$2(typeRef, true); | 4452 var type = this.method.resolveType(typeRef, true, true); |
4529 if (type.get$isTop()) { | 4453 if (type.get$isTop()) { |
4530 type = type.get$library().findTypeByName$1(constructorName); | 4454 type = type.get$library().findTypeByName(constructorName); |
4531 constructorName = ""; | 4455 constructorName = ""; |
4532 } | 4456 } |
4533 if ((type instanceof ParameterType)) { | 4457 if ((type instanceof ParameterType)) { |
4534 $globals.world.error("cannot instantiate a type parameter", node.span); | 4458 $globals.world.error("cannot instantiate a type parameter", node.span); |
4535 return this._makeMissingValue(constructorName); | 4459 return this._makeMissingValue(constructorName); |
4536 } | 4460 } |
4537 var m = type.getConstructor$1(constructorName); | 4461 var m = type.getConstructor(constructorName); |
4538 if (m == null) { | 4462 if ($eq(m)) { |
4539 var name = type.get$jsname(); | 4463 var name = type.get$jsname(); |
4540 if (type.get$isVar()) { | 4464 if (type.get$isVar()) { |
4541 name = typeRef.get$name().get$name(); | 4465 name = typeRef.get$name().get$name(); |
4542 } | 4466 } |
4543 $globals.world.error(("no matching constructor for " + name), node.span); | 4467 $globals.world.error(("no matching constructor for " + name), node.span); |
4544 return this._makeMissingValue(name); | 4468 return this._makeMissingValue(name); |
4545 } | 4469 } |
4546 if (node.isConst) { | 4470 if (node.isConst) { |
4547 if (!m.get$isConst()) { | 4471 if (!m.get$isConst()) { |
4548 $globals.world.error("can't use const on a non-const constructor", node.sp
an); | 4472 $globals.world.error("can't use const on a non-const constructor", node.sp
an); |
4549 } | 4473 } |
4550 var $$list = node.arguments; | 4474 var $$list = node.arguments; |
4551 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 4475 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
4552 var arg = $$list[$$i]; | 4476 var arg = $$i.next(); |
4553 if (!this.visitValue(arg.get$value()).get$isConst()) { | 4477 if (!this.visitValue(arg.get$value()).get$isConst()) { |
4554 $globals.world.error("const constructor expects const arguments", arg.ge
t$span()); | 4478 $globals.world.error("const constructor expects const arguments", arg.ge
t$span()); |
4555 } | 4479 } |
4556 } | 4480 } |
4557 } | 4481 } |
4558 var target = new TypeValue(type, typeRef.get$span()); | 4482 var target = new TypeValue(type, typeRef.get$span()); |
4559 return m.invoke$4(this, node, target, this._makeArgs(node.arguments)); | 4483 return m.invoke(this, node, target, this._makeArgs(node.arguments)); |
4560 } | 4484 } |
4561 MethodGenerator.prototype.visitListExpression = function(node) { | 4485 MethodGenerator.prototype.visitListExpression = function(node) { |
4562 var argValues = []; | 4486 var argValues = []; |
4563 var listType = $globals.world.listType; | 4487 var listType = $globals.world.listType; |
4564 var type = $globals.world.varType; | 4488 var type = $globals.world.varType; |
4565 if (node.itemType != null) { | 4489 if (node.itemType != null) { |
4566 type = this.method.resolveType$2(node.itemType, true); | 4490 type = this.method.resolveType(node.itemType, true, !node.isConst); |
4567 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara
ms())) { | 4491 if (node.isConst && ((type instanceof ParameterType) || type.get$hasTypePara
ms())) { |
4568 $globals.world.error("type parameter cannot be used in const list literals
"); | 4492 $globals.world.error("type parameter cannot be used in const list literals
"); |
4569 } | 4493 } |
4570 listType = listType.getOrMakeConcreteType$1([type]); | 4494 listType = listType.getOrMakeConcreteType([type]); |
4571 } | 4495 } |
4572 var $$list = node.values; | 4496 var $$list = node.values; |
4573 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 4497 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
4574 var item = $$list[$$i]; | 4498 var item = $$i.next(); |
4575 var arg = this.visitTypedValue(item, type); | 4499 var arg = this.visitTypedValue(item, type); |
4576 argValues.add$1(arg); | 4500 argValues.add(arg); |
4577 if (node.isConst && !arg.get$isConst()) { | 4501 if (node.isConst && !arg.get$isConst()) { |
4578 $globals.world.error("const list can only contain const values", arg.get$s
pan()); | 4502 $globals.world.error("const list can only contain const values", arg.get$s
pan()); |
4579 } | 4503 } |
4580 } | 4504 } |
4581 $globals.world.listFactoryType.markUsed(); | 4505 $globals.world.listFactoryType.markUsed(); |
4582 var ret = new ListValue(argValues, node.isConst, listType, node.span); | 4506 var ret = new ListValue(argValues, node.isConst, listType, node.span); |
4583 if (ret.get$isConst()) return ret.getGlobalValue$0(); | 4507 if (ret.get$isConst()) return ret.getGlobalValue(); |
4584 return ret; | 4508 return ret; |
4585 } | 4509 } |
4586 MethodGenerator.prototype.visitMapExpression = function(node) { | 4510 MethodGenerator.prototype.visitMapExpression = function(node) { |
4587 if (node.items.get$length() == (0) && !node.isConst) { | 4511 if (node.items.get$length() == (0) && !node.isConst) { |
4588 return $globals.world.mapType.getConstructor("").invoke$4(this, node, new Ty
peValue($globals.world.mapType, node.span), Arguments.get$EMPTY()); | 4512 return $globals.world.mapType.getConstructor("").invoke(this, node, new Type
Value($globals.world.mapType, node.span), Arguments.get$EMPTY()); |
4589 } | 4513 } |
4590 var values = []; | 4514 var values = []; |
4591 var valueType = $globals.world.varType, keyType = $globals.world.stringType; | 4515 var valueType = $globals.world.varType, keyType = $globals.world.stringType; |
4592 var mapType = $globals.world.mapType; | 4516 var mapType = $globals.world.mapType; |
4593 if (node.valueType != null) { | 4517 if (node.valueType != null) { |
4594 if (node.keyType != null) { | 4518 if (node.keyType != null) { |
4595 keyType = this.method.resolveType$2(node.keyType, true); | 4519 keyType = this.method.resolveType(node.keyType, true, !node.isConst); |
4596 if (!keyType.get$isString()) { | 4520 if (!keyType.get$isString()) { |
4597 $globals.world.error("the key type of a map literal must be \"String\"",
keyType.get$span()); | 4521 $globals.world.error("the key type of a map literal must be \"String\"",
keyType.get$span()); |
4598 } | 4522 } |
4599 if (node.isConst && ((keyType instanceof ParameterType) || keyType.get$has
TypeParams())) { | 4523 if (node.isConst && ((keyType instanceof ParameterType) || keyType.get$has
TypeParams())) { |
4600 $globals.world.error("type parameter cannot be used in const map literal
s"); | 4524 $globals.world.error("type parameter cannot be used in const map literal
s"); |
4601 } | 4525 } |
4602 } | 4526 } |
4603 valueType = this.method.resolveType$2(node.valueType, true); | 4527 valueType = this.method.resolveType(node.valueType, true, !node.isConst); |
4604 if (node.isConst && ((valueType instanceof ParameterType) || valueType.get$h
asTypeParams())) { | 4528 if (node.isConst && ((valueType instanceof ParameterType) || valueType.get$h
asTypeParams())) { |
4605 $globals.world.error("type parameter cannot be used in const map literals"
); | 4529 $globals.world.error("type parameter cannot be used in const map literals"
); |
4606 } | 4530 } |
4607 mapType = mapType.getOrMakeConcreteType$1([keyType, valueType]); | 4531 mapType = mapType.getOrMakeConcreteType([keyType, valueType]); |
4608 } | 4532 } |
4609 for (var i = (0); | 4533 for (var i = (0); |
4610 i < node.items.get$length(); i += (2)) { | 4534 i < node.items.get$length(); i += (2)) { |
4611 var key = this.visitTypedValue(node.items[i], keyType); | 4535 var key = this.visitTypedValue(node.items[i], keyType); |
4612 if (node.isConst && !key.get$isConst()) { | 4536 if (node.isConst && !key.get$isConst()) { |
4613 $globals.world.error("const map can only contain const keys", key.get$span
()); | 4537 $globals.world.error("const map can only contain const keys", key.get$span
()); |
4614 } | 4538 } |
4615 values.add$1(key); | 4539 values.add(key); |
4616 var value = this.visitTypedValue(node.items[i + (1)], valueType); | 4540 var value = this.visitTypedValue(node.items[i + (1)], valueType); |
4617 if (node.isConst && !value.get$isConst()) { | 4541 if (node.isConst && !value.get$isConst()) { |
4618 $globals.world.error("const map can only contain const values", value.get$
span()); | 4542 $globals.world.error("const map can only contain const values", value.get$
span()); |
4619 } | 4543 } |
4620 values.add$1(value); | 4544 values.add(value); |
4621 } | 4545 } |
4622 var ret = new MapValue(values, node.isConst, mapType, node.span); | 4546 var ret = new MapValue(values, node.isConst, mapType, node.span); |
4623 if (ret.get$isConst()) return ret.getGlobalValue$0(); | 4547 if (ret.get$isConst()) return ret.getGlobalValue(); |
4624 return ret; | 4548 return ret; |
4625 } | 4549 } |
4626 MethodGenerator.prototype.visitConditionalExpression = function(node) { | 4550 MethodGenerator.prototype.visitConditionalExpression = function(node) { |
4627 var test = this.visitBool(node.test); | 4551 var test = this.visitBool(node.test); |
4628 var trueBranch = this.visitValue(node.trueBranch); | 4552 var trueBranch = this.visitValue(node.trueBranch); |
4629 var falseBranch = this.visitValue(node.falseBranch); | 4553 var falseBranch = this.visitValue(node.falseBranch); |
4630 return new Value(Type.union(trueBranch.get$type(), falseBranch.get$type()), ("
" + test.get$code() + " ? " + trueBranch.get$code() + " : " + falseBranch.get$co
de()), node.span); | 4554 return new Value(Type.union(trueBranch.get$type(), falseBranch.get$type()), ("
" + test.get$code() + " ? " + trueBranch.get$code() + " : " + falseBranch.get$co
de()), node.span); |
4631 } | 4555 } |
4632 MethodGenerator.prototype.visitIsExpression = function(node) { | 4556 MethodGenerator.prototype.visitIsExpression = function(node) { |
4633 var value = this.visitValue(node.x); | 4557 var value = this.visitValue(node.x); |
4634 var type = this.method.resolveType$2(node.type, false); | 4558 var type = this.method.resolveType(node.type, true, true); |
| 4559 if (type.get$isVar()) { |
| 4560 return Value.comma(value, Value.fromBool(true, node.span)); |
| 4561 } |
4635 return value.instanceOf$4(this, type, node.span, node.isTrue); | 4562 return value.instanceOf$4(this, type, node.span, node.isTrue); |
4636 } | 4563 } |
4637 MethodGenerator.prototype.visitParenExpression = function(node) { | 4564 MethodGenerator.prototype.visitParenExpression = function(node) { |
4638 var body = this.visitValue(node.body); | 4565 var body = this.visitValue(node.body); |
4639 if (body.get$isConst()) return body; | 4566 if (body.get$isConst()) return body; |
4640 return new Value(body.get$type(), ("(" + body.get$code() + ")"), node.span); | 4567 return new Value(body.get$type(), ("(" + body.get$code() + ")"), node.span); |
4641 } | 4568 } |
4642 MethodGenerator.prototype.visitDotExpression = function(node) { | 4569 MethodGenerator.prototype.visitDotExpression = function(node) { |
4643 var target = node.self.visit(this); | 4570 var target = node.self.visit(this); |
4644 return target.get_$3(this, node.name.name, node.name); | 4571 return target.get_(this, node.name.name, node.name); |
4645 } | 4572 } |
4646 MethodGenerator.prototype.visitVarExpression = function(node) { | 4573 MethodGenerator.prototype.visitVarExpression = function(node) { |
4647 var name = node.name.name; | 4574 var name = node.name.name; |
4648 var ret = this._scope.lookup(name); | 4575 var ret = this._scope.lookup(name); |
4649 if (ret != null) return ret; | 4576 if ($ne(ret)) return ret; |
4650 return this._makeThisOrType(node.span).get_$3(this, name, node); | 4577 return this._makeThisOrType(node.span).get_(this, name, node); |
4651 } | 4578 } |
4652 MethodGenerator.prototype._makeMissingValue = function(name) { | 4579 MethodGenerator.prototype._makeMissingValue = function(name) { |
4653 return new Value($globals.world.varType, ("" + name + "()/*NotFound*/"), null)
; | 4580 return new Value($globals.world.varType, ("" + name + "()/*NotFound*/"), null)
; |
4654 } | 4581 } |
4655 MethodGenerator.prototype._makeThisOrType = function(span) { | 4582 MethodGenerator.prototype._makeThisOrType = function(span) { |
4656 return new BareValue(this, this._getOutermostMethod(), span); | 4583 return new BareValue(this, this._getOutermostMethod(), span); |
4657 } | 4584 } |
4658 MethodGenerator.prototype.visitThisExpression = function(node) { | 4585 MethodGenerator.prototype.visitThisExpression = function(node) { |
4659 return this._makeThisValue(node); | 4586 return this._makeThisValue(node); |
4660 } | 4587 } |
4661 MethodGenerator.prototype.visitSuperExpression = function(node) { | 4588 MethodGenerator.prototype.visitSuperExpression = function(node) { |
4662 return this._makeSuperValue(node); | 4589 return this._makeSuperValue(node); |
4663 } | 4590 } |
4664 MethodGenerator.prototype.visitLiteralExpression = function(node) { | 4591 MethodGenerator.prototype.visitLiteralExpression = function(node) { |
4665 return node.value; | 4592 return node.value; |
4666 } | 4593 } |
4667 MethodGenerator.prototype._isUnaryIncrement = function(item) { | 4594 MethodGenerator.prototype._isUnaryIncrement = function(item) { |
4668 if ((item instanceof UnaryExpression)) { | 4595 if ((item instanceof UnaryExpression)) { |
4669 var u = item; | 4596 var u = item; |
4670 return u.op.kind == (16) || u.op.kind == (17); | 4597 return u.op.kind == (16) || u.op.kind == (17); |
4671 } | 4598 } |
4672 else { | 4599 else { |
4673 return false; | 4600 return false; |
4674 } | 4601 } |
4675 } | 4602 } |
4676 MethodGenerator.prototype.visitStringInterpExpression = function(node) { | 4603 MethodGenerator.prototype.visitStringInterpExpression = function(node) { |
4677 var items = []; | 4604 var items = []; |
4678 var $$list = node.pieces; | 4605 var $$list = node.pieces; |
4679 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 4606 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
4680 var item = $$list[$$i]; | 4607 var item = $$i.next(); |
4681 var val = this.visitValue(item); | 4608 var val = this.visitValue(item); |
4682 val.invoke$4(this, "toString", item, Arguments.get$EMPTY()); | 4609 val.invoke(this, "toString", item, Arguments.get$EMPTY()); |
4683 var code = val.get$code(); | 4610 var code = val.get$code(); |
4684 if (this._expressionNeedsParens(item)) { | 4611 if (this._expressionNeedsParens(item)) { |
4685 code = ("(" + code + ")"); | 4612 code = ("(" + code + ")"); |
4686 } | 4613 } |
4687 if ($eq(items.get$length(), (0)) || ($ne(code, "''") && $ne(code, "\"\"")))
{ | 4614 if (items.get$length() == (0) || ($ne(code, "''") && $ne(code, "\"\""))) { |
4688 items.add$1(code); | 4615 items.add(code); |
4689 } | 4616 } |
4690 } | 4617 } |
4691 return new Value($globals.world.stringType, ("(" + Strings.join(items, " + ")
+ ")"), node.span); | 4618 return new Value($globals.world.stringType, ("(" + Strings.join(items, " + ")
+ ")"), node.span); |
4692 } | 4619 } |
4693 MethodGenerator.prototype._checkNonStatic$1 = MethodGenerator.prototype._checkNo
nStatic; | |
4694 MethodGenerator.prototype._pushBlock$1 = function($0) { | 4620 MethodGenerator.prototype._pushBlock$1 = function($0) { |
4695 return this._pushBlock($0, false); | 4621 return this._pushBlock($0, false); |
4696 }; | 4622 }; |
4697 MethodGenerator.prototype.evalBody$2 = MethodGenerator.prototype.evalBody; | |
4698 MethodGenerator.prototype.run$0 = MethodGenerator.prototype.run; | 4623 MethodGenerator.prototype.run$0 = MethodGenerator.prototype.run; |
4699 MethodGenerator.prototype.visitAssertStatement$1 = MethodGenerator.prototype.vis
itAssertStatement; | |
4700 MethodGenerator.prototype.visitBinaryExpression$1 = function($0) { | 4624 MethodGenerator.prototype.visitBinaryExpression$1 = function($0) { |
4701 return this.visitBinaryExpression($0, false); | 4625 return this.visitBinaryExpression($0, false); |
4702 }; | 4626 }; |
4703 MethodGenerator.prototype.visitBlockStatement$1 = MethodGenerator.prototype.visi
tBlockStatement; | |
4704 MethodGenerator.prototype.visitBreakStatement$1 = MethodGenerator.prototype.visi
tBreakStatement; | |
4705 MethodGenerator.prototype.visitContinueStatement$1 = MethodGenerator.prototype.v
isitContinueStatement; | |
4706 MethodGenerator.prototype.visitDeclaredIdentifier$1 = MethodGenerator.prototype.
visitDeclaredIdentifier; | |
4707 MethodGenerator.prototype.visitDietStatement$1 = MethodGenerator.prototype.visit
DietStatement; | |
4708 MethodGenerator.prototype.visitDoStatement$1 = MethodGenerator.prototype.visitDo
Statement; | |
4709 MethodGenerator.prototype.visitEmptyStatement$1 = MethodGenerator.prototype.visi
tEmptyStatement; | |
4710 MethodGenerator.prototype.visitExpressionStatement$1 = MethodGenerator.prototype
.visitExpressionStatement; | |
4711 MethodGenerator.prototype.visitForInStatement$1 = MethodGenerator.prototype.visi
tForInStatement; | |
4712 MethodGenerator.prototype.visitForStatement$1 = MethodGenerator.prototype.visitF
orStatement; | |
4713 MethodGenerator.prototype.visitFunctionDefinition$1 = MethodGenerator.prototype.
visitFunctionDefinition; | |
4714 MethodGenerator.prototype.visitIfStatement$1 = MethodGenerator.prototype.visitIf
Statement; | |
4715 MethodGenerator.prototype.visitIndexExpression$1 = MethodGenerator.prototype.vis
itIndexExpression; | |
4716 MethodGenerator.prototype.visitLabeledStatement$1 = MethodGenerator.prototype.vi
sitLabeledStatement; | |
4717 MethodGenerator.prototype.visitLambdaExpression$1 = MethodGenerator.prototype.vi
sitLambdaExpression; | |
4718 MethodGenerator.prototype.visitLiteralExpression$1 = MethodGenerator.prototype.v
isitLiteralExpression; | |
4719 MethodGenerator.prototype.visitMapExpression$1 = MethodGenerator.prototype.visit
MapExpression; | |
4720 MethodGenerator.prototype.visitNewExpression$1 = MethodGenerator.prototype.visit
NewExpression; | |
4721 MethodGenerator.prototype.visitPostfixExpression$1 = function($0) { | 4627 MethodGenerator.prototype.visitPostfixExpression$1 = function($0) { |
4722 return this.visitPostfixExpression($0, false); | 4628 return this.visitPostfixExpression($0, false); |
4723 }; | 4629 }; |
4724 MethodGenerator.prototype.visitReturnStatement$1 = MethodGenerator.prototype.vis
itReturnStatement; | |
4725 MethodGenerator.prototype.visitSwitchStatement$1 = MethodGenerator.prototype.vis
itSwitchStatement; | |
4726 MethodGenerator.prototype.visitThrowStatement$1 = MethodGenerator.prototype.visi
tThrowStatement; | |
4727 MethodGenerator.prototype.visitTryStatement$1 = MethodGenerator.prototype.visitT
ryStatement; | |
4728 MethodGenerator.prototype.visitVariableDefinition$1 = MethodGenerator.prototype.
visitVariableDefinition; | |
4729 MethodGenerator.prototype.visitWhileStatement$1 = MethodGenerator.prototype.visi
tWhileStatement; | |
4730 MethodGenerator.prototype.writeDefinition$2 = MethodGenerator.prototype.writeDef
inition; | |
4731 // ********** Code for Arguments ************** | 4630 // ********** Code for Arguments ************** |
4732 function Arguments(nodes, values) { | 4631 function Arguments(nodes, values) { |
4733 this.nodes = nodes; | 4632 this.nodes = nodes; |
4734 this.values = values; | 4633 this.values = values; |
4735 } | 4634 } |
4736 Arguments.Arguments$bare$factory = function(arity) { | 4635 Arguments.Arguments$bare$factory = function(arity) { |
4737 var values = []; | 4636 var values = []; |
4738 for (var i = (0); | 4637 for (var i = (0); |
4739 i < arity; i++) { | 4638 i < arity; i++) { |
4740 values.add$1(new VariableValue($globals.world.varType, ("$" + i), null, fals
e)); | 4639 values.add(new VariableValue($globals.world.varType, ("$" + i), null, false)
); |
4741 } | 4640 } |
4742 return new Arguments(null, values); | 4641 return new Arguments(null, values); |
4743 } | 4642 } |
4744 Arguments.get$EMPTY = function() { | 4643 Arguments.get$EMPTY = function() { |
4745 if ($globals.Arguments__empty == null) { | 4644 if ($globals.Arguments__empty == null) { |
4746 $globals.Arguments__empty = new Arguments(null, []); | 4645 $globals.Arguments__empty = new Arguments(null, []); |
4747 } | 4646 } |
4748 return $globals.Arguments__empty; | 4647 return $globals.Arguments__empty; |
4749 } | 4648 } |
4750 Arguments.prototype.get$nameCount = function() { | 4649 Arguments.prototype.get$nameCount = function() { |
4751 return this.get$length() - this.get$bareCount(); | 4650 return this.get$length() - this.get$bareCount(); |
4752 } | 4651 } |
4753 Arguments.prototype.get$hasNames = function() { | 4652 Arguments.prototype.get$hasNames = function() { |
4754 return this.get$bareCount() < this.get$length(); | 4653 return this.get$bareCount() < this.get$length(); |
4755 } | 4654 } |
4756 Arguments.prototype.get$length = function() { | 4655 Arguments.prototype.get$length = function() { |
4757 return this.values.get$length(); | 4656 return this.values.get$length(); |
4758 } | 4657 } |
4759 Arguments.prototype.getName = function(i) { | 4658 Arguments.prototype.getName = function(i) { |
4760 return this.nodes[i].get$label().get$name(); | 4659 return this.nodes[i].label.name; |
4761 } | 4660 } |
4762 Arguments.prototype.getIndexOfName = function(name) { | 4661 Arguments.prototype.getIndexOfName = function(name) { |
4763 for (var i = this.get$bareCount(); | 4662 for (var i = this.get$bareCount(); |
4764 i < this.get$length(); i++) { | 4663 i < this.get$length(); i++) { |
4765 if (this.getName(i) == name) { | 4664 if (this.getName(i) == name) { |
4766 return i; | 4665 return i; |
4767 } | 4666 } |
4768 } | 4667 } |
4769 return (-1); | 4668 return (-1); |
4770 } | 4669 } |
4771 Arguments.prototype.getValue = function(name) { | 4670 Arguments.prototype.getValue = function(name) { |
4772 var i = this.getIndexOfName(name); | 4671 var i = this.getIndexOfName(name); |
4773 return i >= (0) ? this.values[i] : null; | 4672 return i >= (0) ? this.values.$index(i) : null; |
4774 } | 4673 } |
4775 Arguments.prototype.get$bareCount = function() { | 4674 Arguments.prototype.get$bareCount = function() { |
4776 if (this._bareCount == null) { | 4675 if (this._bareCount == null) { |
4777 this._bareCount = this.get$length(); | 4676 this._bareCount = this.get$length(); |
4778 if (this.nodes != null) { | 4677 if (this.nodes != null) { |
4779 for (var i = (0); | 4678 for (var i = (0); |
4780 i < this.nodes.get$length(); i++) { | 4679 i < this.nodes.get$length(); i++) { |
4781 if (this.nodes[i].get$label() != null) { | 4680 if (this.nodes[i].label != null) { |
4782 this._bareCount = i; | 4681 this._bareCount = i; |
4783 break; | 4682 break; |
4784 } | 4683 } |
4785 } | 4684 } |
4786 } | 4685 } |
4787 } | 4686 } |
4788 return this._bareCount; | 4687 return this._bareCount; |
4789 } | 4688 } |
4790 Arguments.prototype.getCode = function() { | 4689 Arguments.prototype.getCode = function() { |
4791 var argsCode = []; | 4690 var argsCode = []; |
4792 for (var i = (0); | 4691 for (var i = (0); |
4793 i < this.get$length(); i++) { | 4692 i < this.get$length(); i++) { |
4794 argsCode.add$1(this.values[i].get$code()); | 4693 argsCode.add(this.values.$index(i).get$code()); |
4795 } | 4694 } |
4796 Arguments.removeTrailingNulls(argsCode); | 4695 Arguments.removeTrailingNulls(argsCode); |
4797 return Strings.join(argsCode, ", "); | 4696 return Strings.join(argsCode, ", "); |
4798 } | 4697 } |
4799 Arguments.removeTrailingNulls = function(argsCode) { | 4698 Arguments.removeTrailingNulls = function(argsCode) { |
4800 while (argsCode.get$length() > (0) && $eq(argsCode.last(), "null")) { | 4699 while (argsCode.get$length() > (0) && $eq(argsCode.last(), "null")) { |
4801 argsCode.removeLast(); | 4700 argsCode.removeLast(); |
4802 } | 4701 } |
4803 } | 4702 } |
4804 Arguments.prototype.getNames = function() { | 4703 Arguments.prototype.getNames = function() { |
4805 var names = []; | 4704 var names = []; |
4806 for (var i = this.get$bareCount(); | 4705 for (var i = this.get$bareCount(); |
4807 i < this.get$length(); i++) { | 4706 i < this.get$length(); i++) { |
4808 names.add$1(this.getName(i)); | 4707 names.add(this.getName(i)); |
4809 } | 4708 } |
4810 return names; | 4709 return names; |
4811 } | 4710 } |
4812 Arguments.prototype.toCallStubArgs = function() { | 4711 Arguments.prototype.toCallStubArgs = function() { |
4813 var result = []; | 4712 var result = []; |
4814 for (var i = (0); | 4713 for (var i = (0); |
4815 i < this.get$bareCount(); i++) { | 4714 i < this.get$bareCount(); i++) { |
4816 result.add$1(new VariableValue($globals.world.varType, ("$" + i), null, fals
e)); | 4715 result.add(new VariableValue($globals.world.varType, ("$" + i), null, false)
); |
4817 } | 4716 } |
4818 for (var i = this.get$bareCount(); | 4717 for (var i = this.get$bareCount(); |
4819 i < this.get$length(); i++) { | 4718 i < this.get$length(); i++) { |
4820 var name = this.getName(i); | 4719 var name = this.getName(i); |
4821 if (name == null) name = ("$" + i); | 4720 if ($eq(name)) name = ("$" + i); |
4822 result.add$1(new VariableValue($globals.world.varType, name, null, false)); | 4721 result.add(new VariableValue($globals.world.varType, name, null, false)); |
4823 } | 4722 } |
4824 return new Arguments(this.nodes, result); | 4723 return new Arguments(this.nodes, result); |
4825 } | 4724 } |
| 4725 Arguments.prototype.matches = function(other) { |
| 4726 if (this.get$length() != other.get$length()) return false; |
| 4727 if (this.get$bareCount() != other.get$bareCount()) return false; |
| 4728 for (var i = (0); |
| 4729 i < this.get$bareCount(); i++) { |
| 4730 if ($ne(this.values.$index(i).get$type(), other.values.$index(i).get$type())
) return false; |
| 4731 } |
| 4732 return true; |
| 4733 } |
4826 // ********** Code for ReturnKind ************** | 4734 // ********** Code for ReturnKind ************** |
4827 function ReturnKind() {} | 4735 function ReturnKind() {} |
4828 // ********** Code for LibraryImport ************** | 4736 // ********** Code for LibraryImport ************** |
4829 function LibraryImport(library, prefix, span) { | 4737 function LibraryImport(library, prefix, span) { |
4830 this.library = library; | 4738 this.library = library; |
4831 this.span = span; | 4739 this.span = span; |
4832 this.prefix = prefix; | 4740 this.prefix = prefix; |
4833 } | 4741 } |
4834 LibraryImport.prototype.get$prefix = function() { return this.prefix; }; | 4742 LibraryImport.prototype.get$prefix = function() { return this.prefix; }; |
4835 LibraryImport.prototype.get$library = function() { return this.library; }; | 4743 LibraryImport.prototype.get$library = function() { return this.library; }; |
4836 LibraryImport.prototype.get$span = function() { return this.span; }; | 4744 LibraryImport.prototype.get$span = function() { return this.span; }; |
4837 // ********** Code for Member ************** | 4745 // ********** Code for Member ************** |
4838 $inherits(Member, Element); | 4746 $inherits(Member, Element); |
4839 function Member(name, declaringType) { | 4747 function Member(name, declaringType) { |
4840 this.isGenerated = false; | |
4841 this.declaringType = declaringType; | 4748 this.declaringType = declaringType; |
4842 this._provideFieldSyntax = false; | |
4843 this._providePropertySyntax = false; | 4749 this._providePropertySyntax = false; |
4844 Element.call(this, name, declaringType); | 4750 Element.call(this, name, declaringType); |
4845 } | 4751 } |
4846 Member.prototype.get$declaringType = function() { return this.declaringType; }; | 4752 Member.prototype.get$declaringType = function() { return this.declaringType; }; |
4847 Member.prototype.get$isGenerated = function() { return this.isGenerated; }; | 4753 Member.prototype.get$genericMember = function() { return this.genericMember; }; |
4848 Member.prototype.set$isGenerated = function(value) { return this.isGenerated = v
alue; }; | 4754 Member.prototype.set$genericMember = function(value) { return this.genericMember
= value; }; |
4849 Member.prototype.get$generator = function() { return this.generator; }; | |
4850 Member.prototype.set$generator = function(value) { return this.generator = value
; }; | |
4851 Member.prototype.get$library = function() { | 4755 Member.prototype.get$library = function() { |
4852 return this.declaringType.get$library(); | 4756 return this.declaringType.get$library(); |
4853 } | 4757 } |
4854 Member.prototype.get$isPrivate = function() { | 4758 Member.prototype.get$isPrivate = function() { |
4855 return this.name != null && this.name.startsWith("_"); | 4759 return this.name != null && this.name.startsWith("_"); |
4856 } | 4760 } |
4857 Member.prototype.get$isConstructor = function() { | 4761 Member.prototype.get$isConstructor = function() { |
4858 return false; | 4762 return false; |
4859 } | 4763 } |
4860 Member.prototype.get$isField = function() { | 4764 Member.prototype.get$isField = function() { |
(...skipping 16 matching lines...) Expand all Loading... |
4877 } | 4781 } |
4878 Member.prototype.get$isFactory = function() { | 4782 Member.prototype.get$isFactory = function() { |
4879 return false; | 4783 return false; |
4880 } | 4784 } |
4881 Member.prototype.get$isOperator = function() { | 4785 Member.prototype.get$isOperator = function() { |
4882 return this.name.startsWith(":"); | 4786 return this.name.startsWith(":"); |
4883 } | 4787 } |
4884 Member.prototype.get$isCallMethod = function() { | 4788 Member.prototype.get$isCallMethod = function() { |
4885 return this.name == ":call"; | 4789 return this.name == ":call"; |
4886 } | 4790 } |
4887 Member.prototype.get$requiresPropertySyntax = function() { | |
4888 return false; | |
4889 } | |
4890 Member.prototype.get$requiresFieldSyntax = function() { | |
4891 return false; | |
4892 } | |
4893 Member.prototype.get$isNative = function() { | 4791 Member.prototype.get$isNative = function() { |
4894 return false; | 4792 return false; |
4895 } | 4793 } |
4896 Member.prototype.get$constructorName = function() { | 4794 Member.prototype.get$constructorName = function() { |
4897 $globals.world.internalError("can not be a constructor", this.get$span()); | 4795 $globals.world.internalError("can not be a constructor", this.get$span()); |
4898 } | 4796 } |
4899 Member.prototype.provideFieldSyntax = function() { | |
4900 | |
4901 } | |
4902 Member.prototype.providePropertySyntax = function() { | 4797 Member.prototype.providePropertySyntax = function() { |
4903 | 4798 |
4904 } | 4799 } |
4905 Member.prototype.get$initDelegate = function() { | 4800 Member.prototype.get$initDelegate = function() { |
4906 $globals.world.internalError("cannot have initializers", this.get$span()); | 4801 $globals.world.internalError("cannot have initializers", this.get$span()); |
4907 } | 4802 } |
4908 Member.prototype.set$initDelegate = function(ctor) { | 4803 Member.prototype.set$initDelegate = function(ctor) { |
4909 $globals.world.internalError("cannot have initializers", this.get$span()); | 4804 $globals.world.internalError("cannot have initializers", this.get$span()); |
4910 } | 4805 } |
4911 Member.prototype.computeValue = function() { | 4806 Member.prototype.computeValue = function() { |
(...skipping 13 matching lines...) Expand all Loading... |
4925 return []; | 4820 return []; |
4926 } | 4821 } |
4927 Member.prototype.get$preciseMemberSet = function() { | 4822 Member.prototype.get$preciseMemberSet = function() { |
4928 if (this._preciseMemberSet == null) { | 4823 if (this._preciseMemberSet == null) { |
4929 this._preciseMemberSet = new MemberSet(this, false); | 4824 this._preciseMemberSet = new MemberSet(this, false); |
4930 } | 4825 } |
4931 return this._preciseMemberSet; | 4826 return this._preciseMemberSet; |
4932 } | 4827 } |
4933 Member.prototype.get$potentialMemberSet = function() { | 4828 Member.prototype.get$potentialMemberSet = function() { |
4934 if (this._potentialMemberSet == null) { | 4829 if (this._potentialMemberSet == null) { |
4935 if (this.declaringType.get$isObject()) { | 4830 if (this.name == ":call") { |
4936 this._potentialMemberSet = $globals.world._members.$index(this.name); | 4831 this._potentialMemberSet = this.get$preciseMemberSet(); |
4937 return this._potentialMemberSet; | 4832 return this._potentialMemberSet; |
4938 } | 4833 } |
4939 var mems = new HashSetImplementation(); | 4834 var mems = new HashSetImplementation_Member(); |
4940 if (this.declaringType.get$isClass()) mems.add$1(this); | 4835 if (this.declaringType.get$isClass()) mems.add(this); |
4941 var $$list = this.declaringType.get$subtypes(); | 4836 var $$list = this.declaringType.get$genericType().get$subtypes(); |
4942 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 4837 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
4943 var subtype = $$i.next$0(); | 4838 var subtype = $$i.next(); |
4944 if (!subtype.get$isClass()) continue; | 4839 if (!subtype.get$isClass()) continue; |
4945 var mem = subtype.get$members().$index(this.name); | 4840 var mem = subtype.get$members().$index(this.name); |
4946 if (mem != null) { | 4841 if (mem != null) { |
4947 mems.add$1(mem); | 4842 if (mem.isDefinedOn(this.declaringType)) { |
| 4843 mems.add(mem); |
| 4844 } |
4948 } | 4845 } |
4949 else if (!this.declaringType.get$isClass()) { | 4846 else if (!this.declaringType.get$isClass()) { |
4950 mem = subtype.getMember$1(this.name); | 4847 mem = subtype.getMember(this.name); |
4951 if (mem != null) { | 4848 if (mem != null && mem.isDefinedOn(this.declaringType)) { |
4952 mems.add$1(mem); | 4849 mems.add(mem); |
4953 } | 4850 } |
4954 } | 4851 } |
4955 } | 4852 } |
4956 if ($ne(mems.get$length(), (0))) { | 4853 if (mems.get$length() != (0)) { |
4957 for (var $$i = mems.iterator$0(); $$i.hasNext$0(); ) { | 4854 for (var $$i = mems.iterator(); $$i.hasNext(); ) { |
4958 var mem = $$i.next$0(); | 4855 var mem = $$i.next(); |
| 4856 if ($ne(this.declaringType.get$genericType(), this.declaringType) && mem
.get$genericMember() != null && mems.contains$1(mem.get$genericMember())) { |
| 4857 mems.remove$1(mem.get$genericMember()); |
| 4858 } |
| 4859 } |
| 4860 for (var $$i = mems.iterator(); $$i.hasNext(); ) { |
| 4861 var mem = $$i.next(); |
4959 if (this._potentialMemberSet == null) { | 4862 if (this._potentialMemberSet == null) { |
4960 this._potentialMemberSet = new MemberSet(mem, false); | 4863 this._potentialMemberSet = new MemberSet(mem, false); |
4961 } | 4864 } |
4962 else { | 4865 else { |
4963 this._potentialMemberSet.add(mem); | 4866 this._potentialMemberSet.add(mem); |
4964 } | 4867 } |
4965 } | 4868 } |
4966 } | 4869 } |
4967 } | 4870 } |
4968 return this._potentialMemberSet; | 4871 return this._potentialMemberSet; |
4969 } | 4872 } |
| 4873 Member.prototype.isDefinedOn = function(type) { |
| 4874 if (type.get$isClass()) { |
| 4875 if (this.declaringType.isSubtypeOf(type)) { |
| 4876 return true; |
| 4877 } |
| 4878 else if (type.isSubtypeOf(this.declaringType)) { |
| 4879 return $eq(type.getMember(this.name), this); |
| 4880 } |
| 4881 else { |
| 4882 return false; |
| 4883 } |
| 4884 } |
| 4885 else { |
| 4886 if (this.declaringType.isSubtypeOf(type)) { |
| 4887 return true; |
| 4888 } |
| 4889 else { |
| 4890 var $$list = this.declaringType.get$subtypes(); |
| 4891 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 4892 var t = $$i.next(); |
| 4893 if (t.isSubtypeOf(type) && $eq(t.getMember(this.name), this)) { |
| 4894 return true; |
| 4895 } |
| 4896 } |
| 4897 return false; |
| 4898 } |
| 4899 } |
| 4900 } |
4970 Member.prototype.canInvoke = function(context, args) { | 4901 Member.prototype.canInvoke = function(context, args) { |
4971 return this.get$canGet() && new Value(this.get$returnType(), null, null).canIn
voke(context, ":call", args); | 4902 if (this.get$canGet() && (this.get$isField() || this.get$isProperty())) { |
| 4903 return this.get$returnType().get$isFunction() || this.get$returnType().get$i
sVar() || this.get$returnType().getCallMethod() != null; |
| 4904 } |
| 4905 return false; |
4972 } | 4906 } |
4973 Member.prototype.invoke = function(context, node, target, args, isDynamic) { | 4907 Member.prototype.invoke = function(context, node, target, args) { |
4974 var newTarget = this._get(context, node, target, isDynamic); | 4908 var newTarget = this._get(context, node, target); |
4975 return newTarget.invoke$5(context, ":call", node, args, isDynamic); | 4909 return newTarget.invoke(context, ":call", node, args); |
4976 } | 4910 } |
4977 Member.prototype.override = function(other) { | 4911 Member.prototype.override = function(other) { |
4978 if (this.get$isStatic()) { | 4912 if (this.get$isStatic()) { |
4979 $globals.world.error("static members can not hide parent members", this.get$
span(), other.get$span()); | 4913 $globals.world.error("static members can not hide parent members", this.get$
span(), other.get$span()); |
4980 return false; | 4914 return false; |
4981 } | 4915 } |
4982 else if (other.get$isStatic()) { | 4916 else if (other.get$isStatic()) { |
4983 $globals.world.error("can not override static member", this.get$span(), othe
r.get$span()); | 4917 $globals.world.error("can not override static member", this.get$span(), othe
r.get$span()); |
4984 return false; | 4918 return false; |
4985 } | 4919 } |
4986 return true; | 4920 return true; |
4987 } | 4921 } |
4988 Member.prototype.get$generatedFactoryName = function() { | 4922 Member.prototype.get$generatedFactoryName = function() { |
4989 var prefix = ("" + this.declaringType.get$jsname() + "." + this.get$constructo
rName() + "$"); | 4923 var prefix = ("" + this.declaringType.get$genericType().get$jsname() + "." + t
his.get$constructorName() + "$"); |
4990 if (this.name == "") { | 4924 if (this.name == "") { |
4991 return ("" + prefix + "factory"); | 4925 return ("" + prefix + "factory"); |
4992 } | 4926 } |
4993 else { | 4927 else { |
4994 return ("" + prefix + this.name + "$factory"); | 4928 return ("" + prefix + this.name + "$factory"); |
4995 } | 4929 } |
4996 } | 4930 } |
4997 Member.prototype.hashCode = function() { | 4931 Member.prototype.hashCode = function() { |
4998 var typeCode = this.declaringType == null ? (1) : this.declaringType.hashCode(
); | 4932 var typeCode = this.declaringType == null ? (1) : this.declaringType.hashCode(
); |
4999 var nameCode = this.get$isConstructor() ? this.get$constructorName().hashCode(
) : this.name.hashCode(); | 4933 var nameCode = this.get$isConstructor() ? this.get$constructorName().hashCode(
) : this.name.hashCode(); |
5000 return (typeCode << (4)) ^ nameCode; | 4934 return $bit_xor(($shl(typeCode, (4))), nameCode); |
5001 } | 4935 } |
5002 Member.prototype.$eq = function(other) { | 4936 Member.prototype.$eq = function(other) { |
5003 return (other instanceof Member) && $eq(this.get$isConstructor(), other.get$is
Constructor()) && $eq(this.declaringType, other.get$declaringType()) && (this.ge
t$isConstructor() ? this.get$constructorName() == other.get$constructorName() :
this.name == other.get$name()); | 4937 return (other instanceof Member) && $eq(this.get$isConstructor(), other.get$is
Constructor()) && $eq(this.declaringType, other.get$declaringType()) && (this.ge
t$isConstructor() ? this.get$constructorName() == other.get$constructorName() :
this.name == other.get$name()); |
5004 } | 4938 } |
5005 Member.prototype._get$3 = Member.prototype._get; | 4939 Member.prototype.resolveType = function(node, typeErrors, allowTypeParams) { |
5006 Member.prototype._get$3$isDynamic = Member.prototype._get; | 4940 allowTypeParams = allowTypeParams && !(this.get$isStatic() && !this.get$isFact
ory()); |
5007 Member.prototype._get$4 = Member.prototype._get; | 4941 return Element.prototype.resolveType.call(this, node, typeErrors, allowTypePar
ams); |
5008 Member.prototype._set$4$isDynamic = Member.prototype._set; | 4942 } |
5009 Member.prototype._set$5 = Member.prototype._set; | 4943 Member.prototype.makeConcrete = function(concreteType) { |
5010 Member.prototype.canInvoke$2 = Member.prototype.canInvoke; | 4944 $globals.world.internalError("can not make this concrete", this.get$span()); |
5011 Member.prototype.computeValue$0 = Member.prototype.computeValue; | 4945 } |
5012 Member.prototype.hashCode$0 = Member.prototype.hashCode; | |
5013 Member.prototype.invoke$4 = function($0, $1, $2, $3) { | |
5014 return this.invoke($0, $1, $2, $3, false); | |
5015 }; | |
5016 Member.prototype.invoke$4$isDynamic = Member.prototype.invoke; | |
5017 Member.prototype.invoke$5 = Member.prototype.invoke; | |
5018 Member.prototype.provideFieldSyntax$0 = Member.prototype.provideFieldSyntax; | |
5019 Member.prototype.providePropertySyntax$0 = Member.prototype.providePropertySynta
x; | |
5020 // ********** Code for AmbiguousMember ************** | 4946 // ********** Code for AmbiguousMember ************** |
5021 $inherits(AmbiguousMember, Member); | 4947 $inherits(AmbiguousMember, Member); |
5022 function AmbiguousMember(name, members) { | 4948 function AmbiguousMember(name, members) { |
5023 this.members = members; | 4949 this.members = members; |
5024 Member.call(this, name, null); | 4950 Member.call(this, name, null); |
5025 } | 4951 } |
5026 AmbiguousMember.prototype.get$members = function() { return this.members; }; | 4952 AmbiguousMember.prototype.get$members = function() { return this.members; }; |
5027 AmbiguousMember.prototype.set$members = function(value) { return this.members =
value; }; | 4953 AmbiguousMember.prototype.set$members = function(value) { return this.members =
value; }; |
5028 // ********** Code for Library ************** | 4954 // ********** Code for Library ************** |
5029 $inherits(Library, Element); | 4955 $inherits(Library, Element); |
5030 function Library(baseSource) { | 4956 function Library(baseSource) { |
5031 this.baseSource = baseSource; | 4957 this.baseSource = baseSource; |
5032 this.isWritten = false; | 4958 this.isWritten = false; |
5033 Element.call(this, null, null); | 4959 Element.call(this, null, null); |
5034 this.sourceDir = dirname(this.baseSource.filename); | 4960 this.sourceDir = dirname(this.baseSource.filename); |
5035 this.topType = new DefinedType(null, this, null, true); | 4961 this.topType = new DefinedType(null, this, null, true); |
5036 this.types = _map(["", this.topType]); | 4962 this.types = _map(["", this.topType]); |
5037 this.imports = []; | 4963 this.imports = []; |
5038 this.natives = []; | 4964 this.natives = []; |
5039 this.sources = []; | 4965 this.sources = []; |
5040 this._privateMembers = new HashMapImplementation(); | 4966 this._privateMembers = new HashMapImplementation(); |
5041 } | 4967 } |
5042 Library.prototype.get$baseSource = function() { return this.baseSource; }; | 4968 Library.prototype.get$baseSource = function() { return this.baseSource; }; |
5043 Library.prototype.get$types = function() { return this.types; }; | 4969 Library.prototype.get$types = function() { return this.types; }; |
5044 Library.prototype.set$types = function(value) { return this.types = value; }; | 4970 Library.prototype.set$types = function(value) { return this.types = value; }; |
5045 Library.prototype.get$imports = function() { return this.imports; }; | 4971 Library.prototype.get$imports = function() { return this.imports; }; |
5046 Library.prototype.set$imports = function(value) { return this.imports = value; }
; | 4972 Library.prototype.set$imports = function(value) { return this.imports = value; }
; |
5047 Library.prototype.get$_privateMembers = function() { return this._privateMembers
; }; | 4973 Library.prototype.get$_privateMembers = function() { return this._privateMembers
; }; |
5048 Library.prototype.set$_privateMembers = function(value) { return this._privateMe
mbers = value; }; | 4974 Library.prototype.set$_privateMembers = function(value) { return this._privateMe
mbers = value; }; |
5049 Library.prototype.get$topType = function() { return this.topType; }; | |
5050 Library.prototype.set$topType = function(value) { return this.topType = value; }
; | |
5051 Library.prototype.get$enclosingElement = function() { | 4975 Library.prototype.get$enclosingElement = function() { |
5052 return null; | 4976 return null; |
5053 } | 4977 } |
5054 Library.prototype.get$library = function() { | 4978 Library.prototype.get$library = function() { |
5055 return this; | 4979 return this; |
5056 } | 4980 } |
5057 Library.prototype.get$isNative = function() { | 4981 Library.prototype.get$isNative = function() { |
5058 return this.topType.isNative; | 4982 return this.topType.isNative; |
5059 } | 4983 } |
5060 Library.prototype.get$isCore = function() { | 4984 Library.prototype.get$isCore = function() { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5095 } | 5019 } |
5096 Library.prototype._addMember = function(member) { | 5020 Library.prototype._addMember = function(member) { |
5097 if (member.get$isPrivate()) { | 5021 if (member.get$isPrivate()) { |
5098 if (member.get$isStatic()) { | 5022 if (member.get$isStatic()) { |
5099 if (member.declaringType.get$isTop()) { | 5023 if (member.declaringType.get$isTop()) { |
5100 $globals.world._addTopName(member); | 5024 $globals.world._addTopName(member); |
5101 } | 5025 } |
5102 return; | 5026 return; |
5103 } | 5027 } |
5104 var mset = this._privateMembers.$index(member.name); | 5028 var mset = this._privateMembers.$index(member.name); |
5105 if (mset == null) { | 5029 if ($eq(mset)) { |
5106 var $$list = $globals.world.libraries.getValues(); | 5030 var $$list = $globals.world.libraries.getValues(); |
5107 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 5031 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
5108 var lib = $$i.next$0(); | 5032 var lib = $$i.next(); |
5109 if (lib.get$_privateMembers().containsKey$1(member.get$jsname())) { | 5033 if (lib.get$_privateMembers().containsKey(member.get$jsname())) { |
5110 member._jsname = ("_" + this.get$jsname() + member.get$jsname()); | 5034 member._jsname = ("_" + this.get$jsname() + member.get$jsname()); |
5111 break; | 5035 break; |
5112 } | 5036 } |
5113 } | 5037 } |
5114 mset = new MemberSet(member, true); | 5038 mset = new MemberSet(member, true); |
5115 this._privateMembers.$setindex(member.name, mset); | 5039 this._privateMembers.$setindex(member.name, mset); |
5116 } | 5040 } |
5117 else { | 5041 else { |
5118 mset.get$members().add$1(member); | 5042 mset.get$members().add(member); |
5119 } | 5043 } |
5120 } | 5044 } |
5121 else { | 5045 else { |
5122 $globals.world._addMember(member); | 5046 $globals.world._addMember(member); |
5123 } | 5047 } |
5124 } | 5048 } |
5125 Library.prototype.getOrAddFunctionType = function(enclosingElement, name, func)
{ | 5049 Library.prototype.getOrAddFunctionType = function(enclosingElement, name, func,
data) { |
5126 var def = new FunctionTypeDefinition(func, null, func.span); | 5050 var def = new FunctionTypeDefinition(func, null, func.span); |
5127 var type = new DefinedType(name, this, def, false); | 5051 var type = new DefinedType(name, this, def, false); |
5128 type.addMethod$2(":call", func); | 5052 type.addMethod(":call", func); |
5129 var m = type.get$members().$index(":call"); | 5053 var m = type.get$members().$index(":call"); |
5130 m.set$enclosingElement(enclosingElement); | 5054 m.set$enclosingElement(enclosingElement); |
5131 m.resolve$0(); | 5055 m.resolve(); |
| 5056 m.set$_methodData(data); |
5132 type.set$interfaces([$globals.world.functionType]); | 5057 type.set$interfaces([$globals.world.functionType]); |
5133 return type; | 5058 return type; |
5134 } | 5059 } |
5135 Library.prototype.addType = function(name, definition, isClass) { | 5060 Library.prototype.addType = function(name, definition, isClass) { |
5136 if (this.types.containsKey(name)) { | 5061 if (this.types.containsKey(name)) { |
5137 var existingType = this.types.$index(name); | 5062 var existingType = this.types.$index(name); |
5138 if ((this.get$isCore() || this.get$isCoreImpl()) && existingType.get$definit
ion() == null) { | 5063 if ((this.get$isCore() || this.get$isCoreImpl()) && $eq(existingType.get$def
inition())) { |
5139 existingType.setDefinition$1(definition); | 5064 existingType.setDefinition(definition); |
5140 } | 5065 } |
5141 else { | 5066 else { |
5142 $globals.world.warning(("duplicate definition of " + name), definition.spa
n, existingType.get$span()); | 5067 $globals.world.warning(("duplicate definition of " + name), definition.spa
n, existingType.get$span()); |
5143 } | 5068 } |
5144 } | 5069 } |
5145 else { | 5070 else { |
5146 this.types.$setindex(name, new DefinedType(name, this, definition, isClass))
; | 5071 this.types.$setindex(name, new DefinedType(name, this, definition, isClass))
; |
5147 } | 5072 } |
5148 return this.types.$index(name); | 5073 return this.types.$index(name); |
5149 } | 5074 } |
5150 Library.prototype.findType = function(type) { | 5075 Library.prototype.findType = function(type) { |
5151 var result = this.findTypeByName(type.name.name); | 5076 var result = this.findTypeByName(type.name.name); |
5152 if (result == null) return null; | 5077 if (result == null) return null; |
5153 if (type.names != null) { | 5078 if (type.names != null) { |
5154 if (type.names.get$length() > (1)) { | 5079 if (type.names.get$length() > (1)) { |
5155 return null; | 5080 return null; |
5156 } | 5081 } |
5157 if (!result.get$isTop()) { | 5082 if (!result.get$isTop()) { |
5158 return null; | 5083 return null; |
5159 } | 5084 } |
5160 return result.get$library().findTypeByName(type.names[(0)].get$name()); | 5085 return result.get$library().findTypeByName(type.names[(0)].name); |
5161 } | 5086 } |
5162 return result; | 5087 return result; |
5163 } | 5088 } |
5164 Library.prototype.findTypeByName = function(name) { | 5089 Library.prototype.findTypeByName = function(name) { |
5165 var ret = this.types.$index(name); | 5090 var ret = this.types.$index(name); |
5166 var $$list = this.imports; | 5091 var $$list = this.imports; |
5167 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 5092 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
5168 var imported = $$list[$$i]; | 5093 var imported = $$i.next(); |
5169 var newRet = null; | 5094 var newRet = null; |
5170 if (imported.get$prefix() == null) { | 5095 if (imported.get$prefix() == null) { |
5171 newRet = imported.get$library().get$types().$index(name); | 5096 newRet = imported.get$library().types.$index(name); |
5172 } | 5097 } |
5173 else if ($eq(imported.get$prefix(), name)) { | 5098 else if (imported.get$prefix() == name) { |
5174 newRet = imported.get$library().get$topType(); | 5099 newRet = imported.get$library().topType; |
5175 } | 5100 } |
5176 if (newRet != null) { | 5101 if ($ne(newRet)) { |
5177 if (ret != null && $ne(ret, newRet)) { | 5102 if ($ne(ret) && $ne(ret, newRet)) { |
5178 $globals.world.error(("conflicting types for \"" + name + "\""), ret.get
$span(), newRet.get$span()); | 5103 $globals.world.error(("conflicting types for \"" + name + "\""), ret.get
$span(), newRet.get$span()); |
5179 } | 5104 } |
5180 else { | 5105 else { |
5181 ret = newRet; | 5106 ret = newRet; |
5182 } | 5107 } |
5183 } | 5108 } |
5184 } | 5109 } |
5185 return ret; | 5110 return ret; |
5186 } | 5111 } |
5187 Library.prototype.resolveType = function(node, typeErrors) { | 5112 Library.prototype.resolveType = function(node, typeErrors, allowTypeParams) { |
5188 if (node == null) return $globals.world.varType; | 5113 if (node == null) return $globals.world.varType; |
5189 if (node.type != null) return node.type; | 5114 var ret = this.findType(node); |
5190 node.type = this.findType(node); | 5115 if ($eq(ret)) { |
5191 if (node.type == null) { | |
5192 var message = ("cannot find type " + Library._getDottedName(node)); | 5116 var message = ("cannot find type " + Library._getDottedName(node)); |
5193 if (typeErrors) { | 5117 if (typeErrors) { |
5194 $globals.world.error(message, node.span); | 5118 $globals.world.error(message, node.span); |
5195 node.type = $globals.world.objectType; | 5119 return $globals.world.objectType; |
5196 } | 5120 } |
5197 else { | 5121 else { |
5198 $globals.world.warning(message, node.span); | 5122 $globals.world.warning(message, node.span); |
5199 node.type = $globals.world.varType; | 5123 return $globals.world.varType; |
5200 } | 5124 } |
5201 } | 5125 } |
5202 return node.type; | 5126 return ret; |
5203 } | 5127 } |
5204 Library._getDottedName = function(type) { | 5128 Library._getDottedName = function(type) { |
5205 if (type.names != null) { | 5129 if (type.names != null) { |
5206 var names = map(type.names, (function (n) { | 5130 var names = map(type.names, (function (n) { |
5207 return n.get$name(); | 5131 return n.get$name(); |
5208 }) | 5132 }) |
5209 ); | 5133 ); |
5210 return type.name.name + "." + Strings.join(names, "."); | 5134 return $add($add(type.name.name, "."), Strings.join(names, ".")); |
5211 } | 5135 } |
5212 else { | 5136 else { |
5213 return type.name.name; | 5137 return type.name.name; |
5214 } | 5138 } |
5215 } | 5139 } |
5216 Library.prototype.lookup = function(name, span) { | 5140 Library.prototype.lookup = function(name, span) { |
5217 return this._topNames.$index(name); | 5141 return this._topNames.$index(name); |
5218 } | 5142 } |
5219 Library.prototype.resolve = function() { | 5143 Library.prototype.resolve = function() { |
5220 if (this.name == null) { | 5144 if (this.name == null) { |
5221 this.name = this.baseSource.filename; | 5145 this.name = this.baseSource.filename; |
5222 var index = this.name.lastIndexOf("/", this.name.length); | 5146 var index = this.name.lastIndexOf("/", this.name.length); |
5223 if (index >= (0)) { | 5147 if ($gte(index, (0))) { |
5224 this.name = this.name.substring($add(index, (1))); | 5148 this.name = this.name.substring($add(index, (1))); |
5225 } | 5149 } |
5226 index = this.name.indexOf("."); | 5150 index = this.name.indexOf("."); |
5227 if (index > (0)) { | 5151 if ($gt(index, (0))) { |
5228 this.name = this.name.substring((0), index); | 5152 this.name = this.name.substring((0), index); |
5229 } | 5153 } |
5230 } | 5154 } |
5231 this._jsname = this.name.replaceAll(".", "_").replaceAll(":", "_").replaceAll(
" ", "_"); | 5155 this._jsname = this.name.replaceAll(".", "_").replaceAll(":", "_").replaceAll(
" ", "_"); |
5232 var $$list = this.types.getValues(); | 5156 var $$list = this.types.getValues(); |
5233 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 5157 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
5234 var type = $$i.next$0(); | 5158 var type = $$i.next(); |
5235 type.resolve$0(); | 5159 type.resolve(); |
5236 } | 5160 } |
5237 } | 5161 } |
5238 Library.prototype._addTopName = function(name, member, localSpan) { | 5162 Library.prototype._addTopName = function(name, member, localSpan) { |
5239 var existing = this._topNames.$index(name); | 5163 var existing = this._topNames.$index(name); |
5240 if (existing == null) { | 5164 if (existing == null) { |
5241 this._topNames.$setindex(name, member); | 5165 this._topNames.$setindex(name, member); |
5242 } | 5166 } |
5243 else { | 5167 else { |
5244 if ((existing instanceof AmbiguousMember)) { | 5168 if ((existing instanceof AmbiguousMember)) { |
5245 existing.get$members().add$1(member); | 5169 existing.get$members().add(member); |
5246 } | 5170 } |
5247 else { | 5171 else { |
5248 var newMember = new AmbiguousMember(name, [existing, member]); | 5172 var newMember = new AmbiguousMember(name, [existing, member]); |
5249 $globals.world.error(("conflicting members for \"" + name + "\""), existin
g.get$span(), member.get$span(), localSpan); | 5173 $globals.world.error(("conflicting members for \"" + name + "\""), existin
g.get$span(), member.get$span(), localSpan); |
5250 this._topNames.$setindex(name, newMember); | 5174 this._topNames.$setindex(name, newMember); |
5251 } | 5175 } |
5252 } | 5176 } |
5253 } | 5177 } |
5254 Library.prototype._addTopNames = function(lib) { | 5178 Library.prototype._addTopNames = function(lib) { |
5255 var $$list = lib.topType.members.getValues(); | 5179 var $$list = lib.topType.members.getValues(); |
5256 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 5180 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
5257 var member = $$i.next$0(); | 5181 var member = $$i.next(); |
5258 if (member.get$isPrivate() && $ne(lib, this)) continue; | 5182 if (member.get$isPrivate() && $ne(lib, this)) continue; |
5259 this._addTopName(member.get$name(), member); | 5183 this._addTopName(member.get$name(), member); |
5260 } | 5184 } |
5261 var $$list = lib.types.getValues(); | 5185 var $$list = lib.types.getValues(); |
5262 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 5186 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
5263 var type = $$i.next$0(); | 5187 var type = $$i.next(); |
5264 if (!type.get$isTop()) { | 5188 if (!type.get$isTop()) { |
5265 if ($ne(lib, this) && type.get$typeMember().get$isPrivate()) continue; | 5189 if ($ne(lib, this) && type.get$typeMember().get$isPrivate()) continue; |
5266 this._addTopName(type.get$name(), type.get$typeMember()); | 5190 this._addTopName(type.get$name(), type.get$typeMember()); |
5267 } | 5191 } |
5268 } | 5192 } |
5269 } | 5193 } |
5270 Library.prototype.postResolveChecks = function() { | 5194 Library.prototype.postResolveChecks = function() { |
5271 this._topNames = new HashMapImplementation(); | 5195 this._topNames = new HashMapImplementation(); |
5272 this._addTopNames(this); | 5196 this._addTopNames(this); |
5273 var $$list = this.imports; | 5197 var $$list = this.imports; |
5274 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 5198 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
5275 var imported = $$list[$$i]; | 5199 var imported = $$i.next(); |
5276 if (imported.get$prefix() == null) { | 5200 if (imported.get$prefix() == null) { |
5277 this._addTopNames(imported.get$library()); | 5201 this._addTopNames(imported.get$library()); |
5278 } | 5202 } |
5279 else { | 5203 else { |
5280 this._addTopName(imported.get$prefix(), imported.get$library().get$topType
().get$typeMember(), imported.get$span()); | 5204 this._addTopName(imported.get$prefix(), imported.get$library().topType.get
$typeMember(), imported.get$span()); |
5281 } | 5205 } |
5282 } | 5206 } |
5283 } | 5207 } |
5284 Library.prototype.visitSources = function() { | 5208 Library.prototype.visitSources = function() { |
5285 var visitor = new _LibraryVisitor(this); | 5209 var visitor = new _LibraryVisitor(this); |
5286 visitor.addSource$1(this.baseSource); | 5210 visitor.addSource(this.baseSource); |
5287 } | 5211 } |
5288 Library.prototype.toString = function() { | 5212 Library.prototype.toString = function() { |
5289 return this.baseSource.filename; | 5213 return this.baseSource.filename; |
5290 } | 5214 } |
5291 Library.prototype.hashCode = function() { | 5215 Library.prototype.hashCode = function() { |
5292 return this.baseSource.filename.hashCode(); | 5216 return this.baseSource.filename.hashCode(); |
5293 } | 5217 } |
5294 Library.prototype.$eq = function(other) { | 5218 Library.prototype.$eq = function(other) { |
5295 return (other instanceof Library) && $eq(other.get$baseSource().get$filename()
, this.baseSource.filename); | 5219 return (other instanceof Library) && other.get$baseSource().filename == this.b
aseSource.filename; |
5296 } | 5220 } |
5297 Library.prototype.findTypeByName$1 = Library.prototype.findTypeByName; | |
5298 Library.prototype.hashCode$0 = Library.prototype.hashCode; | |
5299 Library.prototype.lookup$2 = Library.prototype.lookup; | |
5300 Library.prototype.postResolveChecks$0 = Library.prototype.postResolveChecks; | |
5301 Library.prototype.resolve$0 = Library.prototype.resolve; | |
5302 Library.prototype.resolveType$2 = Library.prototype.resolveType; | |
5303 Library.prototype.toString$0 = Library.prototype.toString; | 5221 Library.prototype.toString$0 = Library.prototype.toString; |
5304 Library.prototype.visitSources$0 = Library.prototype.visitSources; | |
5305 // ********** Code for _LibraryVisitor ************** | 5222 // ********** Code for _LibraryVisitor ************** |
5306 function _LibraryVisitor(library) { | 5223 function _LibraryVisitor(library) { |
5307 this.library = library; | 5224 this.library = library; |
5308 this.isTop = true; | 5225 this.isTop = true; |
5309 this.seenSource = false; | 5226 this.seenSource = false; |
5310 this.seenResource = false; | 5227 this.seenResource = false; |
5311 this.seenImport = false; | 5228 this.seenImport = false; |
5312 this.currentType = this.library.topType; | 5229 this.currentType = this.library.topType; |
5313 this.sources = []; | 5230 this.sources = []; |
5314 } | 5231 } |
5315 _LibraryVisitor.prototype.get$library = function() { return this.library; }; | 5232 _LibraryVisitor.prototype.get$library = function() { return this.library; }; |
5316 _LibraryVisitor.prototype.get$isTop = function() { return this.isTop; }; | 5233 _LibraryVisitor.prototype.get$isTop = function() { return this.isTop; }; |
5317 _LibraryVisitor.prototype.set$isTop = function(value) { return this.isTop = valu
e; }; | 5234 _LibraryVisitor.prototype.set$isTop = function(value) { return this.isTop = valu
e; }; |
5318 _LibraryVisitor.prototype.addSourceFromName = function(name, span) { | 5235 _LibraryVisitor.prototype.addSourceFromName = function(name, span) { |
5319 var filename = this.library.makeFullPath(name); | 5236 var filename = this.library.makeFullPath(name); |
5320 if ($eq(filename, this.library.baseSource.filename)) { | 5237 if ($eq(filename, this.library.baseSource.filename)) { |
5321 $globals.world.error("library can not source itself", span); | 5238 $globals.world.error("library can not source itself", span); |
5322 return; | 5239 return; |
5323 } | 5240 } |
5324 else if (this.sources.some((function (s) { | 5241 else if (this.sources.some((function (s) { |
5325 return $eq(s.get$filename(), filename); | 5242 return s.get$filename() == filename; |
5326 }) | 5243 }) |
5327 )) { | 5244 )) { |
5328 $globals.world.error(("file \"" + filename + "\" has already been sourced"),
span); | 5245 $globals.world.error(("file \"" + filename + "\" has already been sourced"),
span); |
5329 return; | 5246 return; |
5330 } | 5247 } |
5331 var source = $globals.world.readFile(this.library.makeFullPath(name)); | 5248 var source = $globals.world.readFile(this.library.makeFullPath(name)); |
5332 this.sources.add(source); | 5249 this.sources.add(source); |
5333 } | 5250 } |
5334 _LibraryVisitor.prototype.addSource = function(source) { | 5251 _LibraryVisitor.prototype.addSource = function(source) { |
5335 var $this = this; // closure support | 5252 var $this = this; // closure support |
5336 if (this.library.sources.some((function (s) { | 5253 if (this.library.sources.some((function (s) { |
5337 return $eq(s.get$filename(), source.filename); | 5254 return s.get$filename() == source.filename; |
5338 }) | 5255 }) |
5339 )) { | 5256 )) { |
5340 $globals.world.error(("duplicate source file \"" + source.filename + "\"")); | 5257 $globals.world.error(("duplicate source file \"" + source.filename + "\"")); |
5341 return; | 5258 return; |
5342 } | 5259 } |
5343 this.library.sources.add(source); | 5260 this.library.sources.add(source); |
5344 var parser = new Parser(source, $globals.options.dietParse, false, false, (0))
; | 5261 var parser = new Parser(source, $globals.options.dietParse, false, false, (0))
; |
5345 var unit = parser.compilationUnit$0(); | 5262 var unit = parser.compilationUnit(); |
5346 unit.forEach$1((function (def) { | 5263 unit.forEach((function (def) { |
5347 return def.visit$1($this); | 5264 return def.visit($this); |
5348 }) | 5265 }) |
5349 ); | 5266 ); |
5350 this.isTop = false; | 5267 this.isTop = false; |
5351 var newSources = this.sources; | 5268 var newSources = this.sources; |
5352 this.sources = []; | 5269 this.sources = []; |
5353 for (var $$i = newSources.iterator$0(); $$i.hasNext$0(); ) { | 5270 for (var $$i = newSources.iterator(); $$i.hasNext(); ) { |
5354 var source0 = $$i.next$0(); | 5271 var newSource = $$i.next(); |
5355 this.addSource(source0); | 5272 this.addSource(newSource); |
5356 } | 5273 } |
5357 } | 5274 } |
5358 _LibraryVisitor.prototype.visitDirectiveDefinition = function(node) { | 5275 _LibraryVisitor.prototype.visitDirectiveDefinition = function(node) { |
5359 if (!this.isTop) { | 5276 if (!this.isTop) { |
5360 $globals.world.error("directives not allowed in sourced file", node.span); | 5277 $globals.world.error("directives not allowed in sourced file", node.span); |
5361 return; | 5278 return; |
5362 } | 5279 } |
5363 var name; | 5280 var name; |
5364 switch (node.name.name) { | 5281 switch (node.name.name) { |
5365 case "library": | 5282 case "library": |
(...skipping 11 matching lines...) Expand all Loading... |
5377 else { | 5294 else { |
5378 $globals.world.error("already specified library name", node.span); | 5295 $globals.world.error("already specified library name", node.span); |
5379 } | 5296 } |
5380 break; | 5297 break; |
5381 | 5298 |
5382 case "import": | 5299 case "import": |
5383 | 5300 |
5384 this.seenImport = true; | 5301 this.seenImport = true; |
5385 name = this.getFirstStringArg(node); | 5302 name = this.getFirstStringArg(node); |
5386 var prefix = this.tryGetNamedStringArg(node, "prefix"); | 5303 var prefix = this.tryGetNamedStringArg(node, "prefix"); |
5387 if (node.arguments.get$length() > (2) || node.arguments.get$length() == (2
) && prefix == null) { | 5304 if (node.arguments.get$length() > (2) || node.arguments.get$length() == (2
) && $eq(prefix)) { |
5388 $globals.world.error("expected at most one \"name\" argument and one opt
ional \"prefix\"" + (" but found " + node.arguments.get$length()), node.span); | 5305 $globals.world.error($add("expected at most one \"name\" argument and on
e optional \"prefix\"", (" but found " + node.arguments.get$length())), node.spa
n); |
5389 } | 5306 } |
5390 else if (prefix != null && prefix.indexOf$1(".") >= (0)) { | 5307 else if ($ne(prefix) && $gte(prefix.indexOf$1("."), (0))) { |
5391 $globals.world.error("library prefix canot contain \".\"", node.span); | 5308 $globals.world.error("library prefix canot contain \".\"", node.span); |
5392 } | 5309 } |
5393 else if (this.seenSource || this.seenResource) { | 5310 else if (this.seenSource || this.seenResource) { |
5394 $globals.world.error("#imports must come before any #source or #resource
", node.span); | 5311 $globals.world.error("#imports must come before any #source or #resource
", node.span); |
5395 } | 5312 } |
5396 if ($eq(prefix, "")) prefix = null; | 5313 if ($eq(prefix, "")) prefix = null; |
5397 var filename = this.library.makeFullPath(name); | 5314 var filename = this.library.makeFullPath(name); |
5398 if (this.library.imports.some((function (li) { | 5315 if (this.library.imports.some((function (li) { |
5399 return $eq(li.get$library().get$baseSource(), filename); | 5316 return $eq(li.get$library().baseSource, filename); |
5400 }) | 5317 }) |
5401 )) { | 5318 )) { |
5402 $globals.world.error(("duplicate import of \"" + name + "\""), node.span
); | 5319 $globals.world.error(("duplicate import of \"" + name + "\""), node.span
); |
5403 return; | 5320 return; |
5404 } | 5321 } |
5405 var newLib = this.library.addImport(filename, prefix, node.span); | 5322 var newLib = this.library.addImport(filename, prefix, node.span); |
5406 break; | 5323 break; |
5407 | 5324 |
5408 case "source": | 5325 case "source": |
5409 | 5326 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5443 if (node.arguments.get$length() < (1)) { | 5360 if (node.arguments.get$length() < (1)) { |
5444 $globals.world.error(("expected at least one argument but found " + node.arg
uments.get$length()), node.span); | 5361 $globals.world.error(("expected at least one argument but found " + node.arg
uments.get$length()), node.span); |
5445 } | 5362 } |
5446 var arg = node.arguments[(0)]; | 5363 var arg = node.arguments[(0)]; |
5447 if (arg.get$label() != null) { | 5364 if (arg.get$label() != null) { |
5448 $globals.world.error("label not allowed for directive", node.span); | 5365 $globals.world.error("label not allowed for directive", node.span); |
5449 } | 5366 } |
5450 return this._parseStringArgument(arg); | 5367 return this._parseStringArgument(arg); |
5451 } | 5368 } |
5452 _LibraryVisitor.prototype.tryGetNamedStringArg = function(node, argName) { | 5369 _LibraryVisitor.prototype.tryGetNamedStringArg = function(node, argName) { |
5453 var args = node.arguments.filter$1((function (a) { | 5370 var args = node.arguments.filter((function (a) { |
5454 return a.get$label() != null && $eq(a.get$label().get$name(), argName); | 5371 return a.get$label() != null && a.get$label().name == argName; |
5455 }) | 5372 }) |
5456 ); | 5373 ); |
5457 if ($eq(args.get$length(), (0))) { | 5374 if (args.get$length() == (0)) { |
5458 return null; | 5375 return null; |
5459 } | 5376 } |
5460 if (args.get$length() > (1)) { | 5377 if (args.get$length() > (1)) { |
5461 $globals.world.error(("expected at most one \"" + argName + "\" argument but
found ") + node.arguments.get$length(), node.span); | 5378 $globals.world.error(("expected at most one \"" + argName + "\" argument but
found ") + node.arguments.get$length(), node.span); |
5462 } | 5379 } |
5463 for (var $$i = args.iterator$0(); $$i.hasNext$0(); ) { | 5380 for (var $$i = args.iterator(); $$i.hasNext(); ) { |
5464 var arg = $$i.next$0(); | 5381 var arg = $$i.next(); |
5465 return this._parseStringArgument(arg); | 5382 return this._parseStringArgument(arg); |
5466 } | 5383 } |
5467 } | 5384 } |
5468 _LibraryVisitor.prototype._parseStringArgument = function(arg) { | 5385 _LibraryVisitor.prototype._parseStringArgument = function(arg) { |
5469 var expr = arg.value; | 5386 var expr = arg.value; |
5470 if (!(expr instanceof LiteralExpression) || !expr.get$value().get$type().get$i
sString()) { | 5387 if (!(expr instanceof LiteralExpression) || !expr.get$value().get$type().get$i
sString()) { |
5471 $globals.world.error("expected string literal", expr.get$span()); | 5388 $globals.world.error("expected string literal", expr.get$span()); |
5472 } | 5389 } |
5473 return expr.get$value().get$actualValue(); | 5390 return expr.get$value().get$actualValue(); |
5474 } | 5391 } |
5475 _LibraryVisitor.prototype.visitTypeDefinition = function(node) { | 5392 _LibraryVisitor.prototype.visitTypeDefinition = function(node) { |
5476 var oldType = this.currentType; | 5393 var oldType = this.currentType; |
5477 this.currentType = this.library.addType(node.name.name, node, node.isClass); | 5394 this.currentType = this.library.addType(node.name.name, node, node.isClass); |
5478 var $$list = node.body; | 5395 var $$list = node.body; |
5479 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 5396 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
5480 var member = $$list[$$i]; | 5397 var member = $$i.next(); |
5481 member.visit$1(this); | 5398 member.visit(this); |
5482 } | 5399 } |
5483 this.currentType = oldType; | 5400 this.currentType = oldType; |
5484 } | 5401 } |
5485 _LibraryVisitor.prototype.visitVariableDefinition = function(node) { | 5402 _LibraryVisitor.prototype.visitVariableDefinition = function(node) { |
5486 this.currentType.addField(node); | 5403 this.currentType.addField(node); |
5487 } | 5404 } |
5488 _LibraryVisitor.prototype.visitFunctionDefinition = function(node) { | 5405 _LibraryVisitor.prototype.visitFunctionDefinition = function(node) { |
5489 this.currentType.addMethod(node.name.name, node); | 5406 this.currentType.addMethod(node.name.name, node); |
5490 } | 5407 } |
5491 _LibraryVisitor.prototype.visitFunctionTypeDefinition = function(node) { | 5408 _LibraryVisitor.prototype.visitFunctionTypeDefinition = function(node) { |
5492 var type = this.library.addType(node.func.name.name, node, false); | 5409 var type = this.library.addType(node.func.name.name, node, false); |
5493 type.addMethod$2(":call", node.func); | 5410 type.addMethod(":call", node.func); |
5494 } | 5411 } |
5495 _LibraryVisitor.prototype.addSource$1 = _LibraryVisitor.prototype.addSource; | |
5496 _LibraryVisitor.prototype.visitFunctionDefinition$1 = _LibraryVisitor.prototype.
visitFunctionDefinition; | |
5497 _LibraryVisitor.prototype.visitVariableDefinition$1 = _LibraryVisitor.prototype.
visitVariableDefinition; | |
5498 // ********** Code for Parameter ************** | 5412 // ********** Code for Parameter ************** |
5499 function Parameter(definition, method) { | 5413 function Parameter(definition, method) { |
5500 this.method = method; | 5414 this.method = method; |
5501 this.definition = definition; | 5415 this.definition = definition; |
5502 this.isInitializer = false; | 5416 this.isInitializer = false; |
5503 } | 5417 } |
5504 Parameter.prototype.get$definition = function() { return this.definition; }; | 5418 Parameter.prototype.get$definition = function() { return this.definition; }; |
5505 Parameter.prototype.set$definition = function(value) { return this.definition =
value; }; | 5419 Parameter.prototype.set$definition = function(value) { return this.definition =
value; }; |
5506 Parameter.prototype.get$method = function() { return this.method; }; | 5420 Parameter.prototype.get$method = function() { return this.method; }; |
5507 Parameter.prototype.set$method = function(value) { return this.method = value; }
; | 5421 Parameter.prototype.set$method = function(value) { return this.method = value; }
; |
5508 Parameter.prototype.get$name = function() { return this.name; }; | 5422 Parameter.prototype.get$name = function() { return this.name; }; |
5509 Parameter.prototype.set$name = function(value) { return this.name = value; }; | 5423 Parameter.prototype.set$name = function(value) { return this.name = value; }; |
5510 Parameter.prototype.get$type = function() { return this.type; }; | 5424 Parameter.prototype.get$type = function() { return this.type; }; |
5511 Parameter.prototype.set$type = function(value) { return this.type = value; }; | 5425 Parameter.prototype.set$type = function(value) { return this.type = value; }; |
5512 Parameter.prototype.get$isInitializer = function() { return this.isInitializer;
}; | 5426 Parameter.prototype.get$isInitializer = function() { return this.isInitializer;
}; |
5513 Parameter.prototype.set$isInitializer = function(value) { return this.isInitiali
zer = value; }; | 5427 Parameter.prototype.set$isInitializer = function(value) { return this.isInitiali
zer = value; }; |
5514 Parameter.prototype.get$value = function() { return this.value; }; | 5428 Parameter.prototype.get$value = function() { return this.value; }; |
5515 Parameter.prototype.set$value = function(value) { return this.value = value; }; | 5429 Parameter.prototype.set$value = function(value) { return this.value = value; }; |
5516 Parameter.prototype.resolve = function() { | 5430 Parameter.prototype.resolve = function() { |
5517 this.name = this.definition.name.name; | 5431 this.name = this.definition.name.name; |
5518 if (this.name.startsWith("this.")) { | 5432 if (this.name.startsWith("this.")) { |
5519 this.name = this.name.substring((5)); | 5433 this.name = this.name.substring((5)); |
5520 this.isInitializer = true; | 5434 this.isInitializer = true; |
5521 } | 5435 } |
5522 this.type = this.method.resolveType$2(this.definition.type, false); | 5436 this.type = this.method.resolveType(this.definition.type, false, true); |
5523 if (this.definition.value != null) { | 5437 if (this.definition.value != null) { |
5524 if (!this.get$hasDefaultValue()) return; | 5438 if (!this.get$hasDefaultValue()) return; |
5525 if (this.method.name == ":call") { | 5439 if (this.method.name == ":call") { |
5526 var methodDef = this.method.get$definition(); | 5440 var methodDef = this.method.get$definition(); |
5527 if (methodDef.get$body() == null && !this.method.get$isNative()) { | 5441 if ($eq(methodDef.get$body()) && !this.method.get$isNative()) { |
5528 $globals.world.error("default value not allowed on function type", this.
definition.span); | 5442 $globals.world.error("default value not allowed on function type", this.
definition.span); |
5529 } | 5443 } |
5530 } | 5444 } |
5531 else if (this.method.get$isAbstract()) { | 5445 else if (this.method.get$isAbstract()) { |
5532 $globals.world.error("default value not allowed on abstract methods", this
.definition.span); | 5446 $globals.world.error("default value not allowed on abstract methods", this
.definition.span); |
5533 } | 5447 } |
5534 } | 5448 } |
5535 else if (this.isInitializer && !this.method.get$isConstructor()) { | 5449 else if (this.isInitializer && !this.method.get$isConstructor()) { |
5536 $globals.world.error("initializer parameters only allowed on constructors",
this.definition.span); | 5450 $globals.world.error("initializer parameters only allowed on constructors",
this.definition.span); |
5537 } | 5451 } |
5538 } | 5452 } |
5539 Parameter.prototype.genValue = function(method, context) { | 5453 Parameter.prototype.genValue = function(method, context) { |
5540 if (this.definition.value == null || this.value != null) return; | 5454 if (this.definition.value == null || this.value != null) return; |
5541 if (context == null) { | 5455 if (context == null) { |
5542 context = new MethodGenerator(method, null); | 5456 context = new MethodGenerator(method, null); |
5543 } | 5457 } |
5544 this.value = this.definition.value.visit(context); | 5458 this.value = this.definition.value.visit(context); |
5545 if (!this.value.get$isConst()) { | 5459 if (!this.value.get$isConst()) { |
5546 $globals.world.error("default parameter values must be constant", this.value
.span); | 5460 $globals.world.error("default parameter values must be constant", this.value
.span); |
5547 } | 5461 } |
5548 this.value = this.value.convertTo(context, this.type, false); | 5462 this.value = this.value.convertTo(context, this.type); |
5549 } | |
5550 Parameter.prototype.copyWithNewType = function(newMethod, newType) { | |
5551 var ret = new Parameter(this.definition, newMethod); | |
5552 ret.set$type(newType); | |
5553 ret.set$name(this.name); | |
5554 ret.set$isInitializer(this.isInitializer); | |
5555 return ret; | |
5556 } | 5463 } |
5557 Parameter.prototype.get$isOptional = function() { | 5464 Parameter.prototype.get$isOptional = function() { |
5558 return this.definition != null && this.definition.value != null; | 5465 return this.definition != null && this.definition.value != null; |
5559 } | 5466 } |
5560 Parameter.prototype.get$hasDefaultValue = function() { | 5467 Parameter.prototype.get$hasDefaultValue = function() { |
5561 return this.definition.value.span.start != this.definition.span.start; | 5468 return this.definition.value.span.start != this.definition.span.start; |
5562 } | 5469 } |
5563 Parameter.prototype.copyWithNewType$2 = Parameter.prototype.copyWithNewType; | |
5564 Parameter.prototype.genValue$2 = Parameter.prototype.genValue; | |
5565 Parameter.prototype.resolve$0 = Parameter.prototype.resolve; | |
5566 // ********** Code for TypeMember ************** | 5470 // ********** Code for TypeMember ************** |
5567 $inherits(TypeMember, Member); | 5471 $inherits(TypeMember, Member); |
5568 function TypeMember(type) { | 5472 function TypeMember(type) { |
5569 this.type = type; | 5473 this.type = type; |
5570 Member.call(this, type.name, type.library.topType); | 5474 Member.call(this, type.name, type.library.topType); |
5571 } | 5475 } |
5572 TypeMember.prototype.get$type = function() { return this.type; }; | 5476 TypeMember.prototype.get$type = function() { return this.type; }; |
5573 TypeMember.prototype.get$span = function() { | 5477 TypeMember.prototype.get$span = function() { |
5574 return this.type.definition == null ? null : this.type.definition.span; | 5478 return this.type.definition == null ? null : this.type.definition.span; |
5575 } | 5479 } |
5576 TypeMember.prototype.get$isStatic = function() { | 5480 TypeMember.prototype.get$isStatic = function() { |
5577 return true; | 5481 return true; |
5578 } | 5482 } |
5579 TypeMember.prototype.get$returnType = function() { | 5483 TypeMember.prototype.get$returnType = function() { |
5580 return $globals.world.varType; | 5484 return $globals.world.varType; |
5581 } | 5485 } |
5582 TypeMember.prototype.canInvoke = function(context, args) { | 5486 TypeMember.prototype.canInvoke = function(context, args) { |
5583 return false; | 5487 return false; |
5584 } | 5488 } |
5585 TypeMember.prototype.get$canGet = function() { | 5489 TypeMember.prototype.get$canGet = function() { |
5586 return true; | 5490 return true; |
5587 } | 5491 } |
5588 TypeMember.prototype.get$canSet = function() { | 5492 TypeMember.prototype.get$canSet = function() { |
5589 return false; | 5493 return false; |
5590 } | 5494 } |
5591 TypeMember.prototype.get$requiresFieldSyntax = function() { | 5495 TypeMember.prototype._get = function(context, node, target) { |
5592 return true; | |
5593 } | |
5594 TypeMember.prototype._get = function(context, node, target, isDynamic) { | |
5595 return new TypeValue(this.type, node.span); | 5496 return new TypeValue(this.type, node.span); |
5596 } | 5497 } |
5597 TypeMember.prototype._set = function(context, node, target, value, isDynamic) { | 5498 TypeMember.prototype._set = function(context, node, target, value) { |
5598 $globals.world.error("cannot set type", node.span); | 5499 $globals.world.error("cannot set type", node.span); |
5599 } | 5500 } |
5600 TypeMember.prototype.invoke = function(context, node, target, args, isDynamic) { | 5501 TypeMember.prototype.invoke = function(context, node, target, args) { |
5601 $globals.world.error("cannot invoke type", node.span); | 5502 $globals.world.error("cannot invoke type", node.span); |
5602 } | 5503 } |
5603 TypeMember.prototype._get$3 = function($0, $1, $2) { | |
5604 return this._get($0, $1, $2, false); | |
5605 }; | |
5606 TypeMember.prototype._get$3$isDynamic = TypeMember.prototype._get; | |
5607 TypeMember.prototype._get$4 = TypeMember.prototype._get; | |
5608 TypeMember.prototype._set$4$isDynamic = TypeMember.prototype._set; | |
5609 TypeMember.prototype._set$5 = TypeMember.prototype._set; | |
5610 TypeMember.prototype.canInvoke$2 = TypeMember.prototype.canInvoke; | |
5611 TypeMember.prototype.invoke$4 = function($0, $1, $2, $3) { | |
5612 return this.invoke($0, $1, $2, $3, false); | |
5613 }; | |
5614 TypeMember.prototype.invoke$4$isDynamic = TypeMember.prototype.invoke; | |
5615 TypeMember.prototype.invoke$5 = TypeMember.prototype.invoke; | |
5616 // ********** Code for FieldMember ************** | 5504 // ********** Code for FieldMember ************** |
5617 $inherits(FieldMember, Member); | 5505 $inherits(FieldMember, Member); |
5618 function FieldMember(name, declaringType, definition, value) { | 5506 function FieldMember(name, declaringType, definition, value) { |
5619 this.isNative = false; | 5507 this.isNative = false; |
5620 this.definition = definition; | 5508 this.definition = definition; |
5621 this._computing = false; | 5509 this._computing = false; |
5622 this.value = value; | 5510 this.value = value; |
5623 Member.call(this, name, declaringType); | 5511 Member.call(this, name, declaringType); |
5624 } | 5512 } |
5625 FieldMember.prototype.get$definition = function() { return this.definition; }; | 5513 FieldMember.prototype.get$definition = function() { return this.definition; }; |
5626 FieldMember.prototype.get$value = function() { return this.value; }; | 5514 FieldMember.prototype.get$value = function() { return this.value; }; |
5627 FieldMember.prototype.get$type = function() { return this.type; }; | 5515 FieldMember.prototype.get$type = function() { return this.type; }; |
5628 FieldMember.prototype.set$type = function(value) { return this.type = value; }; | 5516 FieldMember.prototype.set$type = function(value) { return this.type = value; }; |
5629 FieldMember.prototype.get$isStatic = function() { return this.isStatic; }; | 5517 FieldMember.prototype.get$isStatic = function() { return this.isStatic; }; |
5630 FieldMember.prototype.set$isStatic = function(value) { return this.isStatic = va
lue; }; | 5518 FieldMember.prototype.set$isStatic = function(value) { return this.isStatic = va
lue; }; |
5631 FieldMember.prototype.get$isFinal = function() { return this.isFinal; }; | 5519 FieldMember.prototype.get$isFinal = function() { return this.isFinal; }; |
5632 FieldMember.prototype.set$isFinal = function(value) { return this.isFinal = valu
e; }; | 5520 FieldMember.prototype.set$isFinal = function(value) { return this.isFinal = valu
e; }; |
5633 FieldMember.prototype.get$isNative = function() { return this.isNative; }; | 5521 FieldMember.prototype.get$isNative = function() { return this.isNative; }; |
5634 FieldMember.prototype.set$isNative = function(value) { return this.isNative = va
lue; }; | 5522 FieldMember.prototype.set$isNative = function(value) { return this.isNative = va
lue; }; |
5635 FieldMember.prototype.override = function(other) { | 5523 FieldMember.prototype.override = function(other) { |
5636 if (!Member.prototype.override.call(this, other)) return false; | 5524 if (!Member.prototype.override.call(this, other)) return false; |
5637 if (other.get$isProperty()) { | 5525 if (other.get$isProperty()) { |
5638 return true; | 5526 return true; |
5639 } | 5527 } |
5640 else { | 5528 else { |
5641 $globals.world.error("field can not override anything but property", this.ge
t$span(), other.get$span()); | 5529 $globals.world.error("field can not override anything but property", this.ge
t$span(), other.get$span()); |
5642 return false; | 5530 return false; |
5643 } | 5531 } |
5644 } | 5532 } |
5645 FieldMember.prototype.provideFieldSyntax = function() { | |
5646 | |
5647 } | |
5648 FieldMember.prototype.providePropertySyntax = function() { | 5533 FieldMember.prototype.providePropertySyntax = function() { |
5649 this._providePropertySyntax = true; | 5534 this._providePropertySyntax = true; |
| 5535 if (this.genericMember != null) { |
| 5536 this.genericMember.providePropertySyntax(); |
| 5537 } |
| 5538 } |
| 5539 FieldMember.prototype.makeConcrete = function(concreteType) { |
| 5540 var ret = new FieldMember(this.name, concreteType, this.definition, this.value
); |
| 5541 ret.set$genericMember(this); |
| 5542 ret.set$_jsname(this._jsname); |
| 5543 return ret; |
5650 } | 5544 } |
5651 FieldMember.prototype.get$span = function() { | 5545 FieldMember.prototype.get$span = function() { |
5652 return this.definition == null ? null : this.definition.span; | 5546 return this.definition == null ? null : this.definition.span; |
5653 } | 5547 } |
5654 FieldMember.prototype.get$returnType = function() { | 5548 FieldMember.prototype.get$returnType = function() { |
5655 return this.type; | 5549 return this.type; |
5656 } | 5550 } |
5657 FieldMember.prototype.get$canGet = function() { | 5551 FieldMember.prototype.get$canGet = function() { |
5658 return true; | 5552 return true; |
5659 } | 5553 } |
5660 FieldMember.prototype.get$canSet = function() { | 5554 FieldMember.prototype.get$canSet = function() { |
5661 return !this.isFinal; | 5555 return !this.isFinal; |
5662 } | 5556 } |
5663 FieldMember.prototype.get$isField = function() { | 5557 FieldMember.prototype.get$isField = function() { |
5664 return true; | 5558 return true; |
5665 } | 5559 } |
5666 FieldMember.prototype.resolve = function() { | 5560 FieldMember.prototype.resolve = function() { |
5667 this.isStatic = this.declaringType.get$isTop(); | 5561 this.isStatic = this.declaringType.get$isTop(); |
5668 this.isFinal = false; | 5562 this.isFinal = false; |
5669 if (this.definition.modifiers != null) { | 5563 if (this.definition.modifiers != null) { |
5670 var $$list = this.definition.modifiers; | 5564 var $$list = this.definition.modifiers; |
5671 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 5565 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
5672 var mod = $$list[$$i]; | 5566 var mod = $$i.next(); |
5673 if ($eq(mod.get$kind(), (85))) { | 5567 if (mod.get$kind() == (85)) { |
5674 if (this.isStatic) { | 5568 if (this.isStatic) { |
5675 $globals.world.error("duplicate static modifier", mod.get$span()); | 5569 $globals.world.error("duplicate static modifier", mod.get$span()); |
5676 } | 5570 } |
5677 this.isStatic = true; | 5571 this.isStatic = true; |
5678 } | 5572 } |
5679 else if ($eq(mod.get$kind(), (99))) { | 5573 else if (mod.get$kind() == (99)) { |
5680 if (this.isFinal) { | 5574 if (this.isFinal) { |
5681 $globals.world.error("duplicate final modifier", mod.get$span()); | 5575 $globals.world.error("duplicate final modifier", mod.get$span()); |
5682 } | 5576 } |
5683 this.isFinal = true; | 5577 this.isFinal = true; |
5684 } | 5578 } |
5685 else { | 5579 else { |
5686 $globals.world.error(("" + mod + " modifier not allowed on field"), mod.
get$span()); | 5580 $globals.world.error(("" + mod + " modifier not allowed on field"), mod.
get$span()); |
5687 } | 5581 } |
5688 } | 5582 } |
5689 } | 5583 } |
5690 this.type = this.resolveType$2(this.definition.type, false); | 5584 this.type = this.resolveType(this.definition.type, false, true); |
5691 if (this.isStatic && !this.get$isFactory() && this.type.get$hasTypeParams()) { | |
5692 $globals.world.error("using type parameter in static context", this.definiti
on.type.span); | |
5693 } | |
5694 if (this.isStatic && this.isFinal && this.value == null) { | 5585 if (this.isStatic && this.isFinal && this.value == null) { |
5695 $globals.world.error("static final field is missing initializer", this.get$s
pan()); | 5586 $globals.world.error("static final field is missing initializer", this.get$s
pan()); |
5696 } | 5587 } |
5697 this.get$library()._addMember(this); | 5588 if (this.declaringType.get$isClass()) this.get$library()._addMember(this); |
5698 } | 5589 } |
5699 FieldMember.prototype.computeValue = function() { | 5590 FieldMember.prototype.computeValue = function() { |
5700 if (this.value == null) return null; | 5591 if (this.value == null) return null; |
5701 if (this._computedValue == null) { | 5592 if (this._computedValue == null) { |
5702 if (this._computing) { | 5593 if (this._computing) { |
5703 $globals.world.error("circular reference", this.value.span); | 5594 $globals.world.error("circular reference", this.value.span); |
5704 return null; | 5595 return null; |
5705 } | 5596 } |
5706 this._computing = true; | 5597 this._computing = true; |
5707 var finalMethod = new MethodMember("final_context", this.declaringType, null
); | 5598 var finalMethod = new MethodMember("final_context", this.declaringType, null
); |
(...skipping 13 matching lines...) Expand all Loading... |
5721 ; | 5612 ; |
5722 } | 5613 } |
5723 else { | 5614 else { |
5724 this._computedValue = $globals.world.gen.globalForStaticField(this, this
._computedValue, [this._computedValue]); | 5615 this._computedValue = $globals.world.gen.globalForStaticField(this, this
._computedValue, [this._computedValue]); |
5725 } | 5616 } |
5726 } | 5617 } |
5727 this._computing = false; | 5618 this._computing = false; |
5728 } | 5619 } |
5729 return this._computedValue; | 5620 return this._computedValue; |
5730 } | 5621 } |
5731 FieldMember.prototype._get = function(context, node, target, isDynamic) { | 5622 FieldMember.prototype._get = function(context, node, target) { |
| 5623 if (!context.get$needsCode()) { |
| 5624 return new PureStaticValue(this.type, node.span, this.isStatic && this.isFin
al, false); |
| 5625 } |
5732 if (this.isNative && this.get$returnType() != null) { | 5626 if (this.isNative && this.get$returnType() != null) { |
5733 this.get$returnType().markUsed(); | 5627 this.get$returnType().markUsed(); |
5734 if ((this.get$returnType() instanceof DefinedType)) { | 5628 if ((this.get$returnType() instanceof DefinedType)) { |
5735 var defaultType = this.get$returnType().get$genericType().defaultType; | 5629 var defaultType = this.get$returnType().get$genericType().defaultType; |
5736 if (defaultType != null && defaultType.get$isNative()) { | 5630 if ($ne(defaultType) && defaultType.get$isNative()) { |
5737 defaultType.markUsed$0(); | 5631 defaultType.markUsed(); |
5738 } | 5632 } |
5739 } | 5633 } |
5740 } | 5634 } |
5741 if (this.isStatic) { | 5635 if (this.isStatic) { |
5742 this.declaringType.markUsed(); | 5636 this.declaringType.markUsed(); |
5743 var cv = this.computeValue(); | 5637 var cv = this.computeValue(); |
5744 if (this.isFinal) { | 5638 if (this.isFinal) { |
5745 return cv; | 5639 return cv; |
5746 } | 5640 } |
5747 $globals.world.gen.hasStatics = true; | 5641 $globals.world.gen.hasStatics = true; |
(...skipping 10 matching lines...) Expand all Loading... |
5758 $globals.world.error("static field of hidden native type is inaccessible
", node.span); | 5652 $globals.world.error("static field of hidden native type is inaccessible
", node.span); |
5759 } | 5653 } |
5760 return new Value(this.type, ("" + this.declaringType.get$jsname() + "." +
this.get$jsname()), node.span); | 5654 return new Value(this.type, ("" + this.declaringType.get$jsname() + "." +
this.get$jsname()), node.span); |
5761 } | 5655 } |
5762 else { | 5656 else { |
5763 return new Value(this.type, ("$globals." + this.declaringType.get$jsname()
+ "_" + this.get$jsname()), node.span); | 5657 return new Value(this.type, ("$globals." + this.declaringType.get$jsname()
+ "_" + this.get$jsname()), node.span); |
5764 } | 5658 } |
5765 } | 5659 } |
5766 return new Value(this.type, ("" + target.get$code() + "." + this.get$jsname())
, node.span); | 5660 return new Value(this.type, ("" + target.get$code() + "." + this.get$jsname())
, node.span); |
5767 } | 5661 } |
5768 FieldMember.prototype._set = function(context, node, target, value, isDynamic) { | 5662 FieldMember.prototype._set = function(context, node, target, value) { |
5769 var lhs = this._get(context, node, target, isDynamic); | 5663 if (!context.get$needsCode()) { |
5770 value = value.convertTo(context, this.type, isDynamic); | 5664 return new PureStaticValue(this.type, node.span, false, false); |
| 5665 } |
| 5666 var lhs = this._get(context, node, target); |
| 5667 value = value.convertTo(context, this.type); |
5771 return new Value(this.type, ("" + lhs.get$code() + " = " + value.get$code()),
node.span); | 5668 return new Value(this.type, ("" + lhs.get$code() + " = " + value.get$code()),
node.span); |
5772 } | 5669 } |
5773 FieldMember.prototype._get$3 = function($0, $1, $2) { | |
5774 return this._get($0, $1, $2, false); | |
5775 }; | |
5776 FieldMember.prototype._get$3$isDynamic = FieldMember.prototype._get; | |
5777 FieldMember.prototype._get$4 = FieldMember.prototype._get; | |
5778 FieldMember.prototype._set$4$isDynamic = FieldMember.prototype._set; | |
5779 FieldMember.prototype._set$5 = FieldMember.prototype._set; | |
5780 FieldMember.prototype.computeValue$0 = FieldMember.prototype.computeValue; | |
5781 FieldMember.prototype.provideFieldSyntax$0 = FieldMember.prototype.provideFieldS
yntax; | |
5782 FieldMember.prototype.providePropertySyntax$0 = FieldMember.prototype.providePro
pertySyntax; | |
5783 FieldMember.prototype.resolve$0 = FieldMember.prototype.resolve; | |
5784 // ********** Code for PropertyMember ************** | 5670 // ********** Code for PropertyMember ************** |
5785 $inherits(PropertyMember, Member); | 5671 $inherits(PropertyMember, Member); |
5786 function PropertyMember(name, declaringType) { | 5672 function PropertyMember(name, declaringType) { |
5787 Member.call(this, name, declaringType); | 5673 Member.call(this, name, declaringType); |
5788 } | 5674 } |
5789 PropertyMember.prototype.get$getter = function() { return this.getter; }; | 5675 PropertyMember.prototype.get$getter = function() { return this.getter; }; |
5790 PropertyMember.prototype.set$getter = function(value) { return this.getter = val
ue; }; | 5676 PropertyMember.prototype.set$getter = function(value) { return this.getter = val
ue; }; |
5791 PropertyMember.prototype.get$setter = function() { return this.setter; }; | 5677 PropertyMember.prototype.get$setter = function() { return this.setter; }; |
5792 PropertyMember.prototype.set$setter = function(value) { return this.setter = val
ue; }; | 5678 PropertyMember.prototype.set$setter = function(value) { return this.setter = val
ue; }; |
5793 PropertyMember.prototype.get$span = function() { | 5679 PropertyMember.prototype.get$span = function() { |
5794 return this.getter != null ? this.getter.get$span() : null; | 5680 return this.getter != null ? this.getter.get$span() : null; |
5795 } | 5681 } |
5796 PropertyMember.prototype.get$canGet = function() { | 5682 PropertyMember.prototype.get$canGet = function() { |
5797 return this.getter != null; | 5683 return this.getter != null; |
5798 } | 5684 } |
5799 PropertyMember.prototype.get$canSet = function() { | 5685 PropertyMember.prototype.get$canSet = function() { |
5800 return this.setter != null; | 5686 return this.setter != null; |
5801 } | 5687 } |
5802 PropertyMember.prototype.get$requiresPropertySyntax = function() { | 5688 PropertyMember.prototype.get$needsFieldSyntax = function() { |
5803 return this.declaringType.get$isClass(); | 5689 return this._overriddenField != null && this._overriddenField.get$isNative(); |
5804 } | |
5805 PropertyMember.prototype.provideFieldSyntax = function() { | |
5806 this._provideFieldSyntax = true; | |
5807 } | |
5808 PropertyMember.prototype.providePropertySyntax = function() { | |
5809 if (this._overriddenField != null && this._overriddenField.get$isNative()) { | |
5810 this.provideFieldSyntax(); | |
5811 } | |
5812 } | 5690 } |
5813 PropertyMember.prototype.get$isStatic = function() { | 5691 PropertyMember.prototype.get$isStatic = function() { |
5814 return this.getter == null ? this.setter.isStatic : this.getter.isStatic; | 5692 return this.getter == null ? this.setter.isStatic : this.getter.isStatic; |
5815 } | 5693 } |
5816 PropertyMember.prototype.get$isProperty = function() { | 5694 PropertyMember.prototype.get$isProperty = function() { |
5817 return true; | 5695 return true; |
5818 } | 5696 } |
5819 PropertyMember.prototype.get$returnType = function() { | 5697 PropertyMember.prototype.get$returnType = function() { |
5820 return this.getter == null ? this.setter.returnType : this.getter.returnType; | 5698 return this.getter == null ? this.setter.returnType : this.getter.returnType; |
5821 } | 5699 } |
| 5700 PropertyMember.prototype.makeConcrete = function(concreteType) { |
| 5701 var ret = new PropertyMember(this.name, concreteType); |
| 5702 if (this.getter != null) ret.set$getter(this.getter.makeConcrete(concreteType)
); |
| 5703 if (this.setter != null) ret.set$setter(this.setter.makeConcrete(concreteType)
); |
| 5704 ret.set$_jsname(this._jsname); |
| 5705 return ret; |
| 5706 } |
5822 PropertyMember.prototype.override = function(other) { | 5707 PropertyMember.prototype.override = function(other) { |
5823 if (!Member.prototype.override.call(this, other)) return false; | 5708 if (!Member.prototype.override.call(this, other)) return false; |
5824 if (other.get$isProperty() || other.get$isField()) { | 5709 if (other.get$isProperty() || other.get$isField()) { |
5825 if (other.get$isProperty()) this.addFromParent(other); | 5710 if (other.get$isProperty()) this.addFromParent(other); |
5826 else this._overriddenField = other; | 5711 else this._overriddenField = other; |
5827 return true; | 5712 return true; |
5828 } | 5713 } |
5829 else { | 5714 else { |
5830 $globals.world.error("property can only override field or property", this.ge
t$span(), other.get$span()); | 5715 $globals.world.error("property can only override field or property", this.ge
t$span(), other.get$span()); |
5831 return false; | 5716 return false; |
5832 } | 5717 } |
5833 } | 5718 } |
5834 PropertyMember.prototype._get = function(context, node, target, isDynamic) { | 5719 PropertyMember.prototype._get = function(context, node, target) { |
5835 if (this.getter == null) { | 5720 if (this.getter == null) { |
5836 if (this._overriddenField != null) { | 5721 if (this._overriddenField != null) { |
5837 return this._overriddenField._get(context, node, target, isDynamic); | 5722 return this._overriddenField._get(context, node, target); |
5838 } | 5723 } |
5839 return target.invokeNoSuchMethod(context, ("get:" + this.name), node); | 5724 return target.invokeNoSuchMethod(context, ("get:" + this.name), node); |
5840 } | 5725 } |
5841 return this.getter.invoke(context, node, target, Arguments.get$EMPTY(), false)
; | 5726 return this.getter.invoke(context, node, target, Arguments.get$EMPTY()); |
5842 } | 5727 } |
5843 PropertyMember.prototype._set = function(context, node, target, value, isDynamic
) { | 5728 PropertyMember.prototype._set = function(context, node, target, value) { |
5844 if (this.setter == null) { | 5729 if (this.setter == null) { |
5845 if (this._overriddenField != null) { | 5730 if (this._overriddenField != null) { |
5846 return this._overriddenField._set(context, node, target, value, isDynamic)
; | 5731 return this._overriddenField._set(context, node, target, value); |
5847 } | 5732 } |
5848 return target.invokeNoSuchMethod(context, ("set:" + this.name), node, new Ar
guments(null, [value])); | 5733 return target.invokeNoSuchMethod(context, ("set:" + this.name), node, new Ar
guments(null, [value])); |
5849 } | 5734 } |
5850 return this.setter.invoke(context, node, target, new Arguments(null, [value]),
isDynamic); | 5735 return this.setter.invoke(context, node, target, new Arguments(null, [value]))
; |
5851 } | 5736 } |
5852 PropertyMember.prototype.addFromParent = function(parentMember) { | 5737 PropertyMember.prototype.addFromParent = function(parentMember) { |
5853 var parent; | 5738 var parent = parentMember; |
5854 if ((parentMember instanceof ConcreteMember)) { | 5739 if (this.getter == null) this.getter = parent.get$getter(); |
5855 var c = parentMember; | 5740 if (this.setter == null) this.setter = parent.get$setter(); |
5856 parent = c.baseMember; | |
5857 } | |
5858 else { | |
5859 parent = parentMember; | |
5860 } | |
5861 if (this.getter == null) this.getter = parent.getter; | |
5862 if (this.setter == null) this.setter = parent.setter; | |
5863 } | 5741 } |
5864 PropertyMember.prototype.resolve = function() { | 5742 PropertyMember.prototype.resolve = function() { |
5865 if (this.getter != null) { | 5743 if (this.getter != null) { |
5866 this.getter.resolve(); | 5744 this.getter.resolve(); |
5867 if (this.getter.parameters.get$length() != (0)) { | 5745 if (this.getter.parameters.get$length() != (0)) { |
5868 $globals.world.error("getter methods should take no arguments", this.gette
r.definition.span); | 5746 $globals.world.error("getter methods should take no arguments", this.gette
r.definition.span); |
5869 } | 5747 } |
5870 if (this.getter.returnType.get$isVoid()) { | 5748 if (this.getter.returnType.get$isVoid()) { |
5871 $globals.world.warning("getter methods should not be void", this.getter.de
finition.returnType.span); | 5749 $globals.world.warning("getter methods should not be void", this.getter.de
finition.returnType.span); |
5872 } | 5750 } |
5873 } | 5751 } |
5874 if (this.setter != null) { | 5752 if (this.setter != null) { |
5875 this.setter.resolve(); | 5753 this.setter.resolve(); |
5876 if (this.setter.parameters.get$length() != (1)) { | 5754 if (this.setter.parameters.get$length() != (1)) { |
5877 $globals.world.error("setter methods should take a single argument", this.
setter.definition.span); | 5755 $globals.world.error("setter methods should take a single argument", this.
setter.definition.span); |
5878 } | 5756 } |
5879 if (!this.setter.returnType.get$isVoid() && this.setter.definition.returnTyp
e != null) { | 5757 if (!this.setter.returnType.get$isVoid() && this.setter.definition.returnTyp
e != null) { |
5880 $globals.world.warning("setter methods should be void", this.setter.defini
tion.returnType.span); | 5758 $globals.world.warning("setter methods should be void", this.setter.defini
tion.returnType.span); |
5881 } | 5759 } |
5882 } | 5760 } |
5883 this.get$library()._addMember(this); | 5761 if (this.declaringType.get$isClass()) this.get$library()._addMember(this); |
5884 } | 5762 } |
5885 PropertyMember.prototype._get$3 = function($0, $1, $2) { | |
5886 return this._get($0, $1, $2, false); | |
5887 }; | |
5888 PropertyMember.prototype._get$3$isDynamic = PropertyMember.prototype._get; | |
5889 PropertyMember.prototype._get$4 = PropertyMember.prototype._get; | |
5890 PropertyMember.prototype._set$4$isDynamic = PropertyMember.prototype._set; | |
5891 PropertyMember.prototype._set$5 = PropertyMember.prototype._set; | |
5892 PropertyMember.prototype.provideFieldSyntax$0 = PropertyMember.prototype.provide
FieldSyntax; | |
5893 PropertyMember.prototype.providePropertySyntax$0 = PropertyMember.prototype.prov
idePropertySyntax; | |
5894 PropertyMember.prototype.resolve$0 = PropertyMember.prototype.resolve; | |
5895 // ********** Code for ConcreteMember ************** | |
5896 $inherits(ConcreteMember, Member); | |
5897 function ConcreteMember(name, declaringType, baseMember) { | |
5898 this.baseMember = baseMember; | |
5899 Member.call(this, name, declaringType); | |
5900 this.parameters = []; | |
5901 this.returnType = this.baseMember.get$returnType().resolveTypeParams(declaring
Type); | |
5902 var $$list = this.baseMember.get$parameters(); | |
5903 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | |
5904 var p = $$list[$$i]; | |
5905 var newType = p.get$type().resolveTypeParams$1(declaringType); | |
5906 if ($ne(newType, p.get$type())) { | |
5907 this.parameters.add(p.copyWithNewType$2(this, newType)); | |
5908 } | |
5909 else { | |
5910 this.parameters.add(p); | |
5911 } | |
5912 } | |
5913 } | |
5914 ConcreteMember.prototype.get$returnType = function() { return this.returnType; }
; | |
5915 ConcreteMember.prototype.set$returnType = function(value) { return this.returnTy
pe = value; }; | |
5916 ConcreteMember.prototype.get$parameters = function() { return this.parameters; }
; | |
5917 ConcreteMember.prototype.set$parameters = function(value) { return this.paramete
rs = value; }; | |
5918 ConcreteMember.prototype.get$span = function() { | |
5919 return this.baseMember.get$span(); | |
5920 } | |
5921 ConcreteMember.prototype.get$isStatic = function() { | |
5922 return this.baseMember.get$isStatic(); | |
5923 } | |
5924 ConcreteMember.prototype.get$isAbstract = function() { | |
5925 return this.baseMember.get$isAbstract(); | |
5926 } | |
5927 ConcreteMember.prototype.get$isConst = function() { | |
5928 return this.baseMember.get$isConst(); | |
5929 } | |
5930 ConcreteMember.prototype.get$isFactory = function() { | |
5931 return this.baseMember.get$isFactory(); | |
5932 } | |
5933 ConcreteMember.prototype.get$isFinal = function() { | |
5934 return this.baseMember.get$isFinal(); | |
5935 } | |
5936 ConcreteMember.prototype.get$isNative = function() { | |
5937 return this.baseMember.get$isNative(); | |
5938 } | |
5939 ConcreteMember.prototype.get$jsname = function() { | |
5940 return this.baseMember.get$jsname(); | |
5941 } | |
5942 ConcreteMember.prototype.get$canGet = function() { | |
5943 return this.baseMember.get$canGet(); | |
5944 } | |
5945 ConcreteMember.prototype.get$canSet = function() { | |
5946 return this.baseMember.get$canSet(); | |
5947 } | |
5948 ConcreteMember.prototype.canInvoke = function(context, args) { | |
5949 return this.baseMember.canInvoke(context, args); | |
5950 } | |
5951 ConcreteMember.prototype.get$isField = function() { | |
5952 return this.baseMember.get$isField(); | |
5953 } | |
5954 ConcreteMember.prototype.get$isMethod = function() { | |
5955 return this.baseMember.get$isMethod(); | |
5956 } | |
5957 ConcreteMember.prototype.get$isProperty = function() { | |
5958 return this.baseMember.get$isProperty(); | |
5959 } | |
5960 ConcreteMember.prototype.get$requiresPropertySyntax = function() { | |
5961 return this.baseMember.get$requiresPropertySyntax(); | |
5962 } | |
5963 ConcreteMember.prototype.get$requiresFieldSyntax = function() { | |
5964 return this.baseMember.get$requiresFieldSyntax(); | |
5965 } | |
5966 ConcreteMember.prototype.provideFieldSyntax = function() { | |
5967 return this.baseMember.provideFieldSyntax(); | |
5968 } | |
5969 ConcreteMember.prototype.providePropertySyntax = function() { | |
5970 return this.baseMember.providePropertySyntax(); | |
5971 } | |
5972 ConcreteMember.prototype.get$isConstructor = function() { | |
5973 return this.name == this.declaringType.name; | |
5974 } | |
5975 ConcreteMember.prototype.get$constructorName = function() { | |
5976 return this.baseMember.get$constructorName(); | |
5977 } | |
5978 ConcreteMember.prototype.get$definition = function() { | |
5979 return this.baseMember.get$definition(); | |
5980 } | |
5981 ConcreteMember.prototype.get$initDelegate = function() { | |
5982 return this.baseMember.get$initDelegate(); | |
5983 } | |
5984 ConcreteMember.prototype.set$initDelegate = function(ctor) { | |
5985 this.baseMember.set$initDelegate(ctor); | |
5986 } | |
5987 ConcreteMember.prototype.resolveType = function(node, isRequired) { | |
5988 var type = this.baseMember.resolveType$2(node, isRequired); | |
5989 return type.resolveTypeParams$1(this.declaringType); | |
5990 } | |
5991 ConcreteMember.prototype.computeValue = function() { | |
5992 return this.baseMember.computeValue(); | |
5993 } | |
5994 ConcreteMember.prototype.override = function(other) { | |
5995 return this.baseMember.override(other); | |
5996 } | |
5997 ConcreteMember.prototype._get = function(context, node, target, isDynamic) { | |
5998 var ret = this.baseMember._get(context, node, target, isDynamic); | |
5999 return new Value(this.get$inferredResult(), ret.get$code(), node.span); | |
6000 } | |
6001 ConcreteMember.prototype._set = function(context, node, target, value, isDynamic
) { | |
6002 var ret = this.baseMember._set(context, node, target, value, isDynamic); | |
6003 return new Value(this.returnType, ret.get$code(), node.span); | |
6004 } | |
6005 ConcreteMember.prototype._evalConstConstructor = function(newObject, args) { | |
6006 return this.baseMember.get$dynamic()._evalConstConstructor$2(newObject, args); | |
6007 } | |
6008 ConcreteMember.prototype.invoke = function(context, node, target, args, isDynami
c) { | |
6009 var ret = this.baseMember.invoke(context, node, target, args, isDynamic); | |
6010 var code = ret.get$code(); | |
6011 if (this.get$isConstructor()) { | |
6012 code = code.replaceFirst$2(this.declaringType.get$genericType().get$jsname()
, this.declaringType.get$jsname()); | |
6013 } | |
6014 if ((this.baseMember instanceof MethodMember)) { | |
6015 this.declaringType.genMethod(this); | |
6016 } | |
6017 return new Value(this.get$inferredResult(), code, node.span); | |
6018 } | |
6019 ConcreteMember.prototype._evalConstConstructor$2 = ConcreteMember.prototype._eva
lConstConstructor; | |
6020 ConcreteMember.prototype._get$3 = function($0, $1, $2) { | |
6021 return this._get($0, $1, $2, false); | |
6022 }; | |
6023 ConcreteMember.prototype._get$3$isDynamic = ConcreteMember.prototype._get; | |
6024 ConcreteMember.prototype._get$4 = ConcreteMember.prototype._get; | |
6025 ConcreteMember.prototype._set$4$isDynamic = ConcreteMember.prototype._set; | |
6026 ConcreteMember.prototype._set$5 = ConcreteMember.prototype._set; | |
6027 ConcreteMember.prototype.canInvoke$2 = ConcreteMember.prototype.canInvoke; | |
6028 ConcreteMember.prototype.computeValue$0 = ConcreteMember.prototype.computeValue; | |
6029 ConcreteMember.prototype.invoke$4 = function($0, $1, $2, $3) { | |
6030 return this.invoke($0, $1, $2, $3, false); | |
6031 }; | |
6032 ConcreteMember.prototype.invoke$4$isDynamic = ConcreteMember.prototype.invoke; | |
6033 ConcreteMember.prototype.invoke$5 = ConcreteMember.prototype.invoke; | |
6034 ConcreteMember.prototype.provideFieldSyntax$0 = ConcreteMember.prototype.provide
FieldSyntax; | |
6035 ConcreteMember.prototype.providePropertySyntax$0 = ConcreteMember.prototype.prov
idePropertySyntax; | |
6036 ConcreteMember.prototype.resolveType$2 = ConcreteMember.prototype.resolveType; | |
6037 // ********** Code for MethodMember ************** | 5763 // ********** Code for MethodMember ************** |
6038 $inherits(MethodMember, Member); | 5764 $inherits(MethodMember, Member); |
6039 function MethodMember(name, declaringType, definition) { | 5765 function MethodMember(name, declaringType, definition) { |
6040 this.isLambda = false; | 5766 this.isLambda = false; |
6041 this._provideOptionalParamInfo = false; | 5767 this._provideOptionalParamInfo = false; |
6042 this.isFactory = false; | 5768 this.isFactory = false; |
6043 this.definition = definition; | 5769 this.definition = definition; |
6044 this.isConst = false; | 5770 this.isConst = false; |
6045 this.isAbstract = false; | 5771 this.isAbstract = false; |
6046 this.isStatic = false; | 5772 this.isStatic = false; |
6047 Member.call(this, name, declaringType); | 5773 Member.call(this, name, declaringType); |
6048 } | 5774 } |
6049 MethodMember.prototype.get$definition = function() { return this.definition; }; | 5775 MethodMember.prototype.get$definition = function() { return this.definition; }; |
6050 MethodMember.prototype.set$definition = function(value) { return this.definition
= value; }; | 5776 MethodMember.prototype.set$definition = function(value) { return this.definition
= value; }; |
6051 MethodMember.prototype.get$returnType = function() { return this.returnType; }; | 5777 MethodMember.prototype.get$returnType = function() { return this.returnType; }; |
6052 MethodMember.prototype.set$returnType = function(value) { return this.returnType
= value; }; | 5778 MethodMember.prototype.set$returnType = function(value) { return this.returnType
= value; }; |
6053 MethodMember.prototype.get$parameters = function() { return this.parameters; }; | 5779 MethodMember.prototype.get$parameters = function() { return this.parameters; }; |
6054 MethodMember.prototype.set$parameters = function(value) { return this.parameters
= value; }; | 5780 MethodMember.prototype.set$parameters = function(value) { return this.parameters
= value; }; |
| 5781 MethodMember.prototype.get$_methodData = function() { return this._methodData; }
; |
| 5782 MethodMember.prototype.set$_methodData = function(value) { return this._methodDa
ta = value; }; |
6055 MethodMember.prototype.get$isStatic = function() { return this.isStatic; }; | 5783 MethodMember.prototype.get$isStatic = function() { return this.isStatic; }; |
6056 MethodMember.prototype.set$isStatic = function(value) { return this.isStatic = v
alue; }; | 5784 MethodMember.prototype.set$isStatic = function(value) { return this.isStatic = v
alue; }; |
6057 MethodMember.prototype.get$isAbstract = function() { return this.isAbstract; }; | 5785 MethodMember.prototype.get$isAbstract = function() { return this.isAbstract; }; |
6058 MethodMember.prototype.set$isAbstract = function(value) { return this.isAbstract
= value; }; | 5786 MethodMember.prototype.set$isAbstract = function(value) { return this.isAbstract
= value; }; |
6059 MethodMember.prototype.get$isConst = function() { return this.isConst; }; | 5787 MethodMember.prototype.get$isConst = function() { return this.isConst; }; |
6060 MethodMember.prototype.set$isConst = function(value) { return this.isConst = val
ue; }; | 5788 MethodMember.prototype.set$isConst = function(value) { return this.isConst = val
ue; }; |
6061 MethodMember.prototype.get$isFactory = function() { return this.isFactory; }; | 5789 MethodMember.prototype.get$isFactory = function() { return this.isFactory; }; |
6062 MethodMember.prototype.set$isFactory = function(value) { return this.isFactory =
value; }; | 5790 MethodMember.prototype.set$isFactory = function(value) { return this.isFactory =
value; }; |
6063 MethodMember.prototype.get$isLambda = function() { return this.isLambda; }; | 5791 MethodMember.prototype.get$isLambda = function() { return this.isLambda; }; |
6064 MethodMember.prototype.set$isLambda = function(value) { return this.isLambda = v
alue; }; | 5792 MethodMember.prototype.set$isLambda = function(value) { return this.isLambda = v
alue; }; |
6065 MethodMember.prototype.get$initDelegate = function() { return this.initDelegate;
}; | 5793 MethodMember.prototype.get$initDelegate = function() { return this.initDelegate;
}; |
6066 MethodMember.prototype.set$initDelegate = function(value) { return this.initDele
gate = value; }; | 5794 MethodMember.prototype.set$initDelegate = function(value) { return this.initDele
gate = value; }; |
| 5795 MethodMember.prototype.makeConcrete = function(concreteType) { |
| 5796 var _name = this.get$isConstructor() ? concreteType.name : this.name; |
| 5797 var ret = new MethodMember(_name, concreteType, this.definition); |
| 5798 ret.set$genericMember(this); |
| 5799 ret.set$_jsname(this._jsname); |
| 5800 return ret; |
| 5801 } |
| 5802 MethodMember.prototype.get$methodData = function() { |
| 5803 if (this.genericMember != null) return this.genericMember.get$dynamic().get$me
thodData(); |
| 5804 if (this._methodData == null) { |
| 5805 this._methodData = new MethodData(this); |
| 5806 } |
| 5807 return this._methodData; |
| 5808 } |
6067 MethodMember.prototype.get$isConstructor = function() { | 5809 MethodMember.prototype.get$isConstructor = function() { |
6068 return this.name == this.declaringType.name; | 5810 return this.name == this.declaringType.name; |
6069 } | 5811 } |
6070 MethodMember.prototype.get$isMethod = function() { | 5812 MethodMember.prototype.get$isMethod = function() { |
6071 return !this.get$isConstructor(); | 5813 return !this.get$isConstructor(); |
6072 } | 5814 } |
6073 MethodMember.prototype.get$isNative = function() { | 5815 MethodMember.prototype.get$isNative = function() { |
6074 return this.definition.nativeBody != null; | 5816 return this.definition.nativeBody != null; |
6075 } | 5817 } |
6076 MethodMember.prototype.get$canGet = function() { | 5818 MethodMember.prototype.get$canGet = function() { |
6077 return true; | 5819 return true; |
6078 } | 5820 } |
6079 MethodMember.prototype.get$canSet = function() { | 5821 MethodMember.prototype.get$canSet = function() { |
6080 return false; | 5822 return false; |
6081 } | 5823 } |
6082 MethodMember.prototype.get$requiresPropertySyntax = function() { | |
6083 return true; | |
6084 } | |
6085 MethodMember.prototype.get$span = function() { | 5824 MethodMember.prototype.get$span = function() { |
6086 return this.definition == null ? null : this.definition.span; | 5825 return this.definition == null ? null : this.definition.span; |
6087 } | 5826 } |
6088 MethodMember.prototype.get$constructorName = function() { | 5827 MethodMember.prototype.get$constructorName = function() { |
6089 var returnType = this.definition.returnType; | 5828 var returnType = this.definition.returnType; |
6090 if (returnType == null) return ""; | 5829 if ($eq(returnType)) return ""; |
6091 if ((returnType instanceof GenericTypeReference)) { | 5830 if ((returnType instanceof GenericTypeReference)) { |
6092 return ""; | 5831 return ""; |
6093 } | 5832 } |
6094 if (returnType.get$names() != null) { | 5833 if (returnType.get$names() != null) { |
6095 return returnType.get$names().$index((0)).get$name(); | 5834 return returnType.get$names()[(0)].name; |
6096 } | 5835 } |
6097 else if (returnType.get$name() != null) { | 5836 else if ($ne(returnType.get$name())) { |
6098 return returnType.get$name().get$name(); | 5837 return returnType.get$name().get$name(); |
6099 } | 5838 } |
6100 $globals.world.internalError("no valid constructor name", this.definition.span
); | 5839 $globals.world.internalError("no valid constructor name", this.definition.span
); |
6101 } | 5840 } |
6102 MethodMember.prototype.get$functionType = function() { | 5841 MethodMember.prototype.get$functionType = function() { |
6103 if (this._functionType == null) { | 5842 if (this._functionType == null) { |
6104 this._functionType = this.get$library().getOrAddFunctionType(this.declaringT
ype, this.name, this.definition); | 5843 this._functionType = this.get$library().getOrAddFunctionType(this.declaringT
ype, this.name, this.definition, this.get$methodData()); |
6105 if (this.parameters == null) { | 5844 if (this.parameters == null) { |
6106 this.resolve(); | 5845 this.resolve(); |
6107 } | 5846 } |
6108 } | 5847 } |
6109 return this._functionType; | 5848 return this._functionType; |
6110 } | 5849 } |
6111 MethodMember.prototype.override = function(other) { | 5850 MethodMember.prototype.override = function(other) { |
6112 if (!Member.prototype.override.call(this, other)) return false; | 5851 if (!Member.prototype.override.call(this, other)) return false; |
6113 if (other.get$isMethod()) { | 5852 if (other.get$isMethod()) { |
6114 return true; | 5853 return true; |
(...skipping 23 matching lines...) Expand all Loading... |
6138 MethodMember.prototype.indexOfParameter = function(name) { | 5877 MethodMember.prototype.indexOfParameter = function(name) { |
6139 for (var i = (0); | 5878 for (var i = (0); |
6140 i < this.parameters.get$length(); i++) { | 5879 i < this.parameters.get$length(); i++) { |
6141 var p = this.parameters[i]; | 5880 var p = this.parameters[i]; |
6142 if (p.get$isOptional() && $eq(p.get$name(), name)) { | 5881 if (p.get$isOptional() && $eq(p.get$name(), name)) { |
6143 return i; | 5882 return i; |
6144 } | 5883 } |
6145 } | 5884 } |
6146 return (-1); | 5885 return (-1); |
6147 } | 5886 } |
6148 MethodMember.prototype.provideFieldSyntax = function() { | |
6149 this._provideFieldSyntax = true; | |
6150 } | |
6151 MethodMember.prototype.providePropertySyntax = function() { | 5887 MethodMember.prototype.providePropertySyntax = function() { |
6152 this._providePropertySyntax = true; | 5888 this._providePropertySyntax = true; |
6153 } | 5889 } |
6154 MethodMember.prototype._set = function(context, node, target, value, isDynamic)
{ | 5890 MethodMember.prototype._set = function(context, node, target, value) { |
6155 $globals.world.error("cannot set method", node.span); | 5891 $globals.world.error("cannot set method", node.span); |
6156 } | 5892 } |
6157 MethodMember.prototype._get = function(context, node, target, isDynamic) { | 5893 MethodMember.prototype._get = function(context, node, target) { |
| 5894 if (!context.get$needsCode()) { |
| 5895 return new PureStaticValue(this.get$functionType(), node.span, false, false)
; |
| 5896 } |
6158 this.declaringType.genMethod(this); | 5897 this.declaringType.genMethod(this); |
6159 this._provideOptionalParamInfo = true; | 5898 this._provideOptionalParamInfo = true; |
6160 if (this.isStatic) { | 5899 if (this.isStatic) { |
6161 this.declaringType.markUsed(); | 5900 this.declaringType.markUsed(); |
6162 var type = this.declaringType.get$isTop() ? "" : ("" + this.declaringType.ge
t$jsname() + "."); | 5901 var type = this.declaringType.get$isTop() ? "" : ("" + this.declaringType.ge
t$jsname() + "."); |
6163 return new Value(this.get$functionType(), ("" + type + this.get$jsname()), n
ode.span); | 5902 return new Value(this.get$functionType(), ("" + type + this.get$jsname()), n
ode.span); |
6164 } | 5903 } |
6165 this._providePropertySyntax = true; | 5904 this._providePropertySyntax = true; |
6166 return new Value(this.get$functionType(), ("" + target.get$code() + ".get$" +
this.get$jsname() + "()"), node.span); | 5905 return new Value(this.get$functionType(), ("" + target.get$code() + ".get$" +
this.get$jsname() + "()"), node.span); |
6167 } | 5906 } |
6168 MethodMember.prototype.namesInHomePositions = function(args) { | 5907 MethodMember.prototype.namesInHomePositions = function(args) { |
6169 if (!args.get$hasNames()) return true; | 5908 if (!args.get$hasNames()) return true; |
6170 for (var i = args.get$bareCount(); | 5909 for (var i = args.get$bareCount(); |
6171 i < args.values.get$length(); i++) { | 5910 i < args.values.get$length(); i++) { |
6172 if (i >= this.parameters.get$length()) { | 5911 if (i >= this.parameters.get$length()) { |
6173 return false; | 5912 return false; |
6174 } | 5913 } |
6175 if (args.getName(i) != this.parameters[i].get$name()) { | 5914 if (args.getName(i) != this.parameters[i].name) { |
6176 return false; | 5915 return false; |
6177 } | 5916 } |
6178 } | 5917 } |
6179 return true; | 5918 return true; |
6180 } | 5919 } |
6181 MethodMember.prototype.namesInOrder = function(args) { | 5920 MethodMember.prototype.namesInOrder = function(args) { |
6182 if (!args.get$hasNames()) return true; | 5921 if (!args.get$hasNames()) return true; |
6183 var lastParameter = null; | 5922 var lastParameter = null; |
6184 for (var i = args.get$bareCount(); | 5923 for (var i = args.get$bareCount(); |
6185 i < this.parameters.get$length(); i++) { | 5924 i < this.parameters.get$length(); i++) { |
6186 var p = args.getIndexOfName(this.parameters[i].get$name()); | 5925 var p = args.getIndexOfName(this.parameters[i].name); |
6187 if (p >= (0) && args.values[p].get$needsTemp()) { | 5926 if ($gte(p, (0)) && args.values.$index(p).get$needsTemp()) { |
6188 if (lastParameter != null && lastParameter > p) { | 5927 if (lastParameter != null && $gt(lastParameter, p)) { |
6189 return false; | 5928 return false; |
6190 } | 5929 } |
6191 lastParameter = p; | 5930 lastParameter = p; |
6192 } | 5931 } |
6193 } | 5932 } |
6194 return true; | 5933 return true; |
6195 } | 5934 } |
6196 MethodMember.prototype.needsArgumentConversion = function(args) { | 5935 MethodMember.prototype.needsArgumentConversion = function(args) { |
6197 var bareCount = args.get$bareCount(); | 5936 var bareCount = args.get$bareCount(); |
6198 for (var i = (0); | 5937 for (var i = (0); |
6199 i < bareCount; i++) { | 5938 i < bareCount; i++) { |
6200 var arg = args.values[i]; | 5939 var arg = args.values.$index(i); |
6201 if (arg.needsConversion$1(this.parameters[i].get$type())) { | 5940 if (arg.needsConversion(this.parameters[i].type)) { |
6202 return true; | 5941 return true; |
6203 } | 5942 } |
6204 } | 5943 } |
6205 if (bareCount < this.parameters.get$length()) { | 5944 if (bareCount < this.parameters.get$length()) { |
6206 this.genParameterValues(); | |
6207 for (var i = bareCount; | 5945 for (var i = bareCount; |
6208 i < this.parameters.get$length(); i++) { | 5946 i < this.parameters.get$length(); i++) { |
6209 var arg = args.getValue(this.parameters[i].get$name()); | 5947 var arg = args.getValue(this.parameters[i].name); |
6210 if (arg != null && arg.needsConversion$1(this.parameters[i].get$type())) { | 5948 if ($ne(arg) && arg.needsConversion(this.parameters[i].type)) { |
6211 return true; | 5949 return true; |
6212 } | 5950 } |
6213 } | 5951 } |
6214 } | 5952 } |
6215 return false; | 5953 return false; |
6216 } | 5954 } |
6217 MethodMember._argCountMsg = function(actual, expected, atLeast) { | 5955 MethodMember._argCountMsg = function(actual, expected, atLeast) { |
6218 return "wrong number of positional arguments, expected " + ("" + (atLeast ? "a
t least " : "") + expected + " but found " + actual); | 5956 return $add("wrong number of positional arguments, expected ", ("" + (atLeast
? "at least " : "") + expected + " but found " + actual)); |
6219 } | 5957 } |
6220 MethodMember.prototype._argError = function(context, node, target, args, msg, ar
gIndex) { | 5958 MethodMember.prototype._argError = function(context, node, target, args, msg, ar
gIndex) { |
6221 var span; | 5959 var span; |
6222 if ((args.nodes == null) || (argIndex >= args.nodes.get$length())) { | 5960 if ((args.nodes == null) || (argIndex >= args.nodes.get$length())) { |
6223 span = node.span; | 5961 span = node.span; |
6224 } | 5962 } |
6225 else { | 5963 else { |
6226 span = args.nodes[argIndex].get$span(); | 5964 span = args.nodes[argIndex].span; |
6227 } | 5965 } |
6228 if (this.isStatic || this.get$isConstructor()) { | 5966 if (this.isStatic || this.get$isConstructor()) { |
6229 $globals.world.error(msg, span); | 5967 $globals.world.error(msg, span); |
6230 } | 5968 } |
6231 else { | 5969 else { |
6232 $globals.world.warning(msg, span); | 5970 $globals.world.warning(msg, span); |
6233 } | 5971 } |
6234 return target.invokeNoSuchMethod(context, this.name, node, args); | 5972 return target.invokeNoSuchMethod(context, this.name, node, args); |
6235 } | 5973 } |
6236 MethodMember.prototype.genParameterValues = function() { | 5974 MethodMember.prototype.genParameterValues = function(context) { |
6237 var $$list = this.parameters; | 5975 var $$list = this.parameters; |
6238 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 5976 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
6239 var p = $$list[$$i]; | 5977 var p = $$i.next(); |
6240 p.genValue$2(this, this.generator); | 5978 p.genValue(this, context); |
6241 } | 5979 } |
6242 } | 5980 } |
6243 MethodMember.prototype.invoke = function(context, node, target, args, isDynamic)
{ | 5981 MethodMember.prototype.invoke = function(context, node, target, args) { |
6244 if (this.parameters == null) { | 5982 if (!context.get$needsCode()) { |
6245 $globals.world.info(("surprised to need to resolve: " + this.declaringType.n
ame + "." + this.name)); | 5983 return new PureStaticValue(this.returnType, node.span, false, false); |
6246 this.resolve(); | |
6247 } | 5984 } |
6248 this.declaringType.genMethod(this); | 5985 this.declaringType.genMethod(this); |
6249 if (this.isStatic || this.isFactory) { | 5986 if (this.isStatic || this.isFactory) { |
6250 this.declaringType.markUsed(); | 5987 this.declaringType.markUsed(); |
6251 } | 5988 } |
6252 if (this.get$isNative() && this.returnType != null) this.returnType.markUsed()
; | 5989 if (this.get$isNative() && this.returnType != null) this.returnType.markUsed()
; |
6253 if (!this.namesInOrder(args)) { | 5990 if (!this.namesInOrder(args)) { |
6254 return context.findMembers(this.name).invokeOnVar(context, node, target, arg
s); | 5991 return context.findMembers(this.name).invokeOnVar(context, node, target, arg
s); |
6255 } | 5992 } |
6256 var argsCode = []; | 5993 var argsCode = []; |
6257 if (!target.get$isType() && (this.get$isConstructor() || target.get$isSuper())
) { | 5994 if (!target.get$isType() && (this.get$isConstructor() || target.get$isSuper())
) { |
6258 argsCode.add$1("this"); | 5995 argsCode.add("this"); |
6259 } | 5996 } |
6260 var bareCount = args.get$bareCount(); | 5997 var bareCount = args.get$bareCount(); |
6261 for (var i = (0); | 5998 for (var i = (0); |
6262 i < bareCount; i++) { | 5999 i < bareCount; i++) { |
6263 var arg = args.values[i]; | 6000 var arg = args.values.$index(i); |
6264 if (i >= this.parameters.get$length()) { | 6001 if (i >= this.parameters.get$length()) { |
6265 var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.get
$length(), false); | 6002 var msg = MethodMember._argCountMsg(args.get$length(), this.parameters.get
$length(), false); |
6266 return this._argError(context, node, target, args, msg, i); | 6003 return this._argError(context, node, target, args, msg, i); |
6267 } | 6004 } |
6268 arg = arg.convertTo$3(context, this.parameters[i].get$type(), isDynamic); | 6005 arg = arg.convertTo(context, this.parameters[i].type); |
6269 argsCode.add$1(arg.get$code()); | 6006 argsCode.add(arg.get$code()); |
6270 } | 6007 } |
6271 var namedArgsUsed = (0); | 6008 var namedArgsUsed = (0); |
6272 if (bareCount < this.parameters.get$length()) { | 6009 if (bareCount < this.parameters.get$length()) { |
6273 this.genParameterValues(); | 6010 this.genParameterValues(context); |
6274 for (var i = bareCount; | 6011 for (var i = bareCount; |
6275 i < this.parameters.get$length(); i++) { | 6012 i < this.parameters.get$length(); i++) { |
6276 var arg = args.getValue(this.parameters[i].get$name()); | 6013 var arg = args.getValue(this.parameters[i].name); |
6277 if (arg == null) { | 6014 if ($eq(arg)) { |
6278 arg = this.parameters[i].get$value(); | 6015 arg = this.parameters[i].value; |
6279 } | 6016 } |
6280 else { | 6017 else { |
6281 arg = arg.convertTo$3(context, this.parameters[i].get$type(), isDynamic)
; | 6018 arg = arg.convertTo(context, this.parameters[i].type); |
6282 namedArgsUsed++; | 6019 namedArgsUsed++; |
6283 } | 6020 } |
6284 if (arg == null || !this.parameters[i].get$isOptional()) { | 6021 if ($eq(arg) || !this.parameters[i].get$isOptional()) { |
6285 var msg = MethodMember._argCountMsg(Math.min(i, args.get$length()), i +
(1), true); | 6022 var msg = MethodMember._argCountMsg(Math.min(i, args.get$length()), i +
(1), true); |
6286 return this._argError(context, node, target, args, msg, i); | 6023 return this._argError(context, node, target, args, msg, i); |
6287 } | 6024 } |
6288 else { | 6025 else { |
6289 argsCode.add$1(arg.get$code()); | 6026 argsCode.add(arg.get$code()); |
6290 } | 6027 } |
6291 } | 6028 } |
6292 Arguments.removeTrailingNulls(argsCode); | 6029 Arguments.removeTrailingNulls(argsCode); |
6293 } | 6030 } |
6294 if (namedArgsUsed < args.get$nameCount()) { | 6031 if (namedArgsUsed < args.get$nameCount()) { |
6295 var seen = new HashSetImplementation(); | 6032 var seen = new HashSetImplementation_dart_core_String(); |
6296 for (var i = bareCount; | 6033 for (var i = bareCount; |
6297 i < args.get$length(); i++) { | 6034 i < args.get$length(); i++) { |
6298 var name = args.getName(i); | 6035 var name = args.getName(i); |
6299 if (seen.contains$1(name)) { | 6036 if (seen.contains$1(name)) { |
6300 return this._argError(context, node, target, args, ("duplicate argument
\"" + name + "\""), i); | 6037 return this._argError(context, node, target, args, ("duplicate argument
\"" + name + "\""), i); |
6301 } | 6038 } |
6302 seen.add$1(name); | 6039 seen.add(name); |
6303 var p = this.indexOfParameter(name); | 6040 var p = this.indexOfParameter(name); |
6304 if (p < (0)) { | 6041 if (p < (0)) { |
6305 return this._argError(context, node, target, args, ("method does not hav
e optional parameter \"" + name + "\""), i); | 6042 return this._argError(context, node, target, args, ("method does not hav
e optional parameter \"" + name + "\""), i); |
6306 } | 6043 } |
6307 else if (p < bareCount) { | 6044 else if (p < bareCount) { |
6308 return this._argError(context, node, target, args, ("argument \"" + name
+ "\" passed as positional and named"), p); | 6045 return this._argError(context, node, target, args, ("argument \"" + name
+ "\" passed as positional and named"), p); |
6309 } | 6046 } |
6310 } | 6047 } |
6311 $globals.world.internalError(("wrong named arguments calling " + this.name),
node.span); | 6048 $globals.world.internalError(("wrong named arguments calling " + this.name),
node.span); |
6312 } | 6049 } |
6313 var argsString = Strings.join(argsCode, ", "); | 6050 var argsString = Strings.join(argsCode, ", "); |
6314 if (this.get$isConstructor()) { | 6051 if (this.get$isConstructor()) { |
6315 return this._invokeConstructor(context, node, target, args, argsString); | 6052 return this._invokeConstructor(context, node, target, args, argsString); |
6316 } | 6053 } |
6317 if (target.get$isSuper()) { | 6054 if (target.get$isSuper()) { |
6318 return new Value(this.get$inferredResult(), ("" + this.declaringType.get$jsn
ame() + ".prototype." + this.get$jsname() + ".call(" + argsString + ")"), node.s
pan); | 6055 return new Value(this.get$inferredResult(), ("" + this.declaringType.get$jsn
ame() + ".prototype." + this.get$jsname() + ".call(" + argsString + ")"), node.s
pan); |
6319 } | 6056 } |
6320 if (this.get$isOperator()) { | 6057 if (this.get$isOperator()) { |
6321 return this._invokeBuiltin(context, node, target, args, argsCode, isDynamic)
; | 6058 return this._invokeBuiltin(context, node, target, args, argsCode); |
6322 } | 6059 } |
6323 if (this.isFactory) { | 6060 if (this.isFactory) { |
6324 return new Value(target.get$type(), ("" + this.get$generatedFactoryName() +
"(" + argsString + ")"), node != null ? node.span : null); | 6061 return new Value(target.get$type(), ("" + this.get$generatedFactoryName() +
"(" + argsString + ")"), node != null ? node.span : null); |
6325 } | 6062 } |
6326 if (this.isStatic) { | 6063 if (this.isStatic) { |
6327 if (this.declaringType.get$isTop()) { | 6064 if (this.declaringType.get$isTop()) { |
6328 return new Value(this.get$inferredResult(), ("" + this.get$jsname() + "("
+ argsString + ")"), node != null ? node.span : null); | 6065 return new Value(this.get$inferredResult(), ("" + this.get$jsname() + "("
+ argsString + ")"), node != null ? node.span : null); |
6329 } | 6066 } |
6330 return new Value(this.get$inferredResult(), ("" + this.declaringType.get$jsn
ame() + "." + this.get$jsname() + "(" + argsString + ")"), node.span); | 6067 return new Value(this.get$inferredResult(), ("" + this.declaringType.get$jsn
ame() + "." + this.get$jsname() + "(" + argsString + ")"), node.span); |
6331 } | 6068 } |
(...skipping 13 matching lines...) Expand all Loading... |
6345 return new Value(target.get$type(), code, span); | 6082 return new Value(target.get$type(), code, span); |
6346 } | 6083 } |
6347 else { | 6084 else { |
6348 if (this.isConst && (node instanceof NewExpression) && node.get$dynamic().ge
t$isConst()) { | 6085 if (this.isConst && (node instanceof NewExpression) && node.get$dynamic().ge
t$isConst()) { |
6349 if (this.get$isNative() || this.declaringType.name == "JSSyntaxRegExp") { | 6086 if (this.get$isNative() || this.declaringType.name == "JSSyntaxRegExp") { |
6350 var code = ("new " + this.declaringType.get$nativeName() + ctor + "(" +
argsString + ")"); | 6087 var code = ("new " + this.declaringType.get$nativeName() + ctor + "(" +
argsString + ")"); |
6351 return $globals.world.gen.globalForConst(new Value(target.get$type(), co
de, span), [args.values]); | 6088 return $globals.world.gen.globalForConst(new Value(target.get$type(), co
de, span), [args.values]); |
6352 } | 6089 } |
6353 var newType = this.declaringType; | 6090 var newType = this.declaringType; |
6354 var newObject = new ObjectValue(true, newType, span); | 6091 var newObject = new ObjectValue(true, newType, span); |
6355 newObject.initFields$0(); | 6092 newObject.initFields(); |
6356 this._evalConstConstructor(newObject, args); | 6093 this._evalConstConstructor(newObject, args); |
6357 return $globals.world.gen.globalForConst(newObject, [args.values]); | 6094 return $globals.world.gen.globalForConst(newObject, [args.values]); |
6358 } | 6095 } |
6359 else { | 6096 else { |
6360 var code = ("new " + this.declaringType.get$nativeName() + ctor + "(" + ar
gsString + ")"); | 6097 var code = ("new " + this.declaringType.get$nativeName() + ctor + "(" + ar
gsString + ")"); |
6361 return new Value(target.get$type(), code, span); | 6098 return new Value(target.get$type(), code, span); |
6362 } | 6099 } |
6363 } | 6100 } |
6364 } | 6101 } |
6365 MethodMember.prototype._evalConstConstructor = function(newObject, args) { | 6102 MethodMember.prototype._evalConstConstructor = function(newObject, args) { |
6366 this.declaringType.markUsed(); | 6103 this.declaringType.markUsed(); |
6367 var generator = new MethodGenerator(this, null); | 6104 this.get$methodData().eval(this, newObject, args); |
6368 generator.evalBody$2(newObject, args); | |
6369 } | 6105 } |
6370 MethodMember.prototype._invokeBuiltin = function(context, node, target, args, ar
gsCode, isDynamic) { | 6106 MethodMember.prototype._invokeBuiltin = function(context, node, target, args, ar
gsCode) { |
6371 if (this.declaringType.get$isNum()) { | 6107 if (target.get$type().get$isNum()) { |
6372 var code; | 6108 var code = null; |
6373 if (this.name == ":negate") { | 6109 if (args.get$length() == (0)) { |
6374 code = ("-" + target.get$code()); | 6110 if (this.name == ":negate") { |
| 6111 code = ("-" + target.get$code()); |
| 6112 } |
| 6113 else if (this.name == ":bit_not") { |
| 6114 code = ("~" + target.get$code()); |
| 6115 } |
6375 } | 6116 } |
6376 else if (this.name == ":bit_not") { | 6117 else if (args.get$length() == (1) && args.values.$index((0)).get$type().get$
isNum()) { |
6377 code = ("~" + target.get$code()); | 6118 if (this.name == ":truncdiv" || this.name == ":mod") { |
| 6119 $globals.world.gen.corejs.useOperator(this.name); |
| 6120 code = ("" + this.get$jsname() + "(" + target.get$code() + ", " + argsCo
de.$index((0)) + ")"); |
| 6121 } |
| 6122 else { |
| 6123 var op = TokenKind.rawOperatorFromMethod(this.name); |
| 6124 code = ("" + target.get$code() + " " + op + " " + argsCode.$index((0))); |
| 6125 } |
6378 } | 6126 } |
6379 else if (this.name == ":truncdiv" || this.name == ":mod") { | 6127 if (code != null) { |
6380 $globals.world.gen.corejs.useOperator(this.name); | 6128 return new Value(this.get$inferredResult(), code, node.span); |
6381 code = ("" + this.get$jsname() + "(" + target.get$code() + ", " + argsCode
.$index((0)) + ")"); | |
6382 } | 6129 } |
6383 else { | |
6384 var op = TokenKind.rawOperatorFromMethod(this.name); | |
6385 code = ("" + target.get$code() + " " + op + " " + argsCode.$index((0))); | |
6386 } | |
6387 return new Value(this.get$inferredResult(), code, node.span); | |
6388 } | 6130 } |
6389 else if (this.declaringType.get$isString()) { | 6131 else if (target.get$type().get$isString()) { |
6390 if (this.name == ":index") { | 6132 if (this.name == ":index" && args.values.$index((0)).get$type().get$isNum())
{ |
6391 return new Value(this.declaringType, ("" + target.get$code() + "[" + argsC
ode.$index((0)) + "]"), node.span); | 6133 return new Value(this.declaringType, ("" + target.get$code() + "[" + argsC
ode.$index((0)) + "]"), node.span); |
6392 } | 6134 } |
6393 else if (this.name == ":add") { | 6135 else if (this.name == ":add" && args.values.$index((0)).get$type().get$isNum
()) { |
6394 return new Value(this.declaringType, ("" + target.get$code() + " + " + arg
sCode.$index((0))), node.span); | 6136 return new Value(this.declaringType, ("" + target.get$code() + " + " + arg
sCode.$index((0))), node.span); |
6395 } | 6137 } |
6396 } | 6138 } |
6397 else if (this.declaringType.get$isNative()) { | 6139 else if (this.declaringType.get$isNative()) { |
6398 if (this.name == ":index") { | 6140 if (args.get$length() > (0) && args.values.$index((0)).get$type().get$isNum(
)) { |
6399 return new Value(this.returnType, ("" + target.get$code() + "[" + argsCode
.$index((0)) + "]"), node.span); | 6141 if (this.name == ":index") { |
6400 } | 6142 return new Value(this.returnType, ("" + target.get$code() + "[" + argsCo
de.$index((0)) + "]"), node.span); |
6401 else if (this.name == ":setindex") { | 6143 } |
6402 return new Value(this.returnType, ("" + target.get$code() + "[" + argsCode
.$index((0)) + "] = " + argsCode.$index((1))), node.span); | 6144 else if (this.name == ":setindex") { |
| 6145 return new Value(this.returnType, ("" + target.get$code() + "[" + argsCo
de.$index((0)) + "] = " + argsCode.$index((1))), node.span); |
| 6146 } |
6403 } | 6147 } |
6404 } | 6148 } |
6405 if (this.name == ":eq" || this.name == ":ne") { | 6149 if (this.name == ":eq" || this.name == ":ne") { |
6406 var op = this.name == ":eq" ? "==" : "!="; | 6150 var op = this.name == ":eq" ? "==" : "!="; |
6407 if (this.name == ":ne") { | 6151 if (this.name == ":ne") { |
6408 target.invoke(context, ":eq", node, args, isDynamic); | 6152 target.invoke(context, ":eq", node, args); |
6409 } | 6153 } |
6410 if ($eq(argsCode.$index((0)), "null")) { | 6154 if ($eq(argsCode.$index((0)), "null")) { |
6411 return new Value(this.get$inferredResult(), ("" + target.get$code() + " "
+ op + " null"), node.span); | 6155 return new Value(this.get$inferredResult(), ("" + target.get$code() + " "
+ op + " null"), node.span); |
6412 } | 6156 } |
6413 else if (target.get$type().get$isNum() || target.get$type().get$isString())
{ | 6157 else if (target.get$type().get$isNum() || target.get$type().get$isString())
{ |
6414 return new Value(this.get$inferredResult(), ("" + target.get$code() + " "
+ op + " " + argsCode.$index((0))), node.span); | 6158 return new Value(this.get$inferredResult(), ("" + target.get$code() + " "
+ op + " " + argsCode.$index((0))), node.span); |
6415 } | 6159 } |
6416 $globals.world.gen.corejs.useOperator(this.name); | 6160 $globals.world.gen.corejs.useOperator(this.name); |
6417 return new Value(this.get$inferredResult(), ("" + this.get$jsname() + "(" +
target.get$code() + ", " + argsCode.$index((0)) + ")"), node.span); | 6161 return new Value(this.get$inferredResult(), ("" + this.get$jsname() + "(" +
target.get$code() + ", " + argsCode.$index((0)) + ")"), node.span); |
6418 } | 6162 } |
6419 if (this.get$isCallMethod()) { | 6163 if (this.get$isCallMethod()) { |
6420 this.declaringType.markUsed(); | 6164 this.declaringType.markUsed(); |
6421 return new Value(this.get$inferredResult(), ("" + target.get$code() + "(" +
Strings.join(argsCode, ", ") + ")"), node.span); | 6165 return new Value(this.get$inferredResult(), ("" + target.get$code() + "(" +
Strings.join(argsCode, ", ") + ")"), node.span); |
6422 } | 6166 } |
6423 if (this.name == ":index") { | 6167 if (this.name == ":index") { |
6424 $globals.world.gen.corejs.useIndex = true; | 6168 $globals.world.gen.corejs.useIndex = true; |
6425 } | 6169 } |
6426 else if (this.name == ":setindex") { | 6170 else if (this.name == ":setindex") { |
6427 $globals.world.gen.corejs.useSetIndex = true; | 6171 $globals.world.gen.corejs.useSetIndex = true; |
6428 } | 6172 } |
| 6173 else { |
| 6174 $globals.world.gen.corejs.useOperator(this.name); |
| 6175 var argsString = argsCode.get$length() == (0) ? "" : (", " + argsCode.$index
((0))); |
| 6176 return new Value(this.returnType, ("" + this.get$jsname() + "(" + target.get
$code() + argsString + ")"), node.span); |
| 6177 } |
6429 var argsString = Strings.join(argsCode, ", "); | 6178 var argsString = Strings.join(argsCode, ", "); |
6430 return new Value(this.get$inferredResult(), ("" + target.get$code() + "." + th
is.get$jsname() + "(" + argsString + ")"), node.span); | 6179 return new Value(this.get$inferredResult(), ("" + target.get$code() + "." + th
is.get$jsname() + "(" + argsString + ")"), node.span); |
6431 } | 6180 } |
6432 MethodMember.prototype.resolve = function() { | 6181 MethodMember.prototype.resolve = function() { |
6433 this.isStatic = this.declaringType.get$isTop(); | 6182 this.isStatic = this.declaringType.get$isTop(); |
6434 this.isConst = false; | 6183 this.isConst = false; |
6435 this.isFactory = false; | 6184 this.isFactory = false; |
6436 this.isAbstract = !this.declaringType.get$isClass(); | 6185 this.isAbstract = !this.declaringType.get$isClass(); |
6437 if (this.definition.modifiers != null) { | 6186 if (this.definition.modifiers != null) { |
6438 var $$list = this.definition.modifiers; | 6187 var $$list = this.definition.modifiers; |
6439 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 6188 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
6440 var mod = $$list[$$i]; | 6189 var mod = $$i.next(); |
6441 if ($eq(mod.get$kind(), (85))) { | 6190 if (mod.get$kind() == (85)) { |
6442 if (this.isStatic) { | 6191 if (this.isStatic) { |
6443 $globals.world.error("duplicate static modifier", mod.get$span()); | 6192 $globals.world.error("duplicate static modifier", mod.get$span()); |
6444 } | 6193 } |
6445 this.isStatic = true; | 6194 this.isStatic = true; |
6446 } | 6195 } |
6447 else if (this.get$isConstructor() && $eq(mod.get$kind(), (92))) { | 6196 else if (this.get$isConstructor() && mod.get$kind() == (92)) { |
6448 if (this.isConst) { | 6197 if (this.isConst) { |
6449 $globals.world.error("duplicate const modifier", mod.get$span()); | 6198 $globals.world.error("duplicate const modifier", mod.get$span()); |
6450 } | 6199 } |
6451 if (this.isFactory) { | 6200 if (this.isFactory) { |
6452 $globals.world.error("const factory not allowed", mod.get$span()); | 6201 $globals.world.error("const factory not allowed", mod.get$span()); |
6453 } | 6202 } |
6454 this.isConst = true; | 6203 this.isConst = true; |
6455 } | 6204 } |
6456 else if ($eq(mod.get$kind(), (74))) { | 6205 else if (mod.get$kind() == (74)) { |
6457 if (this.isFactory) { | 6206 if (this.isFactory) { |
6458 $globals.world.error("duplicate factory modifier", mod.get$span()); | 6207 $globals.world.error("duplicate factory modifier", mod.get$span()); |
6459 } | 6208 } |
6460 if (this.isConst) { | 6209 if (this.isConst) { |
6461 $globals.world.error("const factory not allowed", mod.get$span()); | 6210 $globals.world.error("const factory not allowed", mod.get$span()); |
6462 } | 6211 } |
6463 if (this.isStatic) { | 6212 if (this.isStatic) { |
6464 $globals.world.error("static factory not allowed", mod.get$span()); | 6213 $globals.world.error("static factory not allowed", mod.get$span()); |
6465 } | 6214 } |
6466 this.isFactory = true; | 6215 this.isFactory = true; |
6467 } | 6216 } |
6468 else if ($eq(mod.get$kind(), (71))) { | 6217 else if (mod.get$kind() == (71)) { |
6469 if (this.isAbstract) { | 6218 if (this.isAbstract) { |
6470 if (this.declaringType.get$isClass()) { | 6219 if (this.declaringType.get$isClass()) { |
6471 $globals.world.error("duplicate abstract modifier", mod.get$span()); | 6220 $globals.world.error("duplicate abstract modifier", mod.get$span()); |
6472 } | 6221 } |
6473 else if (!this.get$isCallMethod()) { | 6222 else if (!this.get$isCallMethod()) { |
6474 $globals.world.error("abstract modifier not allowed on interface mem
bers", mod.get$span()); | 6223 $globals.world.error("abstract modifier not allowed on interface mem
bers", mod.get$span()); |
6475 } | 6224 } |
6476 } | 6225 } |
6477 this.isAbstract = true; | 6226 this.isAbstract = true; |
6478 } | 6227 } |
(...skipping 18 matching lines...) Expand all Loading... |
6497 } | 6246 } |
6498 else { | 6247 else { |
6499 if (this.definition.body == null && !this.get$isConstructor() && !this.get$i
sNative()) { | 6248 if (this.definition.body == null && !this.get$isConstructor() && !this.get$i
sNative()) { |
6500 $globals.world.error("method needs a body", this.get$span()); | 6249 $globals.world.error("method needs a body", this.get$span()); |
6501 } | 6250 } |
6502 } | 6251 } |
6503 if (this.get$isConstructor() && !this.isFactory) { | 6252 if (this.get$isConstructor() && !this.isFactory) { |
6504 this.returnType = this.declaringType; | 6253 this.returnType = this.declaringType; |
6505 } | 6254 } |
6506 else { | 6255 else { |
6507 this.returnType = this.resolveType(this.definition.returnType, false, true); | 6256 if ((this.definition.returnType instanceof SimpleTypeReference) && $eq(this.
definition.returnType.get$dynamic().get$type(), $globals.world.voidType)) { |
| 6257 this.returnType = $globals.world.voidType; |
| 6258 } |
| 6259 else { |
| 6260 this.returnType = this.resolveType(this.definition.returnType, false, !thi
s.isStatic); |
| 6261 } |
6508 } | 6262 } |
6509 this.parameters = []; | 6263 this.parameters = []; |
6510 var $$list = this.definition.formals; | 6264 var $$list = this.definition.formals; |
6511 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 6265 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
6512 var formal = $$list[$$i]; | 6266 var formal = $$i.next(); |
6513 var param = new Parameter(formal, this); | 6267 var param = new Parameter(formal, this); |
6514 param.resolve$0(); | 6268 param.resolve(); |
6515 this.parameters.add(param); | 6269 this.parameters.add(param); |
6516 } | 6270 } |
6517 if (!this.isLambda) { | 6271 if (!this.isLambda && this.declaringType.get$isClass()) { |
6518 this.get$library()._addMember(this); | 6272 this.get$library()._addMember(this); |
6519 } | 6273 } |
6520 } | 6274 } |
6521 MethodMember.prototype.resolveType = function(node, typeErrors, allowVoid) { | 6275 // ********** Code for FactoryMap ************** |
6522 var t = Element.prototype.resolveType.call(this, node, typeErrors); | 6276 function FactoryMap() { |
6523 if (this.isStatic && !this.isFactory && (t instanceof ParameterType)) { | 6277 this.factories = new HashMapImplementation(); |
6524 $globals.world.error("using type parameter in static context.", node.span); | 6278 } |
| 6279 FactoryMap.prototype.get$factories = function() { return this.factories; }; |
| 6280 FactoryMap.prototype.set$factories = function(value) { return this.factories = v
alue; }; |
| 6281 FactoryMap.prototype.getFactoriesFor = function(typeName) { |
| 6282 var ret = this.factories.$index(typeName); |
| 6283 if ($eq(ret)) { |
| 6284 ret = new HashMapImplementation(); |
| 6285 this.factories.$setindex(typeName, ret); |
6525 } | 6286 } |
6526 if (!allowVoid && t.get$isVoid()) { | 6287 return ret; |
6527 $globals.world.error("\"void\" only allowed as return type", node.span); | |
6528 } | |
6529 return t; | |
6530 } | 6288 } |
6531 MethodMember.prototype._evalConstConstructor$2 = MethodMember.prototype._evalCon
stConstructor; | 6289 FactoryMap.prototype.addFactory = function(typeName, name, member) { |
6532 MethodMember.prototype._get$3 = function($0, $1, $2) { | 6290 this.getFactoriesFor(typeName).$setindex(name, member); |
6533 return this._get($0, $1, $2, false); | 6291 } |
6534 }; | 6292 FactoryMap.prototype.getFactory = function(typeName, name) { |
6535 MethodMember.prototype._get$3$isDynamic = MethodMember.prototype._get; | 6293 return this.getFactoriesFor(typeName).$index(name); |
6536 MethodMember.prototype._get$4 = MethodMember.prototype._get; | 6294 } |
6537 MethodMember.prototype._set$4$isDynamic = MethodMember.prototype._set; | 6295 FactoryMap.prototype.forEach = function(f) { |
6538 MethodMember.prototype._set$5 = MethodMember.prototype._set; | 6296 this.factories.forEach((function (_, constructors) { |
6539 MethodMember.prototype.canInvoke$2 = MethodMember.prototype.canInvoke; | 6297 constructors.forEach((function (_, member) { |
6540 MethodMember.prototype.invoke$4 = function($0, $1, $2, $3) { | 6298 f(member); |
6541 return this.invoke($0, $1, $2, $3, false); | 6299 }) |
6542 }; | 6300 ); |
6543 MethodMember.prototype.invoke$4$isDynamic = MethodMember.prototype.invoke; | 6301 }) |
6544 MethodMember.prototype.invoke$5 = MethodMember.prototype.invoke; | 6302 ); |
6545 MethodMember.prototype.namesInOrder$1 = MethodMember.prototype.namesInOrder; | 6303 } |
6546 MethodMember.prototype.provideFieldSyntax$0 = MethodMember.prototype.provideFiel
dSyntax; | |
6547 MethodMember.prototype.providePropertySyntax$0 = MethodMember.prototype.provideP
ropertySyntax; | |
6548 MethodMember.prototype.resolve$0 = MethodMember.prototype.resolve; | |
6549 MethodMember.prototype.resolveType$2 = function($0, $1) { | |
6550 return this.resolveType($0, $1, false); | |
6551 }; | |
6552 // ********** Code for MemberSet ************** | 6304 // ********** Code for MemberSet ************** |
6553 function MemberSet(member, isVar) { | 6305 function MemberSet(member, isVar) { |
6554 this.jsname = member.get$jsname(); | 6306 this.jsname = member.get$jsname(); |
6555 this.name = member.name; | 6307 this.name = member.name; |
| 6308 this._preparedForSet = false; |
6556 this.isVar = isVar; | 6309 this.isVar = isVar; |
6557 this.members = [member]; | 6310 this.members = [member]; |
6558 } | 6311 } |
6559 MemberSet.prototype.get$name = function() { return this.name; }; | 6312 MemberSet.prototype.get$name = function() { return this.name; }; |
6560 MemberSet.prototype.get$members = function() { return this.members; }; | 6313 MemberSet.prototype.get$members = function() { return this.members; }; |
6561 MemberSet.prototype.get$jsname = function() { return this.jsname; }; | 6314 MemberSet.prototype.get$jsname = function() { return this.jsname; }; |
6562 MemberSet.prototype.get$isVar = function() { return this.isVar; }; | 6315 MemberSet.prototype.get$isVar = function() { return this.isVar; }; |
6563 MemberSet.prototype.toString = function() { | 6316 MemberSet.prototype.toString = function() { |
6564 return ("" + this.name + ":" + this.members.get$length()); | 6317 return ("" + this.name + ":" + this.members.get$length()); |
6565 } | 6318 } |
6566 MemberSet.prototype.add = function(member) { | 6319 MemberSet.prototype.add = function(member) { |
6567 return this.members.add(member); | 6320 this.members.add(member); |
6568 } | |
6569 MemberSet.prototype.get$isStatic = function() { | |
6570 return this.members.get$length() == (1) && this.members[(0)].get$isStatic(); | |
6571 } | 6321 } |
6572 MemberSet.prototype.get$isOperator = function() { | 6322 MemberSet.prototype.get$isOperator = function() { |
6573 return this.members[(0)].get$isOperator(); | 6323 return this.members[(0)].get$isOperator(); |
6574 } | 6324 } |
6575 MemberSet.prototype.canInvoke = function(context, args) { | |
6576 return this.members.some((function (m) { | |
6577 return m.canInvoke$2(context, args); | |
6578 }) | |
6579 ); | |
6580 } | |
6581 MemberSet.prototype._makeError = function(node, target, action) { | |
6582 if (!target.get$type().get$isVar()) { | |
6583 $globals.world.warning(("could not find applicable " + action + " for \"" +
this.name + "\""), node.span); | |
6584 } | |
6585 return new Value($globals.world.varType, ("" + target.get$code() + "." + this.
jsname + "() /*no applicable " + action + "*/"), node.span); | |
6586 } | |
6587 MemberSet.prototype.get$treatAsField = function() { | 6325 MemberSet.prototype.get$treatAsField = function() { |
6588 if (this._treatAsField == null) { | 6326 if (this._treatAsField == null) { |
6589 this._treatAsField = !this.isVar && (this.members.some((function (m) { | 6327 this._treatAsField = !this.isVar && this.members.every((function (m) { |
6590 return m.get$requiresFieldSyntax(); | 6328 return m.get$isField(); |
6591 }) | 6329 }) |
6592 ) || this.members.every((function (m) { | 6330 ); |
6593 return !m.get$requiresPropertySyntax(); | 6331 } |
6594 }) | 6332 return this._treatAsField; |
6595 )); | 6333 } |
| 6334 MemberSet.unionTypes = function(t1, t2) { |
| 6335 if (t1 == null) return t2; |
| 6336 if (t2 == null) return t1; |
| 6337 return Type.union(t1, t2); |
| 6338 } |
| 6339 MemberSet.prototype._get = function(context, node, target) { |
| 6340 if (this.members.get$length() == (1) && !this.isVar) { |
| 6341 return this.members[(0)]._get(context, node, target); |
| 6342 } |
| 6343 if (this._returnTypeForGet == null) { |
6596 var $$list = this.members; | 6344 var $$list = this.members; |
6597 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 6345 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
6598 var member = $$list[$$i]; | 6346 var member = $$i.next(); |
6599 if (this._treatAsField) { | 6347 if (!member.get$canGet()) continue; |
6600 member.provideFieldSyntax$0(); | 6348 if (!this.get$treatAsField()) member.providePropertySyntax(); |
6601 } | 6349 var r = member._get(context, node, target); |
6602 else { | 6350 this._returnTypeForGet = MemberSet.unionTypes(this._returnTypeForGet, r.ge
t$type()); |
6603 member.providePropertySyntax$0(); | 6351 } |
| 6352 if (this._returnTypeForGet == null) { |
| 6353 $globals.world.error(("no valid getters for \"" + this.name + "\""), node.
span); |
| 6354 } |
| 6355 } |
| 6356 if (this._treatAsField) { |
| 6357 return new Value(this._returnTypeForGet, ("" + target.get$code() + "." + thi
s.jsname), node.span); |
| 6358 } |
| 6359 else { |
| 6360 return new Value(this._returnTypeForGet, ("" + target.get$code() + ".get$" +
this.jsname + "()"), node.span); |
| 6361 } |
| 6362 } |
| 6363 MemberSet.prototype._set = function(context, node, target, value) { |
| 6364 if (this.members.get$length() == (1) && !this.isVar) { |
| 6365 return this.members[(0)]._set(context, node, target, value); |
| 6366 } |
| 6367 if (!this._preparedForSet) { |
| 6368 this._preparedForSet = true; |
| 6369 var $$list = this.members; |
| 6370 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 6371 var member = $$i.next(); |
| 6372 if (!member.get$canSet()) continue; |
| 6373 if (!this.get$treatAsField()) member.providePropertySyntax(); |
| 6374 var r = member._set(context, node, target, value); |
| 6375 } |
| 6376 } |
| 6377 if (this.get$treatAsField()) { |
| 6378 return new Value(value.get$type(), ("" + target.get$code() + "." + this.jsna
me + " = " + value.get$code()), node.span); |
| 6379 } |
| 6380 else { |
| 6381 return new Value(value.get$type(), ("" + target.get$code() + ".set$" + this.
jsname + "(" + value.get$code() + ")"), node.span); |
| 6382 } |
| 6383 } |
| 6384 MemberSet.prototype.invoke = function(context, node, target, args) { |
| 6385 if (this.members.get$length() == (1) && !this.isVar) { |
| 6386 return this.members[(0)].invoke(context, node, target, args); |
| 6387 } |
| 6388 var invokeKey = null; |
| 6389 if (this._invokes == null) { |
| 6390 this._invokes = []; |
| 6391 invokeKey = null; |
| 6392 } |
| 6393 else { |
| 6394 var $$list = this._invokes; |
| 6395 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 6396 var ik = $$i.next(); |
| 6397 if (ik.matches(args)) { |
| 6398 invokeKey = ik; |
| 6399 break; |
6604 } | 6400 } |
6605 } | 6401 } |
6606 } | 6402 } |
6607 return this._treatAsField; | 6403 if ($eq(invokeKey)) { |
6608 } | 6404 invokeKey = new InvokeKey(args); |
6609 MemberSet.prototype._get = function(context, node, target, isDynamic) { | 6405 this._invokes.add(invokeKey); |
6610 var returnValue; | 6406 invokeKey.addMembers(this.members, context, target, args); |
6611 if (this.members.get$length() == (1) && !this.isVar) { | |
6612 return this.members[(0)]._get$4(context, node, target, isDynamic); | |
6613 } | 6407 } |
6614 var targets = this.members.filter$1((function (m) { | 6408 if (invokeKey.get$needsVarCall() || this.get$isOperator()) { |
6615 return m.get$canGet(); | |
6616 }) | |
6617 ); | |
6618 if (this.isVar) { | |
6619 targets.forEach$1((function (m) { | |
6620 return m._get$3$isDynamic(context, node, target, true); | |
6621 }) | |
6622 ); | |
6623 returnValue = new Value(this._foldTypes(targets), null, node.span); | |
6624 } | |
6625 else { | |
6626 if (this.members.get$length() == (1)) { | |
6627 return this.members[(0)]._get$4(context, node, target, isDynamic); | |
6628 } | |
6629 else if ($eq(targets.get$length(), (1))) { | |
6630 return targets.$index((0))._get$4(context, node, target, isDynamic); | |
6631 } | |
6632 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { | |
6633 var member = $$i.next$0(); | |
6634 var value = member._get$3$isDynamic(context, node, target, true); | |
6635 returnValue = this._tryUnion(returnValue, value, node); | |
6636 } | |
6637 if (returnValue == null) { | |
6638 return this._makeError(node, target, "getter"); | |
6639 } | |
6640 } | |
6641 if (returnValue.get$code() == null) { | |
6642 if (this.get$treatAsField()) { | |
6643 return new Value(returnValue.get$type(), ("" + target.get$code() + "." + t
his.jsname), node.span); | |
6644 } | |
6645 else { | |
6646 return new Value(returnValue.get$type(), ("" + target.get$code() + ".get$"
+ this.jsname + "()"), node.span); | |
6647 } | |
6648 } | |
6649 return returnValue; | |
6650 } | |
6651 MemberSet.prototype._set = function(context, node, target, value, isDynamic) { | |
6652 if (this.members.get$length() == (1) && !this.isVar) { | |
6653 return this.members[(0)]._set$5(context, node, target, value, isDynamic); | |
6654 } | |
6655 var returnValue; | |
6656 var targets = this.members.filter$1((function (m) { | |
6657 return m.get$canSet(); | |
6658 }) | |
6659 ); | |
6660 if (this.isVar) { | |
6661 targets.forEach$1((function (m) { | |
6662 return m._set$4$isDynamic(context, node, target, value, true); | |
6663 }) | |
6664 ); | |
6665 returnValue = new Value(this._foldTypes(targets), null, node.span); | |
6666 } | |
6667 else { | |
6668 if (this.members.get$length() == (1)) { | |
6669 return this.members[(0)]._set$5(context, node, target, value, isDynamic); | |
6670 } | |
6671 else if ($eq(targets.get$length(), (1))) { | |
6672 return targets.$index((0))._set$5(context, node, target, value, isDynamic)
; | |
6673 } | |
6674 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { | |
6675 var member = $$i.next$0(); | |
6676 var res = member._set$4$isDynamic(context, node, target, value, true); | |
6677 returnValue = this._tryUnion(returnValue, res, node); | |
6678 } | |
6679 if (returnValue == null) { | |
6680 return this._makeError(node, target, "setter"); | |
6681 } | |
6682 } | |
6683 if (returnValue.get$code() == null) { | |
6684 if (this.get$treatAsField()) { | |
6685 return new Value(returnValue.get$type(), ("" + target.get$code() + "." + t
his.jsname + " = " + value.get$code()), node.span); | |
6686 } | |
6687 else { | |
6688 return new Value(returnValue.get$type(), ("" + target.get$code() + ".set$"
+ this.jsname + "(" + value.get$code() + ")"), node.span); | |
6689 } | |
6690 } | |
6691 return returnValue; | |
6692 } | |
6693 MemberSet.prototype.invoke = function(context, node, target, args, isDynamic) { | |
6694 if (this.isVar && !this.get$isOperator()) { | |
6695 return this.invokeOnVar(context, node, target, args); | |
6696 } | |
6697 if (this.members.get$length() == (1) && !this.isVar) { | |
6698 return this.members[(0)].invoke$5(context, node, target, args, isDynamic); | |
6699 } | |
6700 var targets = this.members.filter$1((function (m) { | |
6701 return m.canInvoke$2(context, args); | |
6702 }) | |
6703 ); | |
6704 if ($eq(targets.get$length(), (1))) { | |
6705 return targets.$index((0)).invoke$5(context, node, target, args, isDynamic); | |
6706 } | |
6707 var returnValue = null; | |
6708 if (targets.get$length() < (1000)) { | |
6709 for (var $$i = targets.iterator$0(); $$i.hasNext$0(); ) { | |
6710 var member = $$i.next$0(); | |
6711 var res = member.invoke$4$isDynamic(context, node, target, args, true); | |
6712 returnValue = this._tryUnion(returnValue, res, node); | |
6713 } | |
6714 if (returnValue == null) { | |
6715 return this._makeError(node, target, "method"); | |
6716 } | |
6717 } | |
6718 else { | |
6719 returnValue = new Value($globals.world.varType, null, node.span); | |
6720 } | |
6721 if (returnValue.get$code() == null) { | |
6722 if (this.name == ":call") { | 6409 if (this.name == ":call") { |
6723 return target._varCall(context, node, args); | 6410 return target._varCall(context, node, args); |
6724 } | 6411 } |
6725 else if (this.get$isOperator()) { | 6412 else if (this.get$isOperator()) { |
6726 return this.invokeSpecial(target, args, returnValue.get$type()); | 6413 return this.invokeSpecial(target, args, invokeKey.get$returnType()); |
6727 } | 6414 } |
6728 else { | 6415 else { |
6729 return this.invokeOnVar(context, node, target, args); | 6416 return this.invokeOnVar(context, node, target, args); |
6730 } | 6417 } |
6731 } | 6418 } |
6732 return returnValue; | 6419 else { |
| 6420 var code = ("" + target.get$code() + "." + this.jsname + "(" + args.getCode(
) + ")"); |
| 6421 return new Value(invokeKey.get$returnType(), code, node.span); |
| 6422 } |
6733 } | 6423 } |
6734 MemberSet.prototype.invokeSpecial = function(target, args, returnType) { | 6424 MemberSet.prototype.invokeSpecial = function(target, args, returnType) { |
6735 var argsString = args.getCode(); | 6425 var argsString = args.getCode(); |
6736 if (this.name == ":index" || this.name == ":setindex") { | 6426 if (this.name == ":index" || this.name == ":setindex") { |
6737 if (this.name == ":index") { | 6427 if (this.name == ":index") { |
6738 $globals.world.gen.corejs.useIndex = true; | 6428 $globals.world.gen.corejs.useIndex = true; |
6739 } | 6429 } |
6740 else if (this.name == ":setindex") { | 6430 else if (this.name == ":setindex") { |
6741 $globals.world.gen.corejs.useSetIndex = true; | 6431 $globals.world.gen.corejs.useSetIndex = true; |
6742 } | 6432 } |
6743 return new Value(returnType, ("" + target.get$code() + "." + this.jsname + "
(" + argsString + ")"), target.span); | 6433 return new Value(returnType, ("" + target.get$code() + "." + this.jsname + "
(" + argsString + ")"), target.span); |
6744 } | 6434 } |
6745 else { | 6435 else { |
6746 if (argsString.get$length() > (0)) argsString = (", " + argsString); | 6436 if (argsString.get$length() > (0)) argsString = (", " + argsString); |
6747 $globals.world.gen.corejs.useOperator(this.name); | 6437 $globals.world.gen.corejs.useOperator(this.name); |
6748 return new Value(returnType, ("" + this.jsname + "(" + target.get$code() + a
rgsString + ")"), target.span); | 6438 return new Value(returnType, ("" + this.jsname + "(" + target.get$code() + a
rgsString + ")"), target.span); |
6749 } | 6439 } |
6750 } | 6440 } |
6751 MemberSet.prototype.invokeOnVar = function(context, node, target, args) { | 6441 MemberSet.prototype.invokeOnVar = function(context, node, target, args) { |
6752 context.counters.dynamicMethodCalls++; | 6442 var $0; |
| 6443 ($0 = context.get$counters()).dynamicMethodCalls = $0.dynamicMethodCalls + (1)
; |
6753 var member = this.getVarMember(context, node, args); | 6444 var member = this.getVarMember(context, node, args); |
6754 return member.invoke$4(context, node, target, args); | 6445 return member.invoke(context, node, target, args); |
6755 } | |
6756 MemberSet.prototype._tryUnion = function(x, y, node) { | |
6757 if (x == null) return y; | |
6758 var type = Type.union(x.get$type(), y.get$type()); | |
6759 if (x.get$code() == y.get$code()) { | |
6760 if ($eq(type, x.get$type())) { | |
6761 return x; | |
6762 } | |
6763 else if (x.get$isConst() || y.get$isConst()) { | |
6764 $globals.world.internalError("unexpected: union of const values "); | |
6765 } | |
6766 else { | |
6767 return Value.union(x, y); | |
6768 } | |
6769 } | |
6770 else { | |
6771 return new Value(type, null, node.span); | |
6772 } | |
6773 } | 6446 } |
6774 MemberSet.prototype.getVarMember = function(context, node, args) { | 6447 MemberSet.prototype.getVarMember = function(context, node, args) { |
6775 if ($globals.world.objectType.varStubs == null) { | 6448 if ($globals.world.objectType.varStubs == null) { |
6776 $globals.world.objectType.varStubs = new HashMapImplementation(); | 6449 $globals.world.objectType.varStubs = new HashMapImplementation(); |
6777 } | 6450 } |
6778 var stubName = _getCallStubName(this.name, args); | 6451 var stubName = _getCallStubName(this.name, args); |
6779 var stub = $globals.world.objectType.varStubs.$index(stubName); | 6452 var stub = $globals.world.objectType.varStubs.$index(stubName); |
6780 if (stub == null) { | 6453 if ($eq(stub)) { |
6781 var mset = context.findMembers(this.name).members; | 6454 var mset = context.findMembers(this.name).members; |
6782 var targets = mset.filter$1((function (m) { | 6455 var targets = mset.filter((function (m) { |
6783 return m.canInvoke$2(context, args); | 6456 return m.canInvoke(context, args); |
6784 }) | 6457 }) |
6785 ); | 6458 ); |
6786 stub = new VarMethodSet(this.name, stubName, targets, args, this._foldTypes(
targets)); | 6459 stub = new VarMethodSet(this.name, stubName, targets, args, this._foldTypes(
targets)); |
6787 $globals.world.objectType.varStubs.$setindex(stubName, stub); | 6460 $globals.world.objectType.varStubs.$setindex(stubName, stub); |
6788 } | 6461 } |
6789 return stub; | 6462 return stub; |
6790 } | 6463 } |
6791 MemberSet.prototype._foldTypes = function(targets) { | 6464 MemberSet.prototype._foldTypes = function(targets) { |
6792 return reduce(map(targets, (function (t) { | 6465 return reduce(map(targets, (function (t) { |
6793 return t.get$returnType(); | 6466 return t.get$returnType(); |
6794 }) | 6467 }) |
6795 ), Type.union, $globals.world.varType); | 6468 ), Type.union, $globals.world.varType); |
6796 } | 6469 } |
6797 MemberSet.prototype._get$3 = function($0, $1, $2) { | |
6798 return this._get($0, $1, $2, false); | |
6799 }; | |
6800 MemberSet.prototype._get$3$isDynamic = MemberSet.prototype._get; | |
6801 MemberSet.prototype._get$4 = MemberSet.prototype._get; | |
6802 MemberSet.prototype._set$4$isDynamic = MemberSet.prototype._set; | |
6803 MemberSet.prototype._set$5 = MemberSet.prototype._set; | |
6804 MemberSet.prototype.add$1 = MemberSet.prototype.add; | |
6805 MemberSet.prototype.canInvoke$2 = MemberSet.prototype.canInvoke; | |
6806 MemberSet.prototype.invoke$4 = function($0, $1, $2, $3) { | |
6807 return this.invoke($0, $1, $2, $3, false); | |
6808 }; | |
6809 MemberSet.prototype.invoke$4$isDynamic = MemberSet.prototype.invoke; | |
6810 MemberSet.prototype.invoke$5 = MemberSet.prototype.invoke; | |
6811 MemberSet.prototype.toString$0 = MemberSet.prototype.toString; | 6470 MemberSet.prototype.toString$0 = MemberSet.prototype.toString; |
6812 // ********** Code for FactoryMap ************** | 6471 // ********** Code for InvokeKey ************** |
6813 function FactoryMap() { | 6472 function InvokeKey(args) { |
6814 this.factories = new HashMapImplementation(); | 6473 this.needsVarCall = false; |
| 6474 this.bareArgs = args.get$bareCount(); |
| 6475 if (this.bareArgs != args.get$length()) { |
| 6476 this.namedArgs = args.getNames(); |
| 6477 } |
6815 } | 6478 } |
6816 FactoryMap.prototype.getFactoriesFor = function(typeName) { | 6479 InvokeKey.prototype.get$returnType = function() { return this.returnType; }; |
6817 var ret = this.factories.$index(typeName); | 6480 InvokeKey.prototype.set$returnType = function(value) { return this.returnType =
value; }; |
6818 if (ret == null) { | 6481 InvokeKey.prototype.get$needsVarCall = function() { return this.needsVarCall; }; |
6819 ret = new HashMapImplementation(); | 6482 InvokeKey.prototype.set$needsVarCall = function(value) { return this.needsVarCal
l = value; }; |
6820 this.factories.$setindex(typeName, ret); | 6483 InvokeKey.prototype.matches = function(args) { |
| 6484 if (this.namedArgs == null) { |
| 6485 if (this.bareArgs != args.get$length()) return false; |
6821 } | 6486 } |
6822 return ret; | 6487 else { |
| 6488 if (this.bareArgs + this.namedArgs.get$length() != args.get$length()) return
false; |
| 6489 } |
| 6490 if (this.bareArgs != args.get$bareCount()) return false; |
| 6491 if (this.namedArgs == null) return true; |
| 6492 for (var i = (0); |
| 6493 i < this.namedArgs.get$length(); i++) { |
| 6494 if (this.namedArgs[i] != args.getName(this.bareArgs + i)) return false; |
| 6495 } |
| 6496 return true; |
6823 } | 6497 } |
6824 FactoryMap.prototype.addFactory = function(typeName, name, member) { | 6498 InvokeKey.prototype.addMembers = function(members, context, target, args) { |
6825 this.getFactoriesFor(typeName).$setindex(name, member); | 6499 for (var $$i = members.iterator(); $$i.hasNext(); ) { |
| 6500 var member = $$i.next(); |
| 6501 if (!(member.get$parameters().get$length() == this.bareArgs && this.namedArg
s == null)) { |
| 6502 this.needsVarCall = true; |
| 6503 } |
| 6504 if (member.canInvoke(context, args)) { |
| 6505 if (member.get$isMethod()) { |
| 6506 this.returnType = MemberSet.unionTypes(this.returnType, member.get$retur
nType()); |
| 6507 member.get$declaringType().genMethod(member); |
| 6508 } |
| 6509 else { |
| 6510 this.needsVarCall = true; |
| 6511 this.returnType = $globals.world.varType; |
| 6512 } |
| 6513 } |
| 6514 } |
| 6515 if (this.returnType == null) { |
| 6516 this.returnType = $globals.world.varType; |
| 6517 } |
6826 } | 6518 } |
6827 FactoryMap.prototype.getFactory = function(typeName, name) { | 6519 // ********** Code for MethodCallData ************** |
6828 return this.getFactoriesFor(typeName).$index(name); | 6520 function MethodCallData(data, method) { |
| 6521 this.method = method; |
| 6522 this.data = data; |
6829 } | 6523 } |
6830 FactoryMap.prototype.forEach = function(f) { | 6524 MethodCallData.prototype.get$method = function() { return this.method; }; |
6831 this.factories.forEach((function (_, constructors) { | 6525 MethodCallData.prototype.set$method = function(value) { return this.method = val
ue; }; |
6832 constructors.forEach((function (_, member) { | 6526 MethodCallData.prototype.get$_methodGenerator = function() { return this._method
Generator; }; |
6833 f.call$1(member); | 6527 MethodCallData.prototype.set$_methodGenerator = function(value) { return this._m
ethodGenerator = value; }; |
6834 }) | 6528 MethodCallData.prototype.matches = function(other) { |
6835 ); | 6529 return $eq(this.method, other.method); |
6836 }) | |
6837 ); | |
6838 } | 6530 } |
6839 FactoryMap.prototype.forEach$1 = function($0) { | 6531 MethodCallData.prototype.run = function() { |
6840 return this.forEach(to$call$1($0)); | 6532 if (this._methodGenerator != null) return; |
6841 }; | 6533 this._methodGenerator = new MethodGenerator(this.method, this.data.context); |
6842 FactoryMap.prototype.getFactory$2 = FactoryMap.prototype.getFactory; | 6534 this._methodGenerator.run(); |
| 6535 } |
| 6536 MethodCallData.prototype.run$0 = MethodCallData.prototype.run; |
| 6537 // ********** Code for MethodData ************** |
| 6538 function MethodData(baseMethod, context) { |
| 6539 this.needsTypeParams = false; |
| 6540 this._calls = []; |
| 6541 this.baseMethod = baseMethod; |
| 6542 this.context = context; |
| 6543 this.body = this.baseMethod.definition.body; |
| 6544 if (this.baseMethod.get$isConstructor()) { |
| 6545 this.needsTypeParams = true; |
| 6546 } |
| 6547 } |
| 6548 MethodData.prototype.get$body = function() { return this.body; }; |
| 6549 MethodData.prototype.set$body = function(value) { return this.body = value; }; |
| 6550 MethodData.prototype.analyze = function() { |
| 6551 if (this.body == null) return; |
| 6552 var ma = new MethodAnalyzer(this.baseMethod, this.body); |
| 6553 ma.analyze$1(this.context); |
| 6554 } |
| 6555 MethodData.prototype.eval = function(method, newObject, args) { |
| 6556 if (method != this.baseMethod) { |
| 6557 if (!this.needsTypeParams) method = this.baseMethod; |
| 6558 } |
| 6559 var gen = new MethodGenerator(method, this.context); |
| 6560 return gen.evalBody(newObject, args); |
| 6561 } |
| 6562 MethodData.prototype.invokeCall = function(callData) { |
| 6563 var $$list = this._calls; |
| 6564 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 6565 var cd = $$i.next(); |
| 6566 if (cd.matches(callData)) { |
| 6567 return cd.run$0(); |
| 6568 } |
| 6569 } |
| 6570 this._calls.add(callData); |
| 6571 callData.run(); |
| 6572 } |
| 6573 MethodData.prototype.run = function(method) { |
| 6574 if (this.body == null && !method.get$isConstructor() && !method.get$isNative()
) return; |
| 6575 if (method != this.baseMethod) { |
| 6576 if (!this.needsTypeParams) method = this.baseMethod; |
| 6577 } |
| 6578 var callData = new MethodCallData(this, method); |
| 6579 method.declaringType.get$genericType().markUsed(); |
| 6580 this.invokeCall(callData); |
| 6581 } |
| 6582 MethodData.prototype.writeDefinition = function(method, writer) { |
| 6583 var gen = null; |
| 6584 var $$list = this._calls; |
| 6585 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
| 6586 var cd = $$i.next(); |
| 6587 if ($eq(cd.get$method(), method)) { |
| 6588 gen = cd.get$_methodGenerator(); |
| 6589 } |
| 6590 } |
| 6591 if ($ne(gen)) { |
| 6592 if (method.definition.nativeBody != null && $eq(method, this.baseMethod)) { |
| 6593 if (method.definition.nativeBody == "") return true; |
| 6594 gen.set$writer(new CodeWriter()); |
| 6595 gen.get$writer().write(method.definition.nativeBody); |
| 6596 gen.set$_paramCode(map(method.parameters, (function (p) { |
| 6597 return p.get$name(); |
| 6598 }) |
| 6599 )); |
| 6600 } |
| 6601 gen.writeDefinition(writer); |
| 6602 return true; |
| 6603 } |
| 6604 else { |
| 6605 return false; |
| 6606 } |
| 6607 } |
| 6608 MethodData.prototype.createFunction = function(writer) { |
| 6609 this.run(this.baseMethod); |
| 6610 this.writeDefinition(this.baseMethod, writer); |
| 6611 } |
| 6612 MethodData.prototype.createLambda = function(node, context) { |
| 6613 var lambdaGen = new MethodGenerator(this.baseMethod, context); |
| 6614 if (this.baseMethod.name != "") { |
| 6615 lambdaGen.get$_scope().create$3$isFinal(this.baseMethod.name, this.baseMetho
d.get$functionType(), this.baseMethod.definition.span, true); |
| 6616 lambdaGen._pushBlock$1(this.baseMethod.definition); |
| 6617 } |
| 6618 this._calls.add(new MethodCallData(this, this.baseMethod)); |
| 6619 lambdaGen.run(); |
| 6620 if (this.baseMethod.name != "") { |
| 6621 lambdaGen._popBlock(this.baseMethod.definition); |
| 6622 } |
| 6623 var writer = new CodeWriter(); |
| 6624 lambdaGen.writeDefinition(writer, node); |
| 6625 return new Value(this.baseMethod.get$functionType(), writer.get$text(), this.b
aseMethod.definition.span); |
| 6626 } |
6843 // ********** Code for Token ************** | 6627 // ********** Code for Token ************** |
6844 function Token(kind, source, start, end) { | 6628 function Token(kind, source, start, end) { |
6845 this.end = end; | 6629 this.end = end; |
6846 this.kind = kind; | 6630 this.kind = kind; |
6847 this.start = start; | 6631 this.start = start; |
6848 this.source = source; | 6632 this.source = source; |
6849 } | 6633 } |
6850 Token.prototype.get$kind = function() { return this.kind; }; | 6634 Token.prototype.get$kind = function() { return this.kind; }; |
6851 Token.prototype.get$end = function() { return this.end; }; | |
6852 Token.prototype.get$start = function() { return this.start; }; | 6635 Token.prototype.get$start = function() { return this.start; }; |
6853 Token.prototype.get$text = function() { | 6636 Token.prototype.get$text = function() { |
6854 return this.source.get$text().substring(this.start, this.end); | 6637 return this.source.get$text().substring(this.start, this.end); |
6855 } | 6638 } |
6856 Token.prototype.toString = function() { | 6639 Token.prototype.toString = function() { |
6857 var kindText = TokenKind.kindToString(this.kind); | 6640 var kindText = TokenKind.kindToString(this.kind); |
6858 var actualText = this.get$text(); | 6641 var actualText = this.get$text(); |
6859 if ($ne(kindText, actualText)) { | 6642 if ($ne(kindText, actualText)) { |
6860 if (actualText.get$length() > (10)) { | 6643 if (actualText.get$length() > (10)) { |
6861 actualText = $add(actualText.substring$2((0), (8)), "..."); | 6644 actualText = $add(actualText.substring((0), (8)), "..."); |
6862 } | 6645 } |
6863 return ("" + kindText + "(" + actualText + ")"); | 6646 return ("" + kindText + "(" + actualText + ")"); |
6864 } | 6647 } |
6865 else { | 6648 else { |
6866 return kindText; | 6649 return kindText; |
6867 } | 6650 } |
6868 } | 6651 } |
6869 Token.prototype.get$span = function() { | 6652 Token.prototype.get$span = function() { |
6870 return new SourceSpan(this.source, this.start, this.end); | 6653 return new SourceSpan(this.source, this.start, this.end); |
6871 } | 6654 } |
6872 Token.prototype.end$0 = function() { | |
6873 return this.end.call$0(); | |
6874 }; | |
6875 Token.prototype.start$0 = function() { | |
6876 return this.start.call$0(); | |
6877 }; | |
6878 Token.prototype.toString$0 = Token.prototype.toString; | 6655 Token.prototype.toString$0 = Token.prototype.toString; |
6879 // ********** Code for LiteralToken ************** | 6656 // ********** Code for LiteralToken ************** |
6880 $inherits(LiteralToken, Token); | 6657 $inherits(LiteralToken, Token); |
6881 function LiteralToken(kind, source, start, end, value) { | 6658 function LiteralToken(kind, source, start, end, value) { |
6882 this.value = value; | 6659 this.value = value; |
6883 Token.call(this, kind, source, start, end); | 6660 Token.call(this, kind, source, start, end); |
6884 } | 6661 } |
6885 LiteralToken.prototype.get$value = function() { return this.value; }; | 6662 LiteralToken.prototype.get$value = function() { return this.value; }; |
6886 LiteralToken.prototype.set$value = function(value) { return this.value = value;
}; | 6663 LiteralToken.prototype.set$value = function(value) { return this.value = value;
}; |
6887 // ********** Code for ErrorToken ************** | 6664 // ********** Code for ErrorToken ************** |
6888 $inherits(ErrorToken, Token); | 6665 $inherits(ErrorToken, Token); |
6889 function ErrorToken(kind, source, start, end, message) { | 6666 function ErrorToken(kind, source, start, end, message) { |
6890 this.message = message; | 6667 this.message = message; |
6891 Token.call(this, kind, source, start, end); | 6668 Token.call(this, kind, source, start, end); |
6892 } | 6669 } |
6893 ErrorToken.prototype.get$message = function() { return this.message; }; | 6670 ErrorToken.prototype.get$message = function() { return this.message; }; |
6894 ErrorToken.prototype.set$message = function(value) { return this.message = value
; }; | 6671 ErrorToken.prototype.set$message = function(value) { return this.message = value
; }; |
6895 // ********** Code for SourceFile ************** | 6672 // ********** Code for SourceFile ************** |
6896 function SourceFile(filename, _text) { | 6673 function SourceFile(filename, _text) { |
6897 this._text = _text; | 6674 this._text = _text; |
6898 this.filename = filename; | 6675 this.filename = filename; |
6899 } | 6676 } |
6900 SourceFile.prototype.get$filename = function() { return this.filename; }; | 6677 SourceFile.prototype.get$filename = function() { return this.filename; }; |
6901 SourceFile.prototype.get$orderInLibrary = function() { return this.orderInLibrar
y; }; | |
6902 SourceFile.prototype.set$orderInLibrary = function(value) { return this.orderInL
ibrary = value; }; | |
6903 SourceFile.prototype.get$text = function() { | 6678 SourceFile.prototype.get$text = function() { |
6904 return this._text; | 6679 return this._text; |
6905 } | 6680 } |
6906 SourceFile.prototype.get$lineStarts = function() { | 6681 SourceFile.prototype.get$lineStarts = function() { |
6907 if (this._lineStarts == null) { | 6682 if (this._lineStarts == null) { |
6908 var starts = [(0)]; | 6683 var starts = [(0)]; |
6909 var index = (0); | 6684 var index = (0); |
6910 while (index < this.get$text().length) { | 6685 while ($lt(index, this.get$text().length)) { |
6911 index = this.get$text().indexOf("\n", index) + (1); | 6686 index = this.get$text().indexOf("\n", index) + (1); |
6912 if (index <= (0)) break; | 6687 if ($lte(index, (0))) break; |
6913 starts.add$1(index); | 6688 starts.add(index); |
6914 } | 6689 } |
6915 starts.add$1(this.get$text().length + (1)); | 6690 starts.add(this.get$text().length + (1)); |
6916 this._lineStarts = starts; | 6691 this._lineStarts = starts; |
6917 } | 6692 } |
6918 return this._lineStarts; | 6693 return this._lineStarts; |
6919 } | 6694 } |
6920 SourceFile.prototype.getLine = function(position) { | 6695 SourceFile.prototype.getLine = function(position) { |
6921 var starts = this.get$lineStarts(); | 6696 var starts = this.get$lineStarts(); |
6922 for (var i = (0); | 6697 for (var i = (0); |
6923 i < starts.get$length(); i++) { | 6698 i < starts.get$length(); i++) { |
6924 if (starts.$index(i) > position) return i - (1); | 6699 if ($gt(starts.$index(i), position)) return i - (1); |
6925 } | 6700 } |
6926 $globals.world.internalError("bad position"); | 6701 $globals.world.internalError("bad position"); |
6927 } | 6702 } |
6928 SourceFile.prototype.getColumn = function(line, position) { | 6703 SourceFile.prototype.getColumn = function(line, position) { |
6929 return position - this.get$lineStarts()[line]; | 6704 return position - this.get$lineStarts()[line]; |
6930 } | 6705 } |
6931 SourceFile.prototype.getLocationMessage = function(message, start, end, includeT
ext) { | 6706 SourceFile.prototype.getLocationMessage = function(message, start, end, includeT
ext) { |
6932 var line = this.getLine(start); | 6707 var line = this.getLine(start); |
6933 var column = this.getColumn(line, start); | 6708 var column = this.getColumn(line, start); |
6934 var buf = new StringBufferImpl(("" + this.filename + ":" + ($add(line, (1))) +
":" + ($add(column, (1))) + ": " + message)); | 6709 var buf = new StringBufferImpl(("" + this.filename + ":" + ($add(line, (1))) +
":" + ($add(column, (1))) + ": " + message)); |
6935 if (includeText) { | 6710 if (includeText) { |
6936 buf.add$1("\n"); | 6711 buf.add("\n"); |
6937 var textLine; | 6712 var textLine; |
6938 if (($add(line, (2))) < this._lineStarts.get$length()) { | 6713 if ($lt(($add(line, (2))), this._lineStarts.get$length())) { |
6939 textLine = this.get$text().substring(this._lineStarts[line], this._lineSta
rts[$add(line, (1))]); | 6714 textLine = this.get$text().substring(this._lineStarts.$index(line), this._
lineStarts.$index($add(line, (1)))); |
6940 } | 6715 } |
6941 else { | 6716 else { |
6942 textLine = this.get$text().substring(this._lineStarts[line]) + "\n"; | 6717 textLine = $add(this.get$text().substring(this._lineStarts.$index(line)),
"\n"); |
6943 } | 6718 } |
6944 var toColumn = Math.min($add(column, (end - start)), textLine.get$length()); | 6719 var toColumn = Math.min($add(column, (end - start)), textLine.get$length()); |
6945 if ($globals.options.useColors) { | 6720 if ($globals.options.useColors) { |
6946 buf.add$1(textLine.substring$2((0), column)); | 6721 buf.add(textLine.substring((0), column)); |
6947 buf.add$1($globals._RED_COLOR); | 6722 buf.add($globals._RED_COLOR); |
6948 buf.add$1(textLine.substring$2(column, toColumn)); | 6723 buf.add(textLine.substring(column, toColumn)); |
6949 buf.add$1($globals._NO_COLOR); | 6724 buf.add($globals._NO_COLOR); |
6950 buf.add$1(textLine.substring$1(toColumn)); | 6725 buf.add(textLine.substring$1(toColumn)); |
6951 } | 6726 } |
6952 else { | 6727 else { |
6953 buf.add$1(textLine); | 6728 buf.add(textLine); |
6954 } | 6729 } |
6955 var i = (0); | 6730 var i = (0); |
6956 for (; i < column; i++) { | 6731 for (; $lt(i, column); i++) { |
6957 buf.add$1(" "); | 6732 buf.add(" "); |
6958 } | 6733 } |
6959 if ($globals.options.useColors) buf.add$1($globals._RED_COLOR); | 6734 if ($globals.options.useColors) buf.add($globals._RED_COLOR); |
6960 for (; i < toColumn; i++) { | 6735 for (; i < toColumn; i++) { |
6961 buf.add$1("^"); | 6736 buf.add("^"); |
6962 } | 6737 } |
6963 if ($globals.options.useColors) buf.add$1($globals._NO_COLOR); | 6738 if ($globals.options.useColors) buf.add($globals._NO_COLOR); |
6964 } | 6739 } |
6965 return buf.toString$0(); | 6740 return buf.toString$0(); |
6966 } | 6741 } |
6967 SourceFile.prototype.compareTo = function(other) { | 6742 SourceFile.prototype.compareTo = function(other) { |
6968 if (this.orderInLibrary != null && other.orderInLibrary != null) { | 6743 if (this.orderInLibrary != null && other.orderInLibrary != null) { |
6969 return this.orderInLibrary - other.orderInLibrary; | 6744 return this.orderInLibrary - other.orderInLibrary; |
6970 } | 6745 } |
6971 else { | 6746 else { |
6972 return this.filename.compareTo(other.filename); | 6747 return this.filename.compareTo(other.filename); |
6973 } | 6748 } |
6974 } | 6749 } |
6975 SourceFile.prototype.compareTo$1 = SourceFile.prototype.compareTo; | |
6976 SourceFile.prototype.getColumn$2 = SourceFile.prototype.getColumn; | |
6977 SourceFile.prototype.getLine$1 = SourceFile.prototype.getLine; | |
6978 // ********** Code for SourceSpan ************** | 6750 // ********** Code for SourceSpan ************** |
6979 function SourceSpan(file, start, end) { | 6751 function SourceSpan(file, start, end) { |
6980 this.file = file; | 6752 this.file = file; |
6981 this.start = start; | 6753 this.start = start; |
6982 this.end = end; | 6754 this.end = end; |
6983 } | 6755 } |
6984 SourceSpan.prototype.get$file = function() { return this.file; }; | 6756 SourceSpan.prototype.get$file = function() { return this.file; }; |
6985 SourceSpan.prototype.get$start = function() { return this.start; }; | 6757 SourceSpan.prototype.get$start = function() { return this.start; }; |
6986 SourceSpan.prototype.get$end = function() { return this.end; }; | |
6987 SourceSpan.prototype.get$text = function() { | 6758 SourceSpan.prototype.get$text = function() { |
6988 return this.file.get$text().substring(this.start, this.end); | 6759 return this.file.get$text().substring(this.start, this.end); |
6989 } | 6760 } |
6990 SourceSpan.prototype.toMessageString = function(message) { | 6761 SourceSpan.prototype.toMessageString = function(message) { |
6991 return this.file.getLocationMessage(message, this.start, this.end, true); | 6762 return this.file.getLocationMessage(message, this.start, this.end, true); |
6992 } | 6763 } |
6993 SourceSpan.prototype.get$locationText = function() { | 6764 SourceSpan.prototype.get$locationText = function() { |
6994 var line = this.file.getLine(this.start); | 6765 var line = this.file.getLine(this.start); |
6995 var column = this.file.getColumn(line, this.start); | 6766 var column = this.file.getColumn(line, this.start); |
6996 return ("" + this.file.filename + ":" + ($add(line, (1))) + ":" + ($add(column
, (1)))); | 6767 return ("" + this.file.filename + ":" + ($add(line, (1))) + ":" + ($add(column
, (1)))); |
6997 } | 6768 } |
6998 SourceSpan.prototype.compareTo = function(other) { | 6769 SourceSpan.prototype.compareTo = function(other) { |
6999 if ($eq(this.file, other.file)) { | 6770 if ($eq(this.file, other.file)) { |
7000 var d = this.start - other.start; | 6771 var d = this.start - other.start; |
7001 return d == (0) ? (this.end - other.end) : d; | 6772 return d == (0) ? (this.end - other.end) : d; |
7002 } | 6773 } |
7003 return this.file.compareTo(other.file); | 6774 return this.file.compareTo(other.file); |
7004 } | 6775 } |
7005 SourceSpan.prototype.compareTo$1 = SourceSpan.prototype.compareTo; | |
7006 SourceSpan.prototype.end$0 = function() { | |
7007 return this.end.call$0(); | |
7008 }; | |
7009 SourceSpan.prototype.start$0 = function() { | |
7010 return this.start.call$0(); | |
7011 }; | |
7012 // ********** Code for InterpStack ************** | 6776 // ********** Code for InterpStack ************** |
7013 function InterpStack(previous, quote, isMultiline) { | 6777 function InterpStack(previous, quote, isMultiline) { |
7014 this.quote = quote; | 6778 this.quote = quote; |
7015 this.isMultiline = isMultiline; | 6779 this.isMultiline = isMultiline; |
7016 this.depth = (-1); | 6780 this.depth = (-1); |
7017 this.previous = previous; | 6781 this.previous = previous; |
7018 } | 6782 } |
7019 InterpStack.prototype.get$previous = function() { return this.previous; }; | 6783 InterpStack.prototype.get$previous = function() { return this.previous; }; |
7020 InterpStack.prototype.set$previous = function(value) { return this.previous = va
lue; }; | 6784 InterpStack.prototype.set$previous = function(value) { return this.previous = va
lue; }; |
7021 InterpStack.prototype.get$quote = function() { return this.quote; }; | 6785 InterpStack.prototype.get$quote = function() { return this.quote; }; |
7022 InterpStack.prototype.get$isMultiline = function() { return this.isMultiline; }; | 6786 InterpStack.prototype.get$isMultiline = function() { return this.isMultiline; }; |
7023 InterpStack.prototype.get$depth = function() { return this.depth; }; | 6787 InterpStack.prototype.get$depth = function() { return this.depth; }; |
7024 InterpStack.prototype.set$depth = function(value) { return this.depth = value; }
; | 6788 InterpStack.prototype.set$depth = function(value) { return this.depth = value; }
; |
7025 InterpStack.prototype.pop = function() { | 6789 InterpStack.prototype.pop = function() { |
7026 return this.previous; | 6790 return this.previous; |
7027 } | 6791 } |
7028 InterpStack.push = function(stack, quote, isMultiline) { | 6792 InterpStack.push = function(stack, quote, isMultiline) { |
7029 var newStack = new InterpStack(stack, quote, isMultiline); | 6793 var newStack = new InterpStack(stack, quote, isMultiline); |
7030 if (stack != null) newStack.set$previous(stack); | 6794 if (stack != null) newStack.set$previous(stack); |
7031 return newStack; | 6795 return newStack; |
7032 } | 6796 } |
7033 InterpStack.prototype.next$0 = function() { | |
7034 return this.next.call$0(); | |
7035 }; | |
7036 // ********** Code for TokenizerHelpers ************** | 6797 // ********** Code for TokenizerHelpers ************** |
7037 function TokenizerHelpers() { | 6798 function TokenizerHelpers() { |
7038 | 6799 |
7039 } | 6800 } |
7040 TokenizerHelpers.isIdentifierStart = function(c) { | 6801 TokenizerHelpers.isIdentifierStart = function(c) { |
7041 return ((c >= (97) && c <= (122)) || (c >= (65) && c <= (90)) || c == (95)); | 6802 return ((c >= (97) && c <= (122)) || (c >= (65) && c <= (90)) || c == (95)); |
7042 } | 6803 } |
7043 TokenizerHelpers.isDigit = function(c) { | 6804 TokenizerHelpers.isDigit = function(c) { |
7044 return (c >= (48) && c <= (57)); | 6805 return (c >= (48) && c <= (57)); |
7045 } | 6806 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7202 var digit = TokenizerBase._hexDigit(this._text.charCodeAt(this._lang_index))
; | 6963 var digit = TokenizerBase._hexDigit(this._text.charCodeAt(this._lang_index))
; |
7203 if ($eq(digit, (-1))) { | 6964 if ($eq(digit, (-1))) { |
7204 if (hexLength == null) { | 6965 if (hexLength == null) { |
7205 return result; | 6966 return result; |
7206 } | 6967 } |
7207 else { | 6968 else { |
7208 return (-1); | 6969 return (-1); |
7209 } | 6970 } |
7210 } | 6971 } |
7211 TokenizerBase._hexDigit(this._text.charCodeAt(this._lang_index)); | 6972 TokenizerBase._hexDigit(this._text.charCodeAt(this._lang_index)); |
7212 result = (result * (16)) + digit; | 6973 result = $add(($mul(result, (16))), digit); |
7213 this._lang_index++; | 6974 this._lang_index++; |
7214 } | 6975 } |
7215 return result; | 6976 return result; |
7216 } | 6977 } |
7217 TokenizerBase.prototype.finishHex = function() { | 6978 TokenizerBase.prototype.finishHex = function() { |
7218 var value = this.readHex(); | 6979 var value = this.readHex(); |
7219 return new LiteralToken((61), this._source, this._startIndex, this._lang_index
, value); | 6980 return new LiteralToken((61), this._source, this._startIndex, this._lang_index
, value); |
7220 } | 6981 } |
7221 TokenizerBase.prototype.finishNumber = function() { | 6982 TokenizerBase.prototype.finishNumber = function() { |
7222 this.eatDigits(); | 6983 this.eatDigits(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7267 while (true) { | 7028 while (true) { |
7268 var ch = this._nextChar(); | 7029 var ch = this._nextChar(); |
7269 if (ch == (0)) { | 7030 if (ch == (0)) { |
7270 return this._errorToken(); | 7031 return this._errorToken(); |
7271 } | 7032 } |
7272 else if (ch == quote) { | 7033 else if (ch == quote) { |
7273 if (this._maybeEatChar(quote)) { | 7034 if (this._maybeEatChar(quote)) { |
7274 if (this._maybeEatChar(quote)) { | 7035 if (this._maybeEatChar(quote)) { |
7275 return this._makeStringToken(buf, false); | 7036 return this._makeStringToken(buf, false); |
7276 } | 7037 } |
7277 buf.add$1(quote); | 7038 buf.add(quote); |
7278 } | 7039 } |
7279 buf.add$1(quote); | 7040 buf.add(quote); |
7280 } | 7041 } |
7281 else if (ch == (36)) { | 7042 else if (ch == (36)) { |
7282 this._interpStack = InterpStack.push(this._interpStack, quote, true); | 7043 this._interpStack = InterpStack.push(this._interpStack, quote, true); |
7283 return this._makeStringToken(buf, true); | 7044 return this._makeStringToken(buf, true); |
7284 } | 7045 } |
7285 else if (ch == (92)) { | 7046 else if (ch == (92)) { |
7286 var escapeVal = this.readEscapeSequence(); | 7047 var escapeVal = this.readEscapeSequence(); |
7287 if ($eq(escapeVal, (-1))) { | 7048 if ($eq(escapeVal, (-1))) { |
7288 return this._errorToken("invalid hex escape sequence"); | 7049 return this._errorToken("invalid hex escape sequence"); |
7289 } | 7050 } |
7290 else { | 7051 else { |
7291 buf.add$1(escapeVal); | 7052 buf.add(escapeVal); |
7292 } | 7053 } |
7293 } | 7054 } |
7294 else { | 7055 else { |
7295 buf.add$1(ch); | 7056 buf.add(ch); |
7296 } | 7057 } |
7297 } | 7058 } |
7298 } | 7059 } |
7299 TokenizerBase.prototype._finishOpenBrace = function() { | 7060 TokenizerBase.prototype._finishOpenBrace = function() { |
7300 var $0; | 7061 var $0; |
7301 if (this._interpStack != null) { | 7062 if (this._interpStack != null) { |
7302 if (this._interpStack.depth == (-1)) { | 7063 if (this._interpStack.depth == (-1)) { |
7303 this._interpStack.depth = (1); | 7064 this._interpStack.depth = (1); |
7304 } | 7065 } |
7305 else { | 7066 else { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7370 } | 7131 } |
7371 else if (ch == (0)) { | 7132 else if (ch == (0)) { |
7372 return this._errorToken(); | 7133 return this._errorToken(); |
7373 } | 7134 } |
7374 else if (ch == (92)) { | 7135 else if (ch == (92)) { |
7375 var escapeVal = this.readEscapeSequence(); | 7136 var escapeVal = this.readEscapeSequence(); |
7376 if ($eq(escapeVal, (-1))) { | 7137 if ($eq(escapeVal, (-1))) { |
7377 return this._errorToken("invalid hex escape sequence"); | 7138 return this._errorToken("invalid hex escape sequence"); |
7378 } | 7139 } |
7379 else { | 7140 else { |
7380 buf.add$1(escapeVal); | 7141 buf.add(escapeVal); |
7381 } | 7142 } |
7382 } | 7143 } |
7383 else { | 7144 else { |
7384 buf.add$1(ch); | 7145 buf.add(ch); |
7385 } | 7146 } |
7386 } | 7147 } |
7387 } | 7148 } |
7388 TokenizerBase.prototype.readEscapeSequence = function() { | 7149 TokenizerBase.prototype.readEscapeSequence = function() { |
7389 var ch = this._nextChar(); | 7150 var ch = this._nextChar(); |
7390 var hexValue; | 7151 var hexValue; |
7391 switch (ch) { | 7152 switch (ch) { |
7392 case (110): | 7153 case (110): |
7393 | 7154 |
7394 return (10); | 7155 return (10); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7482 } | 7243 } |
7483 } | 7244 } |
7484 var kind = this.getIdentifierKind(); | 7245 var kind = this.getIdentifierKind(); |
7485 if (kind == (70)) { | 7246 if (kind == (70)) { |
7486 return this._finishToken((70)); | 7247 return this._finishToken((70)); |
7487 } | 7248 } |
7488 else { | 7249 else { |
7489 return this._finishToken(kind); | 7250 return this._finishToken(kind); |
7490 } | 7251 } |
7491 } | 7252 } |
7492 TokenizerBase.prototype.next$0 = TokenizerBase.prototype.next; | |
7493 // ********** Code for Tokenizer ************** | 7253 // ********** Code for Tokenizer ************** |
7494 $inherits(Tokenizer, TokenizerBase); | 7254 $inherits(Tokenizer, TokenizerBase); |
7495 function Tokenizer(source, skipWhitespace, index) { | 7255 function Tokenizer(source, skipWhitespace, index) { |
7496 TokenizerBase.call(this, source, skipWhitespace, index); | 7256 TokenizerBase.call(this, source, skipWhitespace, index); |
7497 } | 7257 } |
7498 Tokenizer.prototype.next = function() { | 7258 Tokenizer.prototype.next = function() { |
7499 this._startIndex = this._lang_index; | 7259 this._startIndex = this._lang_index; |
7500 if (this._interpStack != null && this._interpStack.depth == (0)) { | 7260 if (this._interpStack != null && this._interpStack.depth == (0)) { |
7501 var istack = this._interpStack; | 7261 var istack = this._interpStack; |
7502 this._interpStack = this._interpStack.pop(); | 7262 this._interpStack = this._interpStack.pop(); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7825 } | 7585 } |
7826 else { | 7586 else { |
7827 return this._errorToken(); | 7587 return this._errorToken(); |
7828 } | 7588 } |
7829 | 7589 |
7830 } | 7590 } |
7831 } | 7591 } |
7832 Tokenizer.prototype.getIdentifierKind = function() { | 7592 Tokenizer.prototype.getIdentifierKind = function() { |
7833 var i0 = this._startIndex; | 7593 var i0 = this._startIndex; |
7834 var ch; | 7594 var ch; |
7835 switch (this._lang_index - i0) { | 7595 switch ($sub(this._lang_index, i0)) { |
7836 case (2): | 7596 case (2): |
7837 | 7597 |
7838 ch = this._text.charCodeAt(i0); | 7598 ch = this._text.charCodeAt(i0); |
7839 if (ch == (100)) { | 7599 if (ch == (100)) { |
7840 if (this._text.charCodeAt($add(i0, (1))) == (111)) return (95); | 7600 if (this._text.charCodeAt($add(i0, (1))) == (111)) return (95); |
7841 } | 7601 } |
7842 else if (ch == (105)) { | 7602 else if (ch == (105)) { |
7843 ch = this._text.charCodeAt($add(i0, (1))); | 7603 ch = this._text.charCodeAt($add(i0, (1))); |
7844 if (ch == (102)) { | 7604 if (ch == (102)) { |
7845 return (102); | 7605 return (102); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8036 | 7796 |
8037 if (this._text.charCodeAt(i0) == (105) && this._text.charCodeAt($add(i0, (
1))) == (109) && this._text.charCodeAt($add(i0, (2))) == (112) && this._text.cha
rCodeAt($add(i0, (3))) == (108) && this._text.charCodeAt($add(i0, (4))) == (101)
&& this._text.charCodeAt($add(i0, (5))) == (109) && this._text.charCodeAt($add(
i0, (6))) == (101) && this._text.charCodeAt($add(i0, (7))) == (110) && this._tex
t.charCodeAt($add(i0, (8))) == (116) && this._text.charCodeAt($add(i0, (9))) ==
(115)) return (76); | 7797 if (this._text.charCodeAt(i0) == (105) && this._text.charCodeAt($add(i0, (
1))) == (109) && this._text.charCodeAt($add(i0, (2))) == (112) && this._text.cha
rCodeAt($add(i0, (3))) == (108) && this._text.charCodeAt($add(i0, (4))) == (101)
&& this._text.charCodeAt($add(i0, (5))) == (109) && this._text.charCodeAt($add(
i0, (6))) == (101) && this._text.charCodeAt($add(i0, (7))) == (110) && this._tex
t.charCodeAt($add(i0, (8))) == (116) && this._text.charCodeAt($add(i0, (9))) ==
(115)) return (76); |
8038 return (70); | 7798 return (70); |
8039 | 7799 |
8040 default: | 7800 default: |
8041 | 7801 |
8042 return (70); | 7802 return (70); |
8043 | 7803 |
8044 } | 7804 } |
8045 } | 7805 } |
8046 Tokenizer.prototype.next$0 = Tokenizer.prototype.next; | |
8047 // ********** Code for TokenKind ************** | 7806 // ********** Code for TokenKind ************** |
8048 function TokenKind() {} | 7807 function TokenKind() {} |
8049 TokenKind.kindToString = function(kind) { | 7808 TokenKind.kindToString = function(kind) { |
8050 switch (kind) { | 7809 switch (kind) { |
8051 case (1): | 7810 case (1): |
8052 | 7811 |
8053 return "end of file"; | 7812 return "end of file"; |
8054 | 7813 |
8055 case (2): | 7814 case (2): |
8056 | 7815 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8507 case (115): | 8266 case (115): |
8508 | 8267 |
8509 return "keyword 'void'"; | 8268 return "keyword 'void'"; |
8510 | 8269 |
8511 case (116): | 8270 case (116): |
8512 | 8271 |
8513 return "keyword 'while'"; | 8272 return "keyword 'while'"; |
8514 | 8273 |
8515 default: | 8274 default: |
8516 | 8275 |
8517 return "TokenKind(" + kind.toString$0() + ")"; | 8276 return $add($add("TokenKind(", kind.toString$0()), ")"); |
8518 | 8277 |
8519 } | 8278 } |
8520 } | 8279 } |
8521 TokenKind.isIdentifier = function(kind) { | 8280 TokenKind.isIdentifier = function(kind) { |
8522 return kind >= (70) && kind < (87); | 8281 return kind >= (70) && kind < (87); |
8523 } | 8282 } |
8524 TokenKind.infixPrecedence = function(kind) { | 8283 TokenKind.infixPrecedence = function(kind) { |
8525 switch (kind) { | 8284 switch (kind) { |
8526 case (20): | 8285 case (20): |
8527 | 8286 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8859 // ********** Code for Parser ************** | 8618 // ********** Code for Parser ************** |
8860 function Parser(source, diet, throwOnIncomplete, optionalSemicolons, startOffset
) { | 8619 function Parser(source, diet, throwOnIncomplete, optionalSemicolons, startOffset
) { |
8861 this.throwOnIncomplete = throwOnIncomplete; | 8620 this.throwOnIncomplete = throwOnIncomplete; |
8862 this.source = source; | 8621 this.source = source; |
8863 this.optionalSemicolons = optionalSemicolons; | 8622 this.optionalSemicolons = optionalSemicolons; |
8864 this._recover = false; | 8623 this._recover = false; |
8865 this._inhibitLambda = false; | 8624 this._inhibitLambda = false; |
8866 this.diet = diet; | 8625 this.diet = diet; |
8867 this._afterParensIndex = (0); | 8626 this._afterParensIndex = (0); |
8868 this.tokenizer = new Tokenizer(this.source, true, startOffset); | 8627 this.tokenizer = new Tokenizer(this.source, true, startOffset); |
8869 this._peekToken = this.tokenizer.next$0(); | 8628 this._peekToken = this.tokenizer.next(); |
8870 this._afterParens = []; | 8629 this._afterParens = []; |
8871 } | 8630 } |
8872 Parser.prototype.get$enableAwait = function() { | 8631 Parser.prototype.get$enableAwait = function() { |
8873 return $globals.experimentalAwaitPhase != null; | 8632 return $globals.experimentalAwaitPhase != null; |
8874 } | 8633 } |
8875 Parser.prototype.isPrematureEndOfFile = function() { | 8634 Parser.prototype.isPrematureEndOfFile = function() { |
8876 if (this.throwOnIncomplete && this._maybeEat((1))) { | 8635 if (this.throwOnIncomplete && this._maybeEat((1))) { |
8877 $throw(new IncompleteSourceException(this._previousToken)); | 8636 $throw(new IncompleteSourceException(this._previousToken)); |
8878 } | 8637 } |
8879 else if (this._maybeEat((1))) { | 8638 else if (this._maybeEat((1))) { |
(...skipping 13 matching lines...) Expand all Loading... |
8893 } | 8652 } |
8894 this._lang_next(); | 8653 this._lang_next(); |
8895 } | 8654 } |
8896 return false; | 8655 return false; |
8897 } | 8656 } |
8898 Parser.prototype._peek = function() { | 8657 Parser.prototype._peek = function() { |
8899 return this._peekToken.kind; | 8658 return this._peekToken.kind; |
8900 } | 8659 } |
8901 Parser.prototype._lang_next = function() { | 8660 Parser.prototype._lang_next = function() { |
8902 this._previousToken = this._peekToken; | 8661 this._previousToken = this._peekToken; |
8903 this._peekToken = this.tokenizer.next$0(); | 8662 this._peekToken = this.tokenizer.next(); |
8904 return this._previousToken; | 8663 return this._previousToken; |
8905 } | 8664 } |
8906 Parser.prototype._peekKind = function(kind) { | 8665 Parser.prototype._peekKind = function(kind) { |
8907 return this._peekToken.kind == kind; | 8666 return this._peekToken.kind == kind; |
8908 } | 8667 } |
8909 Parser.prototype._peekIdentifier = function() { | 8668 Parser.prototype._peekIdentifier = function() { |
8910 return this._isIdentifier(this._peekToken.kind); | 8669 return this._isIdentifier(this._peekToken.kind); |
8911 } | 8670 } |
8912 Parser.prototype._isIdentifier = function(kind) { | 8671 Parser.prototype._isIdentifier = function(kind) { |
8913 return TokenKind.isIdentifier(kind) || (!this.get$enableAwait() && $eq(kind, (
87))); | 8672 return TokenKind.isIdentifier(kind) || (!this.get$enableAwait() && $eq(kind, (
87))); |
8914 } | 8673 } |
8915 Parser.prototype._maybeEat = function(kind) { | 8674 Parser.prototype._maybeEat = function(kind) { |
8916 if (this._peekToken.kind == kind) { | 8675 if (this._peekToken.kind == kind) { |
8917 this._previousToken = this._peekToken; | 8676 this._previousToken = this._peekToken; |
8918 this._peekToken = this.tokenizer.next$0(); | 8677 this._peekToken = this.tokenizer.next(); |
8919 return true; | 8678 return true; |
8920 } | 8679 } |
8921 else { | 8680 else { |
8922 return false; | 8681 return false; |
8923 } | 8682 } |
8924 } | 8683 } |
8925 Parser.prototype._eat = function(kind) { | 8684 Parser.prototype._eat = function(kind) { |
8926 if (!this._maybeEat(kind)) { | 8685 if (!this._maybeEat(kind)) { |
8927 this._errorExpected(TokenKind.kindToString(kind)); | 8686 this._errorExpected(TokenKind.kindToString(kind)); |
8928 } | 8687 } |
(...skipping 18 matching lines...) Expand all Loading... |
8947 location = this._peekToken.get$span(); | 8706 location = this._peekToken.get$span(); |
8948 } | 8707 } |
8949 $globals.world.fatal(message, location); | 8708 $globals.world.fatal(message, location); |
8950 this._recover = true; | 8709 this._recover = true; |
8951 } | 8710 } |
8952 Parser.prototype._skipBlock = function() { | 8711 Parser.prototype._skipBlock = function() { |
8953 var depth = (1); | 8712 var depth = (1); |
8954 this._eat((6)); | 8713 this._eat((6)); |
8955 while (true) { | 8714 while (true) { |
8956 var tok = this._lang_next(); | 8715 var tok = this._lang_next(); |
8957 if ($eq(tok.get$kind(), (6))) { | 8716 if (tok.get$kind() == (6)) { |
8958 depth += (1); | 8717 depth += (1); |
8959 } | 8718 } |
8960 else if ($eq(tok.get$kind(), (7))) { | 8719 else if (tok.get$kind() == (7)) { |
8961 depth -= (1); | 8720 depth -= (1); |
8962 if (depth == (0)) return; | 8721 if (depth == (0)) return; |
8963 } | 8722 } |
8964 else if ($eq(tok.get$kind(), (1))) { | 8723 else if (tok.get$kind() == (1)) { |
8965 this._lang_error("unexpected end of file during diet parse", tok.get$span(
)); | 8724 this._lang_error("unexpected end of file during diet parse", tok.get$span(
)); |
8966 return; | 8725 return; |
8967 } | 8726 } |
8968 } | 8727 } |
8969 } | 8728 } |
8970 Parser.prototype._makeSpan = function(start) { | 8729 Parser.prototype._makeSpan = function(start) { |
8971 return new SourceSpan(this.source, start, this._previousToken.end); | 8730 return new SourceSpan(this.source, start, this._previousToken.end); |
8972 } | 8731 } |
8973 Parser.prototype.compilationUnit = function() { | 8732 Parser.prototype.compilationUnit = function() { |
8974 var ret = []; | 8733 var ret = []; |
8975 this._maybeEat((13)); | 8734 this._maybeEat((13)); |
8976 while (this._peekKind((12))) { | 8735 while (this._peekKind((12))) { |
8977 ret.add$1(this.directive()); | 8736 ret.add(this.directive()); |
8978 } | 8737 } |
8979 this._recover = false; | 8738 this._recover = false; |
8980 while (!this._maybeEat((1))) { | 8739 while (!this._maybeEat((1))) { |
8981 ret.add$1(this.topLevelDefinition()); | 8740 ret.add(this.topLevelDefinition()); |
8982 } | 8741 } |
8983 this._recover = false; | 8742 this._recover = false; |
8984 return ret; | 8743 return ret; |
8985 } | 8744 } |
8986 Parser.prototype.directive = function() { | 8745 Parser.prototype.directive = function() { |
8987 var start = this._peekToken.start; | 8746 var start = this._peekToken.start; |
8988 this._eat((12)); | 8747 this._eat((12)); |
8989 var name = this.identifier(); | 8748 var name = this.identifier(); |
8990 var args = this.arguments(); | 8749 var args = this.arguments(); |
8991 this._eatSemicolon(); | 8750 this._eatSemicolon(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9023 if (this._maybeEat((97))) { | 8782 if (this._maybeEat((97))) { |
9024 _extends = this.typeList(); | 8783 _extends = this.typeList(); |
9025 } | 8784 } |
9026 var _implements = null; | 8785 var _implements = null; |
9027 if (this._maybeEat((76))) { | 8786 if (this._maybeEat((76))) { |
9028 _implements = this.typeList(); | 8787 _implements = this.typeList(); |
9029 } | 8788 } |
9030 var _native = null; | 8789 var _native = null; |
9031 if (this._maybeEat((80))) { | 8790 if (this._maybeEat((80))) { |
9032 _native = this.maybeStringLiteral(); | 8791 _native = this.maybeStringLiteral(); |
9033 if (_native != null) _native = new NativeType(_native); | 8792 if ($ne(_native)) _native = new NativeType(_native); |
9034 } | 8793 } |
9035 var oldFactory = this._maybeEat((74)); | 8794 var oldFactory = this._maybeEat((74)); |
9036 var defaultType = null; | 8795 var defaultType = null; |
9037 if (oldFactory || this._maybeEat((94))) { | 8796 if (oldFactory || this._maybeEat((94))) { |
9038 if (oldFactory) { | 8797 if (oldFactory) { |
9039 $globals.world.warning("factory no longer supported, use \"default\" inste
ad", this._previousToken.get$span()); | 8798 $globals.world.warning("factory no longer supported, use \"default\" inste
ad", this._previousToken.get$span()); |
9040 } | 8799 } |
9041 var baseType = this.nameTypeReference(); | 8800 var baseType = this.nameTypeReference(); |
9042 var typeParams0 = null; | 8801 var factTypeParams = null; |
9043 if (this._peekKind((52))) { | 8802 if (this._peekKind((52))) { |
9044 typeParams0 = this.typeParameters(); | 8803 factTypeParams = this.typeParameters(); |
9045 } | 8804 } |
9046 defaultType = new DefaultTypeReference(oldFactory, baseType, typeParams0, th
is._makeSpan(baseType.get$span().get$start())); | 8805 defaultType = new DefaultTypeReference(oldFactory, baseType, factTypeParams,
this._makeSpan(baseType.get$span().start)); |
9047 } | 8806 } |
9048 var body = []; | 8807 var body = []; |
9049 if (this._maybeEat((6))) { | 8808 if (this._maybeEat((6))) { |
9050 while (!this._maybeEat((7))) { | 8809 while (!this._maybeEat((7))) { |
9051 body.add$1(this.declaration(true)); | 8810 body.add(this.declaration(true)); |
9052 if (this._recover) { | 8811 if (this._recover) { |
9053 if (!this._recoverTo((7), (10))) break; | 8812 if (!this._recoverTo((7), (10))) break; |
9054 this._maybeEat((10)); | 8813 this._maybeEat((10)); |
9055 } | 8814 } |
9056 } | 8815 } |
9057 } | 8816 } |
9058 else { | 8817 else { |
9059 this._errorExpected("block starting with \"{\" or \";\""); | 8818 this._errorExpected("block starting with \"{\" or \";\""); |
9060 } | 8819 } |
9061 return new TypeDefinition(kind == (91), name, typeParams, _extends, _implement
s, _native, defaultType, body, this._makeSpan(start)); | 8820 return new TypeDefinition(kind == (91), name, typeParams, _extends, _implement
s, _native, defaultType, body, this._makeSpan(start)); |
9062 } | 8821 } |
9063 Parser.prototype.functionTypeAlias = function() { | 8822 Parser.prototype.functionTypeAlias = function() { |
9064 var start = this._peekToken.start; | 8823 var start = this._peekToken.start; |
9065 this._eat((86)); | 8824 this._eat((86)); |
9066 var di = this.declaredIdentifier(false); | 8825 var di = this.declaredIdentifier(false); |
9067 var typeParams = null; | 8826 var typeParams = null; |
9068 if (this._peekKind((52))) { | 8827 if (this._peekKind((52))) { |
9069 typeParams = this.typeParameters(); | 8828 typeParams = this.typeParameters(); |
9070 } | 8829 } |
9071 var formals = this.formalParameterList(); | 8830 var formals = this.formalParameterList(); |
9072 this._eatSemicolon(); | 8831 this._eatSemicolon(); |
9073 var func = new FunctionDefinition(null, di.get$type(), di.get$name(), formals,
null, null, null, this._makeSpan(start)); | 8832 var func = new FunctionDefinition(null, di.get$type(), di.get$name(), formals,
null, null, null, this._makeSpan(start)); |
9074 return new FunctionTypeDefinition(func, typeParams, this._makeSpan(start)); | 8833 return new FunctionTypeDefinition(func, typeParams, this._makeSpan(start)); |
9075 } | 8834 } |
9076 Parser.prototype.initializers = function() { | 8835 Parser.prototype.initializers = function() { |
9077 this._inhibitLambda = true; | 8836 this._inhibitLambda = true; |
9078 var ret = []; | 8837 var ret = []; |
9079 do { | 8838 do { |
9080 ret.add$1(this.expression()); | 8839 ret.add(this.expression()); |
9081 } | 8840 } |
9082 while (this._maybeEat((11))) | 8841 while (this._maybeEat((11))) |
9083 this._inhibitLambda = false; | 8842 this._inhibitLambda = false; |
9084 return ret; | 8843 return ret; |
9085 } | 8844 } |
9086 Parser.prototype.get$initializers = function() { | 8845 Parser.prototype.get$initializers = function() { |
9087 return this.initializers.bind(this); | 8846 return this.initializers.bind(this); |
9088 } | 8847 } |
9089 Parser.prototype.functionBody = function(inExpression) { | 8848 Parser.prototype.functionBody = function(inExpression) { |
9090 var start = this._peekToken.start; | 8849 var start = this._peekToken.start; |
(...skipping 17 matching lines...) Expand all Loading... |
9108 if (this._maybeEat((10))) { | 8867 if (this._maybeEat((10))) { |
9109 return null; | 8868 return null; |
9110 } | 8869 } |
9111 } | 8870 } |
9112 this._lang_error("Expected function body (neither { nor => found)"); | 8871 this._lang_error("Expected function body (neither { nor => found)"); |
9113 } | 8872 } |
9114 Parser.prototype.finishField = function(start, modifiers, type, name, value) { | 8873 Parser.prototype.finishField = function(start, modifiers, type, name, value) { |
9115 var names = [name]; | 8874 var names = [name]; |
9116 var values = [value]; | 8875 var values = [value]; |
9117 while (this._maybeEat((11))) { | 8876 while (this._maybeEat((11))) { |
9118 names.add$1(this.identifier()); | 8877 names.add(this.identifier()); |
9119 if (this._maybeEat((20))) { | 8878 if (this._maybeEat((20))) { |
9120 values.add$1(this.expression()); | 8879 values.add(this.expression()); |
9121 } | 8880 } |
9122 else { | 8881 else { |
9123 values.add$1(); | 8882 values.add(); |
9124 } | 8883 } |
9125 } | 8884 } |
9126 this._eatSemicolon(); | 8885 this._eatSemicolon(); |
9127 return new VariableDefinition(modifiers, type, names, values, this._makeSpan(s
tart)); | 8886 return new VariableDefinition(modifiers, type, names, values, this._makeSpan(s
tart)); |
9128 } | 8887 } |
9129 Parser.prototype.finishDefinition = function(start, modifiers, di) { | 8888 Parser.prototype.finishDefinition = function(start, modifiers, di) { |
9130 switch (this._peek()) { | 8889 switch (this._peek()) { |
9131 case (2): | 8890 case (2): |
9132 | 8891 |
9133 var formals = this.formalParameterList(); | 8892 var formals = this.formalParameterList(); |
9134 var inits = null, native_ = null; | 8893 var inits = null, native_ = null; |
9135 if (this._maybeEat((8))) { | 8894 if (this._maybeEat((8))) { |
9136 inits = this.initializers(); | 8895 inits = this.initializers(); |
9137 } | 8896 } |
9138 if (this._maybeEat((80))) { | 8897 if (this._maybeEat((80))) { |
9139 native_ = this.maybeStringLiteral(); | 8898 native_ = this.maybeStringLiteral(); |
9140 if (native_ == null) native_ = ""; | 8899 if ($eq(native_)) native_ = ""; |
9141 } | 8900 } |
9142 var body = this.functionBody(false); | 8901 var body = this.functionBody(false); |
9143 if (di.get$name() == null) { | 8902 if ($eq(di.get$name())) { |
9144 di.set$name(di.get$type().get$name()); | 8903 di.set$name(di.get$type().get$name()); |
9145 } | 8904 } |
9146 return new FunctionDefinition(modifiers, di.get$type(), di.get$name(), for
mals, inits, native_, body, this._makeSpan(start)); | 8905 return new FunctionDefinition(modifiers, di.get$type(), di.get$name(), for
mals, inits, native_, body, this._makeSpan(start)); |
9147 | 8906 |
9148 case (20): | 8907 case (20): |
9149 | 8908 |
9150 this._eat((20)); | 8909 this._eat((20)); |
9151 var value = this.expression(); | 8910 var value = this.expression(); |
9152 return this.finishField(start, modifiers, di.get$type(), di.get$name(), va
lue); | 8911 return this.finishField(start, modifiers, di.get$type(), di.get$name(), va
lue); |
9153 | 8912 |
(...skipping 15 matching lines...) Expand all Loading... |
9169 return this.factoryConstructorDeclaration(); | 8928 return this.factoryConstructorDeclaration(); |
9170 } | 8929 } |
9171 var modifiers = this._readModifiers(); | 8930 var modifiers = this._readModifiers(); |
9172 return this.finishDefinition(start, modifiers, this.declaredIdentifier(include
Operators)); | 8931 return this.finishDefinition(start, modifiers, this.declaredIdentifier(include
Operators)); |
9173 } | 8932 } |
9174 Parser.prototype.factoryConstructorDeclaration = function() { | 8933 Parser.prototype.factoryConstructorDeclaration = function() { |
9175 var start = this._peekToken.start; | 8934 var start = this._peekToken.start; |
9176 var factoryToken = this._lang_next(); | 8935 var factoryToken = this._lang_next(); |
9177 var names = [this.identifier()]; | 8936 var names = [this.identifier()]; |
9178 while (this._maybeEat((14))) { | 8937 while (this._maybeEat((14))) { |
9179 names.add$1(this.identifier()); | 8938 names.add(this.identifier()); |
9180 } | 8939 } |
9181 if (this._peekKind((52))) { | 8940 if (this._peekKind((52))) { |
9182 var tp = this.typeParameters(); | 8941 var tp = this.typeParameters(); |
9183 $globals.world.warning("type parameters on factories are no longer supported
, place them on the class instead", this._makeSpan(tp.$index((0)).get$span().get
$start())); | 8942 $globals.world.warning("type parameters on factories are no longer supported
, place them on the class instead", this._makeSpan(tp.$index((0)).get$span().sta
rt)); |
9184 } | 8943 } |
9185 var name = null; | 8944 var name = null; |
9186 var type = null; | 8945 var type = null; |
9187 if (this._maybeEat((14))) { | 8946 if (this._maybeEat((14))) { |
9188 name = this.identifier(); | 8947 name = this.identifier(); |
9189 } | 8948 } |
9190 else { | 8949 else { |
9191 if (names.get$length() > (1)) { | 8950 if (names.get$length() > (1)) { |
9192 name = names.removeLast$0(); | 8951 name = names.removeLast(); |
9193 } | 8952 } |
9194 else { | 8953 else { |
9195 name = new Identifier("", names.$index((0)).get$span()); | 8954 name = new Identifier("", names.$index((0)).get$span()); |
9196 } | 8955 } |
9197 } | 8956 } |
9198 if (names.get$length() > (1)) { | 8957 if (names.get$length() > (1)) { |
9199 this._lang_error("unsupported qualified name for factory", names.$index((0))
.get$span()); | 8958 this._lang_error("unsupported qualified name for factory", names.$index((0))
.get$span()); |
9200 } | 8959 } |
9201 type = new NameTypeReference(false, names.$index((0)), null, names.$index((0))
.get$span()); | 8960 type = new NameTypeReference(false, names.$index((0)), null, names.$index((0))
.get$span()); |
9202 var di = new DeclaredIdentifier(type, name, this._makeSpan(start)); | 8961 var di = new DeclaredIdentifier(type, name, this._makeSpan(start)); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9264 | 9023 |
9265 return this.declaration(false); | 9024 return this.declaration(false); |
9266 | 9025 |
9267 default: | 9026 default: |
9268 | 9027 |
9269 return this.finishExpressionAsStatement(this.expression()); | 9028 return this.finishExpressionAsStatement(this.expression()); |
9270 | 9029 |
9271 } | 9030 } |
9272 } | 9031 } |
9273 Parser.prototype.finishExpressionAsStatement = function(expr) { | 9032 Parser.prototype.finishExpressionAsStatement = function(expr) { |
9274 var start = expr.get$span().get$start(); | 9033 var start = expr.get$span().start; |
9275 if (this._maybeEat((8))) { | 9034 if (this._maybeEat((8))) { |
9276 var label = this._makeLabel(expr); | 9035 var label = this._makeLabel(expr); |
9277 return new LabeledStatement(label, this.statement(), this._makeSpan(start)); | 9036 return new LabeledStatement(label, this.statement(), this._makeSpan(start)); |
9278 } | 9037 } |
9279 if ((expr instanceof LambdaExpression)) { | 9038 if ((expr instanceof LambdaExpression)) { |
9280 if (!(expr.get$func().get$body() instanceof BlockStatement)) { | 9039 if (!(expr.get$func().body instanceof BlockStatement)) { |
9281 this._eatSemicolon(); | 9040 this._eatSemicolon(); |
9282 expr.get$func().set$span(this._makeSpan(start)); | 9041 expr.get$func().span = this._makeSpan(start); |
9283 } | 9042 } |
9284 return expr.get$func(); | 9043 return expr.get$func(); |
9285 } | 9044 } |
9286 else if ((expr instanceof DeclaredIdentifier)) { | 9045 else if ((expr instanceof DeclaredIdentifier)) { |
9287 var value = null; | 9046 var value = null; |
9288 if (this._maybeEat((20))) { | 9047 if (this._maybeEat((20))) { |
9289 value = this.expression(); | 9048 value = this.expression(); |
9290 } | 9049 } |
9291 return this.finishField(start, null, expr.get$type(), expr.get$name(), value
); | 9050 return this.finishField(start, null, expr.get$type(), expr.get$name(), value
); |
9292 } | 9051 } |
9293 else if (this._isBin(expr, (20)) && ((expr.get$x() instanceof DeclaredIdentifi
er))) { | 9052 else if (this._isBin(expr, (20)) && ((expr.get$x() instanceof DeclaredIdentifi
er))) { |
9294 var di = expr.get$x(); | 9053 var di = expr.get$x(); |
9295 return this.finishField(start, null, di.type, di.name, expr.get$y()); | 9054 return this.finishField(start, null, di.type, di.name, expr.get$y()); |
9296 } | 9055 } |
9297 else if (this._isBin(expr, (52)) && this._maybeEat((11))) { | 9056 else if (this._isBin(expr, (52)) && this._maybeEat((11))) { |
9298 var baseType = this._makeType(expr.get$x()); | 9057 var baseType = this._makeType(expr.get$x()); |
9299 var typeArgs = [this._makeType(expr.get$y())]; | 9058 var typeArgs = [this._makeType(expr.get$y())]; |
9300 var gt = this._finishTypeArguments(baseType, (0), typeArgs); | 9059 var gt = this._finishTypeArguments(baseType, (0), typeArgs); |
9301 var name = this.identifier(); | 9060 var name = this.identifier(); |
9302 var value = null; | 9061 var value = null; |
9303 if (this._maybeEat((20))) { | 9062 if (this._maybeEat((20))) { |
9304 value = this.expression(); | 9063 value = this.expression(); |
9305 } | 9064 } |
9306 return this.finishField(expr.get$span().get$start(), null, gt, name, value); | 9065 return this.finishField(expr.get$span().start, null, gt, name, value); |
9307 } | 9066 } |
9308 else { | 9067 else { |
9309 this._eatSemicolon(); | 9068 this._eatSemicolon(); |
9310 return new ExpressionStatement(expr, this._makeSpan(expr.get$span().get$star
t())); | 9069 return new ExpressionStatement(expr, this._makeSpan(expr.get$span().start)); |
9311 } | 9070 } |
9312 } | 9071 } |
9313 Parser.prototype.testCondition = function() { | 9072 Parser.prototype.testCondition = function() { |
9314 this._eatLeftParen(); | 9073 this._eatLeftParen(); |
9315 var ret = this.expression(); | 9074 var ret = this.expression(); |
9316 this._eat((3)); | 9075 this._eat((3)); |
9317 return ret; | 9076 return ret; |
9318 } | 9077 } |
9319 Parser.prototype.block = function() { | 9078 Parser.prototype.block = function() { |
9320 var start = this._peekToken.start; | 9079 var start = this._peekToken.start; |
9321 this._eat((6)); | 9080 this._eat((6)); |
9322 var stmts = []; | 9081 var stmts = []; |
9323 while (!this._maybeEat((7))) { | 9082 while (!this._maybeEat((7))) { |
9324 stmts.add$1(this.statement()); | 9083 stmts.add(this.statement()); |
9325 if (this._recover && !this._recoverTo((7), (10))) break; | 9084 if (this._recover && !this._recoverTo((7), (10))) break; |
9326 } | 9085 } |
9327 this._recover = false; | 9086 this._recover = false; |
9328 return new BlockStatement(stmts, this._makeSpan(start)); | 9087 return new BlockStatement(stmts, this._makeSpan(start)); |
9329 } | 9088 } |
9330 Parser.prototype.emptyStatement = function() { | 9089 Parser.prototype.emptyStatement = function() { |
9331 var start = this._peekToken.start; | 9090 var start = this._peekToken.start; |
9332 this._eat((10)); | 9091 this._eat((10)); |
9333 return new EmptyStatement(this._makeSpan(start)); | 9092 return new EmptyStatement(this._makeSpan(start)); |
9334 } | 9093 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9367 if ((init instanceof ForInStatement)) { | 9126 if ((init instanceof ForInStatement)) { |
9368 return init; | 9127 return init; |
9369 } | 9128 } |
9370 var test = null; | 9129 var test = null; |
9371 if (!this._maybeEat((10))) { | 9130 if (!this._maybeEat((10))) { |
9372 test = this.expression(); | 9131 test = this.expression(); |
9373 this._eatSemicolon(); | 9132 this._eatSemicolon(); |
9374 } | 9133 } |
9375 var step = []; | 9134 var step = []; |
9376 if (!this._maybeEat((3))) { | 9135 if (!this._maybeEat((3))) { |
9377 step.add$1(this.expression()); | 9136 step.add(this.expression()); |
9378 while (this._maybeEat((11))) { | 9137 while (this._maybeEat((11))) { |
9379 step.add$1(this.expression()); | 9138 step.add(this.expression()); |
9380 } | 9139 } |
9381 this._eat((3)); | 9140 this._eat((3)); |
9382 } | 9141 } |
9383 var body = this.statement(); | 9142 var body = this.statement(); |
9384 return new ForStatement(init, test, step, body, this._makeSpan(start)); | 9143 return new ForStatement(init, test, step, body, this._makeSpan(start)); |
9385 } | 9144 } |
9386 Parser.prototype.forInitializerStatement = function(start) { | 9145 Parser.prototype.forInitializerStatement = function(start) { |
9387 if (this._maybeEat((10))) { | 9146 if (this._maybeEat((10))) { |
9388 return null; | 9147 return null; |
9389 } | 9148 } |
9390 else { | 9149 else { |
9391 var init = this.expression(); | 9150 var init = this.expression(); |
9392 if (this._peekKind((11)) && this._isBin(init, (52))) { | 9151 if (this._peekKind((11)) && this._isBin(init, (52))) { |
9393 this._eat((11)); | 9152 this._eat((11)); |
9394 var baseType = this._makeType(init.get$x()); | 9153 var baseType = this._makeType(init.get$x()); |
9395 var typeArgs = [this._makeType(init.get$y())]; | 9154 var typeArgs = [this._makeType(init.get$y())]; |
9396 var gt = this._finishTypeArguments(baseType, (0), typeArgs); | 9155 var gt = this._finishTypeArguments(baseType, (0), typeArgs); |
9397 var name = this.identifier(); | 9156 var name = this.identifier(); |
9398 init = new DeclaredIdentifier(gt, name, this._makeSpan(init.get$span().get
$start())); | 9157 init = new DeclaredIdentifier(gt, name, this._makeSpan(init.get$span().sta
rt)); |
9399 } | 9158 } |
9400 if (this._maybeEat((103))) { | 9159 if (this._maybeEat((103))) { |
9401 return this._finishForIn(start, this._makeDeclaredIdentifier(init)); | 9160 return this._finishForIn(start, this._makeDeclaredIdentifier(init)); |
9402 } | 9161 } |
9403 else { | 9162 else { |
9404 return this.finishExpressionAsStatement(init); | 9163 return this.finishExpressionAsStatement(init); |
9405 } | 9164 } |
9406 } | 9165 } |
9407 } | 9166 } |
9408 Parser.prototype._finishForIn = function(start, di) { | 9167 Parser.prototype._finishForIn = function(start, di) { |
9409 var expr = this.expression(); | 9168 var expr = this.expression(); |
9410 this._eat((3)); | 9169 this._eat((3)); |
9411 var body = this.statement(); | 9170 var body = this.statement(); |
9412 return new ForInStatement(di, expr, body, this._makeSpan(start)); | 9171 return new ForInStatement(di, expr, body, this._makeSpan(start)); |
9413 } | 9172 } |
9414 Parser.prototype.tryStatement = function() { | 9173 Parser.prototype.tryStatement = function() { |
9415 var start = this._peekToken.start; | 9174 var start = this._peekToken.start; |
9416 this._eat((113)); | 9175 this._eat((113)); |
9417 var body = this.block(); | 9176 var body = this.block(); |
9418 var catches = []; | 9177 var catches = []; |
9419 while (this._peekKind((90))) { | 9178 while (this._peekKind((90))) { |
9420 catches.add$1(this.catchNode()); | 9179 catches.add(this.catchNode()); |
9421 } | 9180 } |
9422 var finallyBlock = null; | 9181 var finallyBlock = null; |
9423 if (this._maybeEat((100))) { | 9182 if (this._maybeEat((100))) { |
9424 finallyBlock = this.block(); | 9183 finallyBlock = this.block(); |
9425 } | 9184 } |
9426 return new TryStatement(body, catches, finallyBlock, this._makeSpan(start)); | 9185 return new TryStatement(body, catches, finallyBlock, this._makeSpan(start)); |
9427 } | 9186 } |
9428 Parser.prototype.catchNode = function() { | 9187 Parser.prototype.catchNode = function() { |
9429 var start = this._peekToken.start; | 9188 var start = this._peekToken.start; |
9430 this._eat((90)); | 9189 this._eat((90)); |
9431 this._eatLeftParen(); | 9190 this._eatLeftParen(); |
9432 var exc = this.declaredIdentifier(false); | 9191 var exc = this.declaredIdentifier(false); |
9433 var trace = null; | 9192 var trace = null; |
9434 if (this._maybeEat((11))) { | 9193 if (this._maybeEat((11))) { |
9435 trace = this.declaredIdentifier(false); | 9194 trace = this.declaredIdentifier(false); |
9436 } | 9195 } |
9437 this._eat((3)); | 9196 this._eat((3)); |
9438 var body = this.block(); | 9197 var body = this.block(); |
9439 return new CatchNode(exc, trace, body, this._makeSpan(start)); | 9198 return new CatchNode(exc, trace, body, this._makeSpan(start)); |
9440 } | 9199 } |
9441 Parser.prototype.switchStatement = function() { | 9200 Parser.prototype.switchStatement = function() { |
9442 var start = this._peekToken.start; | 9201 var start = this._peekToken.start; |
9443 this._eat((109)); | 9202 this._eat((109)); |
9444 var test = this.testCondition(); | 9203 var test = this.testCondition(); |
9445 var cases = []; | 9204 var cases = []; |
9446 this._eat((6)); | 9205 this._eat((6)); |
9447 while (!this._maybeEat((7))) { | 9206 while (!this._maybeEat((7))) { |
9448 cases.add$1(this.caseNode()); | 9207 cases.add(this.caseNode()); |
9449 } | 9208 } |
9450 return new SwitchStatement(test, cases, this._makeSpan(start)); | 9209 return new SwitchStatement(test, cases, this._makeSpan(start)); |
9451 } | 9210 } |
9452 Parser.prototype._peekCaseEnd = function() { | 9211 Parser.prototype._peekCaseEnd = function() { |
9453 var kind = this._peek(); | 9212 var kind = this._peek(); |
9454 return $eq(kind, (7)) || $eq(kind, (89)) || $eq(kind, (94)); | 9213 return $eq(kind, (7)) || $eq(kind, (89)) || $eq(kind, (94)); |
9455 } | 9214 } |
9456 Parser.prototype.caseNode = function() { | 9215 Parser.prototype.caseNode = function() { |
9457 var start = this._peekToken.start; | 9216 var start = this._peekToken.start; |
9458 var label = null; | 9217 var label = null; |
9459 if (this._peekIdentifier()) { | 9218 if (this._peekIdentifier()) { |
9460 label = this.identifier(); | 9219 label = this.identifier(); |
9461 this._eat((8)); | 9220 this._eat((8)); |
9462 } | 9221 } |
9463 var cases = []; | 9222 var cases = []; |
9464 while (true) { | 9223 while (true) { |
9465 if (this._maybeEat((89))) { | 9224 if (this._maybeEat((89))) { |
9466 cases.add$1(this.expression()); | 9225 cases.add(this.expression()); |
9467 this._eat((8)); | 9226 this._eat((8)); |
9468 } | 9227 } |
9469 else if (this._maybeEat((94))) { | 9228 else if (this._maybeEat((94))) { |
9470 cases.add$1(); | 9229 cases.add(); |
9471 this._eat((8)); | 9230 this._eat((8)); |
9472 } | 9231 } |
9473 else { | 9232 else { |
9474 break; | 9233 break; |
9475 } | 9234 } |
9476 } | 9235 } |
9477 if ($eq(cases.get$length(), (0))) { | 9236 if (cases.get$length() == (0)) { |
9478 this._lang_error("case or default"); | 9237 this._lang_error("case or default"); |
9479 } | 9238 } |
9480 var stmts = []; | 9239 var stmts = []; |
9481 while (!this._peekCaseEnd()) { | 9240 while (!this._peekCaseEnd()) { |
9482 stmts.add$1(this.statement()); | 9241 stmts.add(this.statement()); |
9483 if (this._recover && !this._recoverTo((7), (89), (94))) { | 9242 if (this._recover && !this._recoverTo((7), (89), (94))) { |
9484 break; | 9243 break; |
9485 } | 9244 } |
9486 } | 9245 } |
9487 return new CaseNode(label, cases, stmts, this._makeSpan(start)); | 9246 return new CaseNode(label, cases, stmts, this._makeSpan(start)); |
9488 } | 9247 } |
9489 Parser.prototype.returnStatement = function() { | 9248 Parser.prototype.returnStatement = function() { |
9490 var start = this._peekToken.start; | 9249 var start = this._peekToken.start; |
9491 this._eat((107)); | 9250 this._eat((107)); |
9492 var expr; | 9251 var expr; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9547 Parser.prototype._makeType = function(expr) { | 9306 Parser.prototype._makeType = function(expr) { |
9548 if ((expr instanceof VarExpression)) { | 9307 if ((expr instanceof VarExpression)) { |
9549 return new NameTypeReference(false, expr.get$name(), null, expr.get$span()); | 9308 return new NameTypeReference(false, expr.get$name(), null, expr.get$span()); |
9550 } | 9309 } |
9551 else if ((expr instanceof DotExpression)) { | 9310 else if ((expr instanceof DotExpression)) { |
9552 var type = this._makeType(expr.get$self()); | 9311 var type = this._makeType(expr.get$self()); |
9553 if (type.get$names() == null) { | 9312 if (type.get$names() == null) { |
9554 type.set$names([expr.get$name()]); | 9313 type.set$names([expr.get$name()]); |
9555 } | 9314 } |
9556 else { | 9315 else { |
9557 type.get$names().add$1(expr.get$name()); | 9316 type.get$names().add(expr.get$name()); |
9558 } | 9317 } |
9559 type.set$span(expr.get$span()); | 9318 type.set$span(expr.get$span()); |
9560 return type; | 9319 return type; |
9561 } | 9320 } |
9562 else { | 9321 else { |
9563 this._lang_error("expected type reference"); | 9322 this._lang_error("expected type reference"); |
9564 return null; | 9323 return null; |
9565 } | 9324 } |
9566 } | 9325 } |
9567 Parser.prototype.infixExpression = function(precedence) { | 9326 Parser.prototype.infixExpression = function(precedence) { |
9568 return this.finishInfixExpression(this.unaryExpression(), precedence); | 9327 return this.finishInfixExpression(this.unaryExpression(), precedence); |
9569 } | 9328 } |
9570 Parser.prototype._finishDeclaredId = function(type) { | 9329 Parser.prototype._finishDeclaredId = function(type) { |
9571 var name = this.identifier(); | 9330 var name = this.identifier(); |
9572 return this.finishPostfixExpression(new DeclaredIdentifier(type, name, this._m
akeSpan(type.get$span().get$start()))); | 9331 return this.finishPostfixExpression(new DeclaredIdentifier(type, name, this._m
akeSpan(type.get$span().start))); |
9573 } | 9332 } |
9574 Parser.prototype._fixAsType = function(x) { | 9333 Parser.prototype._fixAsType = function(x) { |
9575 if (this._maybeEat((53))) { | 9334 if (this._maybeEat((53))) { |
9576 var base = this._makeType(x.x); | 9335 var base = this._makeType(x.x); |
9577 var typeParam = this._makeType(x.y); | 9336 var typeParam = this._makeType(x.y); |
9578 var type = new GenericTypeReference(base, [typeParam], (0), this._makeSpan(x
.span.start)); | 9337 var type = new GenericTypeReference(base, [typeParam], (0), this._makeSpan(x
.span.start)); |
9579 return this._finishDeclaredId(type); | 9338 return this._finishDeclaredId(type); |
9580 } | 9339 } |
9581 else { | 9340 else { |
9582 var base = this._makeType(x.x); | 9341 var base = this._makeType(x.x); |
(...skipping 10 matching lines...) Expand all Loading... |
9593 this._eat((53)); | 9352 this._eat((53)); |
9594 type = new GenericTypeReference(base, [firstParam], (0), this._makeSpan(x.
span.start)); | 9353 type = new GenericTypeReference(base, [firstParam], (0), this._makeSpan(x.
span.start)); |
9595 } | 9354 } |
9596 return this._finishDeclaredId(type); | 9355 return this._finishDeclaredId(type); |
9597 } | 9356 } |
9598 } | 9357 } |
9599 Parser.prototype.finishInfixExpression = function(x, precedence) { | 9358 Parser.prototype.finishInfixExpression = function(x, precedence) { |
9600 while (true) { | 9359 while (true) { |
9601 var kind = this._peek(); | 9360 var kind = this._peek(); |
9602 var prec = TokenKind.infixPrecedence(this._peek()); | 9361 var prec = TokenKind.infixPrecedence(this._peek()); |
9603 if (prec >= precedence) { | 9362 if ($gte(prec, precedence)) { |
9604 if (kind == (52) || kind == (53)) { | 9363 if (kind == (52) || kind == (53)) { |
9605 if (this._isBin(x, (52))) { | 9364 if (this._isBin(x, (52))) { |
9606 return this._fixAsType(x); | 9365 return this._fixAsType(x); |
9607 } | 9366 } |
9608 } | 9367 } |
9609 var op = this._lang_next(); | 9368 var op = this._lang_next(); |
9610 if ($eq(op.get$kind(), (104))) { | 9369 if (op.get$kind() == (104)) { |
9611 var isTrue = !this._maybeEat((19)); | 9370 var isTrue = !this._maybeEat((19)); |
9612 var typeRef = this.type((0)); | 9371 var typeRef = this.type((0)); |
9613 x = new IsExpression(isTrue, x, typeRef, this._makeSpan(x.span.start)); | 9372 x = new IsExpression(isTrue, x, typeRef, this._makeSpan(x.span.start)); |
9614 continue; | 9373 continue; |
9615 } | 9374 } |
9616 var y = this.infixExpression($eq(prec, (2)) ? prec : $add(prec, (1))); | 9375 var y = this.infixExpression($eq(prec, (2)) ? prec : $add(prec, (1))); |
9617 if ($eq(op.get$kind(), (33))) { | 9376 if (op.get$kind() == (33)) { |
9618 this._eat((8)); | 9377 this._eat((8)); |
9619 var z = this.infixExpression(prec); | 9378 var z = this.infixExpression(prec); |
9620 x = new ConditionalExpression(x, y, z, this._makeSpan(x.span.start)); | 9379 x = new ConditionalExpression(x, y, z, this._makeSpan(x.span.start)); |
9621 } | 9380 } |
9622 else { | 9381 else { |
9623 x = new BinaryExpression(op, x, y, this._makeSpan(x.span.start)); | 9382 x = new BinaryExpression(op, x, y, this._makeSpan(x.span.start)); |
9624 } | 9383 } |
9625 } | 9384 } |
9626 else { | 9385 else { |
9627 break; | 9386 break; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9660 return this.finishPostfixExpression(this.primary()); | 9419 return this.finishPostfixExpression(this.primary()); |
9661 } | 9420 } |
9662 Parser.prototype.argument = function() { | 9421 Parser.prototype.argument = function() { |
9663 var start = this._peekToken.start; | 9422 var start = this._peekToken.start; |
9664 var expr; | 9423 var expr; |
9665 var label = null; | 9424 var label = null; |
9666 if (this._maybeEat((15))) { | 9425 if (this._maybeEat((15))) { |
9667 label = new Identifier("...", this._makeSpan(start)); | 9426 label = new Identifier("...", this._makeSpan(start)); |
9668 } | 9427 } |
9669 expr = this.expression(); | 9428 expr = this.expression(); |
9670 if (label == null && this._maybeEat((8))) { | 9429 if ($eq(label) && this._maybeEat((8))) { |
9671 label = this._makeLabel(expr); | 9430 label = this._makeLabel(expr); |
9672 expr = this.expression(); | 9431 expr = this.expression(); |
9673 } | 9432 } |
9674 return new ArgumentNode(label, expr, this._makeSpan(start)); | 9433 return new ArgumentNode(label, expr, this._makeSpan(start)); |
9675 } | 9434 } |
9676 Parser.prototype.arguments = function() { | 9435 Parser.prototype.arguments = function() { |
9677 var args = []; | 9436 var args = []; |
9678 this._eatLeftParen(); | 9437 this._eatLeftParen(); |
9679 var saved = this._inhibitLambda; | 9438 var saved = this._inhibitLambda; |
9680 this._inhibitLambda = false; | 9439 this._inhibitLambda = false; |
9681 if (!this._maybeEat((3))) { | 9440 if (!this._maybeEat((3))) { |
9682 do { | 9441 do { |
9683 args.add$1(this.argument()); | 9442 args.add(this.argument()); |
9684 } | 9443 } |
9685 while (this._maybeEat((11))) | 9444 while (this._maybeEat((11))) |
9686 this._eat((3)); | 9445 this._eat((3)); |
9687 } | 9446 } |
9688 this._inhibitLambda = saved; | 9447 this._inhibitLambda = saved; |
9689 return args; | 9448 return args; |
9690 } | 9449 } |
9691 Parser.prototype.finishPostfixExpression = function(expr) { | 9450 Parser.prototype.finishPostfixExpression = function(expr) { |
9692 switch (this._peek()) { | 9451 switch (this._peek()) { |
9693 case (2): | 9452 case (2): |
9694 | 9453 |
9695 return this.finishCallOrLambdaExpression(expr); | 9454 return this.finishCallOrLambdaExpression(expr); |
9696 | 9455 |
9697 case (4): | 9456 case (4): |
9698 | 9457 |
9699 this._eat((4)); | 9458 this._eat((4)); |
9700 var index = this.expression(); | 9459 var index = this.expression(); |
9701 this._eat((5)); | 9460 this._eat((5)); |
9702 return this.finishPostfixExpression(new IndexExpression(expr, index, this.
_makeSpan(expr.get$span().get$start()))); | 9461 return this.finishPostfixExpression(new IndexExpression(expr, index, this.
_makeSpan(expr.get$span().start))); |
9703 | 9462 |
9704 case (14): | 9463 case (14): |
9705 | 9464 |
9706 this._eat((14)); | 9465 this._eat((14)); |
9707 var name = this.identifier(); | 9466 var name = this.identifier(); |
9708 var ret = new DotExpression(expr, name, this._makeSpan(expr.get$span().get
$start())); | 9467 var ret = new DotExpression(expr, name, this._makeSpan(expr.get$span().sta
rt)); |
9709 return this.finishPostfixExpression(ret); | 9468 return this.finishPostfixExpression(ret); |
9710 | 9469 |
9711 case (16): | 9470 case (16): |
9712 case (17): | 9471 case (17): |
9713 | 9472 |
9714 var tok = this._lang_next(); | 9473 var tok = this._lang_next(); |
9715 return new PostfixExpression(expr, tok, this._makeSpan(expr.get$span().get
$start())); | 9474 return new PostfixExpression(expr, tok, this._makeSpan(expr.get$span().sta
rt)); |
9716 | 9475 |
9717 case (9): | 9476 case (9): |
9718 case (6): | 9477 case (6): |
9719 | 9478 |
9720 return expr; | 9479 return expr; |
9721 | 9480 |
9722 default: | 9481 default: |
9723 | 9482 |
9724 if (this._peekIdentifier()) { | 9483 if (this._peekIdentifier()) { |
9725 return this.finishPostfixExpression(new DeclaredIdentifier(this._makeTyp
e(expr), this.identifier(), this._makeSpan(expr.get$span().get$start()))); | 9484 return this.finishPostfixExpression(new DeclaredIdentifier(this._makeTyp
e(expr), this.identifier(), this._makeSpan(expr.get$span().start))); |
9726 } | 9485 } |
9727 else { | 9486 else { |
9728 return expr; | 9487 return expr; |
9729 } | 9488 } |
9730 | 9489 |
9731 } | 9490 } |
9732 } | 9491 } |
9733 Parser.prototype.finishCallOrLambdaExpression = function(expr) { | 9492 Parser.prototype.finishCallOrLambdaExpression = function(expr) { |
9734 if (this._atClosureParameters()) { | 9493 if (this._atClosureParameters()) { |
9735 var formals = this.formalParameterList(); | 9494 var formals = this.formalParameterList(); |
9736 var body = this.functionBody(true); | 9495 var body = this.functionBody(true); |
9737 return this._makeFunction(expr, formals, body); | 9496 return this._makeFunction(expr, formals, body); |
9738 } | 9497 } |
9739 else { | 9498 else { |
9740 if ((expr instanceof DeclaredIdentifier)) { | 9499 if ((expr instanceof DeclaredIdentifier)) { |
9741 this._lang_error("illegal target for call, did you mean to declare a funct
ion?", expr.get$span()); | 9500 this._lang_error("illegal target for call, did you mean to declare a funct
ion?", expr.get$span()); |
9742 } | 9501 } |
9743 var args = this.arguments(); | 9502 var args = this.arguments(); |
9744 return this.finishPostfixExpression(new CallExpression(expr, args, this._mak
eSpan(expr.get$span().get$start()))); | 9503 return this.finishPostfixExpression(new CallExpression(expr, args, this._mak
eSpan(expr.get$span().start))); |
9745 } | 9504 } |
9746 } | 9505 } |
9747 Parser.prototype._isBin = function(expr, kind) { | 9506 Parser.prototype._isBin = function(expr, kind) { |
9748 return (expr instanceof BinaryExpression) && $eq(expr.get$op().get$kind(), kin
d); | 9507 return (expr instanceof BinaryExpression) && expr.get$op().kind == kind; |
9749 } | 9508 } |
9750 Parser.prototype._makeLiteral = function(value) { | 9509 Parser.prototype._makeLiteral = function(value) { |
9751 return new LiteralExpression(value, value.span); | 9510 return new LiteralExpression(value, value.span); |
9752 } | 9511 } |
9753 Parser.prototype.primary = function() { | 9512 Parser.prototype.primary = function() { |
9754 var start = this._peekToken.start; | 9513 var start = this._peekToken.start; |
9755 switch (this._peek()) { | 9514 switch (this._peek()) { |
9756 case (110): | 9515 case (110): |
9757 | 9516 |
9758 this._eat((110)); | 9517 this._eat((110)); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9854 return new VarExpression(this.identifier(), this._makeSpan(start)); | 9613 return new VarExpression(this.identifier(), this._makeSpan(start)); |
9855 | 9614 |
9856 } | 9615 } |
9857 } | 9616 } |
9858 Parser.prototype.stringInterpolation = function() { | 9617 Parser.prototype.stringInterpolation = function() { |
9859 var start = this._peekToken.start; | 9618 var start = this._peekToken.start; |
9860 var pieces = new Array(); | 9619 var pieces = new Array(); |
9861 var startQuote = null, endQuote = null; | 9620 var startQuote = null, endQuote = null; |
9862 while (this._peekKind((59))) { | 9621 while (this._peekKind((59))) { |
9863 var token = this._lang_next(); | 9622 var token = this._lang_next(); |
9864 pieces.add$1(this._makeLiteral(Value.fromString(token.get$value(), token.get
$span()))); | 9623 pieces.add(this._makeLiteral(Value.fromString(token.get$value(), token.get$s
pan()))); |
9865 if (this._maybeEat((6))) { | 9624 if (this._maybeEat((6))) { |
9866 pieces.add$1(this.expression()); | 9625 pieces.add(this.expression()); |
9867 this._eat((7)); | 9626 this._eat((7)); |
9868 } | 9627 } |
9869 else if (this._maybeEat((110))) { | 9628 else if (this._maybeEat((110))) { |
9870 pieces.add$1(new ThisExpression(this._previousToken.get$span())); | 9629 pieces.add(new ThisExpression(this._previousToken.get$span())); |
9871 } | 9630 } |
9872 else { | 9631 else { |
9873 var id = this.identifier(); | 9632 var id = this.identifier(); |
9874 pieces.add$1(new VarExpression(id, id.get$span())); | 9633 pieces.add(new VarExpression(id, id.get$span())); |
9875 } | 9634 } |
9876 } | 9635 } |
9877 var tok = this._lang_next(); | 9636 var tok = this._lang_next(); |
9878 if ($ne(tok.get$kind(), (58))) { | 9637 if (tok.get$kind() != (58)) { |
9879 this._errorExpected("interpolated string"); | 9638 this._errorExpected("interpolated string"); |
9880 } | 9639 } |
9881 pieces.add$1(this._makeLiteral(Value.fromString(tok.get$value(), tok.get$span(
)))); | 9640 pieces.add(this._makeLiteral(Value.fromString(tok.get$value(), tok.get$span())
)); |
9882 var span = this._makeSpan(start); | 9641 var span = this._makeSpan(start); |
9883 return new StringInterpExpression(pieces, span); | 9642 return new StringInterpExpression(pieces, span); |
9884 } | 9643 } |
9885 Parser.prototype.maybeStringLiteral = function() { | 9644 Parser.prototype.maybeStringLiteral = function() { |
9886 var kind = this._peek(); | 9645 var kind = this._peek(); |
9887 if ($eq(kind, (58))) { | 9646 if ($eq(kind, (58))) { |
9888 var t = this._lang_next(); | 9647 var t = this._lang_next(); |
9889 return t.get$value(); | 9648 return t.get$value(); |
9890 } | 9649 } |
9891 else if ($eq(kind, (59))) { | 9650 else if ($eq(kind, (59))) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9923 } | 9682 } |
9924 Parser.prototype._peekAfterCloseParen = function() { | 9683 Parser.prototype._peekAfterCloseParen = function() { |
9925 if (this._afterParensIndex < this._afterParens.get$length()) { | 9684 if (this._afterParensIndex < this._afterParens.get$length()) { |
9926 return this._afterParens[this._afterParensIndex]; | 9685 return this._afterParens[this._afterParensIndex]; |
9927 } | 9686 } |
9928 this._afterParensIndex = (0); | 9687 this._afterParensIndex = (0); |
9929 this._afterParens.clear(); | 9688 this._afterParens.clear(); |
9930 var tokens = [this._lang_next()]; | 9689 var tokens = [this._lang_next()]; |
9931 this._lookaheadAfterParens(tokens); | 9690 this._lookaheadAfterParens(tokens); |
9932 var after = this._peekToken; | 9691 var after = this._peekToken; |
9933 tokens.add$1(after); | 9692 tokens.add(after); |
9934 this.tokenizer = new DivertedTokenSource(tokens, this, this.tokenizer); | 9693 this.tokenizer = new DivertedTokenSource(tokens, this, this.tokenizer); |
9935 this._lang_next(); | 9694 this._lang_next(); |
9936 return after; | 9695 return after; |
9937 } | 9696 } |
9938 Parser.prototype._lookaheadAfterParens = function(tokens) { | 9697 Parser.prototype._lookaheadAfterParens = function(tokens) { |
9939 var saved = this._afterParens.get$length(); | 9698 var saved = this._afterParens.get$length(); |
9940 this._afterParens.add(null); | 9699 this._afterParens.add(); |
9941 while (true) { | 9700 while (true) { |
9942 var token = this._lang_next(); | 9701 var token = this._lang_next(); |
9943 tokens.add(token); | 9702 tokens.add(token); |
9944 var kind = token.kind; | 9703 var kind = token.kind; |
9945 if (kind == (3) || kind == (1)) { | 9704 if (kind == (3) || kind == (1)) { |
9946 this._afterParens.$setindex(saved, this._peekToken); | 9705 this._afterParens.$setindex(saved, this._peekToken); |
9947 return; | 9706 return; |
9948 } | 9707 } |
9949 else if (kind == (2)) { | 9708 else if (kind == (2)) { |
9950 this._lookaheadAfterParens(tokens); | 9709 this._lookaheadAfterParens(tokens); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10023 | 9782 |
10024 return null; | 9783 return null; |
10025 | 9784 |
10026 } | 9785 } |
10027 return new Identifier(name, this._makeSpan(start)); | 9786 return new Identifier(name, this._makeSpan(start)); |
10028 } | 9787 } |
10029 Parser.prototype.declaredIdentifier = function(includeOperators) { | 9788 Parser.prototype.declaredIdentifier = function(includeOperators) { |
10030 var start = this._peekToken.start; | 9789 var start = this._peekToken.start; |
10031 var myType = null; | 9790 var myType = null; |
10032 var name = this._specialIdentifier(includeOperators); | 9791 var name = this._specialIdentifier(includeOperators); |
10033 if (name == null) { | 9792 if ($eq(name)) { |
10034 myType = this.type((0)); | 9793 myType = this.type((0)); |
10035 name = this._specialIdentifier(includeOperators); | 9794 name = this._specialIdentifier(includeOperators); |
10036 if (name == null) { | 9795 if ($eq(name)) { |
10037 if (this._peekIdentifier()) { | 9796 if (this._peekIdentifier()) { |
10038 name = this.identifier(); | 9797 name = this.identifier(); |
10039 } | 9798 } |
10040 else if ((myType instanceof NameTypeReference) && myType.get$names() == nu
ll) { | 9799 else if ((myType instanceof NameTypeReference) && myType.get$names() == nu
ll) { |
10041 name = this._typeAsIdentifier(myType); | 9800 name = this._typeAsIdentifier(myType); |
10042 myType = null; | 9801 myType = null; |
10043 } | 9802 } |
10044 else { | 9803 else { |
10045 } | 9804 } |
10046 } | 9805 } |
10047 } | 9806 } |
10048 return new DeclaredIdentifier(myType, name, this._makeSpan(start)); | 9807 return new DeclaredIdentifier(myType, name, this._makeSpan(start)); |
10049 } | 9808 } |
10050 Parser.prototype.finishNewExpression = function(start, isConst) { | 9809 Parser.prototype.finishNewExpression = function(start, isConst) { |
10051 var type = this.type((0)); | 9810 var type = this.type((0)); |
10052 var name = null; | 9811 var name = null; |
10053 if (this._maybeEat((14))) { | 9812 if (this._maybeEat((14))) { |
10054 name = this.identifier(); | 9813 name = this.identifier(); |
10055 } | 9814 } |
10056 var args = this.arguments(); | 9815 var args = this.arguments(); |
10057 return new NewExpression(isConst, type, name, args, this._makeSpan(start)); | 9816 return new NewExpression(isConst, type, name, args, this._makeSpan(start)); |
10058 } | 9817 } |
10059 Parser.prototype.finishListLiteral = function(start, isConst, itemType) { | 9818 Parser.prototype.finishListLiteral = function(start, isConst, itemType) { |
10060 if (this._maybeEat((56))) { | 9819 if (this._maybeEat((56))) { |
10061 return new ListExpression(isConst, itemType, [], this._makeSpan(start)); | 9820 return new ListExpression(isConst, itemType, [], this._makeSpan(start)); |
10062 } | 9821 } |
10063 var values = []; | 9822 var values = []; |
10064 this._eat((4)); | 9823 this._eat((4)); |
10065 while (!this._maybeEat((5))) { | 9824 while (!this._maybeEat((5))) { |
10066 values.add$1(this.expression()); | 9825 values.add(this.expression()); |
10067 if (this._recover && !this._recoverTo((5), (11))) break; | 9826 if (this._recover && !this._recoverTo((5), (11))) break; |
10068 if (!this._maybeEat((11))) { | 9827 if (!this._maybeEat((11))) { |
10069 this._eat((5)); | 9828 this._eat((5)); |
10070 break; | 9829 break; |
10071 } | 9830 } |
10072 } | 9831 } |
10073 return new ListExpression(isConst, itemType, values, this._makeSpan(start)); | 9832 return new ListExpression(isConst, itemType, values, this._makeSpan(start)); |
10074 } | 9833 } |
10075 Parser.prototype.finishMapLiteral = function(start, isConst, keyType, valueType)
{ | 9834 Parser.prototype.finishMapLiteral = function(start, isConst, keyType, valueType)
{ |
10076 var items = []; | 9835 var items = []; |
10077 this._eat((6)); | 9836 this._eat((6)); |
10078 while (!this._maybeEat((7))) { | 9837 while (!this._maybeEat((7))) { |
10079 items.add$1(this.expression()); | 9838 items.add(this.expression()); |
10080 this._eat((8)); | 9839 this._eat((8)); |
10081 items.add$1(this.expression()); | 9840 items.add(this.expression()); |
10082 if (this._recover && !this._recoverTo((7), (11))) break; | 9841 if (this._recover && !this._recoverTo((7), (11))) break; |
10083 if (!this._maybeEat((11))) { | 9842 if (!this._maybeEat((11))) { |
10084 this._eat((7)); | 9843 this._eat((7)); |
10085 break; | 9844 break; |
10086 } | 9845 } |
10087 } | 9846 } |
10088 return new MapExpression(isConst, keyType, valueType, items, this._makeSpan(st
art)); | 9847 return new MapExpression(isConst, keyType, valueType, items, this._makeSpan(st
art)); |
10089 } | 9848 } |
10090 Parser.prototype.finishTypedLiteral = function(start, isConst) { | 9849 Parser.prototype.finishTypedLiteral = function(start, isConst) { |
10091 var span = this._makeSpan(start); | 9850 var span = this._makeSpan(start); |
10092 var typeToBeNamedLater = new NameTypeReference(false, null, null, span); | 9851 var typeToBeNamedLater = new NameTypeReference(false, null, null, span); |
10093 var genericType = this.addTypeArguments(typeToBeNamedLater, (0)); | 9852 var genericType = this.addTypeArguments(typeToBeNamedLater, (0)); |
10094 var typeArgs = genericType.get$typeArguments(); | 9853 var typeArgs = genericType.get$typeArguments(); |
10095 if (this._peekKind((4)) || this._peekKind((56))) { | 9854 if (this._peekKind((4)) || this._peekKind((56))) { |
10096 if ($ne(typeArgs.get$length(), (1))) { | 9855 if (typeArgs.get$length() != (1)) { |
10097 $globals.world.error("exactly one type argument expected for list", generi
cType.get$span()); | 9856 $globals.world.error("exactly one type argument expected for list", generi
cType.get$span()); |
10098 } | 9857 } |
10099 return this.finishListLiteral(start, isConst, typeArgs.$index((0))); | 9858 return this.finishListLiteral(start, isConst, typeArgs.$index((0))); |
10100 } | 9859 } |
10101 else if (this._peekKind((6))) { | 9860 else if (this._peekKind((6))) { |
10102 var keyType, valueType; | 9861 var keyType, valueType; |
10103 if ($eq(typeArgs.get$length(), (1))) { | 9862 if (typeArgs.get$length() == (1)) { |
10104 keyType = null; | 9863 keyType = null; |
10105 valueType = typeArgs.$index((0)); | 9864 valueType = typeArgs.$index((0)); |
10106 } | 9865 } |
10107 else if ($eq(typeArgs.get$length(), (2))) { | 9866 else if (typeArgs.get$length() == (2)) { |
10108 var keyType0 = typeArgs.$index((0)); | 9867 keyType = typeArgs.$index((0)); |
10109 $globals.world.warning("a map literal takes one type argument specifying t
he value type", keyType0.get$span()); | 9868 $globals.world.warning("a map literal takes one type argument specifying t
he value type", keyType.get$span()); |
10110 valueType = typeArgs.$index((1)); | 9869 valueType = typeArgs.$index((1)); |
10111 } | 9870 } |
10112 return this.finishMapLiteral(start, isConst, keyType, valueType); | 9871 return this.finishMapLiteral(start, isConst, keyType, valueType); |
10113 } | 9872 } |
10114 else { | 9873 else { |
10115 this._errorExpected("array or map literal"); | 9874 this._errorExpected("array or map literal"); |
10116 } | 9875 } |
10117 } | 9876 } |
10118 Parser.prototype._readModifiers = function() { | 9877 Parser.prototype._readModifiers = function() { |
10119 var modifiers = null; | 9878 var modifiers = null; |
10120 while (true) { | 9879 while (true) { |
10121 switch (this._peek()) { | 9880 switch (this._peek()) { |
10122 case (85): | 9881 case (85): |
10123 case (99): | 9882 case (99): |
10124 case (92): | 9883 case (92): |
10125 case (71): | 9884 case (71): |
10126 case (74): | 9885 case (74): |
10127 | 9886 |
10128 if (modifiers == null) modifiers = []; | 9887 if ($eq(modifiers)) modifiers = []; |
10129 modifiers.add$1(this._lang_next()); | 9888 modifiers.add(this._lang_next()); |
10130 break; | 9889 break; |
10131 | 9890 |
10132 default: | 9891 default: |
10133 | 9892 |
10134 return modifiers; | 9893 return modifiers; |
10135 | 9894 |
10136 } | 9895 } |
10137 } | 9896 } |
10138 return null; | 9897 return null; |
10139 } | 9898 } |
10140 Parser.prototype.typeParameter = function() { | 9899 Parser.prototype.typeParameter = function() { |
10141 var start = this._peekToken.start; | 9900 var start = this._peekToken.start; |
10142 var name = this.identifier(); | 9901 var name = this.identifier(); |
10143 var myType = null; | 9902 var myType = null; |
10144 if (this._maybeEat((97))) { | 9903 if (this._maybeEat((97))) { |
10145 myType = this.type((1)); | 9904 myType = this.type((1)); |
10146 } | 9905 } |
10147 var tp = new TypeParameter(name, myType, this._makeSpan(start)); | 9906 var tp = new TypeParameter(name, myType, this._makeSpan(start)); |
10148 return new ParameterType(name.get$name(), tp); | 9907 return new ParameterType(name.get$name(), tp); |
10149 } | 9908 } |
10150 Parser.prototype.get$typeParameter = function() { | 9909 Parser.prototype.get$typeParameter = function() { |
10151 return this.typeParameter.bind(this); | 9910 return this.typeParameter.bind(this); |
10152 } | 9911 } |
10153 Parser.prototype.typeParameters = function() { | 9912 Parser.prototype.typeParameters = function() { |
10154 this._eat((52)); | 9913 this._eat((52)); |
10155 var closed = false; | 9914 var closed = false; |
10156 var ret = []; | 9915 var ret = []; |
10157 do { | 9916 do { |
10158 var tp = this.typeParameter(); | 9917 var tp = this.typeParameter(); |
10159 ret.add$1(tp); | 9918 ret.add(tp); |
10160 if ((tp.get$typeParameter().get$extendsType() instanceof GenericTypeReferenc
e) && $eq(tp.get$typeParameter().get$extendsType().get$dynamic().get$depth(), (0
))) { | 9919 if ((tp.get$typeParameter().get$extendsType() instanceof GenericTypeReferenc
e) && tp.get$typeParameter().get$extendsType().get$dynamic().get$depth() == (0))
{ |
10161 closed = true; | 9920 closed = true; |
10162 break; | 9921 break; |
10163 } | 9922 } |
10164 } | 9923 } |
10165 while (this._maybeEat((11))) | 9924 while (this._maybeEat((11))) |
10166 if (!closed) { | 9925 if (!closed) { |
10167 this._eat((53)); | 9926 this._eat((53)); |
10168 } | 9927 } |
10169 return ret; | 9928 return ret; |
10170 } | 9929 } |
(...skipping 16 matching lines...) Expand all Loading... |
10187 } | 9946 } |
10188 } | 9947 } |
10189 Parser.prototype.addTypeArguments = function(baseType, depth) { | 9948 Parser.prototype.addTypeArguments = function(baseType, depth) { |
10190 this._eat((52)); | 9949 this._eat((52)); |
10191 return this._finishTypeArguments(baseType, depth, []); | 9950 return this._finishTypeArguments(baseType, depth, []); |
10192 } | 9951 } |
10193 Parser.prototype._finishTypeArguments = function(baseType, depth, types) { | 9952 Parser.prototype._finishTypeArguments = function(baseType, depth, types) { |
10194 var delta = (-1); | 9953 var delta = (-1); |
10195 do { | 9954 do { |
10196 var myType = this.type(depth + (1)); | 9955 var myType = this.type(depth + (1)); |
10197 types.add$1(myType); | 9956 types.add(myType); |
10198 if ((myType instanceof GenericTypeReference) && myType.get$depth() <= depth)
{ | 9957 if ((myType instanceof GenericTypeReference) && myType.get$depth() <= depth)
{ |
10199 delta = depth - myType.get$depth(); | 9958 delta = depth - myType.get$depth(); |
10200 break; | 9959 break; |
10201 } | 9960 } |
10202 } | 9961 } |
10203 while (this._maybeEat((11))) | 9962 while (this._maybeEat((11))) |
10204 if (delta >= (0)) { | 9963 if ($gte(delta, (0))) { |
10205 depth = depth - delta; | 9964 depth = $sub(depth, delta); |
10206 } | 9965 } |
10207 else { | 9966 else { |
10208 depth = this._eatClosingAngle(depth); | 9967 depth = this._eatClosingAngle(depth); |
10209 } | 9968 } |
10210 var span = this._makeSpan(baseType.span.start); | 9969 var span = this._makeSpan(baseType.span.start); |
10211 return new GenericTypeReference(baseType, types, depth, span); | 9970 return new GenericTypeReference(baseType, types, depth, span); |
10212 } | 9971 } |
10213 Parser.prototype.typeList = function() { | 9972 Parser.prototype.typeList = function() { |
10214 var types = []; | 9973 var types = []; |
10215 do { | 9974 do { |
10216 types.add$1(this.type((0))); | 9975 types.add(this.type((0))); |
10217 } | 9976 } |
10218 while (this._maybeEat((11))) | 9977 while (this._maybeEat((11))) |
10219 return types; | 9978 return types; |
10220 } | 9979 } |
10221 Parser.prototype.nameTypeReference = function() { | 9980 Parser.prototype.nameTypeReference = function() { |
10222 var start = this._peekToken.start; | 9981 var start = this._peekToken.start; |
10223 var name; | 9982 var name; |
10224 var names = null; | 9983 var names = null; |
10225 var typeArgs = null; | 9984 var typeArgs = null; |
10226 var isFinal = false; | 9985 var isFinal = false; |
10227 switch (this._peek()) { | 9986 switch (this._peek()) { |
10228 case (115): | 9987 case (115): |
10229 | 9988 |
10230 return new TypeReference(this._lang_next().get$span(), $globals.world.void
Type); | 9989 return new SimpleTypeReference($globals.world.voidType, this._lang_next().
get$span()); |
10231 | 9990 |
10232 case (114): | 9991 case (114): |
10233 | 9992 |
10234 return new TypeReference(this._lang_next().get$span(), $globals.world.varT
ype); | 9993 return new SimpleTypeReference($globals.world.varType, this._lang_next().g
et$span()); |
10235 | 9994 |
10236 case (99): | 9995 case (99): |
10237 | 9996 |
10238 this._eat((99)); | 9997 this._eat((99)); |
10239 isFinal = true; | 9998 isFinal = true; |
10240 name = this.identifier(); | 9999 name = this.identifier(); |
10241 break; | 10000 break; |
10242 | 10001 |
10243 default: | 10002 default: |
10244 | 10003 |
10245 name = this.identifier(); | 10004 name = this.identifier(); |
10246 break; | 10005 break; |
10247 | 10006 |
10248 } | 10007 } |
10249 while (this._maybeEat((14))) { | 10008 while (this._maybeEat((14))) { |
10250 if (names == null) names = []; | 10009 if ($eq(names)) names = []; |
10251 names.add$1(this.identifier()); | 10010 names.add(this.identifier()); |
10252 } | 10011 } |
10253 return new NameTypeReference(isFinal, name, names, this._makeSpan(start)); | 10012 return new NameTypeReference(isFinal, name, names, this._makeSpan(start)); |
10254 } | 10013 } |
10255 Parser.prototype.type = function(depth) { | 10014 Parser.prototype.type = function(depth) { |
10256 var typeRef = this.nameTypeReference(); | 10015 var typeRef = this.nameTypeReference(); |
10257 if (this._peekKind((52))) { | 10016 if (this._peekKind((52))) { |
10258 return this.addTypeArguments(typeRef, depth); | 10017 return this.addTypeArguments(typeRef, depth); |
10259 } | 10018 } |
10260 else { | 10019 else { |
10261 return typeRef; | 10020 return typeRef; |
10262 } | 10021 } |
10263 } | 10022 } |
10264 Parser.prototype.type.$optional = ['depth', '(0)'] | 10023 Parser.prototype.type.$optional = ['depth', '(0)'] |
10265 Parser.prototype.get$type = function() { | 10024 Parser.prototype.get$type = function() { |
10266 return this.type.bind(this); | 10025 return this.type.bind(this); |
10267 } | 10026 } |
10268 Parser.prototype.formalParameter = function(inOptionalBlock) { | 10027 Parser.prototype.formalParameter = function(inOptionalBlock) { |
10269 var start = this._peekToken.start; | 10028 var start = this._peekToken.start; |
10270 var isThis = false; | 10029 var isThis = false; |
10271 var isRest = false; | 10030 var isRest = false; |
10272 var di = this.declaredIdentifier(false); | 10031 var di = this.declaredIdentifier(false); |
10273 var type = di.get$type(); | 10032 var type = di.get$type(); |
10274 var name = di.get$name(); | 10033 var name = di.get$name(); |
10275 if (name == null) { | 10034 if ($eq(name)) { |
10276 this._lang_error("Formal parameter invalid", this._makeSpan(start)); | 10035 this._lang_error("Formal parameter invalid", this._makeSpan(start)); |
10277 } | 10036 } |
10278 var value = null; | 10037 var value = null; |
10279 if (this._maybeEat((20))) { | 10038 if (this._maybeEat((20))) { |
10280 if (!inOptionalBlock) { | 10039 if (!inOptionalBlock) { |
10281 this._lang_error("default values only allowed inside [optional] section"); | 10040 this._lang_error("default values only allowed inside [optional] section"); |
10282 } | 10041 } |
10283 value = this.expression(); | 10042 value = this.expression(); |
10284 } | 10043 } |
10285 else if (this._peekKind((2))) { | 10044 else if (this._peekKind((2))) { |
10286 var formals = this.formalParameterList(); | 10045 var formals = this.formalParameterList(); |
10287 var func = new FunctionDefinition(null, type, name, formals, null, null, nul
l, this._makeSpan(start)); | 10046 var func = new FunctionDefinition(null, type, name, formals, null, null, nul
l, this._makeSpan(start)); |
10288 type = new FunctionTypeReference(false, func, func.get$span()); | 10047 type = new FunctionTypeReference(false, func, func.get$span()); |
10289 } | 10048 } |
10290 if (inOptionalBlock && value == null) { | 10049 if (inOptionalBlock && $eq(value)) { |
10291 value = this._makeLiteral(Value.fromNull(this._makeSpan(start))); | 10050 value = this._makeLiteral(Value.fromNull(this._makeSpan(start))); |
10292 } | 10051 } |
10293 return new FormalNode(isThis, isRest, type, name, value, this._makeSpan(start)
); | 10052 return new FormalNode(isThis, isRest, type, name, value, this._makeSpan(start)
); |
10294 } | 10053 } |
10295 Parser.prototype.formalParameterList = function() { | 10054 Parser.prototype.formalParameterList = function() { |
10296 this._eatLeftParen(); | 10055 this._eatLeftParen(); |
10297 var formals = []; | 10056 var formals = []; |
10298 var inOptionalBlock = false; | 10057 var inOptionalBlock = false; |
10299 if (!this._maybeEat((3))) { | 10058 if (!this._maybeEat((3))) { |
10300 if (this._maybeEat((4))) { | 10059 if (this._maybeEat((4))) { |
10301 inOptionalBlock = true; | 10060 inOptionalBlock = true; |
10302 } | 10061 } |
10303 formals.add$1(this.formalParameter(inOptionalBlock)); | 10062 formals.add(this.formalParameter(inOptionalBlock)); |
10304 while (this._maybeEat((11))) { | 10063 while (this._maybeEat((11))) { |
10305 if (this._maybeEat((4))) { | 10064 if (this._maybeEat((4))) { |
10306 if (inOptionalBlock) { | 10065 if (inOptionalBlock) { |
10307 this._lang_error("already inside an optional block", this._previousTok
en.get$span()); | 10066 this._lang_error("already inside an optional block", this._previousTok
en.get$span()); |
10308 } | 10067 } |
10309 inOptionalBlock = true; | 10068 inOptionalBlock = true; |
10310 } | 10069 } |
10311 formals.add$1(this.formalParameter(inOptionalBlock)); | 10070 formals.add(this.formalParameter(inOptionalBlock)); |
10312 } | 10071 } |
10313 if (inOptionalBlock) { | 10072 if (inOptionalBlock) { |
10314 this._eat((5)); | 10073 this._eat((5)); |
10315 } | 10074 } |
10316 this._eat((3)); | 10075 this._eat((3)); |
10317 } | 10076 } |
10318 return formals; | 10077 return formals; |
10319 } | 10078 } |
10320 Parser.prototype.identifierForType = function() { | 10079 Parser.prototype.identifierForType = function() { |
10321 var tok = this._lang_next(); | 10080 var tok = this._lang_next(); |
10322 if (!this._isIdentifier(tok.get$kind())) { | 10081 if (!this._isIdentifier(tok.get$kind())) { |
10323 this._lang_error(("expected identifier, but found " + tok), tok.get$span()); | 10082 this._lang_error(("expected identifier, but found " + tok), tok.get$span()); |
10324 } | 10083 } |
10325 if (tok.get$kind() != (70) && $ne(tok.get$kind(), (80))) { | 10084 if (tok.get$kind() != (70) && tok.get$kind() != (80)) { |
10326 this._lang_error(("" + tok + " may not be used as a type name"), tok.get$spa
n()); | 10085 this._lang_error(("" + tok + " may not be used as a type name"), tok.get$spa
n()); |
10327 } | 10086 } |
10328 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start())); | 10087 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start())); |
10329 } | 10088 } |
10330 Parser.prototype.identifier = function() { | 10089 Parser.prototype.identifier = function() { |
10331 var tok = this._lang_next(); | 10090 var tok = this._lang_next(); |
10332 if (!this._isIdentifier(tok.get$kind())) { | 10091 if (!this._isIdentifier(tok.get$kind())) { |
10333 this._lang_error(("expected identifier, but found " + tok), tok.get$span()); | 10092 this._lang_error(("expected identifier, but found " + tok), tok.get$span()); |
10334 } | 10093 } |
10335 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start())); | 10094 return new Identifier(tok.get$text(), this._makeSpan(tok.get$start())); |
10336 } | 10095 } |
10337 Parser.prototype._makeFunction = function(expr, formals, body) { | 10096 Parser.prototype._makeFunction = function(expr, formals, body) { |
10338 var name, type; | 10097 var name, type; |
10339 if ((expr instanceof VarExpression)) { | 10098 if ((expr instanceof VarExpression)) { |
10340 name = expr.get$name(); | 10099 name = expr.get$name(); |
10341 type = null; | 10100 type = null; |
10342 } | 10101 } |
10343 else if ((expr instanceof DeclaredIdentifier)) { | 10102 else if ((expr instanceof DeclaredIdentifier)) { |
10344 name = expr.get$name(); | 10103 name = expr.get$name(); |
10345 type = expr.get$type(); | 10104 type = expr.get$type(); |
10346 if (name == null) { | 10105 if ($eq(name)) { |
10347 this._lang_error("expected name and type", expr.get$span()); | 10106 this._lang_error("expected name and type", expr.get$span()); |
10348 } | 10107 } |
10349 } | 10108 } |
10350 else { | 10109 else { |
10351 this._lang_error("bad function body", expr.get$span()); | 10110 this._lang_error("bad function body", expr.get$span()); |
10352 } | 10111 } |
10353 var span = new SourceSpan(expr.get$span().get$file(), expr.get$span().get$star
t(), body.get$span().get$end()); | 10112 var span = new SourceSpan(expr.get$span().file, expr.get$span().start, body.ge
t$span().end); |
10354 var func = new FunctionDefinition(null, type, name, formals, null, null, body,
span); | 10113 var func = new FunctionDefinition(null, type, name, formals, null, null, body,
span); |
10355 return new LambdaExpression(func, func.get$span()); | 10114 return new LambdaExpression(func, func.get$span()); |
10356 } | 10115 } |
10357 Parser.prototype._makeDeclaredIdentifier = function(e) { | 10116 Parser.prototype._makeDeclaredIdentifier = function(e) { |
10358 if ((e instanceof VarExpression)) { | 10117 if ((e instanceof VarExpression)) { |
10359 return new DeclaredIdentifier(null, e.get$name(), e.get$span()); | 10118 return new DeclaredIdentifier(null, e.get$name(), e.get$span()); |
10360 } | 10119 } |
10361 else if ((e instanceof DeclaredIdentifier)) { | 10120 else if ((e instanceof DeclaredIdentifier)) { |
10362 return e; | 10121 return e; |
10363 } | 10122 } |
10364 else { | 10123 else { |
10365 this._lang_error("expected declared identifier"); | 10124 this._lang_error("expected declared identifier"); |
10366 return new DeclaredIdentifier(null, null, e.get$span()); | 10125 return new DeclaredIdentifier(null, null, e.get$span()); |
10367 } | 10126 } |
10368 } | 10127 } |
10369 Parser.prototype._makeLabel = function(expr) { | 10128 Parser.prototype._makeLabel = function(expr) { |
10370 if ((expr instanceof VarExpression)) { | 10129 if ((expr instanceof VarExpression)) { |
10371 return expr.get$name(); | 10130 return expr.get$name(); |
10372 } | 10131 } |
10373 else { | 10132 else { |
10374 this._errorExpected("label"); | 10133 this._errorExpected("label"); |
10375 return null; | 10134 return null; |
10376 } | 10135 } |
10377 } | 10136 } |
10378 Parser.prototype.block$0 = Parser.prototype.block; | |
10379 Parser.prototype.compilationUnit$0 = Parser.prototype.compilationUnit; | |
10380 // ********** Code for IncompleteSourceException ************** | 10137 // ********** Code for IncompleteSourceException ************** |
10381 function IncompleteSourceException(token) { | 10138 function IncompleteSourceException(token) { |
10382 this.token = token; | 10139 this.token = token; |
10383 } | 10140 } |
10384 IncompleteSourceException.prototype.toString = function() { | 10141 IncompleteSourceException.prototype.toString = function() { |
10385 if (this.token.get$span() == null) return ("Unexpected " + this.token); | 10142 if (this.token.get$span() == null) return ("Unexpected " + this.token); |
10386 return this.token.get$span().toMessageString(("Unexpected " + this.token)); | 10143 return this.token.get$span().toMessageString(("Unexpected " + this.token)); |
10387 } | 10144 } |
10388 IncompleteSourceException.prototype.toString$0 = IncompleteSourceException.proto
type.toString; | 10145 IncompleteSourceException.prototype.toString$0 = IncompleteSourceException.proto
type.toString; |
10389 // ********** Code for DivertedTokenSource ************** | 10146 // ********** Code for DivertedTokenSource ************** |
10390 function DivertedTokenSource(tokens, parser, previousTokenizer) { | 10147 function DivertedTokenSource(tokens, parser, previousTokenizer) { |
10391 this.parser = parser; | 10148 this.parser = parser; |
10392 this._lang_pos = (0); | 10149 this._lang_pos = (0); |
10393 this.tokens = tokens; | 10150 this.tokens = tokens; |
10394 this.previousTokenizer = previousTokenizer; | 10151 this.previousTokenizer = previousTokenizer; |
10395 } | 10152 } |
10396 DivertedTokenSource.prototype.next = function() { | 10153 DivertedTokenSource.prototype.next = function() { |
10397 var token = this.tokens[this._lang_pos]; | 10154 var token = this.tokens[this._lang_pos]; |
10398 ++this._lang_pos; | 10155 ++this._lang_pos; |
10399 if (this._lang_pos == this.tokens.get$length()) { | 10156 if (this._lang_pos == this.tokens.get$length()) { |
10400 this.parser.tokenizer = this.previousTokenizer; | 10157 this.parser.tokenizer = this.previousTokenizer; |
10401 } | 10158 } |
10402 return token; | 10159 return token; |
10403 } | 10160 } |
10404 DivertedTokenSource.prototype.next$0 = DivertedTokenSource.prototype.next; | |
10405 // ********** Code for Node ************** | 10161 // ********** Code for Node ************** |
10406 function Node(span) { | 10162 function Node(span) { |
10407 this.span = span; | 10163 this.span = span; |
10408 } | 10164 } |
10409 Node.prototype.get$span = function() { return this.span; }; | 10165 Node.prototype.get$span = function() { return this.span; }; |
10410 Node.prototype.set$span = function(value) { return this.span = value; }; | 10166 Node.prototype.set$span = function(value) { return this.span = value; }; |
10411 Node.prototype.visit$1 = Node.prototype.visit; | |
10412 // ********** Code for Statement ************** | 10167 // ********** Code for Statement ************** |
10413 $inherits(Statement, Node); | 10168 $inherits(Statement, Node); |
10414 function Statement(span) { | 10169 function Statement(span) { |
10415 Node.call(this, span); | 10170 Node.call(this, span); |
10416 } | 10171 } |
10417 // ********** Code for Definition ************** | 10172 // ********** Code for Definition ************** |
10418 $inherits(Definition, Statement); | 10173 $inherits(Definition, Statement); |
10419 function Definition(span) { | 10174 function Definition(span) { |
10420 Statement.call(this, span); | 10175 Statement.call(this, span); |
10421 } | 10176 } |
10422 Definition.prototype.get$typeParameters = function() { | 10177 Definition.prototype.get$typeParameters = function() { |
10423 return null; | 10178 return null; |
10424 } | 10179 } |
10425 Definition.prototype.get$nativeType = function() { | 10180 Definition.prototype.get$nativeType = function() { |
10426 return null; | 10181 return null; |
10427 } | 10182 } |
10428 // ********** Code for Expression ************** | 10183 // ********** Code for Expression ************** |
10429 $inherits(Expression, Node); | 10184 $inherits(Expression, Node); |
10430 function Expression(span) { | 10185 function Expression(span) { |
10431 Node.call(this, span); | 10186 Node.call(this, span); |
10432 } | 10187 } |
10433 // ********** Code for TypeReference ************** | 10188 // ********** Code for TypeReference ************** |
10434 $inherits(TypeReference, Node); | 10189 $inherits(TypeReference, Node); |
10435 function TypeReference(span, type) { | 10190 function TypeReference(span) { |
10436 this.type = type; | |
10437 Node.call(this, span); | 10191 Node.call(this, span); |
10438 } | 10192 } |
10439 TypeReference.prototype.get$type = function() { return this.type; }; | |
10440 TypeReference.prototype.set$type = function(value) { return this.type = value; }
; | |
10441 TypeReference.prototype.visit = function(visitor) { | |
10442 return visitor.visitTypeReference(this); | |
10443 } | |
10444 TypeReference.prototype.get$isFinal = function() { | |
10445 return false; | |
10446 } | |
10447 TypeReference.prototype.visit$1 = TypeReference.prototype.visit; | |
10448 // ********** Code for DirectiveDefinition ************** | 10193 // ********** Code for DirectiveDefinition ************** |
10449 $inherits(DirectiveDefinition, Definition); | 10194 $inherits(DirectiveDefinition, Definition); |
10450 function DirectiveDefinition(name, arguments, span) { | 10195 function DirectiveDefinition(name, arguments, span) { |
10451 this.arguments = arguments; | 10196 this.arguments = arguments; |
10452 this.name = name; | 10197 this.name = name; |
10453 Definition.call(this, span); | 10198 Definition.call(this, span); |
10454 } | 10199 } |
10455 DirectiveDefinition.prototype.get$name = function() { return this.name; }; | 10200 DirectiveDefinition.prototype.get$name = function() { return this.name; }; |
10456 DirectiveDefinition.prototype.set$name = function(value) { return this.name = va
lue; }; | 10201 DirectiveDefinition.prototype.set$name = function(value) { return this.name = va
lue; }; |
10457 DirectiveDefinition.prototype.visit = function(visitor) { | 10202 DirectiveDefinition.prototype.visit = function(visitor) { |
10458 return visitor.visitDirectiveDefinition(this); | 10203 return visitor.visitDirectiveDefinition(this); |
10459 } | 10204 } |
10460 DirectiveDefinition.prototype.visit$1 = DirectiveDefinition.prototype.visit; | |
10461 // ********** Code for TypeDefinition ************** | 10205 // ********** Code for TypeDefinition ************** |
10462 $inherits(TypeDefinition, Definition); | 10206 $inherits(TypeDefinition, Definition); |
10463 function TypeDefinition(isClass, name, typeParameters, extendsTypes, implementsT
ypes, nativeType, defaultType, body, span) { | 10207 function TypeDefinition(isClass, name, typeParameters, extendsTypes, implementsT
ypes, nativeType, defaultType, body, span) { |
10464 this.extendsTypes = extendsTypes; | 10208 this.extendsTypes = extendsTypes; |
10465 this.isClass = isClass; | 10209 this.isClass = isClass; |
10466 this.name = name; | 10210 this.name = name; |
10467 this.body = body; | 10211 this.body = body; |
10468 this.typeParameters = typeParameters; | 10212 this.typeParameters = typeParameters; |
10469 this.nativeType = nativeType; | 10213 this.nativeType = nativeType; |
10470 this.implementsTypes = implementsTypes; | 10214 this.implementsTypes = implementsTypes; |
10471 this.defaultType = defaultType; | 10215 this.defaultType = defaultType; |
10472 Definition.call(this, span); | 10216 Definition.call(this, span); |
10473 } | 10217 } |
10474 TypeDefinition.prototype.get$isClass = function() { return this.isClass; }; | 10218 TypeDefinition.prototype.get$isClass = function() { return this.isClass; }; |
10475 TypeDefinition.prototype.set$isClass = function(value) { return this.isClass = v
alue; }; | 10219 TypeDefinition.prototype.set$isClass = function(value) { return this.isClass = v
alue; }; |
10476 TypeDefinition.prototype.get$name = function() { return this.name; }; | 10220 TypeDefinition.prototype.get$name = function() { return this.name; }; |
10477 TypeDefinition.prototype.set$name = function(value) { return this.name = value;
}; | 10221 TypeDefinition.prototype.set$name = function(value) { return this.name = value;
}; |
10478 TypeDefinition.prototype.get$typeParameters = function() { return this.typeParam
eters; }; | 10222 TypeDefinition.prototype.get$typeParameters = function() { return this.typeParam
eters; }; |
10479 TypeDefinition.prototype.set$typeParameters = function(value) { return this.type
Parameters = value; }; | 10223 TypeDefinition.prototype.set$typeParameters = function(value) { return this.type
Parameters = value; }; |
10480 TypeDefinition.prototype.get$nativeType = function() { return this.nativeType; }
; | 10224 TypeDefinition.prototype.get$nativeType = function() { return this.nativeType; }
; |
10481 TypeDefinition.prototype.set$nativeType = function(value) { return this.nativeTy
pe = value; }; | 10225 TypeDefinition.prototype.set$nativeType = function(value) { return this.nativeTy
pe = value; }; |
10482 TypeDefinition.prototype.get$body = function() { return this.body; }; | 10226 TypeDefinition.prototype.get$body = function() { return this.body; }; |
10483 TypeDefinition.prototype.set$body = function(value) { return this.body = value;
}; | 10227 TypeDefinition.prototype.set$body = function(value) { return this.body = value;
}; |
10484 TypeDefinition.prototype.visit = function(visitor) { | 10228 TypeDefinition.prototype.visit = function(visitor) { |
10485 return visitor.visitTypeDefinition(this); | 10229 return visitor.visitTypeDefinition(this); |
10486 } | 10230 } |
10487 TypeDefinition.prototype.visit$1 = TypeDefinition.prototype.visit; | |
10488 // ********** Code for FunctionTypeDefinition ************** | 10231 // ********** Code for FunctionTypeDefinition ************** |
10489 $inherits(FunctionTypeDefinition, Definition); | 10232 $inherits(FunctionTypeDefinition, Definition); |
10490 function FunctionTypeDefinition(func, typeParameters, span) { | 10233 function FunctionTypeDefinition(func, typeParameters, span) { |
10491 this.typeParameters = typeParameters; | 10234 this.typeParameters = typeParameters; |
10492 this.func = func; | 10235 this.func = func; |
10493 Definition.call(this, span); | 10236 Definition.call(this, span); |
10494 } | 10237 } |
10495 FunctionTypeDefinition.prototype.get$func = function() { return this.func; }; | 10238 FunctionTypeDefinition.prototype.get$func = function() { return this.func; }; |
10496 FunctionTypeDefinition.prototype.set$func = function(value) { return this.func =
value; }; | 10239 FunctionTypeDefinition.prototype.set$func = function(value) { return this.func =
value; }; |
10497 FunctionTypeDefinition.prototype.get$typeParameters = function() { return this.t
ypeParameters; }; | 10240 FunctionTypeDefinition.prototype.get$typeParameters = function() { return this.t
ypeParameters; }; |
10498 FunctionTypeDefinition.prototype.set$typeParameters = function(value) { return t
his.typeParameters = value; }; | 10241 FunctionTypeDefinition.prototype.set$typeParameters = function(value) { return t
his.typeParameters = value; }; |
10499 FunctionTypeDefinition.prototype.visit = function(visitor) { | 10242 FunctionTypeDefinition.prototype.visit = function(visitor) { |
10500 return visitor.visitFunctionTypeDefinition(this); | 10243 return visitor.visitFunctionTypeDefinition(this); |
10501 } | 10244 } |
10502 FunctionTypeDefinition.prototype.visit$1 = FunctionTypeDefinition.prototype.visi
t; | |
10503 // ********** Code for VariableDefinition ************** | 10245 // ********** Code for VariableDefinition ************** |
10504 $inherits(VariableDefinition, Definition); | 10246 $inherits(VariableDefinition, Definition); |
10505 function VariableDefinition(modifiers, type, names, values, span) { | 10247 function VariableDefinition(modifiers, type, names, values, span) { |
10506 this.modifiers = modifiers; | 10248 this.modifiers = modifiers; |
10507 this.type = type; | 10249 this.type = type; |
10508 this.names = names; | 10250 this.names = names; |
10509 this.values = values; | 10251 this.values = values; |
10510 Definition.call(this, span); | 10252 Definition.call(this, span); |
10511 } | 10253 } |
10512 VariableDefinition.prototype.get$type = function() { return this.type; }; | 10254 VariableDefinition.prototype.get$type = function() { return this.type; }; |
10513 VariableDefinition.prototype.set$type = function(value) { return this.type = val
ue; }; | 10255 VariableDefinition.prototype.set$type = function(value) { return this.type = val
ue; }; |
10514 VariableDefinition.prototype.get$names = function() { return this.names; }; | 10256 VariableDefinition.prototype.get$names = function() { return this.names; }; |
10515 VariableDefinition.prototype.set$names = function(value) { return this.names = v
alue; }; | 10257 VariableDefinition.prototype.set$names = function(value) { return this.names = v
alue; }; |
10516 VariableDefinition.prototype.visit = function(visitor) { | 10258 VariableDefinition.prototype.visit = function(visitor) { |
10517 return visitor.visitVariableDefinition$1(this); | 10259 return visitor.visitVariableDefinition(this); |
10518 } | 10260 } |
10519 VariableDefinition.prototype.visit$1 = VariableDefinition.prototype.visit; | |
10520 // ********** Code for FunctionDefinition ************** | 10261 // ********** Code for FunctionDefinition ************** |
10521 $inherits(FunctionDefinition, Definition); | 10262 $inherits(FunctionDefinition, Definition); |
10522 function FunctionDefinition(modifiers, returnType, name, formals, initializers,
nativeBody, body, span) { | 10263 function FunctionDefinition(modifiers, returnType, name, formals, initializers,
nativeBody, body, span) { |
10523 this.modifiers = modifiers; | 10264 this.modifiers = modifiers; |
10524 this.name = name; | 10265 this.name = name; |
10525 this.initializers = initializers; | 10266 this.initializers = initializers; |
10526 this.body = body; | 10267 this.body = body; |
10527 this.returnType = returnType; | 10268 this.returnType = returnType; |
10528 this.formals = formals; | 10269 this.formals = formals; |
10529 this.nativeBody = nativeBody; | 10270 this.nativeBody = nativeBody; |
10530 Definition.call(this, span); | 10271 Definition.call(this, span); |
10531 } | 10272 } |
10532 FunctionDefinition.prototype.get$returnType = function() { return this.returnTyp
e; }; | 10273 FunctionDefinition.prototype.get$returnType = function() { return this.returnTyp
e; }; |
10533 FunctionDefinition.prototype.set$returnType = function(value) { return this.retu
rnType = value; }; | 10274 FunctionDefinition.prototype.set$returnType = function(value) { return this.retu
rnType = value; }; |
10534 FunctionDefinition.prototype.get$name = function() { return this.name; }; | 10275 FunctionDefinition.prototype.get$name = function() { return this.name; }; |
10535 FunctionDefinition.prototype.set$name = function(value) { return this.name = val
ue; }; | 10276 FunctionDefinition.prototype.set$name = function(value) { return this.name = val
ue; }; |
10536 FunctionDefinition.prototype.get$initializers = function() { return this.initial
izers; }; | 10277 FunctionDefinition.prototype.get$initializers = function() { return this.initial
izers; }; |
10537 FunctionDefinition.prototype.set$initializers = function(value) { return this.in
itializers = value; }; | 10278 FunctionDefinition.prototype.set$initializers = function(value) { return this.in
itializers = value; }; |
10538 FunctionDefinition.prototype.get$nativeBody = function() { return this.nativeBod
y; }; | |
10539 FunctionDefinition.prototype.set$nativeBody = function(value) { return this.nati
veBody = value; }; | |
10540 FunctionDefinition.prototype.get$body = function() { return this.body; }; | 10279 FunctionDefinition.prototype.get$body = function() { return this.body; }; |
10541 FunctionDefinition.prototype.set$body = function(value) { return this.body = val
ue; }; | 10280 FunctionDefinition.prototype.set$body = function(value) { return this.body = val
ue; }; |
10542 FunctionDefinition.prototype.visit = function(visitor) { | 10281 FunctionDefinition.prototype.visit = function(visitor) { |
10543 return visitor.visitFunctionDefinition$1(this); | 10282 return visitor.visitFunctionDefinition(this); |
10544 } | 10283 } |
10545 FunctionDefinition.prototype.visit$1 = FunctionDefinition.prototype.visit; | |
10546 // ********** Code for ReturnStatement ************** | 10284 // ********** Code for ReturnStatement ************** |
10547 $inherits(ReturnStatement, Statement); | 10285 $inherits(ReturnStatement, Statement); |
10548 function ReturnStatement(value, span) { | 10286 function ReturnStatement(value, span) { |
10549 this.value = value; | 10287 this.value = value; |
10550 Statement.call(this, span); | 10288 Statement.call(this, span); |
10551 } | 10289 } |
10552 ReturnStatement.prototype.get$value = function() { return this.value; }; | 10290 ReturnStatement.prototype.get$value = function() { return this.value; }; |
10553 ReturnStatement.prototype.set$value = function(value) { return this.value = valu
e; }; | 10291 ReturnStatement.prototype.set$value = function(value) { return this.value = valu
e; }; |
10554 ReturnStatement.prototype.visit = function(visitor) { | 10292 ReturnStatement.prototype.visit = function(visitor) { |
10555 return visitor.visitReturnStatement$1(this); | 10293 return visitor.visitReturnStatement(this); |
10556 } | 10294 } |
10557 ReturnStatement.prototype.visit$1 = ReturnStatement.prototype.visit; | |
10558 // ********** Code for ThrowStatement ************** | 10295 // ********** Code for ThrowStatement ************** |
10559 $inherits(ThrowStatement, Statement); | 10296 $inherits(ThrowStatement, Statement); |
10560 function ThrowStatement(value, span) { | 10297 function ThrowStatement(value, span) { |
10561 this.value = value; | 10298 this.value = value; |
10562 Statement.call(this, span); | 10299 Statement.call(this, span); |
10563 } | 10300 } |
10564 ThrowStatement.prototype.get$value = function() { return this.value; }; | 10301 ThrowStatement.prototype.get$value = function() { return this.value; }; |
10565 ThrowStatement.prototype.set$value = function(value) { return this.value = value
; }; | 10302 ThrowStatement.prototype.set$value = function(value) { return this.value = value
; }; |
10566 ThrowStatement.prototype.visit = function(visitor) { | 10303 ThrowStatement.prototype.visit = function(visitor) { |
10567 return visitor.visitThrowStatement$1(this); | 10304 return visitor.visitThrowStatement(this); |
10568 } | 10305 } |
10569 ThrowStatement.prototype.visit$1 = ThrowStatement.prototype.visit; | |
10570 // ********** Code for AssertStatement ************** | 10306 // ********** Code for AssertStatement ************** |
10571 $inherits(AssertStatement, Statement); | 10307 $inherits(AssertStatement, Statement); |
10572 function AssertStatement(test, span) { | 10308 function AssertStatement(test, span) { |
10573 this.test = test; | 10309 this.test = test; |
10574 Statement.call(this, span); | 10310 Statement.call(this, span); |
10575 } | 10311 } |
10576 AssertStatement.prototype.visit = function(visitor) { | 10312 AssertStatement.prototype.visit = function(visitor) { |
10577 return visitor.visitAssertStatement$1(this); | 10313 return visitor.visitAssertStatement(this); |
10578 } | 10314 } |
10579 AssertStatement.prototype.visit$1 = AssertStatement.prototype.visit; | |
10580 // ********** Code for BreakStatement ************** | 10315 // ********** Code for BreakStatement ************** |
10581 $inherits(BreakStatement, Statement); | 10316 $inherits(BreakStatement, Statement); |
10582 function BreakStatement(label, span) { | 10317 function BreakStatement(label, span) { |
10583 this.label = label; | 10318 this.label = label; |
10584 Statement.call(this, span); | 10319 Statement.call(this, span); |
10585 } | 10320 } |
10586 BreakStatement.prototype.get$label = function() { return this.label; }; | 10321 BreakStatement.prototype.get$label = function() { return this.label; }; |
10587 BreakStatement.prototype.set$label = function(value) { return this.label = value
; }; | 10322 BreakStatement.prototype.set$label = function(value) { return this.label = value
; }; |
10588 BreakStatement.prototype.visit = function(visitor) { | 10323 BreakStatement.prototype.visit = function(visitor) { |
10589 return visitor.visitBreakStatement$1(this); | 10324 return visitor.visitBreakStatement(this); |
10590 } | 10325 } |
10591 BreakStatement.prototype.visit$1 = BreakStatement.prototype.visit; | |
10592 // ********** Code for ContinueStatement ************** | 10326 // ********** Code for ContinueStatement ************** |
10593 $inherits(ContinueStatement, Statement); | 10327 $inherits(ContinueStatement, Statement); |
10594 function ContinueStatement(label, span) { | 10328 function ContinueStatement(label, span) { |
10595 this.label = label; | 10329 this.label = label; |
10596 Statement.call(this, span); | 10330 Statement.call(this, span); |
10597 } | 10331 } |
10598 ContinueStatement.prototype.get$label = function() { return this.label; }; | 10332 ContinueStatement.prototype.get$label = function() { return this.label; }; |
10599 ContinueStatement.prototype.set$label = function(value) { return this.label = va
lue; }; | 10333 ContinueStatement.prototype.set$label = function(value) { return this.label = va
lue; }; |
10600 ContinueStatement.prototype.visit = function(visitor) { | 10334 ContinueStatement.prototype.visit = function(visitor) { |
10601 return visitor.visitContinueStatement$1(this); | 10335 return visitor.visitContinueStatement(this); |
10602 } | 10336 } |
10603 ContinueStatement.prototype.visit$1 = ContinueStatement.prototype.visit; | |
10604 // ********** Code for IfStatement ************** | 10337 // ********** Code for IfStatement ************** |
10605 $inherits(IfStatement, Statement); | 10338 $inherits(IfStatement, Statement); |
10606 function IfStatement(test, trueBranch, falseBranch, span) { | 10339 function IfStatement(test, trueBranch, falseBranch, span) { |
10607 this.test = test; | 10340 this.test = test; |
10608 this.falseBranch = falseBranch; | 10341 this.falseBranch = falseBranch; |
10609 this.trueBranch = trueBranch; | 10342 this.trueBranch = trueBranch; |
10610 Statement.call(this, span); | 10343 Statement.call(this, span); |
10611 } | 10344 } |
10612 IfStatement.prototype.visit = function(visitor) { | 10345 IfStatement.prototype.visit = function(visitor) { |
10613 return visitor.visitIfStatement$1(this); | 10346 return visitor.visitIfStatement(this); |
10614 } | 10347 } |
10615 IfStatement.prototype.visit$1 = IfStatement.prototype.visit; | |
10616 // ********** Code for WhileStatement ************** | 10348 // ********** Code for WhileStatement ************** |
10617 $inherits(WhileStatement, Statement); | 10349 $inherits(WhileStatement, Statement); |
10618 function WhileStatement(test, body, span) { | 10350 function WhileStatement(test, body, span) { |
10619 this.body = body; | 10351 this.body = body; |
10620 this.test = test; | 10352 this.test = test; |
10621 Statement.call(this, span); | 10353 Statement.call(this, span); |
10622 } | 10354 } |
10623 WhileStatement.prototype.get$body = function() { return this.body; }; | 10355 WhileStatement.prototype.get$body = function() { return this.body; }; |
10624 WhileStatement.prototype.set$body = function(value) { return this.body = value;
}; | 10356 WhileStatement.prototype.set$body = function(value) { return this.body = value;
}; |
10625 WhileStatement.prototype.visit = function(visitor) { | 10357 WhileStatement.prototype.visit = function(visitor) { |
10626 return visitor.visitWhileStatement$1(this); | 10358 return visitor.visitWhileStatement(this); |
10627 } | 10359 } |
10628 WhileStatement.prototype.visit$1 = WhileStatement.prototype.visit; | |
10629 // ********** Code for DoStatement ************** | 10360 // ********** Code for DoStatement ************** |
10630 $inherits(DoStatement, Statement); | 10361 $inherits(DoStatement, Statement); |
10631 function DoStatement(body, test, span) { | 10362 function DoStatement(body, test, span) { |
10632 this.body = body; | 10363 this.body = body; |
10633 this.test = test; | 10364 this.test = test; |
10634 Statement.call(this, span); | 10365 Statement.call(this, span); |
10635 } | 10366 } |
10636 DoStatement.prototype.get$body = function() { return this.body; }; | 10367 DoStatement.prototype.get$body = function() { return this.body; }; |
10637 DoStatement.prototype.set$body = function(value) { return this.body = value; }; | 10368 DoStatement.prototype.set$body = function(value) { return this.body = value; }; |
10638 DoStatement.prototype.visit = function(visitor) { | 10369 DoStatement.prototype.visit = function(visitor) { |
10639 return visitor.visitDoStatement$1(this); | 10370 return visitor.visitDoStatement(this); |
10640 } | 10371 } |
10641 DoStatement.prototype.visit$1 = DoStatement.prototype.visit; | |
10642 // ********** Code for ForStatement ************** | 10372 // ********** Code for ForStatement ************** |
10643 $inherits(ForStatement, Statement); | 10373 $inherits(ForStatement, Statement); |
10644 function ForStatement(init, test, step, body, span) { | 10374 function ForStatement(init, test, step, body, span) { |
10645 this.body = body; | 10375 this.body = body; |
10646 this.test = test; | 10376 this.test = test; |
10647 this.step = step; | 10377 this.step = step; |
10648 this.init = init; | 10378 this.init = init; |
10649 Statement.call(this, span); | 10379 Statement.call(this, span); |
10650 } | 10380 } |
10651 ForStatement.prototype.get$body = function() { return this.body; }; | 10381 ForStatement.prototype.get$body = function() { return this.body; }; |
10652 ForStatement.prototype.set$body = function(value) { return this.body = value; }; | 10382 ForStatement.prototype.set$body = function(value) { return this.body = value; }; |
10653 ForStatement.prototype.visit = function(visitor) { | 10383 ForStatement.prototype.visit = function(visitor) { |
10654 return visitor.visitForStatement$1(this); | 10384 return visitor.visitForStatement(this); |
10655 } | 10385 } |
10656 ForStatement.prototype.visit$1 = ForStatement.prototype.visit; | |
10657 // ********** Code for ForInStatement ************** | 10386 // ********** Code for ForInStatement ************** |
10658 $inherits(ForInStatement, Statement); | 10387 $inherits(ForInStatement, Statement); |
10659 function ForInStatement(item, list, body, span) { | 10388 function ForInStatement(item, list, body, span) { |
10660 this.body = body; | 10389 this.body = body; |
10661 this.item = item; | 10390 this.item = item; |
10662 this.list = list; | 10391 this.list = list; |
10663 Statement.call(this, span); | 10392 Statement.call(this, span); |
10664 } | 10393 } |
10665 ForInStatement.prototype.get$body = function() { return this.body; }; | 10394 ForInStatement.prototype.get$body = function() { return this.body; }; |
10666 ForInStatement.prototype.set$body = function(value) { return this.body = value;
}; | 10395 ForInStatement.prototype.set$body = function(value) { return this.body = value;
}; |
10667 ForInStatement.prototype.visit = function(visitor) { | 10396 ForInStatement.prototype.visit = function(visitor) { |
10668 return visitor.visitForInStatement$1(this); | 10397 return visitor.visitForInStatement(this); |
10669 } | 10398 } |
10670 ForInStatement.prototype.visit$1 = ForInStatement.prototype.visit; | |
10671 // ********** Code for TryStatement ************** | 10399 // ********** Code for TryStatement ************** |
10672 $inherits(TryStatement, Statement); | 10400 $inherits(TryStatement, Statement); |
10673 function TryStatement(body, catches, finallyBlock, span) { | 10401 function TryStatement(body, catches, finallyBlock, span) { |
10674 this.body = body; | 10402 this.body = body; |
10675 this.finallyBlock = finallyBlock; | 10403 this.finallyBlock = finallyBlock; |
10676 this.catches = catches; | 10404 this.catches = catches; |
10677 Statement.call(this, span); | 10405 Statement.call(this, span); |
10678 } | 10406 } |
10679 TryStatement.prototype.get$body = function() { return this.body; }; | 10407 TryStatement.prototype.get$body = function() { return this.body; }; |
10680 TryStatement.prototype.set$body = function(value) { return this.body = value; }; | 10408 TryStatement.prototype.set$body = function(value) { return this.body = value; }; |
10681 TryStatement.prototype.visit = function(visitor) { | 10409 TryStatement.prototype.visit = function(visitor) { |
10682 return visitor.visitTryStatement$1(this); | 10410 return visitor.visitTryStatement(this); |
10683 } | 10411 } |
10684 TryStatement.prototype.visit$1 = TryStatement.prototype.visit; | |
10685 // ********** Code for SwitchStatement ************** | 10412 // ********** Code for SwitchStatement ************** |
10686 $inherits(SwitchStatement, Statement); | 10413 $inherits(SwitchStatement, Statement); |
10687 function SwitchStatement(test, cases, span) { | 10414 function SwitchStatement(test, cases, span) { |
10688 this.test = test; | 10415 this.test = test; |
10689 this.cases = cases; | 10416 this.cases = cases; |
10690 Statement.call(this, span); | 10417 Statement.call(this, span); |
10691 } | 10418 } |
10692 SwitchStatement.prototype.get$cases = function() { return this.cases; }; | 10419 SwitchStatement.prototype.get$cases = function() { return this.cases; }; |
10693 SwitchStatement.prototype.set$cases = function(value) { return this.cases = valu
e; }; | 10420 SwitchStatement.prototype.set$cases = function(value) { return this.cases = valu
e; }; |
10694 SwitchStatement.prototype.visit = function(visitor) { | 10421 SwitchStatement.prototype.visit = function(visitor) { |
10695 return visitor.visitSwitchStatement$1(this); | 10422 return visitor.visitSwitchStatement(this); |
10696 } | 10423 } |
10697 SwitchStatement.prototype.visit$1 = SwitchStatement.prototype.visit; | |
10698 // ********** Code for BlockStatement ************** | 10424 // ********** Code for BlockStatement ************** |
10699 $inherits(BlockStatement, Statement); | 10425 $inherits(BlockStatement, Statement); |
10700 function BlockStatement(body, span) { | 10426 function BlockStatement(body, span) { |
10701 this.body = body; | 10427 this.body = body; |
10702 Statement.call(this, span); | 10428 Statement.call(this, span); |
10703 } | 10429 } |
10704 BlockStatement.prototype.get$body = function() { return this.body; }; | 10430 BlockStatement.prototype.get$body = function() { return this.body; }; |
10705 BlockStatement.prototype.set$body = function(value) { return this.body = value;
}; | 10431 BlockStatement.prototype.set$body = function(value) { return this.body = value;
}; |
10706 BlockStatement.prototype.visit = function(visitor) { | 10432 BlockStatement.prototype.visit = function(visitor) { |
10707 return visitor.visitBlockStatement$1(this); | 10433 return visitor.visitBlockStatement(this); |
10708 } | 10434 } |
10709 BlockStatement.prototype.visit$1 = BlockStatement.prototype.visit; | |
10710 // ********** Code for LabeledStatement ************** | 10435 // ********** Code for LabeledStatement ************** |
10711 $inherits(LabeledStatement, Statement); | 10436 $inherits(LabeledStatement, Statement); |
10712 function LabeledStatement(name, body, span) { | 10437 function LabeledStatement(name, body, span) { |
10713 this.body = body; | 10438 this.body = body; |
10714 this.name = name; | 10439 this.name = name; |
10715 Statement.call(this, span); | 10440 Statement.call(this, span); |
10716 } | 10441 } |
10717 LabeledStatement.prototype.get$name = function() { return this.name; }; | 10442 LabeledStatement.prototype.get$name = function() { return this.name; }; |
10718 LabeledStatement.prototype.set$name = function(value) { return this.name = value
; }; | 10443 LabeledStatement.prototype.set$name = function(value) { return this.name = value
; }; |
10719 LabeledStatement.prototype.get$body = function() { return this.body; }; | 10444 LabeledStatement.prototype.get$body = function() { return this.body; }; |
10720 LabeledStatement.prototype.set$body = function(value) { return this.body = value
; }; | 10445 LabeledStatement.prototype.set$body = function(value) { return this.body = value
; }; |
10721 LabeledStatement.prototype.visit = function(visitor) { | 10446 LabeledStatement.prototype.visit = function(visitor) { |
10722 return visitor.visitLabeledStatement$1(this); | 10447 return visitor.visitLabeledStatement(this); |
10723 } | 10448 } |
10724 LabeledStatement.prototype.visit$1 = LabeledStatement.prototype.visit; | |
10725 // ********** Code for ExpressionStatement ************** | 10449 // ********** Code for ExpressionStatement ************** |
10726 $inherits(ExpressionStatement, Statement); | 10450 $inherits(ExpressionStatement, Statement); |
10727 function ExpressionStatement(body, span) { | 10451 function ExpressionStatement(body, span) { |
10728 this.body = body; | 10452 this.body = body; |
10729 Statement.call(this, span); | 10453 Statement.call(this, span); |
10730 } | 10454 } |
10731 ExpressionStatement.prototype.get$body = function() { return this.body; }; | 10455 ExpressionStatement.prototype.get$body = function() { return this.body; }; |
10732 ExpressionStatement.prototype.set$body = function(value) { return this.body = va
lue; }; | 10456 ExpressionStatement.prototype.set$body = function(value) { return this.body = va
lue; }; |
10733 ExpressionStatement.prototype.visit = function(visitor) { | 10457 ExpressionStatement.prototype.visit = function(visitor) { |
10734 return visitor.visitExpressionStatement$1(this); | 10458 return visitor.visitExpressionStatement(this); |
10735 } | 10459 } |
10736 ExpressionStatement.prototype.visit$1 = ExpressionStatement.prototype.visit; | |
10737 // ********** Code for EmptyStatement ************** | 10460 // ********** Code for EmptyStatement ************** |
10738 $inherits(EmptyStatement, Statement); | 10461 $inherits(EmptyStatement, Statement); |
10739 function EmptyStatement(span) { | 10462 function EmptyStatement(span) { |
10740 Statement.call(this, span); | 10463 Statement.call(this, span); |
10741 } | 10464 } |
10742 EmptyStatement.prototype.visit = function(visitor) { | 10465 EmptyStatement.prototype.visit = function(visitor) { |
10743 return visitor.visitEmptyStatement$1(this); | 10466 return visitor.visitEmptyStatement(this); |
10744 } | 10467 } |
10745 EmptyStatement.prototype.visit$1 = EmptyStatement.prototype.visit; | |
10746 // ********** Code for DietStatement ************** | 10468 // ********** Code for DietStatement ************** |
10747 $inherits(DietStatement, Statement); | 10469 $inherits(DietStatement, Statement); |
10748 function DietStatement(span) { | 10470 function DietStatement(span) { |
10749 Statement.call(this, span); | 10471 Statement.call(this, span); |
10750 } | 10472 } |
10751 DietStatement.prototype.visit = function(visitor) { | 10473 DietStatement.prototype.visit = function(visitor) { |
10752 return visitor.visitDietStatement$1(this); | 10474 return visitor.visitDietStatement(this); |
10753 } | 10475 } |
10754 DietStatement.prototype.visit$1 = DietStatement.prototype.visit; | |
10755 // ********** Code for LambdaExpression ************** | 10476 // ********** Code for LambdaExpression ************** |
10756 $inherits(LambdaExpression, Expression); | 10477 $inherits(LambdaExpression, Expression); |
10757 function LambdaExpression(func, span) { | 10478 function LambdaExpression(func, span) { |
10758 this.func = func; | 10479 this.func = func; |
10759 Expression.call(this, span); | 10480 Expression.call(this, span); |
10760 } | 10481 } |
10761 LambdaExpression.prototype.get$func = function() { return this.func; }; | 10482 LambdaExpression.prototype.get$func = function() { return this.func; }; |
10762 LambdaExpression.prototype.set$func = function(value) { return this.func = value
; }; | 10483 LambdaExpression.prototype.set$func = function(value) { return this.func = value
; }; |
10763 LambdaExpression.prototype.visit = function(visitor) { | 10484 LambdaExpression.prototype.visit = function(visitor) { |
10764 return visitor.visitLambdaExpression$1(this); | 10485 return visitor.visitLambdaExpression(this); |
10765 } | 10486 } |
10766 LambdaExpression.prototype.visit$1 = LambdaExpression.prototype.visit; | |
10767 // ********** Code for CallExpression ************** | 10487 // ********** Code for CallExpression ************** |
10768 $inherits(CallExpression, Expression); | 10488 $inherits(CallExpression, Expression); |
10769 function CallExpression(target, arguments, span) { | 10489 function CallExpression(target, arguments, span) { |
10770 this.target = target; | 10490 this.target = target; |
10771 this.arguments = arguments; | 10491 this.arguments = arguments; |
10772 Expression.call(this, span); | 10492 Expression.call(this, span); |
10773 } | 10493 } |
10774 CallExpression.prototype.visit = function(visitor) { | 10494 CallExpression.prototype.visit = function(visitor) { |
10775 return visitor.visitCallExpression(this); | 10495 return visitor.visitCallExpression(this); |
10776 } | 10496 } |
10777 CallExpression.prototype.visit$1 = CallExpression.prototype.visit; | |
10778 // ********** Code for IndexExpression ************** | 10497 // ********** Code for IndexExpression ************** |
10779 $inherits(IndexExpression, Expression); | 10498 $inherits(IndexExpression, Expression); |
10780 function IndexExpression(target, index, span) { | 10499 function IndexExpression(target, index, span) { |
10781 this.target = target; | 10500 this.target = target; |
10782 this.index = index; | 10501 this.index = index; |
10783 Expression.call(this, span); | 10502 Expression.call(this, span); |
10784 } | 10503 } |
10785 IndexExpression.prototype.visit = function(visitor) { | 10504 IndexExpression.prototype.visit = function(visitor) { |
10786 return visitor.visitIndexExpression$1(this); | 10505 return visitor.visitIndexExpression(this); |
10787 } | 10506 } |
10788 IndexExpression.prototype.visit$1 = IndexExpression.prototype.visit; | |
10789 // ********** Code for BinaryExpression ************** | 10507 // ********** Code for BinaryExpression ************** |
10790 $inherits(BinaryExpression, Expression); | 10508 $inherits(BinaryExpression, Expression); |
10791 function BinaryExpression(op, x, y, span) { | 10509 function BinaryExpression(op, x, y, span) { |
10792 this.y = y; | 10510 this.y = y; |
10793 this.x = x; | 10511 this.x = x; |
10794 this.op = op; | 10512 this.op = op; |
10795 Expression.call(this, span); | 10513 Expression.call(this, span); |
10796 } | 10514 } |
10797 BinaryExpression.prototype.get$op = function() { return this.op; }; | 10515 BinaryExpression.prototype.get$op = function() { return this.op; }; |
10798 BinaryExpression.prototype.set$op = function(value) { return this.op = value; }; | 10516 BinaryExpression.prototype.set$op = function(value) { return this.op = value; }; |
10799 BinaryExpression.prototype.get$x = function() { return this.x; }; | 10517 BinaryExpression.prototype.get$x = function() { return this.x; }; |
10800 BinaryExpression.prototype.set$x = function(value) { return this.x = value; }; | 10518 BinaryExpression.prototype.set$x = function(value) { return this.x = value; }; |
10801 BinaryExpression.prototype.get$y = function() { return this.y; }; | 10519 BinaryExpression.prototype.get$y = function() { return this.y; }; |
10802 BinaryExpression.prototype.set$y = function(value) { return this.y = value; }; | 10520 BinaryExpression.prototype.set$y = function(value) { return this.y = value; }; |
10803 BinaryExpression.prototype.visit = function(visitor) { | 10521 BinaryExpression.prototype.visit = function(visitor) { |
10804 return visitor.visitBinaryExpression$1(this); | 10522 return visitor.visitBinaryExpression$1(this); |
10805 } | 10523 } |
10806 BinaryExpression.prototype.visit$1 = BinaryExpression.prototype.visit; | |
10807 // ********** Code for UnaryExpression ************** | 10524 // ********** Code for UnaryExpression ************** |
10808 $inherits(UnaryExpression, Expression); | 10525 $inherits(UnaryExpression, Expression); |
10809 function UnaryExpression(op, self, span) { | 10526 function UnaryExpression(op, self, span) { |
10810 this.self = self; | 10527 this.self = self; |
10811 this.op = op; | 10528 this.op = op; |
10812 Expression.call(this, span); | 10529 Expression.call(this, span); |
10813 } | 10530 } |
10814 UnaryExpression.prototype.get$op = function() { return this.op; }; | 10531 UnaryExpression.prototype.get$op = function() { return this.op; }; |
10815 UnaryExpression.prototype.set$op = function(value) { return this.op = value; }; | 10532 UnaryExpression.prototype.set$op = function(value) { return this.op = value; }; |
10816 UnaryExpression.prototype.get$self = function() { return this.self; }; | 10533 UnaryExpression.prototype.get$self = function() { return this.self; }; |
10817 UnaryExpression.prototype.set$self = function(value) { return this.self = value;
}; | 10534 UnaryExpression.prototype.set$self = function(value) { return this.self = value;
}; |
10818 UnaryExpression.prototype.visit = function(visitor) { | 10535 UnaryExpression.prototype.visit = function(visitor) { |
10819 return visitor.visitUnaryExpression(this); | 10536 return visitor.visitUnaryExpression(this); |
10820 } | 10537 } |
10821 UnaryExpression.prototype.visit$1 = UnaryExpression.prototype.visit; | |
10822 // ********** Code for PostfixExpression ************** | 10538 // ********** Code for PostfixExpression ************** |
10823 $inherits(PostfixExpression, Expression); | 10539 $inherits(PostfixExpression, Expression); |
10824 function PostfixExpression(body, op, span) { | 10540 function PostfixExpression(body, op, span) { |
10825 this.body = body; | 10541 this.body = body; |
10826 this.op = op; | 10542 this.op = op; |
10827 Expression.call(this, span); | 10543 Expression.call(this, span); |
10828 } | 10544 } |
10829 PostfixExpression.prototype.get$body = function() { return this.body; }; | 10545 PostfixExpression.prototype.get$body = function() { return this.body; }; |
10830 PostfixExpression.prototype.set$body = function(value) { return this.body = valu
e; }; | 10546 PostfixExpression.prototype.set$body = function(value) { return this.body = valu
e; }; |
10831 PostfixExpression.prototype.get$op = function() { return this.op; }; | 10547 PostfixExpression.prototype.get$op = function() { return this.op; }; |
10832 PostfixExpression.prototype.set$op = function(value) { return this.op = value; }
; | 10548 PostfixExpression.prototype.set$op = function(value) { return this.op = value; }
; |
10833 PostfixExpression.prototype.visit = function(visitor) { | 10549 PostfixExpression.prototype.visit = function(visitor) { |
10834 return visitor.visitPostfixExpression$1(this); | 10550 return visitor.visitPostfixExpression$1(this); |
10835 } | 10551 } |
10836 PostfixExpression.prototype.visit$1 = PostfixExpression.prototype.visit; | |
10837 // ********** Code for NewExpression ************** | 10552 // ********** Code for NewExpression ************** |
10838 $inherits(NewExpression, Expression); | 10553 $inherits(NewExpression, Expression); |
10839 function NewExpression(isConst, type, name, arguments, span) { | 10554 function NewExpression(isConst, type, name, arguments, span) { |
10840 this.arguments = arguments; | 10555 this.arguments = arguments; |
10841 this.name = name; | 10556 this.name = name; |
10842 this.type = type; | 10557 this.type = type; |
10843 this.isConst = isConst; | 10558 this.isConst = isConst; |
10844 Expression.call(this, span); | 10559 Expression.call(this, span); |
10845 } | 10560 } |
10846 NewExpression.prototype.get$isConst = function() { return this.isConst; }; | 10561 NewExpression.prototype.get$isConst = function() { return this.isConst; }; |
10847 NewExpression.prototype.set$isConst = function(value) { return this.isConst = va
lue; }; | 10562 NewExpression.prototype.set$isConst = function(value) { return this.isConst = va
lue; }; |
10848 NewExpression.prototype.get$type = function() { return this.type; }; | 10563 NewExpression.prototype.get$type = function() { return this.type; }; |
10849 NewExpression.prototype.set$type = function(value) { return this.type = value; }
; | 10564 NewExpression.prototype.set$type = function(value) { return this.type = value; }
; |
10850 NewExpression.prototype.get$name = function() { return this.name; }; | 10565 NewExpression.prototype.get$name = function() { return this.name; }; |
10851 NewExpression.prototype.set$name = function(value) { return this.name = value; }
; | 10566 NewExpression.prototype.set$name = function(value) { return this.name = value; }
; |
10852 NewExpression.prototype.visit = function(visitor) { | 10567 NewExpression.prototype.visit = function(visitor) { |
10853 return visitor.visitNewExpression$1(this); | 10568 return visitor.visitNewExpression(this); |
10854 } | 10569 } |
10855 NewExpression.prototype.visit$1 = NewExpression.prototype.visit; | |
10856 // ********** Code for ListExpression ************** | 10570 // ********** Code for ListExpression ************** |
10857 $inherits(ListExpression, Expression); | 10571 $inherits(ListExpression, Expression); |
10858 function ListExpression(isConst, itemType, values, span) { | 10572 function ListExpression(isConst, itemType, values, span) { |
10859 this.itemType = itemType; | 10573 this.itemType = itemType; |
10860 this.isConst = isConst; | 10574 this.isConst = isConst; |
10861 this.values = values; | 10575 this.values = values; |
10862 Expression.call(this, span); | 10576 Expression.call(this, span); |
10863 } | 10577 } |
10864 ListExpression.prototype.get$isConst = function() { return this.isConst; }; | 10578 ListExpression.prototype.get$isConst = function() { return this.isConst; }; |
10865 ListExpression.prototype.set$isConst = function(value) { return this.isConst = v
alue; }; | 10579 ListExpression.prototype.set$isConst = function(value) { return this.isConst = v
alue; }; |
10866 ListExpression.prototype.visit = function(visitor) { | 10580 ListExpression.prototype.visit = function(visitor) { |
10867 return visitor.visitListExpression(this); | 10581 return visitor.visitListExpression(this); |
10868 } | 10582 } |
10869 ListExpression.prototype.visit$1 = ListExpression.prototype.visit; | |
10870 // ********** Code for MapExpression ************** | 10583 // ********** Code for MapExpression ************** |
10871 $inherits(MapExpression, Expression); | 10584 $inherits(MapExpression, Expression); |
10872 function MapExpression(isConst, keyType, valueType, items, span) { | 10585 function MapExpression(isConst, keyType, valueType, items, span) { |
10873 this.keyType = keyType; | 10586 this.keyType = keyType; |
10874 this.valueType = valueType; | 10587 this.valueType = valueType; |
10875 this.items = items; | 10588 this.items = items; |
10876 this.isConst = isConst; | 10589 this.isConst = isConst; |
10877 Expression.call(this, span); | 10590 Expression.call(this, span); |
10878 } | 10591 } |
10879 MapExpression.prototype.get$isConst = function() { return this.isConst; }; | 10592 MapExpression.prototype.get$isConst = function() { return this.isConst; }; |
10880 MapExpression.prototype.set$isConst = function(value) { return this.isConst = va
lue; }; | 10593 MapExpression.prototype.set$isConst = function(value) { return this.isConst = va
lue; }; |
10881 MapExpression.prototype.visit = function(visitor) { | 10594 MapExpression.prototype.visit = function(visitor) { |
10882 return visitor.visitMapExpression$1(this); | 10595 return visitor.visitMapExpression(this); |
10883 } | 10596 } |
10884 MapExpression.prototype.visit$1 = MapExpression.prototype.visit; | |
10885 // ********** Code for ConditionalExpression ************** | 10597 // ********** Code for ConditionalExpression ************** |
10886 $inherits(ConditionalExpression, Expression); | 10598 $inherits(ConditionalExpression, Expression); |
10887 function ConditionalExpression(test, trueBranch, falseBranch, span) { | 10599 function ConditionalExpression(test, trueBranch, falseBranch, span) { |
10888 this.test = test; | 10600 this.test = test; |
10889 this.falseBranch = falseBranch; | 10601 this.falseBranch = falseBranch; |
10890 this.trueBranch = trueBranch; | 10602 this.trueBranch = trueBranch; |
10891 Expression.call(this, span); | 10603 Expression.call(this, span); |
10892 } | 10604 } |
10893 ConditionalExpression.prototype.visit = function(visitor) { | 10605 ConditionalExpression.prototype.visit = function(visitor) { |
10894 return visitor.visitConditionalExpression(this); | 10606 return visitor.visitConditionalExpression(this); |
10895 } | 10607 } |
10896 ConditionalExpression.prototype.visit$1 = ConditionalExpression.prototype.visit; | |
10897 // ********** Code for IsExpression ************** | 10608 // ********** Code for IsExpression ************** |
10898 $inherits(IsExpression, Expression); | 10609 $inherits(IsExpression, Expression); |
10899 function IsExpression(isTrue, x, type, span) { | 10610 function IsExpression(isTrue, x, type, span) { |
10900 this.isTrue = isTrue; | 10611 this.isTrue = isTrue; |
10901 this.x = x; | 10612 this.x = x; |
10902 this.type = type; | 10613 this.type = type; |
10903 Expression.call(this, span); | 10614 Expression.call(this, span); |
10904 } | 10615 } |
10905 IsExpression.prototype.get$x = function() { return this.x; }; | 10616 IsExpression.prototype.get$x = function() { return this.x; }; |
10906 IsExpression.prototype.set$x = function(value) { return this.x = value; }; | 10617 IsExpression.prototype.set$x = function(value) { return this.x = value; }; |
10907 IsExpression.prototype.get$type = function() { return this.type; }; | 10618 IsExpression.prototype.get$type = function() { return this.type; }; |
10908 IsExpression.prototype.set$type = function(value) { return this.type = value; }; | 10619 IsExpression.prototype.set$type = function(value) { return this.type = value; }; |
10909 IsExpression.prototype.visit = function(visitor) { | 10620 IsExpression.prototype.visit = function(visitor) { |
10910 return visitor.visitIsExpression(this); | 10621 return visitor.visitIsExpression(this); |
10911 } | 10622 } |
10912 IsExpression.prototype.visit$1 = IsExpression.prototype.visit; | |
10913 // ********** Code for ParenExpression ************** | 10623 // ********** Code for ParenExpression ************** |
10914 $inherits(ParenExpression, Expression); | 10624 $inherits(ParenExpression, Expression); |
10915 function ParenExpression(body, span) { | 10625 function ParenExpression(body, span) { |
10916 this.body = body; | 10626 this.body = body; |
10917 Expression.call(this, span); | 10627 Expression.call(this, span); |
10918 } | 10628 } |
10919 ParenExpression.prototype.get$body = function() { return this.body; }; | 10629 ParenExpression.prototype.get$body = function() { return this.body; }; |
10920 ParenExpression.prototype.set$body = function(value) { return this.body = value;
}; | 10630 ParenExpression.prototype.set$body = function(value) { return this.body = value;
}; |
10921 ParenExpression.prototype.visit = function(visitor) { | 10631 ParenExpression.prototype.visit = function(visitor) { |
10922 return visitor.visitParenExpression(this); | 10632 return visitor.visitParenExpression(this); |
10923 } | 10633 } |
10924 ParenExpression.prototype.visit$1 = ParenExpression.prototype.visit; | |
10925 // ********** Code for AwaitExpression ************** | 10634 // ********** Code for AwaitExpression ************** |
10926 $inherits(AwaitExpression, Expression); | 10635 $inherits(AwaitExpression, Expression); |
10927 function AwaitExpression(body, span) { | 10636 function AwaitExpression(body, span) { |
10928 this.body = body; | 10637 this.body = body; |
10929 Expression.call(this, span); | 10638 Expression.call(this, span); |
10930 } | 10639 } |
10931 AwaitExpression.prototype.get$body = function() { return this.body; }; | 10640 AwaitExpression.prototype.get$body = function() { return this.body; }; |
10932 AwaitExpression.prototype.set$body = function(value) { return this.body = value;
}; | 10641 AwaitExpression.prototype.set$body = function(value) { return this.body = value;
}; |
10933 AwaitExpression.prototype.visit = function(visitor) { | 10642 AwaitExpression.prototype.visit = function(visitor) { |
10934 return visitor.visitAwaitExpression(this); | 10643 return visitor.visitAwaitExpression(this); |
10935 } | 10644 } |
10936 AwaitExpression.prototype.visit$1 = AwaitExpression.prototype.visit; | |
10937 // ********** Code for DotExpression ************** | 10645 // ********** Code for DotExpression ************** |
10938 $inherits(DotExpression, Expression); | 10646 $inherits(DotExpression, Expression); |
10939 function DotExpression(self, name, span) { | 10647 function DotExpression(self, name, span) { |
10940 this.self = self; | 10648 this.self = self; |
10941 this.name = name; | 10649 this.name = name; |
10942 Expression.call(this, span); | 10650 Expression.call(this, span); |
10943 } | 10651 } |
10944 DotExpression.prototype.get$self = function() { return this.self; }; | 10652 DotExpression.prototype.get$self = function() { return this.self; }; |
10945 DotExpression.prototype.set$self = function(value) { return this.self = value; }
; | 10653 DotExpression.prototype.set$self = function(value) { return this.self = value; }
; |
10946 DotExpression.prototype.get$name = function() { return this.name; }; | 10654 DotExpression.prototype.get$name = function() { return this.name; }; |
10947 DotExpression.prototype.set$name = function(value) { return this.name = value; }
; | 10655 DotExpression.prototype.set$name = function(value) { return this.name = value; }
; |
10948 DotExpression.prototype.visit = function(visitor) { | 10656 DotExpression.prototype.visit = function(visitor) { |
10949 return visitor.visitDotExpression(this); | 10657 return visitor.visitDotExpression(this); |
10950 } | 10658 } |
10951 DotExpression.prototype.visit$1 = DotExpression.prototype.visit; | |
10952 // ********** Code for VarExpression ************** | 10659 // ********** Code for VarExpression ************** |
10953 $inherits(VarExpression, Expression); | 10660 $inherits(VarExpression, Expression); |
10954 function VarExpression(name, span) { | 10661 function VarExpression(name, span) { |
10955 this.name = name; | 10662 this.name = name; |
10956 Expression.call(this, span); | 10663 Expression.call(this, span); |
10957 } | 10664 } |
10958 VarExpression.prototype.get$name = function() { return this.name; }; | 10665 VarExpression.prototype.get$name = function() { return this.name; }; |
10959 VarExpression.prototype.set$name = function(value) { return this.name = value; }
; | 10666 VarExpression.prototype.set$name = function(value) { return this.name = value; }
; |
10960 VarExpression.prototype.visit = function(visitor) { | 10667 VarExpression.prototype.visit = function(visitor) { |
10961 return visitor.visitVarExpression(this); | 10668 return visitor.visitVarExpression(this); |
10962 } | 10669 } |
10963 VarExpression.prototype.visit$1 = VarExpression.prototype.visit; | |
10964 // ********** Code for ThisExpression ************** | 10670 // ********** Code for ThisExpression ************** |
10965 $inherits(ThisExpression, Expression); | 10671 $inherits(ThisExpression, Expression); |
10966 function ThisExpression(span) { | 10672 function ThisExpression(span) { |
10967 Expression.call(this, span); | 10673 Expression.call(this, span); |
10968 } | 10674 } |
10969 ThisExpression.prototype.visit = function(visitor) { | 10675 ThisExpression.prototype.visit = function(visitor) { |
10970 return visitor.visitThisExpression(this); | 10676 return visitor.visitThisExpression(this); |
10971 } | 10677 } |
10972 ThisExpression.prototype.visit$1 = ThisExpression.prototype.visit; | |
10973 // ********** Code for SuperExpression ************** | 10678 // ********** Code for SuperExpression ************** |
10974 $inherits(SuperExpression, Expression); | 10679 $inherits(SuperExpression, Expression); |
10975 function SuperExpression(span) { | 10680 function SuperExpression(span) { |
10976 Expression.call(this, span); | 10681 Expression.call(this, span); |
10977 } | 10682 } |
10978 SuperExpression.prototype.visit = function(visitor) { | 10683 SuperExpression.prototype.visit = function(visitor) { |
10979 return visitor.visitSuperExpression(this); | 10684 return visitor.visitSuperExpression(this); |
10980 } | 10685 } |
10981 SuperExpression.prototype.visit$1 = SuperExpression.prototype.visit; | |
10982 // ********** Code for LiteralExpression ************** | 10686 // ********** Code for LiteralExpression ************** |
10983 $inherits(LiteralExpression, Expression); | 10687 $inherits(LiteralExpression, Expression); |
10984 function LiteralExpression(value, span) { | 10688 function LiteralExpression(value, span) { |
10985 this.value = value; | 10689 this.value = value; |
10986 Expression.call(this, span); | 10690 Expression.call(this, span); |
10987 } | 10691 } |
10988 LiteralExpression.prototype.get$value = function() { return this.value; }; | 10692 LiteralExpression.prototype.get$value = function() { return this.value; }; |
10989 LiteralExpression.prototype.set$value = function(value) { return this.value = va
lue; }; | 10693 LiteralExpression.prototype.set$value = function(value) { return this.value = va
lue; }; |
10990 LiteralExpression.prototype.visit = function(visitor) { | 10694 LiteralExpression.prototype.visit = function(visitor) { |
10991 return visitor.visitLiteralExpression$1(this); | 10695 return visitor.visitLiteralExpression(this); |
10992 } | 10696 } |
10993 LiteralExpression.prototype.visit$1 = LiteralExpression.prototype.visit; | |
10994 // ********** Code for StringInterpExpression ************** | 10697 // ********** Code for StringInterpExpression ************** |
10995 $inherits(StringInterpExpression, Expression); | 10698 $inherits(StringInterpExpression, Expression); |
10996 function StringInterpExpression(pieces, span) { | 10699 function StringInterpExpression(pieces, span) { |
10997 this.pieces = pieces; | 10700 this.pieces = pieces; |
10998 Expression.call(this, span); | 10701 Expression.call(this, span); |
10999 } | 10702 } |
11000 StringInterpExpression.prototype.visit = function(visitor) { | 10703 StringInterpExpression.prototype.visit = function(visitor) { |
11001 return visitor.visitStringInterpExpression(this); | 10704 return visitor.visitStringInterpExpression(this); |
11002 } | 10705 } |
11003 StringInterpExpression.prototype.visit$1 = StringInterpExpression.prototype.visi
t; | 10706 // ********** Code for SimpleTypeReference ************** |
| 10707 $inherits(SimpleTypeReference, TypeReference); |
| 10708 function SimpleTypeReference(type, span) { |
| 10709 this.type = type; |
| 10710 TypeReference.call(this, span); |
| 10711 } |
| 10712 SimpleTypeReference.prototype.get$type = function() { return this.type; }; |
| 10713 SimpleTypeReference.prototype.set$type = function(value) { return this.type = va
lue; }; |
| 10714 SimpleTypeReference.prototype.visit = function(visitor) { |
| 10715 return visitor.visitSimpleTypeReference(this); |
| 10716 } |
11004 // ********** Code for NameTypeReference ************** | 10717 // ********** Code for NameTypeReference ************** |
11005 $inherits(NameTypeReference, TypeReference); | 10718 $inherits(NameTypeReference, TypeReference); |
11006 function NameTypeReference(isFinal, name, names, span) { | 10719 function NameTypeReference(isFinal, name, names, span) { |
11007 this.name = name; | 10720 this.name = name; |
11008 this.names = names; | 10721 this.names = names; |
11009 this.isFinal = isFinal; | 10722 this.isFinal = isFinal; |
11010 TypeReference.call(this, span); | 10723 TypeReference.call(this, span); |
11011 } | 10724 } |
11012 NameTypeReference.prototype.get$isFinal = function() { return this.isFinal; }; | 10725 NameTypeReference.prototype.get$isFinal = function() { return this.isFinal; }; |
11013 NameTypeReference.prototype.set$isFinal = function(value) { return this.isFinal
= value; }; | 10726 NameTypeReference.prototype.set$isFinal = function(value) { return this.isFinal
= value; }; |
11014 NameTypeReference.prototype.get$name = function() { return this.name; }; | 10727 NameTypeReference.prototype.get$name = function() { return this.name; }; |
11015 NameTypeReference.prototype.set$name = function(value) { return this.name = valu
e; }; | 10728 NameTypeReference.prototype.set$name = function(value) { return this.name = valu
e; }; |
11016 NameTypeReference.prototype.get$names = function() { return this.names; }; | 10729 NameTypeReference.prototype.get$names = function() { return this.names; }; |
11017 NameTypeReference.prototype.set$names = function(value) { return this.names = va
lue; }; | 10730 NameTypeReference.prototype.set$names = function(value) { return this.names = va
lue; }; |
11018 NameTypeReference.prototype.visit = function(visitor) { | 10731 NameTypeReference.prototype.visit = function(visitor) { |
11019 return visitor.visitNameTypeReference(this); | 10732 return visitor.visitNameTypeReference(this); |
11020 } | 10733 } |
11021 NameTypeReference.prototype.visit$1 = NameTypeReference.prototype.visit; | |
11022 // ********** Code for GenericTypeReference ************** | 10734 // ********** Code for GenericTypeReference ************** |
11023 $inherits(GenericTypeReference, TypeReference); | 10735 $inherits(GenericTypeReference, TypeReference); |
11024 function GenericTypeReference(baseType, typeArguments, depth, span) { | 10736 function GenericTypeReference(baseType, typeArguments, depth, span) { |
11025 this.depth = depth; | 10737 this.depth = depth; |
11026 this.baseType = baseType; | 10738 this.baseType = baseType; |
11027 this.typeArguments = typeArguments; | 10739 this.typeArguments = typeArguments; |
11028 TypeReference.call(this, span); | 10740 TypeReference.call(this, span); |
11029 } | 10741 } |
11030 GenericTypeReference.prototype.get$baseType = function() { return this.baseType;
}; | 10742 GenericTypeReference.prototype.get$baseType = function() { return this.baseType;
}; |
11031 GenericTypeReference.prototype.set$baseType = function(value) { return this.base
Type = value; }; | 10743 GenericTypeReference.prototype.set$baseType = function(value) { return this.base
Type = value; }; |
11032 GenericTypeReference.prototype.get$typeArguments = function() { return this.type
Arguments; }; | 10744 GenericTypeReference.prototype.get$typeArguments = function() { return this.type
Arguments; }; |
11033 GenericTypeReference.prototype.set$typeArguments = function(value) { return this
.typeArguments = value; }; | 10745 GenericTypeReference.prototype.set$typeArguments = function(value) { return this
.typeArguments = value; }; |
11034 GenericTypeReference.prototype.get$depth = function() { return this.depth; }; | 10746 GenericTypeReference.prototype.get$depth = function() { return this.depth; }; |
11035 GenericTypeReference.prototype.set$depth = function(value) { return this.depth =
value; }; | 10747 GenericTypeReference.prototype.set$depth = function(value) { return this.depth =
value; }; |
11036 GenericTypeReference.prototype.visit = function(visitor) { | 10748 GenericTypeReference.prototype.visit = function(visitor) { |
11037 return visitor.visitGenericTypeReference(this); | 10749 return visitor.visitGenericTypeReference(this); |
11038 } | 10750 } |
11039 GenericTypeReference.prototype.visit$1 = GenericTypeReference.prototype.visit; | |
11040 // ********** Code for FunctionTypeReference ************** | 10751 // ********** Code for FunctionTypeReference ************** |
11041 $inherits(FunctionTypeReference, TypeReference); | 10752 $inherits(FunctionTypeReference, TypeReference); |
11042 function FunctionTypeReference(isFinal, func, span) { | 10753 function FunctionTypeReference(isFinal, func, span) { |
11043 this.func = func; | 10754 this.func = func; |
11044 this.isFinal = isFinal; | 10755 this.isFinal = isFinal; |
11045 TypeReference.call(this, span); | 10756 TypeReference.call(this, span); |
11046 } | 10757 } |
11047 FunctionTypeReference.prototype.get$isFinal = function() { return this.isFinal;
}; | 10758 FunctionTypeReference.prototype.get$isFinal = function() { return this.isFinal;
}; |
11048 FunctionTypeReference.prototype.set$isFinal = function(value) { return this.isFi
nal = value; }; | 10759 FunctionTypeReference.prototype.set$isFinal = function(value) { return this.isFi
nal = value; }; |
11049 FunctionTypeReference.prototype.get$func = function() { return this.func; }; | 10760 FunctionTypeReference.prototype.get$func = function() { return this.func; }; |
11050 FunctionTypeReference.prototype.set$func = function(value) { return this.func =
value; }; | 10761 FunctionTypeReference.prototype.set$func = function(value) { return this.func =
value; }; |
11051 FunctionTypeReference.prototype.visit = function(visitor) { | 10762 FunctionTypeReference.prototype.visit = function(visitor) { |
11052 return visitor.visitFunctionTypeReference(this); | 10763 return visitor.visitFunctionTypeReference(this); |
11053 } | 10764 } |
11054 FunctionTypeReference.prototype.visit$1 = FunctionTypeReference.prototype.visit; | |
11055 // ********** Code for DefaultTypeReference ************** | 10765 // ********** Code for DefaultTypeReference ************** |
11056 $inherits(DefaultTypeReference, TypeReference); | 10766 $inherits(DefaultTypeReference, TypeReference); |
11057 function DefaultTypeReference(oldFactory, baseType, typeParameters, span) { | 10767 function DefaultTypeReference(oldFactory, baseType, typeParameters, span) { |
11058 this.typeParameters = typeParameters; | 10768 this.typeParameters = typeParameters; |
11059 this.oldFactory = oldFactory; | 10769 this.oldFactory = oldFactory; |
11060 this.baseType = baseType; | 10770 this.baseType = baseType; |
11061 TypeReference.call(this, span); | 10771 TypeReference.call(this, span); |
11062 } | 10772 } |
11063 DefaultTypeReference.prototype.get$baseType = function() { return this.baseType;
}; | 10773 DefaultTypeReference.prototype.get$baseType = function() { return this.baseType;
}; |
11064 DefaultTypeReference.prototype.set$baseType = function(value) { return this.base
Type = value; }; | 10774 DefaultTypeReference.prototype.set$baseType = function(value) { return this.base
Type = value; }; |
11065 DefaultTypeReference.prototype.get$typeParameters = function() { return this.typ
eParameters; }; | 10775 DefaultTypeReference.prototype.get$typeParameters = function() { return this.typ
eParameters; }; |
11066 DefaultTypeReference.prototype.set$typeParameters = function(value) { return thi
s.typeParameters = value; }; | 10776 DefaultTypeReference.prototype.set$typeParameters = function(value) { return thi
s.typeParameters = value; }; |
11067 DefaultTypeReference.prototype.visit = function(visitor) { | 10777 DefaultTypeReference.prototype.visit = function(visitor) { |
11068 return visitor.visitDefaultTypeReference(this); | 10778 return visitor.visitDefaultTypeReference(this); |
11069 } | 10779 } |
11070 DefaultTypeReference.prototype.visit$1 = DefaultTypeReference.prototype.visit; | |
11071 // ********** Code for ArgumentNode ************** | 10780 // ********** Code for ArgumentNode ************** |
11072 $inherits(ArgumentNode, Node); | 10781 $inherits(ArgumentNode, Node); |
11073 function ArgumentNode(label, value, span) { | 10782 function ArgumentNode(label, value, span) { |
11074 this.label = label; | 10783 this.label = label; |
11075 this.value = value; | 10784 this.value = value; |
11076 Node.call(this, span); | 10785 Node.call(this, span); |
11077 } | 10786 } |
11078 ArgumentNode.prototype.get$label = function() { return this.label; }; | 10787 ArgumentNode.prototype.get$label = function() { return this.label; }; |
11079 ArgumentNode.prototype.set$label = function(value) { return this.label = value;
}; | 10788 ArgumentNode.prototype.set$label = function(value) { return this.label = value;
}; |
11080 ArgumentNode.prototype.get$value = function() { return this.value; }; | 10789 ArgumentNode.prototype.get$value = function() { return this.value; }; |
11081 ArgumentNode.prototype.set$value = function(value) { return this.value = value;
}; | 10790 ArgumentNode.prototype.set$value = function(value) { return this.value = value;
}; |
11082 ArgumentNode.prototype.visit = function(visitor) { | 10791 ArgumentNode.prototype.visit = function(visitor) { |
11083 return visitor.visitArgumentNode(this); | 10792 return visitor.visitArgumentNode(this); |
11084 } | 10793 } |
11085 ArgumentNode.prototype.visit$1 = ArgumentNode.prototype.visit; | |
11086 // ********** Code for FormalNode ************** | 10794 // ********** Code for FormalNode ************** |
11087 $inherits(FormalNode, Node); | 10795 $inherits(FormalNode, Node); |
11088 function FormalNode(isThis, isRest, type, name, value, span) { | 10796 function FormalNode(isThis, isRest, type, name, value, span) { |
11089 this.name = name; | 10797 this.name = name; |
11090 this.isThis = isThis; | 10798 this.isThis = isThis; |
11091 this.type = type; | 10799 this.type = type; |
11092 this.isRest = isRest; | 10800 this.isRest = isRest; |
11093 this.value = value; | 10801 this.value = value; |
11094 Node.call(this, span); | 10802 Node.call(this, span); |
11095 } | 10803 } |
11096 FormalNode.prototype.get$type = function() { return this.type; }; | 10804 FormalNode.prototype.get$type = function() { return this.type; }; |
11097 FormalNode.prototype.set$type = function(value) { return this.type = value; }; | 10805 FormalNode.prototype.set$type = function(value) { return this.type = value; }; |
11098 FormalNode.prototype.get$name = function() { return this.name; }; | 10806 FormalNode.prototype.get$name = function() { return this.name; }; |
11099 FormalNode.prototype.set$name = function(value) { return this.name = value; }; | 10807 FormalNode.prototype.set$name = function(value) { return this.name = value; }; |
11100 FormalNode.prototype.get$value = function() { return this.value; }; | 10808 FormalNode.prototype.get$value = function() { return this.value; }; |
11101 FormalNode.prototype.set$value = function(value) { return this.value = value; }; | 10809 FormalNode.prototype.set$value = function(value) { return this.value = value; }; |
11102 FormalNode.prototype.visit = function(visitor) { | 10810 FormalNode.prototype.visit = function(visitor) { |
11103 return visitor.visitFormalNode(this); | 10811 return visitor.visitFormalNode(this); |
11104 } | 10812 } |
11105 FormalNode.prototype.visit$1 = FormalNode.prototype.visit; | |
11106 // ********** Code for CatchNode ************** | 10813 // ********** Code for CatchNode ************** |
11107 $inherits(CatchNode, Node); | 10814 $inherits(CatchNode, Node); |
11108 function CatchNode(exception, trace, body, span) { | 10815 function CatchNode(exception, trace, body, span) { |
11109 this.body = body; | 10816 this.body = body; |
11110 this.exception = exception; | 10817 this.exception = exception; |
11111 this.trace = trace; | 10818 this.trace = trace; |
11112 Node.call(this, span); | 10819 Node.call(this, span); |
11113 } | 10820 } |
11114 CatchNode.prototype.get$exception = function() { return this.exception; }; | 10821 CatchNode.prototype.get$exception = function() { return this.exception; }; |
11115 CatchNode.prototype.set$exception = function(value) { return this.exception = va
lue; }; | 10822 CatchNode.prototype.set$exception = function(value) { return this.exception = va
lue; }; |
11116 CatchNode.prototype.get$trace = function() { return this.trace; }; | 10823 CatchNode.prototype.get$trace = function() { return this.trace; }; |
11117 CatchNode.prototype.set$trace = function(value) { return this.trace = value; }; | 10824 CatchNode.prototype.set$trace = function(value) { return this.trace = value; }; |
11118 CatchNode.prototype.get$body = function() { return this.body; }; | 10825 CatchNode.prototype.get$body = function() { return this.body; }; |
11119 CatchNode.prototype.set$body = function(value) { return this.body = value; }; | 10826 CatchNode.prototype.set$body = function(value) { return this.body = value; }; |
11120 CatchNode.prototype.visit = function(visitor) { | 10827 CatchNode.prototype.visit = function(visitor) { |
11121 return visitor.visitCatchNode(this); | 10828 return visitor.visitCatchNode(this); |
11122 } | 10829 } |
11123 CatchNode.prototype.visit$1 = CatchNode.prototype.visit; | |
11124 // ********** Code for CaseNode ************** | 10830 // ********** Code for CaseNode ************** |
11125 $inherits(CaseNode, Node); | 10831 $inherits(CaseNode, Node); |
11126 function CaseNode(label, cases, statements, span) { | 10832 function CaseNode(label, cases, statements, span) { |
11127 this.label = label; | 10833 this.label = label; |
11128 this.statements = statements; | 10834 this.statements = statements; |
11129 this.cases = cases; | 10835 this.cases = cases; |
11130 Node.call(this, span); | 10836 Node.call(this, span); |
11131 } | 10837 } |
11132 CaseNode.prototype.get$label = function() { return this.label; }; | 10838 CaseNode.prototype.get$label = function() { return this.label; }; |
11133 CaseNode.prototype.set$label = function(value) { return this.label = value; }; | 10839 CaseNode.prototype.set$label = function(value) { return this.label = value; }; |
11134 CaseNode.prototype.get$cases = function() { return this.cases; }; | 10840 CaseNode.prototype.get$cases = function() { return this.cases; }; |
11135 CaseNode.prototype.set$cases = function(value) { return this.cases = value; }; | 10841 CaseNode.prototype.set$cases = function(value) { return this.cases = value; }; |
11136 CaseNode.prototype.get$statements = function() { return this.statements; }; | 10842 CaseNode.prototype.get$statements = function() { return this.statements; }; |
11137 CaseNode.prototype.set$statements = function(value) { return this.statements = v
alue; }; | 10843 CaseNode.prototype.set$statements = function(value) { return this.statements = v
alue; }; |
11138 CaseNode.prototype.visit = function(visitor) { | 10844 CaseNode.prototype.visit = function(visitor) { |
11139 return visitor.visitCaseNode(this); | 10845 return visitor.visitCaseNode(this); |
11140 } | 10846 } |
11141 CaseNode.prototype.visit$1 = CaseNode.prototype.visit; | |
11142 // ********** Code for TypeParameter ************** | 10847 // ********** Code for TypeParameter ************** |
11143 $inherits(TypeParameter, Node); | 10848 $inherits(TypeParameter, Node); |
11144 function TypeParameter(name, extendsType, span) { | 10849 function TypeParameter(name, extendsType, span) { |
11145 this.extendsType = extendsType; | 10850 this.extendsType = extendsType; |
11146 this.name = name; | 10851 this.name = name; |
11147 Node.call(this, span); | 10852 Node.call(this, span); |
11148 } | 10853 } |
11149 TypeParameter.prototype.get$name = function() { return this.name; }; | 10854 TypeParameter.prototype.get$name = function() { return this.name; }; |
11150 TypeParameter.prototype.set$name = function(value) { return this.name = value; }
; | 10855 TypeParameter.prototype.set$name = function(value) { return this.name = value; }
; |
11151 TypeParameter.prototype.get$extendsType = function() { return this.extendsType;
}; | 10856 TypeParameter.prototype.get$extendsType = function() { return this.extendsType;
}; |
11152 TypeParameter.prototype.set$extendsType = function(value) { return this.extendsT
ype = value; }; | 10857 TypeParameter.prototype.set$extendsType = function(value) { return this.extendsT
ype = value; }; |
11153 TypeParameter.prototype.visit = function(visitor) { | 10858 TypeParameter.prototype.visit = function(visitor) { |
11154 return visitor.visitTypeParameter(this); | 10859 return visitor.visitTypeParameter(this); |
11155 } | 10860 } |
11156 TypeParameter.prototype.visit$1 = TypeParameter.prototype.visit; | |
11157 // ********** Code for Identifier ************** | 10861 // ********** Code for Identifier ************** |
11158 $inherits(Identifier, Node); | 10862 $inherits(Identifier, Node); |
11159 function Identifier(name, span) { | 10863 function Identifier(name, span) { |
11160 this.name = name; | 10864 this.name = name; |
11161 Node.call(this, span); | 10865 Node.call(this, span); |
11162 } | 10866 } |
11163 Identifier.prototype.get$name = function() { return this.name; }; | 10867 Identifier.prototype.get$name = function() { return this.name; }; |
11164 Identifier.prototype.set$name = function(value) { return this.name = value; }; | 10868 Identifier.prototype.set$name = function(value) { return this.name = value; }; |
11165 Identifier.prototype.visit = function(visitor) { | 10869 Identifier.prototype.visit = function(visitor) { |
11166 return visitor.visitIdentifier(this); | 10870 return visitor.visitIdentifier(this); |
11167 } | 10871 } |
11168 Identifier.prototype.visit$1 = Identifier.prototype.visit; | |
11169 // ********** Code for DeclaredIdentifier ************** | 10872 // ********** Code for DeclaredIdentifier ************** |
11170 $inherits(DeclaredIdentifier, Expression); | 10873 $inherits(DeclaredIdentifier, Expression); |
11171 function DeclaredIdentifier(type, name, span) { | 10874 function DeclaredIdentifier(type, name, span) { |
11172 this.name = name; | 10875 this.name = name; |
11173 this.type = type; | 10876 this.type = type; |
11174 Expression.call(this, span); | 10877 Expression.call(this, span); |
11175 } | 10878 } |
11176 DeclaredIdentifier.prototype.get$type = function() { return this.type; }; | 10879 DeclaredIdentifier.prototype.get$type = function() { return this.type; }; |
11177 DeclaredIdentifier.prototype.set$type = function(value) { return this.type = val
ue; }; | 10880 DeclaredIdentifier.prototype.set$type = function(value) { return this.type = val
ue; }; |
11178 DeclaredIdentifier.prototype.get$name = function() { return this.name; }; | 10881 DeclaredIdentifier.prototype.get$name = function() { return this.name; }; |
11179 DeclaredIdentifier.prototype.set$name = function(value) { return this.name = val
ue; }; | 10882 DeclaredIdentifier.prototype.set$name = function(value) { return this.name = val
ue; }; |
11180 DeclaredIdentifier.prototype.visit = function(visitor) { | 10883 DeclaredIdentifier.prototype.visit = function(visitor) { |
11181 return visitor.visitDeclaredIdentifier$1(this); | 10884 return visitor.visitDeclaredIdentifier(this); |
11182 } | 10885 } |
11183 DeclaredIdentifier.prototype.visit$1 = DeclaredIdentifier.prototype.visit; | |
11184 // ********** Code for Type ************** | 10886 // ********** Code for Type ************** |
11185 $inherits(Type, Element); | 10887 $inherits(Type, Element); |
11186 function Type(name) { | 10888 function Type(name) { |
11187 this.isTested = false; | 10889 this.isTested = false; |
11188 this._foundMembers = new HashMapImplementation(); | 10890 this._foundMembers = new HashMapImplementation(); |
11189 this.isChecked = false; | 10891 this.isChecked = false; |
11190 this.isWritten = false; | 10892 this.isWritten = false; |
11191 this.varStubs = new HashMapImplementation(); | 10893 this.varStubs = new HashMapImplementation(); |
11192 Element.call(this, name, null); | 10894 Element.call(this, name, null); |
11193 } | 10895 } |
(...skipping 27 matching lines...) Expand all Loading... |
11221 } | 10923 } |
11222 Type.prototype.get$isString = function() { | 10924 Type.prototype.get$isString = function() { |
11223 return false; | 10925 return false; |
11224 } | 10926 } |
11225 Type.prototype.get$isBool = function() { | 10927 Type.prototype.get$isBool = function() { |
11226 return false; | 10928 return false; |
11227 } | 10929 } |
11228 Type.prototype.get$isFunction = function() { | 10930 Type.prototype.get$isFunction = function() { |
11229 return false; | 10931 return false; |
11230 } | 10932 } |
11231 Type.prototype.get$isList = function() { | |
11232 return false; | |
11233 } | |
11234 Type.prototype.get$isNum = function() { | 10933 Type.prototype.get$isNum = function() { |
11235 return false; | 10934 return false; |
11236 } | 10935 } |
11237 Type.prototype.get$isVoid = function() { | 10936 Type.prototype.get$isVoid = function() { |
11238 return false; | 10937 return false; |
11239 } | 10938 } |
11240 Type.prototype.get$isNullable = function() { | 10939 Type.prototype.get$isNullable = function() { |
11241 return true; | 10940 return true; |
11242 } | 10941 } |
11243 Type.prototype.get$isVarOrFunction = function() { | 10942 Type.prototype.get$isVarOrFunction = function() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11279 Type.prototype.get$members = function() { | 10978 Type.prototype.get$members = function() { |
11280 return null; | 10979 return null; |
11281 } | 10980 } |
11282 Type.prototype.get$definition = function() { | 10981 Type.prototype.get$definition = function() { |
11283 return null; | 10982 return null; |
11284 } | 10983 } |
11285 Type.prototype.get$factories = function() { | 10984 Type.prototype.get$factories = function() { |
11286 return null; | 10985 return null; |
11287 } | 10986 } |
11288 Type.prototype.get$typeArgsInOrder = function() { | 10987 Type.prototype.get$typeArgsInOrder = function() { |
11289 return null; | 10988 return const$0007; |
11290 } | 10989 } |
11291 Type.prototype.get$genericType = function() { | 10990 Type.prototype.get$genericType = function() { |
11292 return this; | 10991 return this; |
11293 } | 10992 } |
| 10993 Type.prototype.get$isConcreteGeneric = function() { |
| 10994 return $ne(this.get$genericType(), this); |
| 10995 } |
11294 Type.prototype.get$interfaces = function() { | 10996 Type.prototype.get$interfaces = function() { |
11295 return null; | 10997 return null; |
11296 } | 10998 } |
11297 Type.prototype.get$parent = function() { | 10999 Type.prototype.get$parent = function() { |
11298 return null; | 11000 return null; |
11299 } | 11001 } |
11300 Type.prototype.getAllMembers = function() { | |
11301 return new HashMapImplementation(); | |
11302 } | |
11303 Type.prototype.get$nativeName = function() { | 11002 Type.prototype.get$nativeName = function() { |
11304 return this.get$isNative() ? this.get$definition().get$nativeType().get$name()
: this.get$jsname(); | 11003 return this.get$isNative() ? this.get$definition().get$nativeType().name : thi
s.get$jsname(); |
11305 } | 11004 } |
11306 Type.prototype.get$avoidNativeName = function() { | 11005 Type.prototype.get$avoidNativeName = function() { |
11307 return this.get$isHiddenNativeType(); | 11006 return this.get$isHiddenNativeType(); |
11308 } | 11007 } |
11309 Type.prototype.get$hasNativeSubtypes = function() { | 11008 Type.prototype.get$hasNativeSubtypes = function() { |
11310 if (this._hasNativeSubtypes == null) { | 11009 if (this._hasNativeSubtypes == null) { |
11311 this._hasNativeSubtypes = this.get$subtypes().some((function (t) { | 11010 this._hasNativeSubtypes = this.get$subtypes().some((function (t) { |
11312 return t.get$isNative(); | 11011 return t.get$isNative(); |
11313 }) | 11012 }) |
11314 ); | 11013 ); |
11315 } | 11014 } |
11316 return this._hasNativeSubtypes; | 11015 return this._hasNativeSubtypes; |
11317 } | 11016 } |
11318 Type.prototype._checkExtends = function() { | 11017 Type.prototype._checkExtends = function() { |
11319 var typeParams = this.get$genericType().typeParameters; | 11018 var typeParams = this.get$genericType().typeParameters; |
11320 if (typeParams != null && this.get$typeArgsInOrder() != null) { | 11019 if ($ne(typeParams)) { |
11321 var args = this.get$typeArgsInOrder().iterator$0(); | 11020 for (var i = (0); |
11322 var params = typeParams.iterator$0(); | 11021 i < typeParams.get$length(); i++) { |
11323 while (args.hasNext$0() && params.hasNext$0()) { | 11022 if ($ne(typeParams.$index(i).get$extendsType())) { |
11324 var typeParam = params.next$0(); | 11023 this.get$typeArgsInOrder().$index(i).get$dynamic().ensureSubtypeOf(typeP
arams.$index(i).get$extendsType(), typeParams.$index(i).get$span(), false); |
11325 var typeArg = args.next$0(); | |
11326 if (typeParam.get$extendsType() != null && typeArg != null) { | |
11327 typeArg.ensureSubtypeOf$3(typeParam.get$extendsType(), typeParam.get$spa
n(), true); | |
11328 } | 11024 } |
11329 } | 11025 } |
11330 } | 11026 } |
11331 if (this.get$interfaces() != null) { | 11027 if (this.get$interfaces() != null) { |
11332 var $$list = this.get$interfaces(); | 11028 var $$list = this.get$interfaces(); |
11333 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 11029 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
11334 var i = $$list[$$i]; | 11030 var i = $$i.next(); |
11335 i._checkExtends$0(); | 11031 i._checkExtends(); |
11336 } | 11032 } |
11337 } | 11033 } |
11338 } | 11034 } |
11339 Type.prototype._checkOverride = function(member) { | 11035 Type.prototype._checkOverride = function(member) { |
11340 var parentMember = this._getMemberInParents(member.name); | 11036 var parentMember = this._getMemberInParents(member.name); |
11341 if (parentMember != null) { | 11037 if ($ne(parentMember)) { |
11342 if (!member.get$isPrivate() || $eq(member.get$library(), parentMember.get$li
brary())) { | 11038 if (!member.get$isPrivate() || $eq(member.get$library(), parentMember.get$li
brary())) { |
11343 member.override(parentMember); | 11039 member.override(parentMember); |
11344 } | 11040 } |
11345 } | 11041 } |
11346 } | 11042 } |
11347 Type.prototype._createNotEqualMember = function() { | 11043 Type.prototype._createNotEqualMember = function() { |
11348 var eq = this.get$members().$index(":eq"); | 11044 var eq = this.get$members().$index(":eq"); |
11349 if (eq == null) { | 11045 if (eq == null) { |
11350 return; | 11046 return; |
11351 } | 11047 } |
11352 var ne = new MethodMember(":ne", this, eq.definition); | 11048 var ne = new MethodMember(":ne", this, eq.definition); |
11353 ne.set$isGenerated(true); | |
11354 ne.set$returnType(eq.returnType); | 11049 ne.set$returnType(eq.returnType); |
11355 ne.set$parameters(eq.parameters); | 11050 ne.set$parameters(eq.parameters); |
11356 ne.set$isStatic(eq.isStatic); | 11051 ne.set$isStatic(eq.isStatic); |
11357 ne.set$isAbstract(eq.isAbstract); | 11052 ne.set$isAbstract(eq.isAbstract); |
11358 this.get$members().$setindex(":ne", ne); | 11053 this.get$members().$setindex(":ne", ne); |
11359 } | 11054 } |
11360 Type.prototype._getMemberInParents = function(memberName) { | 11055 Type.prototype._getMemberInParents = function(memberName) { |
11361 if (this.get$isClass()) { | 11056 if (this.get$isClass()) { |
11362 if (this.get$parent() != null) { | 11057 if (this.get$parent() != null) { |
11363 return this.get$parent().getMember(memberName); | 11058 return this.get$parent().getMember(memberName); |
11364 } | 11059 } |
11365 else { | 11060 else { |
11366 return null; | 11061 return null; |
11367 } | 11062 } |
11368 } | 11063 } |
11369 else { | 11064 else { |
11370 if (this.get$interfaces() != null && this.get$interfaces().get$length() > (0
)) { | 11065 if (this.get$interfaces() != null && this.get$interfaces().get$length() > (0
)) { |
11371 var $$list = this.get$interfaces(); | 11066 var $$list = this.get$interfaces(); |
11372 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 11067 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
11373 var i = $$list[$$i]; | 11068 var i = $$i.next(); |
11374 var ret = i.getMember$1(memberName); | 11069 var ret = i.getMember(memberName); |
11375 if (ret != null) { | 11070 if ($ne(ret)) { |
11376 return ret; | 11071 return ret; |
11377 } | 11072 } |
11378 } | 11073 } |
11379 } | 11074 } |
11380 return $globals.world.objectType.getMember(memberName); | 11075 return $globals.world.objectType.getMember(memberName); |
11381 } | 11076 } |
11382 } | 11077 } |
11383 Type.prototype.ensureSubtypeOf = function(other, span, typeErrors) { | 11078 Type.prototype.ensureSubtypeOf = function(other, span, typeErrors) { |
11384 if (!this.isSubtypeOf(other)) { | 11079 if (!this.isSubtypeOf(other)) { |
11385 var msg = ("type " + this.name + " is not a subtype of " + other.name); | 11080 var msg = ("type " + this.name + " is not a subtype of " + other.name); |
11386 if (typeErrors) { | 11081 if (typeErrors) { |
11387 $globals.world.error(msg, span); | 11082 $globals.world.error(msg, span); |
11388 } | 11083 } |
11389 else { | 11084 else { |
11390 $globals.world.warning(msg, span); | 11085 $globals.world.warning(msg, span); |
11391 } | 11086 } |
11392 } | 11087 } |
11393 } | 11088 } |
11394 Type.prototype.needsVarCall = function(args) { | 11089 Type.prototype.needsVarCall = function(args) { |
11395 if (this.get$isVarOrFunction()) { | 11090 if (this.get$isVarOrFunction()) { |
11396 return true; | 11091 return true; |
11397 } | 11092 } |
11398 var call = this.getCallMethod(); | 11093 var call = this.getCallMethod(); |
11399 if (call != null) { | 11094 if ($ne(call)) { |
11400 if (args.get$length() != call.get$parameters().get$length() || !call.namesIn
Order$1(args)) { | 11095 if (args.get$length() != call.get$parameters().get$length() || !call.namesIn
Order(args)) { |
11401 return true; | 11096 return true; |
11402 } | 11097 } |
11403 } | 11098 } |
11404 return false; | 11099 return false; |
11405 } | 11100 } |
| 11101 Type.prototype.get$needsVarCall = function() { |
| 11102 return this.needsVarCall.bind(this); |
| 11103 } |
11406 Type.union = function(x, y) { | 11104 Type.union = function(x, y) { |
11407 if ($eq(x, y)) return x; | 11105 if ($eq(x, y)) return x; |
11408 if (x.get$isNum() && y.get$isNum()) return $globals.world.numType; | 11106 if (x.get$isNum() && y.get$isNum()) return $globals.world.numType; |
11409 if (x.get$isString() && y.get$isString()) return $globals.world.stringType; | 11107 if (x.get$isString() && y.get$isString()) return $globals.world.stringType; |
11410 return $globals.world.varType; | 11108 return $globals.world.varType; |
11411 } | 11109 } |
11412 Type.prototype.isAssignable = function(other) { | 11110 Type.prototype.isAssignable = function(other) { |
11413 return this.isSubtypeOf(other) || other.isSubtypeOf(this); | 11111 return this.isSubtypeOf(other) || other.isSubtypeOf(this); |
11414 } | 11112 } |
11415 Type.prototype._isDirectSupertypeOf = function(other) { | 11113 Type.prototype._isDirectSupertypeOf = function(other) { |
11416 var $this = this; // closure support | 11114 var $this = this; // closure support |
11417 if (other.get$isClass()) { | 11115 if (other.get$isClass()) { |
11418 return $eq(other.get$parent(), this) || this.get$isObject() && other.get$par
ent() == null; | 11116 return $eq(other.get$parent(), this) || this.get$isObject() && other.get$par
ent() == null; |
11419 } | 11117 } |
11420 else { | 11118 else { |
11421 if (other.get$interfaces() == null || other.get$interfaces().isEmpty()) { | 11119 if (other.get$interfaces() == null || other.get$interfaces().isEmpty()) { |
11422 return this.get$isObject(); | 11120 return this.get$isObject(); |
11423 } | 11121 } |
11424 else { | 11122 else { |
11425 return other.get$interfaces().some((function (i) { | 11123 return other.get$interfaces().some((function (i) { |
11426 return $eq(i, $this); | 11124 return $eq(i, $this); |
11427 }) | 11125 }) |
11428 ); | 11126 ); |
11429 } | 11127 } |
11430 } | 11128 } |
11431 } | 11129 } |
11432 Type.prototype.isSubtypeOf = function(other) { | 11130 Type.prototype.isSubtypeOf = function(other) { |
11433 if ((other instanceof ParameterType)) { | |
11434 return true; | |
11435 } | |
11436 if ($eq(this, other)) return true; | 11131 if ($eq(this, other)) return true; |
11437 if (this.get$isVar()) return true; | 11132 if (this.get$isVar() || other.get$isVar()) return true; |
11438 if (other.get$isVar()) return true; | |
11439 if (other._isDirectSupertypeOf(this)) return true; | 11133 if (other._isDirectSupertypeOf(this)) return true; |
11440 var call = this.getCallMethod(); | 11134 var call = this.getCallMethod(); |
11441 var otherCall = other.getCallMethod(); | 11135 var otherCall = other.getCallMethod(); |
11442 if (call != null && otherCall != null) { | 11136 if ($ne(call) && $ne(otherCall)) { |
11443 return Type._isFunctionSubtypeOf(call, otherCall); | 11137 return Type._isFunctionSubtypeOf(call, otherCall); |
11444 } | 11138 } |
11445 if ($eq(this.get$genericType(), other.get$genericType()) && this.get$typeArgsI
nOrder() != null && other.get$typeArgsInOrder() != null && $eq(this.get$typeArgs
InOrder().get$length(), other.get$typeArgsInOrder().get$length())) { | 11139 if (this.get$genericType() == other.get$genericType()) { |
11446 var t = this.get$typeArgsInOrder().iterator$0(); | 11140 for (var i = (0); |
11447 var s = other.get$typeArgsInOrder().iterator$0(); | 11141 i < this.get$typeArgsInOrder().get$length(); i++) { |
11448 while (t.hasNext$0()) { | 11142 if (!this.get$typeArgsInOrder().$index(i).get$dynamic().isSubtypeOf(other.
get$typeArgsInOrder().$index(i))) { |
11449 if (!t.next$0().isSubtypeOf$1(s.next$0())) return false; | 11143 return false; |
| 11144 } |
11450 } | 11145 } |
11451 return true; | 11146 return true; |
11452 } | 11147 } |
11453 if (this.get$parent() != null && this.get$parent().isSubtypeOf(other)) { | 11148 if (this.get$parent() != null && this.get$parent().isSubtypeOf(other)) { |
11454 return true; | 11149 return true; |
11455 } | 11150 } |
11456 if (this.get$interfaces() != null && this.get$interfaces().some((function (i)
{ | 11151 if (this.get$interfaces() != null && this.get$interfaces().some((function (i)
{ |
11457 return i.isSubtypeOf$1(other); | 11152 return i.isSubtypeOf(other); |
11458 }) | 11153 }) |
11459 )) { | 11154 )) { |
11460 return true; | 11155 return true; |
11461 } | 11156 } |
11462 return false; | 11157 return false; |
11463 } | 11158 } |
11464 Type.prototype.hashCode = function() { | 11159 Type.prototype.hashCode = function() { |
11465 var libraryCode = this.get$library() == null ? (1) : this.get$library().hashCo
de(); | 11160 var libraryCode = this.get$library() == null ? (1) : this.get$library().hashCo
de(); |
11466 var nameCode = this.name == null ? (1) : this.name.hashCode(); | 11161 var nameCode = this.name == null ? (1) : this.name.hashCode(); |
11467 return (libraryCode << (4)) ^ nameCode; | 11162 return $bit_xor(($shl(libraryCode, (4))), nameCode); |
11468 } | 11163 } |
11469 Type.prototype.$eq = function(other) { | 11164 Type.prototype.$eq = function(other) { |
11470 return (other instanceof Type) && $eq(other.get$name(), this.name) && $eq(this
.get$library(), other.get$library()); | 11165 return (other instanceof Type) && $eq(other.get$name(), this.name) && $eq(this
.get$library(), other.get$library()); |
11471 } | 11166 } |
11472 Type._isFunctionSubtypeOf = function(t, s) { | 11167 Type._isFunctionSubtypeOf = function(t, s) { |
11473 if (!s.returnType.get$isVoid() && !s.returnType.isAssignable(t.returnType)) { | 11168 if (!s.returnType.get$isVoid() && !s.returnType.isAssignable(t.returnType)) { |
11474 return false; | 11169 return false; |
11475 } | 11170 } |
11476 var tp = t.parameters; | 11171 var tp = t.parameters; |
11477 var sp = s.parameters; | 11172 var sp = s.parameters; |
11478 if (tp.get$length() < sp.get$length()) return false; | 11173 if (tp.get$length() < sp.get$length()) return false; |
11479 for (var i = (0); | 11174 for (var i = (0); |
11480 i < sp.get$length(); i++) { | 11175 i < sp.get$length(); i++) { |
11481 if ($ne(tp.$index(i).get$isOptional(), sp.$index(i).get$isOptional())) retur
n false; | 11176 if ($ne(tp.$index(i).get$isOptional(), sp.$index(i).get$isOptional())) retur
n false; |
11482 if (tp.$index(i).get$isOptional() && $ne(tp.$index(i).get$name(), sp.$index(
i).get$name())) return false; | 11177 if (tp.$index(i).get$isOptional() && $ne(tp.$index(i).get$name(), sp.$index(
i).get$name())) return false; |
11483 if (!tp.$index(i).get$type().isAssignable$1(sp.$index(i).get$type())) return
false; | 11178 if (!tp.$index(i).get$type().isAssignable(sp.$index(i).get$type())) return f
alse; |
11484 } | 11179 } |
11485 if (tp.get$length() > sp.get$length() && !tp.$index(sp.get$length()).get$isOpt
ional()) return false; | 11180 if (tp.get$length() > sp.get$length() && !tp.$index(sp.get$length()).get$isOpt
ional()) return false; |
11486 return true; | 11181 return true; |
11487 } | 11182 } |
11488 Type.prototype._checkExtends$0 = Type.prototype._checkExtends; | |
11489 Type.prototype.addDirectSubtype$1 = Type.prototype.addDirectSubtype; | |
11490 Type.prototype.ensureSubtypeOf$3 = Type.prototype.ensureSubtypeOf; | |
11491 Type.prototype.getConstructor$1 = Type.prototype.getConstructor; | |
11492 Type.prototype.getFactory$2 = Type.prototype.getFactory; | |
11493 Type.prototype.getMember$1 = Type.prototype.getMember; | |
11494 Type.prototype.getOrMakeConcreteType$1 = Type.prototype.getOrMakeConcreteType; | |
11495 Type.prototype.hashCode$0 = Type.prototype.hashCode; | |
11496 Type.prototype.isAssignable$1 = Type.prototype.isAssignable; | |
11497 Type.prototype.isSubtypeOf$1 = Type.prototype.isSubtypeOf; | |
11498 Type.prototype.markUsed$0 = Type.prototype.markUsed; | |
11499 Type.prototype.resolveTypeParams$1 = Type.prototype.resolveTypeParams; | |
11500 // ********** Code for ParameterType ************** | 11183 // ********** Code for ParameterType ************** |
11501 $inherits(ParameterType, Type); | 11184 $inherits(ParameterType, Type); |
11502 function ParameterType(name, typeParameter) { | 11185 function ParameterType(name, typeParameter) { |
11503 this.typeParameter = typeParameter; | 11186 this.typeParameter = typeParameter; |
11504 Type.call(this, name); | 11187 Type.call(this, name); |
11505 } | 11188 } |
11506 ParameterType.prototype.get$typeParameter = function() { return this.typeParamet
er; }; | 11189 ParameterType.prototype.get$typeParameter = function() { return this.typeParamet
er; }; |
11507 ParameterType.prototype.set$typeParameter = function(value) { return this.typePa
rameter = value; }; | 11190 ParameterType.prototype.set$typeParameter = function(value) { return this.typePa
rameter = value; }; |
11508 ParameterType.prototype.get$extendsType = function() { return this.extendsType;
}; | 11191 ParameterType.prototype.get$extendsType = function() { return this.extendsType;
}; |
11509 ParameterType.prototype.set$extendsType = function(value) { return this.extendsT
ype = value; }; | 11192 ParameterType.prototype.set$extendsType = function(value) { return this.extendsT
ype = value; }; |
(...skipping 17 matching lines...) Expand all Loading... |
11527 } | 11210 } |
11528 ParameterType.prototype.isSubtypeOf = function(other) { | 11211 ParameterType.prototype.isSubtypeOf = function(other) { |
11529 return true; | 11212 return true; |
11530 } | 11213 } |
11531 ParameterType.prototype.getConstructor = function(constructorName) { | 11214 ParameterType.prototype.getConstructor = function(constructorName) { |
11532 $globals.world.internalError("no constructors on type parameters yet"); | 11215 $globals.world.internalError("no constructors on type parameters yet"); |
11533 } | 11216 } |
11534 ParameterType.prototype.getOrMakeConcreteType = function(typeArgs) { | 11217 ParameterType.prototype.getOrMakeConcreteType = function(typeArgs) { |
11535 $globals.world.internalError("no concrete types of type parameters yet", this.
get$span()); | 11218 $globals.world.internalError("no concrete types of type parameters yet", this.
get$span()); |
11536 } | 11219 } |
11537 ParameterType.prototype.resolveTypeParams = function(inType) { | |
11538 return inType.typeArguments.$index(this.name); | |
11539 } | |
11540 ParameterType.prototype.addDirectSubtype = function(type) { | 11220 ParameterType.prototype.addDirectSubtype = function(type) { |
11541 $globals.world.internalError("no subtypes of type parameters yet", this.get$sp
an()); | 11221 $globals.world.internalError("no subtypes of type parameters yet", this.get$sp
an()); |
11542 } | 11222 } |
11543 ParameterType.prototype.resolve = function() { | 11223 ParameterType.prototype.resolve = function() { |
11544 if (this.typeParameter.extendsType != null) { | 11224 if (this.typeParameter.extendsType != null) { |
11545 this.extendsType = this.get$enclosingElement().resolveType$2(this.typeParame
ter.extendsType, true); | 11225 this.extendsType = this.get$enclosingElement().resolveType(this.typeParamete
r.extendsType, true, true); |
11546 } | 11226 } |
11547 else { | 11227 else { |
11548 this.extendsType = $globals.world.objectType; | 11228 this.extendsType = $globals.world.objectType; |
11549 } | 11229 } |
11550 } | 11230 } |
11551 ParameterType.prototype.addDirectSubtype$1 = ParameterType.prototype.addDirectSu
btype; | |
11552 ParameterType.prototype.getConstructor$1 = ParameterType.prototype.getConstructo
r; | |
11553 ParameterType.prototype.getOrMakeConcreteType$1 = ParameterType.prototype.getOrM
akeConcreteType; | |
11554 ParameterType.prototype.isSubtypeOf$1 = ParameterType.prototype.isSubtypeOf; | |
11555 ParameterType.prototype.resolve$0 = ParameterType.prototype.resolve; | |
11556 ParameterType.prototype.resolveTypeParams$1 = ParameterType.prototype.resolveTyp
eParams; | |
11557 // ********** Code for NonNullableType ************** | 11231 // ********** Code for NonNullableType ************** |
11558 $inherits(NonNullableType, Type); | 11232 $inherits(NonNullableType, Type); |
11559 function NonNullableType(type) { | 11233 function NonNullableType(type) { |
11560 this.type = type; | 11234 this.type = type; |
11561 Type.call(this, type.name); | 11235 Type.call(this, type.name); |
11562 } | 11236 } |
11563 NonNullableType.prototype.get$type = function() { return this.type; }; | 11237 NonNullableType.prototype.get$type = function() { return this.type; }; |
11564 NonNullableType.prototype.get$isNullable = function() { | 11238 NonNullableType.prototype.get$isNullable = function() { |
11565 return false; | 11239 return false; |
11566 } | 11240 } |
11567 NonNullableType.prototype.get$isBool = function() { | 11241 NonNullableType.prototype.get$isBool = function() { |
11568 return this.type.get$isBool(); | 11242 return this.type.get$isBool(); |
11569 } | 11243 } |
11570 NonNullableType.prototype.get$isUsed = function() { | 11244 NonNullableType.prototype.get$isUsed = function() { |
11571 return false; | 11245 return false; |
11572 } | 11246 } |
11573 NonNullableType.prototype.isSubtypeOf = function(other) { | 11247 NonNullableType.prototype.isSubtypeOf = function(other) { |
11574 return $eq(this, other) || $eq(this.type, other) || this.type.isSubtypeOf(othe
r); | 11248 return $eq(this, other) || $eq(this.type, other) || this.type.isSubtypeOf(othe
r); |
11575 } | 11249 } |
11576 NonNullableType.prototype.resolveType = function(node, isRequired) { | 11250 NonNullableType.prototype.resolveType = function(node, isRequired, allowTypePara
ms) { |
11577 return this.type.resolveType$2(node, isRequired); | 11251 return this.type.resolveType(node, isRequired, allowTypeParams); |
11578 } | |
11579 NonNullableType.prototype.resolveTypeParams = function(inType) { | |
11580 return this.type.resolveTypeParams(inType); | |
11581 } | 11252 } |
11582 NonNullableType.prototype.addDirectSubtype = function(subtype) { | 11253 NonNullableType.prototype.addDirectSubtype = function(subtype) { |
11583 this.type.addDirectSubtype$1(subtype); | 11254 this.type.addDirectSubtype(subtype); |
11584 } | 11255 } |
11585 NonNullableType.prototype.markUsed = function() { | 11256 NonNullableType.prototype.markUsed = function() { |
11586 this.type.markUsed(); | 11257 this.type.markUsed(); |
11587 } | 11258 } |
11588 NonNullableType.prototype.genMethod = function(method) { | 11259 NonNullableType.prototype.genMethod = function(method) { |
11589 this.type.genMethod(method); | 11260 this.type.genMethod(method); |
11590 } | 11261 } |
11591 NonNullableType.prototype.get$span = function() { | 11262 NonNullableType.prototype.get$span = function() { |
11592 return this.type.get$span(); | 11263 return this.type.get$span(); |
11593 } | 11264 } |
11594 NonNullableType.prototype.getMember = function(name) { | 11265 NonNullableType.prototype.getMember = function(name) { |
11595 return this.type.getMember(name); | 11266 return this.type.getMember(name); |
11596 } | 11267 } |
11597 NonNullableType.prototype.getConstructor = function(name) { | 11268 NonNullableType.prototype.getConstructor = function(name) { |
11598 return this.type.getConstructor$1(name); | 11269 return this.type.getConstructor(name); |
11599 } | |
11600 NonNullableType.prototype.getFactory = function(t, name) { | |
11601 return this.type.getFactory$2(t, name); | |
11602 } | 11270 } |
11603 NonNullableType.prototype.getOrMakeConcreteType = function(typeArgs) { | 11271 NonNullableType.prototype.getOrMakeConcreteType = function(typeArgs) { |
11604 return this.type.getOrMakeConcreteType(typeArgs); | 11272 return this.type.getOrMakeConcreteType(typeArgs); |
11605 } | 11273 } |
11606 NonNullableType.prototype.get$constructors = function() { | 11274 NonNullableType.prototype.get$constructors = function() { |
11607 return this.type.get$constructors(); | 11275 return this.type.get$constructors(); |
11608 } | 11276 } |
11609 NonNullableType.prototype.get$isClass = function() { | 11277 NonNullableType.prototype.get$isClass = function() { |
11610 return this.type.get$isClass(); | 11278 return this.type.get$isClass(); |
11611 } | 11279 } |
(...skipping 29 matching lines...) Expand all Loading... |
11641 } | 11309 } |
11642 NonNullableType.prototype.get$genericType = function() { | 11310 NonNullableType.prototype.get$genericType = function() { |
11643 return this.type.get$genericType(); | 11311 return this.type.get$genericType(); |
11644 } | 11312 } |
11645 NonNullableType.prototype.get$interfaces = function() { | 11313 NonNullableType.prototype.get$interfaces = function() { |
11646 return this.type.get$interfaces(); | 11314 return this.type.get$interfaces(); |
11647 } | 11315 } |
11648 NonNullableType.prototype.get$parent = function() { | 11316 NonNullableType.prototype.get$parent = function() { |
11649 return this.type.get$parent(); | 11317 return this.type.get$parent(); |
11650 } | 11318 } |
11651 NonNullableType.prototype.getAllMembers = function() { | |
11652 return this.type.getAllMembers(); | |
11653 } | |
11654 NonNullableType.prototype.get$isNative = function() { | 11319 NonNullableType.prototype.get$isNative = function() { |
11655 return this.type.get$isNative(); | 11320 return this.type.get$isNative(); |
11656 } | 11321 } |
11657 NonNullableType.prototype.addDirectSubtype$1 = NonNullableType.prototype.addDire
ctSubtype; | |
11658 NonNullableType.prototype.getConstructor$1 = NonNullableType.prototype.getConstr
uctor; | |
11659 NonNullableType.prototype.getFactory$2 = NonNullableType.prototype.getFactory; | |
11660 NonNullableType.prototype.getMember$1 = NonNullableType.prototype.getMember; | |
11661 NonNullableType.prototype.getOrMakeConcreteType$1 = NonNullableType.prototype.ge
tOrMakeConcreteType; | |
11662 NonNullableType.prototype.isSubtypeOf$1 = NonNullableType.prototype.isSubtypeOf; | |
11663 NonNullableType.prototype.markUsed$0 = NonNullableType.prototype.markUsed; | |
11664 NonNullableType.prototype.resolveType$2 = NonNullableType.prototype.resolveType; | |
11665 NonNullableType.prototype.resolveTypeParams$1 = NonNullableType.prototype.resolv
eTypeParams; | |
11666 // ********** Code for ConcreteType ************** | |
11667 $inherits(ConcreteType, Type); | |
11668 function ConcreteType(name, genericType, typeArguments, typeArgsInOrder) { | |
11669 this.isUsed = false; | |
11670 this.constructors = new HashMapImplementation(); | |
11671 this.genericType = genericType; | |
11672 this.factories = new FactoryMap(); | |
11673 this.members = new HashMapImplementation(); | |
11674 this.typeArguments = typeArguments; | |
11675 this.typeArgsInOrder = typeArgsInOrder; | |
11676 Type.call(this, name); | |
11677 } | |
11678 ConcreteType.prototype.get$genericType = function() { return this.genericType; }
; | |
11679 ConcreteType.prototype.get$typeArguments = function() { return this.typeArgument
s; }; | |
11680 ConcreteType.prototype.set$typeArguments = function(value) { return this.typeArg
uments = value; }; | |
11681 ConcreteType.prototype.get$_parent = function() { return this._parent; }; | |
11682 ConcreteType.prototype.set$_parent = function(value) { return this._parent = val
ue; }; | |
11683 ConcreteType.prototype.get$typeArgsInOrder = function() { return this.typeArgsIn
Order; }; | |
11684 ConcreteType.prototype.set$typeArgsInOrder = function(value) { return this.typeA
rgsInOrder = value; }; | |
11685 ConcreteType.prototype.get$isList = function() { | |
11686 return this.genericType.get$isList(); | |
11687 } | |
11688 ConcreteType.prototype.get$isClass = function() { | |
11689 return this.genericType.isClass; | |
11690 } | |
11691 ConcreteType.prototype.get$library = function() { | |
11692 return this.genericType.library; | |
11693 } | |
11694 ConcreteType.prototype.get$span = function() { | |
11695 return this.genericType.get$span(); | |
11696 } | |
11697 ConcreteType.prototype.get$hasTypeParams = function() { | |
11698 return this.typeArguments.getValues().some((function (e) { | |
11699 return (e instanceof ParameterType); | |
11700 }) | |
11701 ); | |
11702 } | |
11703 ConcreteType.prototype.get$isUsed = function() { return this.isUsed; }; | |
11704 ConcreteType.prototype.set$isUsed = function(value) { return this.isUsed = value
; }; | |
11705 ConcreteType.prototype.get$members = function() { return this.members; }; | |
11706 ConcreteType.prototype.set$members = function(value) { return this.members = val
ue; }; | |
11707 ConcreteType.prototype.get$constructors = function() { return this.constructors;
}; | |
11708 ConcreteType.prototype.set$constructors = function(value) { return this.construc
tors = value; }; | |
11709 ConcreteType.prototype.get$factories = function() { return this.factories; }; | |
11710 ConcreteType.prototype.set$factories = function(value) { return this.factories =
value; }; | |
11711 ConcreteType.prototype.resolveTypeParams = function(inType) { | |
11712 var newTypeArgs = []; | |
11713 var needsNewType = false; | |
11714 var $$list = this.typeArgsInOrder; | |
11715 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | |
11716 var t = $$list[$$i]; | |
11717 var newType = t.resolveTypeParams$1(inType); | |
11718 if ($ne(newType, t)) needsNewType = true; | |
11719 newTypeArgs.add$1(newType); | |
11720 } | |
11721 if (!needsNewType) return this; | |
11722 return this.genericType.getOrMakeConcreteType(newTypeArgs); | |
11723 } | |
11724 ConcreteType.prototype.getOrMakeConcreteType = function(typeArgs) { | |
11725 return this.genericType.getOrMakeConcreteType(typeArgs); | |
11726 } | |
11727 ConcreteType.prototype.get$parent = function() { | |
11728 if (this._parent == null && this.genericType.get$parent() != null) { | |
11729 this._parent = this.genericType.get$parent().resolveTypeParams(this); | |
11730 } | |
11731 return this._parent; | |
11732 } | |
11733 ConcreteType.prototype.get$interfaces = function() { | |
11734 if (this._interfaces == null && this.genericType.interfaces != null) { | |
11735 this._interfaces = []; | |
11736 var $$list = this.genericType.interfaces; | |
11737 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | |
11738 var i = $$list[$$i]; | |
11739 this._interfaces.add(i.resolveTypeParams$1(this)); | |
11740 } | |
11741 } | |
11742 return this._interfaces; | |
11743 } | |
11744 ConcreteType.prototype.get$subtypes = function() { | |
11745 if (this._subtypes == null) { | |
11746 this._subtypes = new HashSetImplementation(); | |
11747 var $$list = this.genericType.get$subtypes(); | |
11748 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | |
11749 var s = $$i.next$0(); | |
11750 this._subtypes.add(s.resolveTypeParams$1(this)); | |
11751 } | |
11752 } | |
11753 return this._subtypes; | |
11754 } | |
11755 ConcreteType.prototype.getCallMethod = function() { | |
11756 return this.genericType.getCallMethod(); | |
11757 } | |
11758 ConcreteType.prototype.getAllMembers = function() { | |
11759 var result = this.genericType.getAllMembers(); | |
11760 var $$list = result.getKeys$0(); | |
11761 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | |
11762 var memberName = $$i.next$0(); | |
11763 var myMember = this.members.$index(memberName); | |
11764 if (myMember != null) { | |
11765 result.$setindex(memberName, myMember); | |
11766 } | |
11767 } | |
11768 return result; | |
11769 } | |
11770 ConcreteType.prototype.markUsed = function() { | |
11771 if (this.isUsed) return; | |
11772 this.isUsed = true; | |
11773 this._checkExtends(); | |
11774 this.genericType.markUsed(); | |
11775 } | |
11776 ConcreteType.prototype.genMethod = function(method) { | |
11777 return this.genericType.genMethod(method); | |
11778 } | |
11779 ConcreteType.prototype.getFactory = function(type, constructorName) { | |
11780 return this.genericType.getFactory(type, constructorName); | |
11781 } | |
11782 ConcreteType.prototype.getConstructor = function(constructorName) { | |
11783 var ret = this.constructors.$index(constructorName); | |
11784 if (ret != null) return ret; | |
11785 ret = this.factories.getFactory(this.name, constructorName); | |
11786 if (ret != null) return ret; | |
11787 var genericMember = this.genericType.getConstructor(constructorName); | |
11788 if (genericMember == null) return null; | |
11789 if ($ne(genericMember.get$declaringType(), this.genericType)) { | |
11790 if (!genericMember.get$declaringType().get$isGeneric()) return genericMember
; | |
11791 var newDeclaringType = genericMember.get$declaringType().getOrMakeConcreteTy
pe$1(this.typeArgsInOrder); | |
11792 var factory = newDeclaringType.getFactory$2(this.genericType, constructorNam
e); | |
11793 if (factory != null) return factory; | |
11794 return newDeclaringType.getConstructor$1(constructorName); | |
11795 } | |
11796 if (genericMember.get$isFactory()) { | |
11797 ret = new ConcreteMember(genericMember.get$name(), this, genericMember); | |
11798 this.factories.addFactory(this.name, constructorName, ret); | |
11799 } | |
11800 else { | |
11801 ret = new ConcreteMember(this.name, this, genericMember); | |
11802 this.constructors.$setindex(constructorName, ret); | |
11803 } | |
11804 return ret; | |
11805 } | |
11806 ConcreteType.prototype.getMember = function(memberName) { | |
11807 var member = this._foundMembers.$index(memberName); | |
11808 if (member != null) return member; | |
11809 member = this.members.$index(memberName); | |
11810 if (member != null) { | |
11811 this._checkOverride(member); | |
11812 this._foundMembers.$setindex(memberName, member); | |
11813 return member; | |
11814 } | |
11815 var genericMember = this.genericType.members.$index(memberName); | |
11816 if (genericMember != null) { | |
11817 member = new ConcreteMember(genericMember.get$name(), this, genericMember); | |
11818 this.members.$setindex(memberName, member); | |
11819 this._foundMembers.$setindex(memberName, member); | |
11820 return member; | |
11821 } | |
11822 member = this._getMemberInParents(memberName); | |
11823 this._foundMembers.$setindex(memberName, member); | |
11824 return member; | |
11825 } | |
11826 ConcreteType.prototype.resolveType = function(node, isRequired) { | |
11827 var ret = this.genericType.resolveType$2(node, isRequired); | |
11828 return ret; | |
11829 } | |
11830 ConcreteType.prototype.addDirectSubtype = function(type) { | |
11831 this.genericType.addDirectSubtype(type); | |
11832 } | |
11833 ConcreteType.prototype.addDirectSubtype$1 = ConcreteType.prototype.addDirectSubt
ype; | |
11834 ConcreteType.prototype.getConstructor$1 = ConcreteType.prototype.getConstructor; | |
11835 ConcreteType.prototype.getFactory$2 = ConcreteType.prototype.getFactory; | |
11836 ConcreteType.prototype.getMember$1 = ConcreteType.prototype.getMember; | |
11837 ConcreteType.prototype.getOrMakeConcreteType$1 = ConcreteType.prototype.getOrMak
eConcreteType; | |
11838 ConcreteType.prototype.markUsed$0 = ConcreteType.prototype.markUsed; | |
11839 ConcreteType.prototype.resolveType$2 = ConcreteType.prototype.resolveType; | |
11840 ConcreteType.prototype.resolveTypeParams$1 = ConcreteType.prototype.resolveTypeP
arams; | |
11841 // ********** Code for DefinedType ************** | 11322 // ********** Code for DefinedType ************** |
11842 $inherits(DefinedType, Type); | 11323 $inherits(DefinedType, Type); |
11843 function DefinedType(name, library, definition, isClass) { | 11324 function DefinedType(name, library, definition, isClass) { |
11844 this.isUsed = false; | 11325 this.isUsed = false; |
11845 this.directSubtypes = new HashSetImplementation(); | 11326 this.directSubtypes = new HashSetImplementation_Type(); |
11846 this.isNative = false; | 11327 this.isNative = false; |
11847 this.library = library; | 11328 this.library = library; |
11848 this.isClass = isClass; | 11329 this.isClass = isClass; |
11849 this.constructors = new HashMapImplementation(); | 11330 this.constructors = new HashMapImplementation(); |
11850 this.factories = new FactoryMap(); | 11331 this.factories = new FactoryMap(); |
11851 this.members = new HashMapImplementation(); | 11332 this.members = new HashMapImplementation(); |
11852 Type.call(this, name); | 11333 Type.call(this, name); |
11853 this.setDefinition(definition); | 11334 this.setDefinition(definition); |
11854 } | 11335 } |
11855 DefinedType.prototype.get$definition = function() { return this.definition; }; | 11336 DefinedType.prototype.get$definition = function() { return this.definition; }; |
11856 DefinedType.prototype.set$definition = function(value) { return this.definition
= value; }; | 11337 DefinedType.prototype.set$definition = function(value) { return this.definition
= value; }; |
11857 DefinedType.prototype.get$library = function() { return this.library; }; | 11338 DefinedType.prototype.get$library = function() { return this.library; }; |
11858 DefinedType.prototype.get$isClass = function() { return this.isClass; }; | 11339 DefinedType.prototype.get$isClass = function() { return this.isClass; }; |
11859 DefinedType.prototype.get$_parent = function() { return this._parent; }; | |
11860 DefinedType.prototype.set$_parent = function(value) { return this._parent = valu
e; }; | |
11861 DefinedType.prototype.get$parent = function() { | 11340 DefinedType.prototype.get$parent = function() { |
11862 return this._parent; | 11341 return this._parent; |
11863 } | 11342 } |
11864 DefinedType.prototype.set$parent = function(p) { | 11343 DefinedType.prototype.set$parent = function(p) { |
11865 this._parent = p; | 11344 this._parent = p; |
11866 } | 11345 } |
11867 DefinedType.prototype.get$interfaces = function() { return this.interfaces; }; | 11346 DefinedType.prototype.get$interfaces = function() { return this.interfaces; }; |
11868 DefinedType.prototype.set$interfaces = function(value) { return this.interfaces
= value; }; | 11347 DefinedType.prototype.set$interfaces = function(value) { return this.interfaces
= value; }; |
11869 DefinedType.prototype.get$directSubtypes = function() { return this.directSubtyp
es; }; | 11348 DefinedType.prototype.get$directSubtypes = function() { return this.directSubtyp
es; }; |
11870 DefinedType.prototype.set$directSubtypes = function(value) { return this.directS
ubtypes = value; }; | 11349 DefinedType.prototype.set$directSubtypes = function(value) { return this.directS
ubtypes = value; }; |
11871 DefinedType.prototype.get$typeParameters = function() { return this.typeParamete
rs; }; | 11350 DefinedType.prototype.get$typeParameters = function() { return this.typeParamete
rs; }; |
11872 DefinedType.prototype.set$typeParameters = function(value) { return this.typePar
ameters = value; }; | 11351 DefinedType.prototype.set$typeParameters = function(value) { return this.typePar
ameters = value; }; |
| 11352 DefinedType.prototype.get$typeArgsInOrder = function() { return this.typeArgsInO
rder; }; |
| 11353 DefinedType.prototype.set$typeArgsInOrder = function(value) { return this.typeAr
gsInOrder = value; }; |
11873 DefinedType.prototype.get$constructors = function() { return this.constructors;
}; | 11354 DefinedType.prototype.get$constructors = function() { return this.constructors;
}; |
11874 DefinedType.prototype.set$constructors = function(value) { return this.construct
ors = value; }; | 11355 DefinedType.prototype.set$constructors = function(value) { return this.construct
ors = value; }; |
11875 DefinedType.prototype.get$members = function() { return this.members; }; | 11356 DefinedType.prototype.get$members = function() { return this.members; }; |
11876 DefinedType.prototype.set$members = function(value) { return this.members = valu
e; }; | 11357 DefinedType.prototype.set$members = function(value) { return this.members = valu
e; }; |
11877 DefinedType.prototype.get$factories = function() { return this.factories; }; | 11358 DefinedType.prototype.get$factories = function() { return this.factories; }; |
11878 DefinedType.prototype.set$factories = function(value) { return this.factories =
value; }; | 11359 DefinedType.prototype.set$factories = function(value) { return this.factories =
value; }; |
11879 DefinedType.prototype.get$_concreteTypes = function() { return this._concreteTyp
es; }; | 11360 DefinedType.prototype.get$_concreteTypes = function() { return this._concreteTyp
es; }; |
11880 DefinedType.prototype.set$_concreteTypes = function(value) { return this._concre
teTypes = value; }; | 11361 DefinedType.prototype.set$_concreteTypes = function(value) { return this._concre
teTypes = value; }; |
11881 DefinedType.prototype.get$isUsed = function() { return this.isUsed; }; | 11362 DefinedType.prototype.get$isUsed = function() { return this.isUsed; }; |
11882 DefinedType.prototype.set$isUsed = function(value) { return this.isUsed = value;
}; | 11363 DefinedType.prototype.set$isUsed = function(value) { return this.isUsed = value;
}; |
11883 DefinedType.prototype.get$isNative = function() { return this.isNative; }; | 11364 DefinedType.prototype.get$isNative = function() { return this.isNative; }; |
11884 DefinedType.prototype.set$isNative = function(value) { return this.isNative = va
lue; }; | 11365 DefinedType.prototype.set$isNative = function(value) { return this.isNative = va
lue; }; |
| 11366 DefinedType.prototype.get$baseGenericType = function() { return this.baseGeneric
Type; }; |
| 11367 DefinedType.prototype.set$baseGenericType = function(value) { return this.baseGe
nericType = value; }; |
| 11368 DefinedType.prototype.get$genericType = function() { |
| 11369 return this.baseGenericType == null ? this : this.baseGenericType; |
| 11370 } |
11885 DefinedType.prototype.setDefinition = function(def) { | 11371 DefinedType.prototype.setDefinition = function(def) { |
11886 this.definition = def; | 11372 this.definition = def; |
11887 if ((this.definition instanceof TypeDefinition) && this.definition.get$nativeT
ype() != null) { | 11373 if ((this.definition instanceof TypeDefinition) && this.definition.get$nativeT
ype() != null) { |
11888 this.isNative = true; | 11374 this.isNative = true; |
11889 } | 11375 } |
11890 if (this.definition != null && this.definition.get$typeParameters() != null) { | 11376 if (this.definition != null && $ne(this.definition.get$typeParameters())) { |
11891 this._concreteTypes = new HashMapImplementation(); | 11377 this._concreteTypes = new HashMapImplementation(); |
11892 this.typeParameters = this.definition.get$typeParameters(); | 11378 this.typeParameters = this.definition.get$typeParameters(); |
| 11379 this.typeArgsInOrder = new Array(this.typeParameters.get$length()); |
| 11380 for (var i = (0); |
| 11381 i < this.typeArgsInOrder.get$length(); i++) { |
| 11382 this.typeArgsInOrder.$setindex(i, $globals.world.varType); |
| 11383 } |
| 11384 } |
| 11385 else { |
| 11386 this.typeArgsInOrder = const$0007; |
11893 } | 11387 } |
11894 } | 11388 } |
11895 DefinedType.prototype.get$nativeType = function() { | 11389 DefinedType.prototype.get$nativeType = function() { |
11896 return (this.definition != null ? this.definition.get$nativeType() : null); | 11390 return (this.definition != null ? this.definition.get$nativeType() : null); |
11897 } | 11391 } |
11898 DefinedType.prototype.get$typeArgsInOrder = function() { | |
11899 if (this.typeParameters == null) return null; | |
11900 if (this._typeArgsInOrder == null) { | |
11901 this._typeArgsInOrder = new FixedCollection_Type($globals.world.varType, thi
s.typeParameters.get$length()); | |
11902 } | |
11903 return this._typeArgsInOrder; | |
11904 } | |
11905 DefinedType.prototype.get$isVar = function() { | 11392 DefinedType.prototype.get$isVar = function() { |
11906 return $eq(this, $globals.world.varType); | 11393 return $eq(this, $globals.world.varType); |
11907 } | 11394 } |
11908 DefinedType.prototype.get$isVoid = function() { | 11395 DefinedType.prototype.get$isVoid = function() { |
11909 return $eq(this, $globals.world.voidType); | 11396 return $eq(this, $globals.world.voidType); |
11910 } | 11397 } |
11911 DefinedType.prototype.get$isTop = function() { | 11398 DefinedType.prototype.get$isTop = function() { |
11912 return this.name == null; | 11399 return this.name == null; |
11913 } | 11400 } |
11914 DefinedType.prototype.get$isObject = function() { | 11401 DefinedType.prototype.get$isObject = function() { |
11915 return this.library.get$isCore() && this.name == "Object"; | 11402 return $eq(this, $globals.world.objectType); |
11916 } | 11403 } |
11917 DefinedType.prototype.get$isString = function() { | 11404 DefinedType.prototype.get$isString = function() { |
11918 return this.library.get$isCore() && this.name == "String" || this.library.get$
isCoreImpl() && this.name == "StringImplementation"; | 11405 return $eq(this, $globals.world.stringType) || $eq(this, $globals.world.string
ImplType); |
11919 } | 11406 } |
11920 DefinedType.prototype.get$isBool = function() { | 11407 DefinedType.prototype.get$isBool = function() { |
11921 return this.library.get$isCore() && this.name == "bool"; | 11408 return $eq(this, $globals.world.boolType); |
11922 } | 11409 } |
11923 DefinedType.prototype.get$isFunction = function() { | 11410 DefinedType.prototype.get$isFunction = function() { |
11924 return this.library.get$isCore() && this.name == "Function"; | 11411 return $eq(this, $globals.world.functionType) || $eq(this, $globals.world.func
tionImplType); |
11925 } | |
11926 DefinedType.prototype.get$isList = function() { | |
11927 return this.library.get$isCore() && this.name == "List"; | |
11928 } | 11412 } |
11929 DefinedType.prototype.get$isGeneric = function() { | 11413 DefinedType.prototype.get$isGeneric = function() { |
11930 return this.typeParameters != null; | 11414 return this.typeParameters != null; |
11931 } | 11415 } |
11932 DefinedType.prototype.get$span = function() { | 11416 DefinedType.prototype.get$span = function() { |
11933 return this.definition == null ? null : this.definition.span; | 11417 return this.definition == null ? null : this.definition.span; |
11934 } | 11418 } |
11935 DefinedType.prototype.get$typeofName = function() { | 11419 DefinedType.prototype.get$typeofName = function() { |
11936 if (!this.library.get$isCore()) return null; | 11420 if (!this.library.get$isCore()) return null; |
11937 if (this.get$isBool()) return "boolean"; | 11421 if (this.get$isBool()) return "boolean"; |
11938 else if (this.get$isNum()) return "number"; | 11422 else if (this.get$isNum()) return "number"; |
11939 else if (this.get$isString()) return "string"; | 11423 else if (this.get$isString()) return "string"; |
11940 else if (this.get$isFunction()) return "function"; | 11424 else if (this.get$isFunction()) return "function"; |
11941 else return null; | 11425 else return null; |
11942 } | 11426 } |
11943 DefinedType.prototype.get$isNum = function() { | 11427 DefinedType.prototype.get$isNum = function() { |
11944 return $eq(this, $globals.world.numType) || $eq(this, $globals.world.intType)
|| $eq(this, $globals.world.doubleType) || $eq(this, $globals.world.numImplType)
; | 11428 return $eq(this, $globals.world.numType) || $eq(this, $globals.world.intType)
|| $eq(this, $globals.world.doubleType) || $eq(this, $globals.world.numImplType)
; |
11945 } | 11429 } |
11946 DefinedType.prototype.getCallMethod = function() { | 11430 DefinedType.prototype.getCallMethod = function() { |
11947 return this.members.$index(":call"); | 11431 return this.get$genericType().members.$index(":call"); |
11948 } | 11432 } |
11949 DefinedType.prototype.getAllMembers = function() { | 11433 DefinedType.prototype.getAllMembers = function() { |
11950 return HashMapImplementation.HashMapImplementation$from$factory(this.members); | 11434 return HashMapImplementation.HashMapImplementation$from$factory(this.members); |
11951 } | 11435 } |
11952 DefinedType.prototype.markUsed = function() { | 11436 DefinedType.prototype.markUsed = function() { |
11953 if (this.isUsed) return; | 11437 if (this.isUsed) return; |
11954 this.isUsed = true; | 11438 this.isUsed = true; |
11955 this._checkExtends(); | 11439 this._checkExtends(); |
11956 if (this._lazyGenMethods != null) { | 11440 if (this._lazyGenMethods != null) { |
11957 var $$list = orderValuesByKeys(this._lazyGenMethods); | 11441 var $$list = orderValuesByKeys(this._lazyGenMethods); |
11958 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 11442 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
11959 var method = $$list[$$i]; | 11443 var method = $$i.next(); |
11960 $globals.world.gen.genMethod(method); | 11444 $globals.world.gen.genMethod(method); |
11961 } | 11445 } |
11962 this._lazyGenMethods = null; | 11446 this._lazyGenMethods = null; |
11963 } | 11447 } |
11964 if (this.get$parent() != null) this.get$parent().markUsed(); | 11448 if (this.get$parent() != null) this.get$parent().markUsed(); |
11965 } | 11449 } |
11966 DefinedType.prototype.genMethod = function(method) { | 11450 DefinedType.prototype.genMethod = function(method) { |
11967 if (this.isUsed) { | 11451 if (this.isUsed || this.baseGenericType != null) { |
11968 $globals.world.gen.genMethod(method); | 11452 $globals.world.gen.genMethod(method); |
11969 } | 11453 } |
11970 else if (this.isClass) { | 11454 else if (this.isClass) { |
11971 if (this._lazyGenMethods == null) this._lazyGenMethods = new HashMapImplemen
tation(); | 11455 if (this._lazyGenMethods == null) this._lazyGenMethods = new HashMapImplemen
tation(); |
11972 this._lazyGenMethods.$setindex(method.name, method); | 11456 this._lazyGenMethods.$setindex(method.name, method); |
11973 } | 11457 } |
11974 } | 11458 } |
11975 DefinedType.prototype._resolveInterfaces = function(types) { | 11459 DefinedType.prototype._resolveInterfaces = function(types) { |
11976 if (types == null) return []; | 11460 if (types == null) return []; |
11977 var interfaces = []; | 11461 var interfaces = []; |
11978 for (var $$i = 0;$$i < types.get$length(); $$i++) { | 11462 for (var $$i = types.iterator(); $$i.hasNext(); ) { |
11979 var type = types[$$i]; | 11463 var type = $$i.next(); |
11980 var resolvedInterface = this.resolveType$2(type, true); | 11464 var resolvedInterface = this.resolveType(type, true, true); |
11981 if (resolvedInterface.get$isClosed() && !(this.library.get$isCore() || this.
library.get$isCoreImpl())) { | 11465 if (resolvedInterface.get$isClosed() && !(this.library.get$isCore() || this.
library.get$isCoreImpl())) { |
11982 $globals.world.error(("can not implement \"" + resolvedInterface.get$name(
) + "\": ") + "only native implementation allowed", type.get$span()); | 11466 $globals.world.error($add(("can not implement \"" + resolvedInterface.get$
name() + "\": "), "only native implementation allowed"), type.get$span()); |
11983 } | 11467 } |
11984 resolvedInterface.addDirectSubtype$1(this); | 11468 resolvedInterface.addDirectSubtype(this); |
11985 interfaces.add$1(resolvedInterface); | 11469 interfaces.add(resolvedInterface); |
11986 } | 11470 } |
11987 return interfaces; | 11471 return interfaces; |
11988 } | 11472 } |
11989 DefinedType.prototype.addDirectSubtype = function(type) { | 11473 DefinedType.prototype.addDirectSubtype = function(type) { |
11990 this.directSubtypes.add(type); | 11474 this.directSubtypes.add(type); |
| 11475 if (this.baseGenericType != null) { |
| 11476 this.baseGenericType.addDirectSubtype(type); |
| 11477 } |
11991 } | 11478 } |
11992 DefinedType.prototype.get$subtypes = function() { | 11479 DefinedType.prototype.get$subtypes = function() { |
11993 if (this._subtypes == null) { | 11480 if (this._subtypes == null) { |
11994 this._subtypes = new HashSetImplementation(); | 11481 this._subtypes = new HashSetImplementation_Type(); |
11995 var $$list = this.directSubtypes; | 11482 var $$list = this.directSubtypes; |
11996 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 11483 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
11997 var st = $$i.next$0(); | 11484 var st = $$i.next(); |
11998 this._subtypes.add(st); | 11485 this._subtypes.add(st); |
11999 this._subtypes.addAll(st.get$subtypes()); | 11486 this._subtypes.addAll(st.get$subtypes()); |
12000 } | 11487 } |
12001 } | 11488 } |
12002 return this._subtypes; | 11489 return this._subtypes; |
12003 } | 11490 } |
12004 DefinedType.prototype._cycleInClassExtends = function() { | 11491 DefinedType.prototype._cycleInClassExtends = function() { |
12005 var seen = new HashSetImplementation(); | 11492 var seen = new HashSetImplementation(); |
12006 seen.add$1(this); | 11493 seen.add(this); |
12007 var ancestor = this.get$parent(); | 11494 var ancestor = this.get$parent(); |
12008 while (ancestor != null) { | 11495 while ($ne(ancestor)) { |
12009 if (ancestor == this) { | 11496 if (ancestor == this) { |
12010 return true; | 11497 return true; |
12011 } | 11498 } |
12012 if (seen.contains$1(ancestor)) { | 11499 if (seen.contains$1(ancestor)) { |
12013 return false; | 11500 return false; |
12014 } | 11501 } |
12015 seen.add$1(ancestor); | 11502 seen.add(ancestor); |
12016 ancestor = ancestor.get$parent(); | 11503 ancestor = ancestor.get$parent(); |
12017 } | 11504 } |
12018 return false; | 11505 return false; |
12019 } | 11506 } |
12020 DefinedType.prototype._cycleInInterfaceExtends = function() { | 11507 DefinedType.prototype._cycleInInterfaceExtends = function() { |
12021 var $this = this; // closure support | 11508 var $this = this; // closure support |
12022 var seen = new HashSetImplementation(); | 11509 var seen = new HashSetImplementation(); |
12023 seen.add$1(this); | 11510 seen.add(this); |
12024 function _helper(ancestor) { | 11511 function _helper(ancestor) { |
12025 if (ancestor == null) return false; | 11512 if ($eq(ancestor)) return false; |
12026 if (ancestor == $this) return true; | 11513 if (ancestor == $this) return true; |
12027 if (seen.contains$1(ancestor)) { | 11514 if (seen.contains$1(ancestor)) { |
12028 return false; | 11515 return false; |
12029 } | 11516 } |
12030 seen.add$1(ancestor); | 11517 seen.add(ancestor); |
12031 if (ancestor.get$interfaces() != null) { | 11518 if (ancestor.get$interfaces() != null) { |
12032 var $$list = ancestor.get$interfaces(); | 11519 var $$list = ancestor.get$interfaces(); |
12033 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 11520 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
12034 var parent = $$i.next$0(); | 11521 var parent = $$i.next(); |
12035 if (_helper.call$1(parent)) return true; | 11522 if (_helper(parent)) return true; |
12036 } | 11523 } |
12037 } | 11524 } |
12038 return false; | 11525 return false; |
12039 } | 11526 } |
12040 for (var i = (0); | 11527 for (var i = (0); |
12041 i < this.interfaces.get$length(); i++) { | 11528 i < this.interfaces.get$length(); i++) { |
12042 if (_helper.call$1(this.interfaces[i])) return i; | 11529 if (_helper(this.interfaces.$index(i))) return i; |
12043 } | 11530 } |
12044 return (-1); | 11531 return (-1); |
12045 } | 11532 } |
12046 DefinedType.prototype.resolve = function() { | 11533 DefinedType.prototype.resolve = function() { |
12047 if ((this.definition instanceof TypeDefinition)) { | 11534 if ((this.definition instanceof TypeDefinition)) { |
12048 var typeDef = this.definition; | 11535 var typeDef = this.definition; |
12049 if (this.isClass) { | 11536 if (this.isClass) { |
12050 if (typeDef.extendsTypes != null && typeDef.extendsTypes.get$length() > (0
)) { | 11537 if (typeDef.extendsTypes != null && typeDef.extendsTypes.get$length() > (0
)) { |
12051 if (typeDef.extendsTypes.get$length() > (1)) { | 11538 if (typeDef.extendsTypes.get$length() > (1)) { |
12052 $globals.world.error("more than one base class", typeDef.extendsTypes[
(1)].get$span()); | 11539 $globals.world.error("more than one base class", typeDef.extendsTypes[
(1)].span); |
12053 } | 11540 } |
12054 var extendsTypeRef = typeDef.extendsTypes[(0)]; | 11541 var extendsTypeRef = typeDef.extendsTypes[(0)]; |
12055 if ((extendsTypeRef instanceof GenericTypeReference)) { | 11542 if ((extendsTypeRef instanceof GenericTypeReference)) { |
12056 var g = extendsTypeRef; | 11543 var g = extendsTypeRef; |
12057 this.set$parent(this.resolveType$2(g.baseType, true)); | 11544 this.set$parent(this.resolveType(g.baseType, true, true)); |
12058 } | 11545 } |
12059 this.set$parent(this.resolveType$2(extendsTypeRef, true)); | 11546 this.set$parent(this.resolveType(extendsTypeRef, true, true)); |
12060 if (!this.get$parent().get$isClass()) { | 11547 if (!this.get$parent().get$isClass()) { |
12061 $globals.world.error("class may not extend an interface - use implemen
ts", typeDef.extendsTypes[(0)].get$span()); | 11548 $globals.world.error("class may not extend an interface - use implemen
ts", typeDef.extendsTypes[(0)].span); |
12062 } | 11549 } |
12063 this.get$parent().addDirectSubtype$1(this); | 11550 this.get$parent().addDirectSubtype(this); |
12064 if (this._cycleInClassExtends()) { | 11551 if (this._cycleInClassExtends()) { |
12065 $globals.world.error(("class \"" + this.name + "\" has a cycle in its
inheritance chain"), extendsTypeRef.get$span()); | 11552 $globals.world.error(("class \"" + this.name + "\" has a cycle in its
inheritance chain"), extendsTypeRef.get$span()); |
12066 } | 11553 } |
12067 } | 11554 } |
12068 else { | 11555 else { |
12069 if (!this.get$isObject()) { | 11556 if (!this.get$isObject()) { |
12070 this.set$parent($globals.world.objectType); | 11557 this.set$parent($globals.world.objectType); |
12071 this.get$parent().addDirectSubtype$1(this); | 11558 this.get$parent().addDirectSubtype(this); |
12072 } | 11559 } |
12073 } | 11560 } |
12074 this.interfaces = this._resolveInterfaces(typeDef.implementsTypes); | 11561 this.interfaces = this._resolveInterfaces(typeDef.implementsTypes); |
12075 if (typeDef.defaultType != null) { | 11562 if (typeDef.defaultType != null) { |
12076 $globals.world.error("default not allowed on classes", typeDef.defaultTy
pe.span); | 11563 $globals.world.error("default not allowed on classes", typeDef.defaultTy
pe.span); |
12077 } | 11564 } |
12078 } | 11565 } |
12079 else { | 11566 else { |
12080 if (typeDef.implementsTypes != null && typeDef.implementsTypes.get$length(
) > (0)) { | 11567 if (typeDef.implementsTypes != null && typeDef.implementsTypes.get$length(
) > (0)) { |
12081 $globals.world.error("implements not allowed on interfaces (use extends)
", typeDef.implementsTypes[(0)].get$span()); | 11568 $globals.world.error("implements not allowed on interfaces (use extends)
", typeDef.implementsTypes[(0)].span); |
12082 } | 11569 } |
12083 this.interfaces = this._resolveInterfaces(typeDef.extendsTypes); | 11570 this.interfaces = this._resolveInterfaces(typeDef.extendsTypes); |
12084 var res = this._cycleInInterfaceExtends(); | 11571 var res = this._cycleInInterfaceExtends(); |
12085 if (res >= (0)) { | 11572 if ($gte(res, (0))) { |
12086 $globals.world.error(("interface \"" + this.name + "\" has a cycle in it
s inheritance chain"), typeDef.extendsTypes[res].get$span()); | 11573 $globals.world.error(("interface \"" + this.name + "\" has a cycle in it
s inheritance chain"), typeDef.extendsTypes.$index(res).span); |
12087 } | 11574 } |
12088 if (typeDef.defaultType != null) { | 11575 if (typeDef.defaultType != null) { |
12089 this.defaultType = this.resolveType$2(typeDef.defaultType.baseType, true
); | 11576 this.defaultType = this.resolveType(typeDef.defaultType.baseType, true,
true); |
12090 if (this.defaultType == null) { | 11577 if (this.defaultType == null) { |
12091 $globals.world.warning("unresolved default class", typeDef.defaultType
.span); | 11578 $globals.world.warning("unresolved default class", typeDef.defaultType
.span); |
12092 } | 11579 } |
12093 else { | 11580 else { |
12094 this.defaultType._resolveTypeParams(typeDef.defaultType.typeParameters
); | 11581 if (this.baseGenericType != null) { |
| 11582 if (!this.defaultType.get$isGeneric()) { |
| 11583 $globals.world.error("default type of generic interface must be ge
neric", typeDef.defaultType.span); |
| 11584 } |
| 11585 this.defaultType = this.defaultType.getOrMakeConcreteType(this.typeA
rgsInOrder); |
| 11586 } |
12095 } | 11587 } |
12096 } | 11588 } |
12097 } | 11589 } |
12098 } | 11590 } |
12099 else if ((this.definition instanceof FunctionTypeDefinition)) { | 11591 else if ((this.definition instanceof FunctionTypeDefinition)) { |
12100 this.interfaces = [$globals.world.functionType]; | 11592 this.interfaces = [$globals.world.functionType]; |
12101 } | 11593 } |
12102 this._resolveTypeParams(this.typeParameters); | 11594 this._resolveTypeParams(this.typeParameters); |
12103 if (this.get$isObject()) this._createNotEqualMember(); | 11595 if (this.get$isObject()) this._createNotEqualMember(); |
12104 $globals.world._addType(this); | 11596 if ($ne(this.baseGenericType, $globals.world.listFactoryType)) $globals.world.
_addType(this); |
12105 var $$list = this.constructors.getValues(); | 11597 var $$list = this.constructors.getValues(); |
12106 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 11598 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
12107 var c = $$i.next$0(); | 11599 var c = $$i.next(); |
12108 c.resolve$0(); | 11600 c.resolve(); |
12109 } | 11601 } |
12110 var $$list = this.members.getValues(); | 11602 var $$list = this.members.getValues(); |
12111 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 11603 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
12112 var m = $$i.next$0(); | 11604 var m = $$i.next(); |
12113 m.resolve$0(); | 11605 m.resolve(); |
12114 } | 11606 } |
12115 this.factories.forEach((function (f) { | 11607 this.factories.forEach((function (f) { |
12116 return f.resolve$0(); | 11608 return f.resolve(); |
12117 }) | 11609 }) |
12118 ); | 11610 ); |
12119 if (this.get$isJsGlobalObject()) { | 11611 if (this.get$isJsGlobalObject()) { |
12120 var $$list = this.members.getValues(); | 11612 var $$list = this.members.getValues(); |
12121 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 11613 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
12122 var m = $$i.next$0(); | 11614 var m = $$i.next(); |
12123 if (!m.get$isStatic()) $globals.world._addTopName(new ExistingJsGlobal(m.g
et$name(), m)); | 11615 if (!m.get$isStatic()) $globals.world._addTopName(new ExistingJsGlobal(m.g
et$name(), m)); |
12124 } | 11616 } |
12125 } | 11617 } |
12126 } | 11618 } |
12127 DefinedType.prototype._resolveTypeParams = function(params) { | 11619 DefinedType.prototype._resolveTypeParams = function(params) { |
12128 if (params == null) return; | 11620 if (params == null) return; |
12129 for (var $$i = 0;$$i < params.get$length(); $$i++) { | 11621 for (var $$i = params.iterator(); $$i.hasNext(); ) { |
12130 var tp = params[$$i]; | 11622 var tp = $$i.next(); |
12131 tp.set$enclosingElement(this); | 11623 tp.set$enclosingElement(this); |
12132 tp.resolve$0(); | 11624 tp.resolve(); |
12133 } | 11625 } |
12134 } | 11626 } |
12135 DefinedType.prototype.addMethod = function(methodName, definition) { | 11627 DefinedType.prototype.addMethod = function(methodName, definition) { |
12136 if (methodName == null) methodName = definition.name.name; | 11628 if (methodName == null) methodName = definition.name.name; |
12137 var method = new MethodMember(methodName, this, definition); | 11629 var method = new MethodMember(methodName, this, definition); |
12138 if (method.get$isConstructor()) { | 11630 if (method.get$isConstructor()) { |
12139 if (this.constructors.containsKey(method.get$constructorName())) { | 11631 if (this.constructors.containsKey(method.get$constructorName())) { |
12140 $globals.world.error(("duplicate constructor definition of " + method.get$
name()), definition.span); | 11632 $globals.world.error(("duplicate constructor definition of " + method.get$
name()), definition.span); |
12141 return; | 11633 return; |
12142 } | 11634 } |
12143 this.constructors.$setindex(method.get$constructorName(), method); | 11635 this.constructors.$setindex(method.get$constructorName(), method); |
12144 return; | 11636 return; |
12145 } | 11637 } |
12146 if (definition.modifiers != null && definition.modifiers.get$length() == (1) &
& $eq(definition.modifiers[(0)].get$kind(), (74))) { | 11638 if (definition.modifiers != null && definition.modifiers.get$length() == (1) &
& definition.modifiers[(0)].kind == (74)) { |
12147 if (this.factories.getFactory(method.get$constructorName(), method.get$name(
)) != null) { | 11639 if (this.factories.getFactory(method.get$constructorName(), method.get$name(
)) != null) { |
12148 $globals.world.error(("duplicate factory definition of \"" + method.get$na
me() + "\""), definition.span); | 11640 $globals.world.error(("duplicate factory definition of \"" + method.get$na
me() + "\""), definition.span); |
12149 return; | 11641 return; |
12150 } | 11642 } |
12151 this.factories.addFactory(method.get$constructorName(), method.get$name(), m
ethod); | 11643 this.factories.addFactory(method.get$constructorName(), method.get$name(), m
ethod); |
12152 return; | 11644 return; |
12153 } | 11645 } |
12154 if (methodName.startsWith("get:") || methodName.startsWith("set:")) { | 11646 if (methodName.startsWith("get:") || methodName.startsWith("set:")) { |
12155 var propName = methodName.substring((4)); | 11647 var propName = methodName.substring((4)); |
12156 var prop = this.members.$index(propName); | 11648 var prop = this.members.$index(propName); |
12157 if (prop == null) { | 11649 if ($eq(prop)) { |
12158 prop = new PropertyMember(propName, this); | 11650 prop = new PropertyMember(propName, this); |
12159 this.members.$setindex(propName, prop); | 11651 this.members.$setindex(propName, prop); |
12160 } | 11652 } |
12161 if (!(prop instanceof PropertyMember)) { | 11653 if (!(prop instanceof PropertyMember)) { |
12162 $globals.world.error(("property conflicts with field \"" + propName + "\""
), definition.span); | 11654 $globals.world.error(("property conflicts with field \"" + propName + "\""
), definition.span); |
12163 return; | 11655 return; |
12164 } | 11656 } |
12165 if (methodName[(0)] == "g") { | 11657 if (methodName[(0)] == "g") { |
12166 if (prop.get$getter() != null) { | 11658 if (prop.get$getter() != null) { |
12167 $globals.world.error(("duplicate getter definition for \"" + propName +
"\""), definition.span); | 11659 $globals.world.error(("duplicate getter definition for \"" + propName +
"\""), definition.span); |
(...skipping 10 matching lines...) Expand all Loading... |
12178 } | 11670 } |
12179 if (this.members.containsKey(methodName)) { | 11671 if (this.members.containsKey(methodName)) { |
12180 $globals.world.error(("duplicate method definition of \"" + method.get$name(
) + "\""), definition.span); | 11672 $globals.world.error(("duplicate method definition of \"" + method.get$name(
) + "\""), definition.span); |
12181 return; | 11673 return; |
12182 } | 11674 } |
12183 this.members.$setindex(methodName, method); | 11675 this.members.$setindex(methodName, method); |
12184 } | 11676 } |
12185 DefinedType.prototype.addField = function(definition) { | 11677 DefinedType.prototype.addField = function(definition) { |
12186 for (var i = (0); | 11678 for (var i = (0); |
12187 i < definition.names.get$length(); i++) { | 11679 i < definition.names.get$length(); i++) { |
12188 var name = definition.names[i].get$name(); | 11680 var name = definition.names[i].name; |
12189 if (this.members.containsKey(name)) { | 11681 if (this.members.containsKey(name)) { |
12190 $globals.world.error(("duplicate field definition of \"" + name + "\""), d
efinition.span); | 11682 $globals.world.error(("duplicate field definition of \"" + name + "\""), d
efinition.span); |
12191 return; | 11683 return; |
12192 } | 11684 } |
12193 var value = null; | 11685 var value = null; |
12194 if (definition.values != null) { | 11686 if (definition.values != null) { |
12195 value = definition.values[i]; | 11687 value = definition.values[i]; |
12196 } | 11688 } |
12197 var field = new FieldMember(name, this, definition, value); | 11689 var field = new FieldMember(name, this, definition, value); |
12198 this.members.$setindex(name, field); | 11690 this.members.$setindex(name, field); |
12199 if (this.isNative) { | 11691 if (this.isNative) { |
12200 field.set$isNative(true); | 11692 field.set$isNative(true); |
12201 } | 11693 } |
12202 } | 11694 } |
12203 } | 11695 } |
12204 DefinedType.prototype.getFactory = function(type, constructorName) { | 11696 DefinedType.prototype.getFactory = function(type, constructorName) { |
12205 var ret = this.factories.getFactory(type.name, constructorName); | 11697 if (this.baseGenericType != null) { |
12206 if (ret != null) return ret; | 11698 var rr = this.baseGenericType.get$factories().getFactory(type.get$genericTyp
e().name, constructorName); |
| 11699 if ($ne(rr)) { |
| 11700 $globals.world.info(("need to remap factory on " + this.name + " from " +
rr.get$declaringType().name)); |
| 11701 return rr; |
| 11702 } |
| 11703 else { |
| 11704 var ret = this.getConstructor(constructorName); |
| 11705 return ret; |
| 11706 } |
| 11707 } |
| 11708 var ret = this.factories.getFactory(type.get$genericType().name, constructorNa
me); |
| 11709 if ($ne(ret)) return ret; |
12207 ret = this.factories.getFactory(this.name, constructorName); | 11710 ret = this.factories.getFactory(this.name, constructorName); |
12208 if (ret != null) return ret; | 11711 if ($ne(ret)) return ret; |
12209 ret = this.constructors.$index(constructorName); | 11712 ret = this.constructors.$index(constructorName); |
12210 if (ret != null) return ret; | 11713 if ($ne(ret)) return ret; |
12211 return this._tryCreateDefaultConstructor(constructorName); | 11714 return this._tryCreateDefaultConstructor(constructorName); |
12212 } | 11715 } |
12213 DefinedType.prototype.getConstructor = function(constructorName) { | 11716 DefinedType.prototype.getConstructor = function(constructorName) { |
| 11717 if (this.baseGenericType != null) { |
| 11718 var rr = this.constructors.$index(constructorName); |
| 11719 if ($ne(rr)) return rr; |
| 11720 rr = this.baseGenericType.get$constructors().$index(constructorName); |
| 11721 if ($ne(rr)) { |
| 11722 if (this.defaultType != null) { |
| 11723 var ret = this.defaultType.getFactory(this, constructorName); |
| 11724 return ret; |
| 11725 } |
| 11726 } |
| 11727 else { |
| 11728 rr = this.baseGenericType.get$factories().getFactory(this.baseGenericType.
name, constructorName); |
| 11729 } |
| 11730 if ($eq(rr)) { |
| 11731 rr = this.baseGenericType.get$dynamic()._tryCreateDefaultConstructor(const
ructorName); |
| 11732 } |
| 11733 if ($eq(rr)) return null; |
| 11734 var rr1 = rr.makeConcrete(this); |
| 11735 rr1.resolve(); |
| 11736 this.constructors.$setindex(constructorName, rr1); |
| 11737 return rr1; |
| 11738 } |
12214 var ret = this.constructors.$index(constructorName); | 11739 var ret = this.constructors.$index(constructorName); |
12215 if (ret != null) { | 11740 if ($ne(ret)) { |
12216 if (this.defaultType != null) { | 11741 if (this.defaultType != null) { |
12217 this._checkDefaultTypeParams(); | |
12218 return this.defaultType.getFactory(this, constructorName); | 11742 return this.defaultType.getFactory(this, constructorName); |
12219 } | 11743 } |
12220 return ret; | 11744 return ret; |
12221 } | 11745 } |
12222 ret = this.factories.getFactory(this.name, constructorName); | 11746 ret = this.factories.getFactory(this.name, constructorName); |
12223 if (ret != null) return ret; | 11747 if ($ne(ret)) return ret; |
12224 return this._tryCreateDefaultConstructor(constructorName); | 11748 return this._tryCreateDefaultConstructor(constructorName); |
12225 } | 11749 } |
12226 DefinedType.prototype._checkDefaultTypeParams = function() { | |
12227 function toList(list) { | |
12228 return (list != null ? list : const$0008); | |
12229 } | |
12230 var typeDef = this.definition; | |
12231 if (typeDef.defaultType.oldFactory) { | |
12232 return; | |
12233 } | |
12234 var interfaceParams = toList.call$1(this.typeParameters); | |
12235 var defaultParams = toList.call$1(typeDef.defaultType.typeParameters); | |
12236 var classParams = toList.call$1(this.defaultType.typeParameters); | |
12237 if ($ne(interfaceParams.get$length(), defaultParams.get$length()) || $ne(defau
ltParams.get$length(), classParams.get$length())) { | |
12238 $globals.world.error("\"default\" must have the same number of type paramete
rs as the class and interface do", this.get$span(), typeDef.defaultType.span, th
is.defaultType.get$span()); | |
12239 return; | |
12240 } | |
12241 for (var i = (0); | |
12242 i < interfaceParams.get$length(); i++) { | |
12243 var ip = interfaceParams.$index(i); | |
12244 var dp = defaultParams.$index(i); | |
12245 var cp = classParams.$index(i); | |
12246 dp.resolve$0(); | |
12247 if ($ne(ip.get$name(), dp.get$name()) || $ne(dp.get$name(), cp.get$name()))
{ | |
12248 $globals.world.error("default class must have the same type parameter name
s as the class and interface", ip.get$span(), dp.get$span(), cp.get$span()); | |
12249 } | |
12250 else if ($ne(dp.get$extendsType(), cp.get$extendsType())) { | |
12251 $globals.world.error("default class type parameters must have the same ext
ends as the class does", dp.get$span(), cp.get$span()); | |
12252 } | |
12253 else if (!dp.get$extendsType().isSubtypeOf$1(ip.get$extendsType())) { | |
12254 $globals.world.warning("\"default\" can only have tighter type parameter \
"extends\" than the interface", dp.get$span(), ip.get$span()); | |
12255 } | |
12256 } | |
12257 } | |
12258 DefinedType.prototype._tryCreateDefaultConstructor = function(name) { | 11750 DefinedType.prototype._tryCreateDefaultConstructor = function(name) { |
12259 if (name == "" && this.definition != null && this.isClass && this.constructors
.get$length() == (0)) { | 11751 if (name == "" && this.definition != null && this.isClass && this.constructors
.get$length() == (0)) { |
12260 var span = this.definition.span; | 11752 var span = this.definition.span; |
12261 var inits = null, native_ = null, body = null; | 11753 var inits = null, native_ = null, body = null; |
12262 if (this.isNative) { | 11754 if (this.isNative) { |
12263 native_ = ""; | 11755 native_ = ""; |
12264 inits = null; | 11756 inits = null; |
12265 } | 11757 } |
12266 else { | 11758 else { |
12267 body = null; | 11759 body = null; |
12268 inits = [new CallExpression(new SuperExpression(span), [], span)]; | 11760 inits = [new CallExpression(new SuperExpression(span), [], span)]; |
12269 } | 11761 } |
12270 var typeDef = this.definition; | 11762 var typeDef = this.definition; |
12271 var c = new FunctionDefinition(null, null, typeDef.name, [], inits, native_,
body, span); | 11763 var c = new FunctionDefinition(null, null, typeDef.name, [], inits, native_,
body, span); |
12272 this.addMethod(null, c); | 11764 this.addMethod(null, c); |
12273 this.constructors.$index("").resolve$0(); | 11765 this.constructors.$index("").resolve(); |
12274 return this.constructors.$index(""); | 11766 return this.constructors.$index(""); |
12275 } | 11767 } |
12276 return null; | 11768 return null; |
12277 } | 11769 } |
12278 DefinedType.prototype.getMember = function(memberName) { | 11770 DefinedType.prototype.getMember = function(memberName) { |
12279 var member = this._foundMembers.$index(memberName); | 11771 var member = this._foundMembers.$index(memberName); |
12280 if (member != null) return member; | 11772 if (member != null) return member; |
| 11773 if (this.baseGenericType != null) { |
| 11774 member = this.baseGenericType.getMember(memberName); |
| 11775 if (member == null) return null; |
| 11776 if (member.get$isStatic() || $ne(member.declaringType, this.baseGenericType)
) { |
| 11777 this._foundMembers.$setindex(memberName, member); |
| 11778 return member; |
| 11779 } |
| 11780 var rr = member.makeConcrete(this); |
| 11781 if (member.get$definition() != null || (member instanceof PropertyMember)) { |
| 11782 rr.resolve(); |
| 11783 } |
| 11784 else { |
| 11785 $globals.world.info(("no definition for " + member.name + " on " + this.na
me)); |
| 11786 } |
| 11787 this.members.$setindex(memberName, rr); |
| 11788 this._foundMembers.$setindex(memberName, rr); |
| 11789 return rr; |
| 11790 } |
12281 member = this.members.$index(memberName); | 11791 member = this.members.$index(memberName); |
12282 if (member != null) { | 11792 if (member != null) { |
12283 this._checkOverride(member); | 11793 this._checkOverride(member); |
12284 this._foundMembers.$setindex(memberName, member); | 11794 this._foundMembers.$setindex(memberName, member); |
12285 return member; | 11795 return member; |
12286 } | 11796 } |
12287 if (this.get$isTop()) { | 11797 if (this.get$isTop()) { |
12288 var libType = this.library.findTypeByName(memberName); | 11798 var libType = this.library.findTypeByName(memberName); |
12289 if (libType != null) { | 11799 if ($ne(libType)) { |
12290 member = libType.get$typeMember(); | 11800 member = libType.get$typeMember(); |
12291 this._foundMembers.$setindex(memberName, member); | 11801 this._foundMembers.$setindex(memberName, member); |
12292 return member; | 11802 return member; |
12293 } | 11803 } |
12294 } | 11804 } |
12295 member = this._getMemberInParents(memberName); | 11805 member = this._getMemberInParents(memberName); |
12296 this._foundMembers.$setindex(memberName, member); | 11806 this._foundMembers.$setindex(memberName, member); |
12297 return member; | 11807 return member; |
12298 } | 11808 } |
12299 DefinedType.prototype.resolveTypeParams = function(inType) { | |
12300 return this; | |
12301 } | |
12302 DefinedType.prototype.getOrMakeConcreteType = function(typeArgs) { | 11809 DefinedType.prototype.getOrMakeConcreteType = function(typeArgs) { |
12303 var jsnames = []; | 11810 var jsnames = []; |
12304 var names = []; | 11811 var names = []; |
12305 var typeMap = new HashMapImplementation(); | 11812 var typeMap = new HashMapImplementation(); |
| 11813 var allVar = true; |
12306 for (var i = (0); | 11814 for (var i = (0); |
12307 i < typeArgs.get$length(); i++) { | 11815 i < typeArgs.get$length(); i++) { |
12308 var paramName = this.typeParameters[i].get$name(); | 11816 var typeArg = typeArgs.$index(i); |
12309 typeMap.$setindex(paramName, typeArgs[i]); | 11817 if ((typeArg instanceof ParameterType)) { |
12310 names.add$1(typeArgs[i].get$name()); | 11818 typeArg = $globals.world.varType; |
12311 jsnames.add$1(typeArgs[i].get$jsname()); | 11819 typeArgs.$setindex(i, typeArg); |
| 11820 } |
| 11821 if (!typeArg.get$isVar()) allVar = false; |
| 11822 var paramName = this.typeParameters[i].name; |
| 11823 typeMap.$setindex(paramName, typeArg); |
| 11824 names.add(typeArg.get$name()); |
| 11825 jsnames.add(typeArg.get$jsname()); |
12312 } | 11826 } |
| 11827 if (allVar) return this; |
12313 var jsname = ("" + this.get$jsname() + "_" + Strings.join(jsnames, "$")); | 11828 var jsname = ("" + this.get$jsname() + "_" + Strings.join(jsnames, "$")); |
12314 var simpleName = ("" + this.name + "<" + Strings.join(names, ", ") + ">"); | 11829 var simpleName = ("" + this.name + "<" + Strings.join(names, ", ") + ">"); |
12315 var key = Strings.join(names, "$"); | 11830 var key = Strings.join(names, "$"); |
12316 var ret = this._concreteTypes.$index(key); | 11831 var ret = this._concreteTypes.$index(key); |
12317 if (ret == null) { | 11832 if ($eq(ret)) { |
12318 ret = new ConcreteType(simpleName, this, typeMap, typeArgs); | 11833 ret = new DefinedType(simpleName, this.library, this.definition, this.isClas
s); |
| 11834 ret.set$baseGenericType(this); |
| 11835 ret.set$typeArgsInOrder(typeArgs); |
12319 ret.set$_jsname(jsname); | 11836 ret.set$_jsname(jsname); |
12320 this._concreteTypes.$setindex(key, ret); | 11837 this._concreteTypes.$setindex(key, ret); |
| 11838 ret.resolve(); |
12321 } | 11839 } |
12322 return ret; | 11840 return ret; |
12323 } | 11841 } |
12324 DefinedType.prototype.getCallStub = function(args) { | 11842 DefinedType.prototype.getCallStub = function(args) { |
12325 var name = _getCallStubName("call", args); | 11843 var name = _getCallStubName("call", args); |
12326 var stub = this.varStubs.$index(name); | 11844 var stub = this.varStubs.$index(name); |
12327 if (stub == null) { | 11845 if ($eq(stub)) { |
12328 stub = new VarFunctionStub(name, args); | 11846 stub = new VarFunctionStub(name, args); |
12329 this.varStubs.$setindex(name, stub); | 11847 this.varStubs.$setindex(name, stub); |
12330 } | 11848 } |
12331 return stub; | 11849 return stub; |
12332 } | 11850 } |
12333 DefinedType.prototype.addDirectSubtype$1 = DefinedType.prototype.addDirectSubtyp
e; | |
12334 DefinedType.prototype.addMethod$2 = DefinedType.prototype.addMethod; | |
12335 DefinedType.prototype.getConstructor$1 = DefinedType.prototype.getConstructor; | |
12336 DefinedType.prototype.getFactory$2 = DefinedType.prototype.getFactory; | |
12337 DefinedType.prototype.getMember$1 = DefinedType.prototype.getMember; | |
12338 DefinedType.prototype.getOrMakeConcreteType$1 = DefinedType.prototype.getOrMakeC
oncreteType; | |
12339 DefinedType.prototype.markUsed$0 = DefinedType.prototype.markUsed; | |
12340 DefinedType.prototype.resolve$0 = DefinedType.prototype.resolve; | |
12341 DefinedType.prototype.resolveTypeParams$1 = DefinedType.prototype.resolveTypePar
ams; | |
12342 DefinedType.prototype.setDefinition$1 = DefinedType.prototype.setDefinition; | |
12343 // ********** Code for NativeType ************** | 11851 // ********** Code for NativeType ************** |
12344 function NativeType(name) { | 11852 function NativeType(name) { |
12345 this.isConstructorHidden = false; | 11853 this.isConstructorHidden = false; |
12346 this.isSingleton = false; | 11854 this.isSingleton = false; |
12347 this.isJsGlobalObject = false; | 11855 this.isJsGlobalObject = false; |
12348 this.name = name; | 11856 this.name = name; |
12349 while (true) { | 11857 while (true) { |
12350 if (this.name.startsWith("@")) { | 11858 if (this.name.startsWith("@")) { |
12351 this.name = this.name.substring((1)); | 11859 this.name = this.name.substring((1)); |
12352 this.isJsGlobalObject = true; | 11860 this.isJsGlobalObject = true; |
12353 } | 11861 } |
12354 else if (this.name.startsWith("*")) { | 11862 else if (this.name.startsWith("*")) { |
12355 this.name = this.name.substring((1)); | 11863 this.name = this.name.substring((1)); |
12356 this.isConstructorHidden = true; | 11864 this.isConstructorHidden = true; |
12357 } | 11865 } |
12358 else { | 11866 else { |
12359 break; | 11867 break; |
12360 } | 11868 } |
12361 } | 11869 } |
12362 if (this.name.startsWith("=")) { | 11870 if (this.name.startsWith("=")) { |
12363 this.name = this.name.substring((1)); | 11871 this.name = this.name.substring((1)); |
12364 this.isSingleton = true; | 11872 this.isSingleton = true; |
12365 } | 11873 } |
12366 } | 11874 } |
12367 NativeType.prototype.get$name = function() { return this.name; }; | 11875 NativeType.prototype.get$name = function() { return this.name; }; |
12368 NativeType.prototype.set$name = function(value) { return this.name = value; }; | 11876 NativeType.prototype.set$name = function(value) { return this.name = value; }; |
12369 // ********** Code for FixedCollection ************** | |
12370 function FixedCollection(value, length) { | |
12371 this.length = length; | |
12372 this.value = value; | |
12373 } | |
12374 FixedCollection.prototype.get$value = function() { return this.value; }; | |
12375 FixedCollection.prototype.get$length = function() { return this.length; }; | |
12376 FixedCollection.prototype.iterator = function() { | |
12377 return new FixedIterator_E(this.value, this.length); | |
12378 } | |
12379 FixedCollection.prototype.forEach = function(f) { | |
12380 Collections.forEach(this, f); | |
12381 } | |
12382 FixedCollection.prototype.filter = function(f) { | |
12383 return Collections.filter(this, new Array(), f); | |
12384 } | |
12385 FixedCollection.prototype.every = function(f) { | |
12386 return Collections.every(this, f); | |
12387 } | |
12388 FixedCollection.prototype.some = function(f) { | |
12389 return Collections.some(this, f); | |
12390 } | |
12391 FixedCollection.prototype.isEmpty = function() { | |
12392 return this.length == (0); | |
12393 } | |
12394 FixedCollection.prototype.filter$1 = function($0) { | |
12395 return this.filter(to$call$1($0)); | |
12396 }; | |
12397 FixedCollection.prototype.forEach$1 = function($0) { | |
12398 return this.forEach(to$call$1($0)); | |
12399 }; | |
12400 FixedCollection.prototype.isEmpty$0 = FixedCollection.prototype.isEmpty; | |
12401 FixedCollection.prototype.iterator$0 = FixedCollection.prototype.iterator; | |
12402 // ********** Code for FixedCollection_Type ************** | |
12403 $inherits(FixedCollection_Type, FixedCollection); | |
12404 function FixedCollection_Type(value, length) { | |
12405 this.value = value; | |
12406 this.length = length; | |
12407 } | |
12408 // ********** Code for FixedIterator ************** | |
12409 function FixedIterator(value, length) { | |
12410 this.length = length; | |
12411 this._index = (0); | |
12412 this.value = value; | |
12413 } | |
12414 FixedIterator.prototype.get$value = function() { return this.value; }; | |
12415 FixedIterator.prototype.get$length = function() { return this.length; }; | |
12416 FixedIterator.prototype.hasNext = function() { | |
12417 return this._index < this.length; | |
12418 } | |
12419 FixedIterator.prototype.next = function() { | |
12420 this._index++; | |
12421 return this.value; | |
12422 } | |
12423 FixedIterator.prototype.hasNext$0 = FixedIterator.prototype.hasNext; | |
12424 FixedIterator.prototype.next$0 = FixedIterator.prototype.next; | |
12425 // ********** Code for FixedIterator_E ************** | |
12426 $inherits(FixedIterator_E, FixedIterator); | |
12427 function FixedIterator_E(value, length) { | |
12428 this._index = (0); | |
12429 this.value = value; | |
12430 this.length = length; | |
12431 } | |
12432 // ********** Code for _SharedBackingMap ************** | 11877 // ********** Code for _SharedBackingMap ************** |
12433 $inherits(_SharedBackingMap, HashMapImplementation_K$V); | 11878 $inherits(_SharedBackingMap, HashMapImplementation); |
12434 function _SharedBackingMap() { | 11879 function _SharedBackingMap() { |
12435 this.shared = (0); | 11880 this.shared = (0); |
12436 HashMapImplementation_K$V.call(this); | 11881 HashMapImplementation.call(this); |
12437 } | 11882 } |
12438 _SharedBackingMap._SharedBackingMap$from$factory = function(other) { | 11883 _SharedBackingMap._SharedBackingMap$from$factory = function(other) { |
12439 var result = new _SharedBackingMap_K$V(); | 11884 var result = new _SharedBackingMap(); |
12440 other.forEach((function (k, v) { | 11885 other.forEach((function (k, v) { |
12441 result.$setindex(k, v); | 11886 result.$setindex(k, v); |
12442 }) | 11887 }) |
12443 ); | |
12444 return result; | |
12445 } | |
12446 // ********** Code for _SharedBackingMap_K$V ************** | |
12447 $inherits(_SharedBackingMap_K$V, _SharedBackingMap); | |
12448 function _SharedBackingMap_K$V() { | |
12449 this.shared = (0); | |
12450 HashMapImplementation_K$V.call(this); | |
12451 } | |
12452 _SharedBackingMap_K$V._SharedBackingMap$from$factory = function(other) { | |
12453 var result = new _SharedBackingMap_K$V(); | |
12454 other.forEach((function (k, v) { | |
12455 result.$setindex(k, v); | |
12456 }) | |
12457 ); | 11888 ); |
12458 return result; | 11889 return result; |
12459 } | 11890 } |
12460 // ********** Code for _SharedBackingMap_dart_core_String$VariableValue ********
****** | 11891 // ********** Code for _SharedBackingMap_dart_core_String$VariableValue ********
****** |
12461 $inherits(_SharedBackingMap_dart_core_String$VariableValue, _SharedBackingMap); | 11892 $inherits(_SharedBackingMap_dart_core_String$VariableValue, _SharedBackingMap); |
12462 function _SharedBackingMap_dart_core_String$VariableValue() { | 11893 function _SharedBackingMap_dart_core_String$VariableValue() { |
12463 this.shared = (0); | 11894 this.shared = (0); |
12464 HashMapImplementation_dart_core_String$VariableValue.call(this); | 11895 HashMapImplementation_dart_core_String$VariableValue.call(this); |
12465 } | 11896 } |
12466 _SharedBackingMap_dart_core_String$VariableValue._SharedBackingMap$from$factory
= function(other) { | |
12467 var result = new _SharedBackingMap_dart_core_String$VariableValue(); | |
12468 other.forEach((function (k, v) { | |
12469 result.$setindex(k, v); | |
12470 }) | |
12471 ); | |
12472 return result; | |
12473 } | |
12474 // ********** Code for CopyOnWriteMap ************** | 11897 // ********** Code for CopyOnWriteMap ************** |
12475 function CopyOnWriteMap() { | |
12476 this._lang_map = new _SharedBackingMap_K$V(); | |
12477 } | |
12478 CopyOnWriteMap._wrap$ctor = function(_map) { | 11898 CopyOnWriteMap._wrap$ctor = function(_map) { |
12479 this._lang_map = _map; | 11899 this._lang_map = _map; |
12480 } | 11900 } |
12481 CopyOnWriteMap._wrap$ctor.prototype = CopyOnWriteMap.prototype; | 11901 CopyOnWriteMap._wrap$ctor.prototype = CopyOnWriteMap.prototype; |
| 11902 function CopyOnWriteMap() {} |
12482 CopyOnWriteMap.prototype.clone = function() { | 11903 CopyOnWriteMap.prototype.clone = function() { |
12483 this._lang_map.shared++; | 11904 var $0; |
12484 return new CopyOnWriteMap_K$V._wrap$ctor(this._lang_map); | 11905 ($0 = this._lang_map).shared = $0.shared + (1); |
| 11906 return new CopyOnWriteMap._wrap$ctor(this._lang_map); |
12485 } | 11907 } |
12486 CopyOnWriteMap.prototype._ensureWritable = function() { | 11908 CopyOnWriteMap.prototype._ensureWritable = function() { |
| 11909 var $0; |
12487 if (this._lang_map.shared > (0)) { | 11910 if (this._lang_map.shared > (0)) { |
12488 this._lang_map.shared--; | 11911 ($0 = this._lang_map).shared = $0.shared - (1); |
12489 this._lang_map = _SharedBackingMap._SharedBackingMap$from$factory(this._lang
_map); | 11912 this._lang_map = _SharedBackingMap._SharedBackingMap$from$factory(this._lang
_map); |
12490 } | 11913 } |
12491 } | 11914 } |
12492 CopyOnWriteMap.prototype.$setindex = function(key, value) { | 11915 CopyOnWriteMap.prototype.$setindex = function(key, value) { |
12493 this._ensureWritable(); | 11916 this._ensureWritable(); |
12494 this._lang_map.$setindex(key, value); | 11917 this._lang_map.$setindex(key, value); |
12495 } | 11918 } |
12496 CopyOnWriteMap.prototype.putIfAbsent = function(key, ifAbsent) { | 11919 CopyOnWriteMap.prototype.putIfAbsent = function(key, ifAbsent) { |
12497 this._ensureWritable(); | 11920 this._ensureWritable(); |
12498 return this._lang_map.putIfAbsent(key, ifAbsent); | 11921 return this._lang_map.putIfAbsent(key, ifAbsent); |
12499 } | 11922 } |
| 11923 CopyOnWriteMap.prototype.remove = function(key) { |
| 11924 this._ensureWritable(); |
| 11925 return this._lang_map.remove(key); |
| 11926 } |
12500 CopyOnWriteMap.prototype.$index = function(key) { | 11927 CopyOnWriteMap.prototype.$index = function(key) { |
12501 return this._lang_map.$index(key); | 11928 return this._lang_map.$index(key); |
12502 } | 11929 } |
12503 CopyOnWriteMap.prototype.isEmpty = function() { | 11930 CopyOnWriteMap.prototype.isEmpty = function() { |
12504 return this._lang_map.isEmpty(); | 11931 return this._lang_map.isEmpty(); |
12505 } | 11932 } |
12506 CopyOnWriteMap.prototype.get$length = function() { | 11933 CopyOnWriteMap.prototype.get$length = function() { |
12507 return this._lang_map.get$length(); | 11934 return this._lang_map.get$length(); |
12508 } | 11935 } |
12509 CopyOnWriteMap.prototype.forEach = function(f) { | 11936 CopyOnWriteMap.prototype.forEach = function(f) { |
12510 return this._lang_map.forEach(f); | 11937 return this._lang_map.forEach(f); |
12511 } | 11938 } |
12512 CopyOnWriteMap.prototype.getKeys = function() { | 11939 CopyOnWriteMap.prototype.getKeys = function() { |
12513 return this._lang_map.getKeys(); | 11940 return this._lang_map.getKeys(); |
12514 } | 11941 } |
12515 CopyOnWriteMap.prototype.getValues = function() { | 11942 CopyOnWriteMap.prototype.getValues = function() { |
12516 return this._lang_map.getValues(); | 11943 return this._lang_map.getValues(); |
12517 } | 11944 } |
12518 CopyOnWriteMap.prototype.containsKey = function(key) { | 11945 CopyOnWriteMap.prototype.containsKey = function(key) { |
12519 return this._lang_map.containsKey(key); | 11946 return this._lang_map.containsKey(key); |
12520 } | 11947 } |
12521 CopyOnWriteMap.prototype.containsKey$1 = CopyOnWriteMap.prototype.containsKey; | 11948 CopyOnWriteMap.prototype.remove$1 = CopyOnWriteMap.prototype.remove; |
12522 CopyOnWriteMap.prototype.forEach$1 = function($0) { | |
12523 return this.forEach(to$call$2($0)); | |
12524 }; | |
12525 CopyOnWriteMap.prototype.getKeys$0 = CopyOnWriteMap.prototype.getKeys; | |
12526 CopyOnWriteMap.prototype.getValues$0 = CopyOnWriteMap.prototype.getValues; | |
12527 CopyOnWriteMap.prototype.isEmpty$0 = CopyOnWriteMap.prototype.isEmpty; | |
12528 // ********** Code for CopyOnWriteMap_K$V ************** | |
12529 $inherits(CopyOnWriteMap_K$V, CopyOnWriteMap); | |
12530 function CopyOnWriteMap_K$V() {} | |
12531 CopyOnWriteMap_K$V._wrap$ctor = function(_map) { | |
12532 this._lang_map = _map; | |
12533 } | |
12534 CopyOnWriteMap_K$V._wrap$ctor.prototype = CopyOnWriteMap_K$V.prototype; | |
12535 // ********** Code for CopyOnWriteMap_dart_core_String$VariableValue ***********
*** | 11949 // ********** Code for CopyOnWriteMap_dart_core_String$VariableValue ***********
*** |
12536 $inherits(CopyOnWriteMap_dart_core_String$VariableValue, CopyOnWriteMap); | 11950 $inherits(CopyOnWriteMap_dart_core_String$VariableValue, CopyOnWriteMap); |
12537 function CopyOnWriteMap_dart_core_String$VariableValue() { | 11951 function CopyOnWriteMap_dart_core_String$VariableValue() { |
12538 this._lang_map = new _SharedBackingMap_dart_core_String$VariableValue(); | 11952 this._lang_map = new _SharedBackingMap_dart_core_String$VariableValue(); |
12539 } | 11953 } |
12540 CopyOnWriteMap_dart_core_String$VariableValue._wrap$ctor = function(_map) { | 11954 CopyOnWriteMap_dart_core_String$VariableValue.prototype.remove$1 = CopyOnWriteMa
p_dart_core_String$VariableValue.prototype.remove; |
12541 this._lang_map = _map; | |
12542 } | |
12543 CopyOnWriteMap_dart_core_String$VariableValue._wrap$ctor.prototype = CopyOnWrite
Map_dart_core_String$VariableValue.prototype; | |
12544 CopyOnWriteMap_dart_core_String$VariableValue.prototype.clone = function() { | |
12545 this._lang_map.shared++; | |
12546 return new CopyOnWriteMap_dart_core_String$VariableValue._wrap$ctor(this._lang
_map); | |
12547 } | |
12548 CopyOnWriteMap_dart_core_String$VariableValue.prototype._ensureWritable = functi
on() { | |
12549 if (this._lang_map.shared > (0)) { | |
12550 this._lang_map.shared--; | |
12551 this._lang_map = _SharedBackingMap._SharedBackingMap$from$factory(this._lang
_map); | |
12552 } | |
12553 } | |
12554 CopyOnWriteMap_dart_core_String$VariableValue.prototype.$setindex = function(key
, value) { | |
12555 this._ensureWritable(); | |
12556 this._lang_map.$setindex(key, value); | |
12557 } | |
12558 CopyOnWriteMap_dart_core_String$VariableValue.prototype.$index = function(key) { | |
12559 return this._lang_map.$index(key); | |
12560 } | |
12561 CopyOnWriteMap_dart_core_String$VariableValue.prototype.forEach = function(f) { | |
12562 return this._lang_map.forEach(f); | |
12563 } | |
12564 CopyOnWriteMap_dart_core_String$VariableValue.prototype.containsKey = function(k
ey) { | |
12565 return this._lang_map.containsKey(key); | |
12566 } | |
12567 // ********** Code for Value ************** | 11955 // ********** Code for Value ************** |
12568 function Value(type, code, span) { | 11956 function Value(type, code, span) { |
12569 this.type = type; | 11957 this.type = type; |
12570 this.span = span; | 11958 this.span = span; |
12571 this.code = code; | 11959 this.code = code; |
12572 if (this.get$type() == null) $globals.world.internalError("type passed as null
", this.span); | 11960 if (this.get$type() == null) $globals.world.internalError("type passed as null
", this.span); |
12573 } | 11961 } |
12574 Value.prototype.get$type = function() { return this.type; }; | 11962 Value.prototype.get$type = function() { return this.type; }; |
12575 Value.prototype.get$code = function() { return this.code; }; | 11963 Value.prototype.get$code = function() { return this.code; }; |
12576 Value.prototype.get$span = function() { return this.span; }; | 11964 Value.prototype.get$span = function() { return this.span; }; |
(...skipping 15 matching lines...) Expand all Loading... |
12592 Value.prototype.get$staticType = function() { | 11980 Value.prototype.get$staticType = function() { |
12593 return this.get$type(); | 11981 return this.get$type(); |
12594 } | 11982 } |
12595 Value.comma = function(x, y) { | 11983 Value.comma = function(x, y) { |
12596 return new Value(y.get$type(), ("(" + x.get$code() + ", " + y.get$code() + ")"
), null); | 11984 return new Value(y.get$type(), ("(" + x.get$code() + ", " + y.get$code() + ")"
), null); |
12597 } | 11985 } |
12598 Value.union = function(x, y) { | 11986 Value.union = function(x, y) { |
12599 if (y == null || $eq(x, y)) return x; | 11987 if (y == null || $eq(x, y)) return x; |
12600 if (x == null) return y; | 11988 if (x == null) return y; |
12601 var ret = x._tryUnion(y); | 11989 var ret = x._tryUnion(y); |
12602 if (ret != null) return ret; | 11990 if ($ne(ret)) return ret; |
12603 ret = y._tryUnion(x); | 11991 ret = y._tryUnion(x); |
12604 if (ret != null) return ret; | 11992 if ($ne(ret)) return ret; |
12605 return new Value(Type.union(x.get$type(), y.get$type()), null, null); | 11993 return new Value(Type.union(x.get$type(), y.get$type()), null, null); |
12606 } | 11994 } |
12607 Value.prototype._tryUnion = function(right) { | 11995 Value.prototype._tryUnion = function(right) { |
12608 return null; | 11996 return null; |
12609 } | 11997 } |
12610 Value.prototype.validateInitialized = function(span) { | 11998 Value.prototype.validateInitialized = function(span) { |
12611 | 11999 |
12612 } | 12000 } |
12613 Value.prototype.get_ = function(context, name, node) { | 12001 Value.prototype.get_ = function(context, name, node) { |
12614 var member = this._resolveMember(context, name, node, false); | 12002 var member = this._resolveMember(context, name, node); |
12615 if (member != null) { | 12003 if ($ne(member)) { |
12616 return member._get$3(context, node, this); | 12004 return member._get(context, node, this); |
12617 } | 12005 } |
12618 else { | 12006 else { |
12619 return this.invokeNoSuchMethod(context, ("get:" + name), node); | 12007 return this.invokeNoSuchMethod(context, ("get:" + name), node); |
12620 } | 12008 } |
12621 } | 12009 } |
12622 Value.prototype.set_ = function(context, name, node, value, isDynamic, kind, ret
urnKind) { | 12010 Value.prototype.set_ = function(context, name, node, value, kind, returnKind) { |
12623 var member = this._resolveMember(context, name, node, isDynamic); | 12011 var member = this._resolveMember(context, name, node); |
12624 if (member != null) { | 12012 if ($ne(member)) { |
12625 var thisValue = this; | 12013 var thisValue = this; |
12626 var thisTmp = null; | 12014 var thisTmp = null; |
12627 var retTmp = null; | 12015 var retTmp = null; |
12628 if (kind != (0)) { | 12016 if (kind != (0)) { |
12629 thisTmp = context.getTemp(thisValue); | 12017 thisTmp = context.getTemp(thisValue); |
12630 thisValue = context.assignTemp(thisTmp, thisValue); | 12018 thisValue = context.assignTemp(thisTmp, thisValue); |
12631 var lhs = member._get$3(context, node, thisTmp); | 12019 var lhs = member._get(context, node, thisTmp); |
12632 if (returnKind == (3)) { | 12020 if (returnKind == (3)) { |
12633 retTmp = context.forceTemp(lhs); | 12021 retTmp = context.forceTemp(lhs); |
12634 lhs = context.assignTemp(retTmp, lhs); | 12022 lhs = context.assignTemp(retTmp, lhs); |
12635 } | 12023 } |
12636 value = lhs.binop$4(kind, value, context, node); | 12024 value = lhs.binop(kind, value, context, node); |
12637 } | 12025 } |
12638 if (returnKind == (2)) { | 12026 if (returnKind == (2)) { |
12639 retTmp = context.forceTemp(value); | 12027 retTmp = context.forceTemp(value); |
12640 value = context.assignTemp(retTmp, value); | 12028 value = context.assignTemp(retTmp, value); |
12641 } | 12029 } |
12642 var ret = member._set$5(context, node, thisValue, value, isDynamic); | 12030 var ret = member._set(context, node, thisValue, value); |
12643 if (thisTmp != null && $ne(thisTmp, this)) context.freeTemp(thisTmp); | 12031 if ($ne(thisTmp) && $ne(thisTmp, this)) context.freeTemp(thisTmp); |
12644 if (retTmp != null) { | 12032 if ($ne(retTmp)) { |
12645 context.freeTemp(retTmp); | 12033 context.freeTemp(retTmp); |
12646 return Value.comma(ret, retTmp); | 12034 return Value.comma(ret, retTmp); |
12647 } | 12035 } |
12648 else { | 12036 else { |
12649 return ret; | 12037 return ret; |
12650 } | 12038 } |
12651 } | 12039 } |
12652 else { | 12040 else { |
12653 return this.invokeNoSuchMethod(context, ("set:" + name), node, new Arguments
(null, [value])); | 12041 return this.invokeNoSuchMethod(context, ("set:" + name), node, new Arguments
(null, [value])); |
12654 } | 12042 } |
12655 } | 12043 } |
12656 Value.prototype.setIndex = function(context, index, node, value, isDynamic, kind
, returnKind) { | 12044 Value.prototype.setIndex = function(context, index, node, value, kind, returnKin
d) { |
12657 var member = this._resolveMember(context, ":setindex", node, isDynamic); | 12045 var member = this._resolveMember(context, ":setindex", node); |
12658 if (member != null) { | 12046 if ($ne(member)) { |
12659 var thisValue = this; | 12047 var thisValue = this; |
12660 var indexValue = index; | 12048 var indexValue = index; |
12661 var thisTmp = null; | 12049 var thisTmp = null; |
12662 var indexTmp = null; | 12050 var indexTmp = null; |
12663 var retTmp = null; | 12051 var retTmp = null; |
12664 if (returnKind == (2)) { | 12052 if (returnKind == (2)) { |
12665 retTmp = context.forceTemp(value); | 12053 retTmp = context.forceTemp(value); |
12666 } | 12054 } |
12667 if (kind != (0)) { | 12055 if (kind != (0)) { |
12668 thisTmp = context.getTemp(this); | 12056 thisTmp = context.getTemp(this); |
12669 indexTmp = context.getTemp(index); | 12057 indexTmp = context.getTemp(index); |
12670 thisValue = context.assignTemp(thisTmp, thisValue); | 12058 thisValue = context.assignTemp(thisTmp, thisValue); |
12671 indexValue = context.assignTemp(indexTmp, indexValue); | 12059 indexValue = context.assignTemp(indexTmp, indexValue); |
12672 if (returnKind == (3)) { | 12060 if (returnKind == (3)) { |
12673 retTmp = context.forceTemp(value); | 12061 retTmp = context.forceTemp(value); |
12674 } | 12062 } |
12675 var lhs = thisTmp.invoke$4(context, ":index", node, new Arguments(null, [i
ndexTmp])); | 12063 var lhs = thisTmp.invoke(context, ":index", node, new Arguments(null, [ind
exTmp])); |
12676 if (returnKind == (3)) { | 12064 if (returnKind == (3)) { |
12677 lhs = context.assignTemp(retTmp, lhs); | 12065 lhs = context.assignTemp(retTmp, lhs); |
12678 } | 12066 } |
12679 value = lhs.binop$4(kind, value, context, node); | 12067 value = lhs.binop(kind, value, context, node); |
12680 } | 12068 } |
12681 if (returnKind == (2)) { | 12069 if (returnKind == (2)) { |
12682 value = context.assignTemp(retTmp, value); | 12070 value = context.assignTemp(retTmp, value); |
12683 } | 12071 } |
12684 var ret = member.invoke$5(context, node, thisValue, new Arguments(null, [ind
exValue, value]), isDynamic); | 12072 var ret = member.invoke(context, node, thisValue, new Arguments(null, [index
Value, value])); |
12685 if (thisTmp != null && $ne(thisTmp, this)) context.freeTemp(thisTmp); | 12073 if ($ne(thisTmp) && $ne(thisTmp, this)) context.freeTemp(thisTmp); |
12686 if (indexTmp != null && $ne(indexTmp, index)) context.freeTemp(indexTmp); | 12074 if ($ne(indexTmp) && $ne(indexTmp, index)) context.freeTemp(indexTmp); |
12687 if (retTmp != null) { | 12075 if ($ne(retTmp)) { |
12688 context.freeTemp(retTmp); | 12076 context.freeTemp(retTmp); |
12689 return Value.comma(ret, retTmp); | 12077 return Value.comma(ret, retTmp); |
12690 } | 12078 } |
12691 else { | 12079 else { |
12692 return ret; | 12080 return ret; |
12693 } | 12081 } |
12694 } | 12082 } |
12695 else { | 12083 else { |
12696 return this.invokeNoSuchMethod(context, ":index", node, new Arguments(null,
[index, value])); | 12084 return this.invokeNoSuchMethod(context, ":index", node, new Arguments(null,
[index, value])); |
12697 } | 12085 } |
12698 } | 12086 } |
12699 Value.prototype.unop = function(kind, context, node) { | 12087 Value.prototype.unop = function(kind, context, node) { |
12700 switch (kind) { | 12088 switch (kind) { |
12701 case (19): | 12089 case (19): |
12702 | 12090 |
12703 var newVal = this.convertTo(context, $globals.world.nonNullBool, false); | 12091 var newVal = this.convertTo(context, $globals.world.nonNullBool); |
12704 return new Value(newVal.get$type(), ("!" + newVal.get$code()), node.get$sp
an()); | 12092 return new Value(newVal.get$type(), ("!" + newVal.get$code()), node.get$sp
an()); |
12705 | 12093 |
12706 case (42): | 12094 case (42): |
12707 | 12095 |
12708 $globals.world.error("no unary add operator in dart", node.get$span()); | 12096 $globals.world.error("no unary add operator in dart", node.get$span()); |
12709 break; | 12097 break; |
12710 | 12098 |
12711 case (43): | 12099 case (43): |
12712 | 12100 |
12713 return this.invoke(context, ":negate", node, Arguments.get$EMPTY(), false)
; | 12101 return this.invoke(context, ":negate", node, Arguments.get$EMPTY()); |
12714 | 12102 |
12715 case (18): | 12103 case (18): |
12716 | 12104 |
12717 return this.invoke(context, ":bit_not", node, Arguments.get$EMPTY(), false
); | 12105 return this.invoke(context, ":bit_not", node, Arguments.get$EMPTY()); |
12718 | 12106 |
12719 } | 12107 } |
12720 $globals.world.internalError(("unimplemented: " + node.get$op()), node.get$spa
n()); | 12108 $globals.world.internalError(("unimplemented: " + node.get$op()), node.get$spa
n()); |
12721 } | 12109 } |
| 12110 Value.prototype._mayOverrideEqual = function() { |
| 12111 return this.get$type().get$isVar() || this.get$type().get$isObject() || !this.
get$type().getMember(":eq").declaringType.get$isObject(); |
| 12112 } |
12722 Value.prototype.binop = function(kind, other, context, node) { | 12113 Value.prototype.binop = function(kind, other, context, node) { |
12723 switch (kind) { | 12114 switch (kind) { |
12724 case (35): | 12115 case (35): |
12725 case (34): | 12116 case (34): |
12726 | 12117 |
12727 var code = ("" + this.get$code() + " " + node.get$op() + " " + other.get$c
ode()); | 12118 var code = ("" + this.get$code() + " " + node.get$op() + " " + other.get$c
ode()); |
12728 return new Value($globals.world.nonNullBool, code, node.get$span()); | 12119 return new Value($globals.world.nonNullBool, code, node.get$span()); |
12729 | 12120 |
12730 case (50): | 12121 case (50): |
12731 | 12122 |
12732 return new Value($globals.world.nonNullBool, ("" + this.get$code() + " ==
" + other.get$code()), node.get$span()); | 12123 return new Value($globals.world.nonNullBool, ("" + this.get$code() + " ==
" + other.get$code()), node.get$span()); |
12733 | 12124 |
12734 case (51): | 12125 case (51): |
12735 | 12126 |
12736 return new Value($globals.world.nonNullBool, ("" + this.get$code() + " !=
" + other.get$code()), node.get$span()); | 12127 return new Value($globals.world.nonNullBool, ("" + this.get$code() + " !=
" + other.get$code()), node.get$span()); |
12737 | 12128 |
| 12129 case (48): |
| 12130 |
| 12131 if (other.get$code() == "null") { |
| 12132 if (!this._mayOverrideEqual()) { |
| 12133 return new Value($globals.world.nonNullBool, ("" + this.get$code() + "
== " + other.get$code()), node.get$span()); |
| 12134 } |
| 12135 } |
| 12136 else if (this.get$code() == "null") { |
| 12137 return new Value($globals.world.nonNullBool, ("" + this.get$code() + " =
= " + other.get$code()), node.get$span()); |
| 12138 } |
| 12139 break; |
| 12140 |
| 12141 case (49): |
| 12142 |
| 12143 if (other.get$code() == "null") { |
| 12144 if (!this._mayOverrideEqual()) { |
| 12145 return new Value($globals.world.nonNullBool, ("" + this.get$code() + "
!= " + other.get$code()), node.get$span()); |
| 12146 } |
| 12147 } |
| 12148 else if (this.get$code() == "null") { |
| 12149 return new Value($globals.world.nonNullBool, ("" + this.get$code() + " !
= " + other.get$code()), node.get$span()); |
| 12150 } |
| 12151 break; |
| 12152 |
12738 } | 12153 } |
12739 var name = kind == (49) ? ":ne" : TokenKind.binaryMethodName(kind); | 12154 var name = kind == (49) ? ":ne" : TokenKind.binaryMethodName(kind); |
12740 return this.invoke(context, name, node, new Arguments(null, [other]), false); | 12155 return this.invoke(context, name, node, new Arguments(null, [other])); |
12741 } | 12156 } |
12742 Value.prototype.invoke = function(context, name, node, args, isDynamic) { | 12157 Value.prototype.invoke = function(context, name, node, args) { |
12743 if (name == ":call") { | 12158 if (name == ":call") { |
12744 if (this.get$isType()) { | 12159 if (this.get$isType()) { |
12745 $globals.world.error("must use \"new\" or \"const\" to construct a new ins
tance", node.span); | 12160 $globals.world.error("must use \"new\" or \"const\" to construct a new ins
tance", node.span); |
12746 } | 12161 } |
12747 if (this.get$type().needsVarCall(args)) { | 12162 if (this.get$type().needsVarCall(args)) { |
12748 return this._varCall(context, node, args); | 12163 return this._varCall(context, node, args); |
12749 } | 12164 } |
12750 } | 12165 } |
12751 var member = this._resolveMember(context, name, node, isDynamic); | 12166 var member = this._resolveMember(context, name, node); |
12752 if (member == null) { | 12167 if ($eq(member)) { |
12753 return this.invokeNoSuchMethod(context, name, node, args); | 12168 return this.invokeNoSuchMethod(context, name, node, args); |
12754 } | 12169 } |
12755 else { | 12170 else { |
12756 return member.invoke$5(context, node, this, args, isDynamic); | 12171 return member.invoke(context, node, this, args); |
12757 } | 12172 } |
12758 } | 12173 } |
12759 Value.prototype.canInvoke = function(context, name, args) { | |
12760 if (this.get$type().get$isVarOrFunction() && name == ":call") { | |
12761 return true; | |
12762 } | |
12763 var member = this._resolveMember(context, name, null, true); | |
12764 return member != null && member.canInvoke$2(context, args); | |
12765 } | |
12766 Value.prototype._hasOverriddenNoSuchMethod = function() { | 12174 Value.prototype._hasOverriddenNoSuchMethod = function() { |
12767 var m = this.get$type().getMember("noSuchMethod"); | 12175 var m = this.get$type().getMember("noSuchMethod"); |
12768 return m != null && !m.get$declaringType().get$isObject(); | 12176 return $ne(m) && !m.get$declaringType().get$isObject(); |
12769 } | 12177 } |
12770 Value.prototype.get$isPreciseType = function() { | 12178 Value.prototype.get$isPreciseType = function() { |
12771 return this.get$isSuper() || this.get$isType(); | 12179 return this.get$isSuper() || this.get$isType(); |
12772 } | 12180 } |
12773 Value.prototype._missingMemberError = function(context, name, isDynamic, node) { | 12181 Value.prototype._missingMemberError = function(context, name, node) { |
12774 var onStaticType = false; | 12182 var onStaticType = false; |
12775 if ($ne(this.get$type(), this.get$staticType())) { | 12183 if ($ne(this.get$type(), this.get$staticType())) { |
12776 onStaticType = this.get$staticType().getMember(name) != null; | 12184 onStaticType = this.get$staticType().getMember(name) != null; |
12777 } | 12185 } |
12778 if (!onStaticType && !isDynamic && !this._isVarOrParameterType(this.get$static
Type()) && !this._hasOverriddenNoSuchMethod()) { | 12186 if (!onStaticType && context.get$showWarnings() && !this._isVarOrParameterType
(this.get$staticType()) && !this._hasOverriddenNoSuchMethod()) { |
12779 var typeName = this.get$staticType().name; | 12187 var typeName = this.get$staticType().name; |
12780 if (typeName == null) typeName = this.get$staticType().get$library().name; | 12188 if ($eq(typeName)) typeName = this.get$staticType().get$library().name; |
12781 var message = ("can not resolve \"" + name + "\" on \"" + typeName + "\""); | 12189 var message = ("can not resolve \"" + name + "\" on \"" + typeName + "\""); |
12782 if (this.get$isType()) { | 12190 if (this.get$isType()) { |
12783 $globals.world.error(message, node.span); | 12191 $globals.world.error(message, node.span); |
12784 } | 12192 } |
12785 else { | 12193 else { |
12786 $globals.world.warning(message, node.span); | 12194 $globals.world.warning(message, node.span); |
12787 } | 12195 } |
12788 } | 12196 } |
12789 } | 12197 } |
12790 Value.prototype._tryResolveMember = function(context, name, isDynamic, node) { | 12198 Value.prototype._tryResolveMember = function(context, name, node) { |
12791 var member = this.get$type().getMember(name); | 12199 var member = this.get$type().getMember(name); |
12792 if (member == null) { | 12200 if ($eq(member)) { |
12793 this._missingMemberError(context, name, isDynamic, node); | 12201 this._missingMemberError(context, name, node); |
12794 return null; | 12202 return null; |
12795 } | 12203 } |
12796 else { | 12204 else { |
12797 if (this.get$isType() && !member.get$isStatic()) { | 12205 if (this.get$isType() && !member.get$isStatic() && context.get$showWarnings(
)) { |
12798 if (!isDynamic) { | 12206 $globals.world.error("can not refer to instance member as static", node.sp
an); |
12799 $globals.world.error("can not refer to instance member as static", node.
span); | |
12800 } | |
12801 return null; | 12207 return null; |
12802 } | 12208 } |
12803 } | 12209 } |
12804 if (this.get$isPreciseType() || member.get$isStatic()) { | 12210 if (this.get$isPreciseType() || member.get$isStatic()) { |
12805 return member.get$preciseMemberSet(); | 12211 return member.get$preciseMemberSet(); |
12806 } | 12212 } |
12807 else { | 12213 else { |
12808 return member.get$potentialMemberSet(); | 12214 return member.get$potentialMemberSet(); |
12809 } | 12215 } |
12810 } | 12216 } |
12811 Value.prototype._isVarOrParameterType = function(t) { | 12217 Value.prototype._isVarOrParameterType = function(t) { |
12812 return t.get$isVar() || (t instanceof ParameterType); | 12218 return t.get$isVar() || (t instanceof ParameterType); |
12813 } | 12219 } |
12814 Value.prototype._shouldBindDynamically = function() { | 12220 Value.prototype._shouldBindDynamically = function() { |
12815 return this._isVarOrParameterType(this.get$type()) || $globals.options.forceDy
namic && !this.get$isConst(); | 12221 return this._isVarOrParameterType(this.get$type()) || $globals.options.forceDy
namic && !this.get$isConst(); |
12816 } | 12222 } |
12817 Value.prototype._resolveMember = function(context, name, node, isDynamic) { | 12223 Value.prototype._resolveMember = function(context, name, node) { |
12818 var member = null; | 12224 var member = null; |
12819 if (!this._shouldBindDynamically()) { | 12225 if (!this._shouldBindDynamically()) { |
12820 member = this._tryResolveMember(context, name, isDynamic, node); | 12226 member = this._tryResolveMember(context, name, node); |
12821 } | 12227 } |
12822 if (member == null && !this.get$isSuper() && !this.get$isType()) { | 12228 if ($eq(member) && !this.get$isSuper() && !this.get$isType()) { |
12823 member = context.findMembers(name); | 12229 member = context.findMembers(name); |
12824 if (member == null && !isDynamic) { | 12230 if ($eq(member) && context.get$showWarnings()) { |
12825 var where = "the world"; | 12231 var where = "the world"; |
12826 if (name.startsWith("_")) { | 12232 if (name.startsWith("_")) { |
12827 where = ("library \"" + context.get$library().name + "\""); | 12233 where = ("library \"" + context.get$library().name + "\""); |
12828 } | 12234 } |
12829 $globals.world.warning(("" + name + " is not defined anywhere in " + where
+ "."), node.span); | 12235 $globals.world.warning(("" + name + " is not defined anywhere in " + where
+ "."), node.span); |
12830 } | 12236 } |
12831 } | 12237 } |
12832 return member; | 12238 return member; |
12833 } | 12239 } |
12834 Value.prototype.checkFirstClass = function(span) { | 12240 Value.prototype.checkFirstClass = function(span) { |
12835 if (this.get$isType()) { | 12241 if (this.get$isType()) { |
12836 $globals.world.error("Types are not first class", span); | 12242 $globals.world.error("Types are not first class", span); |
12837 } | 12243 } |
12838 } | 12244 } |
12839 Value.prototype._varCall = function(context, node, args) { | 12245 Value.prototype._varCall = function(context, node, args) { |
12840 var stub = $globals.world.functionType.getCallStub(args); | 12246 var stub = $globals.world.functionType.getCallStub(args); |
12841 return stub.invoke$4(context, node, this, args); | 12247 return stub.invoke(context, node, this, args); |
12842 } | 12248 } |
12843 Value.prototype.needsConversion = function(toType) { | 12249 Value.prototype.needsConversion = function(toType) { |
12844 var c = this.convertTo(null, toType, true); | 12250 var c = this.convertTo(null, toType); |
12845 return c == null || this.get$code() != c.get$code(); | 12251 return $eq(c) || this.get$code() != c.get$code(); |
12846 } | 12252 } |
12847 Value.prototype.convertTo = function(context, toType, isDynamic) { | 12253 Value.prototype.convertTo = function(context, toType) { |
12848 var checked = !isDynamic; | 12254 var checked = context != null && context.get$showWarnings(); |
12849 var callMethod = toType.getCallMethod(); | 12255 var callMethod = toType.getCallMethod(); |
12850 if (callMethod != null) { | 12256 if ($ne(callMethod)) { |
12851 if (checked && !toType.isAssignable(this.get$type())) { | 12257 if (checked && !toType.isAssignable(this.get$type())) { |
12852 this.convertWarning(toType); | 12258 this.convertWarning(toType); |
12853 } | 12259 } |
12854 return this._maybeWrapFunction(toType, callMethod); | 12260 return this._maybeWrapFunction(toType, callMethod); |
12855 } | 12261 } |
12856 var fromType = this.get$type(); | 12262 var fromType = this.get$type(); |
12857 if (this.get$type().get$isVar() && (this.get$code() != "null" || !toType.get$i
sNullable())) { | 12263 if (this.get$type().get$isVar() && (this.get$code() != "null" || !toType.get$i
sNullable())) { |
12858 fromType = $globals.world.objectType; | 12264 fromType = $globals.world.objectType; |
12859 } | 12265 } |
12860 var bothNum = this.get$type().get$isNum() && toType.get$isNum(); | 12266 var bothNum = this.get$type().get$isNum() && toType.get$isNum(); |
12861 if (fromType.isSubtypeOf(toType) || bothNum) { | 12267 if (fromType.isSubtypeOf(toType) || bothNum) { |
12862 return this.changeStaticType(toType); | 12268 return this.changeStaticType(toType); |
12863 } | 12269 } |
12864 if (checked && !toType.isSubtypeOf(this.get$type())) { | 12270 if (checked && !toType.isSubtypeOf(this.get$type())) { |
12865 this.convertWarning(toType); | 12271 this.convertWarning(toType); |
12866 } | 12272 } |
12867 if ($globals.options.enableTypeChecks) { | 12273 if ($globals.options.enableTypeChecks) { |
12868 if (context == null && isDynamic) { | 12274 if (context == null) { |
12869 return null; | 12275 return null; |
12870 } | 12276 } |
12871 return this._typeAssert(context, toType, isDynamic); | 12277 return this._typeAssert(context, toType); |
12872 } | 12278 } |
12873 else { | 12279 else { |
12874 return this.changeStaticType(toType); | 12280 return this.changeStaticType(toType); |
12875 } | 12281 } |
12876 } | 12282 } |
12877 Value.prototype.changeStaticType = function(toType) { | 12283 Value.prototype.changeStaticType = function(toType) { |
12878 return ($eq(toType, this.get$type())) ? this : new ConvertedValue(this, toType
); | 12284 return ($eq(toType, this.get$type())) ? this : new ConvertedValue(this, toType
); |
12879 } | 12285 } |
12880 Value.prototype._maybeWrapFunction = function(toType, callMethod) { | 12286 Value.prototype._maybeWrapFunction = function(toType, callMethod) { |
12881 var arity = callMethod.parameters.get$length(); | 12287 var arity = callMethod.parameters.get$length(); |
12882 var myCall = this.get$type().getCallMethod(); | 12288 var myCall = this.get$type().getCallMethod(); |
12883 var result = this; | 12289 var result = this; |
12884 if (myCall == null || $ne(myCall.get$parameters().get$length(), arity)) { | 12290 if ($eq(myCall) || myCall.get$parameters().get$length() != arity) { |
12885 var stub = $globals.world.functionType.getCallStub(Arguments.Arguments$bare$
factory(arity)); | 12291 var stub = $globals.world.functionType.getCallStub(Arguments.Arguments$bare$
factory(arity)); |
12886 result = new Value(toType, ("to$" + stub.get$name() + "(" + this.get$code()
+ ")"), this.span); | 12292 result = new Value(toType, ("to$" + stub.get$name() + "(" + this.get$code()
+ ")"), this.span); |
12887 } | 12293 } |
12888 if ($eq(toType.get$library(), $globals.world.dom) && $ne(this.get$type().get$l
ibrary(), $globals.world.dom)) { | 12294 if ($eq(toType.get$library(), $globals.world.dom) && $ne(this.get$type().get$l
ibrary(), $globals.world.dom)) { |
12889 if (arity == (0)) { | 12295 if (arity == (0)) { |
12890 $globals.world.gen.corejs.useWrap0 = true; | 12296 $globals.world.gen.corejs.useWrap0 = true; |
12891 } | 12297 } |
12892 else { | 12298 else { |
12893 $globals.world.gen.corejs.useWrap1 = true; | 12299 $globals.world.gen.corejs.useWrap1 = true; |
12894 } | 12300 } |
12895 result = new Value(toType, ("$wrap_call$" + arity + "(" + result.get$code()
+ ")"), this.span); | 12301 result = new Value(toType, ("$wrap_call$" + arity + "(" + result.get$code()
+ ")"), this.span); |
12896 } | 12302 } |
12897 if (result == this) result = this.changeStaticType(toType); | 12303 if (result == this) result = this.changeStaticType(toType); |
12898 return result; | 12304 return result; |
12899 } | 12305 } |
12900 Value.prototype._typeAssert = function(context, toType, isDynamic) { | 12306 Value.prototype._typeAssert = function(context, toType) { |
| 12307 var $0; |
12901 if ((toType instanceof ParameterType)) { | 12308 if ((toType instanceof ParameterType)) { |
12902 var p = toType; | 12309 var p = toType; |
12903 toType = p.extendsType; | 12310 toType = p.extendsType; |
12904 } | 12311 } |
12905 if (toType.get$isObject() || toType.get$isVar()) { | 12312 if (toType.get$isObject() || toType.get$isVar()) { |
12906 $globals.world.internalError(("We thought " + this.get$type().name + " is no
t a subtype of " + toType.name + "?")); | 12313 $globals.world.internalError(("We thought " + this.get$type().name + " is no
t a subtype of " + toType.name + "?")); |
12907 } | 12314 } |
12908 function throwTypeError(paramName) { | 12315 function throwTypeError(paramName) { |
12909 return $globals.world.withoutForceDynamic((function () { | 12316 return $globals.world.withoutForceDynamic((function () { |
12910 var typeErrorCtor = $globals.world.typeErrorType.getConstructor("_internal
"); | 12317 var typeErrorCtor = $globals.world.typeErrorType.getConstructor("_internal
"); |
12911 $globals.world.gen.corejs.ensureTypeNameOf(); | 12318 $globals.world.gen.corejs.ensureTypeNameOf(); |
12912 var result = typeErrorCtor.invoke$5(context, null, new TypeValue($globals.
world.typeErrorType, null), new Arguments(null, [new Value($globals.world.object
Type, paramName, null), new Value($globals.world.stringType, ("\"" + toType.name
+ "\""), null)]), isDynamic); | 12319 var result = typeErrorCtor.invoke(context, null, new TypeValue($globals.wo
rld.typeErrorType, null), new Arguments(null, [new Value($globals.world.objectTy
pe, paramName, null), new Value($globals.world.stringType, ("\"" + toType.name +
"\""), null)])); |
12913 $globals.world.gen.corejs.useThrow = true; | 12320 $globals.world.gen.corejs.useThrow = true; |
12914 return ("$throw(" + result.get$code() + ")"); | 12321 return ("$throw(" + result.get$code() + ")"); |
12915 }) | 12322 }) |
12916 ); | 12323 ); |
12917 } | 12324 } |
12918 if (toType.get$isNum()) toType = $globals.world.numType; | 12325 if (toType.get$isNum()) toType = $globals.world.numType; |
12919 var check; | 12326 var check; |
12920 if (toType.get$isVoid()) { | 12327 if (toType.get$isVoid()) { |
12921 check = ("$assert_void(" + this.get$code() + ")"); | 12328 check = ("$assert_void(" + this.get$code() + ")"); |
12922 if (toType.typeCheckCode == null) { | 12329 if (toType.typeCheckCode == null) { |
12923 toType.typeCheckCode = ("function $assert_void(x) {\n if (x == null) retu
rn null;\n " + throwTypeError.call$1("x") + "\n}"); | 12330 toType.typeCheckCode = ("function $assert_void(x) {\n if (x == null) retu
rn null;\n " + throwTypeError("x") + "\n}"); |
12924 } | 12331 } |
12925 } | 12332 } |
12926 else if ($eq(toType, $globals.world.nonNullBool)) { | 12333 else if ($eq(toType, $globals.world.nonNullBool)) { |
12927 $globals.world.gen.corejs.useNotNullBool = true; | 12334 $globals.world.gen.corejs.useNotNullBool = true; |
12928 check = ("$notnull_bool(" + this.get$code() + ")"); | 12335 check = ("$notnull_bool(" + this.get$code() + ")"); |
12929 } | 12336 } |
12930 else if (toType.get$library().get$isCore() && toType.get$typeofName() != null)
{ | 12337 else if (toType.get$library().get$isCore() && toType.get$typeofName() != null)
{ |
12931 check = ("$assert_" + toType.name + "(" + this.get$code() + ")"); | 12338 check = ("$assert_" + toType.name + "(" + this.get$code() + ")"); |
12932 if (toType.typeCheckCode == null) { | 12339 if (toType.typeCheckCode == null) { |
12933 toType.typeCheckCode = ("function $assert_" + toType.name + "(x) {\n if (
x == null || typeof(x) == \"" + toType.get$typeofName() + "\") return x;\n " +
throwTypeError.call$1("x") + "\n}"); | 12340 toType.typeCheckCode = ("function $assert_" + toType.name + "(x) {\n if (
x == null || typeof(x) == \"" + toType.get$typeofName() + "\") return x;\n " +
throwTypeError("x") + "\n}"); |
12934 } | 12341 } |
12935 } | 12342 } |
12936 else { | 12343 else { |
12937 toType.isChecked = true; | 12344 toType.isChecked = true; |
12938 var checkName = "assert$" + toType.get$jsname(); | 12345 var checkName = $add("assert$", toType.get$jsname()); |
12939 var temp = context.getTemp(this); | 12346 var temp = context.getTemp(this); |
12940 check = ("(" + context.assignTemp(temp, this).get$code() + " == null ? null
:"); | 12347 check = ("(" + context.assignTemp(temp, this).get$code() + " == null ? null
:"); |
12941 check = check + (" " + temp.get$code() + "." + checkName + "())"); | 12348 check = $add(check, (" " + temp.get$code() + "." + checkName + "())")); |
12942 if ($ne(this, temp)) context.freeTemp(temp); | 12349 if ($ne(this, temp)) context.freeTemp(temp); |
12943 $globals.world.objectType.varStubs.putIfAbsent(checkName, (function () { | 12350 $globals.world.objectType.varStubs.putIfAbsent(checkName, (function () { |
12944 return new VarMethodStub(checkName, null, Arguments.get$EMPTY(), throwType
Error.call$1("this")); | 12351 return new VarMethodStub(checkName, null, Arguments.get$EMPTY(), throwType
Error("this")); |
12945 }) | 12352 }) |
12946 ); | 12353 ); |
12947 } | 12354 } |
12948 context.counters.typeAsserts++; | 12355 ($0 = context.get$counters()).typeAsserts = $0.typeAsserts + (1); |
12949 return new Value(toType, check, this.span); | 12356 return new Value(toType, check, this.span); |
12950 } | 12357 } |
12951 Value.prototype.instanceOf = function(context, toType, span, isTrue, forceCheck)
{ | 12358 Value.prototype.instanceOf = function(context, toType, span, isTrue, forceCheck)
{ |
12952 if (toType.get$isVar()) { | 12359 if (toType.get$isVar()) { |
12953 $globals.world.error("can not resolve type", span); | 12360 $globals.world.error("can not resolve type", span); |
12954 } | 12361 } |
12955 var testCode = null; | 12362 var testCode = null; |
12956 if (toType.get$isVar() || toType.get$isObject() || (toType instanceof Paramete
rType)) { | 12363 if (toType.get$isVar() || toType.get$isObject() || (toType instanceof Paramete
rType)) { |
12957 if (this.get$needsTemp()) { | 12364 if (this.get$needsTemp()) { |
12958 return new Value($globals.world.nonNullBool, ("(" + this.get$code() + ", t
rue)"), span); | 12365 return new Value($globals.world.nonNullBool, ("(" + this.get$code() + ", t
rue)"), span); |
12959 } | 12366 } |
12960 else { | 12367 else { |
12961 return Value.fromBool(true, span); | 12368 return Value.fromBool(true, span); |
12962 } | 12369 } |
12963 } | 12370 } |
12964 if (toType.get$library().get$isCore()) { | 12371 if (toType.get$library().get$isCore()) { |
12965 var typeofName = toType.get$typeofName(); | 12372 var typeofName = toType.get$typeofName(); |
12966 if (typeofName != null) { | 12373 if ($ne(typeofName)) { |
12967 testCode = ("(typeof(" + this.get$code() + ") " + (isTrue ? "==" : "!=") +
" '" + typeofName + "')"); | 12374 testCode = ("(typeof(" + this.get$code() + ") " + (isTrue ? "==" : "!=") +
" '" + typeofName + "')"); |
12968 } | 12375 } |
12969 } | 12376 } |
12970 if (toType.get$isClass() && !(toType instanceof ConcreteType) && !toType.get$i
sHiddenNativeType()) { | 12377 if (toType.get$isClass() && !toType.get$isHiddenNativeType() && !toType.get$is
ConcreteGeneric()) { |
12971 toType.markUsed(); | 12378 toType.markUsed(); |
12972 testCode = ("(" + this.get$code() + " instanceof " + toType.get$jsname() + "
)"); | 12379 testCode = ("(" + this.get$code() + " instanceof " + toType.get$jsname() + "
)"); |
12973 if (!isTrue) { | 12380 if (!isTrue) { |
12974 testCode = "!" + testCode; | 12381 testCode = $add("!", testCode); |
12975 } | 12382 } |
12976 } | 12383 } |
12977 if (testCode == null) { | 12384 if (testCode == null) { |
12978 toType.isTested = true; | 12385 toType.isTested = true; |
12979 var temp = context.getTemp(this); | 12386 var temp = context.getTemp(this); |
12980 var checkName = ("is$" + toType.get$jsname()); | 12387 var checkName = ("is$" + toType.get$jsname()); |
12981 testCode = ("(" + context.assignTemp(temp, this).get$code() + " &&"); | 12388 testCode = ("(" + context.assignTemp(temp, this).get$code() + " &&"); |
12982 testCode = testCode + (" " + temp.get$code() + "." + checkName + "())"); | 12389 testCode = $add(testCode, (" " + temp.get$code() + "." + checkName + "())"))
; |
12983 if (isTrue) { | 12390 if (isTrue) { |
12984 testCode = "!!" + testCode; | 12391 testCode = $add("!!", testCode); |
12985 } | 12392 } |
12986 else { | 12393 else { |
12987 testCode = "!" + testCode; | 12394 testCode = $add("!", testCode); |
12988 } | 12395 } |
12989 if ($ne(this, temp)) context.freeTemp(temp); | 12396 if ($ne(this, temp)) context.freeTemp(temp); |
12990 if (!$globals.world.objectType.varStubs.containsKey(checkName)) { | 12397 if (!$globals.world.objectType.varStubs.containsKey(checkName)) { |
12991 $globals.world.objectType.varStubs.$setindex(checkName, new VarMethodStub(
checkName, null, Arguments.get$EMPTY(), "return false")); | 12398 $globals.world.objectType.varStubs.$setindex(checkName, new VarMethodStub(
checkName, null, Arguments.get$EMPTY(), "return false")); |
12992 } | 12399 } |
12993 } | 12400 } |
12994 return new Value($globals.world.nonNullBool, testCode, span); | 12401 return new Value($globals.world.nonNullBool, testCode, span); |
12995 } | 12402 } |
12996 Value.prototype.convertWarning = function(toType) { | 12403 Value.prototype.convertWarning = function(toType) { |
12997 $globals.world.warning(("type \"" + this.get$type().name + "\" is not assignab
le to \"" + toType.name + "\""), this.span); | 12404 $globals.world.warning(("type \"" + this.get$type().name + "\" is not assignab
le to \"" + toType.name + "\""), this.span); |
12998 } | 12405 } |
12999 Value.prototype.invokeNoSuchMethod = function(context, name, node, args) { | 12406 Value.prototype.invokeNoSuchMethod = function(context, name, node, args) { |
13000 if (this.get$isType()) { | 12407 if (this.get$isType()) { |
13001 $globals.world.error(("member lookup failed for \"" + name + "\""), node.spa
n); | 12408 $globals.world.error(("member lookup failed for \"" + name + "\""), node.spa
n); |
13002 } | 12409 } |
13003 var pos = ""; | 12410 var pos = ""; |
13004 if (args != null) { | 12411 if (args != null) { |
13005 var argsCode = []; | 12412 var argsCode = []; |
13006 for (var i = (0); | 12413 for (var i = (0); |
13007 i < args.get$length(); i++) { | 12414 i < args.get$length(); i++) { |
13008 argsCode.add$1(args.values[i].get$code()); | 12415 argsCode.add(args.values.$index(i).get$code()); |
13009 } | 12416 } |
13010 pos = Strings.join(argsCode, ", "); | 12417 pos = Strings.join(argsCode, ", "); |
13011 } | 12418 } |
13012 var noSuchArgs = [new Value($globals.world.stringType, ("\"" + name + "\""), n
ode.span), new Value($globals.world.listType, ("[" + pos + "]"), node.span)]; | 12419 var noSuchArgs = [new Value($globals.world.stringType, ("\"" + name + "\""), n
ode.span), new Value($globals.world.listType, ("[" + pos + "]"), node.span)]; |
13013 return this._resolveMember(context, "noSuchMethod", node, false).invoke(contex
t, node, this, new Arguments(null, noSuchArgs), false); | 12420 return this._resolveMember(context, "noSuchMethod", node).invoke(context, node
, this, new Arguments(null, noSuchArgs)); |
13014 } | 12421 } |
13015 Value.fromBool = function(value, span) { | 12422 Value.fromBool = function(value, span) { |
13016 return new BoolValue(value, true, span); | 12423 return new BoolValue(value, true, span); |
13017 } | 12424 } |
13018 Value.fromInt = function(value, span) { | 12425 Value.fromInt = function(value, span) { |
13019 return new IntValue(value, true, span); | 12426 return new IntValue(value, true, span); |
13020 } | 12427 } |
13021 Value.fromDouble = function(value, span) { | 12428 Value.fromDouble = function(value, span) { |
13022 return new DoubleValue(value, true, span); | 12429 return new DoubleValue(value, true, span); |
13023 } | 12430 } |
13024 Value.fromString = function(value, span) { | 12431 Value.fromString = function(value, span) { |
13025 return new StringValue(value, true, span); | 12432 return new StringValue(value, true, span); |
13026 } | 12433 } |
13027 Value.fromNull = function(span) { | 12434 Value.fromNull = function(span) { |
13028 return new NullValue(true, span); | 12435 return new NullValue(true, span); |
13029 } | 12436 } |
13030 Value.prototype.binop$4 = Value.prototype.binop; | |
13031 Value.prototype.checkFirstClass$1 = Value.prototype.checkFirstClass; | |
13032 Value.prototype.convertTo$2 = function($0, $1) { | |
13033 return this.convertTo($0, $1, false); | |
13034 }; | |
13035 Value.prototype.convertTo$3 = Value.prototype.convertTo; | |
13036 Value.prototype.get_$3 = Value.prototype.get_; | |
13037 Value.prototype.instanceOf$3$isTrue$forceCheck = Value.prototype.instanceOf; | 12437 Value.prototype.instanceOf$3$isTrue$forceCheck = Value.prototype.instanceOf; |
13038 Value.prototype.instanceOf$4 = function($0, $1, $2, $3) { | 12438 Value.prototype.instanceOf$4 = function($0, $1, $2, $3) { |
13039 return this.instanceOf($0, $1, $2, $3, false); | 12439 return this.instanceOf($0, $1, $2, $3, false); |
13040 }; | 12440 }; |
13041 Value.prototype.invoke$4 = function($0, $1, $2, $3) { | 12441 Value.prototype.setIndex$4$kind = function($0, $1, $2, $3, kind) { |
13042 return this.invoke($0, $1, $2, $3, false); | 12442 return this.setIndex($0, $1, $2, $3, kind, (1)); |
13043 }; | 12443 }; |
13044 Value.prototype.invoke$4$isDynamic = Value.prototype.invoke; | 12444 Value.prototype.setIndex$4$kind$returnKind = Value.prototype.setIndex; |
13045 Value.prototype.invoke$5 = Value.prototype.invoke; | 12445 Value.prototype.set_$4$kind = function($0, $1, $2, $3, kind) { |
13046 Value.prototype.invokeNoSuchMethod$4 = Value.prototype.invokeNoSuchMethod; | 12446 return this.set_($0, $1, $2, $3, kind, (1)); |
13047 Value.prototype.needsConversion$1 = Value.prototype.needsConversion; | |
13048 Value.prototype.setIndex$4$kind$returnKind = function($0, $1, $2, $3, kind, retu
rnKind) { | |
13049 return this.setIndex($0, $1, $2, $3, false, kind, returnKind); | |
13050 }; | 12447 }; |
13051 Value.prototype.set_$4$kind$returnKind = function($0, $1, $2, $3, kind, returnKi
nd) { | 12448 Value.prototype.set_$4$kind$returnKind = Value.prototype.set_; |
13052 return this.set_($0, $1, $2, $3, false, kind, returnKind); | 12449 // ********** Code for PureStaticValue ************** |
| 12450 $inherits(PureStaticValue, Value); |
| 12451 function PureStaticValue(type, span, isConst, isType) { |
| 12452 this.isType = isType; |
| 12453 this.isConst = isConst; |
| 12454 Value.call(this, type, null, span); |
| 12455 } |
| 12456 PureStaticValue.prototype.get$isConst = function() { return this.isConst; }; |
| 12457 PureStaticValue.prototype.set$isConst = function(value) { return this.isConst =
value; }; |
| 12458 PureStaticValue.prototype.get$isType = function() { return this.isType; }; |
| 12459 PureStaticValue.prototype.set$isType = function(value) { return this.isType = va
lue; }; |
| 12460 PureStaticValue.prototype.getMem = function(context, name, node) { |
| 12461 var member = this.get$type().getMember(name); |
| 12462 if ($eq(member)) { |
| 12463 $globals.world.warning(("can not find \"" + name + "\" on \"" + this.get$typ
e().name + "\""), node.span); |
| 12464 } |
| 12465 if (this.isType && !member.get$isStatic()) { |
| 12466 $globals.world.error("can not refer to instance member as static", node.span
); |
| 12467 } |
| 12468 return member; |
| 12469 } |
| 12470 PureStaticValue.prototype.get_ = function(context, name, node) { |
| 12471 if (this.get$type().get$isVar()) return new PureStaticValue($globals.world.var
Type, node.span, false, false); |
| 12472 var member = this.getMem(context, name, node); |
| 12473 if ($eq(member)) return new PureStaticValue($globals.world.varType, node.span,
false, false); |
| 12474 return member._get(context, node, this); |
| 12475 } |
| 12476 PureStaticValue.prototype.set_ = function(context, name, node, value, kind, retu
rnKind) { |
| 12477 if (this.get$type().get$isVar()) return new PureStaticValue($globals.world.var
Type, node.span, false, false); |
| 12478 var member = this.getMem(context, name, node); |
| 12479 if ($ne(member)) { |
| 12480 member._set(context, node, this, value); |
| 12481 } |
| 12482 return new PureStaticValue(value.get$type(), node.span, false, false); |
| 12483 } |
| 12484 PureStaticValue.prototype.setIndex = function(context, index, node, value, kind,
returnKind) { |
| 12485 return this.invoke(context, ":setindex", node, new Arguments(null, [index, val
ue])); |
| 12486 } |
| 12487 PureStaticValue.prototype.unop = function(kind, context, node) { |
| 12488 switch (kind) { |
| 12489 case (19): |
| 12490 |
| 12491 return new PureStaticValue($globals.world.boolType, node.get$span(), false
, false); |
| 12492 |
| 12493 case (42): |
| 12494 |
| 12495 if (!this.isConst && !this.get$type().get$isNum()) { |
| 12496 $globals.world.error("no unary add operator in dart", node.get$span()); |
| 12497 } |
| 12498 return new PureStaticValue($globals.world.numType, node.get$span(), false,
false); |
| 12499 |
| 12500 case (43): |
| 12501 |
| 12502 return this.invoke(context, ":negate", node, Arguments.get$EMPTY()); |
| 12503 |
| 12504 case (18): |
| 12505 |
| 12506 return this.invoke(context, ":bit_not", node, Arguments.get$EMPTY()); |
| 12507 |
| 12508 } |
| 12509 $globals.world.internalError(("unimplemented: " + node.get$op()), node.get$spa
n()); |
| 12510 } |
| 12511 PureStaticValue.prototype.binop = function(kind, other, context, node) { |
| 12512 var isConst = this.isConst && other.get$isConst(); |
| 12513 switch (kind) { |
| 12514 case (35): |
| 12515 case (34): |
| 12516 |
| 12517 return new PureStaticValue($globals.world.boolType, node.get$span(), isCon
st, false); |
| 12518 |
| 12519 case (50): |
| 12520 |
| 12521 return new PureStaticValue($globals.world.boolType, node.get$span(), isCon
st, false); |
| 12522 |
| 12523 case (51): |
| 12524 |
| 12525 return new PureStaticValue($globals.world.boolType, node.get$span(), isCon
st, false); |
| 12526 |
| 12527 } |
| 12528 var name = kind == (49) ? ":ne" : TokenKind.binaryMethodName(kind); |
| 12529 var ret = this.invoke(context, name, node, new Arguments(null, [other])); |
| 12530 if (isConst) { |
| 12531 ret = new PureStaticValue(ret.get$type(), node.get$span(), isConst, false); |
| 12532 } |
| 12533 return ret; |
| 12534 } |
| 12535 PureStaticValue.prototype.invoke = function(context, name, node, args) { |
| 12536 if (this.get$type().get$isVar()) return new PureStaticValue($globals.world.var
Type, node.span, false, false); |
| 12537 if (this.get$type().get$isFunction() && name == ":call") { |
| 12538 return new PureStaticValue($globals.world.varType, node.span, false, false); |
| 12539 } |
| 12540 var member = this.getMem(context, name, node); |
| 12541 if ($eq(member)) return new PureStaticValue($globals.world.varType, node.span,
false, false); |
| 12542 return member.invoke(context, node, this, args); |
| 12543 } |
| 12544 PureStaticValue.prototype.setIndex$4$kind = function($0, $1, $2, $3, kind) { |
| 12545 return this.setIndex($0, $1, $2, $3, kind, (1)); |
13053 }; | 12546 }; |
13054 Value.prototype.unop$3 = Value.prototype.unop; | 12547 PureStaticValue.prototype.setIndex$4$kind$returnKind = PureStaticValue.prototype
.setIndex; |
| 12548 PureStaticValue.prototype.set_$4$kind = function($0, $1, $2, $3, kind) { |
| 12549 return this.set_($0, $1, $2, $3, kind, (1)); |
| 12550 }; |
| 12551 PureStaticValue.prototype.set_$4$kind$returnKind = PureStaticValue.prototype.set
_; |
13055 // ********** Code for EvaluatedValue ************** | 12552 // ********** Code for EvaluatedValue ************** |
13056 $inherits(EvaluatedValue, Value); | 12553 $inherits(EvaluatedValue, Value); |
13057 function EvaluatedValue(isConst, type, span) { | 12554 function EvaluatedValue(isConst, type, span) { |
13058 this.isConst = isConst; | 12555 this.isConst = isConst; |
13059 Value.call(this, type, "@@@", span); | 12556 Value.call(this, type, "@@@", span); |
13060 } | 12557 } |
13061 EvaluatedValue.prototype.get$isConst = function() { return this.isConst; }; | 12558 EvaluatedValue.prototype.get$isConst = function() { return this.isConst; }; |
13062 EvaluatedValue.prototype.get$code = function() { | 12559 EvaluatedValue.prototype.get$code = function() { |
13063 $globals.world.internalError("Should not be getting code from raw EvaluatedVal
ue", this.span); | 12560 $globals.world.internalError("Should not be getting code from raw EvaluatedVal
ue", this.span); |
13064 } | 12561 } |
13065 EvaluatedValue.prototype.get$needsTemp = function() { | 12562 EvaluatedValue.prototype.get$needsTemp = function() { |
13066 return false; | 12563 return false; |
13067 } | 12564 } |
13068 EvaluatedValue.prototype.hashCode = function() { | 12565 EvaluatedValue.prototype.hashCode = function() { |
13069 return this.get$code().hashCode(); | 12566 return this.get$code().hashCode(); |
13070 } | 12567 } |
13071 EvaluatedValue.prototype.$eq = function(other) { | 12568 EvaluatedValue.prototype.$eq = function(other) { |
13072 return (other instanceof EvaluatedValue) && $eq(other.get$type(), this.get$typ
e()) && $eq(other.get$code(), this.get$code()); | 12569 return (other instanceof EvaluatedValue) && $eq(other.get$type(), this.get$typ
e()) && $eq(other.get$code(), this.get$code()); |
13073 } | 12570 } |
13074 EvaluatedValue.prototype.hashCode$0 = EvaluatedValue.prototype.hashCode; | |
13075 // ********** Code for NullValue ************** | 12571 // ********** Code for NullValue ************** |
13076 $inherits(NullValue, EvaluatedValue); | 12572 $inherits(NullValue, EvaluatedValue); |
13077 function NullValue(isConst, span) { | 12573 function NullValue(isConst, span) { |
13078 EvaluatedValue.call(this, isConst, $globals.world.varType, span); | 12574 EvaluatedValue.call(this, isConst, $globals.world.varType, span); |
13079 } | 12575 } |
13080 NullValue.prototype.get$actualValue = function() { | 12576 NullValue.prototype.get$actualValue = function() { |
13081 return null; | 12577 return null; |
13082 } | 12578 } |
13083 NullValue.prototype.get$code = function() { | 12579 NullValue.prototype.get$code = function() { |
13084 return "null"; | 12580 return "null"; |
13085 } | 12581 } |
13086 NullValue.prototype.binop = function(kind, other, context, node) { | 12582 NullValue.prototype.binop = function(kind, other, context, node) { |
13087 if (!(other instanceof NullValue)) return Value.prototype.binop.call(this, kin
d, other, context, node); | 12583 if (!(other instanceof NullValue)) return Value.prototype.binop.call(this, kin
d, other, context, node); |
13088 var c = this.isConst && other.get$isConst(); | 12584 var c = this.isConst && other.get$isConst(); |
13089 var s = node.get$span(); | 12585 var s = node.get$span(); |
13090 switch (kind) { | 12586 switch (kind) { |
13091 case (50): | 12587 case (50): |
13092 case (48): | 12588 case (48): |
13093 | 12589 |
13094 return new BoolValue(true, c, s); | 12590 return new BoolValue(true, c, s); |
13095 | 12591 |
13096 case (51): | 12592 case (51): |
13097 case (49): | 12593 case (49): |
13098 | 12594 |
13099 return new BoolValue(false, c, s); | 12595 return new BoolValue(false, c, s); |
13100 | 12596 |
13101 } | 12597 } |
13102 return Value.prototype.binop.call(this, kind, other, context, node); | 12598 return Value.prototype.binop.call(this, kind, other, context, node); |
13103 } | 12599 } |
13104 NullValue.prototype.binop$4 = NullValue.prototype.binop; | |
13105 // ********** Code for BoolValue ************** | 12600 // ********** Code for BoolValue ************** |
13106 $inherits(BoolValue, EvaluatedValue); | 12601 $inherits(BoolValue, EvaluatedValue); |
13107 function BoolValue(actualValue, isConst, span) { | 12602 function BoolValue(actualValue, isConst, span) { |
13108 this.actualValue = actualValue; | 12603 this.actualValue = actualValue; |
13109 EvaluatedValue.call(this, isConst, $globals.world.nonNullBool, span); | 12604 EvaluatedValue.call(this, isConst, $globals.world.nonNullBool, span); |
13110 } | 12605 } |
13111 BoolValue.prototype.get$actualValue = function() { return this.actualValue; }; | 12606 BoolValue.prototype.get$actualValue = function() { return this.actualValue; }; |
13112 BoolValue.prototype.get$code = function() { | 12607 BoolValue.prototype.get$code = function() { |
13113 return this.actualValue ? "true" : "false"; | 12608 return this.actualValue ? "true" : "false"; |
13114 } | 12609 } |
(...skipping 26 matching lines...) Expand all Loading... |
13141 | 12636 |
13142 return new BoolValue(x && y, c, s); | 12637 return new BoolValue(x && y, c, s); |
13143 | 12638 |
13144 case (34): | 12639 case (34): |
13145 | 12640 |
13146 return new BoolValue(x || y, c, s); | 12641 return new BoolValue(x || y, c, s); |
13147 | 12642 |
13148 } | 12643 } |
13149 return Value.prototype.binop.call(this, kind, other, context, node); | 12644 return Value.prototype.binop.call(this, kind, other, context, node); |
13150 } | 12645 } |
13151 BoolValue.prototype.binop$4 = BoolValue.prototype.binop; | |
13152 BoolValue.prototype.unop$3 = BoolValue.prototype.unop; | |
13153 // ********** Code for IntValue ************** | 12646 // ********** Code for IntValue ************** |
13154 $inherits(IntValue, EvaluatedValue); | 12647 $inherits(IntValue, EvaluatedValue); |
13155 function IntValue(actualValue, isConst, span) { | 12648 function IntValue(actualValue, isConst, span) { |
13156 this.actualValue = actualValue; | 12649 this.actualValue = actualValue; |
13157 EvaluatedValue.call(this, isConst, $globals.world.intType, span); | 12650 EvaluatedValue.call(this, isConst, $globals.world.intType, span); |
13158 } | 12651 } |
13159 IntValue.prototype.get$actualValue = function() { return this.actualValue; }; | 12652 IntValue.prototype.get$actualValue = function() { return this.actualValue; }; |
13160 IntValue.prototype.get$code = function() { | 12653 IntValue.prototype.get$code = function() { |
13161 return ("(" + this.actualValue + ")"); | 12654 return ("(" + this.actualValue + ")"); |
13162 } | 12655 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13307 return new BoolValue(x <= y, c, s); | 12800 return new BoolValue(x <= y, c, s); |
13308 | 12801 |
13309 case (55): | 12802 case (55): |
13310 | 12803 |
13311 return new BoolValue(x >= y, c, s); | 12804 return new BoolValue(x >= y, c, s); |
13312 | 12805 |
13313 } | 12806 } |
13314 } | 12807 } |
13315 return Value.prototype.binop.call(this, kind, other, context, node); | 12808 return Value.prototype.binop.call(this, kind, other, context, node); |
13316 } | 12809 } |
13317 IntValue.prototype.binop$4 = IntValue.prototype.binop; | |
13318 IntValue.prototype.unop$3 = IntValue.prototype.unop; | |
13319 // ********** Code for DoubleValue ************** | 12810 // ********** Code for DoubleValue ************** |
13320 $inherits(DoubleValue, EvaluatedValue); | 12811 $inherits(DoubleValue, EvaluatedValue); |
13321 function DoubleValue(actualValue, isConst, span) { | 12812 function DoubleValue(actualValue, isConst, span) { |
13322 this.actualValue = actualValue; | 12813 this.actualValue = actualValue; |
13323 EvaluatedValue.call(this, isConst, $globals.world.doubleType, span); | 12814 EvaluatedValue.call(this, isConst, $globals.world.doubleType, span); |
13324 } | 12815 } |
13325 DoubleValue.prototype.get$actualValue = function() { return this.actualValue; }; | 12816 DoubleValue.prototype.get$actualValue = function() { return this.actualValue; }; |
13326 DoubleValue.prototype.get$code = function() { | 12817 DoubleValue.prototype.get$code = function() { |
13327 return ("(" + this.actualValue + ")"); | 12818 return ("(" + this.actualValue + ")"); |
13328 } | 12819 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13449 return new BoolValue(x <= y, c, s); | 12940 return new BoolValue(x <= y, c, s); |
13450 | 12941 |
13451 case (55): | 12942 case (55): |
13452 | 12943 |
13453 return new BoolValue(x >= y, c, s); | 12944 return new BoolValue(x >= y, c, s); |
13454 | 12945 |
13455 } | 12946 } |
13456 } | 12947 } |
13457 return Value.prototype.binop.call(this, kind, other, context, node); | 12948 return Value.prototype.binop.call(this, kind, other, context, node); |
13458 } | 12949 } |
13459 DoubleValue.prototype.binop$4 = DoubleValue.prototype.binop; | |
13460 DoubleValue.prototype.unop$3 = DoubleValue.prototype.unop; | |
13461 // ********** Code for StringValue ************** | 12950 // ********** Code for StringValue ************** |
13462 $inherits(StringValue, EvaluatedValue); | 12951 $inherits(StringValue, EvaluatedValue); |
13463 function StringValue(actualValue, isConst, span) { | 12952 function StringValue(actualValue, isConst, span) { |
13464 this.actualValue = actualValue; | 12953 this.actualValue = actualValue; |
13465 EvaluatedValue.call(this, isConst, $globals.world.stringType, span); | 12954 EvaluatedValue.call(this, isConst, $globals.world.stringType, span); |
13466 } | 12955 } |
13467 StringValue.prototype.get$actualValue = function() { return this.actualValue; }; | 12956 StringValue.prototype.get$actualValue = function() { return this.actualValue; }; |
13468 StringValue.prototype.binop = function(kind, other, context, node) { | 12957 StringValue.prototype.binop = function(kind, other, context, node) { |
13469 if (!(other instanceof StringValue)) return Value.prototype.binop.call(this, k
ind, other, context, node); | 12958 if (!(other instanceof StringValue)) return Value.prototype.binop.call(this, k
ind, other, context, node); |
13470 var c = this.isConst && other.get$isConst(); | 12959 var c = this.isConst && other.get$isConst(); |
13471 var s = node.get$span(); | 12960 var s = node.get$span(); |
13472 var x = this.actualValue, y = other.get$actualValue(); | 12961 var x = this.actualValue, y = other.get$actualValue(); |
13473 switch (kind) { | 12962 switch (kind) { |
13474 case (50): | 12963 case (50): |
13475 case (48): | 12964 case (48): |
13476 | 12965 |
13477 return new BoolValue(x == y, c, s); | 12966 return new BoolValue(x == y, c, s); |
13478 | 12967 |
13479 case (51): | 12968 case (51): |
13480 case (49): | 12969 case (49): |
13481 | 12970 |
13482 return new BoolValue(x != y, c, s); | 12971 return new BoolValue(x != y, c, s); |
13483 | 12972 |
13484 case (42): | 12973 case (42): |
13485 | 12974 |
13486 return new StringValue(x + y, c, s); | 12975 return new StringValue($add(x, y), c, s); |
13487 | 12976 |
13488 } | 12977 } |
13489 return Value.prototype.binop.call(this, kind, other, context, node); | 12978 return Value.prototype.binop.call(this, kind, other, context, node); |
13490 } | 12979 } |
13491 StringValue.prototype.get$code = function() { | 12980 StringValue.prototype.get$code = function() { |
13492 var buf = new StringBufferImpl(""); | 12981 var buf = new StringBufferImpl(""); |
13493 buf.add("\""); | 12982 buf.add("\""); |
13494 for (var i = (0); | 12983 for (var i = (0); |
13495 i < this.actualValue.length; i++) { | 12984 i < this.actualValue.length; i++) { |
13496 var ch = this.actualValue.charCodeAt(i); | 12985 var ch = this.actualValue.charCodeAt(i); |
(...skipping 18 matching lines...) Expand all Loading... |
13515 buf.add("\\\""); | 13004 buf.add("\\\""); |
13516 break; | 13005 break; |
13517 | 13006 |
13518 case (92): | 13007 case (92): |
13519 | 13008 |
13520 buf.add("\\\\"); | 13009 buf.add("\\\\"); |
13521 break; | 13010 break; |
13522 | 13011 |
13523 default: | 13012 default: |
13524 | 13013 |
13525 if (ch >= (32) && ch <= (126)) { | 13014 if ($gte(ch, (32)) && $lte(ch, (126))) { |
13526 buf.add(this.actualValue[i]); | 13015 buf.add(this.actualValue[i]); |
13527 } | 13016 } |
13528 else { | 13017 else { |
13529 var hex = ch.toRadixString$1((16)); | 13018 var hex = ch.toRadixString((16)); |
13530 switch (hex.get$length()) { | 13019 switch (hex.get$length()) { |
13531 case (1): | 13020 case (1): |
13532 | 13021 |
13533 buf.add("\\x0"); | 13022 buf.add("\\x0"); |
13534 buf.add(hex); | 13023 buf.add(hex); |
13535 break; | 13024 break; |
13536 | 13025 |
13537 case (2): | 13026 case (2): |
13538 | 13027 |
13539 buf.add("\\x"); | 13028 buf.add("\\x"); |
(...skipping 19 matching lines...) Expand all Loading... |
13559 | 13048 |
13560 } | 13049 } |
13561 } | 13050 } |
13562 break; | 13051 break; |
13563 | 13052 |
13564 } | 13053 } |
13565 } | 13054 } |
13566 buf.add("\""); | 13055 buf.add("\""); |
13567 return buf.toString(); | 13056 return buf.toString(); |
13568 } | 13057 } |
13569 StringValue.prototype.binop$4 = StringValue.prototype.binop; | |
13570 // ********** Code for ListValue ************** | 13058 // ********** Code for ListValue ************** |
13571 $inherits(ListValue, EvaluatedValue); | 13059 $inherits(ListValue, EvaluatedValue); |
13572 function ListValue(values, isConst, type, span) { | 13060 function ListValue(values, isConst, type, span) { |
13573 this.values = values; | 13061 this.values = values; |
13574 EvaluatedValue.call(this, isConst, type, span); | 13062 EvaluatedValue.call(this, isConst, type, span); |
13575 } | 13063 } |
13576 ListValue.prototype.get$code = function() { | 13064 ListValue.prototype.get$code = function() { |
13577 var buf = new StringBufferImpl(""); | 13065 var buf = new StringBufferImpl(""); |
13578 buf.add$1("["); | 13066 buf.add("["); |
13579 for (var i = (0); | 13067 for (var i = (0); |
13580 i < this.values.get$length(); i = $add(i, (1))) { | 13068 $lt(i, this.values.get$length()); i = $add(i, (1))) { |
13581 if (i > (0)) buf.add$1(", "); | 13069 if ($gt(i, (0))) buf.add(", "); |
13582 buf.add$1(this.values[i].get$code()); | 13070 buf.add(this.values.$index(i).get$code()); |
13583 } | 13071 } |
13584 buf.add$1("]"); | 13072 buf.add("]"); |
13585 var listCode = buf.toString$0(); | 13073 var listCode = buf.toString$0(); |
13586 if (!this.isConst) return listCode; | 13074 if (!this.isConst) return listCode; |
13587 var v = new Value($globals.world.listType, listCode, this.span); | 13075 var v = new Value($globals.world.listType, listCode, this.span); |
13588 var immutableListCtor = $globals.world.immutableListType.getConstructor("from"
); | 13076 var immutableListCtor = $globals.world.immutableListType.getConstructor("from"
); |
13589 var result = immutableListCtor.invoke$4(null, null, new TypeValue(v.get$type()
, this.span), new Arguments(null, [v])); | 13077 var result = immutableListCtor.invoke($globals.world.gen.mainContext, null, ne
w TypeValue(v.get$type(), this.span), new Arguments(null, [v])); |
13590 return result.get$code(); | 13078 return result.get$code(); |
13591 } | 13079 } |
13592 ListValue.prototype.binop = function(kind, other, context, node) { | 13080 ListValue.prototype.binop = function(kind, other, context, node) { |
13593 if (!(other instanceof ListValue)) return Value.prototype.binop.call(this, kin
d, other, context, node); | 13081 if (!(other instanceof ListValue)) return Value.prototype.binop.call(this, kin
d, other, context, node); |
13594 switch (kind) { | 13082 switch (kind) { |
13595 case (50): | 13083 case (50): |
13596 | 13084 |
13597 return new BoolValue($eq(this.get$type(), other.get$type()) && this.get$co
de() == other.get$code(), this.isConst && other.get$isConst(), node.get$span()); | 13085 return new BoolValue($eq(this.get$type(), other.get$type()) && this.get$co
de() == other.get$code(), this.isConst && other.get$isConst(), node.get$span()); |
13598 | 13086 |
13599 case (51): | 13087 case (51): |
13600 | 13088 |
13601 return new BoolValue($ne(this.get$type(), other.get$type()) || this.get$co
de() != other.get$code(), this.isConst && other.get$isConst(), node.get$span()); | 13089 return new BoolValue($ne(this.get$type(), other.get$type()) || this.get$co
de() != other.get$code(), this.isConst && other.get$isConst(), node.get$span()); |
13602 | 13090 |
13603 } | 13091 } |
13604 return Value.prototype.binop.call(this, kind, other, context, node); | 13092 return Value.prototype.binop.call(this, kind, other, context, node); |
13605 } | 13093 } |
13606 ListValue.prototype.getGlobalValue = function() { | 13094 ListValue.prototype.getGlobalValue = function() { |
13607 return $globals.world.gen.globalForConst(this, this.values); | 13095 return $globals.world.gen.globalForConst(this, this.values); |
13608 } | 13096 } |
13609 ListValue.prototype.binop$4 = ListValue.prototype.binop; | |
13610 ListValue.prototype.getGlobalValue$0 = ListValue.prototype.getGlobalValue; | |
13611 // ********** Code for MapValue ************** | 13097 // ********** Code for MapValue ************** |
13612 $inherits(MapValue, EvaluatedValue); | 13098 $inherits(MapValue, EvaluatedValue); |
13613 function MapValue(values, isConst, type, span) { | 13099 function MapValue(values, isConst, type, span) { |
13614 this.values = values; | 13100 this.values = values; |
13615 EvaluatedValue.call(this, isConst, type, span); | 13101 EvaluatedValue.call(this, isConst, type, span); |
13616 } | 13102 } |
13617 MapValue.prototype.get$code = function() { | 13103 MapValue.prototype.get$code = function() { |
13618 var items = new ListValue(this.values, false, $globals.world.listType, this.sp
an); | 13104 var items = new ListValue(this.values, false, $globals.world.listType, this.sp
an); |
13619 var tp = $globals.world.coreimpl.topType; | 13105 var tp = $globals.world.coreimpl.topType; |
13620 var f = this.isConst ? tp.getMember$1("_constMap") : tp.getMember$1("_map"); | 13106 var f = this.isConst ? tp.getMember("_constMap") : tp.getMember("_map"); |
13621 var value = f.invoke(null, null, new TypeValue(tp, null), new Arguments(null,
[items]), false); | 13107 var value = f.invoke($globals.world.gen.mainContext, null, new TypeValue(tp, n
ull), new Arguments(null, [items])); |
13622 return value.get$code(); | 13108 return value.get$code(); |
13623 } | 13109 } |
13624 MapValue.prototype.getGlobalValue = function() { | 13110 MapValue.prototype.getGlobalValue = function() { |
13625 return $globals.world.gen.globalForConst(this, this.values); | 13111 return $globals.world.gen.globalForConst(this, this.values); |
13626 } | 13112 } |
13627 MapValue.prototype.binop = function(kind, other, context, node) { | 13113 MapValue.prototype.binop = function(kind, other, context, node) { |
13628 if (!(other instanceof MapValue)) return Value.prototype.binop.call(this, kind
, other, context, node); | 13114 if (!(other instanceof MapValue)) return Value.prototype.binop.call(this, kind
, other, context, node); |
13629 switch (kind) { | 13115 switch (kind) { |
13630 case (50): | 13116 case (50): |
13631 | 13117 |
13632 return new BoolValue($eq(this.get$type(), other.get$type()) && this.get$co
de() == other.get$code(), this.isConst && other.get$isConst(), node.get$span()); | 13118 return new BoolValue($eq(this.get$type(), other.get$type()) && this.get$co
de() == other.get$code(), this.isConst && other.get$isConst(), node.get$span()); |
13633 | 13119 |
13634 case (51): | 13120 case (51): |
13635 | 13121 |
13636 return new BoolValue($ne(this.get$type(), other.get$type()) || this.get$co
de() != other.get$code(), this.isConst && other.get$isConst(), node.get$span()); | 13122 return new BoolValue($ne(this.get$type(), other.get$type()) || this.get$co
de() != other.get$code(), this.isConst && other.get$isConst(), node.get$span()); |
13637 | 13123 |
13638 } | 13124 } |
13639 return Value.prototype.binop.call(this, kind, other, context, node); | 13125 return Value.prototype.binop.call(this, kind, other, context, node); |
13640 } | 13126 } |
13641 MapValue.prototype.binop$4 = MapValue.prototype.binop; | |
13642 MapValue.prototype.getGlobalValue$0 = MapValue.prototype.getGlobalValue; | |
13643 // ********** Code for ObjectValue ************** | 13127 // ********** Code for ObjectValue ************** |
13644 $inherits(ObjectValue, EvaluatedValue); | 13128 $inherits(ObjectValue, EvaluatedValue); |
13645 function ObjectValue(isConst, type, span) { | 13129 function ObjectValue(isConst, type, span) { |
13646 this.seenNativeInitializer = false; | 13130 this.seenNativeInitializer = false; |
13647 this.fields = new HashMapImplementation(); | 13131 this.fields = new HashMapImplementation(); |
13648 EvaluatedValue.call(this, isConst, type, span); | 13132 EvaluatedValue.call(this, isConst, type, span); |
13649 } | 13133 } |
13650 ObjectValue.prototype.get$fields = function() { return this.fields; }; | 13134 ObjectValue.prototype.get$fields = function() { return this.fields; }; |
13651 ObjectValue.prototype.get$seenNativeInitializer = function() { return this.seenN
ativeInitializer; }; | 13135 ObjectValue.prototype.get$seenNativeInitializer = function() { return this.seenN
ativeInitializer; }; |
13652 ObjectValue.prototype.set$seenNativeInitializer = function(value) { return this.
seenNativeInitializer = value; }; | 13136 ObjectValue.prototype.set$seenNativeInitializer = function(value) { return this.
seenNativeInitializer = value; }; |
13653 ObjectValue.prototype.get$code = function() { | 13137 ObjectValue.prototype.get$code = function() { |
13654 if (this._code == null) this.validateInitialized(null); | 13138 if (this._code == null) this.validateInitialized(null); |
13655 return this._code; | 13139 return this._code; |
13656 } | 13140 } |
13657 ObjectValue.prototype.initFields = function() { | 13141 ObjectValue.prototype.initFields = function() { |
13658 var allMembers = $globals.world.gen._orderValues(this.get$type().getAllMembers
()); | 13142 var allMembers = $globals.world.gen._orderValues(this.get$type().get$genericTy
pe().getAllMembers()); |
13659 for (var $$i = allMembers.iterator$0(); $$i.hasNext$0(); ) { | 13143 for (var $$i = allMembers.iterator(); $$i.hasNext(); ) { |
13660 var f = $$i.next$0(); | 13144 var f = $$i.next(); |
13661 if (f.get$isField() && !f.get$isStatic() && f.get$declaringType().get$isClas
s()) { | 13145 if (f.get$isField() && !f.get$isStatic() && f.get$declaringType().get$isClas
s()) { |
13662 this.fields.$setindex(f, f.computeValue$0()); | 13146 this.fields.$setindex(f, f.computeValue()); |
13663 } | 13147 } |
13664 } | 13148 } |
13665 } | 13149 } |
13666 ObjectValue.prototype.setField = function(field, value, duringInit) { | 13150 ObjectValue.prototype.setField = function(field, value, duringInit) { |
13667 if (value.get$isConst() && (value instanceof VariableValue)) { | 13151 if (value.get$isConst() && (value instanceof VariableValue)) { |
13668 value = value.get$dynamic().get$value(); | 13152 value = value.get$dynamic().get$value(); |
13669 } | 13153 } |
13670 var currentValue = this.fields.$index(field); | 13154 var currentValue = this.fields.$index(field); |
13671 if (this.isConst && !value.get$isConst()) { | 13155 if (this.isConst && !value.get$isConst()) { |
13672 $globals.world.error("used of non-const value in const intializer", value.sp
an); | 13156 $globals.world.error("used of non-const value in const intializer", value.sp
an); |
13673 } | 13157 } |
13674 if (currentValue == null) { | 13158 if (currentValue == null) { |
13675 this.fields.$setindex(field, value); | 13159 this.fields.$setindex(field, value); |
13676 if (field.get$isFinal() && !duringInit) { | 13160 if (field.get$isFinal() && !duringInit) { |
13677 $globals.world.error("can not initialize final fields outside of initializ
er", value.span); | 13161 $globals.world.error("can not initialize final fields outside of initializ
er", value.span); |
13678 } | 13162 } |
13679 } | 13163 } |
13680 else { | 13164 else { |
13681 if (field.get$isFinal() && field.computeValue() == null) { | 13165 if (field.get$isFinal() && field.computeValue() == null) { |
13682 $globals.world.error("reassignment of field not allowed", value.span, fiel
d.get$span()); | 13166 $globals.world.error("reassignment of field not allowed", value.span, fiel
d.get$span()); |
13683 } | 13167 } |
13684 else { | 13168 else { |
13685 this.fields.$setindex(field, value); | 13169 this.fields.$setindex(field, value); |
13686 } | 13170 } |
13687 } | 13171 } |
13688 } | 13172 } |
13689 ObjectValue.prototype.validateInitialized = function(span) { | 13173 ObjectValue.prototype.validateInitialized = function(span) { |
13690 var buf = new StringBufferImpl(""); | 13174 var buf = new StringBufferImpl(""); |
13691 buf.add$1("Object.create("); | 13175 buf.add("Object.create("); |
13692 buf.add$1(("" + this.get$type().get$jsname() + ".prototype, ")); | 13176 buf.add(("" + this.get$type().get$jsname() + ".prototype, ")); |
13693 buf.add$1("{"); | 13177 buf.add("{"); |
13694 var $$list = this.fields.getKeys(); | 13178 var $$list = this.fields.getKeys(); |
13695 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 13179 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
13696 var field = $$i.next$0(); | 13180 var field = $$i.next(); |
13697 buf.add$1(field.get$name()); | 13181 buf.add(field.get$name()); |
13698 buf.add$1(": "); | 13182 buf.add(": "); |
13699 buf.add$1("{\"value\": "); | 13183 buf.add("{\"value\": "); |
13700 if (this.fields.$index(field) == null) { | 13184 if (this.fields.$index(field) == null) { |
13701 $globals.world.error(("Required field \"" + field.get$name() + "\" was not
initialized"), span, field.get$span()); | 13185 $globals.world.error(("Required field \"" + field.get$name() + "\" was not
initialized"), span, field.get$span()); |
13702 buf.add$1("null"); | 13186 buf.add("null"); |
13703 } | 13187 } |
13704 else { | 13188 else { |
13705 buf.add$1(this.fields.$index(field).get$code()); | 13189 buf.add(this.fields.$index(field).get$code()); |
13706 } | 13190 } |
13707 buf.add$1(", writeable: false}, "); | 13191 buf.add(", writeable: false}, "); |
13708 } | 13192 } |
13709 buf.add$1("})"); | 13193 buf.add("})"); |
13710 this._code = buf.toString$0(); | 13194 this._code = buf.toString$0(); |
13711 } | 13195 } |
13712 ObjectValue.prototype.binop = function(kind, other, context, node) { | 13196 ObjectValue.prototype.binop = function(kind, other, context, node) { |
13713 if (!(other instanceof ObjectValue)) return Value.prototype.binop.call(this, k
ind, other, context, node); | 13197 if (!(other instanceof ObjectValue)) return Value.prototype.binop.call(this, k
ind, other, context, node); |
13714 switch (kind) { | 13198 switch (kind) { |
13715 case (50): | 13199 case (50): |
13716 case (48): | 13200 case (48): |
13717 | 13201 |
13718 return new BoolValue($eq(this.get$type(), other.get$type()) && this.get$co
de() == other.get$code(), this.isConst && other.get$isConst(), node.get$span()); | 13202 return new BoolValue($eq(this.get$type(), other.get$type()) && this.get$co
de() == other.get$code(), this.isConst && other.get$isConst(), node.get$span()); |
13719 | 13203 |
13720 case (51): | 13204 case (51): |
13721 case (49): | 13205 case (49): |
13722 | 13206 |
13723 return new BoolValue($ne(this.get$type(), other.get$type()) || this.get$co
de() != other.get$code(), this.isConst && other.get$isConst(), node.get$span()); | 13207 return new BoolValue($ne(this.get$type(), other.get$type()) || this.get$co
de() != other.get$code(), this.isConst && other.get$isConst(), node.get$span()); |
13724 | 13208 |
13725 } | 13209 } |
13726 return Value.prototype.binop.call(this, kind, other, context, node); | 13210 return Value.prototype.binop.call(this, kind, other, context, node); |
13727 } | 13211 } |
13728 ObjectValue.prototype.binop$4 = ObjectValue.prototype.binop; | |
13729 ObjectValue.prototype.initFields$0 = ObjectValue.prototype.initFields; | |
13730 // ********** Code for GlobalValue ************** | 13212 // ********** Code for GlobalValue ************** |
13731 $inherits(GlobalValue, Value); | 13213 $inherits(GlobalValue, Value); |
13732 function GlobalValue(type, code, isConst, field, name, exp, span, deps) { | 13214 function GlobalValue(type, code, isConst, field, name, exp, span, deps) { |
13733 this.exp = exp; | 13215 this.exp = exp; |
13734 this.field = field; | 13216 this.field = field; |
13735 this.name = name; | 13217 this.name = name; |
13736 this.dependencies = []; | 13218 this.dependencies = []; |
13737 this.isConst = isConst; | 13219 this.isConst = isConst; |
13738 Value.call(this, type, code, span); | 13220 Value.call(this, type, code, span); |
13739 for (var $$i = 0;$$i < deps.get$length(); $$i++) { | 13221 for (var $$i = deps.iterator(); $$i.hasNext(); ) { |
13740 var dep = deps[$$i]; | 13222 var dep = $$i.next(); |
13741 if ((dep instanceof GlobalValue)) { | 13223 if ((dep instanceof GlobalValue)) { |
13742 this.dependencies.add(dep); | 13224 this.dependencies.add(dep); |
13743 this.dependencies.addAll(dep.get$dependencies()); | 13225 this.dependencies.addAll(dep.get$dependencies()); |
13744 } | 13226 } |
13745 } | 13227 } |
13746 } | 13228 } |
13747 GlobalValue.prototype.get$field = function() { return this.field; }; | 13229 GlobalValue.prototype.get$field = function() { return this.field; }; |
13748 GlobalValue.prototype.get$name = function() { return this.name; }; | 13230 GlobalValue.prototype.get$name = function() { return this.name; }; |
13749 GlobalValue.prototype.get$exp = function() { return this.exp; }; | 13231 GlobalValue.prototype.get$exp = function() { return this.exp; }; |
13750 GlobalValue.prototype.get$isConst = function() { return this.isConst; }; | 13232 GlobalValue.prototype.get$isConst = function() { return this.isConst; }; |
(...skipping 26 matching lines...) Expand all Loading... |
13777 else if (this.name != null && other.name == null) { | 13259 else if (this.name != null && other.name == null) { |
13778 return (-1); | 13260 return (-1); |
13779 } | 13261 } |
13780 else if (this.name != null) { | 13262 else if (this.name != null) { |
13781 return this.name.compareTo(other.name); | 13263 return this.name.compareTo(other.name); |
13782 } | 13264 } |
13783 else { | 13265 else { |
13784 return this.field.name.compareTo(other.field.name); | 13266 return this.field.name.compareTo(other.field.name); |
13785 } | 13267 } |
13786 } | 13268 } |
13787 GlobalValue.prototype.compareTo$1 = GlobalValue.prototype.compareTo; | |
13788 // ********** Code for BareValue ************** | 13269 // ********** Code for BareValue ************** |
13789 $inherits(BareValue, Value); | 13270 $inherits(BareValue, Value); |
13790 function BareValue(home, outermost, span) { | 13271 function BareValue(home, outermost, span) { |
13791 this.isType = outermost.get$isStatic(); | 13272 this.isType = outermost.get$isStatic(); |
13792 this.home = home; | 13273 this.home = home; |
13793 Value.call(this, outermost.method.declaringType, null, span); | 13274 Value.call(this, outermost.method.get$declaringType(), null, span); |
13794 } | 13275 } |
13795 BareValue.prototype.get$isType = function() { return this.isType; }; | 13276 BareValue.prototype.get$isType = function() { return this.isType; }; |
13796 BareValue.prototype.get$needsTemp = function() { | 13277 BareValue.prototype.get$needsTemp = function() { |
13797 return false; | 13278 return false; |
13798 } | 13279 } |
13799 BareValue.prototype._shouldBindDynamically = function() { | 13280 BareValue.prototype._shouldBindDynamically = function() { |
13800 return false; | 13281 return false; |
13801 } | 13282 } |
13802 BareValue.prototype.get$code = function() { | 13283 BareValue.prototype.get$code = function() { |
13803 return this._code; | 13284 return this._code; |
13804 } | 13285 } |
13805 BareValue.prototype._ensureCode = function() { | 13286 BareValue.prototype._ensureCode = function() { |
13806 if (this._code == null) this._code = this.isType ? this.get$type().get$jsname(
) : this.home._makeThisCode(); | 13287 if (this._code == null) this._code = this.isType ? this.get$type().get$jsname(
) : this.home._makeThisCode(); |
13807 } | 13288 } |
13808 BareValue.prototype._tryResolveMember = function(context, name, isDynamic, node)
{ | 13289 BareValue.prototype._tryResolveMember = function(context, name, node) { |
13809 var member = this.get$type().getMember(name); | 13290 var member = this.get$type().getMember(name); |
13810 if (member == null || $ne(member.get$declaringType(), this.get$type())) { | 13291 if ($eq(member) || $ne(member.get$declaringType(), this.get$type())) { |
13811 var libMember = this.home.get$library().lookup(name, this.span); | 13292 var libMember = this.home.get$library().lookup(name, this.span); |
13812 if (libMember != null) { | 13293 if (libMember != null) { |
13813 return libMember.get$preciseMemberSet(); | 13294 return libMember.get$preciseMemberSet(); |
13814 } | 13295 } |
13815 } | 13296 } |
13816 this._ensureCode(); | 13297 this._ensureCode(); |
13817 return Value.prototype._tryResolveMember.call(this, context, name, isDynamic,
node); | 13298 return Value.prototype._tryResolveMember.call(this, context, name, node); |
13818 } | 13299 } |
13819 // ********** Code for SuperValue ************** | 13300 // ********** Code for SuperValue ************** |
13820 $inherits(SuperValue, Value); | 13301 $inherits(SuperValue, Value); |
13821 function SuperValue(parentType, span) { | 13302 function SuperValue(parentType, span) { |
13822 Value.call(this, parentType, "this", span); | 13303 Value.call(this, parentType, "this", span); |
13823 } | 13304 } |
13824 SuperValue.prototype.get$needsTemp = function() { | 13305 SuperValue.prototype.get$needsTemp = function() { |
13825 return false; | 13306 return false; |
13826 } | 13307 } |
13827 SuperValue.prototype.get$isSuper = function() { | 13308 SuperValue.prototype.get$isSuper = function() { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13927 return this.replaceValue(this.value.unop(kind, context, node)); | 13408 return this.replaceValue(this.value.unop(kind, context, node)); |
13928 } | 13409 } |
13929 return Value.prototype.unop.call(this, kind, context, node); | 13410 return Value.prototype.unop.call(this, kind, context, node); |
13930 } | 13411 } |
13931 VariableValue.prototype.binop = function(kind, other, context, node) { | 13412 VariableValue.prototype.binop = function(kind, other, context, node) { |
13932 if (this.value != null) { | 13413 if (this.value != null) { |
13933 return this.replaceValue(this.value.binop(kind, VariableValue._unwrap(other)
, context, node)); | 13414 return this.replaceValue(this.value.binop(kind, VariableValue._unwrap(other)
, context, node)); |
13934 } | 13415 } |
13935 return Value.prototype.binop.call(this, kind, other, context, node); | 13416 return Value.prototype.binop.call(this, kind, other, context, node); |
13936 } | 13417 } |
13937 VariableValue.prototype.binop$4 = VariableValue.prototype.binop; | |
13938 VariableValue.prototype.replaceValue$1 = VariableValue.prototype.replaceValue; | |
13939 VariableValue.prototype.unop$3 = VariableValue.prototype.unop; | |
13940 // ********** Code for CompilerException ************** | 13418 // ********** Code for CompilerException ************** |
13941 function CompilerException(_message, _location) { | 13419 function CompilerException(_message, _location) { |
13942 this._lang_message = _message; | 13420 this._lang_message = _message; |
13943 this._location = _location; | 13421 this._location = _location; |
13944 } | 13422 } |
13945 CompilerException.prototype.toString = function() { | 13423 CompilerException.prototype.toString = function() { |
13946 if (this._location != null) { | 13424 if (this._location != null) { |
13947 return ("CompilerException: " + this._location.toMessageString(this._lang_me
ssage)); | 13425 return ("CompilerException: " + this._location.toMessageString(this._lang_me
ssage)); |
13948 } | 13426 } |
13949 else { | 13427 else { |
(...skipping 16 matching lines...) Expand all Loading... |
13966 $globals.world.info(("Invoke calls: " + this.invokeCalls)); | 13444 $globals.world.info(("Invoke calls: " + this.invokeCalls)); |
13967 $globals.world.info(("msetN calls: " + this.msetN)); | 13445 $globals.world.info(("msetN calls: " + this.msetN)); |
13968 } | 13446 } |
13969 CounterLog.prototype.add = function(other) { | 13447 CounterLog.prototype.add = function(other) { |
13970 this.dynamicMethodCalls = this.dynamicMethodCalls + other.dynamicMethodCalls; | 13448 this.dynamicMethodCalls = this.dynamicMethodCalls + other.dynamicMethodCalls; |
13971 this.typeAsserts = this.typeAsserts + other.typeAsserts; | 13449 this.typeAsserts = this.typeAsserts + other.typeAsserts; |
13972 this.objectProtoMembers = this.objectProtoMembers + other.objectProtoMembers; | 13450 this.objectProtoMembers = this.objectProtoMembers + other.objectProtoMembers; |
13973 this.invokeCalls = this.invokeCalls + other.invokeCalls; | 13451 this.invokeCalls = this.invokeCalls + other.invokeCalls; |
13974 this.msetN = this.msetN + other.msetN; | 13452 this.msetN = this.msetN + other.msetN; |
13975 } | 13453 } |
13976 CounterLog.prototype.add$1 = CounterLog.prototype.add; | |
13977 // ********** Code for World ************** | 13454 // ********** Code for World ************** |
13978 function World(files) { | 13455 function World(files) { |
13979 this.files = files; | 13456 this.files = files; |
13980 this._members = new HashMapImplementation(); | 13457 this._members = new HashMapImplementation(); |
13981 this._topNames = new HashMapImplementation(); | 13458 this._topNames = new HashMapImplementation(); |
13982 this.warnings = (0); | 13459 this.warnings = (0); |
13983 this.seenFatal = false; | 13460 this.seenFatal = false; |
13984 this.libraries = new HashMapImplementation(); | 13461 this.libraries = new HashMapImplementation(); |
13985 this.dartBytesRead = (0); | 13462 this.dartBytesRead = (0); |
13986 this._todo = []; | 13463 this._todo = []; |
(...skipping 30 matching lines...) Expand all Loading... |
14017 this.nonNullBool = new NonNullableType(this.boolType); | 13494 this.nonNullBool = new NonNullableType(this.boolType); |
14018 } | 13495 } |
14019 World.prototype._addMember = function(member) { | 13496 World.prototype._addMember = function(member) { |
14020 if (member.get$isStatic()) { | 13497 if (member.get$isStatic()) { |
14021 if (member.declaringType.get$isTop()) { | 13498 if (member.declaringType.get$isTop()) { |
14022 this._addTopName(member); | 13499 this._addTopName(member); |
14023 } | 13500 } |
14024 return; | 13501 return; |
14025 } | 13502 } |
14026 var mset = this._members.$index(member.name); | 13503 var mset = this._members.$index(member.name); |
14027 if (mset == null) { | 13504 if ($eq(mset)) { |
14028 mset = new MemberSet(member, true); | 13505 mset = new MemberSet(member, true); |
14029 this._members.$setindex(mset.get$name(), mset); | 13506 this._members.$setindex(mset.get$name(), mset); |
14030 } | 13507 } |
14031 else { | 13508 else { |
14032 mset.get$members().add$1(member); | 13509 mset.get$members().add(member); |
14033 } | 13510 } |
14034 } | 13511 } |
14035 World.prototype._addTopName = function(named) { | 13512 World.prototype._addTopName = function(named) { |
14036 if ((named instanceof Type) && named.get$isNative()) { | 13513 if ((named instanceof Type) && named.get$isNative()) { |
14037 if (named.get$avoidNativeName()) { | 13514 if (named.get$avoidNativeName()) { |
14038 this._addJavascriptTopName(new ExistingJsGlobal(named.get$nativeName(), na
med), named.get$nativeName()); | 13515 this._addJavascriptTopName(new ExistingJsGlobal(named.get$nativeName(), na
med), named.get$nativeName()); |
14039 } | 13516 } |
14040 else { | 13517 else { |
14041 this._addJavascriptTopName(named, named.get$nativeName()); | 13518 this._addJavascriptTopName(named, named.get$nativeName()); |
14042 } | 13519 } |
14043 } | 13520 } |
14044 this._addJavascriptTopName(named, named.get$jsname()); | 13521 this._addJavascriptTopName(named, named.get$jsname()); |
14045 } | 13522 } |
14046 World.prototype._addJavascriptTopName = function(named, name) { | 13523 World.prototype._addJavascriptTopName = function(named, name) { |
14047 var existing = this._topNames.$index(name); | 13524 var existing = this._topNames.$index(name); |
14048 if (existing == null) { | 13525 if ($eq(existing)) { |
14049 this._topNames.$setindex(name, named); | 13526 this._topNames.$setindex(name, named); |
14050 return; | 13527 return; |
14051 } | 13528 } |
14052 if (existing == named) { | 13529 if (existing == named) { |
14053 return; | 13530 return; |
14054 } | 13531 } |
14055 this.info(("mangling matching top level name \"" + named.get$jsname() + "\" in
") + ("both \"" + named.get$library().get$jsname() + "\" and \"" + existing.get
$library().get$jsname() + "\"")); | 13532 this.info($add(("mangling matching top level name \"" + named.get$jsname() + "
\" in "), ("both \"" + named.get$library().get$jsname() + "\" and \"" + existing
.get$library().get$jsname() + "\""))); |
14056 var existingPri = existing.get$jsnamePriority(); | 13533 var existingPri = existing.get$jsnamePriority(); |
14057 var namedPri = named.get$jsnamePriority(); | 13534 var namedPri = named.get$jsnamePriority(); |
14058 if (existingPri > namedPri || namedPri == (0)) { | 13535 if (existingPri > namedPri || namedPri == (0)) { |
14059 this._renameJavascriptTopName(named); | 13536 this._renameJavascriptTopName(named); |
14060 } | 13537 } |
14061 else if (namedPri > existingPri) { | 13538 else if (namedPri > existingPri) { |
14062 this._renameJavascriptTopName(existing); | 13539 this._renameJavascriptTopName(existing); |
14063 } | 13540 } |
14064 else { | 13541 else { |
14065 var msg = ("conflicting JS name \"" + name + "\" of same ") + ("priority " +
existingPri + ": (already defined in) ") + ("" + existing.get$span().get$locati
onText() + " with priority " + namedPri + ")"); | 13542 var msg = $add($add(("conflicting JS name \"" + name + "\" of same "), ("pri
ority " + existingPri + ": (already defined in) ")), ("" + existing.get$span().g
et$locationText() + " with priority " + namedPri + ")")); |
14066 if (named.get$isNative()) { | 13543 if (named.get$isNative()) { |
14067 $globals.world.info(msg, named.get$span(), existing.get$span()); | 13544 $globals.world.info(msg, named.get$span(), existing.get$span()); |
14068 } | 13545 } |
14069 else { | 13546 else { |
14070 $globals.world.internalError(msg, named.get$span(), existing.get$span()); | 13547 $globals.world.internalError(msg, named.get$span(), existing.get$span()); |
14071 } | 13548 } |
14072 } | 13549 } |
14073 } | 13550 } |
14074 World.prototype._renameJavascriptTopName = function(named) { | 13551 World.prototype._renameJavascriptTopName = function(named) { |
14075 named._jsname = ("" + named.get$library().get$jsname() + "_" + named.get$jsnam
e()); | 13552 named._jsname = ("" + named.get$library().get$jsname() + "_" + named.get$jsnam
e()); |
14076 var existing = this._topNames.$index(named.get$jsname()); | 13553 var existing = this._topNames.$index(named.get$jsname()); |
14077 if (existing != null && $ne(existing, named)) { | 13554 if ($ne(existing) && $ne(existing, named)) { |
14078 $globals.world.internalError(("name mangling failed for \"" + named.get$jsna
me() + "\" ") + ("(\"" + named.get$jsname() + "\" defined also in " + existing.g
et$span().get$locationText() + ")"), named.get$span()); | 13555 $globals.world.internalError($add(("name mangling failed for \"" + named.get
$jsname() + "\" "), ("(\"" + named.get$jsname() + "\" defined also in " + existi
ng.get$span().get$locationText() + ")")), named.get$span()); |
14079 } | 13556 } |
14080 this._topNames.$setindex(named.get$jsname(), named); | 13557 this._topNames.$setindex(named.get$jsname(), named); |
14081 } | 13558 } |
14082 World.prototype._addType = function(type) { | 13559 World.prototype._addType = function(type) { |
14083 if (!type.get$isTop()) this._addTopName(type); | 13560 if (!type.get$isTop()) this._addTopName(type); |
14084 } | 13561 } |
14085 World.prototype.toJsIdentifier = function(name) { | 13562 World.prototype.toJsIdentifier = function(name) { |
14086 if (name == null) return null; | 13563 if (name == null) return null; |
14087 if (this._jsKeywords == null) { | 13564 if (this._jsKeywords == null) { |
14088 this._jsKeywords = HashSetImplementation.HashSetImplementation$from$factory(
["break", "case", "catch", "continue", "debugger", "default", "delete", "do", "e
lse", "finally", "for", "function", "if", "in", "instanceof", "new", "return", "
switch", "this", "throw", "try", "typeof", "var", "void", "while", "with", "clas
s", "enum", "export", "extends", "import", "super", "implements", "interface", "
let", "package", "private", "protected", "public", "static", "yield", "native"])
; | 13565 this._jsKeywords = HashSetImplementation.HashSetImplementation$from$factory(
["break", "case", "catch", "continue", "debugger", "default", "delete", "do", "e
lse", "finally", "for", "function", "if", "in", "instanceof", "new", "return", "
switch", "this", "throw", "try", "typeof", "var", "void", "while", "with", "clas
s", "enum", "export", "extends", "import", "super", "implements", "interface", "
let", "package", "private", "protected", "public", "static", "yield", "native"])
; |
14089 } | 13566 } |
14090 if (this._jsKeywords.contains(name)) { | 13567 if (this._jsKeywords.contains(name)) { |
14091 return name + "_"; | 13568 return $add(name, "_"); |
14092 } | 13569 } |
14093 else { | 13570 else { |
14094 return name.replaceAll("$", "$$").replaceAll(":", "$"); | 13571 return name.replaceAll("$", "$$").replaceAll(":", "$"); |
14095 } | 13572 } |
14096 } | 13573 } |
14097 World.prototype.compileAndSave = function() { | 13574 World.prototype.compileAndSave = function() { |
14098 var success = this.compile(); | 13575 var success = this.compile(); |
14099 if ($globals.options.outfile != null) { | 13576 if ($globals.options.outfile != null) { |
14100 if (success) { | 13577 if (success) { |
14101 var code = $globals.world.getGeneratedCode(); | 13578 var code = $globals.world.getGeneratedCode(); |
14102 if (!$globals.options.outfile.endsWith(".js")) { | 13579 if (!$globals.options.outfile.endsWith(".js")) { |
14103 code = "#!/usr/bin/env node\n" + code; | 13580 code = $add("#!/usr/bin/env node\n", code); |
14104 } | 13581 } |
14105 $globals.world.files.writeString($globals.options.outfile, code); | 13582 $globals.world.files.writeString($globals.options.outfile, code); |
14106 } | 13583 } |
14107 else { | 13584 else { |
14108 $globals.world.files.writeString($globals.options.outfile, "throw 'Sorry,
but I could not generate reasonable code to run.\\n';"); | 13585 $globals.world.files.writeString($globals.options.outfile, "throw 'Sorry,
but I could not generate reasonable code to run.\\n';"); |
14109 } | 13586 } |
14110 } | 13587 } |
14111 return success; | 13588 return success; |
14112 } | 13589 } |
14113 World.prototype.compile = function() { | 13590 World.prototype.compile = function() { |
(...skipping 15 matching lines...) Expand all Loading... |
14129 this.printStatus(); | 13606 this.printStatus(); |
14130 return !this.get$hasErrors(); | 13607 return !this.get$hasErrors(); |
14131 } | 13608 } |
14132 World.prototype.runLeg = function() { | 13609 World.prototype.runLeg = function() { |
14133 var $this = this; // closure support | 13610 var $this = this; // closure support |
14134 if (!$globals.options.enableLeg) return false; | 13611 if (!$globals.options.enableLeg) return false; |
14135 if ($globals.legCompile == null) { | 13612 if ($globals.legCompile == null) { |
14136 this.fatal("requested leg enabled, but no leg compiler available"); | 13613 this.fatal("requested leg enabled, but no leg compiler available"); |
14137 } | 13614 } |
14138 var res = this.withTiming("try leg compile", (function () { | 13615 var res = this.withTiming("try leg compile", (function () { |
14139 return $globals.legCompile.call$1($this); | 13616 return $globals.legCompile($this); |
14140 }) | 13617 }) |
14141 ); | 13618 ); |
14142 if (!res && $globals.options.legOnly) { | 13619 if (!res && $globals.options.legOnly) { |
14143 this.fatal(("Leg could not compile " + $globals.options.dartScript)); | 13620 this.fatal(("Leg could not compile " + $globals.options.dartScript)); |
14144 return true; | 13621 return true; |
14145 } | 13622 } |
14146 return res; | 13623 return res; |
14147 } | 13624 } |
14148 World.prototype.runCompilationPhases = function() { | 13625 World.prototype.runCompilationPhases = function() { |
14149 var $this = this; // closure support | 13626 var $this = this; // closure support |
14150 var lib = this.withTiming("first pass", (function () { | 13627 var lib = this.withTiming("first pass", (function () { |
14151 return $this.processDartScript(); | 13628 return $this.processDartScript(); |
14152 }) | 13629 }) |
14153 ); | 13630 ); |
14154 this.withTiming("resolve top level", this.get$resolveAll()); | 13631 this.withTiming("resolve top level", this.get$resolveAll()); |
14155 if ($globals.experimentalAwaitPhase != null) { | 13632 if ($globals.experimentalAwaitPhase != null) { |
14156 this.withTiming("await translation", to$call$0($globals.experimentalAwaitPha
se)); | 13633 this.withTiming("await translation", to$call$0($globals.experimentalAwaitPha
se)); |
14157 } | 13634 } |
| 13635 this.withTiming("analyze pass", (function () { |
| 13636 $this.analyzeCode(lib); |
| 13637 }) |
| 13638 ); |
14158 this.withTiming("generate code", (function () { | 13639 this.withTiming("generate code", (function () { |
14159 $this.generateCode(lib); | 13640 $this.generateCode(lib); |
14160 }) | 13641 }) |
14161 ); | 13642 ); |
14162 } | 13643 } |
14163 World.prototype.getGeneratedCode = function() { | 13644 World.prototype.getGeneratedCode = function() { |
14164 if (this.legCode != null) { | 13645 if (this.legCode != null) { |
14165 return this.legCode; | 13646 return this.legCode; |
14166 } | 13647 } |
14167 else { | 13648 else { |
14168 return this.frogCode; | 13649 return this.frogCode; |
14169 } | 13650 } |
14170 } | 13651 } |
14171 World.prototype.readFile = function(filename) { | 13652 World.prototype.readFile = function(filename) { |
14172 try { | 13653 try { |
14173 var sourceFile = this.reader.readFile(filename); | 13654 var sourceFile = this.reader.readFile(filename); |
14174 this.dartBytesRead = this.dartBytesRead + sourceFile.get$text().get$length()
; | 13655 this.dartBytesRead = this.dartBytesRead + sourceFile.get$text().length; |
14175 return sourceFile; | 13656 return sourceFile; |
14176 } catch (e) { | 13657 } catch (e) { |
14177 e = _toDartException(e); | 13658 e = _toDartException(e); |
14178 this.warning(("Error reading file: " + filename)); | 13659 this.warning(("Error reading file: " + filename)); |
14179 return new SourceFile(filename, ""); | 13660 return new SourceFile(filename, ""); |
14180 } | 13661 } |
14181 } | 13662 } |
14182 World.prototype.getOrAddLibrary = function(filename) { | 13663 World.prototype.getOrAddLibrary = function(filename) { |
14183 var library = this.libraries.$index(filename); | 13664 var library = this.libraries.$index(filename); |
14184 if (library == null) { | 13665 if (library == null) { |
(...skipping 10 matching lines...) Expand all Loading... |
14195 if (filename == "dart:dom") { | 13676 if (filename == "dart:dom") { |
14196 this.dom = library; | 13677 this.dom = library; |
14197 } | 13678 } |
14198 } | 13679 } |
14199 return library; | 13680 return library; |
14200 } | 13681 } |
14201 World.prototype.process = function() { | 13682 World.prototype.process = function() { |
14202 while (this._todo.get$length() > (0)) { | 13683 while (this._todo.get$length() > (0)) { |
14203 var todo = this._todo; | 13684 var todo = this._todo; |
14204 this._todo = []; | 13685 this._todo = []; |
14205 for (var $$i = todo.iterator$0(); $$i.hasNext$0(); ) { | 13686 for (var $$i = todo.iterator(); $$i.hasNext(); ) { |
14206 var lib = $$i.next$0(); | 13687 var lib = $$i.next(); |
14207 lib.visitSources$0(); | 13688 lib.visitSources(); |
14208 } | 13689 } |
14209 } | 13690 } |
14210 } | 13691 } |
14211 World.prototype.processDartScript = function(script) { | 13692 World.prototype.processDartScript = function(script) { |
14212 if (script == null) script = $globals.options.dartScript; | 13693 if (script == null) script = $globals.options.dartScript; |
14213 var library = this.getOrAddLibrary(script); | 13694 var library = this.getOrAddLibrary(script); |
14214 this.process(); | 13695 this.process(); |
14215 return library; | 13696 return library; |
14216 } | 13697 } |
14217 World.prototype.resolveAll = function() { | 13698 World.prototype.resolveAll = function() { |
14218 var $$list = this.libraries.getValues(); | 13699 var $$list = this.libraries.getValues(); |
14219 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 13700 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
14220 var lib = $$i.next$0(); | 13701 var lib = $$i.next(); |
14221 lib.resolve$0(); | 13702 lib.resolve(); |
14222 } | 13703 } |
14223 var $$list = this.libraries.getValues(); | 13704 var $$list = this.libraries.getValues(); |
14224 for (var $$i = $$list.iterator$0(); $$i.hasNext$0(); ) { | 13705 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
14225 var lib = $$i.next$0(); | 13706 var lib = $$i.next(); |
14226 lib.postResolveChecks$0(); | 13707 lib.postResolveChecks(); |
14227 } | 13708 } |
14228 } | 13709 } |
14229 World.prototype.get$resolveAll = function() { | 13710 World.prototype.get$resolveAll = function() { |
14230 return this.resolveAll.bind(this); | 13711 return this.resolveAll.bind(this); |
14231 } | 13712 } |
14232 World.prototype.findMainMethod = function(lib) { | 13713 World.prototype.findMainMethod = function(lib) { |
14233 var main = lib.lookup("main", lib.get$span()); | 13714 var main = lib.lookup("main", lib.get$span()); |
14234 if (main == null) { | 13715 if ($eq(main)) { |
14235 this.fatal("no main method specified"); | 13716 this.fatal("no main method specified"); |
14236 } | 13717 } |
14237 return main; | 13718 return main; |
14238 } | 13719 } |
| 13720 World.prototype.analyzeCode = function(lib) { |
| 13721 this.gen = new WorldGenerator(this.findMainMethod(lib), new CodeWriter()); |
| 13722 this.gen.analyze(); |
| 13723 } |
14239 World.prototype.generateCode = function(lib) { | 13724 World.prototype.generateCode = function(lib) { |
14240 this.gen = new WorldGenerator(this.findMainMethod(lib), new CodeWriter()); | |
14241 this.gen.run(); | 13725 this.gen.run(); |
14242 this.frogCode = this.gen.writer.get$text(); | 13726 this.frogCode = this.gen.writer.get$text(); |
14243 this.jsBytesWritten = this.frogCode.length; | 13727 this.jsBytesWritten = this.frogCode.length; |
14244 this.gen = null; | 13728 this.gen = null; |
14245 } | 13729 } |
14246 World.prototype._message = function(color, prefix, message, span, span1, span2,
throwing) { | 13730 World.prototype._message = function(color, prefix, message, span, span1, span2,
throwing) { |
14247 if (this.messageHandler != null) { | 13731 if (this.messageHandler != null) { |
14248 this.messageHandler(prefix, message, span); | 13732 this.messageHandler(prefix, message, span); |
14249 if (span1 != null) { | 13733 if (span1 != null) { |
14250 this.messageHandler(prefix, message, span1); | 13734 this.messageHandler(prefix, message, span1); |
14251 } | 13735 } |
14252 if (span2 != null) { | 13736 if (span2 != null) { |
14253 this.messageHandler(prefix, message, span2); | 13737 this.messageHandler(prefix, message, span2); |
14254 } | 13738 } |
14255 } | 13739 } |
14256 else { | 13740 else { |
14257 var messageWithPrefix = $globals.options.useColors ? (color + prefix + $glob
als._NO_COLOR + message) : (prefix + message); | 13741 var messageWithPrefix = $globals.options.useColors ? ($add($add($add(color,
prefix), $globals._NO_COLOR), message)) : ($add(prefix, message)); |
14258 var text = messageWithPrefix; | 13742 var text = messageWithPrefix; |
14259 if (span != null) { | 13743 if (span != null) { |
14260 text = span.toMessageString(messageWithPrefix); | 13744 text = span.toMessageString(messageWithPrefix); |
14261 } | 13745 } |
14262 print(text); | 13746 print(text); |
14263 if (span1 != null) { | 13747 if (span1 != null) { |
14264 print(span1.toMessageString(messageWithPrefix)); | 13748 print(span1.toMessageString(messageWithPrefix)); |
14265 } | 13749 } |
14266 if (span2 != null) { | 13750 if (span2 != null) { |
14267 print(span2.toMessageString(messageWithPrefix)); | 13751 print(span2.toMessageString(messageWithPrefix)); |
14268 } | 13752 } |
14269 } | 13753 } |
14270 if (throwing) { | 13754 if (throwing) { |
14271 $throw(new CompilerException(prefix + message, span)); | 13755 $throw(new CompilerException($add(prefix, message), span)); |
14272 } | 13756 } |
14273 } | 13757 } |
14274 World.prototype.error = function(message, span, span1, span2) { | 13758 World.prototype.error = function(message, span, span1, span2) { |
14275 this.errors++; | 13759 this.errors++; |
14276 this._message($globals._RED_COLOR, "error: ", message, span, span1, span2, $gl
obals.options.throwOnErrors); | 13760 this._message($globals._RED_COLOR, "error: ", message, span, span1, span2, $gl
obals.options.throwOnErrors); |
14277 } | 13761 } |
14278 World.prototype.warning = function(message, span, span1, span2) { | 13762 World.prototype.warning = function(message, span, span1, span2) { |
14279 if ($globals.options.warningsAsErrors) { | 13763 if ($globals.options.warningsAsErrors) { |
14280 this.error(message, span, span1, span2); | 13764 this.error(message, span, span1, span2); |
14281 return; | 13765 return; |
(...skipping 13 matching lines...) Expand all Loading... |
14295 } | 13779 } |
14296 World.prototype.info = function(message, span, span1, span2) { | 13780 World.prototype.info = function(message, span, span1, span2) { |
14297 if ($globals.options.showInfo) { | 13781 if ($globals.options.showInfo) { |
14298 this._message($globals._GREEN_COLOR, "info: ", message, span, span1, span2,
false); | 13782 this._message($globals._GREEN_COLOR, "info: ", message, span, span1, span2,
false); |
14299 } | 13783 } |
14300 } | 13784 } |
14301 World.prototype.withoutForceDynamic = function(fn) { | 13785 World.prototype.withoutForceDynamic = function(fn) { |
14302 var oldForceDynamic = $globals.options.forceDynamic; | 13786 var oldForceDynamic = $globals.options.forceDynamic; |
14303 $globals.options.forceDynamic = false; | 13787 $globals.options.forceDynamic = false; |
14304 try { | 13788 try { |
14305 return fn.call$0(); | 13789 return fn(); |
14306 } finally { | 13790 } finally { |
14307 $globals.options.forceDynamic = oldForceDynamic; | 13791 $globals.options.forceDynamic = oldForceDynamic; |
14308 } | 13792 } |
14309 } | 13793 } |
14310 World.prototype.get$hasErrors = function() { | 13794 World.prototype.get$hasErrors = function() { |
14311 return this.errors > (0); | 13795 return this.errors > (0); |
14312 } | 13796 } |
14313 World.prototype.printStatus = function() { | 13797 World.prototype.printStatus = function() { |
14314 this.counters.info(); | 13798 this.counters.info(); |
14315 this.info(("compiled " + this.dartBytesRead + " bytes Dart -> " + this.jsBytes
Written + " bytes JS")); | 13799 this.info(("compiled " + this.dartBytesRead + " bytes Dart -> " + this.jsBytes
Written + " bytes JS")); |
14316 if (this.get$hasErrors()) { | 13800 if (this.get$hasErrors()) { |
14317 print(("compilation failed with " + this.errors + " errors")); | 13801 print(("compilation failed with " + this.errors + " errors")); |
14318 } | 13802 } |
14319 else { | 13803 else { |
14320 if (this.warnings > (0)) { | 13804 if (this.warnings > (0)) { |
14321 this.info(("compilation completed successfully with " + this.warnings + "
warnings")); | 13805 this.info(("compilation completed successfully with " + this.warnings + "
warnings")); |
14322 } | 13806 } |
14323 else { | 13807 else { |
14324 this.info("compilation completed sucessfully"); | 13808 this.info("compilation completed sucessfully"); |
14325 } | 13809 } |
14326 } | 13810 } |
14327 } | 13811 } |
14328 World.prototype.withTiming = function(name, f) { | 13812 World.prototype.withTiming = function(name, f) { |
14329 var sw = new StopwatchImplementation(); | 13813 var sw = new StopwatchImplementation(); |
14330 sw.start$0(); | 13814 sw.start(); |
14331 var result = f.call$0(); | 13815 var result = f(); |
14332 sw.stop$0(); | 13816 sw.stop(); |
14333 this.info(("" + name + " in " + sw.elapsedInMs$0() + "msec")); | 13817 this.info(("" + name + " in " + sw.elapsedInMs() + "msec")); |
14334 return result; | 13818 return result; |
14335 } | 13819 } |
14336 // ********** Code for FrogOptions ************** | 13820 // ********** Code for FrogOptions ************** |
14337 function FrogOptions(homedir, args, files) { | 13821 function FrogOptions(homedir, args, files) { |
14338 this.legOnly = false; | 13822 this.legOnly = false; |
14339 this.throwOnFatal = false; | 13823 this.throwOnFatal = false; |
14340 this.maxInferenceIterations = (4); | 13824 this.maxInferenceIterations = (4); |
14341 this.config = "dev"; | 13825 this.config = "dev"; |
14342 this.throwOnWarnings = false; | 13826 this.throwOnWarnings = false; |
14343 this.inferTypes = false; | 13827 this.inferTypes = false; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14454 this.useColors = false; | 13938 this.useColors = false; |
14455 break; | 13939 break; |
14456 | 13940 |
14457 case "--Xinfer_types": | 13941 case "--Xinfer_types": |
14458 | 13942 |
14459 this.inferTypes = true; | 13943 this.inferTypes = true; |
14460 break; | 13944 break; |
14461 | 13945 |
14462 default: | 13946 default: |
14463 | 13947 |
14464 if (arg.endsWith$1(".dart")) { | 13948 if (arg.endsWith(".dart")) { |
14465 this.dartScript = arg; | 13949 this.dartScript = arg; |
14466 this.childArgs = args.getRange(i + (1), args.get$length() - i - (1)); | 13950 this.childArgs = args.getRange(i + (1), args.get$length() - i - (1)); |
14467 break loop; | 13951 break loop; |
14468 } | 13952 } |
14469 else if (arg.startsWith$1("--out=")) { | 13953 else if (arg.startsWith("--out=")) { |
14470 this.outfile = arg.substring$1("--out=".length); | 13954 this.outfile = arg.substring$1("--out=".length); |
14471 } | 13955 } |
14472 else if (arg.startsWith$1("--libdir=")) { | 13956 else if (arg.startsWith("--libdir=")) { |
14473 this.libDir = arg.substring$1("--libdir=".length); | 13957 this.libDir = arg.substring$1("--libdir=".length); |
14474 passedLibDir = true; | 13958 passedLibDir = true; |
14475 } | 13959 } |
14476 else { | 13960 else { |
14477 if (!ignoreUnrecognizedFlags) { | 13961 if (!ignoreUnrecognizedFlags) { |
14478 print(("unrecognized flag: \"" + arg + "\"")); | 13962 print(("unrecognized flag: \"" + arg + "\"")); |
14479 } | 13963 } |
14480 } | 13964 } |
14481 | 13965 |
14482 } | 13966 } |
(...skipping 15 matching lines...) Expand all Loading... |
14498 } | 13982 } |
14499 else if ($eq($globals.options.config, "sdk")) { | 13983 else if ($eq($globals.options.config, "sdk")) { |
14500 this._specialLibs = _map(["dart:core", joinPaths($globals.options.libDir, "c
ore/core_frog.dart"), "dart:coreimpl", joinPaths($globals.options.libDir, "corei
mpl/coreimpl_frog.dart"), "dart:html", joinPaths($globals.options.libDir, "html/
html.dart"), "dart:htmlimpl", joinPaths($globals.options.libDir, "htmlimpl/htmli
mpl.dart"), "dart:dom", joinPaths($globals.options.libDir, "dom/frog/dom_frog.da
rt"), "dart:json", joinPaths($globals.options.libDir, "json/json_frog.dart")]); | 13984 this._specialLibs = _map(["dart:core", joinPaths($globals.options.libDir, "c
ore/core_frog.dart"), "dart:coreimpl", joinPaths($globals.options.libDir, "corei
mpl/coreimpl_frog.dart"), "dart:html", joinPaths($globals.options.libDir, "html/
html.dart"), "dart:htmlimpl", joinPaths($globals.options.libDir, "htmlimpl/htmli
mpl.dart"), "dart:dom", joinPaths($globals.options.libDir, "dom/frog/dom_frog.da
rt"), "dart:json", joinPaths($globals.options.libDir, "json/json_frog.dart")]); |
14501 } | 13985 } |
14502 else { | 13986 else { |
14503 $globals.world.error(("Invalid configuration " + $globals.options.config)); | 13987 $globals.world.error(("Invalid configuration " + $globals.options.config)); |
14504 } | 13988 } |
14505 } | 13989 } |
14506 LibraryReader.prototype.readFile = function(fullname) { | 13990 LibraryReader.prototype.readFile = function(fullname) { |
14507 var filename = this._specialLibs.$index(fullname); | 13991 var filename = this._specialLibs.$index(fullname); |
14508 if (filename == null) { | 13992 if ($eq(filename)) { |
14509 filename = fullname; | 13993 filename = fullname; |
14510 } | 13994 } |
14511 if ($globals.world.files.fileExists(filename)) { | 13995 if ($globals.world.files.fileExists(filename)) { |
14512 return new SourceFile(filename, $globals.world.files.readAll(filename)); | 13996 return new SourceFile(filename, $globals.world.files.readAll(filename)); |
14513 } | 13997 } |
14514 else { | 13998 else { |
14515 $globals.world.error(("File not found: " + filename)); | 13999 $globals.world.error(("File not found: " + filename)); |
14516 return new SourceFile(filename, ""); | 14000 return new SourceFile(filename, ""); |
14517 } | 14001 } |
14518 } | 14002 } |
14519 // ********** Code for VarMember ************** | 14003 // ********** Code for VarMember ************** |
14520 function VarMember(name) { | 14004 function VarMember(name) { |
14521 this.isGenerated = false; | 14005 this.isGenerated = false; |
14522 this.name = name; | 14006 this.name = name; |
14523 } | 14007 } |
14524 VarMember.prototype.get$name = function() { return this.name; }; | 14008 VarMember.prototype.get$name = function() { return this.name; }; |
14525 VarMember.prototype.get$isGenerated = function() { return this.isGenerated; }; | 14009 VarMember.prototype.get$isGenerated = function() { return this.isGenerated; }; |
14526 VarMember.prototype.set$isGenerated = function(value) { return this.isGenerated
= value; }; | 14010 VarMember.prototype.set$isGenerated = function(value) { return this.isGenerated
= value; }; |
| 14011 VarMember.prototype.get$body = function() { |
| 14012 return null; |
| 14013 } |
14527 VarMember.prototype.get$returnType = function() { | 14014 VarMember.prototype.get$returnType = function() { |
14528 return $globals.world.varType; | 14015 return $globals.world.varType; |
14529 } | 14016 } |
14530 VarMember.prototype.invoke = function(context, node, target, args) { | 14017 VarMember.prototype.invoke = function(context, node, target, args) { |
14531 return new Value(this.get$returnType(), ("" + target.get$code() + "." + this.n
ame + "(" + args.getCode() + ")"), node.span); | 14018 return new Value(this.get$returnType(), ("" + target.get$code() + "." + this.n
ame + "(" + args.getCode() + ")"), node.span); |
14532 } | 14019 } |
14533 VarMember.prototype.generate$1 = VarMember.prototype.generate; | |
14534 VarMember.prototype.invoke$4 = VarMember.prototype.invoke; | |
14535 // ********** Code for VarFunctionStub ************** | 14020 // ********** Code for VarFunctionStub ************** |
14536 $inherits(VarFunctionStub, VarMember); | 14021 $inherits(VarFunctionStub, VarMember); |
14537 function VarFunctionStub(name, callArgs) { | 14022 function VarFunctionStub(name, callArgs) { |
14538 this.args = callArgs.toCallStubArgs(); | 14023 this.args = callArgs.toCallStubArgs(); |
14539 VarMember.call(this, name); | 14024 VarMember.call(this, name); |
14540 $globals.world.functionImplType.markUsed(); | 14025 $globals.world.functionImplType.markUsed(); |
14541 $globals.world.gen.genMethod($globals.world.functionImplType.getMember("_genSt
ub")); | 14026 $globals.world.gen.genMethod($globals.world.functionImplType.getMember("_genSt
ub")); |
14542 } | 14027 } |
14543 VarFunctionStub.prototype.invoke = function(context, node, target, args) { | 14028 VarFunctionStub.prototype.invoke = function(context, node, target, args) { |
14544 return VarMember.prototype.invoke.call(this, context, node, target, args); | 14029 return VarMember.prototype.invoke.call(this, context, node, target, args); |
(...skipping 21 matching lines...) Expand all Loading... |
14566 w.writeln(("function to$" + this.name + "(f) { return f && f.to$" + this.name
+ "(); }")); | 14051 w.writeln(("function to$" + this.name + "(f) { return f && f.to$" + this.name
+ "(); }")); |
14567 } | 14052 } |
14568 VarFunctionStub.prototype.generateNamed = function(w) { | 14053 VarFunctionStub.prototype.generateNamed = function(w) { |
14569 var named = Strings.join(this.args.getNames(), "\", \""); | 14054 var named = Strings.join(this.args.getNames(), "\", \""); |
14570 var argsCode = this.args.getCode(); | 14055 var argsCode = this.args.getCode(); |
14571 w.enterBlock(("Function.prototype." + this.name + " = function(" + argsCode +
") {")); | 14056 w.enterBlock(("Function.prototype." + this.name + " = function(" + argsCode +
") {")); |
14572 w.writeln(("this." + this.name + " = this._genStub(" + this.args.get$length()
+ ", [\"" + named + "\"]);")); | 14057 w.writeln(("this." + this.name + " = this._genStub(" + this.args.get$length()
+ ", [\"" + named + "\"]);")); |
14573 w.writeln(("return this." + this.name + "(" + argsCode + ");")); | 14058 w.writeln(("return this." + this.name + "(" + argsCode + ");")); |
14574 w.exitBlock("}"); | 14059 w.exitBlock("}"); |
14575 } | 14060 } |
14576 VarFunctionStub.prototype.generate$1 = VarFunctionStub.prototype.generate; | |
14577 VarFunctionStub.prototype.invoke$4 = VarFunctionStub.prototype.invoke; | |
14578 // ********** Code for VarMethodStub ************** | 14061 // ********** Code for VarMethodStub ************** |
14579 $inherits(VarMethodStub, VarMember); | 14062 $inherits(VarMethodStub, VarMember); |
14580 function VarMethodStub(name, member, args, body) { | 14063 function VarMethodStub(name, member, args, body) { |
14581 this.body = body; | 14064 this.body = body; |
14582 this.member = member; | 14065 this.member = member; |
14583 this.args = args; | 14066 this.args = args; |
14584 VarMember.call(this, name); | 14067 VarMember.call(this, name); |
14585 } | 14068 } |
14586 VarMethodStub.prototype.get$body = function() { return this.body; }; | 14069 VarMethodStub.prototype.get$body = function() { return this.body; }; |
14587 VarMethodStub.prototype.get$isHidden = function() { | 14070 VarMethodStub.prototype.get$isHidden = function() { |
14588 return this.member != null ? this.member.declaringType.get$isHiddenNativeType(
) : false; | 14071 return this.member != null ? this.member.declaringType.get$isHiddenNativeType(
) : false; |
14589 } | 14072 } |
14590 VarMethodStub.prototype.get$returnType = function() { | 14073 VarMethodStub.prototype.get$returnType = function() { |
14591 return this.member != null ? this.member.get$returnType() : $globals.world.var
Type; | 14074 return this.member != null ? this.member.get$returnType() : $globals.world.var
Type; |
14592 } | 14075 } |
14593 VarMethodStub.prototype.get$declaringType = function() { | 14076 VarMethodStub.prototype.get$declaringType = function() { |
14594 return this.member != null ? this.member.declaringType : $globals.world.object
Type; | 14077 return this.member != null ? this.member.declaringType : $globals.world.object
Type; |
14595 } | 14078 } |
14596 VarMethodStub.prototype.generate = function(code) { | 14079 VarMethodStub.prototype.generate = function(code) { |
14597 this.isGenerated = true; | 14080 this.isGenerated = true; |
14598 if (!this.get$isHidden() && this._useDirectCall(this.args)) { | 14081 if (!this.get$isHidden() && this._useDirectCall(this.args)) { |
14599 $globals.world.gen._writePrototypePatch(this.get$declaringType(), this.name,
$globals.world.gen._prototypeOf(this.get$declaringType(), this.member.get$jsnam
e()), code, true); | 14082 $globals.world.gen._writePrototypePatch(this.get$declaringType(), this.name,
$globals.world.gen._prototypeOf(this.get$declaringType(), this.member.get$jsnam
e()), code, true); |
14600 } | 14083 } |
14601 else { | 14084 else { |
14602 var suffix = $globals.world.gen._writePrototypePatch(this.get$declaringType(
), this.name, ("function(" + this.args.getCode() + ") {"), code, false); | 14085 var suffix = $globals.world.gen._writePrototypePatch(this.get$declaringType(
), this.name, ("function(" + this.args.getCode() + ") {"), code, false); |
14603 if (!suffix.endsWith(";")) { | 14086 if (!suffix.endsWith(";")) { |
14604 suffix = suffix + ";"; | 14087 suffix = $add(suffix, ";"); |
14605 } | 14088 } |
14606 if (this._needsExactTypeCheck()) { | 14089 if (this._needsExactTypeCheck()) { |
14607 code.enterBlock(("if (Object.getPrototypeOf(this).hasOwnProperty(\"" + thi
s.name + "\")) {")); | 14090 code.enterBlock(("if (Object.getPrototypeOf(this).hasOwnProperty(\"" + thi
s.name + "\")) {")); |
14608 code.writeln(("" + this.body + ";")); | 14091 code.writeln(("" + this.body + ";")); |
14609 code.exitBlock("}"); | 14092 code.exitBlock("}"); |
14610 var argsCode = this.args.getCode(); | 14093 var argsCode = this.args.getCode(); |
14611 if (argsCode != "") argsCode = ", " + argsCode; | 14094 if (argsCode != "") argsCode = $add(", ", argsCode); |
14612 code.writeln(("return Object.prototype." + this.name + ".call(this" + args
Code + ");")); | 14095 code.writeln(("return Object.prototype." + this.name + ".call(this" + args
Code + ");")); |
14613 code.exitBlock(suffix); | 14096 code.exitBlock(suffix); |
14614 } | 14097 } |
14615 else { | 14098 else { |
14616 code.writeln(("" + this.body + ";")); | 14099 code.writeln(("" + this.body + ";")); |
14617 code.exitBlock(suffix); | 14100 code.exitBlock(suffix); |
14618 } | 14101 } |
14619 } | 14102 } |
14620 } | 14103 } |
14621 VarMethodStub.prototype._needsExactTypeCheck = function() { | 14104 VarMethodStub.prototype._needsExactTypeCheck = function() { |
14622 var $this = this; // closure support | 14105 var $this = this; // closure support |
14623 if (this.member == null || this.member.declaringType.get$isObject()) return fa
lse; | 14106 if (this.member == null || this.member.declaringType.get$isObject()) return fa
lse; |
14624 var members = this.member.get$potentialMemberSet().members; | 14107 var members = this.member.get$potentialMemberSet().members; |
14625 return members.filter$1((function (m) { | 14108 return members.filter((function (m) { |
14626 return $ne(m, $this.member) && m.get$declaringType().get$isHiddenNativeType(
); | 14109 return $ne(m, $this.member) && m.get$declaringType().get$isHiddenNativeType(
); |
14627 }) | 14110 }) |
14628 ).get$length() >= (1); | 14111 ).get$length() >= (1); |
14629 } | 14112 } |
14630 VarMethodStub.prototype._useDirectCall = function(args) { | 14113 VarMethodStub.prototype._useDirectCall = function(args) { |
14631 if ((this.member instanceof MethodMember) && !this.member.declaringType.get$ha
sNativeSubtypes()) { | 14114 if ((this.member instanceof MethodMember) && !this.member.declaringType.get$ha
sNativeSubtypes()) { |
14632 var method = this.member; | 14115 var method = this.member; |
14633 if (method.needsArgumentConversion(args)) { | 14116 if (method.needsArgumentConversion(args)) { |
14634 return false; | 14117 return false; |
14635 } | 14118 } |
14636 for (var i = args.get$length(); | 14119 for (var i = args.get$length(); |
14637 i < method.parameters.get$length(); i++) { | 14120 i < method.parameters.get$length(); i++) { |
14638 if ($ne(method.parameters[i].get$value().get$code(), "null")) { | 14121 if (method.parameters[i].value.get$code() != "null") { |
14639 return false; | 14122 return false; |
14640 } | 14123 } |
14641 } | 14124 } |
14642 return method.namesInHomePositions(args); | 14125 return method.namesInHomePositions(args); |
14643 } | 14126 } |
14644 else { | 14127 else { |
14645 return false; | 14128 return false; |
14646 } | 14129 } |
14647 } | 14130 } |
14648 VarMethodStub.prototype.generate$1 = VarMethodStub.prototype.generate; | |
14649 // ********** Code for VarMethodSet ************** | 14131 // ********** Code for VarMethodSet ************** |
14650 $inherits(VarMethodSet, VarMember); | 14132 $inherits(VarMethodSet, VarMember); |
14651 function VarMethodSet(baseName, name, members, callArgs, returnType) { | 14133 function VarMethodSet(baseName, name, members, callArgs, returnType) { |
14652 this.args = callArgs.toCallStubArgs(); | 14134 this.args = callArgs.toCallStubArgs(); |
14653 this.invoked = false; | 14135 this.invoked = false; |
14654 this.baseName = baseName; | 14136 this.baseName = baseName; |
14655 this.members = members; | 14137 this.members = members; |
14656 this.returnType = returnType; | 14138 this.returnType = returnType; |
14657 VarMember.call(this, name); | 14139 VarMember.call(this, name); |
14658 } | 14140 } |
14659 VarMethodSet.prototype.get$members = function() { return this.members; }; | 14141 VarMethodSet.prototype.get$members = function() { return this.members; }; |
14660 VarMethodSet.prototype.get$returnType = function() { return this.returnType; }; | 14142 VarMethodSet.prototype.get$returnType = function() { return this.returnType; }; |
14661 VarMethodSet.prototype.invoke = function(context, node, target, args) { | 14143 VarMethodSet.prototype.invoke = function(context, node, target, args) { |
14662 this._invokeMembers(context, node); | 14144 this._invokeMembers(context, node); |
14663 return VarMember.prototype.invoke.call(this, context, node, target, args); | 14145 return VarMember.prototype.invoke.call(this, context, node, target, args); |
14664 } | 14146 } |
14665 VarMethodSet.prototype._invokeMembers = function(context, node) { | 14147 VarMethodSet.prototype._invokeMembers = function(context, node) { |
14666 if (this.invoked) return; | 14148 if (this.invoked) return; |
14667 this.invoked = true; | 14149 this.invoked = true; |
14668 var hasObjectType = false; | 14150 var hasObjectType = false; |
14669 var $$list = this.members; | 14151 var $$list = this.members; |
14670 for (var $$i = 0;$$i < $$list.get$length(); $$i++) { | 14152 for (var $$i = $$list.iterator(); $$i.hasNext(); ) { |
14671 var member = $$list[$$i]; | 14153 var member = $$i.next(); |
14672 var type = member.get$declaringType(); | 14154 var type = member.get$declaringType(); |
14673 var target = new Value(type, "this", node.span); | 14155 var target = new Value(type, "this", node.span); |
14674 var result = member.invoke$4$isDynamic(context, node, target, this.args, tru
e); | 14156 var result = member.invoke(context, node, target, this.args); |
14675 var stub = new VarMethodStub(this.name, member, this.args, "return " + resul
t.get$code()); | 14157 var stub = new VarMethodStub(this.name, member, this.args, $add("return ", r
esult.get$code())); |
14676 type.get$varStubs().$setindex(stub.get$name(), stub); | 14158 type.get$varStubs().$setindex(stub.get$name(), stub); |
14677 if (type.get$isObject()) hasObjectType = true; | 14159 if (type.get$isObject()) hasObjectType = true; |
14678 } | 14160 } |
14679 if (!hasObjectType) { | 14161 if (!hasObjectType) { |
14680 var target = new Value($globals.world.objectType, "this", node.span); | 14162 var target = new Value($globals.world.objectType, "this", node.span); |
14681 var result = target.invokeNoSuchMethod$4(context, this.baseName, node, this.
args); | 14163 var result = target.invokeNoSuchMethod(context, this.baseName, node, this.ar
gs); |
14682 var stub = new VarMethodStub(this.name, null, this.args, "return " + result.
get$code()); | 14164 var stub = new VarMethodStub(this.name, null, this.args, $add("return ", res
ult.get$code())); |
14683 $globals.world.objectType.varStubs.$setindex(stub.get$name(), stub); | 14165 $globals.world.objectType.varStubs.$setindex(stub.get$name(), stub); |
14684 } | 14166 } |
14685 } | 14167 } |
14686 VarMethodSet.prototype.generate = function(code) { | 14168 VarMethodSet.prototype.generate = function(code) { |
14687 | 14169 |
14688 } | 14170 } |
14689 VarMethodSet.prototype.generate$1 = VarMethodSet.prototype.generate; | |
14690 VarMethodSet.prototype.invoke$4 = VarMethodSet.prototype.invoke; | |
14691 // ********** Code for top level ************** | 14171 // ********** Code for top level ************** |
14692 function _otherOperator(jsname, op) { | 14172 function _otherOperator(jsname, op) { |
14693 return ("function " + jsname + "(x, y) {\n return (typeof(x) == 'number' && t
ypeof(y) == 'number')\n ? x " + op + " y : x." + jsname + "(y);\n}"); | 14173 return ("function " + jsname + "(x, y) {\n return (typeof(x) == 'number' && t
ypeof(y) == 'number')\n ? x " + op + " y : x." + jsname + "(y);\n}"); |
14694 } | 14174 } |
14695 function map(source, mapper) { | 14175 function map(source, mapper) { |
14696 var result = new Array(); | 14176 var result = new Array(); |
14697 if (!!(source && source.is$List())) { | 14177 if (!!(source && source.is$List())) { |
14698 var list = source; | 14178 var list = source; |
14699 result.set$length(list.get$length()); | 14179 result.set$length(list.get$length()); |
14700 for (var i = (0); | 14180 for (var i = (0); |
14701 i < list.get$length(); i++) { | 14181 i < list.get$length(); i++) { |
14702 result.$setindex(i, mapper.call$1(list[i])); | 14182 result.$setindex(i, mapper(list.$index(i))); |
14703 } | 14183 } |
14704 } | 14184 } |
14705 else { | 14185 else { |
14706 for (var $$i = source.iterator$0(); $$i.hasNext$0(); ) { | 14186 for (var $$i = source.iterator(); $$i.hasNext(); ) { |
14707 var item = $$i.next$0(); | 14187 var item = $$i.next(); |
14708 result.add(mapper.call$1(item)); | 14188 result.add(mapper(item)); |
14709 } | 14189 } |
14710 } | 14190 } |
14711 return result; | 14191 return result; |
14712 } | 14192 } |
14713 function reduce(source, callback, initialValue) { | 14193 function reduce(source, callback, initialValue) { |
14714 var i = source.iterator$0(); | 14194 var i = source.iterator(); |
14715 var current = initialValue; | 14195 var current = initialValue; |
14716 if (current == null && i.hasNext$0()) { | 14196 if ($eq(current) && i.hasNext()) { |
14717 current = i.next$0(); | 14197 current = i.next(); |
14718 } | 14198 } |
14719 while (i.hasNext$0()) { | 14199 while (i.hasNext()) { |
14720 current = callback.call$2(current, i.next$0()); | 14200 current = callback.call$2(current, i.next()); |
14721 } | 14201 } |
14722 return current; | 14202 return current; |
14723 } | 14203 } |
14724 function orderValuesByKeys(map) { | 14204 function orderValuesByKeys(map) { |
14725 var keys = map.getKeys(); | 14205 var keys = map.getKeys(); |
14726 keys.sort((function (x, y) { | 14206 keys.sort((function (x, y) { |
14727 return x.compareTo$1(y); | 14207 return x.compareTo(y); |
14728 }) | 14208 }) |
14729 ); | 14209 ); |
14730 var values = []; | 14210 var values = []; |
14731 for (var $$i = 0;$$i < keys.get$length(); $$i++) { | 14211 for (var $$i = keys.iterator(); $$i.hasNext(); ) { |
14732 var k = keys[$$i]; | 14212 var k = $$i.next(); |
14733 values.add$1(map.$index(k)); | 14213 values.add(map.$index(k)); |
14734 } | 14214 } |
14735 return values; | 14215 return values; |
14736 } | 14216 } |
14737 var world; | 14217 var world; |
14738 var experimentalAwaitPhase; | 14218 var experimentalAwaitPhase; |
14739 var legCompile; | 14219 var legCompile; |
14740 function initializeWorld(files) { | 14220 function initializeWorld(files) { |
14741 $globals.world = new World(files); | 14221 $globals.world = new World(files); |
14742 $globals.world.init(); | 14222 $globals.world.init(); |
14743 } | 14223 } |
14744 function compile(homedir, args, files) { | 14224 function compile(homedir, args, files) { |
14745 parseOptions(homedir, args, files); | 14225 parseOptions(homedir, args, files); |
14746 initializeWorld(files); | 14226 initializeWorld(files); |
14747 return $globals.world.compileAndSave(); | 14227 return $globals.world.compileAndSave(); |
14748 } | 14228 } |
14749 var options; | 14229 var options; |
14750 function parseOptions(homedir, args, files) { | 14230 function parseOptions(homedir, args, files) { |
14751 $globals.options = new FrogOptions(homedir, args, files); | 14231 $globals.options = new FrogOptions(homedir, args, files); |
14752 } | 14232 } |
14753 function _getCallStubName(name, args) { | 14233 function _getCallStubName(name, args) { |
14754 var nameBuilder = new StringBufferImpl(("" + name + "$" + args.get$bareCount()
)); | 14234 var nameBuilder = new StringBufferImpl(("" + name + "$" + args.get$bareCount()
)); |
14755 for (var i = args.get$bareCount(); | 14235 for (var i = args.get$bareCount(); |
14756 i < args.get$length(); i++) { | 14236 i < args.get$length(); i++) { |
14757 var name0 = args.getName(i); | 14237 var argName = args.getName(i); |
14758 nameBuilder.add$1("$"); | 14238 nameBuilder.add("$"); |
14759 if (name0.contains$1("$")) { | 14239 if (argName.contains$1("$")) { |
14760 nameBuilder.add$1(("" + name0.get$length())); | 14240 nameBuilder.add(("" + argName.get$length())); |
14761 } | 14241 } |
14762 nameBuilder.add$1(name0); | 14242 nameBuilder.add(argName); |
14763 } | 14243 } |
14764 return nameBuilder.toString$0(); | 14244 return nameBuilder.toString$0(); |
14765 } | 14245 } |
14766 // ********** Library minfrog ************** | 14246 // ********** Library minfrog ************** |
14767 // ********** Code for top level ************** | 14247 // ********** Code for top level ************** |
14768 function main() { | 14248 function main() { |
14769 var homedir = path.dirname(fs.realpathSync(get$process().get$argv()[(1)])); | 14249 var homedir = path.dirname(fs.realpathSync(get$process().get$argv()[(1)])); |
14770 var argv = []; | 14250 var argv = []; |
14771 for (var i = (0); | 14251 for (var i = (0); |
14772 i < get$process().get$argv().get$length(); i++) { | 14252 i < get$process().get$argv().get$length(); i++) { |
14773 argv.add$1(get$process().get$argv()[i]); | 14253 argv.add(get$process().get$argv()[i]); |
14774 if (i == (1)) { | 14254 if (i == (1)) { |
14775 var terminal = get$process().get$env().$index("TERM"); | 14255 var terminal = get$process().get$env().$index("TERM"); |
14776 if (terminal == null || !terminal.startsWith$1("xterm")) { | 14256 if ($eq(terminal) || !terminal.startsWith("xterm")) { |
14777 argv.add$1("--no_colors"); | 14257 argv.add("--no_colors"); |
14778 } | 14258 } |
14779 } | 14259 } |
14780 } | 14260 } |
14781 if (compile(homedir, argv, new NodeFileSystem())) { | 14261 if (compile(homedir, argv, new NodeFileSystem())) { |
14782 var code = $globals.world.getGeneratedCode(); | 14262 var code = $globals.world.getGeneratedCode(); |
14783 if ($globals.options.compileOnly) { | 14263 if ($globals.options.compileOnly) { |
14784 if ($globals.options.outfile != null) { | 14264 if ($globals.options.outfile != null) { |
14785 print(("Compilation succeded. Code generated in: " + $globals.options.ou
tfile)); | 14265 print(("Compilation succeded. Code generated in: " + $globals.options.ou
tfile)); |
14786 } | 14266 } |
14787 else { | 14267 else { |
14788 print("Compilation succeded."); | 14268 print("Compilation succeded."); |
14789 } | 14269 } |
14790 } | 14270 } |
14791 else { | 14271 else { |
14792 get$process().set$argv([argv.$index((0)), argv.$index((1))]); | 14272 get$process().set$argv([argv.$index((0)), argv.$index((1))]); |
14793 get$process().get$argv().addAll($globals.options.childArgs); | 14273 get$process().get$argv().addAll($globals.options.childArgs); |
14794 vm.runInNewContext(code, createSandbox()); | 14274 vm.runInNewContext(code, createSandbox()); |
14795 } | 14275 } |
14796 } | 14276 } |
14797 else { | 14277 else { |
14798 get$process().exit((1)); | 14278 get$process().exit((1)); |
14799 } | 14279 } |
14800 } | 14280 } |
14801 // ********** Generic Type Inheritance ************** | |
14802 /** Implements extends for generic types. */ | |
14803 function $inheritsMembers(child, parent) { | |
14804 child = child.prototype; | |
14805 parent = parent.prototype; | |
14806 Object.getOwnPropertyNames(parent).forEach(function(name) { | |
14807 if (typeof(child[name]) == 'undefined') child[name] = parent[name]; | |
14808 }); | |
14809 } | |
14810 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_E, DoubleLinkedQueueEntry_E); | |
14811 $inheritsMembers(_DoubleLinkedQueueEntrySentinel_KeyValuePair_K$V, DoubleLinkedQ
ueueEntry_KeyValuePair_K$V); | |
14812 $inheritsMembers(_SharedBackingMap_K$V, HashMapImplementation_K$V); | |
14813 $inheritsMembers(_SharedBackingMap_dart_core_String$VariableValue, HashMapImplem
entation_dart_core_String$VariableValue); | |
14814 // 1 dynamic types. | 14281 // 1 dynamic types. |
14815 // 1 types | 14282 // 1 types |
14816 // 0 !leaf | 14283 // 0 !leaf |
14817 // ********** Globals ************** | 14284 // ********** Globals ************** |
14818 function $static_init(){ | 14285 function $static_init(){ |
14819 $globals._GREEN_COLOR = "\x1b[32m"; | 14286 $globals._GREEN_COLOR = "\x1b[32m"; |
14820 $globals._MAGENTA_COLOR = "\x1b[35m"; | 14287 $globals._MAGENTA_COLOR = "\x1b[35m"; |
14821 $globals._NO_COLOR = "\x1b[0m"; | 14288 $globals._NO_COLOR = "\x1b[0m"; |
14822 $globals._RED_COLOR = "\x1b[31m"; | 14289 $globals._RED_COLOR = "\x1b[31m"; |
14823 } | 14290 } |
14824 var const$0000 = Object.create(EmptyQueueException.prototype, {}); | 14291 var const$0000 = Object.create(_DeletedKeySentinel.prototype, {}); |
14825 var const$0001 = Object.create(_DeletedKeySentinel.prototype, {}); | 14292 var const$0001 = Object.create(NoMoreElementsException.prototype, {}); |
14826 var const$0005 = Object.create(NoMoreElementsException.prototype, {}); | 14293 var const$0002 = Object.create(EmptyQueueException.prototype, {}); |
14827 var const$0007 = Object.create(IllegalAccessException.prototype, {}); | 14294 var const$0006 = Object.create(IllegalAccessException.prototype, {}); |
14828 var const$0008 = ImmutableList.ImmutableList$from$factory([]); | 14295 var const$0007 = ImmutableList.ImmutableList$from$factory([]); |
14829 var $globals = {}; | 14296 var $globals = {}; |
14830 $static_init(); | 14297 $static_init(); |
14831 main(); | 14298 main(); |
OLD | NEW |