| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 part of js_ast; | 5 part of js_ast; |
| 6 | 6 |
| 7 abstract class _TypePrinterBase implements TypeRefVisitor { | 7 abstract class _TypePrinterBase implements TypeRefVisitor { |
| 8 void out(String s); | 8 void out(String s); |
| 9 void visit(Node node); | 9 void visit(Node node); |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 } | 32 } |
| 33 | 33 |
| 34 @override | 34 @override |
| 35 visitQualifiedTypeRef(QualifiedTypeRef node) { | 35 visitQualifiedTypeRef(QualifiedTypeRef node) { |
| 36 outSeparated(".", node.path); | 36 outSeparated(".", node.path); |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 abstract class TypeScriptTypePrinter extends _TypePrinterBase { | 40 abstract class TypeScriptTypePrinter extends _TypePrinterBase { |
| 41 | |
| 42 void _outTypeAnnotation(TypeRef type) { | 41 void _outTypeAnnotation(TypeRef type) { |
| 43 if (type is OptionalTypeRef) { | 42 if (type is OptionalTypeRef) { |
| 44 out("?: "); | 43 out("?: "); |
| 45 visit(type.type); | 44 visit(type.type); |
| 46 } else { | 45 } else { |
| 47 out(": "); | 46 out(": "); |
| 48 visit(type); | 47 visit(type); |
| 49 } | 48 } |
| 50 } | 49 } |
| 51 | 50 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 if (selector is LiteralString) { | 150 if (selector is LiteralString) { |
| 152 visit(node.receiver); | 151 visit(node.receiver); |
| 153 out("."); | 152 out("."); |
| 154 out(selector.valueWithoutQuotes); | 153 out(selector.valueWithoutQuotes); |
| 155 } else { | 154 } else { |
| 156 assert(false); | 155 assert(false); |
| 157 out("?"); | 156 out("?"); |
| 158 } | 157 } |
| 159 } | 158 } |
| 160 | 159 |
| 161 @override toString() => _buffer.toString(); | 160 @override |
| 161 toString() => _buffer.toString(); |
| 162 | 162 |
| 163 @override | 163 @override |
| 164 visitArrayTypeRef(ArrayTypeRef node) { | 164 visitArrayTypeRef(ArrayTypeRef node) { |
| 165 out("Array"); | 165 out("Array"); |
| 166 if (node.elementType != null) { | 166 if (node.elementType != null) { |
| 167 out("<"); | 167 out("<"); |
| 168 visit(node.elementType); | 168 visit(node.elementType); |
| 169 out(">"); | 169 out(">"); |
| 170 } | 170 } |
| 171 } | 171 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 outSeparated(", ", node.paramTypes.values); | 217 outSeparated(", ", node.paramTypes.values); |
| 218 } | 218 } |
| 219 out(')'); | 219 out(')'); |
| 220 if (node.returnType != null) { | 220 if (node.returnType != null) { |
| 221 out(":"); | 221 out(":"); |
| 222 visit(node.returnType); | 222 visit(node.returnType); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 } | 226 } |
| OLD | NEW |