read_from
Set the memory location to read out of for an Executable. If not set, the Executable assumes a default of "ro". You can call this function multiple times to read from multiple registers. The first time you call the function, the default of "ro" is not longer relevant.
Definition
void read_from(struct Executable *executable, char *name);
Arguments
executable: TheExecutableto set the parameter on.name: The name of the memory region to read out of. Must match a QuilDECLAREstatement exactly.
Safety
executablemust be the result ofexecutable_from_quilnamemust be a valid, non-NULL, nul-terminated string. It must also live untilexecutableis freed.
Example
With a program like this one:
char *REAL_MEMORY_PROGRAM =
"DECLARE first REAL[1]\n"
"DECLARE second OCTET[1]\n"
"MOVE first[0] 3.141\n"
"MOVE second[0] 2\n";
We've declared a region called first and another called second—both of which we'd like to read out of. Since we are not using a single register called "ro" (the default), we need to specify where to read from.
Executable *exe = executable_from_quil(REAL_MEMORY_PROGRAM);
read_from(exe, "first");
read_from(exe, "second");
ExecutionResult *result = execute_on_qvm(exe);