OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart_codegen; | 5 library dart_codegen; |
6 | 6 |
7 import 'dart_tree.dart' as tree; | 7 import 'dart_tree.dart' as tree; |
8 import 'dart_printer.dart'; | 8 import 'dart_printer.dart'; |
9 import 'dart_tree_printer.dart' show TreePrinter; | 9 import 'dart_tree_printer.dart' show TreePrinter; |
10 import '../tree/tree.dart' as frontend; | 10 import '../tree/tree.dart' as frontend; |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 } else if (type is VoidType) { | 547 } else if (type is VoidType) { |
548 return new TypeAnnotation('void') | 548 return new TypeAnnotation('void') |
549 ..dartType = type; | 549 ..dartType = type; |
550 } else if (type is TypeVariableType) { | 550 } else if (type is TypeVariableType) { |
551 return new TypeAnnotation(type.name) | 551 return new TypeAnnotation(type.name) |
552 ..dartType = type; | 552 ..dartType = type; |
553 } else if (type is DynamicType) { | 553 } else if (type is DynamicType) { |
554 return new TypeAnnotation("dynamic") | 554 return new TypeAnnotation("dynamic") |
555 ..dartType = type; | 555 ..dartType = type; |
556 } else if (type is MalformedType) { | 556 } else if (type is MalformedType) { |
557 // treat malformed types as dynamic | 557 return new TypeAnnotation(type.name) |
558 return new TypeAnnotation("dynamic") | 558 ..dartType = type; |
559 ..dartType = const DynamicType(); | |
560 } else { | 559 } else { |
561 throw "Unsupported type annotation: $type"; | 560 throw "Unsupported type annotation: $type"; |
562 } | 561 } |
563 } | 562 } |
564 | 563 |
565 /// Like [emitType] except the dynamic type is converted to null. | 564 /// Like [emitType] except the dynamic type is converted to null. |
566 TypeAnnotation emitOptionalType(DartType type) { | 565 TypeAnnotation emitOptionalType(DartType type) { |
567 if (type.treatAsDynamic) { | 566 if (type.treatAsDynamic) { |
568 return null; | 567 return null; |
569 } else { | 568 } else { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 return new Identifier(name) | 639 return new Identifier(name) |
641 ..element = exp.element; | 640 ..element = exp.element; |
642 } | 641 } |
643 | 642 |
644 Expression visitFunction(FunctionConstExp exp) { | 643 Expression visitFunction(FunctionConstExp exp) { |
645 return new Identifier(exp.element.name) | 644 return new Identifier(exp.element.name) |
646 ..element = exp.element; | 645 ..element = exp.element; |
647 } | 646 } |
648 | 647 |
649 } | 648 } |
OLD | NEW |