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

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

Issue 10917285: Stub implementation of patch invariants for the patch refactoring. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 8 years, 3 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 class TypeCheckerTask extends CompilerTask { 5 class TypeCheckerTask extends CompilerTask {
6 TypeCheckerTask(Compiler compiler) : super(compiler); 6 TypeCheckerTask(Compiler compiler) : super(compiler);
7 String get name => "Type checker"; 7 String get name => "Type checker";
8 8
9 static const bool LOG_FAILURES = false; 9 static const bool LOG_FAILURES = false;
10 10
11 void check(Node tree, TreeElements elements) { 11 void check(Node tree, TreeElements elements) {
12 measure(() { 12 measure(() {
13 Visitor visitor = 13 Visitor visitor =
14 new TypeCheckerVisitor(compiler, elements, compiler.types); 14 new TypeCheckerVisitor(compiler, elements, compiler.types);
15 try { 15 try {
16 tree.accept(visitor); 16 tree.accept(visitor);
17 } on CancelTypeCheckException catch (e) { 17 } on CancelTypeCheckException catch (e) {
18 if (LOG_FAILURES) { 18 if (LOG_FAILURES) {
19 // Do not warn about unimplemented features; log message instead. 19 // Do not warn about unimplemented features; log message instead.
20 compiler.log("'${e.node}': ${e.reason}"); 20 compiler.log("'${e.node}': ${e.reason}");
21 } 21 }
22 } 22 }
23 }); 23 });
24 } 24 }
25 } 25 }
26 26
27 abstract class DartType implements Hashable { 27 abstract class DartType implements Hashable {
28 abstract SourceString get name; 28 abstract SourceString get name;
29 /**
30 * Returns the [Element] which declared this type.
31 *
32 * This can be [ClassElement] for classes, [TypedefElement] for typedefs,
33 * [TypeVariableElement] for type variables and [FunctionElement] for
34 * function types.
35 *
36 * Invariant: [element] must be a declaration element.
37 */
29 abstract Element get element; 38 abstract Element get element;
30 39
31 /** 40 /**
32 * Returns the unaliased type of this type. 41 * Returns the unaliased type of this type.
33 * 42 *
34 * The unaliased type of a typedef'd type is the unaliased type to which its 43 * The unaliased type of a typedef'd type is the unaliased type to which its
35 * name is bound. The unaliased version of any other type is the type itself. 44 * name is bound. The unaliased version of any other type is the type itself.
36 * 45 *
37 * For example, the unaliased type of [: typedef A Func<A,B>(B b) :] is the 46 * For example, the unaliased type of [: typedef A Func<A,B>(B b) :] is the
38 * function type [: (B) -> A :] and the unaliased type of 47 * function type [: (B) -> A :] and the unaliased type of
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return arguments == other.arguments; 156 return arguments == other.arguments;
148 } 157 }
149 } 158 }
150 159
151 class FunctionType implements DartType { 160 class FunctionType implements DartType {
152 final Element element; 161 final Element element;
153 DartType returnType; 162 DartType returnType;
154 Link<DartType> parameterTypes; 163 Link<DartType> parameterTypes;
155 164
156 FunctionType(DartType this.returnType, Link<DartType> this.parameterTypes, 165 FunctionType(DartType this.returnType, Link<DartType> this.parameterTypes,
157 Element this.element); 166 Element this.element) {
167 assert(element == null || invariant(element, element.isDeclaration));
ahe 2012/09/20 11:12:07 ===
Johnni Winther 2012/09/21 09:18:25 Done.
168 }
158 169
159 DartType unalias(Compiler compiler) => this; 170 DartType unalias(Compiler compiler) => this;
160 171
161 String toString() { 172 String toString() {
162 StringBuffer sb = new StringBuffer(); 173 StringBuffer sb = new StringBuffer();
163 bool first = true; 174 bool first = true;
164 sb.add('('); 175 sb.add('(');
165 parameterTypes.printOn(sb, ', '); 176 parameterTypes.printOn(sb, ', ');
166 sb.add(') -> ${returnType}'); 177 sb.add(') -> ${returnType}');
167 return sb.toString(); 178 return sb.toString();
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 } 917 }
907 918
908 visitCatchBlock(CatchBlock node) { 919 visitCatchBlock(CatchBlock node) {
909 return unhandledStatement(); 920 return unhandledStatement();
910 } 921 }
911 922
912 visitTypedef(Typedef node) { 923 visitTypedef(Typedef node) {
913 return unhandledStatement(); 924 return unhandledStatement();
914 } 925 }
915 } 926 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698