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 8935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8946 OS::SNPrint(chars, len, kFormat, prefix.ToCString()); | 8946 OS::SNPrint(chars, len, kFormat, prefix.ToCString()); |
8947 return chars; | 8947 return chars; |
8948 } | 8948 } |
8949 | 8949 |
8950 | 8950 |
8951 void LibraryPrefix::PrintToJSONStream(JSONStream* stream, bool ref) const { | 8951 void LibraryPrefix::PrintToJSONStream(JSONStream* stream, bool ref) const { |
8952 JSONObject jsobj(stream); | 8952 JSONObject jsobj(stream); |
8953 } | 8953 } |
8954 | 8954 |
8955 | 8955 |
| 8956 void Namespace::set_metadata_field(const Field& value) const { |
| 8957 StorePointer(&raw_ptr()->metadata_field_, value.raw()); |
| 8958 } |
| 8959 |
| 8960 |
| 8961 void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) { |
| 8962 ASSERT(Field::Handle(metadata_field()).IsNull()); |
| 8963 Field& field = Field::Handle(Field::New(Symbols::TopLevel(), |
| 8964 true, // is_static |
| 8965 false, // is_final |
| 8966 false, // is_const |
| 8967 owner_class, |
| 8968 token_pos)); |
| 8969 field.set_type(Type::Handle(Type::DynamicType())); |
| 8970 field.set_value(Array::empty_array()); |
| 8971 set_metadata_field(field); |
| 8972 } |
| 8973 |
| 8974 |
| 8975 RawObject* Namespace::GetMetadata() const { |
| 8976 Field& field = Field::Handle(metadata_field()); |
| 8977 if (field.IsNull()) { |
| 8978 // There is no metadata for this object. |
| 8979 return Object::empty_array().raw(); |
| 8980 } |
| 8981 Object& metadata = Object::Handle(); |
| 8982 metadata = field.value(); |
| 8983 if (field.value() == Object::empty_array().raw()) { |
| 8984 metadata = Parser::ParseMetadata(Class::Handle(field.owner()), |
| 8985 field.token_pos()); |
| 8986 if (metadata.IsArray()) { |
| 8987 ASSERT(Array::Cast(metadata).raw() != Object::empty_array().raw()); |
| 8988 field.set_value(Array::Cast(metadata)); |
| 8989 } |
| 8990 } |
| 8991 return metadata.raw(); |
| 8992 } |
| 8993 |
| 8994 |
8956 const char* Namespace::ToCString() const { | 8995 const char* Namespace::ToCString() const { |
8957 const char* kFormat = "Namespace for library '%s'"; | 8996 const char* kFormat = "Namespace for library '%s'"; |
8958 const Library& lib = Library::Handle(library()); | 8997 const Library& lib = Library::Handle(library()); |
8959 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1; | 8998 intptr_t len = OS::SNPrint(NULL, 0, kFormat, lib.ToCString()) + 1; |
8960 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 8999 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
8961 OS::SNPrint(chars, len, kFormat, lib.ToCString()); | 9000 OS::SNPrint(chars, len, kFormat, lib.ToCString()); |
8962 return chars; | 9001 return chars; |
8963 } | 9002 } |
8964 | 9003 |
8965 | 9004 |
(...skipping 8490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17456 return "_MirrorReference"; | 17495 return "_MirrorReference"; |
17457 } | 17496 } |
17458 | 17497 |
17459 | 17498 |
17460 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 17499 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
17461 Instance::PrintToJSONStream(stream, ref); | 17500 Instance::PrintToJSONStream(stream, ref); |
17462 } | 17501 } |
17463 | 17502 |
17464 | 17503 |
17465 } // namespace dart | 17504 } // namespace dart |
OLD | NEW |