OLD | NEW |
---|---|
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 void check(Node tree, TreeElements elements) { | 9 void check(Node tree, TreeElements elements) { |
10 measure(() { | 10 measure(() { |
(...skipping 30 matching lines...) Expand all Loading... | |
41 static final MAYBE_RETURNING = const StatementType('<maybe returning>'); | 41 static final MAYBE_RETURNING = const StatementType('<maybe returning>'); |
42 | 42 |
43 /** Combine the information about two control-flow edges that are joined. */ | 43 /** Combine the information about two control-flow edges that are joined. */ |
44 StatementType join(StatementType other) { | 44 StatementType join(StatementType other) { |
45 return (this === other) ? this : MAYBE_RETURNING; | 45 return (this === other) ? this : MAYBE_RETURNING; |
46 } | 46 } |
47 | 47 |
48 String toString() => stringName; | 48 String toString() => stringName; |
49 } | 49 } |
50 | 50 |
51 class SimpleType implements Type { | 51 class TypeVariable { |
ahe
2012/02/29 12:49:15
What is the purpose of this class?
karlklose
2012/03/30 11:56:40
Removed.
| |
52 final SourceString name; | 52 final SourceString name; |
53 final Element element; | 53 final Type value; |
ahe
2012/02/29 12:49:15
What is this?
karlklose
2012/03/30 11:56:40
Removed the class.
| |
54 const TypeVariable(this.name, [this.value]); | |
55 } | |
ngeoffray
2012/02/24 13:36:15
You can remove the code above.
karlklose
2012/03/30 11:56:40
Done.
| |
54 | 56 |
55 const SimpleType(SourceString this.name, Element this.element); | 57 class InterfaceType implements Type { |
58 final SourceString name; | |
59 final ClassElement element; | |
60 final Link<Type> arguments; | |
61 const InterfaceType(SourceString this.name, ClassElement this.element, | |
62 [Link<Type> arguments = const EmptyLink<Type>()]) | |
ahe
2012/02/29 12:49:15
Why not this.arguments?
karlklose
2012/03/30 11:56:40
Done.
| |
63 : this.arguments = arguments; | |
ngeoffray
2012/02/24 13:36:15
Add new line.
ngeoffray
2012/02/24 13:36:15
Do you think it'd be more robust to write:
this.ar
karlklose
2012/03/30 11:56:40
Done.
| |
64 toString() { | |
65 StringBuffer sb = new StringBuffer(); | |
66 sb.add(name); | |
67 bool first = true; | |
68 for (Link link = arguments; !link.isEmpty(); link = link.tail) { | |
ahe
2012/02/29 12:49:15
Could you use:
if (!arguments.isEmpty()) {
sb.ad
karlklose
2012/03/30 11:56:40
Done.
| |
69 sb.add(first ? '<' : ', '); | |
70 sb.add(link.head); | |
71 if (link.tail.isEmpty()) sb.add('>'); | |
72 first = false; | |
73 } | |
74 return sb.toString(); | |
75 } | |
76 } | |
56 | 77 |
78 // TODO(karlklose): merge into InterfaceType as a named constructor. | |
ahe
2012/02/29 12:49:15
+1
| |
79 class SimpleType extends InterfaceType { | |
80 const SimpleType(SourceString name, Element element) : super(name, element); | |
57 String toString() => name.toString(); | 81 String toString() => name.toString(); |
58 } | 82 } |
59 | 83 |
60 class FunctionType implements Type { | 84 class FunctionType implements Type { |
61 final Element element; | 85 final Element element; |
62 final Type returnType; | 86 final Type returnType; |
63 final Link<Type> parameterTypes; | 87 final Link<Type> parameterTypes; |
64 | 88 |
65 const FunctionType(Type this.returnType, Link<Type> this.parameterTypes, | 89 const FunctionType(Type this.returnType, Link<Type> this.parameterTypes, |
66 Element this.element); | 90 Element this.element); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 } | 651 } |
628 | 652 |
629 visitCatchBlock(CatchBlock node) { | 653 visitCatchBlock(CatchBlock node) { |
630 compiler.unimplemented('visitCatchBlock', node: node); | 654 compiler.unimplemented('visitCatchBlock', node: node); |
631 } | 655 } |
632 | 656 |
633 visitTypedef(Typedef node) { | 657 visitTypedef(Typedef node) { |
634 compiler.unimplemented('visitTypedef', node: node); | 658 compiler.unimplemented('visitTypedef', node: node); |
635 } | 659 } |
636 } | 660 } |
OLD | NEW |