From 274d65d2a76ed48cb618e25e0916e20ba3d5c87b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 7 Jun 2021 11:55:09 +0200 Subject: Strip partition part from module name when forming imported partition name --- libbuild2/cc/parser+module.test.testscript | 10 ++++++++++ libbuild2/cc/parser.cxx | 18 ++++++++++++------ libbuild2/cc/parser.hxx | 8 -------- 3 files changed, 22 insertions(+), 14 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/cc/parser+module.test.testscript b/libbuild2/cc/parser+module.test.testscript index 91cbe45..6935f5e 100644 --- a/libbuild2/cc/parser+module.test.testscript +++ b/libbuild2/cc/parser+module.test.testscript @@ -59,6 +59,16 @@ import foo:part; import foo:part.sub; EOO +: import-part-from-part +: +$* <>EOO +module foo:part; +import :part.sub; +EOI +module foo:part; +import foo:part.sub; +EOO + : export-imported : $* <>EOO diff --git a/libbuild2/cc/parser.cxx b/libbuild2/cc/parser.cxx index 61d62b7..dc5093f 100644 --- a/libbuild2/cc/parser.cxx +++ b/libbuild2/cc/parser.cxx @@ -195,7 +195,7 @@ namespace build2 if (!u_->module_info.name.empty ()) fail (l) << "multiple module declarations"; - u_->type =np.second + u_->type = np.second ? (ex ? unit_type::module_intf_part : unit_type::module_impl_part) : (ex ? unit_type::module_intf : unit_type::module_impl); u_->module_info.name = move (np.first); @@ -226,22 +226,28 @@ namespace build2 } case type::colon: { + // Add the module name to the partition so that code that doesn't + // need to distinguish between different kinds of imports doesn't + // have to. + // + // Note that if this itself is a partition, then we need to strip + // the partition part from the module name. + // switch (u_->type) { case unit_type::module_intf: case unit_type::module_impl: + un = u_->module_info.name; + break; case unit_type::module_intf_part: case unit_type::module_impl_part: + un.assign (u_->module_info.name, 0, u_->module_info.name.find (':')); break; default: fail (t) << "partition importation out of module purview"; } - // Add the module name to the partition so that code that doesn't - // need to distinguish beetween different kinds of imports doesn't - // have to. - // - un = u_->module_info.name + parse_module_part (t); + parse_module_part (t, un); ut = import_type::module_part; break; } diff --git a/libbuild2/cc/parser.hxx b/libbuild2/cc/parser.hxx index a1f1e57..1fbf1a3 100644 --- a/libbuild2/cc/parser.hxx +++ b/libbuild2/cc/parser.hxx @@ -44,14 +44,6 @@ namespace build2 pair parse_module_name (token&, bool); - string - parse_module_part (token& t) - { - string n; - parse_module_part (t, n); - return n; - } - void parse_module_part (token&, string&); -- cgit v1.1