2932
More consistent labeling of waypoints. Use types only when you need to distinguish between function overloadings. Otherwise just use variable names unless it's truly not apparent what they are (like that the result is a recipe in "End Rewrite Instruction").
This commit is contained in:
parent
3473c63ad9
commit
43b866d199
12
020run.cc
12
020run.cc
|
@ -251,13 +251,13 @@ void load_all(string dir) {
|
|||
|
||||
:(code)
|
||||
vector<double> read_memory(reagent/*copy*/ x) {
|
||||
// Begin Preprocess read_memory(reagent x)
|
||||
// Begin Preprocess read_memory(x)
|
||||
vector<double> result;
|
||||
if (is_literal(x)) {
|
||||
result.push_back(x.value);
|
||||
return result;
|
||||
}
|
||||
// End Preprocess read_memory(reagent x)
|
||||
// End Preprocess read_memory(x)
|
||||
int size = size_of(x);
|
||||
for (int offset = 0; offset < size; ++offset) {
|
||||
double val = get_or_insert(Memory, x.value+offset);
|
||||
|
@ -268,20 +268,20 @@ vector<double> read_memory(reagent/*copy*/ x) {
|
|||
}
|
||||
|
||||
void write_memory(reagent/*copy*/ x, const vector<double>& data) {
|
||||
// Begin Preprocess write_memory(reagent x, vector<double> data)
|
||||
// Begin Preprocess write_memory(x, data)
|
||||
if (!x.type) {
|
||||
raise << "can't write to " << to_string(x) << "; no type\n" << end();
|
||||
return;
|
||||
}
|
||||
if (is_dummy(x)) return;
|
||||
if (is_literal(x)) return;
|
||||
// End Preprocess write_memory(reagent x, vector<double> data)
|
||||
// End Preprocess write_memory(x, data)
|
||||
if (x.value == 0) return;
|
||||
if (size_mismatch(x, data)) {
|
||||
raise << maybe(current_recipe_name()) << "size mismatch in storing to " << x.original_string << " (" << size_of(x.type) << " vs " << SIZE(data) << ") at '" << to_original_string(current_instruction()) << "'\n" << end();
|
||||
return;
|
||||
}
|
||||
// End write_memory(reagent x) Special-cases
|
||||
// End write_memory(x) Special-cases
|
||||
for (int offset = 0; offset < SIZE(data); ++offset) {
|
||||
assert(x.value+offset > 0);
|
||||
trace(9999, "mem") << "storing " << no_scientific(data.at(offset)) << " in location " << x.value+offset << end();
|
||||
|
@ -292,7 +292,7 @@ void write_memory(reagent/*copy*/ x, const vector<double>& data) {
|
|||
:(code)
|
||||
int size_of(const reagent& r) {
|
||||
if (r.type == NULL) return 0;
|
||||
// End size_of(reagent) Cases
|
||||
// End size_of(reagent r) Cases
|
||||
return size_of(r.type);
|
||||
}
|
||||
int size_of(const type_tree* type) {
|
||||
|
|
|
@ -81,7 +81,7 @@ def main [
|
|||
string print_mu(const reagent& r, const vector<double>& data) {
|
||||
if (is_literal(r))
|
||||
return r.name+' ';
|
||||
// End print Special-cases(reagent r, data)
|
||||
// End print Special-cases(r, data)
|
||||
ostringstream out;
|
||||
for (long long i = 0; i < SIZE(data); ++i)
|
||||
out << no_scientific(data.at(i)) << ' ';
|
||||
|
|
|
@ -122,7 +122,7 @@ Container_metadata = Container_metadata_snapshot;
|
|||
|
||||
//: do no work in size_of, simply lookup Container_metadata
|
||||
|
||||
:(before "End size_of(reagent) Cases")
|
||||
:(before "End size_of(reagent r) Cases")
|
||||
if (r.metadata.size) return r.metadata.size;
|
||||
|
||||
:(before "End size_of(type) Cases")
|
||||
|
|
|
@ -92,7 +92,7 @@ def main [
|
|||
]
|
||||
+app: foo: 3 14 15 16
|
||||
|
||||
:(before "End size_of(reagent) Cases")
|
||||
:(before "End size_of(reagent r) Cases")
|
||||
if (r.type && r.type->value == get(Type_ordinal, "array")) {
|
||||
if (!r.type->right) {
|
||||
raise << maybe(current_recipe_name()) << "'" << r.original_string << "' is an array of what?\n" << end();
|
||||
|
|
|
@ -66,7 +66,7 @@ def main [
|
|||
]
|
||||
+app: foo: abc
|
||||
|
||||
:(before "End print Special-cases(reagent r, data)")
|
||||
:(before "End print Special-cases(r, data)")
|
||||
if (is_mu_string(r)) {
|
||||
assert(scalar(data));
|
||||
return read_mu_string(data.at(0))+' ';
|
||||
|
|
|
@ -82,7 +82,7 @@ int address(int offset, int base) {
|
|||
|
||||
//:: reads and writes to the 'default-space' variable have special behavior
|
||||
|
||||
:(after "Begin Preprocess write_memory(reagent x, vector<double> data)")
|
||||
:(after "Begin Preprocess write_memory(x, data)")
|
||||
if (x.name == "default-space") {
|
||||
if (!scalar(data)
|
||||
|| !x.type
|
||||
|
@ -105,7 +105,7 @@ def main [
|
|||
]
|
||||
+mem: storing 10 in location 1
|
||||
|
||||
:(after "Begin Preprocess read_memory(reagent x)")
|
||||
:(after "Begin Preprocess read_memory(x)")
|
||||
if (x.name == "default-space") {
|
||||
vector<double> result;
|
||||
result.push_back(current_call().default_space);
|
||||
|
@ -178,7 +178,7 @@ if (s == "number-of-locals") return true;
|
|||
if (curr.name == "new-default-space") {
|
||||
rewrite_default_space_instruction(curr);
|
||||
}
|
||||
:(after "Begin Preprocess read_memory(reagent x)")
|
||||
:(after "Begin Preprocess read_memory(x)")
|
||||
if (x.name == "number-of-locals") {
|
||||
vector<double> result;
|
||||
result.push_back(Name[get(Recipe_ordinal, current_recipe_name())][""]);
|
||||
|
@ -186,7 +186,7 @@ if (x.name == "number-of-locals") {
|
|||
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<double> data)")
|
||||
:(after "Begin Preprocess write_memory(x, data)")
|
||||
if (x.name == "number-of-locals") {
|
||||
raise << maybe(current_recipe_name()) << "can't write to special name 'number-of-locals'\n" << end();
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue