OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/kernel_reader.h" | 5 #include "vm/kernel_reader.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 281 |
282 | 282 |
283 dart::Class& KernelReader::ReadClass(const dart::Library& library, | 283 dart::Class& KernelReader::ReadClass(const dart::Library& library, |
284 const dart::Class& toplevel_class, | 284 const dart::Class& toplevel_class, |
285 Class* kernel_klass) { | 285 Class* kernel_klass) { |
286 // This will trigger a call to [ReadPreliminaryClass] if not already done. | 286 // This will trigger a call to [ReadPreliminaryClass] if not already done. |
287 dart::Class& klass = LookupClass(kernel_klass); | 287 dart::Class& klass = LookupClass(kernel_klass); |
288 | 288 |
289 ActiveClassScope active_class_scope(&active_class_, kernel_klass, &klass); | 289 ActiveClassScope active_class_scope(&active_class_, kernel_klass, &klass); |
290 | 290 |
291 for (intptr_t i = 0; i < kernel_klass->fields().length(); i++) { | 291 if (library.raw() == dart::Library::InternalLibrary() && |
292 Field* kernel_field = kernel_klass->fields()[i]; | 292 klass.Name() == Symbols::ClassID().raw()) { |
293 ActiveMemberScope active_member_scope(&active_class_, kernel_field); | 293 // If this is a dart:internal.ClassID class ignore field declarations |
| 294 // contained in the Kernel file and instead inject our own const |
| 295 // fields. |
| 296 klass.InjectCIDFields(); |
| 297 } else { |
| 298 for (intptr_t i = 0; i < kernel_klass->fields().length(); i++) { |
| 299 Field* kernel_field = kernel_klass->fields()[i]; |
| 300 ActiveMemberScope active_member_scope(&active_class_, kernel_field); |
294 | 301 |
295 const dart::String& name = H.DartFieldName(kernel_field->name()); | 302 const dart::String& name = H.DartFieldName(kernel_field->name()); |
296 const AbstractType& type = | 303 const AbstractType& type = |
297 T.TranslateTypeWithoutFinalization(kernel_field->type()); | 304 T.TranslateTypeWithoutFinalization(kernel_field->type()); |
298 const Object& script_class = | 305 const Object& script_class = |
299 ClassForScriptAt(klass, kernel_field->source_uri_index()); | 306 ClassForScriptAt(klass, kernel_field->source_uri_index()); |
300 dart::Field& field = dart::Field::Handle( | 307 dart::Field& field = dart::Field::Handle( |
301 Z, dart::Field::New(name, kernel_field->IsStatic(), | 308 Z, |
302 // In the VM all const fields are implicitly final | 309 dart::Field::New(name, kernel_field->IsStatic(), |
303 // whereas in Kernel they are not final because they | 310 // In the VM all const fields are implicitly final |
304 // are not explicitly declared that way. | 311 // whereas in Kernel they are not final because they |
305 kernel_field->IsFinal() || kernel_field->IsConst(), | 312 // are not explicitly declared that way. |
306 kernel_field->IsConst(), | 313 kernel_field->IsFinal() || kernel_field->IsConst(), |
307 false, // is_reflectable | 314 kernel_field->IsConst(), |
308 script_class, type, kernel_field->position())); | 315 false, // is_reflectable |
309 field.set_kernel_field(kernel_field); | 316 script_class, type, kernel_field->position())); |
310 field.set_has_initializer(kernel_field->initializer() != NULL); | 317 field.set_kernel_field(kernel_field); |
311 GenerateFieldAccessors(klass, field, kernel_field); | 318 field.set_has_initializer(kernel_field->initializer() != NULL); |
312 klass.AddField(field); | 319 GenerateFieldAccessors(klass, field, kernel_field); |
| 320 klass.AddField(field); |
| 321 } |
313 } | 322 } |
314 | 323 |
315 for (intptr_t i = 0; i < kernel_klass->constructors().length(); i++) { | 324 for (intptr_t i = 0; i < kernel_klass->constructors().length(); i++) { |
316 Constructor* kernel_constructor = kernel_klass->constructors()[i]; | 325 Constructor* kernel_constructor = kernel_klass->constructors()[i]; |
317 ActiveMemberScope active_member_scope(&active_class_, kernel_constructor); | 326 ActiveMemberScope active_member_scope(&active_class_, kernel_constructor); |
318 ActiveFunctionScope active_function_scope(&active_class_, | 327 ActiveFunctionScope active_function_scope(&active_class_, |
319 kernel_constructor->function()); | 328 kernel_constructor->function()); |
320 | 329 |
321 const dart::String& name = H.DartConstructorName(kernel_constructor); | 330 const dart::String& name = H.DartConstructorName(kernel_constructor); |
322 Function& function = dart::Function::ZoneHandle( | 331 Function& function = dart::Function::ZoneHandle( |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 initializer_fun.set_is_debuggable(false); | 798 initializer_fun.set_is_debuggable(false); |
790 initializer_fun.set_is_reflectable(false); | 799 initializer_fun.set_is_reflectable(false); |
791 initializer_fun.set_is_inlinable(false); | 800 initializer_fun.set_is_inlinable(false); |
792 return new (zone) ParsedFunction(thread, initializer_fun); | 801 return new (zone) ParsedFunction(thread, initializer_fun); |
793 } | 802 } |
794 | 803 |
795 | 804 |
796 } // namespace kernel | 805 } // namespace kernel |
797 } // namespace dart | 806 } // namespace dart |
798 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 807 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |