| 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } | 425 } |
| 426 | 426 |
| 427 lookupLocalMember(SourceString memberName) => imported[memberName]; | 427 lookupLocalMember(SourceString memberName) => imported[memberName]; |
| 428 | 428 |
| 429 Type computeType(Compiler compiler) => compiler.types.dynamicType; | 429 Type computeType(Compiler compiler) => compiler.types.dynamicType; |
| 430 | 430 |
| 431 Token position() => firstPosition; | 431 Token position() => firstPosition; |
| 432 } | 432 } |
| 433 | 433 |
| 434 class TypedefElement extends Element implements TypeDeclarationElement { | 434 class TypedefElement extends Element implements TypeDeclarationElement { |
| 435 Type cachedType; |
| 435 Typedef cachedNode; | 436 Typedef cachedNode; |
| 436 TypedefType cachedType; | |
| 437 Type alias; | |
| 438 | 437 |
| 439 TypedefElement(SourceString name, Element enclosing) | 438 TypedefElement(SourceString name, Element enclosing) |
| 440 : super(name, ElementKind.TYPEDEF, enclosing); | 439 : super(name, ElementKind.TYPEDEF, enclosing); |
| 441 | 440 |
| 442 /** | 441 Type computeType(Compiler compiler) { |
| 443 * Function signature for a typedef of a function type. The signature is | 442 if (cachedType !== null) return cachedType; |
| 444 * kept to provide full information about parameter names through the mirror | 443 cachedType = compiler.computeFunctionType( |
| 445 * system. | 444 this, compiler.resolveTypedef(this)); |
| 446 * | |
| 447 * The [functionSignature] is not available until the typedef element has been | |
| 448 * resolved. | |
| 449 */ | |
| 450 FunctionSignature functionSignature; | |
| 451 | |
| 452 TypedefType computeType(Compiler compiler) { | |
| 453 if (cachedType == null) { | |
| 454 Typedef node = parseNode(compiler); | |
| 455 Link<Type> parameters = | |
| 456 TypeDeclarationElement.createTypeVariables(this, node.typeParameters); | |
| 457 cachedType = new TypedefType(this, parameters); | |
| 458 } | |
| 459 return cachedType; | 445 return cachedType; |
| 460 } | 446 } |
| 461 | 447 |
| 462 Link<Type> get typeVariables() => cachedType.typeArguments; | 448 Link<Type> get typeVariables() => const EmptyLink<Type>(); |
| 463 | 449 |
| 464 Scope buildScope() => | 450 Scope buildScope() => |
| 465 new TypeDeclarationScope(enclosingElement.buildScope(), this); | 451 new TypeDeclarationScope(enclosingElement.buildScope(), this); |
| 466 } | 452 } |
| 467 | 453 |
| 468 class VariableElement extends Element { | 454 class VariableElement extends Element { |
| 469 final VariableListElement variables; | 455 final VariableListElement variables; |
| 470 Expression cachedNode; // The send or the identifier in the variables list. | 456 Expression cachedNode; // The send or the identifier in the variables list. |
| 471 | 457 |
| 472 Modifiers get modifiers() => variables.modifiers; | 458 Modifiers get modifiers() => variables.modifiers; |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 TypeVariableElement(name, Element enclosing, this.cachedNode, | 1248 TypeVariableElement(name, Element enclosing, this.cachedNode, |
| 1263 [this.type, this.bound]) | 1249 [this.type, this.bound]) |
| 1264 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1250 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1265 | 1251 |
| 1266 TypeVariableType computeType(compiler) => type; | 1252 TypeVariableType computeType(compiler) => type; |
| 1267 | 1253 |
| 1268 Node parseNode(compiler) => cachedNode; | 1254 Node parseNode(compiler) => cachedNode; |
| 1269 | 1255 |
| 1270 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1256 String toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1271 } | 1257 } |
| OLD | NEW |