Skip to content

Commit f0317ab

Browse files
Rename ipr::Linkgage (#310)
to `ipr::Language_linkage` to make it sound different from _name linkage_ as modules introduce more "linkage"
1 parent 5f7b0c4 commit f0317ab

File tree

3 files changed

+44
-45
lines changed

3 files changed

+44
-45
lines changed

include/ipr/impl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,21 @@ namespace ipr::impl {
160160
using Transfer = impl::Basic_binary<ipr::Transfer>;
161161

162162
// -- Specialized implementation of ipr::Transfer
163-
// An object of this class pairs a specified linkage with the natural
163+
// An object of this class pairs a specified language linkage with the natural
164164
// C++ calling convention.
165165
struct Transfer_from_linkage : ipr::Transfer {
166-
constexpr explicit Transfer_from_linkage(const ipr::Linkage& l) : link{l} { }
167-
const ipr::Linkage& first() const final { return link; }
166+
constexpr explicit Transfer_from_linkage(const ipr::Language_linkage& l) : link{l} { }
167+
const ipr::Language_linkage& first() const final { return link; }
168168
const ipr::Calling_convention& second() const final;
169169
private:
170-
const ipr::Linkage& link;
170+
const ipr::Language_linkage& link;
171171
};
172172

173173
// -- Specialized implementation of ipr::Transfer
174174
// An object of this class pairs the C++ language linkage with a specified calling convention.
175175
struct Transfer_from_cc : ipr::Transfer {
176176
constexpr explicit Transfer_from_cc(const ipr::Calling_convention& cc) : conv{cc} { }
177-
const ipr::Linkage& first() const final;
177+
const ipr::Language_linkage& first() const final;
178178
const ipr::Calling_convention& second() const final { return conv; }
179179
private:
180180
const ipr::Calling_convention& conv;
@@ -441,8 +441,8 @@ namespace ipr::impl {
441441
const ipr::Transfer& cxx_transfer();
442442

443443
// The two language linkages required of all C++ implementations.
444-
const ipr::Linkage& c_linkage();
445-
inline const ipr::Linkage& cxx_linkage() { return cxx_transfer().linkage(); }
444+
const ipr::Language_linkage& c_linkage();
445+
inline const ipr::Language_linkage& cxx_linkage() { return cxx_transfer().language_linkage(); }
446446

447447
// The type of types, including itselt.
448448
// Yes, we have a ``Type: Type'' problem.
@@ -730,7 +730,7 @@ namespace ipr::impl {
730730
unique_decl() : seq{*this} { }
731731
ipr::Specifiers specifiers() const override { return { }; }
732732
const ipr::Decl& master() const final { return *this; }
733-
const ipr::Linkage& linkage() const final { return impl::cxx_linkage(); }
733+
const ipr::Language_linkage& language_linkage() const final { return impl::cxx_linkage(); }
734734
const ipr::Sequence<ipr::Decl>& decl_set() const final { return seq; }
735735
private:
736736
singleton_ref<ipr::Decl> seq;
@@ -1327,7 +1327,7 @@ namespace ipr::impl {
13271327
return compare(lhs.what(), rhs.what());
13281328
}
13291329

1330-
inline int compare(const ipr::Linkage& lhs, const ipr::Linkage& rhs)
1330+
inline int compare(const ipr::Language_linkage& lhs, const ipr::Language_linkage& rhs)
13311331
{
13321332
return compare(lhs.language(), rhs.language());
13331333
}
@@ -1389,7 +1389,7 @@ namespace ipr::impl {
13891389
struct master_decl_data : basic_decl_data<Interface>, overload_entry {
13901390
// The declaration that is considered to be the definition.
13911391
Optional<Interface> def { };
1392-
util::ref<const ipr::Linkage> langlinkage { };
1392+
util::ref<const ipr::Language_linkage> lang_linkage { };
13931393

13941394
// The overload set that contains this master declaration. It
13951395
// shall be set at the time the node for the master declaration
@@ -1410,7 +1410,7 @@ namespace ipr::impl {
14101410
using Base = basic_decl_data<ipr::Template>;
14111411
// The declaration that is considered to be the definition.
14121412
Optional<ipr::Template> def { };
1413-
util::ref<const ipr::Linkage> langlinkage { };
1413+
util::ref<const ipr::Language_linkage> lang_linkage { };
14141414
const ipr::Template* primary;
14151415
const ipr::Region* home;
14161416

@@ -1489,9 +1489,9 @@ namespace ipr::impl {
14891489

14901490
Decl() : decl_data{ nullptr } { }
14911491

1492-
const ipr::Linkage& linkage() const final
1492+
const ipr::Language_linkage& language_linkage() const final
14931493
{
1494-
return util::check(decl_data.master_data)->langlinkage.get();
1494+
return util::check(decl_data.master_data)->lang_linkage.get();
14951495
}
14961496

14971497
const ipr::Region& home_region() const final {
@@ -2225,9 +2225,9 @@ namespace ipr::impl {
22252225
// as setting their types (as expressions) and their names.
22262226

22272227
struct type_factory {
2228-
const ipr::Transfer& get_transfer_from_linkage(const ipr::Linkage&);
2228+
const ipr::Transfer& get_transfer_from_linkage(const ipr::Language_linkage&);
22292229
const ipr::Transfer& get_transfer_from_convention(const ipr::Calling_convention&);
2230-
const ipr::Transfer& get_transfer(const ipr::Linkage&, const ipr::Calling_convention&);
2230+
const ipr::Transfer& get_transfer(const ipr::Language_linkage&, const ipr::Calling_convention&);
22312231

22322232
// Build an IPR node for an expression that denotes a type.
22332233
// The transfer protocol, if not specified, is assumed to be C++.
@@ -2536,8 +2536,8 @@ namespace ipr::impl {
25362536

25372537
struct expr_factory : name_factory {
25382538
// Returns an IPR node a language linkage.
2539-
const ipr::Linkage& get_linkage(util::word_view);
2540-
const ipr::Linkage& get_linkage(const ipr::String&);
2539+
const ipr::Language_linkage& get_linkage(util::word_view);
2540+
const ipr::Language_linkage& get_linkage(const ipr::String&);
25412541

25422542
// Rerturn an IPR for a calling convention.
25432543
const ipr::Calling_convention& get_calling_convention(util::word_view);
@@ -2662,7 +2662,7 @@ namespace ipr::impl {
26622662
impl::Static_assert* make_static_assert_expr(const ipr::Expr&, Optional<ipr::String> = { });
26632663

26642664
private:
2665-
util::rb_tree::container<ipr::Linkage> linkages;
2665+
util::rb_tree::container<ipr::Language_linkage> linkages;
26662666
util::rb_tree::container<ipr::Calling_convention> conventions;
26672667

26682668
util::rb_tree::container<impl::Literal> lits;
@@ -2830,8 +2830,8 @@ namespace ipr::impl {
28302830
Lexicon();
28312831
~Lexicon();
28322832

2833-
const ipr::Linkage& cxx_linkage() const final;
2834-
const ipr::Linkage& c_linkage() const final;
2833+
const ipr::Language_linkage& cxx_linkage() const final;
2834+
const ipr::Language_linkage& c_linkage() const final;
28352835

28362836
ipr::Specifiers export_specifier() const final;
28372837
ipr::Specifiers static_specifier() const final;

include/ipr/interface

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ namespace ipr {
156156
const Logogram& conv;
157157
};
158158

159-
// -- Linkage --
159+
// -- Language_linkage --
160160
// An object of this type represents language linkage, e.g., "C" in `extern "C"'.
161161
// The ISO standard mandates at least two language linkages: "C" and
162162
// "C++". If those were the only language linkages used in practice,
@@ -166,11 +166,11 @@ namespace ipr {
166166
// is adopted in the form of a logogram. From ISO C++ point of view, language
167167
// linkage applies only to function names, variable names, and function types.
168168
// Furthermore, a language linkage applied to a function type is a calling convention.
169-
struct Linkage {
170-
explicit constexpr Linkage(const Logogram& l) : lang{l} { }
169+
struct Language_linkage {
170+
explicit constexpr Language_linkage(const Logogram& l) : lang{l} { }
171171
const Logogram& language() const { return lang; }
172-
bool operator==(const Linkage& x) const { return lang == x.lang; }
173-
bool operator!=(const Linkage&) const = default;
172+
bool operator==(const Language_linkage& x) const { return lang == x.lang; }
173+
bool operator!=(const Language_linkage&) const = default;
174174
private:
175175
const Logogram& lang;
176176
};
@@ -179,12 +179,12 @@ namespace ipr {
179179
// A summary of characteristics of data or control tranfer. Both language linkage and
180180
// calling convention affect how data are transferred to subroutines in function calls.
181181
// Furthermore, language linkage also affects linking across translation units.
182-
struct Transfer : Basic_binary<const Linkage&, const Calling_convention&> {
183-
const Linkage& linkage() const { return first(); }
182+
struct Transfer : Basic_binary<const Language_linkage&, const Calling_convention&> {
183+
const Language_linkage& language_linkage() const { return first(); }
184184
const Calling_convention& convention() const { return second(); }
185185
bool operator==(const Transfer& t) const
186186
{
187-
return linkage() == t.linkage() and convention() == t.convention();
187+
return language_linkage() == t.language_linkage() and convention() == t.convention();
188188
}
189189
bool operator!=(const Transfer&) const = default;
190190
};
@@ -568,7 +568,6 @@ namespace ipr {
568568
struct Type : Expr {
569569
virtual const Name& name() const = 0;
570570
virtual const Transfer& transfer() const = 0;
571-
const Linkage& linkage() const { return transfer().linkage(); }
572571
protected:
573572
constexpr Type(Category_code c) : Expr{ c } { }
574573
};
@@ -1776,7 +1775,7 @@ namespace ipr {
17761775
// (b) a non-template declaration.
17771776
struct Decl : Stmt {
17781777
virtual Specifiers specifiers() const = 0;
1779-
virtual const Linkage& linkage() const = 0;
1778+
virtual const Language_linkage& language_linkage() const = 0;
17801779

17811780
virtual const Name& name() const = 0;
17821781

@@ -1994,8 +1993,8 @@ namespace ipr {
19941993
// and as default value for case in labeled statements.
19951994
virtual const Symbol& delete_value() const = 0; // "delete" - as initializer in deleted function definitions.
19961995

1997-
virtual const Linkage& cxx_linkage() const = 0; // constant for 'extern "C++"'
1998-
virtual const Linkage& c_linkage() const = 0; // constant for 'extern "C"'
1996+
virtual const Language_linkage& cxx_linkage() const = 0; // constant for 'extern "C++"'
1997+
virtual const Language_linkage& c_linkage() const = 0; // constant for 'extern "C"'
19991998

20001999
virtual Specifiers export_specifier() const = 0; // `export` specifier.
20012000
virtual Specifiers static_specifier() const = 0; // `static` standard specifier.

src/impl.cxx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ namespace ipr::impl {
151151
constexpr auto& internal_string(const char8_t* p) { return known_word(p).operand(); }
152152

153153
// Known language linkages to all C++ implementations.
154-
constexpr Linkage c_link { known_word(u8"C") };
155-
constexpr Linkage cxx_link { known_word(u8"C++") };
154+
constexpr Language_linkage c_link { known_word(u8"C") };
155+
constexpr Language_linkage cxx_link { known_word(u8"C++") };
156156
}
157157

158-
const ipr::Linkage& c_linkage() { return impl::c_link; }
158+
const ipr::Language_linkage& c_linkage() { return impl::c_link; }
159159
}
160160

161161
// -- Standard basic specifiers and qualifiers
@@ -200,7 +200,7 @@ namespace ipr::impl {
200200
namespace ipr::impl {
201201
namespace {
202202
struct Natural_transfer : ipr::Transfer {
203-
const ipr::Linkage& first() const final { return impl::cxx_link; }
203+
const ipr::Language_linkage& first() const final { return impl::cxx_link; }
204204
const ipr::Calling_convention& second() const final { return impl::natural_cc; }
205205
};
206206

@@ -214,7 +214,7 @@ namespace ipr::impl {
214214
namespace ipr::impl {
215215
const ipr::Calling_convention& Transfer_from_linkage::second() const { return impl::natural_cc; }
216216

217-
const ipr::Linkage& Transfer_from_cc::first() const { return impl::cxx_link; }
217+
const ipr::Language_linkage& Transfer_from_cc::first() const { return impl::cxx_link; }
218218
}
219219

220220
namespace ipr::impl {
@@ -1009,7 +1009,7 @@ namespace ipr::impl {
10091009

10101010
inline int compare(const ipr::Transfer& x, const ipr::Transfer& y)
10111011
{
1012-
if (auto cmp = impl::compare(x.linkage(), y.linkage()))
1012+
if (auto cmp = impl::compare(x.language_linkage(), y.language_linkage()))
10131013
return cmp;
10141014
return impl::compare(x.convention(), y.convention());
10151015
}
@@ -1137,9 +1137,9 @@ namespace ipr::impl {
11371137
};
11381138
// <<<< Yuriy Solodkyy: 2008/07/10
11391139

1140-
const ipr::Transfer& type_factory::get_transfer_from_linkage(const ipr::Linkage& l)
1140+
const ipr::Transfer& type_factory::get_transfer_from_linkage(const ipr::Language_linkage& l)
11411141
{
1142-
constexpr auto cmp = [](auto& x, auto& y) { return impl::compare(x.linkage(), y); };
1142+
constexpr auto cmp = [](auto& x, auto& y) { return impl::compare(x.language_linkage(), y); };
11431143
return *xfer_links.insert(l, cmp);
11441144
}
11451145

@@ -1149,7 +1149,7 @@ namespace ipr::impl {
11491149
return *xfer_ccs.insert(c, cmp);
11501150
}
11511151

1152-
const ipr::Transfer& type_factory::get_transfer(const ipr::Linkage& l, const ipr::Calling_convention& c)
1152+
const ipr::Transfer& type_factory::get_transfer(const ipr::Language_linkage& l, const ipr::Calling_convention& c)
11531153
{
11541154
if (l == impl::cxx_link)
11551155
return get_transfer_from_convention(c);
@@ -1726,7 +1726,7 @@ namespace ipr::impl {
17261726
// ------------------------
17271727

17281728
// -- Language linkage
1729-
const ipr::Linkage& expr_factory::get_linkage(util::word_view w)
1729+
const ipr::Language_linkage& expr_factory::get_linkage(util::word_view w)
17301730
{
17311731
if (w == u8"C")
17321732
return impl::c_link;
@@ -1735,7 +1735,7 @@ namespace ipr::impl {
17351735
return get_linkage(get_string(w));
17361736
}
17371737

1738-
const ipr::Linkage& expr_factory::get_linkage(const ipr::String& lang)
1738+
const ipr::Language_linkage& expr_factory::get_linkage(const ipr::String& lang)
17391739
{
17401740
if (physically_same(lang, internal_string(u8"C")))
17411741
return impl::c_link;
@@ -2348,8 +2348,8 @@ namespace ipr::impl {
23482348

23492349
// -- impl::Lexicon --
23502350

2351-
const ipr::Linkage& Lexicon::c_linkage() const { return impl::c_link; }
2352-
const ipr::Linkage& Lexicon::cxx_linkage() const { return impl::cxx_link; }
2351+
const ipr::Language_linkage& Lexicon::c_linkage() const { return impl::c_link; }
2352+
const ipr::Language_linkage& Lexicon::cxx_linkage() const { return impl::cxx_link; }
23532353

23542354
namespace {
23552355
struct UnknownLogogramError {

0 commit comments

Comments
 (0)