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 8929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8940 OS::SNPrint(chars, len, kFormat, prefix.ToCString()); | 8940 OS::SNPrint(chars, len, kFormat, prefix.ToCString()); |
8941 return chars; | 8941 return chars; |
8942 } | 8942 } |
8943 | 8943 |
8944 | 8944 |
8945 void LibraryPrefix::PrintToJSONStream(JSONStream* stream, bool ref) const { | 8945 void LibraryPrefix::PrintToJSONStream(JSONStream* stream, bool ref) const { |
8946 JSONObject jsobj(stream); | 8946 JSONObject jsobj(stream); |
8947 } | 8947 } |
8948 | 8948 |
8949 | 8949 |
8950 void Namespace::set_metadata_field(const Field& value) const { | |
8951 StorePointer(&raw_ptr()->metadata_field_, value.raw()); | |
8952 } | |
8953 | |
8954 | |
8955 void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) { | |
8956 ASSERT(Field::Handle(metadata_field()).IsNull()); | |
8957 Field& field = Field::Handle(Field::New(Symbols::TopLevel(), | |
8958 true, // is_static | |
8959 false, // is_final | |
8960 false, // is_const | |
8961 owner_class, | |
8962 token_pos)); | |
8963 field.set_type(Type::Handle(Type::DynamicType())); | |
8964 field.set_value(Array::empty_array()); | |
8965 set_metadata_field(field); | |
8966 } | |
8967 | |
8968 | |
8969 RawObject* Namespace::GetMetadata() const { | |
8970 Field& field = Field::Handle(metadata_field()); | |
8971 if (field.IsNull()) { | |
8972 // There is no metadata for this object. | |
8973 return Object::empty_array().raw(); | |
8974 } | |
8975 Object& metadata = Object::Handle(); | |
8976 metadata = field.value(); | |
8977 if (field.value() == Object::empty_array().raw()) { | |
8978 metadata = Parser::ParseMetadata(Class::Handle(field.owner()), | |
8979 field.token_pos()); | |
8980 if (metadata.IsArray()) { | |
8981 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw()); | |
8982 field.set_value(Array::Cast(metadata)); | |
8983 } | |
8984 } | |
8985 return metadata.raw(); | |
8986 } | |
8987 | |
8988 | |
8989 const char* Namespace::ToCString() const { | 8950 const char* Namespace::ToCString() const { |
8990 const char* kFormat = "Namespace for library '%s'"; | 8951 const char* kFormat = "Namespace for library '%s'"; |
8991 const Library& lib = Library::Handle(library()); | 8952 const Library& lib = Library::Handle(library()); |
8992 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1; | 8953 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1; |
8993 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 8954 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
8994 OS::SNPrint(chars, len, kFormat, lib.ToCString()); | 8955 OS::SNPrint(chars, len, kFormat, lib.ToCString()); |
8995 return chars; | 8956 return chars; |
8996 } | 8957 } |
8997 | 8958 |
8998 | 8959 |
(...skipping 8550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17549 return "_MirrorReference"; | 17510 return "_MirrorReference"; |
17550 } | 17511 } |
17551 | 17512 |
17552 | 17513 |
17553 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17514 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
17554 Instance::PrintToJSONStream(stream, ref); | 17515 Instance::PrintToJSONStream(stream, ref); |
17555 } | 17516 } |
17556 | 17517 |
17557 | 17518 |
17558 } // namespace dart | 17519 } // namespace dart |
OLD | NEW |