OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 package com.google.dart.compiler.resolver; | 5 package com.google.dart.compiler.resolver; |
6 | 6 |
7 import com.google.dart.compiler.DartCompilerContext; | 7 import com.google.dart.compiler.DartCompilerContext; |
8 import com.google.dart.compiler.DartCompilerErrorCode; | 8 import com.google.dart.compiler.DartCompilerErrorCode; |
9 import com.google.dart.compiler.ErrorCode; | 9 import com.google.dart.compiler.ErrorCode; |
10 import com.google.dart.compiler.ast.DartClass; | 10 import com.google.dart.compiler.ast.DartClass; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 return (ConstructorElement) e; | 216 return (ConstructorElement) e; |
217 } | 217 } |
218 // If the constructor name resolves to a class or there was an error, | 218 // If the constructor name resolves to a class or there was an error, |
219 // create the unnamed constructor. | 219 // create the unnamed constructor. |
220 return Elements.constructorFromMethodNode(method, "", (ClassElement) curre ntHolder, | 220 return Elements.constructorFromMethodNode(method, "", (ClassElement) curre ntHolder, |
221 (ClassElement) e); | 221 (ClassElement) e); |
222 } | 222 } |
223 | 223 |
224 private FieldElement buildField(DartField fieldNode, Type type) { | 224 private FieldElement buildField(DartField fieldNode, Type type) { |
225 assert !fieldNode.getModifiers().isAbstractField(); | 225 assert !fieldNode.getModifiers().isAbstractField(); |
226 Modifiers modifiers = fieldNode.getModifiers(); | |
227 if (modifiers.isFinal() && (modifiers.isStatic() || context == topLevelCon text)) { | |
228 // final toplevel fields are implicitly compile-time constants. | |
229 modifiers = modifiers.makeStatic(); | |
230 // Set the "const" modifier so that it is easy to compare a constant fie ld to other | |
231 // types of constant expressions. | |
232 modifiers = modifiers.makeConstant(); | |
233 } | |
ngeoffray
2011/10/17 10:59:38
Since all initializations must be constant, do you
zundel
2011/10/17 14:14:26
This is just for help in evaluating whether an exp
| |
226 FieldElement fieldElement = fieldNode.getSymbol(); | 234 FieldElement fieldElement = fieldNode.getSymbol(); |
227 if (fieldElement == null) { | 235 if (fieldElement == null) { |
228 fieldElement = Elements.fieldFromNode(fieldNode, currentHolder, fieldNod e.getModifiers()); | 236 fieldElement = Elements.fieldFromNode(fieldNode, currentHolder, modifier s); |
229 addField(currentHolder, fieldElement); | 237 addField(currentHolder, fieldElement); |
230 } else { | 238 } else { |
231 // This is a top-level element, and an element was already created in | 239 // This is a top-level element, and an element was already created in |
232 // TopLevelElementBuilder. | 240 // TopLevelElementBuilder. |
233 Elements.addField(currentHolder, fieldElement); | 241 Elements.addField(currentHolder, fieldElement); |
234 assertTopLevel(fieldNode); | 242 assertTopLevel(fieldNode); |
235 } | 243 } |
236 fieldElement.setType(type); | 244 fieldElement.setType(type); |
237 return recordElement(fieldNode, fieldElement); | 245 return recordElement(fieldNode, fieldElement); |
238 } | 246 } |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 } | 492 } |
485 } | 493 } |
486 return element; | 494 return element; |
487 } | 495 } |
488 | 496 |
489 void resolutionError(DartNode node, ErrorCode errorCode, Object... arguments ) { | 497 void resolutionError(DartNode node, ErrorCode errorCode, Object... arguments ) { |
490 topLevelContext.resolutionError(node, errorCode, arguments); | 498 topLevelContext.resolutionError(node, errorCode, arguments); |
491 } | 499 } |
492 } | 500 } |
493 } | 501 } |
OLD | NEW |