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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 if (type.IsType()) { | 519 if (type.IsType()) { |
520 resolved_type = ResolveTypeClass(cls, Type::Cast(type)); | 520 resolved_type = ResolveTypeClass(cls, Type::Cast(type)); |
521 if (resolved_type.IsMalformed()) { | 521 if (resolved_type.IsMalformed()) { |
522 ASSERT(resolved_type.IsResolved()); | 522 ASSERT(resolved_type.IsResolved()); |
523 return resolved_type.raw(); | 523 return resolved_type.raw(); |
524 } | 524 } |
525 } else { | 525 } else { |
526 ASSERT(type.IsFunctionType()); | 526 ASSERT(type.IsFunctionType()); |
527 const Function& signature = | 527 const Function& signature = |
528 Function::Handle(FunctionType::Cast(type).signature()); | 528 Function::Handle(FunctionType::Cast(type).signature()); |
529 ResolveSignature(cls, signature); | 529 const Class& scope_class = |
| 530 Class::Handle(FunctionType::Cast(type).scope_class()); |
| 531 if (scope_class.IsTypedefClass()) { |
| 532 ResolveSignature(scope_class, signature); |
| 533 } else { |
| 534 ResolveSignature(cls, signature); |
| 535 } |
530 resolved_type = type.raw(); | 536 resolved_type = type.raw(); |
531 } | 537 } |
532 // Mark type as resolved before resolving its type arguments in order to avoid | 538 // Mark type as resolved before resolving its type arguments in order to avoid |
533 // repeating resolution of recursive types. | 539 // repeating resolution of recursive types. |
534 resolved_type.SetIsResolved(); | 540 resolved_type.SetIsResolved(); |
535 // Resolve type arguments, if any. | 541 // Resolve type arguments, if any. |
536 const TypeArguments& arguments = | 542 const TypeArguments& arguments = |
537 TypeArguments::Handle(resolved_type.arguments()); | 543 TypeArguments::Handle(resolved_type.arguments()); |
538 if (!arguments.IsNull()) { | 544 if (!arguments.IsNull()) { |
539 const intptr_t num_arguments = arguments.Length(); | 545 const intptr_t num_arguments = arguments.Length(); |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 // If the type is a FunctionType, we also need to finalize the types in its | 1155 // If the type is a FunctionType, we also need to finalize the types in its |
1150 // signature, i.e. finalize the result type and parameter types of the | 1156 // signature, i.e. finalize the result type and parameter types of the |
1151 // signature function of this function type. | 1157 // signature function of this function type. |
1152 // We do this after marking this type as finalized in order to allow a | 1158 // We do this after marking this type as finalized in order to allow a |
1153 // function type to refer to itself via its parameter types and result type. | 1159 // function type to refer to itself via its parameter types and result type. |
1154 // Note that we do not instantiate these types according to the type | 1160 // Note that we do not instantiate these types according to the type |
1155 // arguments. This will happen on demand when executing a type test. | 1161 // arguments. This will happen on demand when executing a type test. |
1156 if (resolved_type.IsFunctionType()) { | 1162 if (resolved_type.IsFunctionType()) { |
1157 const Function& signature = | 1163 const Function& signature = |
1158 Function::Handle(Z, FunctionType::Cast(resolved_type).signature()); | 1164 Function::Handle(Z, FunctionType::Cast(resolved_type).signature()); |
1159 FinalizeSignature(cls, signature); | 1165 const Class& scope_class = |
| 1166 Class::Handle(Z, FunctionType::Cast(resolved_type).scope_class()); |
| 1167 if (scope_class.IsTypedefClass()) { |
| 1168 FinalizeSignature(scope_class, signature); |
| 1169 } else { |
| 1170 FinalizeSignature(cls, signature); |
| 1171 } |
1160 } | 1172 } |
1161 | 1173 |
1162 if (FLAG_trace_type_finalization) { | 1174 if (FLAG_trace_type_finalization) { |
1163 THR_Print("Done finalizing type '%s' with %" Pd " type args: %s\n", | 1175 THR_Print("Done finalizing type '%s' with %" Pd " type args: %s\n", |
1164 String::Handle(Z, resolved_type.Name()).ToCString(), | 1176 String::Handle(Z, resolved_type.Name()).ToCString(), |
1165 num_expanded_type_arguments, | 1177 num_expanded_type_arguments, |
1166 resolved_type.ToCString()); | 1178 resolved_type.ToCString()); |
1167 } | 1179 } |
1168 | 1180 |
1169 if (finalization >= kCanonicalize) { | 1181 if (finalization >= kCanonicalize) { |
(...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3271 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3283 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
3272 field ^= fields_array.At(0); | 3284 field ^= fields_array.At(0); |
3273 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3285 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
3274 name ^= field.name(); | 3286 name ^= field.name(); |
3275 expected_name ^= String::New("_data"); | 3287 expected_name ^= String::New("_data"); |
3276 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3288 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
3277 #endif | 3289 #endif |
3278 } | 3290 } |
3279 | 3291 |
3280 } // namespace dart | 3292 } // namespace dart |
OLD | NEW |