| 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 static final bool LOG_FAILURES = false; | 9 static final bool LOG_FAILURES = false; |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 /** Combine the information about two control-flow edges that are joined. */ | 55 /** Combine the information about two control-flow edges that are joined. */ |
| 56 StatementType join(StatementType other) { | 56 StatementType join(StatementType other) { |
| 57 return (this === other) ? this : MAYBE_RETURNING; | 57 return (this === other) ? this : MAYBE_RETURNING; |
| 58 } | 58 } |
| 59 | 59 |
| 60 String toString() => stringName; | 60 String toString() => stringName; |
| 61 } | 61 } |
| 62 | 62 |
| 63 class InterfaceType implements Type { | 63 class InterfaceType implements Type { |
| 64 final SourceString name; | |
| 65 final Element element; | 64 final Element element; |
| 66 final Link<Type> arguments; | 65 final Link<Type> arguments; |
| 67 | 66 |
| 68 const InterfaceType(this.name, this.element, | 67 const InterfaceType(this.element, |
| 69 [this.arguments = const EmptyLink<Type>()]); | 68 [this.arguments = const EmptyLink<Type>()]); |
| 70 | 69 |
| 70 SourceString get name() => element.name; |
| 71 |
| 71 toString() { | 72 toString() { |
| 72 StringBuffer sb = new StringBuffer(); | 73 StringBuffer sb = new StringBuffer(); |
| 73 sb.add(name.slowToString()); | 74 sb.add(name.slowToString()); |
| 74 if (!arguments.isEmpty()) { | 75 if (!arguments.isEmpty()) { |
| 75 sb.add('<'); | 76 sb.add('<'); |
| 76 arguments.printOn(sb); | 77 arguments.printOn(sb, ', '); |
| 77 sb.add('>'); | 78 sb.add('>'); |
| 78 } | 79 } |
| 79 return sb.toString(); | 80 return sb.toString(); |
| 80 } | 81 } |
| 81 } | 82 } |
| 82 | 83 |
| 83 class FunctionType implements Type { | 84 class FunctionType implements Type { |
| 84 final Element element; | 85 final Element element; |
| 85 final Type returnType; | 86 final Type returnType; |
| 86 final Link<Type> parameterTypes; | 87 final Link<Type> parameterTypes; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 111 static final LIST = const SourceString('List'); | 112 static final LIST = const SourceString('List'); |
| 112 | 113 |
| 113 final InterfaceType voidType; | 114 final InterfaceType voidType; |
| 114 final InterfaceType dynamicType; | 115 final InterfaceType dynamicType; |
| 115 | 116 |
| 116 Types(Element dynamicElement) | 117 Types(Element dynamicElement) |
| 117 : this.with(dynamicElement, new LibraryElement(new Script(null, null))); | 118 : this.with(dynamicElement, new LibraryElement(new Script(null, null))); |
| 118 | 119 |
| 119 // TODO(karlklose): should we have a class Void? | 120 // TODO(karlklose): should we have a class Void? |
| 120 Types.with(Element dynamicElement, LibraryElement library) | 121 Types.with(Element dynamicElement, LibraryElement library) |
| 121 : voidType = new InterfaceType(VOID, new ClassElement(VOID, library)), | 122 : voidType = new InterfaceType(new ClassElement(VOID, library)), |
| 122 dynamicType = new InterfaceType(DYNAMIC, dynamicElement); | 123 dynamicType = new InterfaceType(dynamicElement); |
| 123 | 124 |
| 124 Type lookup(SourceString s) { | 125 Type lookup(SourceString s) { |
| 125 if (VOID == s) { | 126 if (VOID == s) { |
| 126 return voidType; | 127 return voidType; |
| 127 } else if (DYNAMIC == s || s.stringValue === 'var') { | 128 } else if (DYNAMIC == s || s.stringValue === 'var') { |
| 128 return dynamicType; | 129 return dynamicType; |
| 129 } | 130 } |
| 130 return null; | 131 return null; |
| 131 } | 132 } |
| 132 | 133 |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 } | 728 } |
| 728 | 729 |
| 729 visitCatchBlock(CatchBlock node) { | 730 visitCatchBlock(CatchBlock node) { |
| 730 fail(node); | 731 fail(node); |
| 731 } | 732 } |
| 732 | 733 |
| 733 visitTypedef(Typedef node) { | 734 visitTypedef(Typedef node) { |
| 734 fail(node); | 735 fail(node); |
| 735 } | 736 } |
| 736 } | 737 } |
| OLD | NEW |