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 6773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6784 return raw_ptr()->source_; | 6784 return raw_ptr()->source_; |
6785 } | 6785 } |
6786 | 6786 |
6787 | 6787 |
6788 RawString* Script::GenerateSource() const { | 6788 RawString* Script::GenerateSource() const { |
6789 const TokenStream& token_stream = TokenStream::Handle(tokens()); | 6789 const TokenStream& token_stream = TokenStream::Handle(tokens()); |
6790 return token_stream.GenerateSource(); | 6790 return token_stream.GenerateSource(); |
6791 } | 6791 } |
6792 | 6792 |
6793 | 6793 |
| 6794 const char* Script::GetKindAsCString() const { |
| 6795 switch (kind()) { |
| 6796 case RawScript::kScriptTag: |
| 6797 return "script"; |
| 6798 case RawScript::kLibraryTag: |
| 6799 return "library"; |
| 6800 case RawScript::kSourceTag: |
| 6801 return "source"; |
| 6802 case RawScript::kPatchTag: |
| 6803 return "patch"; |
| 6804 default: |
| 6805 UNIMPLEMENTED(); |
| 6806 } |
| 6807 UNREACHABLE(); |
| 6808 return NULL; |
| 6809 } |
| 6810 |
| 6811 |
6794 void Script::set_url(const String& value) const { | 6812 void Script::set_url(const String& value) const { |
6795 StorePointer(&raw_ptr()->url_, value.raw()); | 6813 StorePointer(&raw_ptr()->url_, value.raw()); |
6796 } | 6814 } |
6797 | 6815 |
6798 | 6816 |
6799 void Script::set_source(const String& value) const { | 6817 void Script::set_source(const String& value) const { |
6800 StorePointer(&raw_ptr()->source_, value.raw()); | 6818 StorePointer(&raw_ptr()->source_, value.raw()); |
6801 } | 6819 } |
6802 | 6820 |
6803 | 6821 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7035 } | 7053 } |
7036 | 7054 |
7037 | 7055 |
7038 const char* Script::ToCString() const { | 7056 const char* Script::ToCString() const { |
7039 return "Script"; | 7057 return "Script"; |
7040 } | 7058 } |
7041 | 7059 |
7042 | 7060 |
7043 void Script::PrintToJSONStream(JSONStream* stream, bool ref) const { | 7061 void Script::PrintToJSONStream(JSONStream* stream, bool ref) const { |
7044 JSONObject jsobj(stream); | 7062 JSONObject jsobj(stream); |
| 7063 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 7064 intptr_t id = ring->GetIdForObject(raw()); |
| 7065 jsobj.AddProperty("type", JSONType(ref)); |
| 7066 jsobj.AddProperty("id", id); |
| 7067 const String& name = String::Handle(url()); |
| 7068 jsobj.AddProperty("name", name.ToCString()); |
| 7069 jsobj.AddProperty("kind", GetKindAsCString()); |
| 7070 if (ref) { |
| 7071 return; |
| 7072 } |
| 7073 const String& source = String::Handle(Source()); |
| 7074 jsobj.AddProperty("source", source.ToCString()); |
7045 } | 7075 } |
7046 | 7076 |
7047 | 7077 |
7048 DictionaryIterator::DictionaryIterator(const Library& library) | 7078 DictionaryIterator::DictionaryIterator(const Library& library) |
7049 : array_(Array::Handle(library.dictionary())), | 7079 : array_(Array::Handle(library.dictionary())), |
7050 // Last element in array is a Smi indicating the number of entries used. | 7080 // Last element in array is a Smi indicating the number of entries used. |
7051 size_(Array::Handle(library.dictionary()).Length() - 1), | 7081 size_(Array::Handle(library.dictionary()).Length() - 1), |
7052 next_ix_(0) { | 7082 next_ix_(0) { |
7053 MoveToNextObject(); | 7083 MoveToNextObject(); |
7054 } | 7084 } |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8152 if (entry.IsFunction()) { | 8182 if (entry.IsFunction()) { |
8153 const Function& func = Function::Cast(entry); | 8183 const Function& func = Function::Cast(entry); |
8154 if (func.kind() == RawFunction::kRegularFunction || | 8184 if (func.kind() == RawFunction::kRegularFunction || |
8155 func.kind() == RawFunction::kGetterFunction || | 8185 func.kind() == RawFunction::kGetterFunction || |
8156 func.kind() == RawFunction::kSetterFunction) { | 8186 func.kind() == RawFunction::kSetterFunction) { |
8157 jsarr.AddValue(func); | 8187 jsarr.AddValue(func); |
8158 } | 8188 } |
8159 } | 8189 } |
8160 } | 8190 } |
8161 } | 8191 } |
| 8192 { |
| 8193 JSONArray jsarr(&jsobj, "scripts"); |
| 8194 Array& scripts = Array::Handle(LoadedScripts()); |
| 8195 Script& script = Script::Handle(); |
| 8196 for (intptr_t i = 0; i < scripts.Length(); i++) { |
| 8197 script ^= scripts.At(i); |
| 8198 jsarr.AddValue(script); |
| 8199 } |
| 8200 } |
8162 } | 8201 } |
8163 | 8202 |
8164 | 8203 |
8165 RawLibrary* LibraryPrefix::GetLibrary(int index) const { | 8204 RawLibrary* LibraryPrefix::GetLibrary(int index) const { |
8166 if ((index >= 0) || (index < num_imports())) { | 8205 if ((index >= 0) || (index < num_imports())) { |
8167 const Array& imports = Array::Handle(this->imports()); | 8206 const Array& imports = Array::Handle(this->imports()); |
8168 Namespace& import = Namespace::Handle(); | 8207 Namespace& import = Namespace::Handle(); |
8169 import ^= imports.At(index); | 8208 import ^= imports.At(index); |
8170 return import.library(); | 8209 return import.library(); |
8171 } | 8210 } |
(...skipping 7838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16010 return "_MirrorReference"; | 16049 return "_MirrorReference"; |
16011 } | 16050 } |
16012 | 16051 |
16013 | 16052 |
16014 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 16053 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
16015 Instance::PrintToJSONStream(stream, ref); | 16054 Instance::PrintToJSONStream(stream, ref); |
16016 } | 16055 } |
16017 | 16056 |
16018 | 16057 |
16019 } // namespace dart | 16058 } // namespace dart |
OLD | NEW |