about summary refs log tree commit diff stats
path: root/053recipe_header.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-12 10:00:43 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-12 10:00:43 -0700
commit59e47aca14ce352a1814953df4be220406c94747 (patch)
tree6d9aab829a480d5a0babe4d969c6e63dde6db3c9 /053recipe_header.cc
parentf8b9e5c0dccd1563764426878ba0f2f982c3f310 (diff)
downloadmu-59e47aca14ce352a1814953df4be220406c94747.tar.gz
3341
Process type abbreviations in function headers.

Still a couple of places where doing this causes strange errors. We'll
track those down next.
Diffstat (limited to '053recipe_header.cc')
-rw-r--r--053recipe_header.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/053recipe_header.cc b/053recipe_header.cc
index d385d41c..0bbba110 100644
--- a/053recipe_header.cc
+++ b/053recipe_header.cc
@@ -142,6 +142,28 @@ if (result.has_header) {
   trace(9999, "parse") << "recipe " << result.name << " has a header" << end();
 }
 
+//: Support type abbreviations in headers.
+
+:(scenario type_abbreviations_in_recipe_headers)
+type string = address:array:character
+def main [
+  local-scope
+  a:string <- foo
+  1:character/raw <- index *a, 0
+]
+def foo -> a:string [
+  local-scope
+  load-ingredients
+  a <- new [abc]
+]
++mem: storing 97 in location 1
+
+:(before "End Expand Type Abbreviations(caller)")
+for (long int i = 0; i < SIZE(caller.ingredients); ++i)
+  expand_type_abbreviations(caller.ingredients.at(i).type);
+for (long int i = 0; i < SIZE(caller.products); ++i)
+  expand_type_abbreviations(caller.products.at(i).type);
+
 //: Rewrite 'load-ingredients' to instructions to create all reagents in the header.
 
 :(before "End Rewrite Instruction(curr, recipe result)")