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

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

Issue 9283031: Build script tags. (Closed) Base URL: ssh://aaricia.aar/home/ahe/Dart/all/dart.googlecode.com.git@script
Patch Set: Address review comments 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
« no previous file with comments | « dart/frog/leg/compiler.dart ('k') | 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 toString() => id; 44 toString() => id;
45 } 45 }
46 46
47 class Element implements Hashable { 47 class Element implements Hashable {
48 final SourceString name; 48 final SourceString name;
49 final ElementKind kind; 49 final ElementKind kind;
50 final Element enclosingElement; 50 final Element enclosingElement;
51 Modifiers get modifiers() => null; 51 Modifiers get modifiers() => null;
52 52
53
54 Node parseNode(Canceler canceler, Logger logger) { 53 Node parseNode(Canceler canceler, Logger logger) {
55 canceler.cancel("Internal Error: Element.parseNode"); 54 canceler.cancel("Internal Error: Element.parseNode");
56 } 55 }
57 56
58 Type computeType(Compiler compiler) { 57 Type computeType(Compiler compiler) {
59 compiler.internalError("Element.computeType."); 58 compiler.internalError("Element.computeType.");
60 } 59 }
61 60
62 bool isFunction() => kind == ElementKind.FUNCTION; 61 bool isFunction() => kind == ElementKind.FUNCTION;
63 bool isMember() => 62 bool isMember() =>
(...skipping 16 matching lines...) Expand all
80 const Element(this.name, this.kind, this.enclosingElement); 79 const Element(this.name, this.kind, this.enclosingElement);
81 80
82 // TODO(kasperl): This is a very bad hash code for the element and 81 // TODO(kasperl): This is a very bad hash code for the element and
83 // there's no reason why two elements with the same name should have 82 // there's no reason why two elements with the same name should have
84 // the same hash code. Replace this with a simple id in the element? 83 // the same hash code. Replace this with a simple id in the element?
85 int hashCode() => name.hashCode(); 84 int hashCode() => name.hashCode();
86 85
87 toString() => '$kind($name)'; 86 toString() => '$kind($name)';
88 } 87 }
89 88
90 class CompilationUnitElement extends Element { 89 class ContainerElement extends Element {
90 ContainerElement(name, kind, enclosingElement) :
91 super(name, kind, enclosingElement);
92
93 abstract void addMember(Element element, Canceler canceler);
94 }
95
96 class CompilationUnitElement extends ContainerElement {
91 final Script script; 97 final Script script;
98 Link<Element> topLevelElements = const EmptyLink<Element>();
99 Link<ScriptTag> tags = const EmptyLink<ScriptTag>();
100
92 CompilationUnitElement(Script script, Element enclosing) 101 CompilationUnitElement(Script script, Element enclosing)
93 : super(new SourceString(script.name), 102 : super(new SourceString(script.name),
94 ElementKind.COMPILATION_UNIT, 103 ElementKind.COMPILATION_UNIT,
95 enclosing), 104 enclosing),
96 this.script = script; 105 this.script = script;
106
107 void addMember(Element element, Canceler canceler) {
108 topLevelElements = topLevelElements.prepend(element);
109 }
110
111 void addTag(ScriptTag tag) {
112 tags = tags.prepend(tag);
113 }
97 } 114 }
98 115
99 class VariableElement extends Element { 116 class VariableElement extends Element {
100 final VariableListElement variables; 117 final VariableListElement variables;
101 Expression cachedNode; // The send or the identifier in the variables list. 118 Expression cachedNode; // The send or the identifier in the variables list.
102 119
103 Modifiers get modifiers() => variables.modifiers; 120 Modifiers get modifiers() => variables.modifiers;
104 121
105 VariableElement(SourceString name, 122 VariableElement(SourceString name,
106 VariableListElement this.variables, 123 VariableListElement this.variables,
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 new Identifier.synthetic(''), 339 new Identifier.synthetic(''),
323 new NodeList.empty(), 340 new NodeList.empty(),
324 new Block(new NodeList.empty()), 341 new Block(new NodeList.empty()),
325 null, null, null); 342 null, null, null);
326 return cachedNode; 343 return cachedNode;
327 } 344 }
328 345
329 Token position() => null; 346 Token position() => null;
330 } 347 }
331 348
332 class ClassElement extends Element { 349 class ClassElement extends ContainerElement {
333 Type type; 350 Type type;
334 Type supertype; 351 Type supertype;
335 Link<Element> members = const EmptyLink<Element>(); 352 Link<Element> members = const EmptyLink<Element>();
336 Map<SourceString, Element> localMembers; 353 Map<SourceString, Element> localMembers;
337 Map<SourceString, Element> constructors; 354 Map<SourceString, Element> constructors;
338 Link<Type> interfaces = const EmptyLink<Type>(); 355 Link<Type> interfaces = const EmptyLink<Type>();
339 bool isResolved = false; 356 bool isResolved = false;
340 // backendMembers are members that have been added by the backend to simplify 357 // backendMembers are members that have been added by the backend to simplify
341 // compilation. They don't have any user-side counter-part. 358 // compilation. They don't have any user-side counter-part.
342 Link<Element> backendMembers = const EmptyLink<Element>(); 359 Link<Element> backendMembers = const EmptyLink<Element>();
343 SynthesizedConstructorElement synthesizedConstructor; 360 SynthesizedConstructorElement synthesizedConstructor;
344 361
345 ClassElement(SourceString name, CompilationUnitElement enclosing) 362 ClassElement(SourceString name, CompilationUnitElement enclosing)
346 : localMembers = new Map<SourceString, Element>(), 363 : localMembers = new Map<SourceString, Element>(),
347 constructors = new Map<SourceString, Element>(), 364 constructors = new Map<SourceString, Element>(),
348 super(name, ElementKind.CLASS, enclosing); 365 super(name, ElementKind.CLASS, enclosing);
349 366
350 void addMember(Element element) { 367 void addMember(Element element, Canceler canceler) {
351 members = members.prepend(element); 368 members = members.prepend(element);
352 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR || 369 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR ||
353 element.modifiers.isFactory()) { 370 element.modifiers.isFactory()) {
354 constructors[element.name] = element; 371 constructors[element.name] = element;
355 } else { 372 } else {
356 localMembers[element.name] = element; 373 localMembers[element.name] = element;
357 } 374 }
358 } 375 }
359 376
360 Type computeType(compiler) { 377 Type computeType(compiler) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 if (send.isPropertyAccess) return false; 455 if (send.isPropertyAccess) return false;
439 if (send.receiver !== null) return false; 456 if (send.receiver !== null) return false;
440 Element element = elements[send]; 457 Element element = elements[send];
441 // (o)() or foo()(). 458 // (o)() or foo()().
442 if (element === null && send.selector.asIdentifier() === null) return true; 459 if (element === null && send.selector.asIdentifier() === null) return true;
443 if (element === null) return false; 460 if (element === null) return false;
444 // foo() with foo a local or a parameter. 461 // foo() with foo a local or a parameter.
445 return element.isVariable() || element.isParameter(); 462 return element.isVariable() || element.isParameter();
446 } 463 }
447 } 464 }
OLDNEW
« no previous file with comments | « dart/frog/leg/compiler.dart ('k') | dart/frog/leg/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698