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

Side by Side Diff: dart/frog/leg/elements/elements.dart

Issue 9241014: Generate AST nodes for field initializers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: changes Created 8 years, 11 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
« no previous file with comments | « no previous file | dart/frog/leg/resolver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 final Script script; 87 final Script script;
88 CompilationUnitElement(Script script, Element enclosing) 88 CompilationUnitElement(Script script, Element enclosing)
89 : super(new SourceString(script.name), 89 : super(new SourceString(script.name),
90 ElementKind.COMPILATION_UNIT, 90 ElementKind.COMPILATION_UNIT,
91 enclosing), 91 enclosing),
92 this.script = script; 92 this.script = script;
93 } 93 }
94 94
95 class VariableElement extends Element { 95 class VariableElement extends Element {
96 final VariableListElement variables; 96 final VariableListElement variables;
97 final Node node; // The send or the identifier in the variables list. 97 Expression node; // The send or the identifier in the variables list.
98 98
99 Modifiers get modifiers() => variables.modifiers; 99 Modifiers get modifiers() => variables.modifiers;
100 100
101 VariableElement(SourceString name, 101 VariableElement(SourceString name,
102 Node this.node,
103 VariableListElement this.variables, 102 VariableListElement this.variables,
104 ElementKind kind, 103 ElementKind kind,
105 Element enclosing) 104 Element enclosing)
106 : super(name, kind, enclosing); 105 : super(name, kind, enclosing);
107 106
108 Node parseNode(Canceler canceler, Logger logger) { 107 Node parseNode(Canceler canceler, Logger logger) {
109 assert(node != null); 108 if (node !== null) return node;
110 return node; 109 VariableDefinitions definitions = variables.parseNode(canceler, logger);
110 for (Link<Node> link = definitions.definitions.nodes;
111 !link.isEmpty(); link = link.tail) {
112 Expression initializedIdentifier = link.head;
113 Identifier identifier = initializedIdentifier.asIdentifier();
114 if (identifier === null) {
115 identifier = initializedIdentifier.asSendSet().selector.asIdentifier();
116 }
117 if (name === identifier.source) {
118 node = initializedIdentifier;
119 return node;
120 }
121 }
122 canceler.cancel('internal error: could not find $name', node: variables);
111 } 123 }
112 124
113 Type computeType(Compiler compiler) { 125 Type computeType(Compiler compiler) {
114 return variables.computeType(compiler); 126 return variables.computeType(compiler);
115 } 127 }
116 128
117 Type get type() => variables.type; 129 Type get type() => variables.type;
118 130
119 bool isInstanceMember() { 131 bool isInstanceMember() {
120 return isMember() && !modifiers.isStatic(); 132 return isMember() && !modifiers.isStatic();
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (send.isPropertyAccess) return false; 401 if (send.isPropertyAccess) return false;
390 if (send.receiver !== null) return false; 402 if (send.receiver !== null) return false;
391 Element element = elements[send]; 403 Element element = elements[send];
392 // (o)() or foo()(). 404 // (o)() or foo()().
393 if (element === null && send.selector.asIdentifier() === null) return true; 405 if (element === null && send.selector.asIdentifier() === null) return true;
394 if (element === null) return false; 406 if (element === null) return false;
395 // foo() with foo a local or a parameter. 407 // foo() with foo a local or a parameter.
396 return element.isVariable() || element.isParameter(); 408 return element.isVariable() || element.isParameter();
397 } 409 }
398 } 410 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698