Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: lib/compiler/implementation/elements/elements.dart

Issue 10830117: Port the remaining of dart:core to the unified corelib. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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, new VariableListElement.from(other.variables, enclosing),
453 other.kind, enclosing, other.cachedNode);
Mads Ager (google) 2012/08/01 13:48:34 These are arguments to the this call. Align as arg
Anders Johnsen 2012/08/01 14:21:09 Done.
448 454
449 Node parseNode(DiagnosticListener listener) { 455 Node parseNode(DiagnosticListener listener) {
450 if (cachedNode !== null) return cachedNode; 456 if (cachedNode !== null) return cachedNode;
451 VariableDefinitions definitions = variables.parseNode(listener); 457 VariableDefinitions definitions = variables.parseNode(listener);
452 for (Link<Node> link = definitions.definitions.nodes; 458 for (Link<Node> link = definitions.definitions.nodes;
453 !link.isEmpty(); link = link.tail) { 459 !link.isEmpty(); link = link.tail) {
454 Expression initializedIdentifier = link.head; 460 Expression initializedIdentifier = link.head;
455 Identifier identifier = initializedIdentifier.asIdentifier(); 461 Identifier identifier = initializedIdentifier.asIdentifier();
456 if (identifier === null) { 462 if (identifier === null) {
457 identifier = initializedIdentifier.asSendSet().selector.asIdentifier(); 463 identifier = initializedIdentifier.asSendSet().selector.asIdentifier();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 Element enclosing) 521 Element enclosing)
516 : super(null, kind, enclosing); 522 : super(null, kind, enclosing);
517 523
518 VariableListElement.node(VariableDefinitions node, 524 VariableListElement.node(VariableDefinitions node,
519 ElementKind kind, 525 ElementKind kind,
520 Element enclosing) 526 Element enclosing)
521 : super(null, kind, enclosing), 527 : super(null, kind, enclosing),
522 this.cachedNode = node, 528 this.cachedNode = node,
523 this.modifiers = node.modifiers; 529 this.modifiers = node.modifiers;
524 530
531 factory VariableListElement.from(VariableListElement other,
532 Element enclosing) {
533 var variableList;
534 if (other is PartialFieldListElement) {
535 variableList = new PartialFieldListElement(
536 other.beginToken, other.endToken, other.modifiers, enclosing);
537 } else {
538 variableList = new VariableListElement(other.kind, other.modifiers, enclos ing);
Mads Ager (google) 2012/08/01 13:48:34 Long line.
Anders Johnsen 2012/08/01 14:21:09 Done.
539 }
540 variableList.cachedNode = other.cachedNode;
541 variableList.type = other.type;
542 return variableList;
543 }
544
525 VariableDefinitions parseNode(DiagnosticListener listener) { 545 VariableDefinitions parseNode(DiagnosticListener listener) {
526 return cachedNode; 546 return cachedNode;
527 } 547 }
528 548
529 Type computeType(Compiler compiler) { 549 Type computeType(Compiler compiler) {
530 if (type != null) return type; 550 if (type != null) return type;
531 VariableDefinitions node = parseNode(compiler); 551 VariableDefinitions node = parseNode(compiler);
532 if (node.type !== null) { 552 if (node.type !== null) {
533 type = compiler.resolveTypeAnnotation(this, node.type); 553 type = compiler.resolveTypeAnnotation(this, node.type);
534 } else { 554 } else {
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 final Node node; 1202 final Node node;
1183 Type bound; 1203 Type bound;
1184 Type type; 1204 Type type;
1185 TypeVariableElement(name, Element enclosing, this.node, this.type, 1205 TypeVariableElement(name, Element enclosing, this.node, this.type,
1186 [this.bound]) 1206 [this.bound])
1187 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 1207 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
1188 Type computeType(compiler) => type; 1208 Type computeType(compiler) => type;
1189 Node parseNode(compiler) => node; 1209 Node parseNode(compiler) => node;
1190 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1210 toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1191 } 1211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698