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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/compile_time_constants.dart

Issue 11299009: Support type literals as compile-time constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * The [ConstantHandler] keeps track of compile-time constants, 8 * The [ConstantHandler] keeps track of compile-time constants,
9 * initializations of global and static fields, and default values of 9 * initializations of global and static fields, and default values of
10 * optional parameters. 10 * optional parameters.
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 compiler.enqueuer.codegen.registerStaticUse(element); 409 compiler.enqueuer.codegen.registerStaticUse(element);
410 return constant; 410 return constant;
411 } else if (Elements.isStaticOrTopLevelField(element)) { 411 } else if (Elements.isStaticOrTopLevelField(element)) {
412 Constant result; 412 Constant result;
413 if (element.modifiers.isConst()) { 413 if (element.modifiers.isConst()) {
414 result = compiler.compileConstant(element); 414 result = compiler.compileConstant(element);
415 } else if (element.modifiers.isFinal() && !isEvaluatingConstant) { 415 } else if (element.modifiers.isFinal() && !isEvaluatingConstant) {
416 result = compiler.compileVariable(element); 416 result = compiler.compileVariable(element);
417 } 417 }
418 if (result != null) return result; 418 if (result != null) return result;
419 } else if (Elements.isClass(element) || Elements.isTypedef(element)) {
420 DartType type = element.computeType(compiler).asRaw();
421 Constant constant =
422 new TypeConstant(type, compiler.typeClass.computeType(compiler));
423 compiler.constantHandler.registerCompileTimeConstant(constant);
424 return constant;
419 } 425 }
420 return signalNotCompileTimeConstant(send); 426 return signalNotCompileTimeConstant(send);
421 } else if (send.isCall) { 427 } else if (send.isCall) {
422 if (identical(element, compiler.identicalFunction) 428 if (identical(element, compiler.identicalFunction)
423 && send.argumentCount() == 2) { 429 && send.argumentCount() == 2) {
424 Constant left = evaluate(send.argumentsNode.nodes.head); 430 Constant left = evaluate(send.argumentsNode.nodes.head);
425 Constant right = evaluate(send.argumentsNode.nodes.tail.head); 431 Constant right = evaluate(send.argumentsNode.nodes.tail.head);
426 Constant result = constantSystem.identity.fold(left, right); 432 Constant result = constantSystem.identity.fold(left, right);
427 if (result != null) return result; 433 if (result != null) return result;
428 } 434 }
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 // Use the default value. 827 // Use the default value.
822 fieldValue = compiler.compileConstant(field); 828 fieldValue = compiler.compileConstant(field);
823 } 829 }
824 jsNewArguments.add(fieldValue); 830 jsNewArguments.add(fieldValue);
825 }, 831 },
826 includeBackendMembers: true, 832 includeBackendMembers: true,
827 includeSuperMembers: true); 833 includeSuperMembers: true);
828 return jsNewArguments; 834 return jsNewArguments;
829 } 835 }
830 } 836 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698