diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-01 21:48:49 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-02 10:30:09 -0700 |
commit | f652431d44a1fecf2ba778cf2d59f8ec650fcd68 (patch) | |
tree | 460f72e711c625e6178c4eb7d7203ffb6b4be1ed /cpp/030length | |
parent | 8dacba823f0a65af414f539cc36f7064444a06a7 (diff) | |
download | mu-f652431d44a1fecf2ba778cf2d59f8ec650fcd68.tar.gz |
1001
Diffstat (limited to 'cpp/030length')
-rw-r--r-- | cpp/030length | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cpp/030length b/cpp/030length new file mode 100644 index 00000000..6a297dd3 --- /dev/null +++ b/cpp/030length @@ -0,0 +1,25 @@ +:(scenario "array_length") +recipe main [ + 1:integer <- copy 3:literal + 2:integer <- copy 14:literal + 3:integer <- copy 15:literal + 4:integer <- copy 16:literal + 5:integer <- length 1:array:integer +] ++run: instruction main/4 ++mem: storing 3 in location 5 + +:(before "End Globals") +const int LENGTH = 25; +:(before "End Primitive Recipe Numbers") +Recipe_number["length"] = LENGTH; +assert(Next_recipe_number == LENGTH); +Next_recipe_number++; +:(before "End Primitive Recipe Implementations") +case LENGTH: { + reagent x = canonize(instructions[pc].ingredients[0]); + vector<int> result; + result.push_back(Memory[x.value]); + write_memory(instructions[pc].products[0], result); + break; +} |