OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/code_generator.h" |
7 #include "vm/flags.h" | 8 #include "vm/flags.h" |
8 #include "vm/heap.h" | 9 #include "vm/heap.h" |
9 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
10 #include "vm/longjump.h" | 11 #include "vm/longjump.h" |
11 #include "vm/object_store.h" | 12 #include "vm/object_store.h" |
12 #include "vm/parser.h" | |
13 #include "vm/symbols.h" | 13 #include "vm/symbols.h" |
14 | 14 |
15 namespace dart { | 15 namespace dart { |
16 | 16 |
17 DEFINE_FLAG(bool, error_on_bad_override, false, | 17 DEFINE_FLAG(bool, error_on_bad_override, false, |
18 "Report error for bad overrides."); | 18 "Report error for bad overrides."); |
19 DEFINE_FLAG(bool, error_on_bad_type, false, | 19 DEFINE_FLAG(bool, error_on_bad_type, false, |
20 "Report error for malformed types."); | 20 "Report error for malformed types."); |
21 DEFINE_FLAG(bool, print_classes, false, "Prints details about loaded classes."); | 21 DEFINE_FLAG(bool, print_classes, false, "Prints details about loaded classes."); |
22 DEFINE_FLAG(bool, trace_class_finalization, false, "Trace class finalization."); | 22 DEFINE_FLAG(bool, trace_class_finalization, false, "Trace class finalization."); |
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2607 OS::Print(" %s\n", field.ToCString()); | 2607 OS::Print(" %s\n", field.ToCString()); |
2608 } | 2608 } |
2609 } | 2609 } |
2610 | 2610 |
2611 // Either report an error or mark the type as malformed. | 2611 // Either report an error or mark the type as malformed. |
2612 void ClassFinalizer::ReportMalformedType(const Error& prev_error, | 2612 void ClassFinalizer::ReportMalformedType(const Error& prev_error, |
2613 const Script& script, | 2613 const Script& script, |
2614 const Type& type, | 2614 const Type& type, |
2615 const char* format, | 2615 const char* format, |
2616 va_list args) { | 2616 va_list args) { |
2617 LanguageError& error = LanguageError::Handle(); | 2617 LanguageError& error = LanguageError::Handle( |
2618 if (prev_error.IsNull()) { | 2618 LanguageError::NewFormattedV( |
2619 error ^= Parser::FormatError( | 2619 prev_error, script, type.token_pos(), |
2620 script, type.token_pos(), "Error", format, args); | 2620 LanguageError::kMalformedType, Heap::kOld, |
2621 } else { | 2621 format, args)); |
2622 error ^= Parser::FormatErrorWithAppend( | |
2623 prev_error, script, type.token_pos(), "Error", format, args); | |
2624 } | |
2625 if (FLAG_error_on_bad_type) { | 2622 if (FLAG_error_on_bad_type) { |
2626 ReportError(error); | 2623 ReportError(error); |
2627 } | 2624 } |
2628 type.set_malformed_error(error); | 2625 type.set_malformed_error(error); |
2629 // Make the type raw, since it may not be possible to | 2626 // Make the type raw, since it may not be possible to |
2630 // properly finalize its type arguments. | 2627 // properly finalize its type arguments. |
2631 type.set_type_class(Class::Handle(Object::dynamic_class())); | 2628 type.set_type_class(Class::Handle(Object::dynamic_class())); |
2632 type.set_arguments(Object::null_abstract_type_arguments()); | 2629 type.set_arguments(Object::null_abstract_type_arguments()); |
2633 if (!type.IsFinalized()) { | 2630 if (!type.IsFinalized()) { |
2634 type.SetIsFinalized(); | 2631 type.SetIsFinalized(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2677 UNREACHABLE(); | 2674 UNREACHABLE(); |
2678 } | 2675 } |
2679 | 2676 |
2680 | 2677 |
2681 void ClassFinalizer::ReportError(const Error& prev_error, | 2678 void ClassFinalizer::ReportError(const Error& prev_error, |
2682 const Script& script, | 2679 const Script& script, |
2683 intptr_t token_pos, | 2680 intptr_t token_pos, |
2684 const char* format, ...) { | 2681 const char* format, ...) { |
2685 va_list args; | 2682 va_list args; |
2686 va_start(args, format); | 2683 va_start(args, format); |
2687 Error& error = Error::Handle(); | 2684 Error& error = Error::Handle( |
2688 if (prev_error.IsNull()) { | 2685 LanguageError::NewFormattedV( |
2689 error ^= Parser::FormatError(script, token_pos, "Error", format, args); | 2686 prev_error, script, token_pos, |
2690 } else { | 2687 LanguageError::kError, Heap::kNew, |
2691 error ^= Parser::FormatErrorWithAppend( | 2688 format, args)); |
2692 prev_error, script, token_pos, "Error", format, args); | |
2693 } | |
2694 va_end(args); | 2689 va_end(args); |
2695 ReportError(error); | 2690 ReportError(error); |
2696 } | 2691 } |
2697 | 2692 |
2698 | 2693 |
2699 void ClassFinalizer::VerifyImplicitFieldOffsets() { | 2694 void ClassFinalizer::VerifyImplicitFieldOffsets() { |
2700 #ifdef DEBUG | 2695 #ifdef DEBUG |
2701 Isolate* isolate = Isolate::Current(); | 2696 Isolate* isolate = Isolate::Current(); |
2702 const ClassTable& class_table = *(isolate->class_table()); | 2697 const ClassTable& class_table = *(isolate->class_table()); |
2703 Class& cls = Class::Handle(isolate); | 2698 Class& cls = Class::Handle(isolate); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2749 expected_name ^= String::New("_offset"); | 2744 expected_name ^= String::New("_offset"); |
2750 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 2745 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
2751 field ^= fields_array.At(2); | 2746 field ^= fields_array.At(2); |
2752 ASSERT(field.Offset() == TypedDataView::length_offset()); | 2747 ASSERT(field.Offset() == TypedDataView::length_offset()); |
2753 name ^= field.name(); | 2748 name ^= field.name(); |
2754 ASSERT(name.Equals("length")); | 2749 ASSERT(name.Equals("length")); |
2755 #endif | 2750 #endif |
2756 } | 2751 } |
2757 | 2752 |
2758 } // namespace dart | 2753 } // namespace dart |
OLD | NEW |