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

Side by Side 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: Refine comment 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// This library defines the association between runtime objects and 5 /// This library defines the association between runtime objects and
6 /// runtime types. 6 /// runtime types.
7 part of dart._runtime; 7 part of dart._runtime;
8 8
9 /// 9 ///
10 /// Runtime type information. This module defines the mapping from 10 /// Runtime type information. This module defines the mapping from
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 case "symbol": 86 case "symbol":
87 return Symbol; 87 return Symbol;
88 } 88 }
89 // Undefined is handled above. For historical reasons, 89 // Undefined is handled above. For historical reasons,
90 // typeof null == "object" in JS. 90 // typeof null == "object" in JS.
91 if ($obj === null) return $Null; 91 if ($obj === null) return $Null;
92 return null; 92 return null;
93 })()'''); 93 })()''');
94 94
95 runtimeType(obj) => JS('', '''(() => { 95 runtimeType(obj) => JS('', '''(() => {
96 // Lookup primitive (int/double/string)
96 let result = $checkPrimitiveType($obj); 97 let result = $checkPrimitiveType($obj);
97 if (result !== null) return result; 98 if (result !== null) return result;
98 return $obj.runtimeType; 99
100 // Lookup recorded type
101 result = $obj.runtimeType;
Jennifer Messerly 2016/02/10 00:20:30 huh, the old code here looks broken. Shouldn't thi
vsm 2016/02/11 22:36:06 For object properties, we either: (1) use the uns
Jennifer Messerly 2016/02/11 23:04:57 yeah, I mean, this is a bug in how the hand-coded
102 if (result) return result;
103
104 // Lookup extension type for native object
105 result = $obj[$_extensionType];
Jennifer Messerly 2016/02/10 00:20:30 we can just go with realRuntimeType here, right? T
vsm 2016/02/11 22:36:06 Yeah, was try to avoid the redundant check on prim
106 if (result) return result;
107
108 // TODO(vsm): Return JSObject?
Jennifer Messerly 2016/02/10 00:20:30 (this may be moot based on realRuntimeType comment
vsm 2016/02/11 22:36:06 Removed
109 return null;
99 })()'''); 110 })()''');
100 111
101 getFunctionType(obj) => JS('', '''(() => { 112 getFunctionType(obj) => JS('', '''(() => {
102 // TODO(vsm): Encode this properly on the function for Dart-generated code. 113 // TODO(vsm): Encode this properly on the function for Dart-generated code.
103 let args = Array($obj.length).fill($dynamicR); 114 let args = Array($obj.length).fill($dynamicR);
104 return $definiteFunctionType($bottom, args); 115 return $definiteFunctionType($bottom, args);
105 })()'''); 116 })()''');
106 117
107 /// 118 ///
108 /// Returns the runtime type of obj. This is the same as `obj.realRuntimeType` 119 /// Returns the runtime type of obj. This is the same as `obj.realRuntimeType`
109 /// but will not call an overridden getter. 120 /// but will not call an overridden getter.
110 /// 121 ///
111 /// Currently this will return null for non-Dart objects. 122 /// Currently this will return null for non-Dart objects.
112 /// 123 ///
113 realRuntimeType(obj) => JS('', '''(() => { 124 realRuntimeType(obj) => JS('', '''(() => {
125 // Lookup primitive type
114 let result = $checkPrimitiveType($obj); 126 let result = $checkPrimitiveType($obj);
115 if (result !== null) return result; 127 if (result !== null) return result;
128
129 // Lookup recorded *real* type (not user definable runtimeType)
116 // TODO(vsm): Should we treat Dart and JS objects differently here? 130 // TODO(vsm): Should we treat Dart and JS objects differently here?
117 // E.g., we can check if obj instanceof core.Object to differentiate. 131 // E.g., we can check if obj instanceof core.Object to differentiate.
118 result = $obj[$_runtimeType]; 132 result = $obj[$_runtimeType];
119 if (result) return result; 133 if (result) return result;
134
135 // Lookup extension type
136 result = $obj[$_extensionType];
Jennifer Messerly 2016/02/10 00:20:30 Fallback to the constructor should find our type,
vsm 2016/02/11 22:36:06 Hmm, I think there are (at least) 3 interesting ca
Jennifer Messerly 2016/02/11 23:04:57 This shouldn't happen. setType must be called for
137 if (result) return result;
138
139 // Fallback on constructor for class types
120 result = $obj.constructor; 140 result = $obj.constructor;
121 if (result == Function) { 141 if (result == Function) {
122 // An undecorated Function should have come from 142 // An undecorated Function should have come from
123 // JavaScript. Treat as untyped. 143 // JavaScript. Treat as untyped.
124 return $jsobject; 144 return $jsobject;
125 } 145 }
126 return result; 146 return result;
127 })()'''); 147 })()''');
128 148
129 LazyTagged(infoFn) => JS('', '''(() => { 149 LazyTagged(infoFn) => JS('', '''(() => {
(...skipping 18 matching lines...) Expand all
148 tagMemoized(value, compute) => JS('', '''(() => { 168 tagMemoized(value, compute) => JS('', '''(() => {
149 let cache = null; 169 let cache = null;
150 function getter() { 170 function getter() {
151 if ($compute == null) return cache; 171 if ($compute == null) return cache;
152 cache = $compute(); 172 cache = $compute();
153 $compute = null; 173 $compute = null;
154 return cache; 174 return cache;
155 } 175 }
156 $tagComputed($value, getter); 176 $tagComputed($value, getter);
157 })()'''); 177 })()''');
OLDNEW
« tool/input_sdk/private/operations.dart ('K') | « tool/input_sdk/private/operations.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698