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

Unified Diff: tool/input_sdk/private/rtti.dart

Issue 1680263002: Support for dart:typed_data (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Address comments, rebase Created 4 years, 10 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 | « tool/input_sdk/private/operations.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/private/rtti.dart
diff --git a/tool/input_sdk/private/rtti.dart b/tool/input_sdk/private/rtti.dart
index 8694daa6e38033594b9add6644e6d9d50c09f808..b0b65876a254beb75b85cbccb8b022ae5d547c54 100644
--- a/tool/input_sdk/private/rtti.dart
+++ b/tool/input_sdk/private/rtti.dart
@@ -93,9 +93,15 @@ checkPrimitiveType(obj) => JS('', '''(() => {
})()''');
runtimeType(obj) => JS('', '''(() => {
+ // Lookup primitive (int/double/string)
let result = $checkPrimitiveType($obj);
if (result !== null) return result;
- return $obj.runtimeType;
+
+ // Lookup recorded type
+ result = $obj.runtimeType;
+ if (result) return result;
+
+ return $_nonPrimitiveRuntimeType(obj);
})()''');
getFunctionType(obj) => JS('', '''(() => {
@@ -111,12 +117,25 @@ getFunctionType(obj) => JS('', '''(() => {
/// Currently this will return null for non-Dart objects.
///
realRuntimeType(obj) => JS('', '''(() => {
+ // Lookup primitive type
let result = $checkPrimitiveType($obj);
if (result !== null) return result;
+
+ return $_nonPrimitiveRuntimeType(obj);
+})()''');
+
+_nonPrimitiveRuntimeType(obj) => JS('', '''(() => {
+ // Lookup recorded *real* type (not user definable runtimeType)
// TODO(vsm): Should we treat Dart and JS objects differently here?
// E.g., we can check if obj instanceof core.Object to differentiate.
- result = $obj[$_runtimeType];
+ let result = $obj[$_runtimeType];
+ if (result) return result;
+
+ // Lookup extension type
+ result = $obj[$_extensionType];
if (result) return result;
+
+ // Fallback on constructor for class types
result = $obj.constructor;
if (result == Function) {
// An undecorated Function should have come from
« no previous file with comments | « tool/input_sdk/private/operations.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698