about summary refs log tree commit diff stats
path: root/033exclusive_container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-10-01 16:28:47 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-01 16:28:47 -0700
commit96bb317f32d4e56af526076ebc472ec5ba5b3108 (patch)
tree7527a1f2a9a01910320f0634bc37a82a44aac844 /033exclusive_container.cc
parenta6ce88d7ec5c952189e8d4df2819d4a6d5e7f395 (diff)
downloadmu-96bb317f32d4e56af526076ebc472ec5ba5b3108.tar.gz
2230
Diffstat (limited to '033exclusive_container.cc')
-rw-r--r--033exclusive_container.cc28
1 files changed, 17 insertions, 11 deletions
diff --git a/033exclusive_container.cc b/033exclusive_container.cc
index ae4a7e4c..d4973c7c 100644
--- a/033exclusive_container.cc
+++ b/033exclusive_container.cc
@@ -81,24 +81,30 @@ recipe main [
 MAYBE_CONVERT,
 :(before "End Primitive Recipe Numbers")
 Recipe_ordinal["maybe-convert"] = MAYBE_CONVERT;
-:(before "End Primitive Recipe Implementations")
+:(before "End Primitive Recipe Checks")
 case MAYBE_CONVERT: {
-  if (SIZE(ingredients) != 2) {
-    raise << maybe(current_recipe_name()) << "'maybe-convert' expects exactly 2 ingredients in '" << current_instruction().to_string() << "'\n" << end();
+  if (SIZE(inst.ingredients) != 2) {
+    raise << maybe(Recipe[r].name) << "'maybe-convert' expects exactly 2 ingredients in '" << inst.to_string() << "'\n" << end();
     break;
   }
-  reagent base = canonize(current_instruction().ingredients.at(0));
-  long long int base_address = base.value;
-  if (base_address == 0) {
-    raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << current_instruction().to_string() << "'\n" << end();
+  reagent base = inst.ingredients.at(0);
+  canonize_type(base);
+  if (base.types.empty() || Type[base.types.at(0)].kind != exclusive_container) {
+    raise << current_recipe_name () << "first ingredient of 'maybe-convert' should be an exclusive-container, but got " << base.original_string << '\n' << end();
     break;
   }
-  if (base.types.empty() || Type[base.types.at(0)].kind != exclusive_container) {
-    raise << current_recipe_name () << ": first ingredient of 'maybe-convert' should be an exclusive-container, but got " << base.original_string << '\n' << end();
+  if (!is_literal(inst.ingredients.at(1))) {
+    raise << maybe(Recipe[r].name) << "second ingredient of 'maybe-convert' should have type 'variant', but got " << inst.ingredients.at(1).original_string << '\n' << end();
     break;
   }
-  if (!is_literal(current_instruction().ingredients.at(1))) {
-    raise << maybe(current_recipe_name()) << "second ingredient of 'maybe-convert' should have type 'variant', but got " << current_instruction().ingredients.at(1).original_string << '\n' << end();
+  break;
+}
+:(before "End Primitive Recipe Implementations")
+case MAYBE_CONVERT: {
+  reagent base = canonize(current_instruction().ingredients.at(0));
+  long long int base_address = base.value;
+  if (base_address == 0) {
+    raise << maybe(current_recipe_name()) << "tried to access location 0 in '" << current_instruction().to_string() << "'\n" << end();
     break;
   }
   long long int tag = current_instruction().ingredients.at(1).value;