From b9007109a1b6044f5b3239ccacc10946c94c46f4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 16 Oct 2016 10:41:59 +0200 Subject: Add notion of scope to testscript model --- build2/test/script/script | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'build2/test/script/script') diff --git a/build2/test/script/script b/build2/test/script/script index f5e5ef0..005d6e5 100644 --- a/build2/test/script/script +++ b/build2/test/script/script @@ -57,20 +57,22 @@ namespace build2 command_exit exit; }; - class script + class scope { public: - script (target& test_target, target& script_target); + scope* parent; // NULL for the root (script) scope. - public: - target& test_target; // Target we are testing. - target& script_target; // Target of the testscript file. + scope (scope& p): parent (&p) {} + + protected: + scope (): parent (nullptr) {} // For the root (script) scope. + // Variables. + // public: // Note that if we pass the variable name as a string, then it will // be looked up in the wrong pool. // - variable_pool var_pool; variable_map vars; // Lookup the variable starting from this scope, continuing with outer @@ -97,6 +99,19 @@ namespace build2 value& append (const variable&); }; + + class script: public scope + { + public: + script (target& test_target, target& script_target); + + public: + target& test_target; // Target we are testing. + target& script_target; // Target of the testscript file. + + public: + variable_pool var_pool; + }; } } } -- cgit v1.1