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

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

Issue 208423012: Add helpers library to dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | 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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 } 792 }
793 // Else we don't need to do anything. The final handler is only 793 // Else we don't need to do anything. The final handler is only
794 // optimistically trying to compile constants. So it is normal that we 794 // optimistically trying to compile constants. So it is normal that we
795 // sometimes see non-compile time constants. 795 // sometimes see non-compile time constants.
796 // Simply return [:null:] which is used to propagate a failing 796 // Simply return [:null:] which is used to propagate a failing
797 // compile-time compilation. 797 // compile-time compilation.
798 return null; 798 return null;
799 } 799 }
800 } 800 }
801 801
802 class TryCompileTimeConstantEvaluator extends CompileTimeConstantEvaluator {
803 TryCompileTimeConstantEvaluator(ConstantHandler handler,
804 TreeElements elements,
805 Compiler compiler)
806 : super(handler, elements, compiler, isConst: true);
807
808 error(Node node, MessageKind message) {
809 // Just fail without reporting it anywhere.
810 throw new CompileTimeConstantError(
811 message, const {}, compiler.terseDiagnostics);
812 }
813 }
814
815 class CompileTimeConstantError {
816 final Message message;
817 CompileTimeConstantError(MessageKind kind, Map arguments, bool terse)
818 : message = new Message(kind, arguments, terse);
819 String toString() => message.toString();
820 }
821
822 class ConstructorEvaluator extends CompileTimeConstantEvaluator { 802 class ConstructorEvaluator extends CompileTimeConstantEvaluator {
823 final FunctionElement constructor; 803 final FunctionElement constructor;
824 final Map<Element, Constant> definitions; 804 final Map<Element, Constant> definitions;
825 final Map<Element, Constant> fieldValues; 805 final Map<Element, Constant> fieldValues;
826 806
827 /** 807 /**
828 * Documentation wanted -- johnniwinther 808 * Documentation wanted -- johnniwinther
829 * 809 *
830 * Invariant: [constructor] must be an implementation element. 810 * Invariant: [constructor] must be an implementation element.
831 */ 811 */
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 if (fieldValue == null) { 981 if (fieldValue == null) {
1002 // Use the default value. 982 // Use the default value.
1003 fieldValue = handler.compileConstant(field); 983 fieldValue = handler.compileConstant(field);
1004 } 984 }
1005 jsNewArguments.add(fieldValue); 985 jsNewArguments.add(fieldValue);
1006 }, 986 },
1007 includeSuperAndInjectedMembers: true); 987 includeSuperAndInjectedMembers: true);
1008 return jsNewArguments; 988 return jsNewArguments;
1009 } 989 }
1010 } 990 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698