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-25 21:42:18 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-25 21:42:18 -0700
commitc6034af30882b6a0a38bcf1fe546ed3dfd3bed04 (patch)
treed63634d44163ad21ddbbabf9a9386adf697a7aa2 /033exclusive_container.cc
parentf5dfb7f7374c7e78575d0c205db391814be1b434 (diff)
downloadmu-c6034af30882b6a0a38bcf1fe546ed3dfd3bed04.tar.gz
2277 - reagents now have a tree of types
Diffstat (limited to '033exclusive_container.cc')
-rw-r--r--033exclusive_container.cc22
1 files changed, 10 insertions, 12 deletions
diff --git a/033exclusive_container.cc b/033exclusive_container.cc
index 1f591acd..5376e058 100644
--- a/033exclusive_container.cc
+++ b/033exclusive_container.cc
@@ -11,13 +11,9 @@ type_ordinal tmp = Type_ordinal["number-or-point"] = Next_type_ordinal++;
 Type[tmp].size = 2;
 Type[tmp].kind = exclusive_container;
 Type[tmp].name = "number-or-point";
-vector<type_ordinal> t1;
-t1.push_back(number);
-Type[tmp].elements.push_back(t1);
-vector<type_ordinal> t2;
-t2.push_back(point);
-Type[tmp].elements.push_back(t2);
+Type[tmp].elements.push_back(new type_tree(number));
 Type[tmp].element_names.push_back("i");
+Type[tmp].elements.push_back(new type_tree(point));
 Type[tmp].element_names.push_back("p");
 }
 
@@ -36,7 +32,7 @@ recipe main [
 +mem: storing 34 in location 5
 +mem: storing 35 in location 6
 
-:(before "End size_of(types) Cases")
+:(before "End size_of(type) Cases")
 if (t.kind == exclusive_container) {
   // size of an exclusive container is the size of its largest variant
   // (So like containers, it can't contain arrays.)
@@ -89,7 +85,7 @@ case MAYBE_CONVERT: {
   }
   reagent base = inst.ingredients.at(0);
   canonize_type(base);
-  if (base.types.empty() || Type[base.types.at(0)].kind != exclusive_container) {
+  if (!base.type || !base.type->value || Type[base.type->value].kind != exclusive_container) {
     raise_error << maybe(Recipe[r].name) << "first ingredient of 'maybe-convert' should be an exclusive-container, but got " << base.original_string << '\n' << end();
     break;
   }
@@ -101,7 +97,8 @@ case MAYBE_CONVERT: {
 }
 :(before "End Primitive Recipe Implementations")
 case MAYBE_CONVERT: {
-  reagent base = canonize(current_instruction().ingredients.at(0));
+  reagent base = current_instruction().ingredients.at(0);
+  canonize(base);
   long long int base_address = base.value;
   if (base_address == 0) {
     raise_error << maybe(current_recipe_name()) << "tried to access location 0 in '" << current_instruction().to_string() << "'\n" << end();
@@ -160,9 +157,10 @@ recipe main [
 :(before "End size_mismatch(x) Cases")
 if (current_instruction().operation == MERGE
     && !current_instruction().products.empty()
-    && !current_instruction().products.at(0).types.empty()) {
-  reagent x = canonize(current_instruction().products.at(0));
-  if (Type[x.types.at(0)].kind == exclusive_container) {
+    && current_instruction().products.at(0).type) {
+  reagent x = current_instruction().products.at(0);
+  canonize(x);
+  if (Type[x.type->value].kind == exclusive_container) {
     return size_of(x) < SIZE(data);
   }
 }