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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 object_store->set_stacktrace_class(cls); | 591 object_store->set_stacktrace_class(cls); |
592 RegisterClass(cls, "Stacktrace", impl_script, core_impl_lib); | 592 RegisterClass(cls, "Stacktrace", impl_script, core_impl_lib); |
593 pending_classes.Add(cls, Heap::kOld); | 593 pending_classes.Add(cls, Heap::kOld); |
594 // Super type set below, after Object is allocated. | 594 // Super type set below, after Object is allocated. |
595 | 595 |
596 cls = Class::New<JSRegExp>(); | 596 cls = Class::New<JSRegExp>(); |
597 object_store->set_jsregexp_class(cls); | 597 object_store->set_jsregexp_class(cls); |
598 RegisterClass(cls, "JSSyntaxRegExp", impl_script, core_impl_lib); | 598 RegisterClass(cls, "JSSyntaxRegExp", impl_script, core_impl_lib); |
599 pending_classes.Add(cls, Heap::kOld); | 599 pending_classes.Add(cls, Heap::kOld); |
600 | 600 |
| 601 cls = Class::New<WeakProperty>(); |
| 602 object_store->set_weak_property_class(cls); |
| 603 RegisterClass(cls, "WeakProperty", impl_script, core_impl_lib); |
| 604 pending_classes.Add(cls, Heap::kOld); |
| 605 |
601 // Initialize the base interfaces used by the core VM classes. | 606 // Initialize the base interfaces used by the core VM classes. |
602 const Script& script = Script::Handle(Bootstrap::LoadScript()); | 607 const Script& script = Script::Handle(Bootstrap::LoadScript()); |
603 | 608 |
604 // Allocate and initialize the Object class and type. The Object | 609 // Allocate and initialize the Object class and type. The Object |
605 // class and ByteArray subclasses are the only pre-allocated, | 610 // class and ByteArray subclasses are the only pre-allocated, |
606 // non-interface classes in the core library. | 611 // non-interface classes in the core library. |
607 cls = Class::New<Instance>(); | 612 cls = Class::New<Instance>(); |
608 object_store->set_object_class(cls); | 613 object_store->set_object_class(cls); |
609 cls.set_name(String::Handle(Symbols::New("Object"))); | 614 cls.set_name(String::Handle(Symbols::New("Object"))); |
610 cls.set_script(script); | 615 cls.set_script(script); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 | 936 |
932 cls = Class::New<Bool>(); | 937 cls = Class::New<Bool>(); |
933 object_store->set_bool_class(cls); | 938 object_store->set_bool_class(cls); |
934 | 939 |
935 cls = Class::New<Stacktrace>(); | 940 cls = Class::New<Stacktrace>(); |
936 object_store->set_stacktrace_class(cls); | 941 object_store->set_stacktrace_class(cls); |
937 | 942 |
938 cls = Class::New<JSRegExp>(); | 943 cls = Class::New<JSRegExp>(); |
939 object_store->set_jsregexp_class(cls); | 944 object_store->set_jsregexp_class(cls); |
940 | 945 |
| 946 cls = Class::New<WeakProperty>(); |
| 947 object_store->set_weak_property_class(cls); |
| 948 |
941 // Allocate pre-initialized values. | 949 // Allocate pre-initialized values. |
942 Bool& bool_value = Bool::Handle(); | 950 Bool& bool_value = Bool::Handle(); |
943 bool_value = Bool::New(true); | 951 bool_value = Bool::New(true); |
944 object_store->set_true_value(bool_value); | 952 object_store->set_true_value(bool_value); |
945 bool_value = Bool::New(false); | 953 bool_value = Bool::New(false); |
946 object_store->set_false_value(bool_value); | 954 object_store->set_false_value(bool_value); |
947 } | 955 } |
948 | 956 |
949 | 957 |
950 void Object::Print() const { | 958 void Object::Print() const { |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1580 const Type& signature_type = Type::Handle(result.SignatureType()); | 1588 const Type& signature_type = Type::Handle(result.SignatureType()); |
1581 ASSERT(!signature_type.IsFinalized()); | 1589 ASSERT(!signature_type.IsFinalized()); |
1582 const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld)); | 1590 const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld)); |
1583 new_canonical_types.SetAt(0, signature_type); | 1591 new_canonical_types.SetAt(0, signature_type); |
1584 result.set_canonical_types(new_canonical_types); | 1592 result.set_canonical_types(new_canonical_types); |
1585 return result.raw(); | 1593 return result.raw(); |
1586 } | 1594 } |
1587 | 1595 |
1588 | 1596 |
1589 RawClass* Class::GetClass(intptr_t class_id, bool is_signature_class) { | 1597 RawClass* Class::GetClass(intptr_t class_id, bool is_signature_class) { |
1590 if (class_id >= kIntegerCid && class_id <= kJSRegExpCid) { | 1598 if (class_id >= kIntegerCid && class_id <= kWeakPropertyCid) { |
1591 return Isolate::Current()->class_table()->At(class_id); | 1599 return Isolate::Current()->class_table()->At(class_id); |
1592 } | 1600 } |
1593 if (class_id >= kNumPredefinedCids) { | 1601 if (class_id >= kNumPredefinedCids) { |
1594 if (is_signature_class) { | 1602 if (is_signature_class) { |
1595 return Class::New<Closure>(); | 1603 return Class::New<Closure>(); |
1596 } | 1604 } |
1597 return Class::New<Instance>(); | 1605 return Class::New<Instance>(); |
1598 } | 1606 } |
1599 OS::Print("Class::GetClass id unknown: %d\n", class_id); | 1607 OS::Print("Class::GetClass id unknown: %d\n", class_id); |
1600 UNREACHABLE(); | 1608 UNREACHABLE(); |
(...skipping 9426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11027 | 11035 |
11028 const char* JSRegExp::ToCString() const { | 11036 const char* JSRegExp::ToCString() const { |
11029 const String& str = String::Handle(pattern()); | 11037 const String& str = String::Handle(pattern()); |
11030 const char* format = "JSRegExp: pattern=%s flags=%s"; | 11038 const char* format = "JSRegExp: pattern=%s flags=%s"; |
11031 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 11039 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
11032 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 11040 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
11033 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 11041 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
11034 return chars; | 11042 return chars; |
11035 } | 11043 } |
11036 | 11044 |
| 11045 |
| 11046 RawWeakProperty* WeakProperty::New(Heap::Space space) { |
| 11047 ASSERT(Isolate::Current()->object_store()->weak_property_class() |
| 11048 != Class::null()); |
| 11049 WeakProperty& result = WeakProperty::Handle(); |
| 11050 { |
| 11051 RawObject* raw = Object::Allocate(WeakProperty::kClassId, |
| 11052 WeakProperty::InstanceSize(), |
| 11053 space); |
| 11054 NoGCScope no_gc; |
| 11055 result ^= raw; |
| 11056 } |
| 11057 return result.raw(); |
| 11058 } |
| 11059 |
| 11060 |
| 11061 const char* WeakProperty::ToCString() const { |
| 11062 return "WeakProperty"; |
| 11063 } |
| 11064 |
11037 } // namespace dart | 11065 } // namespace dart |
OLD | NEW |