26using Ptr = fe::Arena::Ref<const T>;
33using Ptrs = fe::Vector<Ptr<T>>;
34using Dbgs = fe::Vector<Dbg>;
56 std::optional<Vis>
vis = {};
68 :
sym{sym_plugin, sym_tag}
79 auto base =
sym.plugin.str() +
"." +
sym.tag.str();
80 return driver.sym(own ==
sym.tag ?
base :
base +
"." + own.str());
92 fe::Vector<fe::Vector<Sym>>
subs;
94 std::optional<bool>
pi;
117 Sym
sym(
const std::string& s) {
return driver().sym(s); }
124 template<
class T,
class... Args>
125 auto ptr(Args&&... args) {
126 return arena_.ref<
const T>(std::forward<Args>(args)...);
130 template<
class R,
class T = std::ranges::range_value_t<R>>
132 auto span = arena_.copy(range);
133 return fe::View<T>(span.data(), span.size());
144 std::pair<Ptr<File>&,
bool>
file(
const fe::Src* src);
158 void bootstrap(Sym plugin, std::ostream& h);
165 swap(a1.world_, a2.world_ );
166 swap(a1.arena_, a2.arena_ );
167 swap(a1.files_, a2.files_ );
168 swap(a1.scopes_, a2.scopes_);
176 World* world_ =
nullptr;
178 std::unique_ptr<Files> files_;
179 std::deque<Scope> scopes_;
182 absl::node_hash_map<fe::Sym, absl::node_hash_map<fe::Sym, AnnexInfo>> plugin2sym2annex_;
186class Node :
public fe::RuntimeCast<Node> {
191 assert((!
loc.begin == !
loc.end &&
loc.begin <=
loc.end) &&
"malformed Loc");
192 assert((!
loc || !
loc.src || (
loc.src->contains(
loc.begin) &&
loc.src->contains(
loc.end)))
193 &&
"Loc outside its Src");
197 Loc
loc()
const {
return loc_; }
199 virtual void stream(fe::Tab&, std::ostream&)
const = 0;
239 virtual Dbg
dbg()
const {
return Dbg(
loc(), Sym()); }
243 virtual std::pair<AnnexInfo*, sub_t>
annex_sub()
const {
return {
nullptr, 0}; }
249 virtual bool is_anx()
const {
return false; }
263 Vis vis()
const override {
return mods_.resolved_vis(); }
264 bool is_extern()
const override {
return mods_.is_extern; }
265 bool is_anx()
const override {
return mods_.is_anx; }
287 virtual void bind(
Scopes&,
bool rebind,
bool quiet)
const = 0;
304 void bind(
Scopes&,
bool rebind,
bool quiet)
const override;
307 void stream(fe::Tab&, std::ostream&)
const override;
318 Dbg
dbg()
const override {
return dbg_; }
320 std::pair<AnnexInfo*, sub_t>
annex_sub()
const override {
return {annex_, sub_}; }
322 Vis vis()
const override {
return vis_; }
323 bool is_anx()
const override {
return anx_; }
330 void bind(
Scopes&,
bool rebind,
bool quiet)
const override;
333 void stream(fe::Tab&, std::ostream&)
const override;
339 mutable sub_t sub_ = 0;
341 mutable bool anx_ =
false;
354 Dbg
dbg()
const override {
return dbg_; }
357 void bind(
Scopes&,
bool rebind,
bool quiet)
const override;
360 void stream(fe::Tab&, std::ostream&)
const override;
376 Dbg
dbg()
const override {
return dbg_; }
379 void bind(
Scopes&,
bool rebind,
bool quiet)
const override;
382 void stream(fe::Tab&, std::ostream&)
const override;
402 bool is_implicit()
const override {
return delim_l_ == Tok::Tag::D_brace_l; }
404 auto ptrns()
const {
return vla<0>(); }
408 void bind(
Scopes&,
bool rebind,
bool quiet)
const override;
413 void stream(fe::Tab&, std::ostream&)
const override;
430 void stream(fe::Tab&, std::ostream&)
const override;
443 void stream(fe::Tab&, std::ostream&)
const override;
457 auto dbgs()
const {
return vla<0>(); }
463 void stream(fe::Tab&, std::ostream&)
const override;
466 mutable const Decl* decl_ =
nullptr;
477 Dbg
dbg()
const {
return path_->back(); }
481 void stream(fe::Tab&, std::ostream&)
const override;
501 void stream(fe::Tab&, std::ostream&)
const override;
522 void stream(fe::Tab&, std::ostream&)
const override;
541 auto decls()
const {
return vla<0>(); }
546 void stream(fe::Tab&, std::ostream&)
const override;
565 void stream(fe::Tab&, std::ostream&)
const override;
580 const Expr*
dom()
const {
return dom_.get(); }
583 void stream(fe::Tab&, std::ostream&)
const override;
604 const Expr*
lhs()
const {
return lhs_.get(); }
606 const Expr*
rhs()
const {
return rhs_.get(); }
612 return infix && infix->op().isa(tag) ? infix :
nullptr;
616 void stream(fe::Tab&, std::ostream&)
const override;
630 mutable Pi* pi_ =
nullptr;
649 void stream(fe::Tab&, std::ostream&)
const override;
663 auto arms()
const {
return vla<0>(); }
668 void stream(fe::Tab&, std::ostream&)
const override;
693 auto loc = type->loc();
697 virtual void bind(
Scopes&,
bool quiet =
false)
const;
699 void stream(fe::Tab&, std::ostream&)
const override;
719 Tok::Tag tag()
const {
return tag_; }
720 const Dom* dom()
const {
return dom_.get(); }
721 const Expr* codom()
const {
return codom_.get(); }
723 void bind(Scopes&)
const override;
724 void stream(fe::Tab&, std::ostream&)
const override;
727 const Def*
emit_(Emitter&)
const override;
728 const Def*
emit_decl_(Emitter&,
const Def* type)
const override;
729 void emit_body_(Emitter&,
const Def* decl)
const override;
744 void stream(fe::Tab&, std::ostream&)
const override;
763 const Expr*
arg()
const {
return arg_.get(); }
766 void stream(fe::Tab&, std::ostream&)
const override;
787 const Expr*
arg()
const {
return arg_.get(); }
791 void stream(fe::Tab&, std::ostream&)
const override;
813 void stream(fe::Tab&, std::ostream&)
const override;
831 auto elems()
const {
return vla<0>(); }
836 void stream(fe::Tab&, std::ostream&)
const override;
856 void stream(fe::Tab&, std::ostream&)
const override;
871 , inhabitant_(expr) {}
876 void stream(fe::Tab&, std::ostream&)
const override;
915 bool is_import()
const {
return tag_ != Tok::Tag::K_use; }
917 Dbg
alias()
const {
return alias_; }
924 Dbg
dbg()
const override {
return is_splice() ? Dbg() : alias_ ? alias_ : path_->back(); }
929 void stream(fe::Tab&, std::ostream&)
const override;
939 const File* file_ =
nullptr;
941 mutable const Scope* scope_ =
nullptr;
957 void stream(fe::Tab&, std::ostream&)
const override;
977 Dbg
dbg()
const override {
return dbg_; }
982 void stream(fe::Tab&, std::ostream&)
const override;
983 std::pair<AnnexInfo*, sub_t>
annex_sub()
const override {
return {annex_, sub_}; }
989 mutable sub_t sub_ = 0;
1000 Dbg
dbg()
const override {
return dbg_; }
1009 void stream(fe::Tab&, std::ostream&)
const override;
1010 std::pair<AnnexInfo*, sub_t>
annex_sub()
const override {
return {annex_, sub_}; }
1018 mutable sub_t sub_ = 0;
1019 mutable const Def* mim_type_ =
nullptr;
1031 Dbg
dbg()
const override {
return dbg_; }
1043 void stream(fe::Tab&, std::ostream&)
const override;
1044 std::pair<AnnexInfo*, sub_t>
annex_sub()
const override {
return {annex_, sub_}; }
1048 virtual void stream_(fe::Tab&, std::ostream&)
const;
1055 mutable sub_t sub_ = 0;
1071 void bind(
Scopes&,
bool quiet =
false)
const override;
1073 void stream(fe::Tab&, std::ostream&)
const override;
1092 auto doms()
const {
return vla<0>(); }
1101 std::pair<AnnexInfo*, sub_t>
annex_sub()
const override {
return {annex_, sub_}; }
1104 void stream_(fe::Tab&, std::ostream&)
const override;
1110 mutable sub_t sub_ = 0;
1121 Dbg
dbg()
const override {
return dbg_; }
1126 void stream(fe::Tab&, std::ostream&)
const override;
1127 std::pair<AnnexInfo*, sub_t>
annex_sub()
const override {
return {annex_, sub_}; }
1133 mutable sub_t sub_ = 0;
1148 Dbg
dbg()
const override {
return dbg_; }
1156 void stream(fe::Tab&, std::ostream&)
const override;
1166 bool is_normalizer_;
1179 Dbg
dbg()
const override {
return dbg_; }
1185 void stream(fe::Tab&, std::ostream&)
const override;
1194 fe::View<Ptr<ValDecl>> decls_;
1219 void stream(fe::Tab&, std::ostream&)
const override;
1222 mutable fe::View<Ptr<UseDecl>> implicit_imports_;
1224 mutable bool bound_ =
false, emitted_ =
false;
1229 return load_plugins(w, fe::View<std::string>({std::string(plugin)}));
Some "global" variables needed all over the place.
A dependent function type.
The World represents the whole program and manages creation of MimIR nodes (Defs).
Owns the arena all AST nodes live in as well as the AnnexInfos of all plugins.
Scope & scope()
A fresh Scope for a ModDecl; owned here, as an AST node never runs a destructor.
friend void swap(AST &a1, AST &a2) noexcept
fe::View< T > copy(const R &range)
An Arena-allocated copy of range - for the few lists that do not sit behind a node.
auto ptr(Args &&... args)
The VLA ranges of a fe::VLA node come last, in the order its VLA_Types declares them.
void bootstrap_py(Sym plugin, std::ostream &h)
Sym sym(std::string_view s)
const auto & plugin2annexes(Sym plugin)
void bootstrap(Sym plugin, std::ostream &h)
Sym sym_return()
"return".
AnnexInfo * name2annex(Scopes &s, Dbg dbg, sub_t *sub_id)
Sym sym_error()
"_error_".
std::pair< Ptr< File > &, bool > file(const fe::Src *src)
Sym sym(const std::string &s)
void emit(Emitter &) const override
Dbg dbg() const override
The name this Decl introduces; anonymous if it has none.
std::pair< AnnexInfo *, sub_t > annex_sub() const override
The (AnnexInfo, sub) slot this decl registered itself under as an annex; {nullptr,...
void stream(fe::Tab &, std::ostream &) const override
void bind(Scopes &) const override
const Path * path() const
AliasDecl(Loc loc, Vis vis, Dbg dbg, Ptr< Path > path)
const Def * emit_value(Emitter &, const Def *) const override
const Def * emit_type(Emitter &) const override
const Ptrn * ptrn() const
Dbg dbg() const override
The name this Decl introduces; anonymous if it has none.
AliasPtrn(Loc loc, Ptr< Ptrn > ptrn, Dbg dbg)
bool is_implicit() const override
void bind(Scopes &, bool rebind, bool quiet) const override
void stream(fe::Tab &, std::ostream &) const override
void bind(Scopes &) const override
AppExpr(Loc loc, Ptr< Expr > callee, Ptr< Expr > arg)
const Def * emit_(Emitter &) const override
void stream(fe::Tab &, std::ostream &) const override
const Expr * callee() const
Sibling(Loc loc, Vis vis, Dbg dbg, const AxmDecl *owner)
const AxmDecl * owner() const
std::pair< AnnexInfo *, sub_t > annex_sub() const override
The (AnnexInfo, sub) slot this decl registered itself under as an annex; {nullptr,...
Dbg dbg() const override
The name this Decl introduces; anonymous if it has none.
void emit(Emitter &) const override
std::pair< AnnexInfo *, sub_t > annex_sub() const override
The (AnnexInfo, sub) slot this decl registered itself under as an annex; {nullptr,...
const Expr * type() const
void bind(Scopes &) const override
AxmDecl(Loc loc, Vis vis, Dbg dbg, Ptr< Expr > type, Dbg normalizer, Tok curry, Tok trip)
void stream(fe::Tab &, std::ostream &) const override
const Def * mim_type() const
Dbg dbg() const override
The name this Decl introduces; anonymous if it has none.
const Expr * expr() const
DeclExpr(Loc loc, Ptr< Expr > expr, bool is_where)
const Def * emit_(Emitter &) const override
std::tuple< Ptr< ValDecl > > VLA_Types
void bind(Scopes &) const override
void stream(fe::Tab &, std::ostream &) const override
Base class of all declarations; caches the emitted Decl::def.
virtual bool is_anx() const
Whether this decl is registered as a compiler-exposed annex (anx).
virtual std::pair< AnnexInfo *, sub_t > annex_sub() const
The (AnnexInfo, sub) slot this decl registered itself under as an annex; {nullptr,...
virtual Vis vis() const
A ValDecl's own Vis; Pub for anything else (Ptrn, Import, ...), which the priv/pub system ignores.
virtual bool is_extern() const
Whether this decl crosses the Mim/native boundary (extern); body presence picks which side supplies i...
virtual const Scope * scope() const
Non-nullptr if this Decl is a module whose members a Path may walk into.
virtual Dbg dbg() const
The name this Decl introduces; anonymous if it has none.
void stream(fe::Tab &, std::ostream &) const override
void bind(Scopes &) const override
const Def * emit_(Emitter &) const override
const Def * emit_type(Emitter &) const override
const Def * emit_value(Emitter &, const Def *) const override
void bind(Scopes &, bool rebind, bool quiet) const override
void stream(fe::Tab &, std::ostream &) const override
Base class of all expressions.
const Def * emit(Emitter &) const
const Def * emit_decl(Emitter &, const Def *type) const
virtual const Def * emit_decl_(Emitter &, const Def *) const
virtual void bind(Scopes &) const =0
virtual const Def * emit_(Emitter &) const =0
void emit_body(Emitter &, const Def *decl) const
virtual void emit_body_(Emitter &, const Def *) const
The AST of one source file: an anonymous ModDecl that a UseDecl binds under a name of its own.
void add_implicit_imports(fe::View< Ptr< UseDecl > > imports) const
void compile(AST &) const
auto implicit_imports() const
Imports the driver was told about via -p; they precede everything the file itself declares.
void stream(fe::Tab &, std::ostream &) const override
File(Loc loc, Scope &members, fe::View< Ptr< ValDecl > > decls)
const Def * emit_type(Emitter &) const override
GrpPtrn(Dbg dbg, const IdPtrn *id)
void bind(Scopes &, bool rebind, bool quiet) const override
const Def * emit_value(Emitter &, const Def *) const override
void stream(fe::Tab &, std::ostream &) const override
const IdPtrn * id() const
Dbg dbg() const override
The name this Decl introduces; anonymous if it has none.
void bind(Scopes &) const override
void stream(fe::Tab &, std::ostream &) const override
const Def * emit_(Emitter &) const override
Vis vis() const override
Mirrors the enclosing LetDecl::vis/is_anx, since a let's Ptrn - not the LetDecl - is what a Path reso...
void stream(fe::Tab &, std::ostream &) const override
const Def * emit_type(Emitter &) const override
void bind(Scopes &, bool rebind, bool quiet) const override
IdPtrn(Loc loc, Dbg dbg, Ptr< Expr > type)
std::pair< AnnexInfo *, sub_t > annex_sub() const override
The (AnnexInfo, sub) slot this decl registered itself under as an annex; {nullptr,...
Dbg dbg() const override
The name this Decl introduces; anonymous if it has none.
const Def * emit_value(Emitter &, const Def *) const override
static Ptr< IdPtrn > make_id(AST &ast, Dbg dbg, Ptr< Expr > type)
const Expr * type() const
bool is_anx() const override
Whether this decl is registered as a compiler-exposed annex (anx).
void emit_body_(Emitter &, const Def *decl) const override
void bind(Scopes &) const override
static const InfixExpr * isa_op(Tok::Tag tag, const Expr *expr)
const Expr * callee() const
const Def * emit_(Emitter &) const override
const Def * emit_decl_(Emitter &, const Def *type) const override
void stream(fe::Tab &, std::ostream &) const override
InfixExpr(Loc loc, Ptr< Expr > lhs, Tok op, Ptr< Expr > rhs, Ptr< Expr > callee)
callee is the `op a MIM_INFIX_SUGAR operator desugars to and nullptr for MIM_INFIX_CORE.
One dom of a LamDecl: ptrn@(filter) with an optional : ret type.
Lam * emit_value(Emitter &) const
const Expr * filter() const
Dom(Loc loc, Ptr< Ptrn > ptrn, Ptr< Expr > filter)
tag dbg dom_0 ... dom_n-1: codom = body; with LamDecl::tag lam/con/fun or anonymous λ/cn/fn.
void bind_body(Scopes &) const override
bool is_external() const
extern without a body is a forward declaration whose implementation lives in a native translation uni...
std::pair< AnnexInfo *, sub_t > annex_sub() const override
The (AnnexInfo, sub) slot this decl registered itself under as an annex; {nullptr,...
const Expr * codom() const
std::tuple< Ptr< Dom > > VLA_Types
void emit_decl(Emitter &) const override
void emit_body(Emitter &) const override
void bind_decl(Scopes &) const override
LamDecl(Loc loc, Mods mods, Tok::Tag tag, Dbg dbg, Ptr< Expr > codom, Ptr< Expr > body, Ptr< RecDecl > next)
const Dom * dom(size_t i) const
void stream_(fe::Tab &, std::ostream &) const override
Streams this declaration alone - without the leading rec/and and without the trailing ;.
void bind(Scopes &) const override
void emit_body_(Emitter &, const Def *decl) const override
const Def * emit_(Emitter &) const override
const LamDecl * lam() const
const Def * emit_decl_(Emitter &, const Def *type) const override
void stream(fe::Tab &, std::ostream &) const override
LamExpr(Ptr< LamDecl > lam)
void bind(Scopes &) const override
void stream(fe::Tab &, std::ostream &) const override
LetDecl(Loc loc, Mods mods, Ptr< Ptrn > ptrn, Ptr< Expr > value)
const Expr * value() const
const Ptrn * ptrn() const
void emit(Emitter &) const override
const Expr * type() const
const Def * emit_(Emitter &) const override
LitExpr(Loc loc, Tok tok, Ptr< Expr > type)
void bind(Scopes &) const override
void stream(fe::Tab &, std::ostream &) const override
ptrn => body of a MatchExpr.
const Expr * body() const
Arm(Loc loc, Ptr< Ptrn > ptrn, Ptr< Expr > body)
const Ptrn * ptrn() const
void bind(Scopes &) const override
const Def * emit_(Emitter &) const override
std::tuple< Ptr< Arm > > VLA_Types
const Expr * scrutinee() const
void stream(fe::Tab &, std::ostream &) const override
const Arm * arm(size_t i) const
MatchExpr(Loc loc, Ptr< Expr > scrutinee)
void bind_decls(Scopes &) const
void bind(Scopes &) const override
void emit_decls(Emitter &) const
void emit(Emitter &) const override
ModDecl(Loc loc, Vis vis, Dbg dbg, Scope &members, fe::View< Ptr< ValDecl > > decls)
void stream(fe::Tab &, std::ostream &) const override
const Scope * scope() const override
Non-nullptr if this Decl is a module whose members a Path may walk into.
Dbg dbg() const override
The name this Decl introduces; anonymous if it has none.
virtual void stream(fe::Tab &, std::ostream &) const =0
const Def * emit_(Emitter &) const override
const Path * path() const
void bind(Scopes &) const override
PathExpr(Ptr< Path > path)
void stream(fe::Tab &, std::ostream &) const override
const Decl * decl() const
void bind(Scopes &, bool quiet=false) const
std::tuple< Dbg > VLA_Types
void stream(fe::Tab &, std::ostream &) const override
const Decl * decl() const
One dom of a PiExpr: ptrn with an optional -> ret type.
virtual void emit_type(Emitter &) const
Dom(Loc loc, Ptr< Ptrn > ptrn)
void add_ret(AST &ast, Ptr< Expr > type) const
const IdPtrn * ret() const
const Ptrn * ptrn() const
const Def * emit_(Emitter &) const override
void stream(fe::Tab &, std::ostream &) const override
void bind(Scopes &) const override
const Def * emit_decl_(Emitter &, const Def *type) const override
PiExpr(Loc loc, Tok::Tag tag, Ptr< Dom > dom, Ptr< Expr > codom)
void emit_body_(Emitter &, const Def *decl) const override
void stream(fe::Tab &, std::ostream &) const override
const Def * emit_(Emitter &) const override
void bind(Scopes &) const override
PrimaryExpr(Loc loc, Tok::Tag tag)
Base class of all patterns.
static Ptr< Expr > to_expr(AST &, Ptr< Ptrn >)
virtual void bind(Scopes &, bool rebind, bool quiet) const =0
virtual const Def * emit_value(Emitter &, const Def *) const =0
const Def * emit_proj(Emitter &, const Def *def, size_t n, size_t i) const
Ptrn::emit_value on def's i-th of n projections - with this Ptrn's Loc, so the projection is blamed o...
virtual const Def * emit_type(Emitter &) const =0
virtual bool is_implicit() const
void emit(Emitter &) const override
void stream(fe::Tab &, std::ostream &) const override
virtual void emit_body(Emitter &) const
virtual void bind_body(Scopes &) const
virtual void emit_decl(Emitter &) const
virtual void bind_decl(Scopes &) const
Dbg dbg() const override
The name this Decl introduces; anonymous if it has none.
RecDecl(Loc loc, Mods mods, Dbg dbg, Ptr< Expr > body, Ptr< RecDecl > next)
virtual void stream_(fe::Tab &, std::ostream &) const
Streams this declaration alone - without the leading rec/and and without the trailing ;.
const Expr * body() const
const RecDecl * next() const
void bind(Scopes &) const override
std::pair< AnnexInfo *, sub_t > annex_sub() const override
The (AnnexInfo, sub) slot this decl registered itself under as an annex; {nullptr,...
const Ptrn * ptrn() const
void bind(Scopes &) const override
void stream(fe::Tab &, std::ostream &) const override
const Def * emit_(Emitter &) const override
RetExpr(Loc loc, Ptr< Ptrn > ptrn, Ptr< Expr > callee, Ptr< Expr > arg, Ptr< Expr > body)
const Expr * body() const
const Expr * callee() const
void bind(Scopes &) const override
const Expr * guard() const
bool is_normalizer() const
RuleDecl(Loc loc, Dbg dbg, Ptr< Ptrn > var, Ptr< Expr > lhs, Ptr< Expr > rhs, Ptr< Expr > guard, bool is_normalizer)
void emit(Emitter &) const override
Dbg dbg() const override
The name this Decl introduces; anonymous if it has none.
void stream(fe::Tab &, std::ostream &) const override
void bind(Scopes &) const override
RuleExpr(Loc loc, Ptr< Expr > dom)
const Def * emit_(Emitter &) const override
void stream(fe::Tab &, std::ostream &) const override
const Expr * body() const
SeqExpr(Loc loc, bool is_pack, Ptr< IdPtrn > arity, Ptr< Expr > body)
const IdPtrn * arity() const
void bind(Scopes &) const override
void stream(fe::Tab &, std::ostream &) const override
const Def * emit_(Emitter &) const override
const TuplePtrn * ptrn() const
const Def * emit_decl_(Emitter &, const Def *type) const override
void emit_body_(Emitter &, const Def *decl) const override
const Def * emit_(Emitter &) const override
void bind(Scopes &) const override
void stream(fe::Tab &, std::ostream &) const override
SigmaExpr(Ptr< TuplePtrn > ptrn)
static constexpr Tok::Tag delim_l2r(Tag tag)
const Expr * elem(size_t i) const
void bind(Scopes &) const override
const Def * emit_(Emitter &) const override
void stream(fe::Tab &, std::ostream &) const override
std::tuple< Ptr< Expr > > VLA_Types
(ptrn_0, ..., ptrn_n-1), [ptrn_0, ..., ptrn_n-1], or {ptrn_0, ..., ptrn_n-1}
bool is_implicit() const override
void bind(Scopes &, bool rebind, bool quiet) const override
const Ptrn * ptrn(size_t i) const
std::tuple< Ptr< Ptrn > > VLA_Types
const Def * emit_type(Emitter &) const override
const Def * emit_decl(Emitter &, const Def *type) const
void stream(fe::Tab &, std::ostream &) const override
TuplePtrn(Loc loc, Tok::Tag delim_l)
const Def * emit_value(Emitter &, const Def *) const override
const Def * emit_body(Emitter &, const Def *decl) const
const Def * emit_(Emitter &) const override
const Expr * level() const
void stream(fe::Tab &, std::ostream &) const override
TypeExpr(Loc loc, Ptr< Expr > level)
void bind(Scopes &) const override
const Expr * inhabitant() const
const Def * emit_(Emitter &) const override
UniqExpr(Loc loc, Ptr< Expr > expr)
void bind(Scopes &) const override
void stream(fe::Tab &, std::ostream &) const override
Dbg dbg() const override
The name this decl introduces; anonymous if it splices instead.
UseDecl(Loc loc, Mods mods, Ptr< Path > path, Dbg alias)
use path [as alias|*];; no alias means as *.
const Scope * scope() const override
Non-nullptr if this Decl is a module whose members a Path may walk into.
void emit(Emitter &) const override
bool is_splice() const
as *: splice the module's public members, bind no name.
Dbg alias() const
Empty, unless the source spelled as I.
void stream(fe::Tab &, std::ostream &) const override
Sym file_path() const
Spelling of an import "..."; empty otherwise.
void bind(Scopes &) const override
bool is_file_path() const
UseDecl(Loc loc, Mods mods, Tok::Tag tag, Ptr< Path > path, Sym file_path, Dbg alias, bool splice, const File *file)
import/plugin; name is the module name, derived from file_path if there is one.
const File * file() const
Tok::Tag tag() const
import, plugin, or use.
const Path * path() const
Module path of a use; module name of an import/plugin.
virtual void bind(Scopes &) const =0
ValDecl(Loc loc, Mods mods={})
const Mods & mods() const
bool is_extern() const override
Whether this decl crosses the Mim/native boundary (extern); body presence picks which side supplies i...
Vis vis() const override
A ValDecl's own Vis; Pub for anything else (Ptrn, Import, ...), which the priv/pub system ignores.
virtual void emit(Emitter &) const =0
bool is_anx() const override
Whether this decl is registered as a compiler-exposed annex (anx).
fe::SymMap< Bind > Scope
Maps a name to the Binding introducing it.
Vis
Visibility tier of a ValDecl.
AST load_plugins(World &, fe::View< std::string >)
fe::Arena::Ref< const T > Ptr
Nodes live in the AST's Arena and are never destroyed, so this merely points at one.
AST load_plugin(World &w, std::string_view plugin)
fe::Vector< Ptr< T > > Ptrs
One name in a Scope: the Decl it introduces and the Vis of this binding.
static constexpr flags_t flags(plugin_t p, tag_t t, sub_t s=0)
Assembles the full flags from its plugin, tag, and sub fields.
static std::optional< plugin_t > mangle(std::string_view plugin)
Mangles s into a dense 48-bit representation.
Bookkeeping of an annex introduced by an AxmDecl.
Sym qualified(Driver &driver, Sym own) const
Fully-qualified plugin.tag[.sub] name for own (this decl's own Dbg::sym), registered for by-name look...
struct mim::ast::AnnexInfo::@112046103026102051147230017206327014033073201371 sym
struct mim::ast::AnnexInfo::@177100250272201136376142224053244231100060214216 id
plugin_t plugin_id() const
The mangled plugin part of the flags.
AnnexInfo(Sym sym_plugin, Sym sym_tag, tag_t id_tag)
flags_t base() const
The base flags (plugin + tag, no sub).
fe::Vector< fe::Vector< Sym > > subs
List of subs which is a list of aliases.
Raw, unvalidated combination of priv/pub/extern/anx modifiers written before a declaration.
Vis default_vis() const
extern/anx nudge the default visibility to Pub unless priv is given explicitly.