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/code_generator.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2070 PendingTypes* pending_types) { | 2070 PendingTypes* pending_types) { |
2071 if (mixin_app_class.is_mixin_type_applied()) { | 2071 if (mixin_app_class.is_mixin_type_applied()) { |
2072 return; | 2072 return; |
2073 } | 2073 } |
2074 Type& mixin_type = Type::Handle(mixin_app_class.mixin()); | 2074 Type& mixin_type = Type::Handle(mixin_app_class.mixin()); |
2075 ASSERT(!mixin_type.IsNull()); | 2075 ASSERT(!mixin_type.IsNull()); |
2076 ASSERT(mixin_type.HasResolvedTypeClass()); | 2076 ASSERT(mixin_type.HasResolvedTypeClass()); |
2077 const Class& mixin_class = Class::Handle(mixin_type.type_class()); | 2077 const Class& mixin_class = Class::Handle(mixin_type.type_class()); |
2078 | 2078 |
2079 if (FLAG_trace_class_finalization) { | 2079 if (FLAG_trace_class_finalization) { |
2080 THR_Print("Applying mixin type '%s' to %s at pos %" Pd "\n", | 2080 THR_Print("Applying mixin type '%s' to %s at pos %s\n", |
2081 String::Handle(mixin_type.Name()).ToCString(), | 2081 String::Handle(mixin_type.Name()).ToCString(), |
2082 mixin_app_class.ToCString(), | 2082 mixin_app_class.ToCString(), |
2083 mixin_app_class.token_pos()); | 2083 mixin_app_class.token_pos().ToCString()); |
2084 } | 2084 } |
2085 | 2085 |
2086 // Check for illegal self references. | 2086 // Check for illegal self references. |
2087 GrowableArray<intptr_t> visited_mixins; | 2087 GrowableArray<intptr_t> visited_mixins; |
2088 if (!IsMixinCycleFree(mixin_class, &visited_mixins)) { | 2088 if (!IsMixinCycleFree(mixin_class, &visited_mixins)) { |
2089 const String& class_name = String::Handle(mixin_class.Name()); | 2089 const String& class_name = String::Handle(mixin_class.Name()); |
2090 ReportError(mixin_class, mixin_class.token_pos(), | 2090 ReportError(mixin_class, mixin_class.token_pos(), |
2091 "mixin class '%s' illegally refers to itself", | 2091 "mixin class '%s' illegally refers to itself", |
2092 class_name.ToCString()); | 2092 class_name.ToCString()); |
2093 } | 2093 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2200 // If the mixin is a mixin application alias class, there are no members to | 2200 // If the mixin is a mixin application alias class, there are no members to |
2201 // apply here. A new synthesized class representing the aliased mixin | 2201 // apply here. A new synthesized class representing the aliased mixin |
2202 // application class was inserted in the super chain of this mixin application | 2202 // application class was inserted in the super chain of this mixin application |
2203 // class. Members of the actual mixin class will be applied when visiting | 2203 // class. Members of the actual mixin class will be applied when visiting |
2204 // the mixin application class referring to the actual mixin. | 2204 // the mixin application class referring to the actual mixin. |
2205 ASSERT(!mixin_cls.is_mixin_app_alias() || | 2205 ASSERT(!mixin_cls.is_mixin_app_alias() || |
2206 Class::Handle(zone, cls.SuperClass()).IsMixinApplication()); | 2206 Class::Handle(zone, cls.SuperClass()).IsMixinApplication()); |
2207 // A default constructor will be created for the mixin app alias class. | 2207 // A default constructor will be created for the mixin app alias class. |
2208 | 2208 |
2209 if (FLAG_trace_class_finalization) { | 2209 if (FLAG_trace_class_finalization) { |
2210 THR_Print("Applying mixin members of %s to %s at pos %" Pd "\n", | 2210 THR_Print("Applying mixin members of %s to %s at pos %s\n", |
2211 mixin_cls.ToCString(), | 2211 mixin_cls.ToCString(), |
2212 cls.ToCString(), | 2212 cls.ToCString(), |
2213 cls.token_pos()); | 2213 cls.token_pos().ToCString()); |
2214 } | 2214 } |
2215 | 2215 |
2216 const GrowableObjectArray& cloned_funcs = | 2216 const GrowableObjectArray& cloned_funcs = |
2217 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); | 2217 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); |
2218 | 2218 |
2219 CreateForwardingConstructors(cls, mixin_cls, cloned_funcs); | 2219 CreateForwardingConstructors(cls, mixin_cls, cloned_funcs); |
2220 | 2220 |
2221 Array& functions = Array::Handle(zone); | 2221 Array& functions = Array::Handle(zone); |
2222 Function& func = Function::Handle(zone); | 2222 Function& func = Function::Handle(zone); |
2223 // The parser creates the mixin application class with no functions. | 2223 // The parser creates the mixin application class with no functions. |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3135 } else { | 3135 } else { |
3136 // The only case where the malformed type was already finalized is when its | 3136 // The only case where the malformed type was already finalized is when its |
3137 // type arguments are not within bounds. In that case, we have a prev_error. | 3137 // type arguments are not within bounds. In that case, we have a prev_error. |
3138 ASSERT(!prev_error.IsNull()); | 3138 ASSERT(!prev_error.IsNull()); |
3139 } | 3139 } |
3140 } | 3140 } |
3141 | 3141 |
3142 | 3142 |
3143 RawType* ClassFinalizer::NewFinalizedMalformedType(const Error& prev_error, | 3143 RawType* ClassFinalizer::NewFinalizedMalformedType(const Error& prev_error, |
3144 const Script& script, | 3144 const Script& script, |
3145 intptr_t type_pos, | 3145 TokenPosition type_pos, |
3146 const char* format, ...) { | 3146 const char* format, ...) { |
3147 va_list args; | 3147 va_list args; |
3148 va_start(args, format); | 3148 va_start(args, format); |
3149 const UnresolvedClass& unresolved_class = UnresolvedClass::Handle( | 3149 const UnresolvedClass& unresolved_class = UnresolvedClass::Handle( |
3150 UnresolvedClass::New(LibraryPrefix::Handle(), | 3150 UnresolvedClass::New(LibraryPrefix::Handle(), |
3151 Symbols::Empty(), | 3151 Symbols::Empty(), |
3152 type_pos)); | 3152 type_pos)); |
3153 const Type& type = Type::Handle( | 3153 const Type& type = Type::Handle( |
3154 Type::New(unresolved_class, TypeArguments::Handle(), type_pos)); | 3154 Type::New(unresolved_class, TypeArguments::Handle(), type_pos)); |
3155 MarkTypeMalformed(prev_error, script, type, format, args); | 3155 MarkTypeMalformed(prev_error, script, type, format, args); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3195 | 3195 |
3196 | 3196 |
3197 void ClassFinalizer::ReportError(const Error& error) { | 3197 void ClassFinalizer::ReportError(const Error& error) { |
3198 Report::LongJump(error); | 3198 Report::LongJump(error); |
3199 UNREACHABLE(); | 3199 UNREACHABLE(); |
3200 } | 3200 } |
3201 | 3201 |
3202 | 3202 |
3203 void ClassFinalizer::ReportErrors(const Error& prev_error, | 3203 void ClassFinalizer::ReportErrors(const Error& prev_error, |
3204 const Class& cls, | 3204 const Class& cls, |
3205 intptr_t token_pos, | 3205 TokenPosition token_pos, |
3206 const char* format, ...) { | 3206 const char* format, ...) { |
3207 va_list args; | 3207 va_list args; |
3208 va_start(args, format); | 3208 va_start(args, format); |
3209 const Script& script = Script::Handle(cls.script()); | 3209 const Script& script = Script::Handle(cls.script()); |
3210 Report::LongJumpV(prev_error, script, token_pos, format, args); | 3210 Report::LongJumpV(prev_error, script, token_pos, format, args); |
3211 va_end(args); | 3211 va_end(args); |
3212 UNREACHABLE(); | 3212 UNREACHABLE(); |
3213 } | 3213 } |
3214 | 3214 |
3215 | 3215 |
3216 void ClassFinalizer::ReportError(const Class& cls, | 3216 void ClassFinalizer::ReportError(const Class& cls, |
3217 intptr_t token_pos, | 3217 TokenPosition token_pos, |
3218 const char* format, ...) { | 3218 const char* format, ...) { |
3219 va_list args; | 3219 va_list args; |
3220 va_start(args, format); | 3220 va_start(args, format); |
3221 const Script& script = Script::Handle(cls.script()); | 3221 const Script& script = Script::Handle(cls.script()); |
3222 Report::MessageV(Report::kError, | 3222 Report::MessageV(Report::kError, |
3223 script, token_pos, Report::AtLocation, format, args); | 3223 script, token_pos, Report::AtLocation, format, args); |
3224 va_end(args); | 3224 va_end(args); |
3225 UNREACHABLE(); | 3225 UNREACHABLE(); |
3226 } | 3226 } |
3227 | 3227 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3294 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3294 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
3295 field ^= fields_array.At(0); | 3295 field ^= fields_array.At(0); |
3296 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3296 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
3297 name ^= field.name(); | 3297 name ^= field.name(); |
3298 expected_name ^= String::New("_data"); | 3298 expected_name ^= String::New("_data"); |
3299 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3299 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
3300 #endif | 3300 #endif |
3301 } | 3301 } |
3302 | 3302 |
3303 } // namespace dart | 3303 } // namespace dart |
OLD | NEW |