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

Side by Side Diff: pkg/compiler/lib/src/js_backend/constant_system_javascript.dart

Issue 792643003: Add DartTypes to abstract Types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 6 years 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 part of js_backend; 5 part of js_backend;
6 6
7 const JAVA_SCRIPT_CONSTANT_SYSTEM = const JavaScriptConstantSystem(); 7 const JAVA_SCRIPT_CONSTANT_SYSTEM = const JavaScriptConstantSystem();
8 8
9 class JavaScriptBitNotOperation extends BitNotOperation { 9 class JavaScriptBitNotOperation extends BitNotOperation {
10 const JavaScriptBitNotOperation(); 10 const JavaScriptBitNotOperation();
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 NullConstantValue createNull() => new NullConstantValue(); 226 NullConstantValue createNull() => new NullConstantValue();
227 227
228 // Integer checks don't verify that the number is not -0.0. 228 // Integer checks don't verify that the number is not -0.0.
229 bool isInt(ConstantValue constant) => constant.isInt || constant.isMinusZero; 229 bool isInt(ConstantValue constant) => constant.isInt || constant.isMinusZero;
230 bool isDouble(ConstantValue constant) 230 bool isDouble(ConstantValue constant)
231 => constant.isDouble && !constant.isMinusZero; 231 => constant.isDouble && !constant.isMinusZero;
232 bool isString(ConstantValue constant) => constant.isString; 232 bool isString(ConstantValue constant) => constant.isString;
233 bool isBool(ConstantValue constant) => constant.isBool; 233 bool isBool(ConstantValue constant) => constant.isBool;
234 bool isNull(ConstantValue constant) => constant.isNull; 234 bool isNull(ConstantValue constant) => constant.isNull;
235 235
236 bool isSubtype(Compiler compiler, DartType s, DartType t) { 236 bool isSubtype(DartTypes types, DartType s, DartType t) {
237 // At runtime, an integer is both an integer and a double: the 237 // At runtime, an integer is both an integer and a double: the
238 // integer type check is Math.floor, which will return true only 238 // integer type check is Math.floor, which will return true only
239 // for real integers, and our double type check is 'typeof number' 239 // for real integers, and our double type check is 'typeof number'
240 // which will return true for both integers and doubles. 240 // which will return true for both integers and doubles.
241 if (s.element == compiler.intClass && t.element == compiler.doubleClass) { 241 if (s == types.coreTypes.intType && t == types.coreTypes.doubleType) {
242 return true; 242 return true;
243 } 243 }
244 return compiler.types.isSubtype(s, t); 244 return types.isSubtype(s, t);
245 } 245 }
246 246
247 MapConstantValue createMap(Compiler compiler, 247 MapConstantValue createMap(Compiler compiler,
248 InterfaceType sourceType, 248 InterfaceType sourceType,
249 List<ConstantValue> keys, 249 List<ConstantValue> keys,
250 List<ConstantValue> values) { 250 List<ConstantValue> values) {
251 JavaScriptBackend backend = compiler.backend; 251 JavaScriptBackend backend = compiler.backend;
252 252
253 bool onlyStringKeys = true; 253 bool onlyStringKeys = true;
254 ConstantValue protoValue = null; 254 ConstantValue protoValue = null;
255 for (int i = 0; i < keys.length ; i++) { 255 for (int i = 0; i < keys.length ; i++) {
256 var key = keys[i]; 256 var key = keys[i];
257 if (key.isString) { 257 if (key.isString) {
258 if (key.primitiveValue == JavaScriptMapConstant.PROTO_PROPERTY) { 258 if (key.primitiveValue == JavaScriptMapConstant.PROTO_PROPERTY) {
259 protoValue = values[i]; 259 protoValue = values[i];
260 } 260 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 result.add(keyList); 336 result.add(keyList);
337 } else { 337 } else {
338 // Add the keys individually to avoid generating an unused list constant 338 // Add the keys individually to avoid generating an unused list constant
339 // for the keys. 339 // for the keys.
340 result.addAll(keys); 340 result.addAll(keys);
341 } 341 }
342 result.addAll(values); 342 result.addAll(values);
343 return result; 343 return result;
344 } 344 }
345 } 345 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/task.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698