about summary refs log tree commit diff stats
path: root/010vm.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-01-30 12:03:16 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-01-30 12:03:16 -0800
commit1cfcb62fa11e2f57fb982500c7df810826988dfc (patch)
tree1f330bc2fc87765438f318e934890848035b1285 /010vm.cc
parent2ac236e2bc7b6c392142b296b9f6353ee6d9662e (diff)
downloadmu-1cfcb62fa11e2f57fb982500c7df810826988dfc.tar.gz
2617 - better error messages
When we stash a value, mu does several levels of work for us:

a) First it inserts instructions above the stash to convert the value to
text using to-text-line.
b) to-text-line calls to-text. Both are shape-shifting, so multiple
levels of specialization happen.

To give a good error message, we track the 'stack' of current
specializations at the time of the error, and also check if the
offending instruction at the top-most level looks like it was inserted
while rewriting stash instructions.

Manual example (since booleans can't be stashed at the moment):
  x:boolean <- copy 1/true
  stash x
Diffstat (limited to '010vm.cc')
-rw-r--r--010vm.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/010vm.cc b/010vm.cc
index e772e811..af3bcc98 100644
--- a/010vm.cc
+++ b/010vm.cc
@@ -35,6 +35,7 @@ struct instruction {
   string label;  // only if is_label
   string name;  // only if !is_label
   string old_name;  // before our automatic rewrite rules
+  string original_string;
   recipe_ordinal operation;  // get(Recipe_ordinal, name)
   vector<reagent> ingredients;  // only if !is_label
   vector<reagent> products;  // only if !is_label
@@ -228,7 +229,7 @@ recipe::recipe() {
 instruction::instruction() :is_label(false), operation(IDLE) {
   // End instruction Constructor
 }
-void instruction::clear() { is_label=false; label.clear(); name.clear(); old_name.clear(); operation=IDLE; ingredients.clear(); products.clear(); }
+void instruction::clear() { is_label=false; label.clear(); name.clear(); old_name.clear(); operation=IDLE; ingredients.clear(); products.clear(); original_string.clear(); }
 bool instruction::is_clear() { return !is_label && name.empty(); }
 
 // Reagents have the form <name>:<type>:<type>:.../<property>/<property>/...