| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 void ClassFinalizer::FinalizeType(const Type& type) { | 431 void ClassFinalizer::FinalizeType(const Type& type) { |
| 432 ASSERT(type.IsResolved()); | 432 ASSERT(type.IsResolved()); |
| 433 if (type.IsFinalized()) { | 433 if (type.IsFinalized()) { |
| 434 return; | 434 return; |
| 435 } | 435 } |
| 436 | 436 |
| 437 // At this point, we can only have a parameterized_type. | 437 // At this point, we can only have a parameterized_type. |
| 438 ParameterizedType& parameterized_type = ParameterizedType::Handle(); | 438 ParameterizedType& parameterized_type = ParameterizedType::Handle(); |
| 439 parameterized_type ^= type.raw(); | 439 parameterized_type ^= type.raw(); |
| 440 | 440 |
| 441 if (parameterized_type.is_being_finalized()) { | 441 if (parameterized_type.IsBeingFinalized()) { |
| 442 ReportError("type '%s' illegally refers to itself\n", | 442 ReportError("type '%s' illegally refers to itself\n", |
| 443 String::Handle(parameterized_type.Name()).ToCString()); | 443 String::Handle(parameterized_type.Name()).ToCString()); |
| 444 } | 444 } |
| 445 | 445 |
| 446 // Mark type as being finalized in order to detect illegal self reference. | 446 // Mark type as being finalized in order to detect illegal self reference. |
| 447 parameterized_type.set_is_being_finalized(); | 447 parameterized_type.set_is_being_finalized(); |
| 448 | 448 |
| 449 // Finalize the current type arguments of the type, which are still the | 449 // Finalize the current type arguments of the type, which are still the |
| 450 // parsed type arguments. | 450 // parsed type arguments. |
| 451 TypeArguments& arguments = | 451 TypeArguments& arguments = |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 // are canonicalized and finalized upon creation, since all the types they | 533 // are canonicalized and finalized upon creation, since all the types they |
| 534 // reference are already resolved. | 534 // reference are already resolved. |
| 535 void ClassFinalizer::ResolveAndFinalizeSignature(const Class& cls, | 535 void ClassFinalizer::ResolveAndFinalizeSignature(const Class& cls, |
| 536 const Function& function) { | 536 const Function& function) { |
| 537 // Resolve result type. | 537 // Resolve result type. |
| 538 Type& type = Type::Handle(function.result_type()); | 538 Type& type = Type::Handle(function.result_type()); |
| 539 type = ResolveType(cls, type); | 539 type = ResolveType(cls, type); |
| 540 function.set_result_type(type); | 540 function.set_result_type(type); |
| 541 FinalizeType(type); | 541 FinalizeType(type); |
| 542 // Resolve formal parameter types. | 542 // Resolve formal parameter types. |
| 543 intptr_t num_parameters = function.NumberOfParameters(); | 543 const intptr_t num_parameters = function.NumberOfParameters(); |
| 544 for (intptr_t p = 0; p < num_parameters; p++) { | 544 for (intptr_t i = 0; i < num_parameters; i++) { |
| 545 type = function.ParameterTypeAt(p); | 545 type = function.ParameterTypeAt(i); |
| 546 type = ResolveType(cls, type); | 546 type = ResolveType(cls, type); |
| 547 function.SetParameterTypeAt(p, type); | 547 function.SetParameterTypeAt(i, type); |
| 548 FinalizeType(type); | 548 FinalizeType(type); |
| 549 } | 549 } |
| 550 } | 550 } |
| 551 | 551 |
| 552 | 552 |
| 553 static bool FuncNameExistsInSuper(const Class& cls, | 553 static bool FuncNameExistsInSuper(const Class& cls, |
| 554 const String& name) { | 554 const String& name) { |
| 555 Class& super_class = Class::Handle(); | 555 Class& super_class = Class::Handle(); |
| 556 Function& function = Function::Handle(); | 556 Function& function = Function::Handle(); |
| 557 super_class = cls.SuperClass(); | 557 super_class = cls.SuperClass(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 } | 635 } |
| 636 if (function.kind() == RawFunction::kSetterFunction) { | 636 if (function.kind() == RawFunction::kSetterFunction) { |
| 637 name = String::New("set:"); | 637 name = String::New("set:"); |
| 638 name = String::SubString(func_name, name.Length()); | 638 name = String::SubString(func_name, name.Length()); |
| 639 if (FuncNameExistsInSuper(cls, name)) { | 639 if (FuncNameExistsInSuper(cls, name)) { |
| 640 ReportError("'%s' overrides a function in the super class.\n", | 640 ReportError("'%s' overrides a function in the super class.\n", |
| 641 func_name.ToCString()); | 641 func_name.ToCString()); |
| 642 } | 642 } |
| 643 } | 643 } |
| 644 } | 644 } |
| 645 // Resolve type of signature function. | 645 // Resolve the signature type if this class is a signature class. |
| 646 if (cls.IsSignatureClass()) { | 646 if (cls.IsSignatureClass()) { |
| 647 ResolveAndFinalizeSignature(cls, | 647 const Type& signature_type = Type::Handle(cls.SignatureType()); |
| 648 Function::Handle(cls.signature_function())); | 648 FinalizeType(signature_type); |
| 649 } | 649 } |
| 650 } | 650 } |
| 651 | 651 |
| 652 | 652 |
| 653 void ClassFinalizer::FinalizeClass(const Class& cls) { | 653 void ClassFinalizer::FinalizeClass(const Class& cls) { |
| 654 if (cls.is_finalized()) { | 654 if (cls.is_finalized()) { |
| 655 return; | 655 return; |
| 656 } | 656 } |
| 657 if (FLAG_trace_class_finalization) { | 657 if (FLAG_trace_class_finalization) { |
| 658 OS::Print("Finalize %s\n", cls.ToCString()); | 658 OS::Print("Finalize %s\n", cls.ToCString()); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 ASSERT(msg_buffer != NULL); | 976 ASSERT(msg_buffer != NULL); |
| 977 va_list args; | 977 va_list args; |
| 978 va_start(args, format); | 978 va_start(args, format); |
| 979 OS::VSNPrint(msg_buffer, kBufferLength, format, args); | 979 OS::VSNPrint(msg_buffer, kBufferLength, format, args); |
| 980 va_end(args); | 980 va_end(args); |
| 981 isolate->long_jump_base()->Jump(1, msg_buffer); | 981 isolate->long_jump_base()->Jump(1, msg_buffer); |
| 982 UNREACHABLE(); | 982 UNREACHABLE(); |
| 983 } | 983 } |
| 984 | 984 |
| 985 } // namespace dart | 985 } // namespace dart |
| OLD | NEW |