Chromium Code Reviews| 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 6528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6539 | 6539 |
| 6540 static RawString* MakeFunctionMetaName(const Function& func) { | 6540 static RawString* MakeFunctionMetaName(const Function& func) { |
| 6541 const String& cname = | 6541 const String& cname = |
| 6542 String::Handle(MakeClassMetaName(Class::Handle(func.origin()))); | 6542 String::Handle(MakeClassMetaName(Class::Handle(func.origin()))); |
| 6543 String& fname = String::Handle(func.name()); | 6543 String& fname = String::Handle(func.name()); |
| 6544 fname = String::Concat(Symbols::At(), fname); | 6544 fname = String::Concat(Symbols::At(), fname); |
| 6545 return String::Concat(cname, fname); | 6545 return String::Concat(cname, fname); |
| 6546 } | 6546 } |
| 6547 | 6547 |
| 6548 | 6548 |
| 6549 static RawString* MakeTypeParameterMetaName(const TypeParameter& param) { | |
| 6550 const String& cname = String::Handle( | |
| 6551 MakeClassMetaName(Class::Handle(param.parameterized_class()))); | |
| 6552 String& pname = String::Handle(param.name()); | |
| 6553 pname = String::Concat(Symbols::At(), pname); | |
| 6554 return String::Concat(cname, pname); | |
|
rmacnak
2013/09/13 01:13:28
We can have a type parameter and function or field
Michael Lippautz (Google)
2013/09/13 01:42:17
I changed the separator symbol. We can change this
| |
| 6555 } | |
| 6556 | |
| 6557 | |
| 6549 void Library::AddMetadata(const Class& cls, | 6558 void Library::AddMetadata(const Class& cls, |
| 6550 const String& name, | 6559 const String& name, |
| 6551 intptr_t token_pos) const { | 6560 intptr_t token_pos) const { |
| 6552 const String& metaname = String::Handle(Symbols::New(name)); | 6561 const String& metaname = String::Handle(Symbols::New(name)); |
| 6553 Field& field = Field::Handle(Field::New(metaname, | 6562 Field& field = Field::Handle(Field::New(metaname, |
| 6554 true, // is_static | 6563 true, // is_static |
| 6555 false, // is_final | 6564 false, // is_final |
| 6556 false, // is_const | 6565 false, // is_const |
| 6557 cls, | 6566 cls, |
| 6558 token_pos)); | 6567 token_pos)); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 6577 } | 6586 } |
| 6578 | 6587 |
| 6579 | 6588 |
| 6580 void Library::AddFunctionMetadata(const Function& func, | 6589 void Library::AddFunctionMetadata(const Function& func, |
| 6581 intptr_t token_pos) const { | 6590 intptr_t token_pos) const { |
| 6582 AddMetadata(Class::Handle(func.origin()), | 6591 AddMetadata(Class::Handle(func.origin()), |
| 6583 String::Handle(MakeFunctionMetaName(func)), | 6592 String::Handle(MakeFunctionMetaName(func)), |
| 6584 token_pos); | 6593 token_pos); |
| 6585 } | 6594 } |
| 6586 | 6595 |
| 6596 | |
| 6597 void Library::AddTypeParameterMetadata(const TypeParameter& param, | |
| 6598 intptr_t token_pos) const { | |
| 6599 AddMetadata(Class::Handle(param.parameterized_class()), | |
| 6600 String::Handle(MakeTypeParameterMetaName(param)), | |
| 6601 token_pos); | |
| 6602 } | |
| 6603 | |
| 6604 | |
| 6587 void Library::AddLibraryMetadata(const Class& cls, intptr_t token_pos) const { | 6605 void Library::AddLibraryMetadata(const Class& cls, intptr_t token_pos) const { |
| 6588 AddMetadata(cls, Symbols::TopLevel(), token_pos); | 6606 AddMetadata(cls, Symbols::TopLevel(), token_pos); |
| 6589 } | 6607 } |
| 6590 | 6608 |
| 6591 | 6609 |
| 6592 RawString* Library::MakeMetadataName(const Object& obj) const { | 6610 RawString* Library::MakeMetadataName(const Object& obj) const { |
| 6593 if (obj.IsClass()) { | 6611 if (obj.IsClass()) { |
| 6594 return MakeClassMetaName(Class::Cast(obj)); | 6612 return MakeClassMetaName(Class::Cast(obj)); |
| 6595 } else if (obj.IsField()) { | 6613 } else if (obj.IsField()) { |
| 6596 return MakeFieldMetaName(Field::Cast(obj)); | 6614 return MakeFieldMetaName(Field::Cast(obj)); |
| 6597 } else if (obj.IsFunction()) { | 6615 } else if (obj.IsFunction()) { |
| 6598 return MakeFunctionMetaName(Function::Cast(obj)); | 6616 return MakeFunctionMetaName(Function::Cast(obj)); |
| 6599 } else if (obj.IsLibrary()) { | 6617 } else if (obj.IsLibrary()) { |
| 6600 return Symbols::TopLevel().raw(); | 6618 return Symbols::TopLevel().raw(); |
| 6619 } else if (obj.IsTypeParameter()) { | |
| 6620 return MakeTypeParameterMetaName(TypeParameter::Cast(obj)); | |
| 6601 } | 6621 } |
| 6602 UNIMPLEMENTED(); | 6622 UNIMPLEMENTED(); |
| 6603 return String::null(); | 6623 return String::null(); |
| 6604 } | 6624 } |
| 6605 | 6625 |
| 6606 | 6626 |
| 6607 RawField* Library::GetMetadataField(const String& metaname) const { | 6627 RawField* Library::GetMetadataField(const String& metaname) const { |
| 6608 const GrowableObjectArray& metadata = | 6628 const GrowableObjectArray& metadata = |
| 6609 GrowableObjectArray::Handle(this->metadata()); | 6629 GrowableObjectArray::Handle(this->metadata()); |
| 6610 Field& entry = Field::Handle(); | 6630 Field& entry = Field::Handle(); |
| 6611 String& entryname = String::Handle(); | 6631 String& entryname = String::Handle(); |
| 6612 intptr_t num_entries = metadata.Length(); | 6632 intptr_t num_entries = metadata.Length(); |
| 6613 for (intptr_t i = 0; i < num_entries; i++) { | 6633 for (intptr_t i = 0; i < num_entries; i++) { |
| 6614 entry ^= metadata.At(i); | 6634 entry ^= metadata.At(i); |
| 6615 entryname = entry.name(); | 6635 entryname = entry.name(); |
| 6616 if (entryname.Equals(metaname)) { | 6636 if (entryname.Equals(metaname)) { |
| 6617 return entry.raw(); | 6637 return entry.raw(); |
| 6618 } | 6638 } |
| 6619 } | 6639 } |
| 6620 return Field::null(); | 6640 return Field::null(); |
| 6621 } | 6641 } |
| 6622 | 6642 |
| 6623 | 6643 |
| 6624 RawObject* Library::GetMetadata(const Object& obj) const { | 6644 RawObject* Library::GetMetadata(const Object& obj) const { |
| 6625 if (!obj.IsClass() && !obj.IsField() && !obj.IsFunction() && | 6645 if (!obj.IsClass() && !obj.IsField() && !obj.IsFunction() && |
| 6626 !obj.IsLibrary()) { | 6646 !obj.IsLibrary() && !obj.IsTypeParameter()) { |
| 6627 return Object::null(); | 6647 return Object::null(); |
| 6628 } | 6648 } |
| 6629 const String& metaname = String::Handle(MakeMetadataName(obj)); | 6649 const String& metaname = String::Handle(MakeMetadataName(obj)); |
| 6630 Field& field = Field::Handle(GetMetadataField(metaname)); | 6650 Field& field = Field::Handle(GetMetadataField(metaname)); |
| 6631 if (field.IsNull()) { | 6651 if (field.IsNull()) { |
| 6632 // There is no metadata for this object. | 6652 // There is no metadata for this object. |
| 6633 return Object::empty_array().raw();; | 6653 return Object::empty_array().raw();; |
| 6634 } | 6654 } |
| 6635 Object& metadata = Object::Handle(); | 6655 Object& metadata = Object::Handle(); |
| 6636 metadata = field.value(); | 6656 metadata = field.value(); |
| (...skipping 8248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14885 return "_MirrorReference"; | 14905 return "_MirrorReference"; |
| 14886 } | 14906 } |
| 14887 | 14907 |
| 14888 | 14908 |
| 14889 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14909 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 14890 JSONObject jsobj(stream); | 14910 JSONObject jsobj(stream); |
| 14891 } | 14911 } |
| 14892 | 14912 |
| 14893 | 14913 |
| 14894 } // namespace dart | 14914 } // namespace dart |
| OLD | NEW |