Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 927 return folded; | 927 return folded; |
| 928 } | 928 } |
| 929 return super.visitSend(send); | 929 return super.visitSend(send); |
| 930 } | 930 } |
| 931 | 931 |
| 932 visitSendSet(SendSet node) { | 932 visitSendSet(SendSet node) { |
| 933 error(node); | 933 error(node); |
| 934 } | 934 } |
| 935 | 935 |
| 936 Constant visitNewExpression(NewExpression node) { | 936 Constant visitNewExpression(NewExpression node) { |
| 937 Element currentElement = compiler.currentElement; | |
| 938 | |
| 937 void assignArgumentsToParameters( | 939 void assignArgumentsToParameters( |
| 938 FunctionParameters parameters, | 940 FunctionParameters parameters, |
| 939 Map<Element, Constant> constructorDefinitions, | 941 Map<Element, Constant> constructorDefinitions, |
| 940 Map<Element, Constant> fieldValues) { | 942 Map<Element, Constant> fieldValues) { |
| 941 Send send = node.send; | 943 Send send = node.send; |
| 942 if (send.arguments.isEmpty() && parameters.parameterCount == 0) return; | 944 if (send.arguments.isEmpty() && parameters.parameterCount == 0) return; |
| 943 List<Constant> arguments = <Constant>[]; | 945 List<Constant> arguments = <Constant>[]; |
| 944 Selector selector = elements.getSelector(send); | 946 Selector selector = elements.getSelector(send); |
| 945 | 947 |
| 946 Function compileArgument = evaluate; | 948 Function compileArgument = evaluate; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 992 if (member.isInstanceMember() && member.kind == ElementKind.FIELD) { | 994 if (member.isInstanceMember() && member.kind == ElementKind.FIELD) { |
| 993 Constant fieldValue = fieldValues[member]; | 995 Constant fieldValue = fieldValues[member]; |
| 994 if (fieldValue === null) { | 996 if (fieldValue === null) { |
| 995 // Use the default value. | 997 // Use the default value. |
| 996 fieldValue = constantHandler.compileVariable(member); | 998 fieldValue = constantHandler.compileVariable(member); |
| 997 } | 999 } |
| 998 jsNewArguments.add(fieldValue); | 1000 jsNewArguments.add(fieldValue); |
| 999 } | 1001 } |
| 1000 } | 1002 } |
| 1001 if (classElement.superclass != compiler.coreLibrary.find(Types.OBJECT)) { | 1003 if (classElement.superclass != compiler.coreLibrary.find(Types.OBJECT)) { |
| 1002 compiler.unimplemented("ConstantHandler with super", node: node); | 1004 compiler.withCurrentElement(currentElement, () { |
|
ngeoffray
2012/03/23 07:50:22
Why is that necessary? The withCurrentElement line
ahe
2012/03/23 11:30:31
That's the wrong element. It is the element for th
| |
| 1005 compiler.unimplemented("ConstantHandler with super", node: node); | |
| 1006 }); | |
| 1003 } | 1007 } |
| 1004 return jsNewArguments; | 1008 return jsNewArguments; |
| 1005 } | 1009 } |
| 1006 | 1010 |
| 1007 if (!node.isConst()) error(node); | 1011 if (!node.isConst()) error(node); |
| 1008 | 1012 |
| 1009 FunctionElement constructor = elements[node.send]; | 1013 FunctionElement constructor = elements[node.send]; |
| 1010 TreeElements constructorElements = | 1014 TreeElements constructorElements = |
| 1011 compiler.resolver.resolveMethodElement(constructor); | 1015 compiler.resolver.resolveMethodElement(constructor); |
| 1012 if (constructor != constructor.defaultImplementation) { | 1016 if (constructor != constructor.defaultImplementation) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 return constant; | 1056 return constant; |
| 1053 } | 1057 } |
| 1054 | 1058 |
| 1055 error(Node node) { | 1059 error(Node node) { |
| 1056 // TODO(floitsch): get the list of constants that are currently compiled | 1060 // TODO(floitsch): get the list of constants that are currently compiled |
| 1057 // and present some kind of stack-trace. | 1061 // and present some kind of stack-trace. |
| 1058 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT; | 1062 MessageKind kind = MessageKind.NOT_A_COMPILE_TIME_CONSTANT; |
| 1059 compiler.reportError(node, new CompileTimeConstantError(kind, const [])); | 1063 compiler.reportError(node, new CompileTimeConstantError(kind, const [])); |
| 1060 } | 1064 } |
| 1061 } | 1065 } |
| OLD | NEW |