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

Side by Side Diff: frog/leg/compile_time_constants.dart

Issue 9699033: Introduce FieldParameterElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo. Created 8 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
« no previous file with comments | « no previous file | frog/leg/compiler.dart » ('j') | frog/leg/elements/elements.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class Constant implements Hashable { 5 class Constant implements Hashable {
6 const Constant(); 6 const Constant();
7 7
8 bool isNull() => false; 8 bool isNull() => false;
9 bool isBool() => false; 9 bool isBool() => false;
10 bool isTrue() => false; 10 bool isTrue() => false;
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 479
480 /** 480 /**
481 * Compiles the initial value of the given field and stores it in an internal 481 * Compiles the initial value of the given field and stores it in an internal
482 * map. 482 * map.
483 * 483 *
484 * [WorkItem] must contain a [VariableElement] refering to a global or 484 * [WorkItem] must contain a [VariableElement] refering to a global or
485 * static field. 485 * static field.
486 */ 486 */
487 void compileWorkItem(WorkItem work) { 487 void compileWorkItem(WorkItem work) {
488 assert(work.element.kind == ElementKind.FIELD 488 assert(work.element.kind == ElementKind.FIELD
489 || work.element.kind == ElementKind.PARAMETER); 489 || work.element.kind == ElementKind.PARAMETER
490 || work.element.kind == ElementKind.FIELD_PARAMETER);
490 VariableElement element = work.element; 491 VariableElement element = work.element;
491 // Shortcut if it has already been compiled. 492 // Shortcut if it has already been compiled.
492 if (initialVariableValues.containsKey(element)) return; 493 if (initialVariableValues.containsKey(element)) return;
493 compileVariableWithDefinitions(element, work.resolutionTree); 494 compileVariableWithDefinitions(element, work.resolutionTree);
494 assert(pendingVariables.isEmpty()); 495 assert(pendingVariables.isEmpty());
495 } 496 }
496 497
497 compileVariable(VariableElement element) { 498 compileVariable(VariableElement element) {
498 if (initialVariableValues.containsKey(element)) { 499 if (initialVariableValues.containsKey(element)) {
499 Constant result = initialVariableValues[element]; 500 Constant result = initialVariableValues[element];
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 if (arguments.length < parameters.parameterCount && 926 if (arguments.length < parameters.parameterCount &&
926 arguments.length >= parameters.requiredParameterCount) { 927 arguments.length >= parameters.requiredParameterCount) {
927 compiler.unimplemented("ConstantHandler with optional arguments", 928 compiler.unimplemented("ConstantHandler with optional arguments",
928 node: node); 929 node: node);
929 } else { 930 } else {
930 error(node); 931 error(node);
931 } 932 }
932 } 933 }
933 int index = 0; 934 int index = 0;
934 parameters.forEachParameter((Element parameter) { 935 parameters.forEachParameter((Element parameter) {
935 constructorDefinitions[parameter] = arguments[index++]; 936 Constant argument = arguments[index++];
937 constructorDefinitions[parameter] = argument;
938 if (parameter.kind == ElementKind.FIELD_PARAMETER) {
939 FieldParameterElement fieldParameterElement = parameter;
940 constructorDefinitions[fieldParameterElement.fieldElement] = argument;
941 }
936 }); 942 });
937 } 943 }
938 944
939 void compileInitializers(Link<Node> initializers, 945 void compileInitializers(Link<Node> initializers,
940 CompileTimeConstantEvaluator evaluator, 946 CompileTimeConstantEvaluator evaluator,
941 TreeElements constructorElements, 947 TreeElements constructorElements,
942 Map<Element, Constant> constructorDefinitions) { 948 Map<Element, Constant> constructorDefinitions) {
943 for (Link<Node> link = initializers; !link.isEmpty(); link = link.tail) { 949 for (Link<Node> link = initializers; !link.isEmpty(); link = link.tail) {
944 assert(link.head is Send); 950 assert(link.head is Send);
945 if (link.head is !SendSet) { 951 if (link.head is !SendSet) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 return constant; 1021 return constant;
1016 } 1022 }
1017 1023
1018 error(Node node) { 1024 error(Node node) {
1019 // TODO(floitsch): get the list of constants that are currently compiled 1025 // TODO(floitsch): get the list of constants that are currently compiled
1020 // and present some kind of stack-trace. 1026 // and present some kind of stack-trace.
1021 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT; 1027 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT;
1022 compiler.reportError(node, new CompileTimeConstantError(kind, const [])); 1028 compiler.reportError(node, new CompileTimeConstantError(kind, const []));
1023 } 1029 }
1024 } 1030 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/compiler.dart » ('j') | frog/leg/elements/elements.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698