about summary refs log tree commit diff stats
path: root/055shape_shifting_container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-11-06 11:54:20 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-11-06 11:54:20 -0800
commit4769dd2e8721e41769fce0a98523fe2e50035277 (patch)
tree964923da99f11e8a187fff8103b76f751035bb49 /055shape_shifting_container.cc
parent571791babc25dce11c188ece3530817a1c80391c (diff)
downloadmu-4769dd2e8721e41769fce0a98523fe2e50035277.tar.gz
3638
Reorder a couple of nonsensically-placed fragments.
Diffstat (limited to '055shape_shifting_container.cc')
-rw-r--r--055shape_shifting_container.cc31
1 files changed, 15 insertions, 16 deletions
diff --git a/055shape_shifting_container.cc b/055shape_shifting_container.cc
index 044e7089..352124c7 100644
--- a/055shape_shifting_container.cc
+++ b/055shape_shifting_container.cc
@@ -223,6 +223,13 @@ def main [
 # no other stores
 % CHECK_EQ(trace_count_prefix("mem", "storing"), 7);
 
+:(before "End variant_type Special-cases")
+if (contains_type_ingredient(element)) {
+  if (!type->right)
+    raise << "illegal type " << to_string(type) << " seems to be missing a type ingredient or three while computing variant type of exclusive-container\n" << end();
+  replace_type_ingredients(element.type, type->right, info);
+}
+
 :(scenario get_on_shape_shifting_container)
 container foo:_t [
   x:_t
@@ -295,15 +302,6 @@ replace_type_ingredients(element, full_type, exclusive_container_info, location_
 replace_type_ingredients(element, type, info, location_for_error_messages);
 if (contains_type_ingredient(element)) return;  // error raised elsewhere
 
-:(code)
-void replace_type_ingredients(reagent& element, const type_tree* caller_type, const type_info& info, const string& location_for_error_messages) {
-  if (contains_type_ingredient(element)) {
-    if (!caller_type->right)
-      raise << "illegal type " << names_to_string(caller_type) << " seems to be missing a type ingredient or three" << location_for_error_messages << '\n' << end();
-    replace_type_ingredients(element.type, caller_type->right, info);
-  }
-}
-
 :(after "Compute size_of Container")
 assert(!contains_type_ingredient(type));
 :(after "Compute size_of Exclusive Container")
@@ -320,6 +318,14 @@ bool contains_type_ingredient(const type_tree* type) {
   return contains_type_ingredient(type->left) || contains_type_ingredient(type->right);
 }
 
+void replace_type_ingredients(reagent& element, const type_tree* caller_type, const type_info& info, const string& location_for_error_messages) {
+  if (contains_type_ingredient(element)) {
+    if (!caller_type->right)
+      raise << "illegal type " << names_to_string(caller_type) << " seems to be missing a type ingredient or three" << location_for_error_messages << '\n' << end();
+    replace_type_ingredients(element.type, caller_type->right, info);
+  }
+}
+
 // replace all type_ingredients in element_type with corresponding elements of callsite_type
 void replace_type_ingredients(type_tree* element_type, const type_tree* callsite_type, const type_info& container_info) {
   if (!callsite_type) return;  // error but it's already been raised above
@@ -681,10 +687,3 @@ def main [
   1:foo:bar <- merge 1/y, 23
 ]
 +error: main: too few ingredients in '1:foo:bar <- merge 1/y, 23'
-
-:(before "End variant_type Special-cases")
-if (contains_type_ingredient(element)) {
-  if (!type->right)
-    raise << "illegal type " << to_string(type) << " seems to be missing a type ingredient or three while computing variant type of exclusive-container\n" << end();
-  replace_type_ingredients(element.type, type->right, info);
-}