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

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

Issue 206193002: Remove cancel and make crash exit with code 253. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 if (preSortCompare != null) { 219 if (preSortCompare != null) {
220 sorted.sort(preSortCompare); 220 sorted.sort(preSortCompare);
221 } 221 }
222 sorted.forEach(addConstant); 222 sorted.forEach(addConstant);
223 return result; 223 return result;
224 } 224 }
225 225
226 Constant getInitialValueFor(VariableElement element) { 226 Constant getInitialValueFor(VariableElement element) {
227 Constant initialValue = initialVariableValues[element.declaration]; 227 Constant initialValue = initialVariableValues[element.declaration];
228 if (initialValue == null) { 228 if (initialValue == null) {
229 compiler.internalError("No initial value for given element", 229 compiler.internalError(element, "No initial value for given element.");
230 element: element);
231 } 230 }
232 return initialValue; 231 return initialValue;
233 } 232 }
234 } 233 }
235 234
236 class CompileTimeConstantEvaluator extends Visitor { 235 class CompileTimeConstantEvaluator extends Visitor {
237 bool isEvaluatingConstant; 236 bool isEvaluatingConstant;
238 final ConstantHandler handler; 237 final ConstantHandler handler;
239 final TreeElements elements; 238 final TreeElements elements;
240 final Compiler compiler; 239 final Compiler compiler;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 case "!": 494 case "!":
496 folded = constantSystem.not.fold(receiverConstant); 495 folded = constantSystem.not.fold(receiverConstant);
497 break; 496 break;
498 case "-": 497 case "-":
499 folded = constantSystem.negate.fold(receiverConstant); 498 folded = constantSystem.negate.fold(receiverConstant);
500 break; 499 break;
501 case "~": 500 case "~":
502 folded = constantSystem.bitNot.fold(receiverConstant); 501 folded = constantSystem.bitNot.fold(receiverConstant);
503 break; 502 break;
504 default: 503 default:
505 compiler.internalError("Unexpected operator.", node: op); 504 compiler.internalError(op, "Unexpected operator.");
506 break; 505 break;
507 } 506 }
508 if (folded == null) return signalNotCompileTimeConstant(send); 507 if (folded == null) return signalNotCompileTimeConstant(send);
509 return folded; 508 return folded;
510 } else if (send.isOperator && !send.isPostfix) { 509 } else if (send.isOperator && !send.isPostfix) {
511 assert(send.argumentCount() == 1); 510 assert(send.argumentCount() == 1);
512 Constant left = evaluate(send.receiver); 511 Constant left = evaluate(send.receiver);
513 Constant right = evaluate(send.argumentsNode.nodes.head); 512 Constant right = evaluate(send.argumentsNode.nodes.head);
514 if (left == null || right == null) return null; 513 if (left == null || right == null) return null;
515 Operator op = send.selector.asOperator(); 514 Operator op = send.selector.asOperator();
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 compiler, 840 compiler,
842 isConst: true) { 841 isConst: true) {
843 assert(invariant(constructor, constructor.isImplementation)); 842 assert(invariant(constructor, constructor.isImplementation));
844 } 843 }
845 844
846 Constant visitSend(Send send) { 845 Constant visitSend(Send send) {
847 Element element = elements[send]; 846 Element element = elements[send];
848 if (Elements.isLocal(element)) { 847 if (Elements.isLocal(element)) {
849 Constant constant = definitions[element]; 848 Constant constant = definitions[element];
850 if (constant == null) { 849 if (constant == null) {
851 compiler.internalError("Local variable without value", node: send); 850 compiler.internalError(send, "Local variable without value.");
852 } 851 }
853 return constant; 852 return constant;
854 } 853 }
855 return super.visitSend(send); 854 return super.visitSend(send);
856 } 855 }
857 856
858 void potentiallyCheckType(Node node, 857 void potentiallyCheckType(Node node,
859 TypedElement element, 858 TypedElement element,
860 Constant constant) { 859 Constant constant) {
861 if (compiler.enableTypeAssertions) { 860 if (compiler.enableTypeAssertions) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 if (enclosingClass != compiler.objectClass) { 964 if (enclosingClass != compiler.objectClass) {
966 assert(superClass != null); 965 assert(superClass != null);
967 assert(superClass.resolutionState == STATE_DONE); 966 assert(superClass.resolutionState == STATE_DONE);
968 967
969 Selector selector = 968 Selector selector =
970 new Selector.callDefaultConstructor(enclosingClass.getLibrary()); 969 new Selector.callDefaultConstructor(enclosingClass.getLibrary());
971 970
972 FunctionElement targetConstructor = 971 FunctionElement targetConstructor =
973 superClass.lookupConstructor(selector); 972 superClass.lookupConstructor(selector);
974 if (targetConstructor == null) { 973 if (targetConstructor == null) {
975 compiler.internalError("no default constructor available", 974 compiler.internalError(functionNode,
976 node: functionNode); 975 "No default constructor available.");
977 } 976 }
978 List<Constant> compiledArguments = evaluateArgumentsToConstructor( 977 List<Constant> compiledArguments = evaluateArgumentsToConstructor(
979 functionNode, selector, const Link<Node>(), targetConstructor); 978 functionNode, selector, const Link<Node>(), targetConstructor);
980 evaluateSuperOrRedirectSend(compiledArguments, targetConstructor); 979 evaluateSuperOrRedirectSend(compiledArguments, targetConstructor);
981 } 980 }
982 } 981 }
983 } 982 }
984 983
985 /** 984 /**
986 * Simulates the execution of the [constructor] with the given 985 * Simulates the execution of the [constructor] with the given
(...skipping 15 matching lines...) Expand all
1002 if (fieldValue == null) { 1001 if (fieldValue == null) {
1003 // Use the default value. 1002 // Use the default value.
1004 fieldValue = handler.compileConstant(field); 1003 fieldValue = handler.compileConstant(field);
1005 } 1004 }
1006 jsNewArguments.add(fieldValue); 1005 jsNewArguments.add(fieldValue);
1007 }, 1006 },
1008 includeSuperAndInjectedMembers: true); 1007 includeSuperAndInjectedMembers: true);
1009 return jsNewArguments; 1008 return jsNewArguments;
1010 } 1009 }
1011 } 1010 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/closure.dart ('k') | sdk/lib/_internal/compiler/implementation/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698