about summary refs log tree commit diff stats
path: root/010vm.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-10-26 01:19:27 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-26 01:19:27 -0700
commit7bba6e7bb7fd7bfdfc71626a34a08cb96a084b74 (patch)
tree2e053b799990e3f561a178f2a3340e9a131617ad /010vm.cc
parent9cc389ce771636c1350c269ef042c47c427ecd28 (diff)
downloadmu-7bba6e7bb7fd7bfdfc71626a34a08cb96a084b74.tar.gz
2282
Switch format for tracing reagents in preparation for trees rather than
arrays of properties.
Diffstat (limited to '010vm.cc')
-rw-r--r--010vm.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/010vm.cc b/010vm.cc
index 8e3bab59..d0a5fee5 100644
--- a/010vm.cc
+++ b/010vm.cc
@@ -286,20 +286,28 @@ reagent::reagent() :value(0), initialized(false), type(NULL) {
 
 string reagent::to_string() const {
   ostringstream out;
-  out << "{name: \"" << name << "\"";
   if (!properties.empty()) {
-    out << ", properties: [";
+    out << "{";
     for (long long int i = 0; i < SIZE(properties); ++i) {
+      if (i > 0) out << ", ";
       out << "\"" << properties.at(i).first << "\": ";
+      if (properties.at(i).second.empty()) {
+        out << "\"\"";
+        continue;
+      }
+      if (SIZE(properties.at(i).second) == 1) {
+        out << "\"" << properties.at(i).second.at(0) << "\"";
+        continue;
+      }
+      out << "<";
       for (long long int j = 0; j < SIZE(properties.at(i).second); ++j) {
-        if (j > 0) out << ':';
+        if (j > 0) out << " : ";
         out << "\"" << properties.at(i).second.at(j) << "\"";
       }
-      if (i < SIZE(properties)-1) out << ", ";
-      else out << "]";
+      out << ">";
     }
+    out << "}";
   }
-  out << "}";
   return out.str();
 }