Standardize on calling literate waypoints "Special-cases" rather than
"Cases". Invariably there's a default path already present.
This commit is contained in:
Kartik K. Agaram 2016-11-07 09:10:48 -08:00
parent 133a461436
commit 1211a3ab30
14 changed files with 31 additions and 31 deletions

View File

@ -324,18 +324,18 @@ void write_memory(reagent/*copy*/ x, const vector<double>& data) {
:(code)
int size_of(const reagent& r) {
if (!r.type) return 0;
// End size_of(reagent r) Cases
// End size_of(reagent r) Special-cases
return size_of(r.type);
}
int size_of(const type_tree* type) {
if (!type) return 0;
// End size_of(type) Cases
// End size_of(type) Special-cases
return 1;
}
bool size_mismatch(const reagent& x, const vector<double>& data) {
if (!x.type) return true;
// End size_mismatch(x) Cases
// End size_mismatch(x) Special-cases
//? if (size_of(x) != SIZE(data)) cerr << size_of(x) << " vs " << SIZE(data) << '\n';
return size_of(x) != SIZE(data);
}

View File

@ -144,10 +144,10 @@ void clear_container_metadata() {
//: do no work in size_of, simply lookup Container_metadata
:(before "End size_of(reagent r) Cases")
:(before "End size_of(reagent r) Special-cases")
if (r.metadata.size) return r.metadata.size;
:(before "End size_of(type) Cases")
:(before "End size_of(type) Special-cases")
if (type->atom) {
if (type->value == -1) return 1; // error value, but we'll raise it elsewhere
if (type->value == 0) return 1;
@ -219,7 +219,7 @@ void compute_container_sizes(const type_tree* type, set<type_tree>& pending_meta
element_type = element_type->left;
compute_container_sizes(element_type, pending_metadata, location_for_error_messages);
}
// End compute_container_sizes Non-atom Cases
// End compute_container_sizes Non-atom Special-cases
return;
}
assert(type->atom);
@ -228,7 +228,7 @@ void compute_container_sizes(const type_tree* type, set<type_tree>& pending_meta
if (info.kind == CONTAINER) {
compute_container_sizes(info, type, pending_metadata, location_for_error_messages);
}
// End compute_container_sizes Atom Cases
// End compute_container_sizes Atom Special-cases
}
void compute_container_sizes(const type_info& container_info, const type_tree* full_type, set<type_tree>& pending_metadata, const string& location_for_error_messages) {

View File

@ -183,7 +183,7 @@ void check_merge_call(const vector<reagent>& ingredients, const reagent& product
}
break;
}
// End check_merge_call Cases
// End check_merge_call Special-cases
default: {
if (!types_coercible(container, ingredients.at(ingredient_index))) {
raise << maybe(caller.name) << "incorrect type of ingredient " << ingredient_index << " in '" << inst.original_string << "'\n" << end();

View File

@ -98,7 +98,7 @@ def main [
]
+app: foo: 3 14 15 16
:(before "End size_of(reagent r) Cases")
:(before "End size_of(reagent r) Special-cases")
if (!r.type->atom && r.type->left->atom && r.type->left->value == get(Type_ordinal, "array")) {
if (!r.type->right) {
raise << maybe(current_recipe_name()) << "'" << r.original_string << "' is an array of what?\n" << end();
@ -112,7 +112,7 @@ if (!r.type->atom && r.type->left->atom && r.type->left->value == get(Type_ordin
//: disable the size mismatch check for arrays since the destination array
//: need not be initialized
:(before "End size_mismatch(x) Cases")
:(before "End size_mismatch(x) Special-cases")
if (x.type && !x.type->atom && x.type->left->value == get(Type_ordinal, "array")) return false;
//: arrays are disallowed inside containers unless their length is fixed in
@ -133,7 +133,7 @@ container foo [
//: disable the size mismatch check for 'merge' instructions since containers
//: can contain arrays, and since we already do plenty of checking for them
:(before "End size_mismatch(x) Cases")
:(before "End size_mismatch(x) Special-cases")
if (current_call().running_step_index < SIZE(get(Recipe, current_call().running_recipe).steps)
&& current_instruction().operation == MERGE) {
return false;

View File

@ -30,12 +30,12 @@ def main [
+mem: storing 34 in location 5
+mem: storing 35 in location 6
:(before "End size_of(type) Cases")
:(before "End size_of(type) Special-cases")
if (t.kind == EXCLUSIVE_CONTAINER) {
// Compute size_of Exclusive Container
return get(Container_metadata, type).size;
}
:(before "End compute_container_sizes Atom Cases")
:(before "End compute_container_sizes Atom Special-cases")
if (info.kind == EXCLUSIVE_CONTAINER) {
compute_exclusive_container_sizes(info, type, pending_metadata, location_for_error_messages);
}
@ -314,7 +314,7 @@ def main [
+mem: storing 34 in location 6
$error: 0
:(before "End check_merge_call Cases")
:(before "End check_merge_call Special-cases")
case EXCLUSIVE_CONTAINER: {
assert(state.data.top().container_element_index == 0);
trace(9999, "transform") << "checking exclusive container " << to_string(container) << " vs ingredient " << ingredient_index << end();
@ -435,7 +435,7 @@ $error: 0
//: Since the different variants of an exclusive-container might have
//: different sizes, relax the size mismatch check for 'merge' instructions.
:(before "End size_mismatch(x) Cases")
:(before "End size_mismatch(x) Special-cases")
if (current_step_index() < SIZE(Current_routine->steps())
&& current_instruction().operation == MERGE
&& !current_instruction().products.empty()

View File

@ -319,7 +319,7 @@ void compute_container_address_offsets(const type_tree* type, const string& loca
element_type = element_type->left;
compute_container_address_offsets(element_type, location_for_error_messages);
}
// End compute_container_address_offsets Non-atom Cases
// End compute_container_address_offsets Non-atom Special-cases
}
if (!contains_key(Type, root_type(type)->value)) return; // error raised elsewhere
type_info& info = get(Type, root_type(type)->value);

View File

@ -104,7 +104,7 @@ bool is_disqualified(/*mutable*/ reagent& x, const instruction& inst, const stri
}
if (is_raw(x)) return true;
if (is_literal(x)) return true;
// End is_disqualified Cases
// End is_disqualified Special-cases
if (x.initialized) return true;
return false;
}
@ -150,7 +150,7 @@ bool is_named_location(const reagent& x) {
bool is_special_name(const string& s) {
if (s == "_") return true;
if (s == "0") return true;
// End is_special_name Cases
// End is_special_name Special-cases
return false;
}

View File

@ -43,10 +43,10 @@ def main [
+name: assign x 1
-name: assign default-space 1
:(before "End is_disqualified Cases")
:(before "End is_disqualified Special-cases")
if (x.name == "default-space")
x.initialized = true;
:(before "End is_special_name Cases")
:(before "End is_special_name Special-cases")
if (s == "default-space") return true;
//:: now implement space support
@ -166,10 +166,10 @@ def main [
# allocate space for x and y, as well as the chaining slot at 0
+mem: array length is 3
:(before "End is_disqualified Cases")
:(before "End is_disqualified Special-cases")
if (x.name == "number-of-locals")
x.initialized = true;
:(before "End is_special_name Cases")
:(before "End is_special_name Special-cases")
if (s == "number-of-locals") return true;
:(before "End Rewrite Instruction(curr, recipe result)")

View File

@ -29,10 +29,10 @@ def main [
+mem: storing 24 in location 23
//: to support it, create another special variable called global space
:(before "End is_disqualified Cases")
:(before "End is_disqualified Special-cases")
if (x.name == "global-space")
x.initialized = true;
:(before "End is_special_name Cases")
:(before "End is_special_name Special-cases")
if (s == "global-space") return true;
//: writes to this variable go to a field in the current routine

View File

@ -225,7 +225,7 @@ void maybe_make_raw(reagent& r, const recipe& caller) {
}
//: Test.
:(before "End is_special_name Cases")
:(before "End is_special_name Special-cases")
if (s == "__maybe_make_raw_test__") return true;
:(before "End Special Scenario Variable Names(r)")
//: ugly: we only need this for this one test, but need to define it for all time
@ -416,7 +416,7 @@ void check_type(const string& lhs, istream& in) {
check_string(address, literal);
return;
}
// End Scenario Type Cases
// End Scenario Type Special-cases
raise << "don't know how to check memory for '" << lhs << "'\n" << end();
}

View File

@ -490,7 +490,7 @@ def main [
//: offsets containing addresses for containers and exclusive containers --
//: that we need to teach about type ingredients.
:(before "End compute_container_sizes Non-atom Cases")
:(before "End compute_container_sizes Non-atom Special-cases")
const type_tree* root = root_type(type);
type_info& info = get(Type, root->value);
if (info.kind == CONTAINER) {
@ -550,7 +550,7 @@ void test_container_sizes_recursive_shape_shifting_container() {
CHECK_EQ(r2.metadata.size, 2);
}
:(before "End compute_container_address_offsets Non-atom Cases")
:(before "End compute_container_address_offsets Non-atom Special-cases")
const type_tree* root = root_type(type);
type_info& info = get(Type, root->value);
if (info.kind == CONTAINER) {

View File

@ -152,7 +152,7 @@ extern const int SCREEN = Next_predefined_global_for_scenarios++;
:(before "End Special Scenario Variable Names(r)")
Name[r]["screen"] = SCREEN;
//: make 'screen' always a raw location in scenarios
:(before "End is_special_name Cases")
:(before "End is_special_name Special-cases")
if (s == "screen") return true;
:(before "End Rewrite Instruction(curr, recipe result)")

View File

@ -39,7 +39,7 @@ extern const int CONSOLE = Next_predefined_global_for_scenarios++;
:(before "End Special Scenario Variable Names(r)")
Name[r]["console"] = CONSOLE;
//: make 'console' always a raw location in scenarios
:(before "End is_special_name Cases")
:(before "End is_special_name Special-cases")
if (s == "console") return true;
:(before "End Primitive Recipe Declarations")

View File

@ -76,7 +76,7 @@ extern const int RESOURCES = Next_predefined_global_for_scenarios++;
:(before "End Special Scenario Variable Names(r)")
Name[r]["resources"] = RESOURCES;
//: make 'resources' always a raw location in scenarios
:(before "End is_special_name Cases")
:(before "End is_special_name Special-cases")
if (s == "resources") return true;
:(before "End Initialize Type Of Special Name In Scenario(r)")
if (r.name == "resources") r.type = new_type_tree("address:resources");