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

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

Issue 2620023002: Use elements/types in constants/values (Closed)
Patch Set: Created 3 years, 11 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) 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 dart2js.constant_system.js; 5 library dart2js.constant_system.js;
6 6
7 import '../compiler.dart' show Compiler; 7 import '../compiler.dart' show Compiler;
8 import '../constant_system_dart.dart'; 8 import '../constant_system_dart.dart';
9 import '../constants/constant_system.dart'; 9 import '../constants/constant_system.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 NullConstantValue createNull() => new NullConstantValue(); 313 NullConstantValue createNull() => new NullConstantValue();
314 314
315 @override 315 @override
316 ListConstantValue createList( 316 ListConstantValue createList(
317 ResolutionInterfaceType type, List<ConstantValue> values) { 317 ResolutionInterfaceType type, List<ConstantValue> values) {
318 return new ListConstantValue(type, values); 318 return new ListConstantValue(type, values);
319 } 319 }
320 320
321 @override 321 @override
322 ConstantValue createType(Compiler compiler, ResolutionDartType type) { 322 ConstantValue createType(Compiler compiler, ResolutionDartType type) {
323 return new TypeConstantValue( 323 ResolutionInterfaceType instanceType = compiler
324 type, 324 .backend.backendClasses.typeImplementation
325 compiler.backend.backendClasses.typeImplementation 325 .computeType(compiler.resolution);
326 .computeType(compiler.resolution)); 326 return new TypeConstantValue(type, instanceType);
327 } 327 }
328 328
329 // Integer checks report true for -0.0, INFINITY, and -INFINITY. At 329 // Integer checks report true for -0.0, INFINITY, and -INFINITY. At
330 // runtime an 'X is int' check is implemented as: 330 // runtime an 'X is int' check is implemented as:
331 // 331 //
332 // typeof(X) === "number" && Math.floor(X) === X 332 // typeof(X) === "number" && Math.floor(X) === X
333 // 333 //
334 // We consistently match that runtime semantics at compile time as well. 334 // We consistently match that runtime semantics at compile time as well.
335 bool isInt(ConstantValue constant) { 335 bool isInt(ConstantValue constant) {
336 return constant.isInt || 336 return constant.isInt ||
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 375 }
376 } else { 376 } else {
377 onlyStringKeys = false; 377 onlyStringKeys = false;
378 // Don't handle __proto__ values specially in the general map case. 378 // Don't handle __proto__ values specially in the general map case.
379 protoValue = null; 379 protoValue = null;
380 break; 380 break;
381 } 381 }
382 } 382 }
383 383
384 bool hasProtoKey = (protoValue != null); 384 bool hasProtoKey = (protoValue != null);
385 ResolutionDartType keysType; 385 ResolutionInterfaceType keysType;
386 if (sourceType.treatAsRaw) { 386 if (sourceType.treatAsRaw) {
387 keysType = commonElements.listType(); 387 keysType = commonElements.listType();
388 } else { 388 } else {
389 keysType = commonElements.listType(sourceType.typeArguments.first); 389 keysType = commonElements.listType(sourceType.typeArguments.first);
390 } 390 }
391 ListConstantValue keysList = new ListConstantValue(keysType, keys); 391 ListConstantValue keysList = new ListConstantValue(keysType, keys);
392 ClassElement classElement = onlyStringKeys 392 ClassElement classElement = onlyStringKeys
393 ? (hasProtoKey 393 ? (hasProtoKey
394 ? backend.helpers.constantProtoMapClass 394 ? backend.helpers.constantProtoMapClass
395 : backend.helpers.constantStringMapClass) 395 : backend.helpers.constantStringMapClass)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 result.add(keyList); 458 result.add(keyList);
459 } else { 459 } else {
460 // Add the keys individually to avoid generating an unused list constant 460 // Add the keys individually to avoid generating an unused list constant
461 // for the keys. 461 // for the keys.
462 result.addAll(keys); 462 result.addAll(keys);
463 } 463 }
464 result.addAll(values); 464 result.addAll(values);
465 return result; 465 return result;
466 } 466 }
467 } 467 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698