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 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 RawFunction::kImplicitStaticFinalGetter, | 1222 RawFunction::kImplicitStaticFinalGetter, |
1223 /* is_static = */ true, | 1223 /* is_static = */ true, |
1224 /* is_const = */ field.is_const(), | 1224 /* is_const = */ field.is_const(), |
1225 /* is_abstract = */ false, | 1225 /* is_abstract = */ false, |
1226 /* is_external = */ false, | 1226 /* is_external = */ false, |
1227 cls, | 1227 cls, |
1228 field.token_pos())); | 1228 field.token_pos())); |
1229 getter.set_result_type(type); | 1229 getter.set_result_type(type); |
1230 cls.AddFunction(getter); | 1230 cls.AddFunction(getter); |
1231 field.set_value(Instance::Handle(Object::sentinel().raw())); | 1231 field.set_value(Instance::Handle(Object::sentinel().raw())); |
| 1232 |
| 1233 // Create initializer function. |
| 1234 // We don't have the start position of the initializer expression |
| 1235 // here, but can compute it from the field identifier position: |
| 1236 // The initializer expression starts after the assignment token at +2. |
| 1237 const intptr_t initializer_pos = field.token_pos() + 2; |
| 1238 const Function& init_function = Function::ZoneHandle( |
| 1239 Function::NewStaticInitializer( |
| 1240 String::Handle(field.name()), |
| 1241 type, |
| 1242 cls, |
| 1243 initializer_pos)); |
| 1244 cls.AddFunction(init_function); |
1232 } | 1245 } |
1233 } | 1246 } |
1234 } | 1247 } |
1235 } | 1248 } |
1236 // Collect interfaces, super interfaces, and super classes of this class. | 1249 // Collect interfaces, super interfaces, and super classes of this class. |
1237 const GrowableObjectArray& interfaces = | 1250 const GrowableObjectArray& interfaces = |
1238 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 1251 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
1239 CollectInterfaces(cls, interfaces); | 1252 CollectInterfaces(cls, interfaces); |
1240 // Include superclasses in list of interfaces and super interfaces. | 1253 // Include superclasses in list of interfaces and super interfaces. |
1241 super_class = cls.SuperClass(); | 1254 super_class = cls.SuperClass(); |
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2762 expected_name ^= String::New("_offset"); | 2775 expected_name ^= String::New("_offset"); |
2763 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 2776 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
2764 field ^= fields_array.At(2); | 2777 field ^= fields_array.At(2); |
2765 ASSERT(field.Offset() == TypedDataView::length_offset()); | 2778 ASSERT(field.Offset() == TypedDataView::length_offset()); |
2766 name ^= field.name(); | 2779 name ^= field.name(); |
2767 ASSERT(name.Equals("length")); | 2780 ASSERT(name.Equals("length")); |
2768 #endif | 2781 #endif |
2769 } | 2782 } |
2770 | 2783 |
2771 } // namespace dart | 2784 } // namespace dart |
OLD | NEW |