| 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 final VariableListElement variables; | 437 final VariableListElement variables; |
| 438 Expression cachedNode; // The send or the identifier in the variables list. | 438 Expression cachedNode; // The send or the identifier in the variables list. |
| 439 | 439 |
| 440 Modifiers get modifiers() => variables.modifiers; | 440 Modifiers get modifiers() => variables.modifiers; |
| 441 | 441 |
| 442 VariableElement(SourceString name, | 442 VariableElement(SourceString name, |
| 443 VariableListElement this.variables, | 443 VariableListElement this.variables, |
| 444 ElementKind kind, | 444 ElementKind kind, |
| 445 Element enclosing, | 445 Element enclosing, |
| 446 [Node node]) | 446 [Node node]) |
| 447 : super(name, kind, enclosing), cachedNode = node; | 447 : super(name, kind, enclosing), cachedNode = node; |
| 448 |
| 449 VariableElement.from(SourceString name, |
| 450 VariableElement other, |
| 451 Element enclosing) |
| 452 : this(name, |
| 453 new VariableListElement.from(other.variables, enclosing), |
| 454 other.kind, |
| 455 enclosing, |
| 456 other.cachedNode); |
| 448 | 457 |
| 449 Node parseNode(DiagnosticListener listener) { | 458 Node parseNode(DiagnosticListener listener) { |
| 450 if (cachedNode !== null) return cachedNode; | 459 if (cachedNode !== null) return cachedNode; |
| 451 VariableDefinitions definitions = variables.parseNode(listener); | 460 VariableDefinitions definitions = variables.parseNode(listener); |
| 452 for (Link<Node> link = definitions.definitions.nodes; | 461 for (Link<Node> link = definitions.definitions.nodes; |
| 453 !link.isEmpty(); link = link.tail) { | 462 !link.isEmpty(); link = link.tail) { |
| 454 Expression initializedIdentifier = link.head; | 463 Expression initializedIdentifier = link.head; |
| 455 Identifier identifier = initializedIdentifier.asIdentifier(); | 464 Identifier identifier = initializedIdentifier.asIdentifier(); |
| 456 if (identifier === null) { | 465 if (identifier === null) { |
| 457 identifier = initializedIdentifier.asSendSet().selector.asIdentifier(); | 466 identifier = initializedIdentifier.asSendSet().selector.asIdentifier(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 Element enclosing) | 524 Element enclosing) |
| 516 : super(null, kind, enclosing); | 525 : super(null, kind, enclosing); |
| 517 | 526 |
| 518 VariableListElement.node(VariableDefinitions node, | 527 VariableListElement.node(VariableDefinitions node, |
| 519 ElementKind kind, | 528 ElementKind kind, |
| 520 Element enclosing) | 529 Element enclosing) |
| 521 : super(null, kind, enclosing), | 530 : super(null, kind, enclosing), |
| 522 this.cachedNode = node, | 531 this.cachedNode = node, |
| 523 this.modifiers = node.modifiers; | 532 this.modifiers = node.modifiers; |
| 524 | 533 |
| 534 factory VariableListElement.from(VariableListElement other, |
| 535 Element enclosing) { |
| 536 var variableList; |
| 537 if (other is PartialFieldListElement) { |
| 538 variableList = new PartialFieldListElement(other.beginToken, |
| 539 other.endToken, |
| 540 other.modifiers, |
| 541 enclosing); |
| 542 } else { |
| 543 variableList = new VariableListElement(other.kind, |
| 544 other.modifiers, |
| 545 enclosing); |
| 546 } |
| 547 variableList.cachedNode = other.cachedNode; |
| 548 variableList.type = other.type; |
| 549 return variableList; |
| 550 } |
| 551 |
| 525 VariableDefinitions parseNode(DiagnosticListener listener) { | 552 VariableDefinitions parseNode(DiagnosticListener listener) { |
| 526 return cachedNode; | 553 return cachedNode; |
| 527 } | 554 } |
| 528 | 555 |
| 529 Type computeType(Compiler compiler) { | 556 Type computeType(Compiler compiler) { |
| 530 if (type != null) return type; | 557 if (type != null) return type; |
| 531 VariableDefinitions node = parseNode(compiler); | 558 VariableDefinitions node = parseNode(compiler); |
| 532 if (node.type !== null) { | 559 if (node.type !== null) { |
| 533 type = compiler.resolveTypeAnnotation(this, node.type); | 560 type = compiler.resolveTypeAnnotation(this, node.type); |
| 534 } else { | 561 } else { |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 final Node node; | 1209 final Node node; |
| 1183 Type bound; | 1210 Type bound; |
| 1184 Type type; | 1211 Type type; |
| 1185 TypeVariableElement(name, Element enclosing, this.node, this.type, | 1212 TypeVariableElement(name, Element enclosing, this.node, this.type, |
| 1186 [this.bound]) | 1213 [this.bound]) |
| 1187 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1214 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1188 Type computeType(compiler) => type; | 1215 Type computeType(compiler) => type; |
| 1189 Node parseNode(compiler) => node; | 1216 Node parseNode(compiler) => node; |
| 1190 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1217 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1191 } | 1218 } |
| OLD | NEW |