aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script/script
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-16 10:41:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:21 +0200
commitb9007109a1b6044f5b3239ccacc10946c94c46f4 (patch)
treedc47d05c21dd9684d7b7ab6f5756b775d3a75892 /build2/test/script/script
parente6932f85e8b20876f66968b31f84488eee31153d (diff)
Add notion of scope to testscript model
Diffstat (limited to 'build2/test/script/script')
-rw-r--r--build2/test/script/script27
1 files changed, 21 insertions, 6 deletions
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;
+ };
}
}
}