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 #library('elements'); | 5 #library('elements'); |
| 6 | 6 |
| 7 #import('../tree/tree.dart'); | 7 #import('../tree/tree.dart'); |
| 8 #import('../scanner/scannerlib.dart'); | 8 #import('../scanner/scannerlib.dart'); |
| 9 #import('../leg.dart'); // TODO(karlklose): we only need type. | 9 #import('../leg.dart'); // TODO(karlklose): we only need type. |
| 10 #import('../util/util.dart'); | 10 #import('../util/util.dart'); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 super(prefix, ElementKind.PREFIX, enclosing); | 326 super(prefix, ElementKind.PREFIX, enclosing); |
| 327 | 327 |
| 328 lookupLocalMember(SourceString memberName) => imported[memberName]; | 328 lookupLocalMember(SourceString memberName) => imported[memberName]; |
| 329 | 329 |
| 330 Type computeType(Compiler compiler) => compiler.types.dynamicType; | 330 Type computeType(Compiler compiler) => compiler.types.dynamicType; |
| 331 | 331 |
| 332 Token position() => firstPosition; | 332 Token position() => firstPosition; |
| 333 } | 333 } |
| 334 | 334 |
| 335 class TypedefElement extends Element { | 335 class TypedefElement extends Element { |
| 336 Token token; | 336 final Token token; |
| 337 Type cachedType; | |
| 338 | |
| 337 TypedefElement(SourceString name, Element enclosing, this.token) | 339 TypedefElement(SourceString name, Element enclosing, this.token) |
| 338 : super(name, ElementKind.TYPEDEF, enclosing); | 340 : super(name, ElementKind.TYPEDEF, enclosing); |
| 339 | 341 |
| 340 position() => findMyName(token); | 342 position() => findMyName(token); |
| 343 | |
| 344 Type computeType(Compiler compiler) { | |
| 345 if (cachedType === null) { | |
| 346 cachedType = new InterfaceType(name, this); | |
|
ahe
2012/04/19 08:20:06
This could be set in the constructor.
karlklose
2012/04/25 11:45:43
Done.
| |
| 347 } | |
| 348 return cachedType; | |
| 349 } | |
| 341 } | 350 } |
| 342 | 351 |
| 343 class VariableElement extends Element { | 352 class VariableElement extends Element { |
| 344 final VariableListElement variables; | 353 final VariableListElement variables; |
| 345 Expression cachedNode; // The send or the identifier in the variables list. | 354 Expression cachedNode; // The send or the identifier in the variables list. |
| 346 | 355 |
| 347 Modifiers get modifiers() => variables.modifiers; | 356 Modifiers get modifiers() => variables.modifiers; |
| 348 | 357 |
| 349 VariableElement(SourceString name, | 358 VariableElement(SourceString name, |
| 350 VariableListElement this.variables, | 359 VariableListElement this.variables, |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 final Node node; | 1025 final Node node; |
| 1017 Type bound; | 1026 Type bound; |
| 1018 Type type; | 1027 Type type; |
| 1019 TypeVariableElement(name, Element enclosing, this.node, this.type, | 1028 TypeVariableElement(name, Element enclosing, this.node, this.type, |
| 1020 [this.bound]) | 1029 [this.bound]) |
| 1021 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1030 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1022 Type computeType(compiler) => type; | 1031 Type computeType(compiler) => type; |
| 1023 Node parseNode(compiler) => node; | 1032 Node parseNode(compiler) => node; |
| 1024 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1033 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1025 } | 1034 } |
| OLD | NEW |