Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: runtime/vm/object.cc

Issue 1160943002: Give structured information about imports and export in the service's library response. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add test Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 9898 matching lines...) Expand 10 before | Expand all | Expand 10 after
9909 Class& klass = Class::Handle(); 9909 Class& klass = Class::Handle();
9910 while (class_iter.HasNext()) { 9910 while (class_iter.HasNext()) {
9911 klass = class_iter.GetNextClass(); 9911 klass = class_iter.GetNextClass();
9912 if (!klass.IsCanonicalSignatureClass() && 9912 if (!klass.IsCanonicalSignatureClass() &&
9913 !klass.IsMixinApplication()) { 9913 !klass.IsMixinApplication()) {
9914 jsarr.AddValue(klass); 9914 jsarr.AddValue(klass);
9915 } 9915 }
9916 } 9916 }
9917 } 9917 }
9918 { 9918 {
9919 JSONArray jsarr(&jsobj, "imports"); 9919 JSONArray jsarr(&jsobj, "dependencies");
9920 Library& lib = Library::Handle(); 9920
9921 for (intptr_t i = 0; i < num_imports(); i++) { 9921 Array& ports = Array::Handle();
9922 lib = ImportLibraryAt(i); 9922 Namespace& ns = Namespace::Handle();
9923 jsarr.AddValue(lib); 9923 Library& target = Library::Handle();
9924
9925 // Unprefixed imports.
9926 ports = imports();
9927 for (intptr_t i = 0; i < ports.Length(); i++) {
9928 ns ^= ports.At(i);
9929 if (ns.IsNull()) continue;
9930
9931 JSONObject jsdep(&jsarr);
9932 jsdep.AddProperty("isDeferred", false);
9933 jsdep.AddProperty("isExport", false);
9934 jsdep.AddProperty("isImport", true);
9935 target = ns.library();
9936 jsdep.AddProperty("target", target);
9937 }
9938
9939 // Exports.
9940 ports = exports();
9941 for (intptr_t i = 0; i < ports.Length(); i++) {
9942 ns ^= ports.At(i);
9943 if (ns.IsNull()) continue;
9944
9945 JSONObject jsdep(&jsarr);
9946 jsdep.AddProperty("isDeferred", false);
9947 jsdep.AddProperty("isExport", true);
9948 jsdep.AddProperty("isImport", false);
9949 target = ns.library();
9950 jsdep.AddProperty("target", target);
9951 }
9952
9953 // Prefixed imports.
9954 DictionaryIterator entries(*this);
9955 Object& entry = Object::Handle();
9956 LibraryPrefix& prefix = LibraryPrefix::Handle();
9957 String& prefixName = String::Handle();
9958 while (entries.HasNext()) {
9959 entry = entries.GetNext();
9960 if (entry.IsLibraryPrefix()) {
9961 prefix ^= entry.raw();
9962 ports = prefix.imports();
9963 for (intptr_t i = 0; i < ports.Length(); i++) {
9964 ns ^= ports.At(i);
9965 if (ns.IsNull()) continue;
9966
9967 JSONObject jsdep(&jsarr);
9968 jsdep.AddProperty("isDeferred", prefix.is_deferred_load());
9969 jsdep.AddProperty("isExport", false);
9970 jsdep.AddProperty("isImport", true);
9971 prefixName = prefix.name();
9972 ASSERT(!prefixName.IsNull());
9973 jsdep.AddProperty("prefix", prefixName.ToCString());
9974 target = ns.library();
9975 jsdep.AddProperty("target", target);
9976 }
9977 }
9924 } 9978 }
9925 } 9979 }
9926 { 9980 {
9927 JSONArray jsarr(&jsobj, "variables"); 9981 JSONArray jsarr(&jsobj, "variables");
9928 DictionaryIterator entries(*this); 9982 DictionaryIterator entries(*this);
9929 Object& entry = Object::Handle(); 9983 Object& entry = Object::Handle();
9930 while (entries.HasNext()) { 9984 while (entries.HasNext()) {
9931 entry = entries.GetNext(); 9985 entry = entries.GetNext();
9932 if (entry.IsField()) { 9986 if (entry.IsField()) {
9933 jsarr.AddValue(entry); 9987 jsarr.AddValue(entry);
(...skipping 10805 matching lines...) Expand 10 before | Expand all | Expand 10 after
20739 return tag_label.ToCString(); 20793 return tag_label.ToCString();
20740 } 20794 }
20741 20795
20742 20796
20743 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20797 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20744 Instance::PrintJSONImpl(stream, ref); 20798 Instance::PrintJSONImpl(stream, ref);
20745 } 20799 }
20746 20800
20747 20801
20748 } // namespace dart 20802 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698