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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_helper.dart

Issue 869953002: dart2js: add type lookup in the new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library _js_helper; 5 library _js_helper;
6 6
7 import 'dart:_js_embedded_names' show 7 import 'dart:_js_embedded_names' show
8 ALL_CLASSES, 8 GET_TYPE_FROM_NAME,
9 GET_ISOLATE_TAG, 9 GET_ISOLATE_TAG,
10 INTERCEPTED_NAMES, 10 INTERCEPTED_NAMES,
11 INTERCEPTORS_BY_TAG, 11 INTERCEPTORS_BY_TAG,
12 LEAF_TAGS, 12 LEAF_TAGS,
13 METADATA, 13 METADATA,
14 DEFERRED_LIBRARY_URIS, 14 DEFERRED_LIBRARY_URIS,
15 DEFERRED_LIBRARY_HASHES, 15 DEFERRED_LIBRARY_HASHES,
16 INITIALIZE_LOADED_HUNK, 16 INITIALIZE_LOADED_HUNK,
17 IS_HUNK_LOADED, 17 IS_HUNK_LOADED,
18 IS_HUNK_INITIALIZED, 18 IS_HUNK_INITIALIZED,
(...skipping 3122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 "'${JS('String', 'JSON.stringify(#)', rti)}' to RuntimeType."); 3141 "'${JS('String', 'JSON.stringify(#)', rti)}' to RuntimeType.");
3142 } 3142 }
3143 } 3143 }
3144 3144
3145 class RuntimeTypePlain extends RuntimeType { 3145 class RuntimeTypePlain extends RuntimeType {
3146 final String name; 3146 final String name;
3147 3147
3148 RuntimeTypePlain(this.name); 3148 RuntimeTypePlain(this.name);
3149 3149
3150 toRti() { 3150 toRti() {
3151 var allClasses = JS_EMBEDDED_GLOBAL('', ALL_CLASSES); 3151 var getTypeFromName = JS_EMBEDDED_GLOBAL('', GET_TYPE_FROM_NAME);
3152 var rti = JS('', '#[#]', allClasses, name); 3152 var rti = JS('', '#(#)', getTypeFromName, name);
3153 if (rti == null) throw "no type for '$name'"; 3153 if (rti == null) throw "no type for '$name'";
3154 return rti; 3154 return rti;
3155 } 3155 }
3156 3156
3157 String toString() => name; 3157 String toString() => name;
3158 } 3158 }
3159 3159
3160 class RuntimeTypeGeneric extends RuntimeType { 3160 class RuntimeTypeGeneric extends RuntimeType {
3161 final String name; 3161 final String name;
3162 final List<RuntimeType> arguments; 3162 final List<RuntimeType> arguments;
3163 var rti; 3163 var rti;
3164 3164
3165 RuntimeTypeGeneric(this.name, this.arguments, this.rti); 3165 RuntimeTypeGeneric(this.name, this.arguments, this.rti);
3166 3166
3167 toRti() { 3167 toRti() {
3168 if (rti != null) return rti; 3168 if (rti != null) return rti;
3169 var allClasses = JS_EMBEDDED_GLOBAL('', ALL_CLASSES); 3169 var getTypeFromName = JS_EMBEDDED_GLOBAL('', GET_TYPE_FROM_NAME);
3170 var result = JS('JSExtendableArray', '[#[#]]', allClasses, name); 3170 var result = JS('JSExtendableArray', '[#(#)]', getTypeFromName, name);
3171 if (result[0] == null) { 3171 if (result[0] == null) {
3172 throw "no type for '$name<...>'"; 3172 throw "no type for '$name<...>'";
3173 } 3173 }
3174 for (RuntimeType argument in arguments) { 3174 for (RuntimeType argument in arguments) {
3175 JS('', '#.push(#)', result, argument.toRti()); 3175 JS('', '#.push(#)', result, argument.toRti());
3176 } 3176 }
3177 return rti = result; 3177 return rti = result;
3178 } 3178 }
3179 3179
3180 String toString() => '$name<${arguments.join(", ")}>'; 3180 String toString() => '$name<${arguments.join(", ")}>';
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
3455 throw new MainError("No top-level function named 'main'."); 3455 throw new MainError("No top-level function named 'main'.");
3456 } 3456 }
3457 3457
3458 void badMain() { 3458 void badMain() {
3459 throw new MainError("'main' is not a function."); 3459 throw new MainError("'main' is not a function.");
3460 } 3460 }
3461 3461
3462 void mainHasTooManyParameters() { 3462 void mainHasTooManyParameters() {
3463 throw new MainError("'main' expects too many parameters."); 3463 throw new MainError("'main' expects too many parameters.");
3464 } 3464 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698