From 51ae6dcf64ce1de3f0f28228050c7db1776e5b1b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 19 May 2020 19:57:46 +0300 Subject: Remove redundant script member from build::script::environment class --- libbuild2/build/script/parser.cxx | 6 +++--- libbuild2/build/script/parser.hxx | 2 +- libbuild2/build/script/parser.test.cxx | 4 ++-- libbuild2/build/script/script.cxx | 3 +-- libbuild2/build/script/script.hxx | 3 +-- libbuild2/rule.cxx | 4 ++-- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/libbuild2/build/script/parser.cxx b/libbuild2/build/script/parser.cxx index c64bcd9..9c397f1 100644 --- a/libbuild2/build/script/parser.cxx +++ b/libbuild2/build/script/parser.cxx @@ -240,7 +240,7 @@ namespace build2 // void parser:: - execute (environment& e, runner& r) + execute (const script& s, environment& e, runner& r) { path_ = nullptr; // Set by replays. @@ -248,7 +248,7 @@ namespace build2 set_lexer (nullptr); - script_ = nullptr; + script_ = const_cast (&s); runner_ = &r; environment_ = &e; @@ -258,7 +258,7 @@ namespace build2 void parser:: exec_script () { - const script& s (environment_->script); + const script& s (*script_); runner_->enter (*environment_, s.start_loc); diff --git a/libbuild2/build/script/parser.hxx b/libbuild2/build/script/parser.hxx index 40f4c62..7183509 100644 --- a/libbuild2/build/script/parser.hxx +++ b/libbuild2/build/script/parser.hxx @@ -68,7 +68,7 @@ namespace build2 // public: void - execute (environment&, runner&); + execute (const script&, environment&, runner&); protected: void diff --git a/libbuild2/build/script/parser.test.cxx b/libbuild2/build/script/parser.test.cxx index 705fd9d..b5afd47 100644 --- a/libbuild2/build/script/parser.test.cxx +++ b/libbuild2/build/script/parser.test.cxx @@ -131,9 +131,9 @@ namespace build2 if (!dump) { - environment e (s, tt); + environment e (tt); print_runner r (line); - p.execute (e, r); + p.execute (s, e, r); } else build2::script::dump (cout, "", s.lines); diff --git a/libbuild2/build/script/script.cxx b/libbuild2/build/script/script.cxx index 2a796ab..cbd41c7 100644 --- a/libbuild2/build/script/script.cxx +++ b/libbuild2/build/script/script.cxx @@ -20,7 +20,7 @@ namespace build2 static const string wd_name ("current directory"); environment:: - environment (const build::script::script& s, const target& pt) + environment (const target& pt) : build2::script::environment ( pt.ctx, cast (pt.ctx.global_scope["build.host"]), @@ -29,7 +29,6 @@ namespace build2 redirect (redirect_type::none), redirect (redirect_type::merge, 2), redirect (redirect_type::pass)), - script (s), primary_target (pt), vars (context, false /* global */) { diff --git a/libbuild2/build/script/script.hxx b/libbuild2/build/script/script.hxx index 9ada56f..1540ed8 100644 --- a/libbuild2/build/script/script.hxx +++ b/libbuild2/build/script/script.hxx @@ -52,7 +52,7 @@ namespace build2 class environment: public build2::script::environment { public: - environment (const script&, const target& primary_target); + environment (const target& primary_target); environment (environment&&) = delete; environment (const environment&) = delete; @@ -60,7 +60,6 @@ namespace build2 environment& operator= (const environment&) = delete; public: - const build::script::script& script; const target& primary_target; // Script-local variable pool. diff --git a/libbuild2/rule.cxx b/libbuild2/rule.cxx index 49cb8f3..5e28805 100644 --- a/libbuild2/rule.cxx +++ b/libbuild2/rule.cxx @@ -578,9 +578,9 @@ namespace build2 if (!ctx.dry_run || verb >= 2) { build::script::parser p (ctx); - build::script::environment e (script, t); + build::script::environment e (t); build::script::default_runner r; - p.execute (e, r); + p.execute (script, e, r); } return target_state::changed; -- cgit v1.1