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

Unified Diff: lib/runtime/dart_runtime.js

Issue 1093353004: fix list initializers (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: baselines Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/runtime/dart/typed_data.js ('k') | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/runtime/dart_runtime.js
diff --git a/lib/runtime/dart_runtime.js b/lib/runtime/dart_runtime.js
index e6995067318b24b0a06bc9a1934ec3491a579d9f..dee8918910d4007f8ae4881cb392094f0d61b8d3 100644
--- a/lib/runtime/dart_runtime.js
+++ b/lib/runtime/dart_runtime.js
@@ -84,6 +84,11 @@ var dart, _js_helper;
dart.dsend = dsend;
function dindex(obj, index) {
+ // TODO(jmesserly): remove this special case once Array extensions are
+ // hooked up.
+ if (obj instanceof Array && getRuntimeType(index) == core.int) {
+ return obj[index];
+ }
return checkAndCall(obj.get, obj, [index], '[]');
}
dart.dindex = dindex;
@@ -102,6 +107,10 @@ var dart, _js_helper;
}
dart.as = cast;
+
+ // TODO(vsm): How should we encode the runtime type?
+ let runtimeType = Symbol('runtimeType');
+
/**
* Returns the runtime type of obj. This is the same as `obj.runtimeType`
* but will not call an overridden getter.
@@ -126,7 +135,7 @@ var dart, _js_helper;
if (obj === null) return core.Null;
// TODO(vsm): Should we treat Dart and JS objects differently here?
// E.g., we can check if obj instanceof core.Object to differentiate.
- var result = obj[dart.runtimeType];
+ var result = obj[runtimeType];
if (result) return result;
result = obj.constructor;
if (result == Function) {
@@ -766,15 +775,18 @@ var dart, _js_helper;
}
dart.generic = generic;
+ /** Sets the runtime type of `obj` to be `type` */
+ function setType(obj, type) {
+ obj[runtimeType] = type;
+ }
+ dart.setType = setType;
+
// TODO(jmesserly): right now this is a sentinel. It should be a type object
// of some sort, assuming we keep around `dynamic` at runtime.
dart.dynamic = { toString() { return 'dynamic'; } };
dart.void = { toString() { return 'void'; } };
dart.bottom = { toString() { return 'bottom'; } };
- // TODO(vsm): How should we encode the runtime type?
- dart.runtimeType = Symbol('runtimeType');
-
dart.JsSymbol = Symbol;
// TODO(jmesserly): hack to bootstrap the SDK
« no previous file with comments | « lib/runtime/dart/typed_data.js ('k') | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698