3502
Better implementation of commit 3445: not requiring types for special variables in scenarios. It turned out that it wasn't working anytime we needed to call 'get' on a special variable inside a scenario. After moving that work to an earlier transform we can now use 'filesystem' without a type inside scenarios.
This commit is contained in:
parent
392249a76d
commit
30c90fc4c7
|
@ -874,15 +874,20 @@ void check_or_set_invalid_types(const recipe_ordinal r) {
|
|||
for (int index = 0; index < SIZE(caller.steps); ++index) {
|
||||
instruction& inst = caller.steps.at(index);
|
||||
for (int i = 0; i < SIZE(inst.ingredients); ++i)
|
||||
check_or_set_invalid_types(inst.ingredients.at(i).type, maybe(caller.name), "'"+inst.original_string+"'");
|
||||
check_or_set_invalid_types(inst.ingredients.at(i), caller, inst);
|
||||
for (int i = 0; i < SIZE(inst.products); ++i)
|
||||
check_or_set_invalid_types(inst.products.at(i).type, maybe(caller.name), "'"+inst.original_string+"'");
|
||||
check_or_set_invalid_types(inst.products.at(i), caller, inst);
|
||||
}
|
||||
// End check_or_set_invalid_types
|
||||
}
|
||||
|
||||
void check_or_set_invalid_types(reagent& r, const recipe& caller, const instruction& inst) {
|
||||
// Begin check_or_set_invalid_types(r)
|
||||
check_or_set_invalid_types(r.type, maybe(caller.name), "'"+inst.original_string+"'");
|
||||
}
|
||||
|
||||
void check_or_set_invalid_types(type_tree* type, const string& block, const string& name) {
|
||||
if (!type) return; // will throw a more precise error elsewhere
|
||||
if (!type) return;
|
||||
// End Container Type Checks
|
||||
if (!type->atom) {
|
||||
check_or_set_invalid_types(type->left, block, name);
|
||||
|
|
|
@ -187,12 +187,9 @@ void initialize_key_names() {
|
|||
Key["escape"] = TB_KEY_ESC;
|
||||
}
|
||||
|
||||
:(after "Begin transform_names Ingredient Special-cases(ingredient, inst, caller)")
|
||||
:(after "Begin check_or_set_invalid_types(r)")
|
||||
if (is_scenario(caller))
|
||||
initialize_special_name(ingredient);
|
||||
:(after "Begin transform_names Product Special-cases(product, inst, caller)")
|
||||
if (is_scenario(caller))
|
||||
initialize_special_name(product);
|
||||
initialize_special_name(r);
|
||||
:(code)
|
||||
bool is_scenario(const recipe& caller) {
|
||||
return starts_with(caller.name, "scenario_");
|
||||
|
|
|
@ -20,7 +20,7 @@ scenario foo [
|
|||
|xyz|
|
||||
]
|
||||
]
|
||||
data:&:@:file-mapping <- get *filesystem:&:filesystem, data:offset
|
||||
data:&:@:file-mapping <- get *filesystem, data:offset
|
||||
file1:file-mapping <- index *data, 0
|
||||
file1-name:text <- get file1, name:offset
|
||||
10:@:char/raw <- copy *file1-name
|
||||
|
@ -59,7 +59,7 @@ scenario foo [
|
|||
|x\\\\|yz|
|
||||
]
|
||||
]
|
||||
data:&:@:file-mapping <- get *filesystem:&:filesystem, data:offset
|
||||
data:&:@:file-mapping <- get *filesystem, data:offset
|
||||
file1:file-mapping <- index *data, 0
|
||||
file1-name:text <- get file1, name:offset
|
||||
10:@:char/raw <- copy *file1-name
|
||||
|
@ -80,6 +80,8 @@ Name[r]["filesystem"] = FILESYSTEM;
|
|||
//: make 'filesystem' always a raw location in scenarios
|
||||
:(before "End is_special_name Cases")
|
||||
if (s == "filesystem") return true;
|
||||
:(before "End Initialize Type Of Special Name In Scenario(r)")
|
||||
if (r.name == "filesystem") r.type = new_type_tree("address:filesystem");
|
||||
|
||||
:(before "End initialize_transform_rewrite_literal_string_to_text()")
|
||||
recipes_taking_literal_strings.insert("assume-filesystem");
|
||||
|
|
Loading…
Reference in New Issue
Block a user