aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/script
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/script')
-rw-r--r--libbuild2/script/parser.cxx24
-rw-r--r--libbuild2/script/parser.hxx8
2 files changed, 28 insertions, 4 deletions
diff --git a/libbuild2/script/parser.cxx b/libbuild2/script/parser.cxx
index 5c7510b..160374d 100644
--- a/libbuild2/script/parser.cxx
+++ b/libbuild2/script/parser.cxx
@@ -3,6 +3,7 @@
#include <libbuild2/script/parser.hxx>
+#include <libbuild2/variable.hxx>
#include <libbuild2/script/run.hxx> // exit
#include <libbuild2/script/lexer.hxx>
@@ -1716,7 +1717,8 @@ namespace build2
const function<exec_set_function>& exec_set,
const function<exec_cmd_function>& exec_cmd,
const function<exec_if_function>& exec_if,
- size_t& li)
+ size_t& li,
+ variable_pool* var_pool)
{
try
{
@@ -1743,7 +1745,20 @@ namespace build2
{
case line_type::var:
{
- exec_set (*ln.var, t, tt, ll);
+ // Enter the variable into the pool if this is not done during
+ // the script parsing. Note that in this case the pool is
+ // expected to be provided.
+ //
+ const variable* var (ln.var);
+
+ if (var == nullptr)
+ {
+ assert (var_pool != nullptr);
+
+ var = &var_pool->insert (t.value);
+ }
+
+ exec_set (*var, t, tt, ll);
replay_stop ();
break;
@@ -1861,7 +1876,10 @@ namespace build2
// Next if-else.
//
lines::const_iterator j (next (i, false, false));
- if (!exec_lines (i + 1, j, exec_set, exec_cmd, exec_if, li))
+ if (!exec_lines (i + 1, j,
+ exec_set, exec_cmd, exec_if,
+ li,
+ var_pool))
return false;
i = j->type == line_type::cmd_end ? j : next (j, true, true);
diff --git a/libbuild2/script/parser.hxx b/libbuild2/script/parser.hxx
index 850794e..ecd9f5a 100644
--- a/libbuild2/script/parser.hxx
+++ b/libbuild2/script/parser.hxx
@@ -146,12 +146,18 @@ namespace build2
size_t li,
const location&);
+ // If a parser implementation doesn't pre-enter variables into a pool
+ // during the pre-parsing phase, then they are entered during the
+ // execution phase and so the variable pool must be provided. Note that
+ // in this case the variable pool insertions are not MT-safe.
+ //
bool
exec_lines (lines::const_iterator b, lines::const_iterator e,
const function<exec_set_function>&,
const function<exec_cmd_function>&,
const function<exec_if_function>&,
- size_t& li);
+ size_t& li,
+ variable_pool* = nullptr);
// Set lexer pointers for both the current and the base classes.
//