:(scenario reply)
recipe main [
1:number, 2:number <- f 34:literal
]
recipe f [
12:number <- next-ingredient
13:number <- add 1:literal, 12:number
reply 12:number, 13:number
]
+mem: storing 34 in location 1
+mem: storing 35 in location 2
:(before "End Primitive Recipe Declarations")
REPLY,
:(before "End Primitive Recipe Numbers")
Recipe_number["reply"] = REPLY;
:(before "End Primitive Recipe Implementations")
case REPLY: {
const instruction& reply_inst = current_instruction();
--Callstack_depth;
Current_routine->calls.pop_front();
if (Current_routine->calls.empty()) goto stop_running_current_routine;
const instruction& caller_instruction = current_instruction();
copy(ingredients.begin(), ingredients.end(), inserter(products, products.begin()));
for (long long int i = 0; i < SIZE(caller_instruction.products); ++i) {
trace(Primitive_recipe_depth, "run") << "result " << i << " is " << to_string(ingredients.at(i));
if (has_property(reply_inst.ingredients.at(i), "same-as-ingredient")) {
vector<string> tmp = property(reply_inst.ingredients.at(i), "same-as-ingredient");
assert(SIZE(tmp) == 1);
long long int ingredient_index = to_integer(tmp.at(0));
if (caller_instruction.products.at(i).value != caller_instruction.ingredients.at(ingredient_index).value)
raise << "'same-as-ingredient' result " << caller_instruction.products.at(i).value << " must be location " << caller_instruction.ingredients.at(ingredient_index).value << '\n';
}
}
break;
}
:(scenario reply_container)
recipe main [
3:point <#
#
# Nim's Runtime Library
# (c) Copyright 2015 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## This module contains code for reading from `stdin`:idx:. On UNIX the
## linenoise library is wrapped and set up to provide default key bindings
## (e.g. you can navigate with the arrow keys). On Windows ``system.readLine``
## is used. This suffices because Windows' console already provides the
## wanted functionality.
{.deadCodeElim: on.}
when defined(Windows):
proc readLineFromStdin*(prompt: string): TaintedString {.
tags: