OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 String& field_name = String::Handle(isolate); | 1503 String& field_name = String::Handle(isolate); |
1504 | 1504 |
1505 #define CLASS_LIST_WITH_NULL(V) \ | 1505 #define CLASS_LIST_WITH_NULL(V) \ |
1506 V(Null) \ | 1506 V(Null) \ |
1507 CLASS_LIST_NO_OBJECT(V) | 1507 CLASS_LIST_NO_OBJECT(V) |
1508 | 1508 |
1509 #define ADD_SET_FIELD(clazz) \ | 1509 #define ADD_SET_FIELD(clazz) \ |
1510 field_name = Symbols::New("cid"#clazz); \ | 1510 field_name = Symbols::New("cid"#clazz); \ |
1511 field = Field::New(field_name, true, false, true, false, cls, 0); \ | 1511 field = Field::New(field_name, true, false, true, false, cls, 0); \ |
1512 value = Smi::New(k##clazz##Cid); \ | 1512 value = Smi::New(k##clazz##Cid); \ |
1513 field.set_value(value); \ | 1513 field.SetStaticFieldValue(value, true); \ |
1514 field.set_type(Type::Handle(Type::IntType())); \ | 1514 field.set_type(Type::Handle(Type::IntType())); \ |
1515 cls.AddField(field); \ | 1515 cls.AddField(field); \ |
1516 | 1516 |
1517 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) | 1517 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) |
1518 #undef ADD_SET_FIELD | 1518 #undef ADD_SET_FIELD |
1519 | 1519 |
1520 isolate->object_store()->InitKnownObjects(); | 1520 isolate->object_store()->InitKnownObjects(); |
1521 | 1521 |
1522 return Error::null(); | 1522 return Error::null(); |
1523 #else // defined(DART_NO_SNAPSHOT). | 1523 #else // defined(DART_NO_SNAPSHOT). |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 const intptr_t length = raw_ptr()->instance_size_in_words_; | 2027 const intptr_t length = raw_ptr()->instance_size_in_words_; |
2028 array = Array::New(length, Heap::kOld); | 2028 array = Array::New(length, Heap::kOld); |
2029 Class& cls = Class::Handle(this->raw()); | 2029 Class& cls = Class::Handle(this->raw()); |
2030 Array& fields = Array::Handle(); | 2030 Array& fields = Array::Handle(); |
2031 Field& f = Field::Handle(); | 2031 Field& f = Field::Handle(); |
2032 while (!cls.IsNull()) { | 2032 while (!cls.IsNull()) { |
2033 fields = cls.fields(); | 2033 fields = cls.fields(); |
2034 for (intptr_t i = 0; i < fields.Length(); ++i) { | 2034 for (intptr_t i = 0; i < fields.Length(); ++i) { |
2035 f ^= fields.At(i); | 2035 f ^= fields.At(i); |
2036 if (!f.is_static()) { | 2036 if (!f.is_static()) { |
2037 array.SetAt(f.Offset() >> kWordSizeLog2, f); | 2037 array.SetAt(f.InstanceFieldOffset() >> kWordSizeLog2, f); |
2038 } | 2038 } |
2039 } | 2039 } |
2040 cls = cls.SuperClass(); | 2040 cls = cls.SuperClass(); |
2041 } | 2041 } |
2042 StorePointer(&raw_ptr()->offset_in_words_to_field_, array.raw()); | 2042 StorePointer(&raw_ptr()->offset_in_words_to_field_, array.raw()); |
2043 } | 2043 } |
2044 return array.raw(); | 2044 return array.raw(); |
2045 } | 2045 } |
2046 | 2046 |
2047 | 2047 |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2577 } | 2577 } |
2578 } | 2578 } |
2579 set_type_arguments_field_offset(type_args_field_offset); | 2579 set_type_arguments_field_offset(type_args_field_offset); |
2580 ASSERT(offset > 0); | 2580 ASSERT(offset > 0); |
2581 Field& field = Field::Handle(); | 2581 Field& field = Field::Handle(); |
2582 intptr_t len = flds.Length(); | 2582 intptr_t len = flds.Length(); |
2583 for (intptr_t i = 0; i < len; i++) { | 2583 for (intptr_t i = 0; i < len; i++) { |
2584 field ^= flds.At(i); | 2584 field ^= flds.At(i); |
2585 // Offset is computed only for instance fields. | 2585 // Offset is computed only for instance fields. |
2586 if (!field.is_static()) { | 2586 if (!field.is_static()) { |
2587 ASSERT(field.Offset() == 0); | 2587 ASSERT(field.InstanceFieldOffset() == 0); |
2588 field.SetOffset(offset); | 2588 field.SetInstanceFieldOffset(offset); |
2589 offset += kWordSize; | 2589 offset += kWordSize; |
2590 } | 2590 } |
2591 } | 2591 } |
2592 set_instance_size(RoundedAllocationSize(offset)); | 2592 set_instance_size(RoundedAllocationSize(offset)); |
2593 set_next_field_offset(offset); | 2593 set_next_field_offset(offset); |
2594 } | 2594 } |
2595 | 2595 |
2596 | 2596 |
2597 RawFunction* Class::GetInvocationDispatcher(const String& target_name, | 2597 RawFunction* Class::GetInvocationDispatcher(const String& target_name, |
2598 const Array& args_desc, | 2598 const Array& args_desc, |
(...skipping 4640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7239 RawClass* Field::origin() const { | 7239 RawClass* Field::origin() const { |
7240 const Object& obj = Object::Handle(raw_ptr()->owner_); | 7240 const Object& obj = Object::Handle(raw_ptr()->owner_); |
7241 if (obj.IsClass()) { | 7241 if (obj.IsClass()) { |
7242 return Class::Cast(obj).raw(); | 7242 return Class::Cast(obj).raw(); |
7243 } | 7243 } |
7244 ASSERT(obj.IsPatchClass()); | 7244 ASSERT(obj.IsPatchClass()); |
7245 return PatchClass::Cast(obj).source_class(); | 7245 return PatchClass::Cast(obj).source_class(); |
7246 } | 7246 } |
7247 | 7247 |
7248 | 7248 |
7249 RawInstance* Field::value() const { | 7249 RawInstance* Field::StaticFieldValue() const { |
7250 ASSERT(is_static()); // Valid only for static dart fields. | 7250 ASSERT(is_static()); // Valid only for static dart fields. |
7251 return raw_ptr()->value_; | 7251 return raw_ptr()->value_.static_value_; |
7252 } | 7252 } |
7253 | 7253 |
7254 | 7254 |
7255 void Field::set_value(const Instance& value) const { | 7255 void Field::SetStaticFieldValue(const Instance& value, |
| 7256 bool save_initial_value) const { |
7256 ASSERT(is_static()); // Valid only for static dart fields. | 7257 ASSERT(is_static()); // Valid only for static dart fields. |
7257 StorePointer(&raw_ptr()->value_, value.raw()); | 7258 StorePointer(&raw_ptr()->value_.static_value_, value.raw()); |
| 7259 if (save_initial_value) { |
| 7260 StorePointer(&raw_ptr()->initializer_.saved_initial_value_, value.raw()); |
| 7261 } |
7258 } | 7262 } |
7259 | 7263 |
7260 | 7264 |
7261 void Field::set_type(const AbstractType& value) const { | 7265 void Field::set_type(const AbstractType& value) const { |
7262 ASSERT(!value.IsNull()); | 7266 ASSERT(!value.IsNull()); |
7263 StorePointer(&raw_ptr()->type_, value.raw()); | 7267 StorePointer(&raw_ptr()->type_, value.raw()); |
7264 } | 7268 } |
7265 | 7269 |
7266 | 7270 |
7267 RawField* Field::New() { | 7271 RawField* Field::New() { |
7268 ASSERT(Object::field_class() != Class::null()); | 7272 ASSERT(Object::field_class() != Class::null()); |
7269 RawObject* raw = Object::Allocate(Field::kClassId, | 7273 RawObject* raw = Object::Allocate(Field::kClassId, |
7270 Field::InstanceSize(), | 7274 Field::InstanceSize(), |
7271 Heap::kOld); | 7275 Heap::kOld); |
7272 return reinterpret_cast<RawField*>(raw); | 7276 return reinterpret_cast<RawField*>(raw); |
7273 } | 7277 } |
7274 | 7278 |
7275 | 7279 |
7276 RawField* Field::New(const String& name, | 7280 RawField* Field::New(const String& name, |
7277 bool is_static, | 7281 bool is_static, |
7278 bool is_final, | 7282 bool is_final, |
7279 bool is_const, | 7283 bool is_const, |
7280 bool is_reflectable, | 7284 bool is_reflectable, |
7281 const Class& owner, | 7285 const Class& owner, |
7282 intptr_t token_pos) { | 7286 intptr_t token_pos) { |
7283 ASSERT(!owner.IsNull()); | 7287 ASSERT(!owner.IsNull()); |
7284 const Field& result = Field::Handle(Field::New()); | 7288 const Field& result = Field::Handle(Field::New()); |
7285 result.set_name(name); | 7289 result.set_name(name); |
7286 result.set_is_static(is_static); | 7290 result.set_is_static(is_static); |
7287 if (is_static) { | 7291 if (!is_static) { |
7288 result.set_value(Object::null_instance()); | 7292 result.SetInstanceFieldOffset(0); |
7289 } else { | |
7290 result.SetOffset(0); | |
7291 } | 7293 } |
7292 result.set_is_final(is_final); | 7294 result.set_is_final(is_final); |
7293 result.set_is_const(is_const); | 7295 result.set_is_const(is_const); |
7294 result.set_is_reflectable(is_reflectable); | 7296 result.set_is_reflectable(is_reflectable); |
7295 result.set_is_double_initialized(false); | 7297 result.set_is_double_initialized(false); |
7296 result.set_owner(owner); | 7298 result.set_owner(owner); |
7297 result.set_token_pos(token_pos); | 7299 result.set_token_pos(token_pos); |
7298 result.set_has_initializer(false); | 7300 result.set_has_initializer(false); |
7299 result.set_is_unboxing_candidate(true); | 7301 result.set_is_unboxing_candidate(true); |
7300 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid); | 7302 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid); |
(...skipping 11 matching lines...) Expand all Loading... |
7312 | 7314 |
7313 | 7315 |
7314 RawField* Field::Clone(const Class& new_owner) const { | 7316 RawField* Field::Clone(const Class& new_owner) const { |
7315 Field& clone = Field::Handle(); | 7317 Field& clone = Field::Handle(); |
7316 clone ^= Object::Clone(*this, Heap::kOld); | 7318 clone ^= Object::Clone(*this, Heap::kOld); |
7317 const Class& owner = Class::Handle(this->owner()); | 7319 const Class& owner = Class::Handle(this->owner()); |
7318 const PatchClass& clone_owner = | 7320 const PatchClass& clone_owner = |
7319 PatchClass::Handle(PatchClass::New(new_owner, owner)); | 7321 PatchClass::Handle(PatchClass::New(new_owner, owner)); |
7320 clone.set_owner(clone_owner); | 7322 clone.set_owner(clone_owner); |
7321 if (!clone.is_static()) { | 7323 if (!clone.is_static()) { |
7322 clone.SetOffset(0); | 7324 clone.SetInstanceFieldOffset(0); |
7323 } | 7325 } |
7324 if (new_owner.NumTypeParameters() > 0) { | 7326 if (new_owner.NumTypeParameters() > 0) { |
7325 // Adjust the field type to refer to type parameters of the new owner. | 7327 // Adjust the field type to refer to type parameters of the new owner. |
7326 AbstractType& type = AbstractType::Handle(clone.type()); | 7328 AbstractType& type = AbstractType::Handle(clone.type()); |
7327 type ^= type.CloneUninstantiated(new_owner); | 7329 type ^= type.CloneUninstantiated(new_owner); |
7328 clone.set_type(type); | 7330 clone.set_type(type); |
7329 } | 7331 } |
7330 return clone.raw(); | 7332 return clone.raw(); |
7331 } | 7333 } |
7332 | 7334 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7421 | 7423 |
7422 AbstractType& declared_type = AbstractType::Handle(type()); | 7424 AbstractType& declared_type = AbstractType::Handle(type()); |
7423 jsobj.AddProperty("declaredType", declared_type); | 7425 jsobj.AddProperty("declaredType", declared_type); |
7424 jsobj.AddProperty("static", is_static()); | 7426 jsobj.AddProperty("static", is_static()); |
7425 jsobj.AddProperty("final", is_final()); | 7427 jsobj.AddProperty("final", is_final()); |
7426 jsobj.AddProperty("const", is_const()); | 7428 jsobj.AddProperty("const", is_const()); |
7427 if (ref) { | 7429 if (ref) { |
7428 return; | 7430 return; |
7429 } | 7431 } |
7430 if (is_static()) { | 7432 if (is_static()) { |
7431 const Instance& valueObj = Instance::Handle(value()); | 7433 const Instance& valueObj = Instance::Handle(StaticFieldValue()); |
7432 jsobj.AddProperty("staticValue", valueObj); | 7434 jsobj.AddProperty("staticValue", valueObj); |
7433 } | 7435 } |
7434 | 7436 |
7435 jsobj.AddProperty("_guardNullable", is_nullable()); | 7437 jsobj.AddProperty("_guardNullable", is_nullable()); |
7436 if (guarded_cid() == kIllegalCid) { | 7438 if (guarded_cid() == kIllegalCid) { |
7437 jsobj.AddProperty("_guardClass", "unknown"); | 7439 jsobj.AddProperty("_guardClass", "unknown"); |
7438 } else if (guarded_cid() == kDynamicCid) { | 7440 } else if (guarded_cid() == kDynamicCid) { |
7439 jsobj.AddProperty("_guardClass", "dynamic"); | 7441 jsobj.AddProperty("_guardClass", "dynamic"); |
7440 } else { | 7442 } else { |
7441 ClassTable* table = Isolate::Current()->class_table(); | 7443 ClassTable* table = Isolate::Current()->class_table(); |
(...skipping 25 matching lines...) Expand all Loading... |
7467 String& closure_name = String::Handle(this->name()); | 7469 String& closure_name = String::Handle(this->name()); |
7468 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); | 7470 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); |
7469 if (make_setter) { | 7471 if (make_setter) { |
7470 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); | 7472 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); |
7471 } | 7473 } |
7472 | 7474 |
7473 Field& closure_field = Field::Handle(); | 7475 Field& closure_field = Field::Handle(); |
7474 closure_field = field_owner.LookupStaticField(closure_name); | 7476 closure_field = field_owner.LookupStaticField(closure_name); |
7475 if (!closure_field.IsNull()) { | 7477 if (!closure_field.IsNull()) { |
7476 ASSERT(closure_field.is_static()); | 7478 ASSERT(closure_field.is_static()); |
7477 const Instance& closure = Instance::Handle(closure_field.value()); | 7479 const Instance& closure = |
| 7480 Instance::Handle(closure_field.StaticFieldValue()); |
7478 ASSERT(!closure.IsNull()); | 7481 ASSERT(!closure.IsNull()); |
7479 ASSERT(closure.IsClosure()); | 7482 ASSERT(closure.IsClosure()); |
7480 return closure.raw(); | 7483 return closure.raw(); |
7481 } | 7484 } |
7482 | 7485 |
7483 // This is the first time a closure for this field is requested. | 7486 // This is the first time a closure for this field is requested. |
7484 // Create the closure and a new static field in which it is stored. | 7487 // Create the closure and a new static field in which it is stored. |
7485 const char* field_name = String::Handle(name()).ToCString(); | 7488 const char* field_name = String::Handle(name()).ToCString(); |
7486 String& expr_src = String::Handle(); | 7489 String& expr_src = String::Handle(); |
7487 if (make_setter) { | 7490 if (make_setter) { |
(...skipping 12 matching lines...) Expand all Loading... |
7500 // the result here, since Object::Clone() is a private method. | 7503 // the result here, since Object::Clone() is a private method. |
7501 result = Object::Clone(result, Heap::kOld); | 7504 result = Object::Clone(result, Heap::kOld); |
7502 | 7505 |
7503 closure_field = Field::New(closure_name, | 7506 closure_field = Field::New(closure_name, |
7504 true, // is_static | 7507 true, // is_static |
7505 true, // is_final | 7508 true, // is_final |
7506 true, // is_const | 7509 true, // is_const |
7507 false, // is_reflectable | 7510 false, // is_reflectable |
7508 field_owner, | 7511 field_owner, |
7509 this->token_pos()); | 7512 this->token_pos()); |
7510 closure_field.set_value(Instance::Cast(result)); | 7513 closure_field.SetStaticFieldValue(Instance::Cast(result), true); |
7511 closure_field.set_type(Type::Handle(Type::DynamicType())); | 7514 closure_field.set_type(Type::Handle(Type::DynamicType())); |
7512 field_owner.AddField(closure_field); | 7515 field_owner.AddField(closure_field); |
7513 | 7516 |
7514 return Instance::RawCast(result.raw()); | 7517 return Instance::RawCast(result.raw()); |
7515 } | 7518 } |
7516 | 7519 |
7517 | 7520 |
7518 RawInstance* Field::GetterClosure() const { | 7521 RawInstance* Field::GetterClosure() const { |
7519 return AccessorClosure(false); | 7522 return AccessorClosure(false); |
7520 } | 7523 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7576 } | 7579 } |
7577 | 7580 |
7578 | 7581 |
7579 void Field::DeoptimizeDependentCode() const { | 7582 void Field::DeoptimizeDependentCode() const { |
7580 FieldDependentArray a(*this); | 7583 FieldDependentArray a(*this); |
7581 a.DisableCode(); | 7584 a.DisableCode(); |
7582 } | 7585 } |
7583 | 7586 |
7584 | 7587 |
7585 bool Field::IsUninitialized() const { | 7588 bool Field::IsUninitialized() const { |
7586 const Instance& value = Instance::Handle(raw_ptr()->value_); | 7589 const Instance& value = Instance::Handle(raw_ptr()->value_.static_value_); |
7587 ASSERT(value.raw() != Object::transition_sentinel().raw()); | 7590 ASSERT(value.raw() != Object::transition_sentinel().raw()); |
7588 return value.raw() == Object::sentinel().raw(); | 7591 return value.raw() == Object::sentinel().raw(); |
7589 } | 7592 } |
7590 | 7593 |
7591 | 7594 |
7592 void Field::set_initializer(const Function& initializer) const { | 7595 void Field::SetPrecompiledInitializer(const Function& initializer) const { |
7593 StorePointer(&raw_ptr()->initializer_, initializer.raw()); | 7596 StorePointer(&raw_ptr()->initializer_.precompiled_initializer_, |
| 7597 initializer.raw()); |
| 7598 } |
| 7599 |
| 7600 |
| 7601 bool Field::HasPrecompiledInitializer() const { |
| 7602 return raw_ptr()->initializer_.value_->IsFunction(); |
| 7603 } |
| 7604 |
| 7605 |
| 7606 void Field::SetSavedInitialStaticValue(const Instance& value) const { |
| 7607 StorePointer(&raw_ptr()->initializer_.saved_initial_value_, value.raw()); |
7594 } | 7608 } |
7595 | 7609 |
7596 | 7610 |
7597 void Field::EvaluateInitializer() const { | 7611 void Field::EvaluateInitializer() const { |
7598 ASSERT(is_static()); | 7612 ASSERT(is_static()); |
7599 if (value() == Object::sentinel().raw()) { | 7613 if (StaticFieldValue() == Object::sentinel().raw()) { |
7600 set_value(Object::transition_sentinel()); | 7614 SetStaticFieldValue(Object::transition_sentinel()); |
7601 Object& value = Object::Handle(Compiler::EvaluateStaticInitializer(*this)); | 7615 Object& value = Object::Handle(Compiler::EvaluateStaticInitializer(*this)); |
7602 if (value.IsError()) { | 7616 if (value.IsError()) { |
7603 set_value(Object::null_instance()); | 7617 SetStaticFieldValue(Object::null_instance()); |
7604 Exceptions::PropagateError(Error::Cast(value)); | 7618 Exceptions::PropagateError(Error::Cast(value)); |
7605 UNREACHABLE(); | 7619 UNREACHABLE(); |
7606 } | 7620 } |
7607 ASSERT(value.IsNull() || value.IsInstance()); | 7621 ASSERT(value.IsNull() || value.IsInstance()); |
7608 set_value(value.IsNull() ? Instance::null_instance() | 7622 SetStaticFieldValue(value.IsNull() ? Instance::null_instance() |
7609 : Instance::Cast(value)); | 7623 : Instance::Cast(value)); |
7610 return; | 7624 return; |
7611 } else if (value() == Object::transition_sentinel().raw()) { | 7625 } else if (StaticFieldValue() == Object::transition_sentinel().raw()) { |
7612 set_value(Object::null_instance()); | 7626 SetStaticFieldValue(Object::null_instance()); |
7613 const Array& ctor_args = Array::Handle(Array::New(1)); | 7627 const Array& ctor_args = Array::Handle(Array::New(1)); |
7614 const String& field_name = String::Handle(name()); | 7628 const String& field_name = String::Handle(name()); |
7615 ctor_args.SetAt(0, field_name); | 7629 ctor_args.SetAt(0, field_name); |
7616 Exceptions::ThrowByType(Exceptions::kCyclicInitializationError, ctor_args); | 7630 Exceptions::ThrowByType(Exceptions::kCyclicInitializationError, ctor_args); |
7617 UNREACHABLE(); | 7631 UNREACHABLE(); |
7618 return; | 7632 return; |
7619 } | 7633 } |
7620 UNREACHABLE(); | 7634 UNREACHABLE(); |
7621 } | 7635 } |
7622 | 7636 |
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9091 intptr_t token_pos) const { | 9105 intptr_t token_pos) const { |
9092 const String& metaname = String::Handle(Symbols::New(name)); | 9106 const String& metaname = String::Handle(Symbols::New(name)); |
9093 Field& field = Field::Handle(Field::New(metaname, | 9107 Field& field = Field::Handle(Field::New(metaname, |
9094 true, // is_static | 9108 true, // is_static |
9095 false, // is_final | 9109 false, // is_final |
9096 false, // is_const | 9110 false, // is_const |
9097 false, // is_reflectable | 9111 false, // is_reflectable |
9098 cls, | 9112 cls, |
9099 token_pos)); | 9113 token_pos)); |
9100 field.set_type(Type::Handle(Type::DynamicType())); | 9114 field.set_type(Type::Handle(Type::DynamicType())); |
9101 field.set_value(Array::empty_array()); | 9115 field.SetStaticFieldValue(Array::empty_array(), true); |
9102 GrowableObjectArray& metadata = | 9116 GrowableObjectArray& metadata = |
9103 GrowableObjectArray::Handle(this->metadata()); | 9117 GrowableObjectArray::Handle(this->metadata()); |
9104 metadata.Add(field, Heap::kOld); | 9118 metadata.Add(field, Heap::kOld); |
9105 cls.AddField(field); | 9119 cls.AddField(field); |
9106 } | 9120 } |
9107 | 9121 |
9108 | 9122 |
9109 void Library::AddClassMetadata(const Class& cls, | 9123 void Library::AddClassMetadata(const Class& cls, |
9110 const Class& toplevel_class, | 9124 const Class& toplevel_class, |
9111 intptr_t token_pos) const { | 9125 intptr_t token_pos) const { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9185 !obj.IsLibrary() && !obj.IsTypeParameter()) { | 9199 !obj.IsLibrary() && !obj.IsTypeParameter()) { |
9186 return Object::null(); | 9200 return Object::null(); |
9187 } | 9201 } |
9188 const String& metaname = String::Handle(MakeMetadataName(obj)); | 9202 const String& metaname = String::Handle(MakeMetadataName(obj)); |
9189 Field& field = Field::Handle(GetMetadataField(metaname)); | 9203 Field& field = Field::Handle(GetMetadataField(metaname)); |
9190 if (field.IsNull()) { | 9204 if (field.IsNull()) { |
9191 // There is no metadata for this object. | 9205 // There is no metadata for this object. |
9192 return Object::empty_array().raw(); | 9206 return Object::empty_array().raw(); |
9193 } | 9207 } |
9194 Object& metadata = Object::Handle(); | 9208 Object& metadata = Object::Handle(); |
9195 metadata = field.value(); | 9209 metadata = field.StaticFieldValue(); |
9196 if (field.value() == Object::empty_array().raw()) { | 9210 if (field.StaticFieldValue() == Object::empty_array().raw()) { |
9197 metadata = Parser::ParseMetadata(Class::Handle(field.owner()), | 9211 metadata = Parser::ParseMetadata(Class::Handle(field.owner()), |
9198 field.token_pos()); | 9212 field.token_pos()); |
9199 if (metadata.IsArray()) { | 9213 if (metadata.IsArray()) { |
9200 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw()); | 9214 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw()); |
9201 field.set_value(Array::Cast(metadata)); | 9215 field.SetStaticFieldValue(Array::Cast(metadata), true); |
9202 } | 9216 } |
9203 } | 9217 } |
9204 return metadata.raw(); | 9218 return metadata.raw(); |
9205 } | 9219 } |
9206 | 9220 |
9207 | 9221 |
9208 static bool ShouldBePrivate(const String& name) { | 9222 static bool ShouldBePrivate(const String& name) { |
9209 return | 9223 return |
9210 (name.Length() >= 1 && | 9224 (name.Length() >= 1 && |
9211 name.CharAt(0) == '_') || | 9225 name.CharAt(0) == '_') || |
(...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10599 void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) { | 10613 void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) { |
10600 ASSERT(Field::Handle(metadata_field()).IsNull()); | 10614 ASSERT(Field::Handle(metadata_field()).IsNull()); |
10601 Field& field = Field::Handle(Field::New(Symbols::TopLevel(), | 10615 Field& field = Field::Handle(Field::New(Symbols::TopLevel(), |
10602 true, // is_static | 10616 true, // is_static |
10603 false, // is_final | 10617 false, // is_final |
10604 false, // is_const | 10618 false, // is_const |
10605 false, // is_reflectable | 10619 false, // is_reflectable |
10606 owner_class, | 10620 owner_class, |
10607 token_pos)); | 10621 token_pos)); |
10608 field.set_type(Type::Handle(Type::DynamicType())); | 10622 field.set_type(Type::Handle(Type::DynamicType())); |
10609 field.set_value(Array::empty_array()); | 10623 field.SetStaticFieldValue(Array::empty_array(), true); |
10610 set_metadata_field(field); | 10624 set_metadata_field(field); |
10611 owner_class.AddField(field); | 10625 owner_class.AddField(field); |
10612 } | 10626 } |
10613 | 10627 |
10614 | 10628 |
10615 RawObject* Namespace::GetMetadata() const { | 10629 RawObject* Namespace::GetMetadata() const { |
10616 Field& field = Field::Handle(metadata_field()); | 10630 Field& field = Field::Handle(metadata_field()); |
10617 if (field.IsNull()) { | 10631 if (field.IsNull()) { |
10618 // There is no metadata for this object. | 10632 // There is no metadata for this object. |
10619 return Object::empty_array().raw(); | 10633 return Object::empty_array().raw(); |
10620 } | 10634 } |
10621 Object& metadata = Object::Handle(); | 10635 Object& metadata = Object::Handle(); |
10622 metadata = field.value(); | 10636 metadata = field.StaticFieldValue(); |
10623 if (field.value() == Object::empty_array().raw()) { | 10637 if (field.StaticFieldValue() == Object::empty_array().raw()) { |
10624 metadata = Parser::ParseMetadata(Class::Handle(field.owner()), | 10638 metadata = Parser::ParseMetadata(Class::Handle(field.owner()), |
10625 field.token_pos()); | 10639 field.token_pos()); |
10626 if (metadata.IsArray()) { | 10640 if (metadata.IsArray()) { |
10627 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw()); | 10641 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw()); |
10628 field.set_value(Array::Cast(metadata)); | 10642 field.SetStaticFieldValue(Array::Cast(metadata), true); |
10629 } | 10643 } |
10630 } | 10644 } |
10631 return metadata.raw(); | 10645 return metadata.raw(); |
10632 } | 10646 } |
10633 | 10647 |
10634 | 10648 |
10635 const char* Namespace::ToCString() const { | 10649 const char* Namespace::ToCString() const { |
10636 const char* kFormat = "Namespace for library '%s'"; | 10650 const char* kFormat = "Namespace for library '%s'"; |
10637 const Library& lib = Library::Handle(library()); | 10651 const Library& lib = Library::Handle(library()); |
10638 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1; | 10652 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1; |
(...skipping 10851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21490 return tag_label.ToCString(); | 21504 return tag_label.ToCString(); |
21491 } | 21505 } |
21492 | 21506 |
21493 | 21507 |
21494 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21508 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21495 Instance::PrintJSONImpl(stream, ref); | 21509 Instance::PrintJSONImpl(stream, ref); |
21496 } | 21510 } |
21497 | 21511 |
21498 | 21512 |
21499 } // namespace dart | 21513 } // namespace dart |
OLD | NEW |