| 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/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 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 // class Object. | 1114 // class Object. |
| 1115 const Type& mixin_super_type = Type::Handle(mixin_cls.super_type()); | 1115 const Type& mixin_super_type = Type::Handle(mixin_cls.super_type()); |
| 1116 if (!mixin_super_type.IsObjectType()) { | 1116 if (!mixin_super_type.IsObjectType()) { |
| 1117 const Script& script = Script::Handle(cls.script()); | 1117 const Script& script = Script::Handle(cls.script()); |
| 1118 const String& class_name = String::Handle(mixin_cls.Name()); | 1118 const String& class_name = String::Handle(mixin_cls.Name()); |
| 1119 ReportError(script, cls.token_pos(), | 1119 ReportError(script, cls.token_pos(), |
| 1120 "mixin class %s must extend class Object", | 1120 "mixin class %s must extend class Object", |
| 1121 class_name.ToCString()); | 1121 class_name.ToCString()); |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 // Copy the type parameters of the mixin class to the mixin |
| 1125 // application class. |
| 1126 const int num_type_parameters = mixin_cls.NumTypeParameters(); |
| 1127 if (num_type_parameters > 0) { |
| 1128 ASSERT(cls.NumTypeParameters() == 0); |
| 1129 const TypeArguments& type_params = |
| 1130 TypeArguments::Handle(mixin_cls.type_parameters()); |
| 1131 const TypeArguments& cloned_type_params = |
| 1132 TypeArguments::Handle(TypeArguments::New(num_type_parameters)); |
| 1133 ASSERT(!type_params.IsNull()); |
| 1134 TypeParameter& param = TypeParameter::Handle(); |
| 1135 TypeParameter& cloned_param = TypeParameter::Handle(); |
| 1136 String& param_name = String::Handle(); |
| 1137 AbstractType& param_bound = AbstractType::Handle(); |
| 1138 for (int i = 0; i < num_type_parameters; i++) { |
| 1139 param ^= type_params.TypeAt(i); |
| 1140 param_name = param.name(); |
| 1141 param_bound = param.bound(); |
| 1142 cloned_param = TypeParameter::New( |
| 1143 cls, i, param_name, param_bound, param.token_pos()); |
| 1144 cloned_type_params.SetTypeAt(i, cloned_param); |
| 1145 } |
| 1146 cls.set_type_parameters(cloned_type_params); |
| 1147 } |
| 1148 |
| 1124 const GrowableObjectArray& cloned_funcs = | 1149 const GrowableObjectArray& cloned_funcs = |
| 1125 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 1150 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
| 1126 Array& functions = Array::Handle(); | 1151 Array& functions = Array::Handle(); |
| 1127 Function& func = Function::Handle(); | 1152 Function& func = Function::Handle(); |
| 1128 // The parser creates the mixin application class and adds just | 1153 // The parser creates the mixin application class and adds just |
| 1129 // one function, the implicit constructor. | 1154 // one function, the implicit constructor. |
| 1130 functions = cls.functions(); | 1155 functions = cls.functions(); |
| 1131 ASSERT(functions.Length() == 1); | 1156 ASSERT(functions.Length() == 1); |
| 1132 func ^= functions.At(0); | 1157 func ^= functions.At(0); |
| 1133 ASSERT(func.IsImplicitConstructor()); | 1158 ASSERT(func.IsImplicitConstructor()); |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 void ClassFinalizer::ReportError(const char* format, ...) { | 1696 void ClassFinalizer::ReportError(const char* format, ...) { |
| 1672 va_list args; | 1697 va_list args; |
| 1673 va_start(args, format); | 1698 va_start(args, format); |
| 1674 const Error& error = Error::Handle( | 1699 const Error& error = Error::Handle( |
| 1675 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1700 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
| 1676 va_end(args); | 1701 va_end(args); |
| 1677 ReportError(error); | 1702 ReportError(error); |
| 1678 } | 1703 } |
| 1679 | 1704 |
| 1680 } // namespace dart | 1705 } // namespace dart |
| OLD | NEW |