diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-29 23:55:51 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-29 23:55:51 -0700 |
commit | 72cccd08c7a3462072b8ae5aea1576f010bf12c0 (patch) | |
tree | bffdef85020f1393c74bf8b21d605f87e9f6a889 /cpp/010vm.cc | |
parent | 288728767877f95e644d02c0f15d5d319832187f (diff) | |
download | mu-72cccd08c7a3462072b8ae5aea1576f010bf12c0.tar.gz |
1225
Finally start tracing the actual instructions as they run.
Diffstat (limited to 'cpp/010vm.cc')
-rw-r--r-- | cpp/010vm.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cpp/010vm.cc b/cpp/010vm.cc index 40f8f269..e38a5958 100644 --- a/cpp/010vm.cc +++ b/cpp/010vm.cc @@ -30,6 +30,7 @@ struct instruction { vector<reagent> products; // only if !is_label instruction(); void clear(); + string to_string() const; }; :(before "struct instruction") @@ -218,6 +219,22 @@ string reagent::to_string() const { return out.str(); } +string instruction::to_string() const { + if (is_label) return label; + ostringstream out; + for (size_t i = 0; i < products.size(); ++i) { + if (i > 0) out << ", "; + out << products[i].to_string(); + } + if (!products.empty()) out << " <- "; + out << name << ' '; + for (size_t i = 0; i < ingredients.size(); ++i) { + if (i > 0) out << ", "; + out << ingredients[i].to_string(); + } + return out.str(); +} + string slurp_until(istream& in, char delim) { ostringstream out; char c; |