Chromium Code Reviews| 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 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2068 } | 2068 } |
| 2069 Type& mixin_type = Type::Handle(mixin_app_class.mixin()); | 2069 Type& mixin_type = Type::Handle(mixin_app_class.mixin()); |
| 2070 ASSERT(!mixin_type.IsNull()); | 2070 ASSERT(!mixin_type.IsNull()); |
| 2071 ASSERT(mixin_type.HasResolvedTypeClass()); | 2071 ASSERT(mixin_type.HasResolvedTypeClass()); |
| 2072 const Class& mixin_class = Class::Handle(mixin_type.type_class()); | 2072 const Class& mixin_class = Class::Handle(mixin_type.type_class()); |
| 2073 | 2073 |
| 2074 if (FLAG_trace_class_finalization) { | 2074 if (FLAG_trace_class_finalization) { |
| 2075 THR_Print("Applying mixin type '%s' to %s at pos %" Pd "\n", | 2075 THR_Print("Applying mixin type '%s' to %s at pos %" Pd "\n", |
| 2076 String::Handle(mixin_type.Name()).ToCString(), | 2076 String::Handle(mixin_type.Name()).ToCString(), |
| 2077 mixin_app_class.ToCString(), | 2077 mixin_app_class.ToCString(), |
| 2078 mixin_app_class.token_pos()); | 2078 mixin_app_class.token_pos().value()); |
|
Ivan Posva
2016/02/01 17:16:52
ditto.
Here and other places.
Cutch
2016/02/02 18:00:20
Done.
Cutch
2016/02/02 18:00:20
Done.
| |
| 2079 } | 2079 } |
| 2080 | 2080 |
| 2081 // Check for illegal self references. | 2081 // Check for illegal self references. |
| 2082 GrowableArray<intptr_t> visited_mixins; | 2082 GrowableArray<intptr_t> visited_mixins; |
| 2083 if (!IsMixinCycleFree(mixin_class, &visited_mixins)) { | 2083 if (!IsMixinCycleFree(mixin_class, &visited_mixins)) { |
| 2084 const String& class_name = String::Handle(mixin_class.Name()); | 2084 const String& class_name = String::Handle(mixin_class.Name()); |
| 2085 ReportError(mixin_class, mixin_class.token_pos(), | 2085 ReportError(mixin_class, mixin_class.token_pos(), |
| 2086 "mixin class '%s' illegally refers to itself", | 2086 "mixin class '%s' illegally refers to itself", |
| 2087 class_name.ToCString()); | 2087 class_name.ToCString()); |
| 2088 } | 2088 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2198 // class. Members of the actual mixin class will be applied when visiting | 2198 // class. Members of the actual mixin class will be applied when visiting |
| 2199 // the mixin application class referring to the actual mixin. | 2199 // the mixin application class referring to the actual mixin. |
| 2200 ASSERT(!mixin_cls.is_mixin_app_alias() || | 2200 ASSERT(!mixin_cls.is_mixin_app_alias() || |
| 2201 Class::Handle(zone, cls.SuperClass()).IsMixinApplication()); | 2201 Class::Handle(zone, cls.SuperClass()).IsMixinApplication()); |
| 2202 // A default constructor will be created for the mixin app alias class. | 2202 // A default constructor will be created for the mixin app alias class. |
| 2203 | 2203 |
| 2204 if (FLAG_trace_class_finalization) { | 2204 if (FLAG_trace_class_finalization) { |
| 2205 THR_Print("Applying mixin members of %s to %s at pos %" Pd "\n", | 2205 THR_Print("Applying mixin members of %s to %s at pos %" Pd "\n", |
| 2206 mixin_cls.ToCString(), | 2206 mixin_cls.ToCString(), |
| 2207 cls.ToCString(), | 2207 cls.ToCString(), |
| 2208 cls.token_pos()); | 2208 cls.token_pos().value()); |
| 2209 } | 2209 } |
| 2210 | 2210 |
| 2211 const GrowableObjectArray& cloned_funcs = | 2211 const GrowableObjectArray& cloned_funcs = |
| 2212 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); | 2212 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); |
| 2213 | 2213 |
| 2214 CreateForwardingConstructors(cls, mixin_cls, cloned_funcs); | 2214 CreateForwardingConstructors(cls, mixin_cls, cloned_funcs); |
| 2215 | 2215 |
| 2216 Array& functions = Array::Handle(zone); | 2216 Array& functions = Array::Handle(zone); |
| 2217 Function& func = Function::Handle(zone); | 2217 Function& func = Function::Handle(zone); |
| 2218 // The parser creates the mixin application class with no functions. | 2218 // The parser creates the mixin application class with no functions. |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3124 } else { | 3124 } else { |
| 3125 // The only case where the malformed type was already finalized is when its | 3125 // The only case where the malformed type was already finalized is when its |
| 3126 // type arguments are not within bounds. In that case, we have a prev_error. | 3126 // type arguments are not within bounds. In that case, we have a prev_error. |
| 3127 ASSERT(!prev_error.IsNull()); | 3127 ASSERT(!prev_error.IsNull()); |
| 3128 } | 3128 } |
| 3129 } | 3129 } |
| 3130 | 3130 |
| 3131 | 3131 |
| 3132 RawType* ClassFinalizer::NewFinalizedMalformedType(const Error& prev_error, | 3132 RawType* ClassFinalizer::NewFinalizedMalformedType(const Error& prev_error, |
| 3133 const Script& script, | 3133 const Script& script, |
| 3134 intptr_t type_pos, | 3134 TokenDescriptor type_pos, |
| 3135 const char* format, ...) { | 3135 const char* format, ...) { |
| 3136 va_list args; | 3136 va_list args; |
| 3137 va_start(args, format); | 3137 va_start(args, format); |
| 3138 const UnresolvedClass& unresolved_class = UnresolvedClass::Handle( | 3138 const UnresolvedClass& unresolved_class = UnresolvedClass::Handle( |
| 3139 UnresolvedClass::New(LibraryPrefix::Handle(), | 3139 UnresolvedClass::New(LibraryPrefix::Handle(), |
| 3140 Symbols::Empty(), | 3140 Symbols::Empty(), |
| 3141 type_pos)); | 3141 type_pos)); |
| 3142 const Type& type = Type::Handle( | 3142 const Type& type = Type::Handle( |
| 3143 Type::New(unresolved_class, TypeArguments::Handle(), type_pos)); | 3143 Type::New(unresolved_class, TypeArguments::Handle(), type_pos)); |
| 3144 MarkTypeMalformed(prev_error, script, type, format, args); | 3144 MarkTypeMalformed(prev_error, script, type, format, args); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3184 | 3184 |
| 3185 | 3185 |
| 3186 void ClassFinalizer::ReportError(const Error& error) { | 3186 void ClassFinalizer::ReportError(const Error& error) { |
| 3187 Report::LongJump(error); | 3187 Report::LongJump(error); |
| 3188 UNREACHABLE(); | 3188 UNREACHABLE(); |
| 3189 } | 3189 } |
| 3190 | 3190 |
| 3191 | 3191 |
| 3192 void ClassFinalizer::ReportErrors(const Error& prev_error, | 3192 void ClassFinalizer::ReportErrors(const Error& prev_error, |
| 3193 const Class& cls, | 3193 const Class& cls, |
| 3194 intptr_t token_pos, | 3194 TokenDescriptor token_pos, |
| 3195 const char* format, ...) { | 3195 const char* format, ...) { |
| 3196 va_list args; | 3196 va_list args; |
| 3197 va_start(args, format); | 3197 va_start(args, format); |
| 3198 const Script& script = Script::Handle(cls.script()); | 3198 const Script& script = Script::Handle(cls.script()); |
| 3199 Report::LongJumpV(prev_error, script, token_pos, format, args); | 3199 Report::LongJumpV(prev_error, script, token_pos, format, args); |
| 3200 va_end(args); | 3200 va_end(args); |
| 3201 UNREACHABLE(); | 3201 UNREACHABLE(); |
| 3202 } | 3202 } |
| 3203 | 3203 |
| 3204 | 3204 |
| 3205 void ClassFinalizer::ReportError(const Class& cls, | 3205 void ClassFinalizer::ReportError(const Class& cls, |
| 3206 intptr_t token_pos, | 3206 TokenDescriptor token_pos, |
| 3207 const char* format, ...) { | 3207 const char* format, ...) { |
| 3208 va_list args; | 3208 va_list args; |
| 3209 va_start(args, format); | 3209 va_start(args, format); |
| 3210 const Script& script = Script::Handle(cls.script()); | 3210 const Script& script = Script::Handle(cls.script()); |
| 3211 Report::MessageV(Report::kError, | 3211 Report::MessageV(Report::kError, |
| 3212 script, token_pos, Report::AtLocation, format, args); | 3212 script, token_pos, Report::AtLocation, format, args); |
| 3213 va_end(args); | 3213 va_end(args); |
| 3214 UNREACHABLE(); | 3214 UNREACHABLE(); |
| 3215 } | 3215 } |
| 3216 | 3216 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3283 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3283 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
| 3284 field ^= fields_array.At(0); | 3284 field ^= fields_array.At(0); |
| 3285 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3285 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
| 3286 name ^= field.name(); | 3286 name ^= field.name(); |
| 3287 expected_name ^= String::New("_data"); | 3287 expected_name ^= String::New("_data"); |
| 3288 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3288 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
| 3289 #endif | 3289 #endif |
| 3290 } | 3290 } |
| 3291 | 3291 |
| 3292 } // namespace dart | 3292 } // namespace dart |
| OLD | NEW |