diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-15 21:12:30 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-15 21:12:30 -0700 |
commit | 30c90fc4c79f254c41b4c3ee7dfb3cc505179438 (patch) | |
tree | b3eb2313bb200c3d23a1c0dda9ba8cdb7a8dba44 | |
parent | 392249a76da19cae798998dda198fbe59fbee905 (diff) | |
download | mu-30c90fc4c79f254c41b4c3ee7dfb3cc505179438.tar.gz |
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.
-rw-r--r-- | 030container.cc | 11 | ||||
-rw-r--r-- | 085scenario_console.cc | 7 | ||||
-rw-r--r-- | 089scenario_filesystem.cc | 6 |
3 files changed, 14 insertions, 10 deletions
diff --git a/030container.cc b/030container.cc index bc421ac6..3ad38fda 100644 --- a/030container.cc +++ b/030container.cc @@ -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); diff --git a/085scenario_console.cc b/085scenario_console.cc index 3c446a3b..24ffebed 100644 --- a/085scenario_console.cc +++ b/085scenario_console.cc @@ -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_"); diff --git a/089scenario_filesystem.cc b/089scenario_filesystem.cc index 25b1a4c4..078757a5 100644 --- a/089scenario_filesystem.cc +++ b/089scenario_filesystem.cc @@ -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"); |