From 3473c63ad94756d6f79ddd5c48813e79d87429ca Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 6 May 2016 00:46:39 -0700 Subject: 2931 - be explicit about making copies --- 043space.cc | 66 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to '043space.cc') diff --git a/043space.cc b/043space.cc index d29cf983..e4a39b7c 100644 --- a/043space.cc +++ b/043space.cc @@ -82,21 +82,21 @@ int address(int offset, int base) { //:: reads and writes to the 'default-space' variable have special behavior -:(after "void write_memory(reagent x, const vector& data)") - if (x.name == "default-space") { - if (!scalar(data) - || !x.type - || x.type->value != get(Type_ordinal, "address") - || !x.type->right - || x.type->right->value != get(Type_ordinal, "array") - || !x.type->right->right - || x.type->right->right->value != get(Type_ordinal, "location") - || x.type->right->right->right) { - raise << maybe(current_recipe_name()) << "'default-space' should be of type address:array:location, but tried to write " << to_string(data) << '\n' << end(); - } - current_call().default_space = data.at(0); - return; +:(after "Begin Preprocess write_memory(reagent x, vector data)") +if (x.name == "default-space") { + if (!scalar(data) + || !x.type + || x.type->value != get(Type_ordinal, "address") + || !x.type->right + || x.type->right->value != get(Type_ordinal, "array") + || !x.type->right->right + || x.type->right->right->value != get(Type_ordinal, "location") + || x.type->right->right->right) { + raise << maybe(current_recipe_name()) << "'default-space' should be of type address:array:location, but tried to write " << to_string(data) << '\n' << end(); } + current_call().default_space = data.at(0); + return; +} :(scenario get_default_space) def main [ @@ -105,12 +105,12 @@ def main [ ] +mem: storing 10 in location 1 -:(after "vector read_memory(reagent x)") - if (x.name == "default-space") { - vector result; - result.push_back(current_call().default_space); - return result; - } +:(after "Begin Preprocess read_memory(reagent x)") +if (x.name == "default-space") { + vector result; + result.push_back(current_call().default_space); + return result; +} //:: fix 'get' @@ -178,19 +178,19 @@ if (s == "number-of-locals") return true; if (curr.name == "new-default-space") { rewrite_default_space_instruction(curr); } -:(after "vector read_memory(reagent x)") - if (x.name == "number-of-locals") { - vector result; - result.push_back(Name[get(Recipe_ordinal, current_recipe_name())][""]); - if (result.back() == 0) - raise << "no space allocated for default-space in recipe " << current_recipe_name() << "; are you using names?\n" << end(); - return result; - } -:(after "void write_memory(reagent x, const vector& data)") - if (x.name == "number-of-locals") { - raise << maybe(current_recipe_name()) << "can't write to special name 'number-of-locals'\n" << end(); - return; - } +:(after "Begin Preprocess read_memory(reagent x)") +if (x.name == "number-of-locals") { + vector result; + result.push_back(Name[get(Recipe_ordinal, current_recipe_name())][""]); + if (result.back() == 0) + raise << "no space allocated for default-space in recipe " << current_recipe_name() << "; are you using names?\n" << end(); + return result; +} +:(after "Begin Preprocess write_memory(reagent x, vector data)") +if (x.name == "number-of-locals") { + raise << maybe(current_recipe_name()) << "can't write to special name 'number-of-locals'\n" << end(); + return; +} //:: a little hook to automatically reclaim the default-space when returning //:: from a recipe -- cgit 1.4.1-2-gfad0 kkartik/mu/commit/kernel.soso/descriptortables.h?h=hlt&id=46bb1d3157f9ad575c83a4bfa1e32b0d21bc8546'>46bb1d31 ^
1
2
3
4
5
6
7
8
9