| 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 #include "vm/class_finalizer.h" | 5 #include "vm/class_finalizer.h" |
| 6 | 6 |
| 7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
| 8 #include "vm/heap.h" | 8 #include "vm/heap.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 } | 814 } |
| 815 | 815 |
| 816 return parameterized_type.Canonicalize(); | 816 return parameterized_type.Canonicalize(); |
| 817 } | 817 } |
| 818 | 818 |
| 819 | 819 |
| 820 void ClassFinalizer::ResolveAndFinalizeSignature(const Class& cls, | 820 void ClassFinalizer::ResolveAndFinalizeSignature(const Class& cls, |
| 821 const Function& function) { | 821 const Function& function) { |
| 822 // Resolve result type. | 822 // Resolve result type. |
| 823 AbstractType& type = AbstractType::Handle(function.result_type()); | 823 AbstractType& type = AbstractType::Handle(function.result_type()); |
| 824 FinalizationKind result_finalization = kFinalize; | 824 // In case of a factory, the parser sets the factory result type to a type |
| 825 if (function.IsFactory()) { | 825 // with an unresolved class whose name matches the factory name. |
| 826 // The name of a factory must always be resolved to a class or interface. | 826 // It is not a compile time error if this name does not resolve to a class or |
| 827 // The parser sets the factory result type to a type with an unresolved | 827 // interface. |
| 828 // class whose name matches the factory name. | 828 ResolveType(cls, type, kFinalize); |
| 829 result_finalization = kFinalizeWellFormed; | 829 type = FinalizeType(cls, type, kFinalize); |
| 830 // TODO(regis): Gilad asks if this compile-time error could be relaxed. | |
| 831 // The result type of such a factory method would simply be malformed. | |
| 832 } | |
| 833 ResolveType(cls, type, result_finalization); | |
| 834 type = FinalizeType(cls, type, result_finalization); | |
| 835 // In production mode, a malformed result type is mapped to Dynamic. | 830 // In production mode, a malformed result type is mapped to Dynamic. |
| 836 if (!FLAG_enable_type_checks && type.IsMalformed()) { | 831 if (!FLAG_enable_type_checks && type.IsMalformed()) { |
| 837 type = Type::DynamicType(); | 832 type = Type::DynamicType(); |
| 838 } | 833 } |
| 839 function.set_result_type(type); | 834 function.set_result_type(type); |
| 840 // Resolve formal parameter types. | 835 // Resolve formal parameter types. |
| 841 const intptr_t num_parameters = function.NumberOfParameters(); | 836 const intptr_t num_parameters = function.NumberOfParameters(); |
| 842 for (intptr_t i = 0; i < num_parameters; i++) { | 837 for (intptr_t i = 0; i < num_parameters; i++) { |
| 843 type = function.ParameterTypeAt(i); | 838 type = function.ParameterTypeAt(i); |
| 844 ResolveType(cls, type, kFinalize); | 839 ResolveType(cls, type, kFinalize); |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 void ClassFinalizer::ReportError(const char* format, ...) { | 1486 void ClassFinalizer::ReportError(const char* format, ...) { |
| 1492 va_list args; | 1487 va_list args; |
| 1493 va_start(args, format); | 1488 va_start(args, format); |
| 1494 const Error& error = Error::Handle( | 1489 const Error& error = Error::Handle( |
| 1495 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1490 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
| 1496 va_end(args); | 1491 va_end(args); |
| 1497 ReportError(error); | 1492 ReportError(error); |
| 1498 } | 1493 } |
| 1499 | 1494 |
| 1500 } // namespace dart | 1495 } // namespace dart |
| OLD | NEW |