Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: compiler/lib/implementation/core.js

Issue 8566022: Function type checking (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Getting to work in optimized Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Helpers for lazy static initialization. 6 * Helpers for lazy static initialization.
7 */ 7 */
8 var static$uninitialized = {}; 8 var static$uninitialized = {};
9 var static$initializing = {}; 9 var static$initializing = {};
10 10
11 // Optimized versions of closure bindings. 11 // Optimized versions of closure bindings.
12 // Name convention: $bind<number-of-scopes>_<number-of-arguments>(fn, this, scop es, args) 12 // Name convention: $bind<number-of-scopes>_<number-of-arguments>(fn, this, scop es, args)
13 function $bind0_0(fn, thisObj) { 13 function $bind0_0(fn, fRtt, thisObj) {
14 return function() { 14 var fun = function() {
15 return fn.call(thisObj); 15 return fn.call(thisObj);
16 } 16 }
17 } 17 if (fRtt) {
18 function $bind0_1(fn, thisObj) { 18 fun.$lookupRTT = function() {
19 return function(arg) { 19 return fRtt.call(thisObj);
20 }
21 }
22 return fun;
23 }
24 function $bind0_1(fn, fRtt, thisObj) {
25 var fun = function(arg) {
20 return fn.call(thisObj, arg); 26 return fn.call(thisObj, arg);
21 } 27 }
22 } 28 if (fRtt) {
23 function $bind0_2(fn, thisObj) { 29 fun.$lookupRTT = function() {
24 return function(arg1, arg2) { 30 return fRtt.call(thisObj);
31 }
32 }
33 return fun;
34 }
35 function $bind0_2(fn, fRtt, thisObj) {
36 var fun = function(arg1, arg2) {
25 return fn.call(thisObj, arg1, arg2); 37 return fn.call(thisObj, arg1, arg2);
26 } 38 }
27 } 39 if (fRtt) {
28 function $bind0_3(fn, thisObj) { 40 fun.$lookupRTT = function() {
29 return function(arg1, arg2, arg3) { 41 return fRtt.call(thisObj);
42 }
43 }
44 return fun;
45 }
46 function $bind0_3(fn, fRtt, thisObj) {
47 var fun = function(arg1, arg2, arg3) {
30 return fn.call(thisObj, arg1, arg2, arg3); 48 return fn.call(thisObj, arg1, arg2, arg3);
31 } 49 }
32 } 50 if (fRtt) {
33 function $bind0_4(fn, thisObj) { 51 fun.$lookupRTT = function() {
34 return function(arg1, arg2, arg3, arg4) { 52 return fRtt.call(thisObj);
53 }
54 }
55 return fun;
56 }
57 function $bind0_4(fn, fRtt, thisObj) {
58 var fun = function(arg1, arg2, arg3, arg4) {
35 return fn.call(thisObj, arg1, arg2, arg3, arg4); 59 return fn.call(thisObj, arg1, arg2, arg3, arg4);
36 } 60 }
37 } 61 if (fRtt) {
38 function $bind0_5(fn, thisObj) { 62 fun.$lookupRTT = function() {
39 return function(arg1, arg2, arg3, arg4, arg5) { 63 return fRtt.call(thisObj);
64 }
65 }
66 return fun;
67 }
68 function $bind0_5(fn, fRtt, thisObj) {
69 var fun = function(arg1, arg2, arg3, arg4, arg5) {
40 return fn.call(thisObj, arg1, arg2, arg3, arg4, arg5); 70 return fn.call(thisObj, arg1, arg2, arg3, arg4, arg5);
41 } 71 }
42 } 72 if (fRtt) {
43 73 fun.$lookupRTT = function() {
44 function $bind1_0(fn, thisObj, scope) { 74 return fRtt.call(thisObj);
45 return function() { 75 }
76 }
77 return fun;
78 }
79
80 function $bind1_0(fn, fRtt, thisObj, scope) {
81 var fun = function() {
46 return fn.call(thisObj, scope); 82 return fn.call(thisObj, scope);
47 } 83 }
48 } 84 if (fRtt) {
49 function $bind1_1(fn, thisObj, scope) { 85 fun.$lookupRTT = function() {
50 return function(arg) { 86 return fRtt.call(thisObj);
87 }
88 }
89 return fun;
90 }
91 function $bind1_1(fn, fRtt, thisObj, scope) {
92 var fun = function(arg) {
51 return fn.call(thisObj, scope, arg); 93 return fn.call(thisObj, scope, arg);
52 } 94 }
53 } 95 if (fRtt) {
54 function $bind1_2(fn, thisObj, scope) { 96 fun.$lookupRTT = function() {
55 return function(arg1, arg2) { 97 return fRtt.call(thisObj);
98 }
99 }
100 return fun;
101 }
102 function $bind1_2(fn, fRtt, thisObj, scope) {
103 var fun = function(arg1, arg2) {
56 return fn.call(thisObj, scope, arg1, arg2); 104 return fn.call(thisObj, scope, arg1, arg2);
57 } 105 }
58 } 106 if (fRtt) {
59 function $bind1_3(fn, thisObj, scope) { 107 fun.$lookupRTT = function() {
60 return function(arg1, arg2, arg3) { 108 return fRtt.call(thisObj);
109 }
110 }
111 return fun;
112 }
113 function $bind1_3(fn, fRtt, thisObj, scope) {
114 var fun = function(arg1, arg2, arg3) {
61 return fn.call(thisObj, scope, arg1, arg2, arg3); 115 return fn.call(thisObj, scope, arg1, arg2, arg3);
62 } 116 }
63 } 117 if (fRtt) {
64 function $bind1_4(fn, thisObj, scope) { 118 fun.$lookupRTT = function() {
65 return function(arg1, arg2, arg3, arg4) { 119 return fRtt.call(thisObj);
120 }
121 }
122 return fun;
123 }
124 function $bind1_4(fn, fRtt, thisObj, scope) {
125 var fun = function(arg1, arg2, arg3, arg4) {
66 return fn.call(thisObj, scope, arg1, arg2, arg3, arg4); 126 return fn.call(thisObj, scope, arg1, arg2, arg3, arg4);
67 } 127 }
68 } 128 if (fRtt) {
69 function $bind1_5(fn, thisObj, scope) { 129 fun.$lookupRTT = function() {
70 return function(arg1, arg2, arg3, arg4, arg5) { 130 return fRtt.call(thisObj);
131 }
132 }
133 return fun;
134 }
135 function $bind1_5(fn, fRtt, thisObj, scope) {
136 var fun = function(arg1, arg2, arg3, arg4, arg5) {
71 return fn.call(thisObj, scope, arg1, arg2, arg3, arg4, arg5); 137 return fn.call(thisObj, scope, arg1, arg2, arg3, arg4, arg5);
72 } 138 }
73 } 139 if (fRtt) {
74 140 fun.$lookupRTT = function() {
75 function $bind2_0(fn, thisObj, scope1, scope2) { 141 return fRtt.call(thisObj);
76 return function() { 142 }
143 }
144 return fun;
145 }
146
147 function $bind2_0(fn, fRtt, thisObj, scope1, scope2) {
148 var fun = function() {
77 return fn.call(thisObj, scope1, scope2); 149 return fn.call(thisObj, scope1, scope2);
78 } 150 }
79 } 151 if (fRtt) {
80 function $bind2_1(fn, thisObj, scope1, scope2) { 152 fun.$lookupRTT = function() {
81 return function(arg) { 153 return fRtt.call(thisObj);
154 }
155 }
156 return fun;
157 }
158 function $bind2_1(fn, fRtt, thisObj, scope1, scope2) {
159 var fun = function(arg) {
82 return fn.call(thisObj, scope1, scope2, arg); 160 return fn.call(thisObj, scope1, scope2, arg);
83 } 161 }
84 } 162 if (fRtt) {
85 function $bind2_2(fn, thisObj, scope1, scope2) { 163 fun.$lookupRTT = function() {
86 return function(arg1, arg2) { 164 return fRtt.call(thisObj);
165 }
166 }
167 return fun;
168 }
169 function $bind2_2(fn, fRtt, thisObj, scope1, scope2) {
170 var fun = function(arg1, arg2) {
87 return fn.call(thisObj, scope1, scope2, arg1, arg2); 171 return fn.call(thisObj, scope1, scope2, arg1, arg2);
88 } 172 }
89 } 173 if (fRtt) {
90 function $bind2_3(fn, thisObj, scope1, scope2) { 174 fun.$lookupRTT = function() {
91 return function(arg1, arg2, arg3) { 175 return fRtt.call(thisObj);
176 }
177 }
178 return fun;
179 }
180 function $bind2_3(fn, fRtt, thisObj, scope1, scope2) {
181 var fun = function(arg1, arg2, arg3) {
92 return fn.call(thisObj, scope1, scope2, arg1, arg2, arg3); 182 return fn.call(thisObj, scope1, scope2, arg1, arg2, arg3);
93 } 183 }
94 } 184 if (fRtt) {
95 function $bind2_4(fn, thisObj, scope1, scope2) { 185 fun.$lookupRTT = function() {
96 return function(arg1, arg2, arg3, arg4) { 186 return fRtt.call(thisObj);
187 }
188 }
189 return fun;
190 }
191 function $bind2_4(fn, fRtt, thisObj, scope1, scope2) {
192 var fun = function(arg1, arg2, arg3, arg4) {
97 return fn.call(thisObj, scope1, scope2, arg1, arg2, arg3, arg4); 193 return fn.call(thisObj, scope1, scope2, arg1, arg2, arg3, arg4);
98 } 194 }
99 } 195 if (fRtt) {
100 function $bind2_5(fn, thisObj, scope1, scope2) { 196 fun.$lookupRTT = function() {
101 return function(arg1, arg2, arg3, arg4, arg5) { 197 return fRtt.call(thisObj);
198 }
199 }
200 return fun;
201 }
202 function $bind2_5(fn, fRtt, thisObj, scope1, scope2) {
203 var fun = function(arg1, arg2, arg3, arg4, arg5) {
102 return fn.call(thisObj, scope1, scope2, arg1, arg2, arg3, arg4, arg5); 204 return fn.call(thisObj, scope1, scope2, arg1, arg2, arg3, arg4, arg5);
103 } 205 }
104 } 206 if (fRtt) {
105 207 fun.$lookupRTT = function() {
106 function $bind3_0(fn, thisObj, scope1, scope2, scope3) { 208 return fRtt.call(thisObj);
107 return function() { 209 }
210 }
211 return fun;
212 }
213
214 function $bind3_0(fn, fRtt, thisObj, scope1, scope2, scope3) {
215 var fun = function() {
108 return fn.call(thisObj, scope1, scope2, scope3); 216 return fn.call(thisObj, scope1, scope2, scope3);
109 } 217 }
110 } 218 if (fRtt) {
111 function $bind3_1(fn, thisObj, scope1, scope2, scope3) { 219 fun.$lookupRTT = function() {
112 return function(arg) { 220 return fRtt.call(thisObj);
221 }
222 }
223 return fun;
224 }
225 function $bind3_1(fn, fRtt, thisObj, scope1, scope2, scope3) {
226 var fun = function(arg) {
113 return fn.call(thisObj, scope1, scope2, scope3, arg); 227 return fn.call(thisObj, scope1, scope2, scope3, arg);
114 } 228 }
115 } 229 if (fRtt) {
116 function $bind3_2(fn, thisObj, scope1, scope2, scope3) { 230 fun.$lookupRTT = function() {
117 return function(arg1, arg2) { 231 return fRtt.call(thisObj);
232 }
233 }
234 return fun;
235 }
236 function $bind3_2(fn, fRtt, thisObj, scope1, scope2, scope3) {
237 var fun = function(arg1, arg2) {
118 return fn.call(thisObj, scope1, scope2, arg1, arg2); 238 return fn.call(thisObj, scope1, scope2, arg1, arg2);
119 } 239 }
120 } 240 if (fRtt) {
121 function $bind3_3(fn, thisObj, scope1, scope2, scope3) { 241 fun.$lookupRTT = function() {
122 return function(arg1, arg2, arg3) { 242 return fRtt.call(thisObj);
243 }
244 }
245 return fun;
246 }
247 function $bind3_3(fn, fRtt, thisObj, scope1, scope2, scope3) {
248 var fun = function(arg1, arg2, arg3) {
123 return fn.call(thisObj, scope1, scope2, scope3, arg1, arg2, arg3); 249 return fn.call(thisObj, scope1, scope2, scope3, arg1, arg2, arg3);
124 } 250 }
125 } 251 if (fRtt) {
126 function $bind3_4(fn, thisObj, scope1, scope2, scope3) { 252 fun.$lookupRTT = function() {
127 return function(arg1, arg2, arg3, arg4) { 253 return fRtt.call(thisObj);
254 }
255 }
256 return fun;
257 }
258 function $bind3_4(fn, fRtt, thisObj, scope1, scope2, scope3) {
259 var fun = function(arg1, arg2, arg3, arg4) {
128 return fn.call(thisObj, scope1, scope2, scope3, arg1, arg2, arg3, arg4); 260 return fn.call(thisObj, scope1, scope2, scope3, arg1, arg2, arg3, arg4);
129 } 261 }
130 } 262 if (fRtt) {
131 function $bind3_5(fn, thisObj, scope1, scope2, scope3) { 263 fun.$lookupRTT = function() {
132 return function(arg1, arg2, arg3, arg4, arg5) { 264 return fRtt.call(thisObj);
265 }
266 }
267 return fun;
268 }
269 function $bind3_5(fn, fRtt, thisObj, scope1, scope2, scope3) {
270 var fun = function(arg1, arg2, arg3, arg4, arg5) {
133 return fn.call(thisObj, scope1, scope2, scope3, arg1, arg2, arg3, arg4, arg5 ); 271 return fn.call(thisObj, scope1, scope2, scope3, arg1, arg2, arg3, arg4, arg5 );
134 } 272 }
273 if (fRtt) {
274 fun.$lookupRTT = function() {
275 return fRtt.call(thisObj);
276 }
277 }
278 return fun;
135 } 279 }
136 280
137 /** 281 /**
138 * Implements extends for dart classes on javascript prototypes. 282 * Implements extends for dart classes on javascript prototypes.
139 * @param {Function} child 283 * @param {Function} child
140 * @param {Function} parent 284 * @param {Function} parent
141 */ 285 */
142 function $inherits(child, parent) { 286 function $inherits(child, parent) {
143 if (child.prototype.__proto__) { 287 if (child.prototype.__proto__) {
144 child.prototype.__proto__ = parent.prototype; 288 child.prototype.__proto__ = parent.prototype;
145 } else { 289 } else {
146 function tmp() {}; 290 function tmp() {};
147 tmp.prototype = parent.prototype; 291 tmp.prototype = parent.prototype;
148 child.prototype = new tmp(); 292 child.prototype = new tmp();
149 child.prototype.constructor = child; 293 child.prototype.constructor = child;
150 } 294 }
151 } 295 }
152 296
153 /** 297 /**
154 * @param {Function} fn 298 * @param {Function} fn
299 * @param {Function=} fRtt
155 * @param {Object|undefined} thisObj 300 * @param {Object|undefined} thisObj
156 * @param {...*} var_args 301 * @param {...*} var_args
157 */ 302 */
158 function $bind(fn, thisObj, var_args) { 303 function $bind(fn, fRtt, thisObj, var_args) {
159 if (arguments.length > 2) { 304 var func;
160 var boundArgs = Array.prototype.slice.call(arguments, 2); 305 if (arguments.length > 3) {
161 return function() { 306 var boundArgs = Array.prototype.slice.call(arguments, 3);
307 func = function() {
162 // Prepend the bound arguments to the current arguments. 308 // Prepend the bound arguments to the current arguments.
163 var newArgs = Array.prototype.slice.call(arguments); 309 var newArgs = Array.prototype.slice.call(arguments);
164 Array.prototype.unshift.apply(newArgs, boundArgs); 310 Array.prototype.unshift.apply(newArgs, boundArgs);
165 return fn.apply(thisObj, newArgs); 311 return fn.apply(thisObj, newArgs);
166 }; 312 };
167 } else { 313 } else {
168 return function() { 314 func = function() {
169 return fn.apply(thisObj, arguments); 315 return fn.apply(thisObj, arguments);
170 }; 316 };
171 } 317 }
318 if(fRtt) {
319 func.$lookupRTT = function() {
320 return fRtt.apply(thisObj, arguments);
321 };
322 }
323 return func;
172 } 324 }
173 325
174 /** 326 /**
175 * Dart null object that should be used by JS implementation to test for 327 * Dart null object that should be used by JS implementation to test for
176 * Dart null. 328 * Dart null.
177 * 329 *
178 * TODO(ngeoffray): update dartc to generate this variable instead of 330 * TODO(ngeoffray): update dartc to generate this variable instead of
179 * undefined. 331 * undefined.
180 * @const 332 * @const
181 */ 333 */
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 return match; 615 return match;
464 } 616 }
465 o.$dartConstId = id; 617 o.$dartConstId = id;
466 $consts[key] = o; 618 $consts[key] = o;
467 return o; 619 return o;
468 } 620 }
469 621
470 function $Dart$MapLiteralFactory() { 622 function $Dart$MapLiteralFactory() {
471 return native__CoreJsUtil__newMapLiteral(); 623 return native__CoreJsUtil__newMapLiteral();
472 } 624 }
OLDNEW
« no previous file with comments | « compiler/javatests/com/google/dart/compiler/common/GenerateSourceMapTest.java ('k') | compiler/lib/implementation/rtt.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698