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

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

Issue 15861005: Implement ClassMirror.owner and LibraryMirror.uri. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix problem in deferred code Created 7 years, 7 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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:collection'; 7 import 'dart:collection';
8 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, 8 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS,
9 JS, 9 JS,
10 JS_CALL_IN_ISOLATE, 10 JS_CALL_IN_ISOLATE,
11 JS_CURRENT_ISOLATE, 11 JS_CURRENT_ISOLATE,
12 JS_DART_OBJECT_CONSTRUCTOR, 12 JS_DART_OBJECT_CONSTRUCTOR,
13 JS_OPERATOR_IS_PREFIX, 13 JS_OPERATOR_IS_PREFIX,
14 JS_OPERATOR_AS_PREFIX, 14 JS_OPERATOR_AS_PREFIX,
15 RAW_DART_FUNCTION_REF; 15 RAW_DART_FUNCTION_REF;
16 import 'dart:_interceptors' show getInterceptor, 16 import 'dart:_interceptors';
17 interceptedNames,
18 dispatchPropertyName,
19 makeDispatchRecord,
20 setDispatchProperty,
21 Interceptor,
22 JSMutableIndexable,
23 JSUnknown;
24 import "dart:_collection-dev" as _symbol_dev; 17 import "dart:_collection-dev" as _symbol_dev;
25 18
26 part 'constant_map.dart'; 19 part 'constant_map.dart';
27 part 'native_helper.dart'; 20 part 'native_helper.dart';
28 part 'regexp_helper.dart'; 21 part 'regexp_helper.dart';
29 part 'string_helper.dart'; 22 part 'string_helper.dart';
30 part 'js_rti.dart'; 23 part 'js_rti.dart';
31 24
32 bool isJsArray(var value) { 25 bool isJsArray(var value) {
33 return value != null && JS('bool', r'(#.constructor === Array)', value); 26 return value != null && JS('bool', r'(#.constructor === Array)', value);
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 if (jsFunction == null) { 564 if (jsFunction == null) {
572 throw new NoSuchMethodError(function, selectorName, arguments, {}); 565 throw new NoSuchMethodError(function, selectorName, arguments, {});
573 } 566 }
574 // We bound 'this' to [function] because of how we compile 567 // We bound 'this' to [function] because of how we compile
575 // closures: escaped local variables are stored and accessed through 568 // closures: escaped local variables are stored and accessed through
576 // [function]. 569 // [function].
577 return JS('var', '#.apply(#, #)', jsFunction, function, arguments); 570 return JS('var', '#.apply(#, #)', jsFunction, function, arguments);
578 } 571 }
579 572
580 static getConstructor(String className) { 573 static getConstructor(String className) {
574 // TODO(ahe): Generalize this and improve test coverage of
575 // reflecting on intercepted classes.
576 if (JS('bool', '# == "String"', className)) return const JSString();
577 if (JS('bool', '# == "int"', int)) return const JSInt();
578 if (JS('bool', '# == "double"', int)) return const JSDouble();
579 if (JS('bool', '# == "num"', int)) return const JSNumber();
580 if (JS('bool', '# == "bool"', int)) return const JSBool();
581 if (JS('bool', '# == "List"', int)) return const JSArray();
581 // TODO(ahe): How to safely access $? 582 // TODO(ahe): How to safely access $?
582 return JS('var', r'$[#]', className); 583 return JS('var', r'$[#]', className);
583 } 584 }
584 585
585 static bool identicalImplementation(a, b) { 586 static bool identicalImplementation(a, b) {
586 return JS('bool', '# == null', a) 587 return JS('bool', '# == null', a)
587 ? JS('bool', '# == null', b) 588 ? JS('bool', '# == null', b)
588 : JS('bool', '# === #', a, b); 589 : JS('bool', '# === #', a, b);
589 } 590 }
590 } 591 }
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 expectedArgumentNames); 1407 expectedArgumentNames);
1407 } 1408 }
1408 1409
1409 /** 1410 /**
1410 * Called by generated code when a static field's initializer references the 1411 * Called by generated code when a static field's initializer references the
1411 * field that is currently being initialized. 1412 * field that is currently being initialized.
1412 */ 1413 */
1413 void throwCyclicInit(String staticName) { 1414 void throwCyclicInit(String staticName) {
1414 throw new RuntimeError("Cyclic initialization for static $staticName"); 1415 throw new RuntimeError("Cyclic initialization for static $staticName");
1415 } 1416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698