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

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

Issue 10387033: Add VoidElement and VoidType to make sure that there is a canonical void type. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 const ElementKind('library', ElementCategory.NONE); 85 const ElementKind('library', ElementCategory.NONE);
86 static final ElementKind PREFIX = 86 static final ElementKind PREFIX =
87 const ElementKind('prefix', ElementCategory.PREFIX); 87 const ElementKind('prefix', ElementCategory.PREFIX);
88 static final ElementKind TYPEDEF = 88 static final ElementKind TYPEDEF =
89 const ElementKind('typedef', ElementCategory.ALIAS); 89 const ElementKind('typedef', ElementCategory.ALIAS);
90 90
91 static final ElementKind STATEMENT = 91 static final ElementKind STATEMENT =
92 const ElementKind('statement', ElementCategory.NONE); 92 const ElementKind('statement', ElementCategory.NONE);
93 static final ElementKind LABEL = 93 static final ElementKind LABEL =
94 const ElementKind('label', ElementCategory.NONE); 94 const ElementKind('label', ElementCategory.NONE);
95 static final ElementKind VOID =
96 const ElementKind('void', ElementCategory.NONE);
95 97
96 toString() => id; 98 toString() => id;
97 } 99 }
98 100
99 class Element implements Hashable { 101 class Element implements Hashable {
100 final SourceString name; 102 final SourceString name;
101 final ElementKind kind; 103 final ElementKind kind;
102 final Element enclosingElement; 104 final Element enclosingElement;
103 Modifiers get modifiers() => null; 105 Modifiers get modifiers() => null;
104 106
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 } 659 }
658 660
659 class SynthesizedConstructorElement extends FunctionElement { 661 class SynthesizedConstructorElement extends FunctionElement {
660 SynthesizedConstructorElement(Element enclosing) 662 SynthesizedConstructorElement(Element enclosing)
661 : super(enclosing.name, ElementKind.GENERATIVE_CONSTRUCTOR, 663 : super(enclosing.name, ElementKind.GENERATIVE_CONSTRUCTOR,
662 null, enclosing); 664 null, enclosing);
663 665
664 Token position() => enclosingElement.position(); 666 Token position() => enclosingElement.position();
665 } 667 }
666 668
669 class VoidElement extends Element {
670 VoidElement(Element enclosing)
671 : super(Types.VOID, ElementKind.VOID, enclosing);
ngeoffray 2012/05/09 08:54:40 Please add return types to the methods below.
karlklose 2012/05/09 10:32:41 Done.
672 computeType(compiler) => compiler.types.voidType;
673 parseNode(_) {
674 throw 'internal error: parseNode on void';
675 }
676 impliesType() => true;
677 }
678
667 class ClassElement extends ContainerElement { 679 class ClassElement extends ContainerElement {
668 Type type; 680 Type type;
669 Type supertype; 681 Type supertype;
670 Type defaultClass; 682 Type defaultClass;
671 Link<Element> members = const EmptyLink<Element>(); 683 Link<Element> members = const EmptyLink<Element>();
672 Map<SourceString, Element> localMembers; 684 Map<SourceString, Element> localMembers;
673 Map<SourceString, Element> constructors; 685 Map<SourceString, Element> constructors;
674 Link<Type> interfaces = const EmptyLink<Type>(); 686 Link<Type> interfaces = const EmptyLink<Type>();
675 LinkedHashMap<SourceString, TypeVariableElement> typeParameters; 687 LinkedHashMap<SourceString, TypeVariableElement> typeParameters;
676 bool isResolved = false; 688 bool isResolved = false;
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 final Node node; 1042 final Node node;
1031 Type bound; 1043 Type bound;
1032 Type type; 1044 Type type;
1033 TypeVariableElement(name, Element enclosing, this.node, this.type, 1045 TypeVariableElement(name, Element enclosing, this.node, this.type,
1034 [this.bound]) 1046 [this.bound])
1035 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 1047 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
1036 Type computeType(compiler) => type; 1048 Type computeType(compiler) => type;
1037 Node parseNode(compiler) => node; 1049 Node parseNode(compiler) => node;
1038 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1050 toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1039 } 1051 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698