Change singleton returned type to a reference

We do not need a raw pointer for this singleton,
nor we need having it on the heap through a
smart pointer.

gcc/rust/ChangeLog:

	* ast/rust-ast.h: Change dereference from a pointer to a reference
	accessor.
	* ast/rust-expr.h: Likewise.
	* ast/rust-item.h: Likewise.
	* ast/rust-macro.h: Likewise.
	* ast/rust-path.h: Likewise.
	* ast/rust-pattern.h: Likewise.
	* ast/rust-type.h: Likewise.
	* backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address):
	Likewise.
	* backend/rust-compile-context.h: Likewise.
	* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
	(CompileExpr::generate_closure_function): Likewise.
	* backend/rust-compile-extern.h: Likewise.
	* backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise.
	* backend/rust-compile-intrinsic.cc (Intrinsics::compile): Likewise.
	* backend/rust-compile-item.cc (CompileItem::visit): Likewise.
	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve):
	Likewise.
	(HIRCompileBase::query_compile): Likewise.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise.
	(TyTyResolveCompile::create_dyn_obj_record): Likewise.
	* backend/rust-compile.cc (HIRCompileBase::coerce_to_dyn_object):
	Likewise.
	* backend/rust-mangle-v0.cc (v0_path): Likewise.
	(v0_mangle_item): Likewise.
	* checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go):
	Likewise.
	* checks/errors/privacy/rust-privacy-check.cc (Resolver::resolve):
	Likewise.
	* checks/errors/rust-const-checker.cc (ConstChecker::ConstChecker):
	Likewise.
	* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::UnsafeChecker):
	Likewise.
	* checks/lints/rust-lint-marklive-base.h: Likewise.
	* checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise.
	(MarkLive::visit): Likewise.
	(MarkLive::visit_path_segment): Likewise.
	* checks/lints/rust-lint-marklive.h: Likewise.
	* checks/lints/rust-lint-scan-deadcode.h: Likewise.
	* expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Likewise.
	* expand/rust-macro-expand.h (struct MacroExpander): Change mapping
	from pointer to a reference.
	* expand/rust-proc-macro.cc (BangProcMacro::BangProcMacro): Replace
	pointer accessor with reference accessor.
	(AttributeProcMacro::AttributeProcMacro): Likewise.
	(CustomDeriveProcMacro::CustomDeriveProcMacro): Likewise.
	* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_lifetime):
	Likewise.
	(ASTLoweringBase::lower_loop_label): Likewise.
	(ASTLoweringBase::lower_path_expr_seg): Likewise.
	(ASTLoweringBase::lower_self): Likewise.
	(ASTLoweringBase::handle_lang_item_attribute): Likewise.
	(ASTLoweringBase::lower_extern_block): Likewise.
	(ASTLoweringBase::lower_macro_definition): Likewise.
	* hir/rust-ast-lower-base.h: Likewise.
	* hir/rust-ast-lower-block.h: Likewise.
	* hir/rust-ast-lower-enumitem.h: Likewise.
	* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::translate): Likewise.
	(ASTLoweringExpr::visit): Likewise.
	* hir/rust-ast-lower-extern.h: Likewise.
	* hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::translate):
	Likewise.
	(ASTLowerImplItem::visit): Likewise.
	(ASTLowerTraitItem::translate): Likewise.
	(ASTLowerTraitItem::visit): Likewise.
	* hir/rust-ast-lower-item.cc (ASTLoweringItem::translate): Likewise.
	(ASTLoweringItem::visit): Likewise.
	(ASTLoweringSimplePath::lower): Likewise.
	* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate):
	Likewise.
	(ASTLoweringPattern::visit): Likewise.
	* hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::translate): Likewise.
	(ASTLoweringStmt::visit): Likewise.
	* hir/rust-ast-lower-struct-field-expr.h: Likewise.
	* hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Likewise.
	(ASTLowerQualifiedPathInType::visit): Likewise.
	(ASTLoweringType::translate): Likewise.
	(ASTLoweringType::visit): Likewise.
	(ASTLowerGenericParam::translate): Likewise.
	(ASTLowerGenericParam::visit): Likewise.
	(ASTLoweringTypeBounds::translate): Likewise.
	(ASTLoweringTypeBounds::visit): Likewise.
	(ASTLowerWhereClauseItem::translate): Likewise.
	(ASTLowerWhereClauseItem::visit): Likewise.
	* hir/rust-ast-lower.cc (ASTLowering::go): Likewise.
	(ASTLoweringBlock::visit): Likewise.
	(ASTLoweringIfBlock::visit): Likewise.
	(ASTLoweringIfLetBlock::visit): Likewise.
	(ASTLowerStructExprField::visit): Likewise.
	(ASTLoweringExprWithBlock::visit): Likewise.
	(ASTLowerPathInExpression::visit): Likewise.
	(ASTLoweringBase::lower_qual_path_type): Likewise.
	(ASTLowerQualPathInExpression::visit): Likewise.
	* metadata/rust-export-metadata.cc (ExportContext::emit_trait):
	Likewise.
	(ExportContext::emit_function): Likewise.
	(ExportContext::emit_macro): Likewise.
	(PublicInterface::PublicInterface): Likewise.
	(PublicInterface::expected_metadata_filename): Likewise.
	* metadata/rust-export-metadata.h: Likewise.
	* resolve/rust-ast-resolve-base.h: Likewise.
	* resolve/rust-ast-resolve-implitem.h: Likewise.
	* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit):
	Likewise.
	(ResolveItem::visit): Likewise.
	(ResolveExternItem::visit): Likewise.
	* resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path):
	Likewise.
	* resolve/rust-ast-resolve-stmt.h: Likewise.
	* resolve/rust-ast-resolve-toplevel.h: Likewise.
	* resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go):
	Likewise.
	(ResolveTypeToCanonicalPath::visit): Likewise.
	* resolve/rust-ast-resolve-type.h: Likewise.
	* resolve/rust-ast-resolve.cc (NameResolution::NameResolution):
	Likewise.
	(NameResolution::go): Likewise.
	* resolve/rust-ast-resolve.h: Likewise.
	* resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes):
	Likewise.
	* resolve/rust-early-name-resolver.cc (EarlyNameResolver::EarlyNameResolver):
	Likewise.
	* resolve/rust-late-name-resolver-2.0.cc (next_node_id): Likewise.
	(next_hir_id): Likewise.
	* resolve/rust-name-resolution-context.cc (NameResolutionContext::NameResolutionContext):
	Likewise.
	* resolve/rust-name-resolver.cc (Resolver::Resolver): Likewise.
	(Resolver::generate_builtins): Likewise.
	(Resolver::setup_builtin): Likewise.
	* resolve/rust-name-resolver.h: Likewise.
	* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
	Likewise.
	(TopLevel::handle_use_glob): Likewise.
	* rust-session-manager.cc (Session::get_instance): Likewise.
	(Session::handle_input_files): Likewise.
	(Session::handle_crate_name): Likewise.
	(Session::compile_crate): Likewise.
	(Session::load_extern_crate): Likewise.
	* rust-session-manager.h: Likewise.
	* typecheck/rust-autoderef.cc (Adjuster::try_unsize_type): Likewise.
	* typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion):
	Likewise.
	(TypeCoercionRules::coerce_unsafe_ptr): Likewise.
	(TypeCoercionRules::coerce_borrowed_pointer): Likewise.
	(TypeCoercionRules::coerce_unsized): Likewise.
	* typecheck/rust-coercion.h: Likewise.
	* typecheck/rust-hir-dot-operator.cc (MethodResolver::select):
	Likewise.
	* typecheck/rust-hir-inherent-impl-overlap.h: Likewise.
	* typecheck/rust-hir-path-probe.cc (PathProbeType::process_enum_item_for_candiates):
	Likewise.
	(PathProbeType::process_impl_items_for_candidates): Likewise.
	(PathProbeImplTrait::process_trait_impl_items_for_candidates):
	Likewise.
	* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait):
	Likewise.
	(TraitItemReference::get_parent_trait_mappings): Likewise.
	* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal):
	Likewise.
	(TypeCheckBase::get_marker_predicate): Likewise.
	* typecheck/rust-hir-type-check-base.h: Likewise.
	* typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit):
	Likewise.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
	Likewise.
	(TypeCheckExpr::resolve_operator_overload): Likewise.
	(TypeCheckExpr::resolve_fn_trait_call): Likewise.
	* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit):
	Likewise.
	(TypeCheckImplItem::visit): Likewise.
	* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):
	Likewise.
	* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path):
	Likewise.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::emit_pattern_size_error):
	Likewise.
	(ClosureParamInfer::Resolve): Likewise.
	* typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::resolve):
	Likewise.
	* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Likewise.
	(TypeCheckType::resolve_root_path): Likewise.
	(TypeResolveGenericParam::visit): Likewise.
	(ResolveWhereClauseItem::visit): Likewise.
	* typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn):
	Likewise.
	* typecheck/rust-type-util.cc (query_type): Likewise.
	* typecheck/rust-typecheck-context.cc (TypeCheckContext::compute_inference_variables):
	Likewise.
	* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::scan): Likewise.
	(TypeBoundsProbe::assemble_builtin_candidate): Likewise.
	(TypeCheckBase::get_predicate_from_bound): Likewise.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise.
	(TypeCheckMethodCallExpr::check): Likewise.
	* typecheck/rust-tyty-call.h: Likewise.
	* typecheck/rust-tyty-cmp.h: Likewise.
	* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::override_context):
	Likewise.
	(SubstitutionRef::monomorphize): Likewise.
	* typecheck/rust-tyty-util.cc (TyVar::get_implicit_infer_var):
	Likewise.
	(TyVar::monomorphized_clone): Likewise.
	(TyWithLocation::TyWithLocation): Likewise.
	* typecheck/rust-tyty.cc (BaseType::satisfies_bound): Likewise.
	(InferType::clone): Likewise.
	(ADTType::handle_substitions): Likewise.
	(TupleType::handle_substitions): Likewise.
	(FnType::handle_substitions): Likewise.
	(ClosureType::setup_fn_once_output): Likewise.
	(ArrayType::handle_substitions): Likewise.
	(SliceType::handle_substitions): Likewise.
	(ReferenceType::handle_substitions): Likewise.
	(PointerType::handle_substitions): Likewise.
	(ParamType::handle_substitions): Likewise.
	* typecheck/rust-tyty.h: Likewise.
	* typecheck/rust-unify.cc (UnifyRules::UnifyRules): Likewise.
	(UnifyRules::commit): Likewise.
	* util/rust-hir-map.cc: Change getter return type to a reference.
	* util/rust-hir-map.h: Update function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
devel/rust/master
Pierre-Emmanuel Patry 2024-04-24 10:51:13 +02:00 committed by CohenArthur
parent 3a31617b48
commit 8a7256676e
94 changed files with 923 additions and 941 deletions

View File

@ -374,7 +374,7 @@ public:
// TODO: put checks in constructor to enforce this rule?
SimplePathSegment (std::string segment_name, location_t locus)
: segment_name (std::move (segment_name)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
/* Returns whether simple path segment is in an invalid state (currently, if
@ -425,14 +425,14 @@ public:
location_t locus = UNDEF_LOCATION)
: opening_scope_resolution (has_opening_scope_resolution),
segments (std::move (path_segments)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
SimplePath (Identifier ident)
: opening_scope_resolution (false),
segments ({SimplePathSegment (ident.as_string (), ident.get_locus ())}),
locus (ident.get_locus ()),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// Creates an empty SimplePath.
@ -1127,7 +1127,7 @@ public:
virtual void add_semicolon () {}
protected:
Stmt () : node_id (Analysis::Mappings::get ()->get_next_node_id ()) {}
Stmt () : node_id (Analysis::Mappings::get ().get_next_node_id ()) {}
// Clone function implementation as pure virtual method
virtual Stmt *clone_stmt_impl () const = 0;
@ -1264,7 +1264,7 @@ public:
protected:
// Constructor
Expr () : node_id (Analysis::Mappings::get ()->get_next_node_id ()) {}
Expr () : node_id (Analysis::Mappings::get ().get_next_node_id ()) {}
// Clone function implementation as pure virtual method
virtual Expr *clone_expr_impl () const = 0;
@ -1437,7 +1437,7 @@ public:
NodeId get_node_id () const { return node_id; }
protected:
Type () : node_id (Analysis::Mappings::get ()->get_next_node_id ()) {}
Type () : node_id (Analysis::Mappings::get ().get_next_node_id ()) {}
// Clone function implementation as pure virtual method
virtual Type *clone_type_impl () const = 0;
@ -1519,7 +1519,7 @@ public:
// Constructor
Lifetime (LifetimeType type, std::string name = std::string (),
location_t locus = UNDEF_LOCATION)
: TypeParamBound (Analysis::Mappings::get ()->get_next_node_id ()),
: TypeParamBound (Analysis::Mappings::get ().get_next_node_id ()),
lifetime_type (type), lifetime_name (std::move (name)), locus (locus)
{}
@ -1588,7 +1588,7 @@ public:
NodeId get_node_id () { return node_id; }
protected:
GenericParam () : node_id (Analysis::Mappings::get ()->get_next_node_id ()) {}
GenericParam () : node_id (Analysis::Mappings::get ().get_next_node_id ()) {}
GenericParam (NodeId node_id) : node_id (node_id) {}
// Clone function implementation as pure virtual method
@ -1682,12 +1682,12 @@ class TraitItem : public AssociatedItem
{
protected:
TraitItem (location_t locus)
: node_id (Analysis::Mappings::get ()->get_next_node_id ()),
: node_id (Analysis::Mappings::get ().get_next_node_id ()),
vis (Visibility::create_private ()), locus (locus)
{}
TraitItem (Visibility vis, location_t locus)
: node_id (Analysis::Mappings::get ()->get_next_node_id ()), vis (vis),
: node_id (Analysis::Mappings::get ().get_next_node_id ()), vis (vis),
locus (locus)
{}
@ -1713,7 +1713,7 @@ public:
class ExternalItem : public Visitable
{
public:
ExternalItem () : node_id (Analysis::Mappings::get ()->get_next_node_id ()) {}
ExternalItem () : node_id (Analysis::Mappings::get ().get_next_node_id ()) {}
ExternalItem (NodeId node_id) : node_id (node_id) {}
@ -1987,7 +1987,7 @@ public:
Crate (std::vector<std::unique_ptr<Item>> items,
std::vector<Attribute> inner_attrs)
: inner_attrs (std::move (inner_attrs)), items (std::move (items)),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// Copy constructor with vector clone

View File

@ -26,7 +26,7 @@ public:
LoopLabel (Lifetime loop_label, location_t locus = UNDEF_LOCATION)
: label (std::move (loop_label)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// Returns whether the LoopLabel is in an error state.
@ -1113,7 +1113,7 @@ public:
NodeId get_node_id () const { return node_id; }
protected:
ArrayElems () : node_id (Analysis::Mappings::get ()->get_next_node_id ()) {}
ArrayElems () : node_id (Analysis::Mappings::get ().get_next_node_id ()) {}
// pure virtual clone implementation
virtual ArrayElems *clone_array_elems_impl () const = 0;
@ -1762,7 +1762,7 @@ protected:
// pure virtual clone implementation
virtual StructExprField *clone_struct_expr_field_impl () const = 0;
StructExprField () : node_id (Analysis::Mappings::get ()->get_next_node_id ())
StructExprField () : node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
NodeId node_id;
@ -4298,7 +4298,7 @@ private:
public:
MatchCase (MatchArm arm, std::unique_ptr<Expr> expr)
: arm (std::move (arm)), expr (std::move (expr)),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
MatchCase (const MatchCase &other)

View File

@ -86,7 +86,7 @@ public:
= std::vector<std::unique_ptr<TypeParamBound>> (),
std::unique_ptr<Type> type = nullptr,
Attribute outer_attr = Attribute::create_empty ())
: GenericParam (Analysis::Mappings::get ()->get_next_node_id ()),
: GenericParam (Analysis::Mappings::get ().get_next_node_id ()),
outer_attr (std::move (outer_attr)),
type_representation (std::move (type_representation)),
type_param_bounds (std::move (type_param_bounds)),
@ -210,7 +210,7 @@ public:
location_t locus)
: lifetime (std::move (lifetime)),
lifetime_bounds (std::move (lifetime_bounds)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
std::string as_string () const override;
@ -258,7 +258,7 @@ public:
: for_lifetimes (std::move (for_lifetimes)),
bound_type (std::move (bound_type)),
type_param_bounds (std::move (type_param_bounds)),
node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus)
node_id (Analysis::Mappings::get ().get_next_node_id ()), locus (locus)
{}
// Copy constructor requires clone
@ -339,7 +339,7 @@ class WhereClause
public:
WhereClause (std::vector<std::unique_ptr<WhereClauseItem>> where_clause_items)
: where_clause_items (std::move (where_clause_items)),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// copy constructor with vector clone
@ -396,7 +396,7 @@ class Param : public Visitable
public:
Param (std::vector<Attribute> outer_attrs, location_t locus)
: outer_attrs (std::move (outer_attrs)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
virtual ~Param () = default;
@ -1018,7 +1018,7 @@ protected:
virtual UseTree *clone_use_tree_impl () const = 0;
UseTree (location_t locus)
: locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ())
: locus (locus), node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
};
@ -1718,7 +1718,7 @@ public:
std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)),
field_name (std::move (field_name)), field_type (std::move (field_type)),
node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus)
node_id (Analysis::Mappings::get ().get_next_node_id ()), locus (locus)
{}
// Copy constructor
@ -1878,7 +1878,7 @@ public:
std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
: outer_attrs (std::move (outer_attrs)), visibility (std::move (vis)),
field_type (std::move (field_type)),
node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus)
node_id (Analysis::Mappings::get ().get_next_node_id ()), locus (locus)
{}
// Copy constructor with clone
@ -3573,7 +3573,7 @@ public:
std::vector<Attribute> outer_attrs, location_t locus)
: name (std::move (name)), param_type (std::move (param_type)),
outer_attrs (std::move (outer_attrs)),
node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus),
node_id (Analysis::Mappings::get ().get_next_node_id ()), locus (locus),
variadic (false)
{}
@ -3581,13 +3581,13 @@ public:
location_t locus)
: name (std::move (name)), param_type (nullptr),
outer_attrs (std::move (outer_attrs)),
node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus),
node_id (Analysis::Mappings::get ().get_next_node_id ()), locus (locus),
variadic (true)
{}
NamedFunctionParam (std::vector<Attribute> outer_attrs, location_t locus)
: name (""), param_type (nullptr), outer_attrs (std::move (outer_attrs)),
node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus),
node_id (Analysis::Mappings::get ().get_next_node_id ()), locus (locus),
variadic (true)
{}

View File

@ -720,7 +720,7 @@ private:
location_t locus, bool is_semi_coloned,
std::vector<std::unique_ptr<MacroInvocation>> &&pending_eager_invocs)
: TraitItem (locus), outer_attrs (std::move (outer_attrs)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ()),
node_id (Analysis::Mappings::get ().get_next_node_id ()),
invoc_data (std::move (invoc_data)), is_semi_coloned (is_semi_coloned),
kind (kind), builtin_kind (builtin_kind),
pending_eager_invocs (std::move (pending_eager_invocs))

View File

@ -506,7 +506,7 @@ public:
GenericArgs generic_args = GenericArgs::create_empty ())
: segment_name (std::move (segment_name)),
generic_args (std::move (generic_args)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
/* Constructor for segment with generic arguments (from segment name and all
@ -519,7 +519,7 @@ public:
generic_args (GenericArgs (std::move (lifetime_args),
std::move (generic_args),
std::move (binding_args))),
locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ())
locus (locus), node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// Returns whether path expression segment is in an error state.
@ -621,7 +621,7 @@ public:
: PathPattern (std::move (path_segments)),
outer_attrs (std::move (outer_attrs)),
has_opening_scope_resolution (has_opening_scope_resolution),
locus (locus), _node_id (Analysis::Mappings::get ()->get_next_node_id ())
locus (locus), _node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// Creates an error state path in expression.
@ -743,7 +743,7 @@ public:
bool has_separating_scope_resolution, location_t locus)
: ident_segment (std::move (ident_segment)), locus (locus),
has_separating_scope_resolution (has_separating_scope_resolution),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
TypePathSegment (std::string segment_name,
@ -751,7 +751,7 @@ public:
: ident_segment (PathIdentSegment (std::move (segment_name), locus)),
locus (locus),
has_separating_scope_resolution (has_separating_scope_resolution),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
TypePathSegment (TypePathSegment const &other)
@ -1149,7 +1149,7 @@ public:
TypePath trait_path = TypePath::create_error ())
: type_to_invoke_on (std::move (invoke_on_type)),
trait_path (std::move (trait_path)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// Copy constructor uses custom deep copy for Type to preserve polymorphism
@ -1243,7 +1243,7 @@ public:
: PathPattern (std::move (path_segments)),
outer_attrs (std::move (outer_attrs)),
path_type (std::move (qual_path_type)), locus (locus),
_node_id (Analysis::Mappings::get ()->get_next_node_id ())
_node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
/* TODO: maybe make a shortcut constructor that has QualifiedPathType

View File

@ -36,13 +36,13 @@ public:
// Constructor for a literal pattern
LiteralPattern (Literal lit, location_t locus)
: lit (std::move (lit)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
LiteralPattern (std::string val, Literal::LitType type, location_t locus,
PrimitiveCoreType type_hint)
: lit (Literal (std::move (val), type, type_hint)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
location_t get_locus () const override final { return locus; }
@ -90,7 +90,7 @@ public:
std::unique_ptr<Pattern> to_bind = nullptr)
: Pattern (), variable_ident (std::move (ident)), is_ref (is_ref),
is_mut (is_mut), to_bind (std::move (to_bind)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
IdentifierPattern (NodeId node_id, Identifier ident, location_t locus,
@ -175,7 +175,7 @@ public:
std::string as_string () const override { return std::string (1, '_'); }
WildcardPattern (location_t locus)
: locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ())
: locus (locus), node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
location_t get_locus () const override final { return locus; }
@ -204,7 +204,7 @@ public:
std::string as_string () const override { return ".."; }
RestPattern (location_t locus)
: locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ())
: locus (locus), node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
location_t get_locus () const override final { return locus; }
@ -390,7 +390,7 @@ public:
bool has_ellipsis_syntax = false)
: lower (std::move (lower)), upper (std::move (upper)),
has_ellipsis_syntax (has_ellipsis_syntax), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// Copy constructor with clone
@ -469,7 +469,7 @@ public:
bool ref_has_two_amps, location_t locus)
: has_two_amps (ref_has_two_amps), is_mut (is_mut_reference),
pattern (std::move (pattern)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// Copy constructor requires clone
@ -612,7 +612,7 @@ public:
std::vector<Attribute> outer_attribs,
location_t locus)
: StructPatternField (std::move (outer_attribs), locus,
Analysis::Mappings::get ()->get_next_node_id ()),
Analysis::Mappings::get ().get_next_node_id ()),
index (index), tuple_pattern (std::move (tuple_pattern))
{}
@ -692,7 +692,7 @@ public:
std::vector<Attribute> outer_attrs,
location_t locus)
: StructPatternField (std::move (outer_attrs), locus,
Analysis::Mappings::get ()->get_next_node_id ()),
Analysis::Mappings::get ().get_next_node_id ()),
ident (std::move (ident)), ident_pattern (std::move (ident_pattern))
{}
@ -771,7 +771,7 @@ public:
StructPatternFieldIdent (Identifier ident, bool is_ref, bool is_mut,
std::vector<Attribute> outer_attrs, location_t locus)
: StructPatternField (std::move (outer_attrs), locus,
Analysis::Mappings::get ()->get_next_node_id ()),
Analysis::Mappings::get ().get_next_node_id ()),
has_ref (is_ref), has_mut (is_mut), ident (std::move (ident))
{}
@ -926,7 +926,7 @@ public:
StructPatternElements elems
= StructPatternElements::create_empty ())
: path (std::move (struct_path)), elems (std::move (elems)),
node_id (Analysis::Mappings::get ()->get_next_node_id ()), locus (locus)
node_id (Analysis::Mappings::get ().get_next_node_id ()), locus (locus)
{}
/* TODO: constructor to construct via elements included in
@ -1146,7 +1146,7 @@ public:
TupleStructPattern (PathInExpression tuple_struct_path,
std::unique_ptr<TupleStructItems> items)
: path (std::move (tuple_struct_path)), items (std::move (items)),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{
rust_assert (this->items != nullptr);
}
@ -1395,7 +1395,7 @@ public:
TuplePattern (std::unique_ptr<TuplePatternItems> items, location_t locus)
: items (std::move (items)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{
rust_assert (this->items != nullptr);
}
@ -1462,7 +1462,7 @@ public:
GroupedPattern (std::unique_ptr<Pattern> pattern_in_parens, location_t locus)
: pattern_in_parens (std::move (pattern_in_parens)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// Copy constructor uses clone
@ -1521,7 +1521,7 @@ public:
SlicePattern (std::vector<std::unique_ptr<Pattern>> items, location_t locus)
: items (std::move (items)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// Copy constructor with vector clone
@ -1588,7 +1588,7 @@ public:
AltPattern (std::vector<std::unique_ptr<Pattern>> alts, location_t locus)
: alts (std::move (alts)), locus (locus),
node_id (Analysis::Mappings::get ()->get_next_node_id ())
node_id (Analysis::Mappings::get ().get_next_node_id ())
{}
// Copy constructor with vector clone

View File

@ -52,7 +52,7 @@ public:
bool opening_question_mark = false,
std::vector<LifetimeParam> for_lifetimes
= std::vector<LifetimeParam> ())
: TypeParamBound (Analysis::Mappings::get ()->get_next_node_id ()),
: TypeParamBound (Analysis::Mappings::get ().get_next_node_id ()),
in_parens (in_parens), opening_question_mark (opening_question_mark),
for_lifetimes (std::move (for_lifetimes)),
type_path (std::move (type_path)), locus (locus)

View File

@ -877,7 +877,7 @@ HIRCompileBase::resolve_method_address (TyTy::FnType *fntype,
// Now we can try and resolve the address since this might be a forward
// declared function, generic function which has not be compiled yet or
// its an not yet trait bound function
HIR::Item *resolved_item = ctx->get_mappings ()->lookup_defid (id);
HIR::Item *resolved_item = ctx->get_mappings ().lookup_defid (id);
if (resolved_item != nullptr)
{
if (!fntype->has_substitutions_defined ())
@ -888,8 +888,8 @@ HIRCompileBase::resolve_method_address (TyTy::FnType *fntype,
// it might be resolved to a trait item
HIR::TraitItem *trait_item
= ctx->get_mappings ()->lookup_trait_item_defid (id);
HIR::Trait *trait = ctx->get_mappings ()->lookup_trait_item_mapping (
= ctx->get_mappings ().lookup_trait_item_defid (id);
HIR::Trait *trait = ctx->get_mappings ().lookup_trait_item_mapping (
trait_item->get_mappings ().get_hirid ());
Resolver::TraitReference *trait_ref

View File

@ -89,7 +89,7 @@ public:
Resolver::Resolver *get_resolver () { return resolver; }
Resolver::TypeCheckContext *get_tyctx () { return tyctx; }
Analysis::Mappings *get_mappings () { return mappings; }
Analysis::Mappings &get_mappings () { return mappings; }
void push_block (tree scope)
{
@ -390,7 +390,7 @@ public:
private:
Resolver::Resolver *resolver;
Resolver::TypeCheckContext *tyctx;
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
Mangler mangler;
// state

View File

@ -120,7 +120,7 @@ CompileExpr::visit (HIR::ReturnExpr &expr)
TyTy::BaseType *expected = fncontext.retty;
location_t lvalue_locus
= ctx->get_mappings ()->lookup_location (expected->get_ref ());
= ctx->get_mappings ().lookup_location (expected->get_ref ());
TyTy::BaseType *actual = nullptr;
bool ok = ctx->get_tyctx ()->lookup_type (
@ -456,7 +456,7 @@ CompileExpr::visit (HIR::StructExprStructFields &struct_expr)
// process arguments
auto &argument = struct_expr.get_fields ().at (0);
auto lvalue_locus
= ctx->get_mappings ()->lookup_location (expected->get_ty_ref ());
= ctx->get_mappings ().lookup_location (expected->get_ty_ref ());
auto rvalue_locus = argument->get_locus ();
auto rvalue = CompileStructExprField::Compile (argument.get (), ctx);
@ -488,7 +488,7 @@ CompileExpr::visit (HIR::StructExprStructFields &struct_expr)
// process arguments
auto &argument = struct_expr.get_fields ().at (i);
auto lvalue_locus
= ctx->get_mappings ()->lookup_location (expected->get_ty_ref ());
= ctx->get_mappings ().lookup_location (expected->get_ty_ref ());
auto rvalue_locus = argument->get_locus ();
auto rvalue = CompileStructExprField::Compile (argument.get (), ctx);
@ -735,7 +735,7 @@ CompileExpr::visit (HIR::BreakExpr &expr)
}
HirId ref = UNKNOWN_HIRID;
if (!ctx->get_mappings ()->lookup_node_to_hir (resolved_node_id, &ref))
if (!ctx->get_mappings ().lookup_node_to_hir (resolved_node_id, &ref))
{
rust_fatal_error (expr.get_locus (), "reverse lookup label failure");
return;
@ -779,7 +779,7 @@ CompileExpr::visit (HIR::ContinueExpr &expr)
}
HirId ref = UNKNOWN_HIRID;
if (!ctx->get_mappings ()->lookup_node_to_hir (resolved_node_id, &ref))
if (!ctx->get_mappings ().lookup_node_to_hir (resolved_node_id, &ref))
{
rust_fatal_error (expr.get_locus (), "reverse lookup label failure");
return;
@ -1153,7 +1153,7 @@ CompileExpr::visit (HIR::CallExpr &expr)
// coerce it if required
location_t lvalue_locus
= ctx->get_mappings ()->lookup_location (expected->get_ty_ref ());
= ctx->get_mappings ().lookup_location (expected->get_ty_ref ());
location_t rvalue_locus = argument->get_locus ();
rvalue
= coercion_site (argument->get_mappings ().get_hirid (), rvalue,
@ -1257,7 +1257,7 @@ CompileExpr::visit (HIR::CallExpr &expr)
// coerce it if required
location_t lvalue_locus
= ctx->get_mappings ()->lookup_location (expected->get_ty_ref ());
= ctx->get_mappings ().lookup_location (expected->get_ty_ref ());
location_t rvalue_locus = argument->get_locus ();
rvalue = coercion_site (argument->get_mappings ().get_hirid (), rvalue,
actual, expected, lvalue_locus, rvalue_locus);
@ -1346,7 +1346,7 @@ CompileExpr::visit (HIR::MethodCallExpr &expr)
// coerce it if required
location_t lvalue_locus
= ctx->get_mappings ()->lookup_location (expected->get_ty_ref ());
= ctx->get_mappings ().lookup_location (expected->get_ty_ref ());
location_t rvalue_locus = argument->get_locus ();
rvalue = coercion_site (argument->get_mappings ().get_hirid (), rvalue,
actual, expected, lvalue_locus, rvalue_locus);
@ -2175,7 +2175,7 @@ CompileExpr::visit (HIR::ClosureExpr &expr)
{
// lookup the HirId
HirId ref = UNKNOWN_HIRID;
bool ok = ctx->get_mappings ()->lookup_node_to_hir (capture, &ref);
bool ok = ctx->get_mappings ().lookup_node_to_hir (capture, &ref);
rust_assert (ok);
// lookup the var decl
@ -2209,7 +2209,7 @@ CompileExpr::generate_closure_function (HIR::ClosureExpr &expr,
const Resolver::CanonicalPath &parent_canonical_path
= closure_tyty.get_ident ().path;
NodeId node_id;
bool ok = ctx->get_mappings ()->lookup_hir_to_node (
bool ok = ctx->get_mappings ().lookup_hir_to_node (
expr.get_mappings ().get_hirid (), &node_id);
rust_assert (ok);
Resolver::CanonicalPath path = parent_canonical_path.append (
@ -2245,7 +2245,7 @@ CompileExpr::generate_closure_function (HIR::ClosureExpr &expr,
{
// lookup the HirId
HirId ref = UNKNOWN_HIRID;
bool ok = ctx->get_mappings ()->lookup_node_to_hir (capture, &ref);
bool ok = ctx->get_mappings ().lookup_node_to_hir (capture, &ref);
rust_assert (ok);
// get the assessor

View File

@ -135,7 +135,7 @@ public:
{
// then we need to get the canonical path of it and mangle it
const Resolver::CanonicalPath *canonical_path = nullptr;
bool ok = ctx->get_mappings ()->lookup_canonical_path (
bool ok = ctx->get_mappings ().lookup_canonical_path (
function.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);

View File

@ -28,7 +28,7 @@ CompileTraitItem::visit (HIR::TraitItemConst &constant)
TyTy::BaseType *resolved_type = concrete;
const Resolver::CanonicalPath *canonical_path = nullptr;
bool ok = ctx->get_mappings ()->lookup_canonical_path (
bool ok = ctx->get_mappings ().lookup_canonical_path (
constant.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);
@ -78,7 +78,7 @@ CompileTraitItem::visit (HIR::TraitItemFunc &func)
}
const Resolver::CanonicalPath *canonical_path = nullptr;
bool ok = ctx->get_mappings ()->lookup_canonical_path (
bool ok = ctx->get_mappings ().lookup_canonical_path (
func.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);

View File

@ -269,7 +269,7 @@ Intrinsics::compile (TyTy::FnType *fntype)
if (it != generic_intrinsics.end ())
return it->second (ctx, fntype);
location_t locus = ctx->get_mappings ()->lookup_location (fntype->get_ref ());
location_t locus = ctx->get_mappings ().lookup_location (fntype->get_ref ());
rust_error_at (locus, ErrorCode::E0093,
"unrecognized intrinsic function: %<%s%>",
fntype->get_identifier ().c_str ());

View File

@ -43,7 +43,7 @@ CompileItem::visit (HIR::StaticItem &var)
tree type = TyTyResolveCompile::compile (ctx, resolved_type);
const Resolver::CanonicalPath *canonical_path = nullptr;
ok = ctx->get_mappings ()->lookup_canonical_path (
ok = ctx->get_mappings ().lookup_canonical_path (
var.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);
@ -103,8 +103,8 @@ CompileItem::visit (HIR::ConstantItem &constant)
else
{
const Resolver::CanonicalPath *canonical_path_ptr = nullptr;
ok = ctx->get_mappings ()->lookup_canonical_path (mappings.get_nodeid (),
&canonical_path_ptr);
ok = ctx->get_mappings ().lookup_canonical_path (mappings.get_nodeid (),
&canonical_path_ptr);
rust_assert (ok);
canonical_path = *canonical_path_ptr;
}
@ -155,7 +155,7 @@ CompileItem::visit (HIR::Function &function)
HirId parent_impl_block = UNKNOWN_HIRID;
HirId id = function.get_mappings ().get_hirid ();
HIR::ImplItem *impl_item
= ctx->get_mappings ()->lookup_hir_implitem (id, &parent_impl_block);
= ctx->get_mappings ().lookup_hir_implitem (id, &parent_impl_block);
if (impl_item != nullptr)
{
Resolver::AssociatedImplTrait *impl = nullptr;
@ -182,7 +182,7 @@ CompileItem::visit (HIR::Function &function)
else
{
const Resolver::CanonicalPath *path = nullptr;
bool ok = ctx->get_mappings ()->lookup_canonical_path (
bool ok = ctx->get_mappings ().lookup_canonical_path (
function.get_mappings ().get_nodeid (), &path);
rust_assert (ok);

View File

@ -126,7 +126,7 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment,
}
HirId ref;
if (!ctx->get_mappings ()->lookup_node_to_hir (ref_node_id, &ref))
if (!ctx->get_mappings ().lookup_node_to_hir (ref_node_id, &ref))
{
rust_error_at (expr_locus, "reverse call path lookup failure");
return error_mark_node;
@ -199,10 +199,10 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup,
const Analysis::NodeMapping &mappings,
location_t expr_locus, bool is_qualified_path)
{
HIR::Item *resolved_item = ctx->get_mappings ()->lookup_hir_item (ref);
HIR::Item *resolved_item = ctx->get_mappings ().lookup_hir_item (ref);
HirId parent_block;
HIR::ExternalItem *resolved_extern_item
= ctx->get_mappings ()->lookup_hir_extern_item (ref, &parent_block);
= ctx->get_mappings ().lookup_hir_extern_item (ref, &parent_block);
bool is_hir_item = resolved_item != nullptr;
bool is_hir_extern_item = resolved_extern_item != nullptr;
bool is_fn = lookup->get_kind () == TyTy::TypeKind::FNDEF;
@ -242,7 +242,7 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup,
HirId parent_impl_id = UNKNOWN_HIRID;
HIR::ImplItem *resolved_item
= ctx->get_mappings ()->lookup_hir_implitem (ref, &parent_impl_id);
= ctx->get_mappings ().lookup_hir_implitem (ref, &parent_impl_id);
bool is_impl_item = resolved_item != nullptr;
if (is_impl_item)
{
@ -257,8 +257,8 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup,
{
// it might be resolved to a trait item
HIR::TraitItem *trait_item
= ctx->get_mappings ()->lookup_hir_trait_item (ref);
HIR::Trait *trait = ctx->get_mappings ()->lookup_trait_item_mapping (
= ctx->get_mappings ().lookup_hir_trait_item (ref);
HIR::Trait *trait = ctx->get_mappings ().lookup_trait_item_mapping (
trait_item->get_mappings ().get_hirid ());
Resolver::TraitReference *trait_ref

View File

@ -147,7 +147,7 @@ TyTyResolveCompile::visit (const TyTy::PlaceholderType &type)
void
TyTyResolveCompile::visit (const TyTy::ClosureType &type)
{
auto mappings = ctx->get_mappings ();
auto &mappings = ctx->get_mappings ();
std::vector<Backend::typed_identifier> fields;
@ -156,7 +156,7 @@ TyTyResolveCompile::visit (const TyTy::ClosureType &type)
{
// lookup the HirId
HirId ref = UNKNOWN_HIRID;
bool ok = mappings->lookup_node_to_hir (capture, &ref);
bool ok = mappings.lookup_node_to_hir (capture, &ref);
rust_assert (ok);
// lookup the var decl type
@ -201,7 +201,7 @@ TyTyResolveCompile::visit (const TyTy::FnType &type)
{
auto ret = TyTyResolveCompile::compile (ctx, hir_type, trait_object_mode);
location_t return_type_locus
= ctx->get_mappings ()->lookup_location (hir_type->get_ref ());
= ctx->get_mappings ().lookup_location (hir_type->get_ref ());
results.push_back (
Backend::typed_identifier ("_", ret, return_type_locus));
}
@ -214,7 +214,7 @@ TyTyResolveCompile::visit (const TyTy::FnType &type)
auto compiled_param = Backend::typed_identifier (
param_pair.first->as_string (), compiled_param_type,
ctx->get_mappings ()->lookup_location (param_tyty->get_ref ()));
ctx->get_mappings ().lookup_location (param_tyty->get_ref ()));
parameters.push_back (compiled_param);
}
@ -263,7 +263,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type)
= TyTyResolveCompile::compile (ctx, field->get_field_type ());
Backend::typed_identifier f (field->get_name (), compiled_field_ty,
ctx->get_mappings ()->lookup_location (
ctx->get_mappings ().lookup_location (
type.get_ty_ref ()));
fields.push_back (std::move (f));
}
@ -307,7 +307,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type)
tree enumeral_type
= TyTyResolveCompile::get_implicit_enumeral_node_type (ctx);
Backend::typed_identifier f (RUST_ENUM_DISR_FIELD_NAME, enumeral_type,
ctx->get_mappings ()->lookup_location (
ctx->get_mappings ().lookup_location (
variant->get_id ()));
fields.push_back (std::move (f));
@ -326,7 +326,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type)
Backend::typed_identifier f (
field_name, compiled_field_ty,
ctx->get_mappings ()->lookup_location (type.get_ty_ref ()));
ctx->get_mappings ().lookup_location (type.get_ty_ref ()));
fields.push_back (std::move (f));
}
@ -353,7 +353,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type)
std::string implicit_variant_name = variant->get_identifier ();
Backend::typed_identifier f (implicit_variant_name, variant_record,
ctx->get_mappings ()->lookup_location (
ctx->get_mappings ().lookup_location (
type.get_ty_ref ()));
enum_fields.push_back (std::move (f));
}
@ -411,7 +411,7 @@ TyTyResolveCompile::visit (const TyTy::TupleType &type)
// approach makes it simpler to use a C-only debugger, or
// GDB's C mode, when debugging Rust.
Backend::typed_identifier f ("__" + std::to_string (i), compiled_field_ty,
ctx->get_mappings ()->lookup_location (
ctx->get_mappings ().lookup_location (
type.get_ty_ref ()));
fields.push_back (std::move (f));
}
@ -714,14 +714,14 @@ TyTyResolveCompile::create_dyn_obj_record (const TyTy::DynamicObjectType &type)
tree uintptr_ty = build_pointer_type (uint);
Backend::typed_identifier f ("pointer", uintptr_ty,
ctx->get_mappings ()->lookup_location (
ctx->get_mappings ().lookup_location (
type.get_ty_ref ()));
fields.push_back (std::move (f));
tree vtable_size = build_int_cst (size_type_node, items.size ());
tree vtable_type = Backend::array_type (uintptr_ty, vtable_size);
Backend::typed_identifier vtf ("vtable", vtable_type,
ctx->get_mappings ()->lookup_location (
ctx->get_mappings ().lookup_location (
type.get_ty_ref ()));
fields.push_back (std::move (vtf));

View File

@ -189,7 +189,7 @@ HIRCompileBase::coerce_to_dyn_object (tree compiled_ref,
location_t locus)
{
// DST's get wrapped in a pseudo reference that doesnt exist...
const TyTy::ReferenceType r (ctx->get_mappings ()->get_next_hir_id (),
const TyTy::ReferenceType r (ctx->get_mappings ().get_next_hir_id (),
TyTy::TyVar (ty->get_ref ()), Mutability::Imm);
tree dynamic_object = TyTyResolveCompile::compile (ctx, &r);

View File

@ -369,13 +369,13 @@ static std::string
v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty,
const Resolver::CanonicalPath &cpath)
{
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
V0Path v0path = {};
cpath.iterate_segs ([&] (const Resolver::CanonicalPath &seg) {
HirId hir_id;
bool ok = mappings->lookup_node_to_hir (seg.get_node_id (), &hir_id);
bool ok = mappings.lookup_node_to_hir (seg.get_node_id (), &hir_id);
if (!ok)
{
// FIXME: generic arg in canonical path? (e.g. <i32> in crate::S<i32>)
@ -384,10 +384,10 @@ v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty,
HirId parent_impl_id = UNKNOWN_HIRID;
HIR::ImplItem *impl_item
= mappings->lookup_hir_implitem (hir_id, &parent_impl_id);
HIR::TraitItem *trait_item = mappings->lookup_hir_trait_item (hir_id);
HIR::Item *item = mappings->lookup_hir_item (hir_id);
HIR::Expr *expr = mappings->lookup_hir_expr (hir_id);
= mappings.lookup_hir_implitem (hir_id, &parent_impl_id);
HIR::TraitItem *trait_item = mappings.lookup_hir_trait_item (hir_id);
HIR::Item *item = mappings.lookup_hir_item (hir_id);
HIR::Expr *expr = mappings.lookup_hir_expr (hir_id);
if (impl_item != nullptr)
{
@ -490,7 +490,7 @@ v0_mangle_item (Rust::Compile::Context *ctx, const TyTy::BaseType *ty,
rust_debug ("Start mangling: %s", path.get ().c_str ());
// TODO: get Instanciating CrateNum
// auto mappings = Analysis::Mappings::get ();
// auto &mappings = Analysis::Mappings::get ();
// std::string crate_name;
// bool ok = mappings->get_crate_name (path.get_crate_num (), crate_name);
// rust_assert (ok);

View File

@ -64,10 +64,9 @@ BorrowChecker::go (HIR::Crate &crate)
if (enable_dump_bir)
{
mkdir_wrapped ("bir_dump");
auto mappings = Analysis::Mappings::get ();
bool ok
= mappings->get_crate_name (crate.get_mappings ().get_crate_num (),
crate_name);
auto &mappings = Analysis::Mappings::get ();
bool ok = mappings.get_crate_name (crate.get_mappings ().get_crate_num (),
crate_name);
rust_assert (ok);
mkdir_wrapped ("nll_facts_gccrs");
@ -183,4 +182,4 @@ BorrowChecker::go (HIR::Crate &crate)
}
} // namespace HIR
} // namespace Rust
} // namespace Rust

View File

@ -35,13 +35,13 @@ void
Resolver::resolve (HIR::Crate &crate)
{
PrivacyContext ctx;
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
auto resolver = Rust::Resolver::Resolver::get ();
auto ty_ctx = ::Rust::Resolver::TypeCheckContext::get ();
VisibilityResolver (*mappings, *resolver).go (crate);
PubRestrictedVisitor (*mappings).go (crate);
PrivacyReporter (*mappings, *resolver, *ty_ctx).go (crate);
VisibilityResolver (mappings, *resolver).go (crate);
PubRestrictedVisitor (mappings).go (crate);
PrivacyReporter (mappings, *resolver, *ty_ctx).go (crate);
auto visitor = ReachabilityVisitor (ctx, *ty_ctx);

View File

@ -27,7 +27,7 @@ namespace HIR {
ConstChecker::ConstChecker ()
: resolver (*Resolver::Resolver::get ()),
mappings (*Analysis::Mappings::get ())
mappings (Analysis::Mappings::get ())
{}
void

View File

@ -29,7 +29,7 @@ namespace HIR {
UnsafeChecker::UnsafeChecker ()
: context (*Resolver::TypeCheckContext::get ()),
resolver (*Resolver::Resolver::get ()),
mappings (*Analysis::Mappings::get ())
mappings (Analysis::Mappings::get ())
{}
void

View File

@ -36,7 +36,7 @@ public:
protected:
MarkLiveBase () : mappings (Analysis::Mappings::get ()) {}
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
};
} // namespace Analysis

View File

@ -85,7 +85,7 @@ MarkLive::go (HIR::Crate &)
HirId hirId = worklist.back ();
worklist.pop_back ();
scannedSymbols.emplace (hirId);
HIR::Item *item = mappings->lookup_hir_item (hirId);
HIR::Item *item = mappings.lookup_hir_item (hirId);
liveSymbols.emplace (hirId);
if (item != nullptr)
{
@ -95,7 +95,7 @@ MarkLive::go (HIR::Crate &)
{ // the item maybe inside a trait impl
HirId parent_impl_id = UNKNOWN_HIRID;
HIR::ImplItem *implItem
= mappings->lookup_hir_implitem (hirId, &parent_impl_id);
= mappings.lookup_hir_implitem (hirId, &parent_impl_id);
if (implItem != nullptr)
implItem->accept_vis (*this);
}
@ -119,11 +119,11 @@ MarkLive::visit (HIR::PathInExpression &expr)
// node back to HIR
HirId ref;
bool ok = mappings->lookup_node_to_hir (ref_node_id, &ref);
bool ok = mappings.lookup_node_to_hir (ref_node_id, &ref);
rust_assert (ok);
// it must resolve to some kind of HIR::Item or HIR::InheritImplItem
HIR::Item *resolved_item = mappings->lookup_hir_item (ref);
HIR::Item *resolved_item = mappings.lookup_hir_item (ref);
if (resolved_item != nullptr)
{
mark_hir_id (resolved_item->get_mappings ().get_hirid ());
@ -132,7 +132,7 @@ MarkLive::visit (HIR::PathInExpression &expr)
{
HirId parent_impl_id = UNKNOWN_HIRID;
HIR::ImplItem *resolved_item
= mappings->lookup_hir_implitem (ref, &parent_impl_id);
= mappings.lookup_hir_implitem (ref, &parent_impl_id);
if (resolved_item != nullptr)
{
mark_hir_id (resolved_item->get_impl_mappings ().get_hirid ());
@ -155,7 +155,7 @@ MarkLive::visit (HIR::MethodCallExpr &expr)
// node back to HIR
HirId ref;
bool ok = mappings->lookup_node_to_hir (ref_node_id, &ref);
bool ok = mappings.lookup_node_to_hir (ref_node_id, &ref);
rust_assert (ok);
mark_hir_id (ref);
}
@ -180,7 +180,7 @@ MarkLive::visit_path_segment (HIR::PathExprSegment seg)
return false;
}
HirId ref;
bool ok = mappings->lookup_node_to_hir (ref_node_id, &ref);
bool ok = mappings.lookup_node_to_hir (ref_node_id, &ref);
rust_assert (ok);
mark_hir_id (ref);
return true;
@ -254,7 +254,7 @@ MarkLive::visit (HIR::TypeAlias &alias)
resolver->lookup_resolved_type (
alias.get_type_aliased ()->get_mappings ().get_nodeid (), &ast_node_id);
HirId hir_id;
bool ok = mappings->lookup_node_to_hir (ast_node_id, &hir_id);
bool ok = mappings.lookup_node_to_hir (ast_node_id, &hir_id);
rust_assert (ok);
mark_hir_id (hir_id);
}

View File

@ -276,7 +276,7 @@ private:
std::vector<HirId> worklist;
std::set<HirId> liveSymbols;
std::set<HirId> scannedSymbols;
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
Resolver::Resolver *resolver;
Resolver::TypeCheckContext *tyctx;
MarkLive (std::vector<HirId> worklist)

View File

@ -53,10 +53,9 @@ public:
HirId hirId = function.get_mappings ().get_hirid ();
if (should_warn (hirId) && !function.get_visibility ().is_public ())
{
if (mappings->is_impl_item (hirId))
if (mappings.is_impl_item (hirId))
{
HIR::ImplBlock *implBlock
= mappings->lookup_associated_impl (hirId);
HIR::ImplBlock *implBlock = mappings.lookup_associated_impl (hirId);
if (!implBlock->has_trait_ref ())
{
rust_warning_at (
@ -136,7 +135,7 @@ public:
private:
std::set<HirId> live_symbols;
Resolver::Resolver *resolver;
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
ScanDeadcode (std::set<HirId> &live_symbols)
: live_symbols (live_symbols), resolver (Resolver::Resolver::get ()),

View File

@ -273,7 +273,7 @@ MacroExpander::expand_invoc (AST::MacroInvocation &invoc, bool has_semicolon)
// lookup the rules
AST::MacroRulesDefinition *rules_def = nullptr;
bool ok = mappings->lookup_macro_invocation (invoc, &rules_def);
bool ok = mappings.lookup_macro_invocation (invoc, &rules_def);
// If there's no rule associated with the invocation, we can simply return
// early. The early name resolver will have already emitted an error.

View File

@ -411,7 +411,7 @@ struct MacroExpander
AST::Fragment expand_derive_proc_macro (T &item, AST::SimplePath &path)
{
tl::optional<CustomDeriveProcMacro &> macro
= mappings->lookup_derive_proc_macro_invocation (path);
= mappings.lookup_derive_proc_macro_invocation (path);
if (!macro.has_value ())
{
rust_error_at (path.get_locus (), "macro not found");
@ -434,7 +434,7 @@ struct MacroExpander
AST::MacroInvocation &invocation)
{
tl::optional<BangProcMacro &> macro
= mappings->lookup_bang_proc_macro_invocation (invocation);
= mappings.lookup_bang_proc_macro_invocation (invocation);
if (!macro.has_value ())
{
rust_error_at (invocation.get_locus (), "macro not found");
@ -456,7 +456,7 @@ struct MacroExpander
AST::Fragment expand_attribute_proc_macro (T &item, AST::SimplePath &path)
{
tl::optional<AttributeProcMacro &> macro
= mappings->lookup_attribute_proc_macro_invocation (path);
= mappings.lookup_attribute_proc_macro_invocation (path);
if (!macro.has_value ())
{
rust_error_at (path.get_locus (), "macro not found");
@ -512,7 +512,7 @@ private:
public:
Resolver::Resolver *resolver;
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
};
} // namespace Rust

View File

@ -29,21 +29,19 @@
namespace Rust {
BangProcMacro::BangProcMacro (ProcMacro::Bang macro)
: name (macro.name),
node_id (Analysis::Mappings::get ()->get_next_node_id ()),
: name (macro.name), node_id (Analysis::Mappings::get ().get_next_node_id ()),
macro (macro.macro)
{}
AttributeProcMacro::AttributeProcMacro (ProcMacro::Attribute macro)
: name (macro.name),
node_id (Analysis::Mappings::get ()->get_next_node_id ()),
: name (macro.name), node_id (Analysis::Mappings::get ().get_next_node_id ()),
macro (macro.macro)
{}
CustomDeriveProcMacro::CustomDeriveProcMacro (ProcMacro::CustomDerive macro)
: trait_name (macro.trait_name),
attributes (macro.attributes, macro.attributes + macro.attr_size),
node_id (Analysis::Mappings::get ()->get_next_node_id ()),
node_id (Analysis::Mappings::get ().get_next_node_id ()),
macro (macro.macro)
{}

View File

@ -537,11 +537,11 @@ ASTLoweringBase::lower_lifetime (AST::Lifetime &lifetime,
lifetime_type = AST::Lifetime::STATIC;
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, lifetime.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
mappings->insert_node_to_hir (mapping.get_nodeid (), mapping.get_hirid ());
mappings.insert_node_to_hir (mapping.get_nodeid (), mapping.get_hirid ());
return HIR::Lifetime (mapping, lifetime_type, lifetime.get_lifetime_name (),
lifetime.get_locus ());
@ -552,11 +552,11 @@ ASTLoweringBase::lower_loop_label (AST::LoopLabel &loop_label)
{
HIR::Lifetime life = lower_lifetime (loop_label.get_lifetime ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, loop_label.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
mappings->insert_node_to_hir (mapping.get_nodeid (), mapping.get_hirid ());
mappings.insert_node_to_hir (mapping.get_nodeid (), mapping.get_hirid ());
return HIR::LoopLabel (mapping, std::move (life), loop_label.get_locus ());
}
@ -578,9 +578,9 @@ ASTLoweringBase::lower_generic_params (
HIR::PathExprSegment
ASTLoweringBase::lower_path_expr_seg (AST::PathExprSegment &s)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, s.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
return HIR::PathExprSegment (
@ -651,10 +651,10 @@ ASTLoweringBase::lower_self (AST::Param &param)
rust_assert (param.is_self ());
auto self = static_cast<AST::SelfParam &> (param);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, self.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
if (self.has_type ())
{
@ -792,8 +792,8 @@ ASTLoweringBase::handle_lang_item_attribute (const ItemWrapper &item,
auto lang_item_type = LangItem::Parse (lang_item_type_str);
if (lang_item_type)
mappings->insert_lang_item (*lang_item_type,
item.get_mappings ().get_defid ());
mappings.insert_lang_item (*lang_item_type,
item.get_mappings ().get_defid ());
else
rust_error_at (attr.get_locus (), "unknown lang item");
}
@ -940,10 +940,10 @@ ASTLoweringBase::lower_extern_block (AST::ExternBlock &extern_block)
{
HIR::Visibility vis = translate_visibility (extern_block.get_visibility ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, extern_block.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
std::vector<std::unique_ptr<HIR::ExternalItem>> extern_items;
for (auto &item : extern_block.get_extern_items ())
@ -972,7 +972,7 @@ ASTLoweringBase::lower_extern_block (AST::ExternBlock &extern_block)
extern_block.get_outer_attrs (),
extern_block.get_locus ());
mappings->insert_hir_extern_block (hir_extern_block);
mappings.insert_hir_extern_block (hir_extern_block);
return hir_extern_block;
}
@ -987,9 +987,9 @@ ASTLoweringBase::lower_macro_definition (AST::MacroRulesDefinition &def)
if (is_export)
{
mappings->insert_exported_macro (def);
mappings->insert_ast_item (&def);
mappings->insert_location (def.get_node_id (), def.get_locus ());
mappings.insert_exported_macro (def);
mappings.insert_ast_item (&def);
mappings.insert_location (def.get_node_id (), def.get_locus ());
}
}

View File

@ -261,7 +261,7 @@ protected:
attr_mappings (Analysis::BuiltinAttributeMappings::get ())
{}
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
Analysis::BuiltinAttributeMappings *attr_mappings;
HIR::Lifetime lower_lifetime (AST::Lifetime &lifetime,

View File

@ -37,7 +37,7 @@ public:
expr.accept_vis (resolver);
if (resolver.translated != nullptr)
{
resolver.mappings->insert_hir_expr (resolver.translated);
resolver.mappings.insert_hir_expr (resolver.translated);
}
*terminated = resolver.terminated;
@ -51,9 +51,9 @@ public:
HIR::BlockExpr *block
= ASTLoweringBlock::translate (expr.get_block_expr (), terminated);
auto crate_num = resolver.mappings->get_current_crate ();
auto crate_num = resolver.mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
resolver.mappings->get_next_hir_id (
resolver.mappings.get_next_hir_id (
crate_num),
UNKNOWN_LOCAL_DEFID);
@ -62,7 +62,7 @@ public:
std::unique_ptr<HIR::BlockExpr> (block),
expr.get_outer_attrs (), expr.get_locus ());
resolver.mappings->insert_hir_expr (translated);
resolver.mappings.insert_hir_expr (translated);
return translated;
}
@ -89,7 +89,7 @@ public:
expr.accept_vis (resolver);
if (resolver.translated != nullptr)
{
resolver.mappings->insert_hir_expr (resolver.translated);
resolver.mappings.insert_hir_expr (resolver.translated);
}
*terminated = resolver.terminated;
return resolver.translated;
@ -121,7 +121,7 @@ public:
expr.accept_vis (resolver);
if (resolver.translated != nullptr)
{
resolver.mappings->insert_hir_expr (resolver.translated);
resolver.mappings.insert_hir_expr (resolver.translated);
}
return resolver.translated;
}
@ -150,7 +150,7 @@ public:
expr.accept_vis (resolver);
if (resolver.translated != nullptr)
{
resolver.mappings->insert_hir_expr (resolver.translated);
resolver.mappings.insert_hir_expr (resolver.translated);
}
*terminated = resolver.terminated;
@ -196,9 +196,9 @@ public:
HIR::LoopLabel loop_label = lower_loop_label (expr.get_loop_label ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated

View File

@ -45,19 +45,19 @@ public:
auto hirid = resolver.translated->get_mappings ().get_hirid ();
auto defid = resolver.translated->get_mappings ().get_defid ();
resolver.mappings->insert_defid_mapping (defid, resolver.translated);
resolver.mappings->insert_location (hirid,
resolver.translated->get_locus ());
resolver.mappings.insert_defid_mapping (defid, resolver.translated);
resolver.mappings.insert_location (hirid,
resolver.translated->get_locus ());
return resolver.translated;
}
void visit (AST::EnumItem &item) override
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, item.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
if (item.has_visibility ())
rust_error_at (item.get_locus (),
@ -69,10 +69,10 @@ public:
void visit (AST::EnumItemTuple &item) override
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, item.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
if (item.has_visibility ())
rust_error_at (item.get_locus (),
@ -85,11 +85,10 @@ public:
HIR::Visibility vis = translate_visibility (field.get_visibility ());
HIR::Type *type = ASTLoweringType::translate (field.get_field_type ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping field_mapping (
crate_num, field.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
crate_num, field.get_node_id (), mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
HIR::TupleField translated_field (field_mapping,
std::unique_ptr<HIR::Type> (type),
@ -106,10 +105,10 @@ public:
void visit (AST::EnumItemStruct &item) override
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, item.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
if (item.has_visibility ())
rust_error_at (item.get_locus (),
@ -122,11 +121,10 @@ public:
HIR::Visibility vis = translate_visibility (field.get_visibility ());
HIR::Type *type = ASTLoweringType::translate (field.get_field_type ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping field_mapping (
crate_num, field.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
crate_num, field.get_node_id (), mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
HIR::StructField translated_field (field_mapping,
field.get_field_name (),
@ -148,10 +146,10 @@ public:
void visit (AST::EnumItemDiscriminant &item) override
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, item.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
if (item.has_visibility ())
rust_error_at (item.get_locus (),

View File

@ -45,8 +45,8 @@ ASTLoweringExpr::translate (AST::Expr &expr, bool *terminated)
return nullptr;
}
resolver.mappings->insert_hir_expr (resolver.translated);
resolver.mappings->insert_location (
resolver.mappings.insert_hir_expr (resolver.translated);
resolver.mappings.insert_location (
resolver.translated->get_mappings ().get_hirid (), expr.get_locus ());
if (terminated != nullptr)
@ -61,9 +61,9 @@ ASTLoweringExpr::visit (AST::TupleIndexExpr &expr)
HIR::Expr *tuple_expr
= ASTLoweringExpr::translate (expr.get_tuple_expr (), &terminated);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -82,9 +82,9 @@ ASTLoweringExpr::visit (AST::TupleExpr &expr)
tuple_elements.push_back (std::unique_ptr<HIR::Expr> (t));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -150,9 +150,9 @@ ASTLoweringExpr::visit (AST::ReturnExpr &expr)
? ASTLoweringExpr::translate (expr.get_returned_expr ())
: nullptr;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::ReturnExpr (mapping, expr.get_locus (),
@ -172,10 +172,10 @@ ASTLoweringExpr::visit (AST::CallExpr &expr)
params.push_back (std::unique_ptr<HIR::Expr> (trans));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (
crate_num, UNKNOWN_NODEID /* this can map back to the AST*/,
mappings->get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID);
mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID);
translated = new HIR::CallExpr (mapping, std::unique_ptr<HIR::Expr> (func),
std::move (params), expr.get_outer_attrs (),
@ -198,9 +198,9 @@ ASTLoweringExpr::visit (AST::MethodCallExpr &expr)
params.push_back (std::unique_ptr<HIR::Expr> (trans));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -215,9 +215,9 @@ ASTLoweringExpr::visit (AST::AssignmentExpr &expr)
HIR::Expr *lhs = ASTLoweringExpr::translate (expr.get_left_expr ());
HIR::Expr *rhs = ASTLoweringExpr::translate (expr.get_right_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -229,9 +229,9 @@ ASTLoweringExpr::visit (AST::AssignmentExpr &expr)
void
ASTLoweringExpr::visit (AST::IdentifierExpr &expr)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping1 (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
Analysis::NodeMapping mapping2 (mapping1);
@ -249,9 +249,9 @@ ASTLoweringExpr::visit (AST::ArrayExpr &expr)
rust_assert (translated_array_elems != nullptr);
HIR::ArrayElems *elems = translated_array_elems;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -267,9 +267,9 @@ ASTLoweringExpr::visit (AST::ArrayIndexExpr &expr)
HIR::Expr *array_index_expr
= ASTLoweringExpr::translate (expr.get_index_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -288,10 +288,10 @@ ASTLoweringExpr::visit (AST::ArrayElemsValues &elems)
elements.push_back (std::unique_ptr<HIR::Expr> (translated_elem));
}
auto crate_num = mappings->get_current_crate ();
Analysis::NodeMapping mapping (mappings->get_current_crate (),
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (mappings.get_current_crate (),
elems.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated_array_elems
@ -304,10 +304,10 @@ ASTLoweringExpr::visit (AST::ArrayElemsCopied &elems)
HIR::Expr *element = ASTLoweringExpr::translate (elems.get_elem_to_copy ());
HIR::Expr *num_copies = ASTLoweringExpr::translate (elems.get_num_copies ());
auto crate_num = mappings->get_current_crate ();
Analysis::NodeMapping mapping (mappings->get_current_crate (),
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (mappings.get_current_crate (),
elems.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated_array_elems
@ -318,9 +318,9 @@ ASTLoweringExpr::visit (AST::ArrayElemsCopied &elems)
void
ASTLoweringExpr::visit (AST::LiteralExpr &expr)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
HIR::Literal l = lower_literal (expr.get_literal ());
@ -336,9 +336,9 @@ ASTLoweringExpr::visit (AST::ArithmeticOrLogicalExpr &expr)
HIR::Expr *rhs = ASTLoweringExpr::translate (expr.get_right_expr ());
rust_assert (rhs != nullptr);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::ArithmeticOrLogicalExpr (
@ -354,9 +354,9 @@ ASTLoweringExpr::visit (AST::ComparisonExpr &expr)
HIR::Expr *rhs = ASTLoweringExpr::translate (expr.get_right_expr ());
rust_assert (rhs != nullptr);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -373,9 +373,9 @@ ASTLoweringExpr::visit (AST::LazyBooleanExpr &expr)
HIR::Expr *rhs = ASTLoweringExpr::translate (expr.get_right_expr ());
rust_assert (rhs != nullptr);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -390,9 +390,9 @@ ASTLoweringExpr::visit (AST::NegationExpr &expr)
HIR::Expr *negated_value
= ASTLoweringExpr::translate (expr.get_negated_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
= new HIR::NegationExpr (mapping,
@ -409,9 +409,9 @@ ASTLoweringExpr::visit (AST::TypeCastExpr &expr)
HIR::Type *type_to_cast_to
= lower_type_no_bounds (expr.get_type_to_cast_to ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -464,9 +464,9 @@ ASTLoweringExpr::visit (AST::CompoundAssignmentExpr &expr)
HIR::Expr *asignee_expr = ASTLoweringExpr::translate (expr.get_left_expr ());
HIR::Expr *value = ASTLoweringExpr::translate (expr.get_right_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::CompoundAssignmentExpr (
@ -482,9 +482,9 @@ ASTLoweringExpr::visit (AST::StructExprStruct &struct_expr)
HIR::PathInExpression copied_path (*path);
delete path;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, struct_expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::StructExprStruct (mapping, copied_path,
@ -519,9 +519,9 @@ ASTLoweringExpr::visit (AST::StructExprStructFields &struct_expr)
fields.push_back (std::unique_ptr<HIR::StructExprField> (translated));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, struct_expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -537,9 +537,9 @@ ASTLoweringExpr::visit (AST::GroupedExpr &expr)
HIR::Expr *paren_expr
= ASTLoweringExpr::translate (expr.get_expr_in_parens ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -553,9 +553,9 @@ ASTLoweringExpr::visit (AST::FieldAccessExpr &expr)
{
HIR::Expr *receiver = ASTLoweringExpr::translate (expr.get_receiver_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
= new HIR::FieldAccessExpr (mapping, std::unique_ptr<HIR::Expr> (receiver),
@ -591,9 +591,9 @@ ASTLoweringExpr::visit (AST::BreakExpr &expr)
? ASTLoweringExpr::translate (expr.get_break_expr ())
: nullptr;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -607,9 +607,9 @@ ASTLoweringExpr::visit (AST::ContinueExpr &expr)
{
HIR::Lifetime break_label = lower_lifetime (expr.get_label ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -623,9 +623,9 @@ ASTLoweringExpr::visit (AST::BorrowExpr &expr)
HIR::Expr *borrow_lvalue
= ASTLoweringExpr::translate (expr.get_borrowed_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
auto *borrow_expr
@ -636,9 +636,9 @@ ASTLoweringExpr::visit (AST::BorrowExpr &expr)
if (expr.get_is_double_borrow ())
{
NodeId artificial_double_borrow_id = mappings->get_next_node_id ();
NodeId artificial_double_borrow_id = mappings.get_next_node_id ();
Analysis::NodeMapping mapping (crate_num, artificial_double_borrow_id,
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
borrow_expr
@ -658,9 +658,9 @@ ASTLoweringExpr::visit (AST::DereferenceExpr &expr)
HIR::Expr *dref_lvalue
= ASTLoweringExpr::translate (expr.get_dereferenced_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -675,9 +675,9 @@ ASTLoweringExpr::visit (AST::ErrorPropagationExpr &expr)
HIR::Expr *propagating_expr
= ASTLoweringExpr::translate (expr.get_propagating_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::ErrorPropagationExpr (
mapping, std::unique_ptr<HIR::Expr> (propagating_expr),
@ -693,9 +693,9 @@ ASTLoweringExpr::visit (AST::MatchExpr &expr)
void
ASTLoweringExpr::visit (AST::RangeFromToExpr &expr)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
HIR::Expr *range_from = ASTLoweringExpr::translate (expr.get_from_expr ());
@ -711,9 +711,9 @@ ASTLoweringExpr::visit (AST::RangeFromToExpr &expr)
void
ASTLoweringExpr::visit (AST::RangeFromExpr &expr)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
HIR::Expr *range_from = ASTLoweringExpr::translate (expr.get_from_expr ());
@ -726,9 +726,9 @@ ASTLoweringExpr::visit (AST::RangeFromExpr &expr)
void
ASTLoweringExpr::visit (AST::RangeToExpr &expr)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
HIR::Expr *range_to = ASTLoweringExpr::translate (expr.get_to_expr ());
@ -741,9 +741,9 @@ ASTLoweringExpr::visit (AST::RangeToExpr &expr)
void
ASTLoweringExpr::visit (AST::RangeFullExpr &expr)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::RangeFullExpr (mapping, expr.get_locus ());
@ -752,9 +752,9 @@ ASTLoweringExpr::visit (AST::RangeFullExpr &expr)
void
ASTLoweringExpr::visit (AST::RangeFromToInclExpr &expr)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
HIR::Expr *range_from = ASTLoweringExpr::translate (expr.get_from_expr ());
@ -780,10 +780,10 @@ ASTLoweringExpr::visit (AST::ClosureExprInner &expr)
closure_params.push_back (std::move (p));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated
= new HIR::ClosureExpr (mapping, std::move (closure_params),
@ -807,10 +807,10 @@ ASTLoweringExpr::visit (AST::ClosureExprInnerTyped &expr)
closure_params.push_back (std::move (p));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated
= new HIR::ClosureExpr (mapping, std::move (closure_params),

View File

@ -39,9 +39,9 @@ public:
item->accept_vis (resolver);
rust_assert (resolver.translated != nullptr);
resolver.mappings->insert_hir_extern_item (resolver.translated,
parent_hirid);
resolver.mappings->insert_location (
resolver.mappings.insert_hir_extern_item (resolver.translated,
parent_hirid);
resolver.mappings.insert_location (
resolver.translated->get_mappings ().get_hirid (),
resolver.translated->get_locus ());
@ -53,10 +53,10 @@ public:
HIR::Visibility vis = translate_visibility (item.get_visibility ());
HIR::Type *static_type = ASTLoweringType::translate (item.get_type ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, item.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::ExternalStaticItem (
mapping, item.get_identifier (), std::unique_ptr<HIR::Type> (static_type),
@ -103,10 +103,10 @@ public:
HIR::Type *param_type = ASTLoweringType::translate (param.get_type ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, param.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (
crate_num));
function_params.push_back (
@ -114,10 +114,10 @@ public:
std::unique_ptr<HIR::Type> (param_type)));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, function.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::ExternalFunctionItem (
mapping, function.get_function_name (), std::move (generic_params),
@ -128,10 +128,10 @@ public:
void visit (AST::ExternalTypeItem &type) override
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, type.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
HIR::Visibility vis = translate_visibility (type.get_visibility ());

View File

@ -42,10 +42,10 @@ ASTLowerImplItem::translate (AST::AssociatedItem &item, HirId parent_impl_id)
auto locus = resolver.translated->get_locus ();
resolver.handle_outer_attributes (*resolver.item_cast);
resolver.mappings->insert_hir_implitem (parent_impl_id,
resolver.translated);
resolver.mappings->insert_location (id, locus);
resolver.mappings->insert_defid_mapping (defid, resolver.item_cast);
resolver.mappings.insert_hir_implitem (parent_impl_id,
resolver.translated);
resolver.mappings.insert_location (id, locus);
resolver.mappings.insert_defid_mapping (defid, resolver.item_cast);
}
return resolver.translated;
@ -65,10 +65,10 @@ ASTLowerImplItem::visit (AST::TypeAlias &alias)
HIR::Type *existing_type
= ASTLoweringType::translate (alias.get_type_aliased ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, alias.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
auto type_alias
= new HIR::TypeAlias (mapping, alias.get_new_type_name (),
@ -89,10 +89,10 @@ ASTLowerImplItem::visit (AST::ConstantItem &constant)
HIR::Type *type = ASTLoweringType::translate (constant.get_type (), true);
HIR::Expr *expr = ASTLoweringExpr::translate (constant.get_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, constant.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
auto translated_constant
= new HIR::ConstantItem (mapping, constant.get_identifier (), vis,
@ -152,9 +152,9 @@ ASTLowerImplItem::visit (AST::Function &function)
auto translated_type = std::unique_ptr<HIR::Type> (
ASTLoweringType::translate (param.get_type ()));
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, param.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
auto hir_param
@ -169,13 +169,13 @@ ASTLowerImplItem::visit (AST::Function &function)
ASTLoweringBlock::translate (*function.get_definition ().value (),
&terminated));
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, function.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
mappings->insert_location (function_body->get_mappings ().get_hirid (),
function.get_locus ());
mappings.insert_location (function_body->get_mappings ().get_hirid (),
function.get_locus ());
auto fn
= new HIR::Function (mapping, std::move (function_name),
@ -188,8 +188,8 @@ ASTLowerImplItem::visit (AST::Function &function)
if (!fn->get_self_param ().is_error ())
{
// insert mappings for self
mappings->insert_hir_self_param (&fn->get_self_param ());
mappings->insert_location (
mappings.insert_hir_self_param (&fn->get_self_param ());
mappings.insert_location (
fn->get_self_param ().get_mappings ().get_hirid (),
fn->get_self_param ().get_locus ());
}
@ -197,8 +197,8 @@ ASTLowerImplItem::visit (AST::Function &function)
// add the mappings for the function params at the end
for (auto &param : fn->get_function_params ())
{
mappings->insert_hir_param (&param);
mappings->insert_location (mapping.get_hirid (), param.get_locus ());
mappings.insert_hir_param (&param);
mappings.insert_location (mapping.get_hirid (), param.get_locus ());
}
translated = fn;
@ -218,9 +218,9 @@ ASTLowerTraitItem::translate (AST::AssociatedItem &item)
auto locus = resolver.translated->get_trait_locus ();
resolver.handle_outer_attributes (*resolver.translated);
resolver.mappings->insert_hir_trait_item (resolver.translated);
resolver.mappings->insert_location (id, locus);
resolver.mappings->insert_defid_mapping (defid, resolver.translated);
resolver.mappings.insert_hir_trait_item (resolver.translated);
resolver.mappings.insert_location (id, locus);
resolver.mappings.insert_defid_mapping (defid, resolver.translated);
}
return resolver.translated;
@ -262,9 +262,9 @@ ASTLowerTraitItem::visit (AST::Function &func)
auto translated_type = std::unique_ptr<HIR::Type> (
ASTLoweringType::translate (param.get_type ()));
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, param.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
auto hir_param
@ -287,10 +287,10 @@ ASTLowerTraitItem::visit (AST::Function &func)
&terminated))
: nullptr;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, func.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
auto *trait_item
= new HIR::TraitItemFunc (mapping, std::move (decl), std::move (block_expr),
@ -299,16 +299,16 @@ ASTLowerTraitItem::visit (AST::Function &func)
if (func.has_self_param ())
{
// insert mappings for self
mappings->insert_hir_self_param (&self_param);
mappings->insert_location (self_param.get_mappings ().get_hirid (),
self_param.get_locus ());
mappings.insert_hir_self_param (&self_param);
mappings.insert_location (self_param.get_mappings ().get_hirid (),
self_param.get_locus ());
}
// add the mappings for the function params at the end
for (auto &param : trait_item->get_decl ().get_function_params ())
{
mappings->insert_hir_param (&param);
mappings->insert_location (mapping.get_hirid (), param.get_locus ());
mappings.insert_hir_param (&param);
mappings.insert_location (mapping.get_hirid (), param.get_locus ());
}
}
@ -320,10 +320,10 @@ ASTLowerTraitItem::visit (AST::TraitItemConst &constant)
? ASTLoweringExpr::translate (constant.get_expr ())
: nullptr;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, constant.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
HIR::TraitItemConst *trait_item
= new HIR::TraitItemConst (mapping, constant.get_identifier (),
@ -338,10 +338,10 @@ void
ASTLowerTraitItem::visit (AST::TraitItemType &type)
{
std::vector<std::unique_ptr<HIR::TypeParamBound> > type_param_bounds;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, type.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
HIR::TraitItemType *trait_item
= new HIR::TraitItemType (mapping, type.get_identifier (),

View File

@ -44,10 +44,10 @@ ASTLoweringItem::translate (AST::Item &item)
auto locus = resolver.translated->get_locus ();
resolver.handle_outer_attributes (*resolver.translated);
resolver.mappings->insert_ast_item (&item);
resolver.mappings->insert_hir_item (resolver.translated);
resolver.mappings->insert_location (id, locus);
resolver.mappings->insert_defid_mapping (defid, resolver.translated);
resolver.mappings.insert_ast_item (&item);
resolver.mappings.insert_hir_item (resolver.translated);
resolver.mappings.insert_location (id, locus);
resolver.mappings.insert_defid_mapping (defid, resolver.translated);
}
return resolver.translated;
@ -56,10 +56,10 @@ ASTLoweringItem::translate (AST::Item &item)
void
ASTLoweringItem::visit (AST::Module &module)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, module.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
// should be lowered from module.get_vis()
HIR::Visibility vis = translate_visibility (module.get_visibility ());
@ -83,7 +83,7 @@ ASTLoweringItem::visit (AST::Module &module)
= new HIR::Module (mapping, module.get_name (), module.get_locus (),
std::move (items), std::move (vis),
std::move (inner_attrs), std::move (outer_attrs));
mappings->insert_module (static_cast<Module *> (translated));
mappings.insert_module (static_cast<Module *> (translated));
}
void
@ -107,10 +107,10 @@ ASTLoweringItem::visit (AST::TypeAlias &alias)
HIR::Type *existing_type
= ASTLoweringType::translate (alias.get_type_aliased ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, alias.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated
= new HIR::TypeAlias (mapping, alias.get_new_type_name (),
@ -150,11 +150,10 @@ ASTLoweringItem::visit (AST::TupleStruct &struct_decl)
HIR::Visibility vis = translate_visibility (field.get_visibility ());
HIR::Type *type = ASTLoweringType::translate (field.get_field_type ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, field.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (
crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
HIR::TupleField translated_field (mapping,
std::unique_ptr<HIR::Type> (type), vis,
@ -163,10 +162,10 @@ ASTLoweringItem::visit (AST::TupleStruct &struct_decl)
fields.push_back (std::move (translated_field));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, struct_decl.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::TupleStruct (mapping, std::move (fields),
struct_decl.get_identifier (),
@ -207,11 +206,10 @@ ASTLoweringItem::visit (AST::StructStruct &struct_decl)
HIR::Visibility vis = translate_visibility (field.get_visibility ());
HIR::Type *type = ASTLoweringType::translate (field.get_field_type ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, field.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (
crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
HIR::StructField translated_field (mapping, field.get_field_name (),
std::unique_ptr<HIR::Type> (type), vis,
@ -224,10 +222,10 @@ ASTLoweringItem::visit (AST::StructStruct &struct_decl)
fields.push_back (std::move (translated_field));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, struct_decl.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::StructStruct (mapping, std::move (fields),
struct_decl.get_identifier (),
@ -268,10 +266,10 @@ ASTLoweringItem::visit (AST::Enum &enum_decl)
items.push_back (std::unique_ptr<HIR::EnumItem> (hir_item));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, enum_decl.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
HIR::Enum *hir_enum
= new HIR::Enum (mapping, enum_decl.get_identifier (), vis,
@ -281,7 +279,7 @@ ASTLoweringItem::visit (AST::Enum &enum_decl)
translated = hir_enum;
for (auto &variant : hir_enum->get_variants ())
{
mappings->insert_hir_enumitem (hir_enum, variant.get ());
mappings.insert_hir_enumitem (hir_enum, variant.get ());
}
}
@ -314,11 +312,10 @@ ASTLoweringItem::visit (AST::Union &union_decl)
HIR::Visibility vis = translate_visibility (variant.get_visibility ());
HIR::Type *type = ASTLoweringType::translate (variant.get_field_type ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, variant.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (
crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
HIR::StructField translated_variant (mapping, variant.get_field_name (),
std::unique_ptr<HIR::Type> (type),
@ -331,10 +328,10 @@ ASTLoweringItem::visit (AST::Union &union_decl)
variants.push_back (std::move (translated_variant));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, union_decl.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated
= new HIR::Union (mapping, union_decl.get_identifier (), vis,
@ -351,10 +348,10 @@ ASTLoweringItem::visit (AST::StaticItem &var)
HIR::Type *type = ASTLoweringType::translate (var.get_type (), true);
HIR::Expr *expr = ASTLoweringExpr::translate (var.get_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, var.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::StaticItem (mapping, var.get_identifier (),
var.is_mutable () ? Mutability::Mut
@ -372,10 +369,10 @@ ASTLoweringItem::visit (AST::ConstantItem &constant)
HIR::Type *type = ASTLoweringType::translate (constant.get_type (), true);
HIR::Expr *expr = ASTLoweringExpr::translate (constant.get_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, constant.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::ConstantItem (mapping, constant.get_identifier (), vis,
std::unique_ptr<HIR::Type> (type),
@ -429,9 +426,9 @@ ASTLoweringItem::visit (AST::Function &function)
auto translated_type = std::unique_ptr<HIR::Type> (
ASTLoweringType::translate (param.get_type ()));
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, param.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
auto hir_param
@ -446,13 +443,13 @@ ASTLoweringItem::visit (AST::Function &function)
ASTLoweringBlock::translate (*function.get_definition ().value (),
&terminated));
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, function.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
mappings->insert_location (function_body->get_mappings ().get_hirid (),
function.get_locus ());
mappings.insert_location (function_body->get_mappings ().get_hirid (),
function.get_locus ());
auto fn
= new HIR::Function (mapping, std::move (function_name),
@ -465,8 +462,8 @@ ASTLoweringItem::visit (AST::Function &function)
// add the mappings for the function params at the end
for (auto &param : fn->get_function_params ())
{
mappings->insert_hir_param (&param);
mappings->insert_location (mapping.get_hirid (), param.get_locus ());
mappings.insert_hir_param (&param);
mappings.insert_location (mapping.get_hirid (), param.get_locus ());
}
translated = fn;
@ -521,10 +518,10 @@ ASTLoweringItem::visit (AST::InherentImpl &impl_block)
HIR::Type *impl_type = ASTLoweringType::translate (impl_block.get_type ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, impl_block.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
std::vector<std::unique_ptr<HIR::ImplItem>> impl_items;
std::vector<HirId> impl_item_ids;
@ -548,10 +545,10 @@ ASTLoweringItem::visit (AST::InherentImpl &impl_block)
impl_block.get_locus ());
translated = hir_impl_block;
mappings->insert_hir_impl_block (hir_impl_block);
mappings.insert_hir_impl_block (hir_impl_block);
for (auto &impl_item_id : impl_item_ids)
{
mappings->insert_impl_item_mapping (impl_item_id, hir_impl_block);
mappings.insert_impl_item_mapping (impl_item_id, hir_impl_block);
}
}
@ -598,10 +595,10 @@ ASTLoweringItem::visit (AST::Trait &trait)
trait_item_ids.push_back (lowered->get_mappings ().get_hirid ());
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, trait.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
auto trait_unsafety = Unsafety::Normal;
if (trait.is_unsafe ())
@ -618,7 +615,7 @@ ASTLoweringItem::visit (AST::Trait &trait)
for (auto trait_item_id : trait_item_ids)
{
mappings->insert_trait_item_mapping (trait_item_id, hir_trait);
mappings.insert_trait_item_mapping (trait_item_id, hir_trait);
}
}
@ -672,10 +669,10 @@ ASTLoweringItem::visit (AST::TraitImpl &impl_block)
HIR::TypePath *trait_ref
= ASTLowerTypePath::translate (impl_block.get_trait_path ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, impl_block.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
std::vector<std::unique_ptr<HIR::ImplItem>> impl_items;
std::vector<HirId> impl_item_ids;
@ -702,10 +699,10 @@ ASTLoweringItem::visit (AST::TraitImpl &impl_block)
impl_block.get_locus ());
translated = hir_impl_block;
mappings->insert_hir_impl_block (hir_impl_block);
mappings.insert_hir_impl_block (hir_impl_block);
for (auto &impl_item_id : impl_item_ids)
{
mappings->insert_impl_item_mapping (impl_item_id, hir_impl_block);
mappings.insert_impl_item_mapping (impl_item_id, hir_impl_block);
}
}
@ -732,17 +729,17 @@ ASTLoweringSimplePath::translate (const AST::SimplePath &path)
HIR::SimplePathSegment
ASTLoweringSimplePath::lower (const AST::SimplePathSegment &segment)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
auto node_id = segment.get_node_id ();
auto mapping = Analysis::NodeMapping (crate_num, node_id,
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
auto hir_seg = HIR::SimplePathSegment (mapping);
mappings->insert_node_to_hir (node_id, mapping.get_hirid ());
// mappings->insert_simple_path_segment (crate_num, node_id, &segment);
mappings.insert_node_to_hir (node_id, mapping.get_hirid ());
// mappings.insert_simple_path_segment (crate_num, node_id, &segment);
return hir_seg;
}
@ -754,18 +751,18 @@ ASTLoweringSimplePath::lower (const AST::SimplePath &path)
for (auto &segment : path.get_segments ())
segments.emplace_back (lower (segment));
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
auto node_id = path.get_node_id ();
auto mapping = Analysis::NodeMapping (crate_num, node_id,
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
auto lowered
= HIR::SimplePath (std::move (segments), mapping, path.get_locus ());
mappings->insert_node_to_hir (node_id, mapping.get_hirid ());
// mappings->insert_simple_path (crate_num, node_id, &path);
mappings.insert_node_to_hir (node_id, mapping.get_hirid ());
// mappings.insert_simple_path (crate_num, node_id, &path);
return lowered;
}

View File

@ -33,8 +33,8 @@ ASTLoweringPattern::translate (AST::Pattern &pattern, bool is_let_top_level)
rust_assert (resolver.translated != nullptr);
resolver.mappings->insert_hir_pattern (resolver.translated);
resolver.mappings->insert_location (
resolver.mappings.insert_hir_pattern (resolver.translated);
resolver.mappings.insert_location (
resolver.translated->get_mappings ().get_hirid (), pattern.get_locus ());
return resolver.translated;
@ -43,9 +43,9 @@ ASTLoweringPattern::translate (AST::Pattern &pattern, bool is_let_top_level)
void
ASTLoweringPattern::visit (AST::IdentifierPattern &pattern)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
std::unique_ptr<Pattern> to_bind;
@ -95,9 +95,9 @@ ASTLoweringPattern::visit (AST::TupleStructPattern &pattern)
break;
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::TupleStructPattern (
@ -123,10 +123,9 @@ ASTLoweringPattern::visit (AST::StructPattern &pattern)
auto &tuple
= static_cast<AST::StructPatternFieldTuplePat &> (*field);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, tuple.get_node_id (),
mappings->get_next_hir_id (
crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
std::unique_ptr<HIR::Pattern> pat (
@ -144,10 +143,9 @@ ASTLoweringPattern::visit (AST::StructPattern &pattern)
AST::StructPatternFieldIdentPat &ident
= static_cast<AST::StructPatternFieldIdentPat &> (*field);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, ident.get_node_id (),
mappings->get_next_hir_id (
crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
std::unique_ptr<HIR::Pattern> pat (
@ -165,10 +163,9 @@ ASTLoweringPattern::visit (AST::StructPattern &pattern)
AST::StructPatternFieldIdent &ident
= static_cast<AST::StructPatternFieldIdent &> (*field.get ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, ident.get_node_id (),
mappings->get_next_hir_id (
crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
f = new HIR::StructPatternFieldIdent (
@ -182,16 +179,16 @@ ASTLoweringPattern::visit (AST::StructPattern &pattern)
// insert the reverse mappings and locations
auto field_id = f->get_mappings ().get_hirid ();
auto field_node_id = f->get_mappings ().get_nodeid ();
mappings->insert_location (field_id, f->get_locus ());
mappings->insert_node_to_hir (field_node_id, field_id);
mappings.insert_location (field_id, f->get_locus ());
mappings.insert_node_to_hir (field_node_id, field_id);
// add it to the lowered fields list
fields.push_back (std::unique_ptr<HIR::StructPatternField> (f));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
HIR::StructPatternElements elems (std::move (fields));
@ -201,9 +198,9 @@ ASTLoweringPattern::visit (AST::StructPattern &pattern)
void
ASTLoweringPattern::visit (AST::WildcardPattern &pattern)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::WildcardPattern (mapping, pattern.get_locus ());
@ -231,9 +228,9 @@ ASTLoweringPattern::visit (AST::TuplePattern &pattern)
break;
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -243,9 +240,9 @@ ASTLoweringPattern::visit (AST::TuplePattern &pattern)
void
ASTLoweringPattern::visit (AST::LiteralPattern &pattern)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
HIR::Literal l = lower_literal (pattern.get_literal ());
@ -259,9 +256,9 @@ ASTLoweringPattern::visit (AST::RangePattern &pattern)
auto upper_bound = lower_range_pattern_bound (pattern.get_upper_bound ());
auto lower_bound = lower_range_pattern_bound (pattern.get_lower_bound ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -279,9 +276,9 @@ ASTLoweringPattern::visit (AST::GroupedPattern &pattern)
void
ASTLoweringPattern::visit (AST::ReferencePattern &pattern)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
HIR::Pattern *inner
@ -296,7 +293,7 @@ ASTLoweringPattern::visit (AST::ReferencePattern &pattern)
if (pattern.is_double_reference ())
{
Analysis::NodeMapping mapping2 (crate_num, pattern.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
= new HIR::ReferencePattern (mapping2,
@ -315,9 +312,9 @@ ASTLoweringPattern::visit (AST::SlicePattern &pattern)
items.push_back (std::unique_ptr<HIR::Pattern> (item));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -327,9 +324,9 @@ ASTLoweringPattern::visit (AST::SlicePattern &pattern)
void
ASTLoweringPattern::visit (AST::AltPattern &pattern)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
std::vector<std::unique_ptr<HIR::Pattern>> alts;

View File

@ -35,10 +35,10 @@ ASTLoweringStmt::translate (AST::Stmt *stmt, bool *terminated)
return nullptr;
*terminated = resolver.terminated;
resolver.mappings->insert_location (
resolver.mappings.insert_location (
resolver.translated->get_mappings ().get_hirid (),
resolver.translated->get_locus ());
resolver.mappings->insert_hir_stmt (resolver.translated);
resolver.mappings.insert_hir_stmt (resolver.translated);
return resolver.translated;
}
@ -48,9 +48,9 @@ ASTLoweringStmt::visit (AST::ExprStmt &stmt)
{
HIR::Expr *expr = ASTLoweringExpr::translate (stmt.get_expr (), &terminated);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, stmt.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
= new HIR::ExprStmt (mapping, std::unique_ptr<HIR::Expr> (expr),
@ -75,9 +75,9 @@ ASTLoweringStmt::visit (AST::LetStmt &stmt)
= stmt.has_init_expr () ? ASTLoweringExpr::translate (stmt.get_init_expr ())
: nullptr;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, stmt.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
= new HIR::LetStmt (mapping, std::unique_ptr<HIR::Pattern> (variables),
@ -113,10 +113,10 @@ ASTLoweringStmt::visit (AST::Enum &enum_decl)
void
ASTLoweringStmt::visit (AST::EmptyStmt &empty)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, empty.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::EmptyStmt (mapping, empty.get_locus ());
}

View File

@ -36,8 +36,8 @@ public:
field.accept_vis (compiler);
rust_assert (compiler.translated != nullptr);
compiler.mappings->insert_hir_struct_field (compiler.translated);
compiler.mappings->insert_location (
compiler.mappings.insert_hir_struct_field (compiler.translated);
compiler.mappings.insert_location (
compiler.translated->get_mappings ().get_hirid (), field.get_locus ());
return compiler.translated;

View File

@ -33,8 +33,8 @@ ASTLowerTypePath::translate (AST::TypePath &type)
void
ASTLowerTypePath::visit (AST::TypePathSegmentFunction &segment)
{
auto crate_num = mappings->get_current_crate ();
auto hirid = mappings->get_next_hir_id (crate_num);
auto crate_num = mappings.get_current_crate ();
auto hirid = mappings.get_next_hir_id (crate_num);
Analysis::NodeMapping mapping (crate_num, segment.get_node_id (), hirid,
UNKNOWN_LOCAL_DEFID);
@ -64,8 +64,8 @@ ASTLowerTypePath::visit (AST::TypePathSegmentFunction &segment)
void
ASTLowerTypePath::visit (AST::TypePathSegment &segment)
{
auto crate_num = mappings->get_current_crate ();
auto hirid = mappings->get_next_hir_id (crate_num);
auto crate_num = mappings.get_current_crate ();
auto hirid = mappings.get_next_hir_id (crate_num);
Analysis::NodeMapping mapping (crate_num, segment.get_node_id (), hirid,
UNKNOWN_LOCAL_DEFID);
@ -87,8 +87,8 @@ ASTLowerTypePath::visit (AST::TypePathSegmentGeneric &segment)
auto generic_args = lower_generic_args (segment.get_generic_args ());
auto crate_num = mappings->get_current_crate ();
auto hirid = mappings->get_next_hir_id (crate_num);
auto crate_num = mappings.get_current_crate ();
auto hirid = mappings.get_next_hir_id (crate_num);
Analysis::NodeMapping mapping (crate_num, segment.get_node_id (), hirid,
UNKNOWN_LOCAL_DEFID);
@ -113,10 +113,10 @@ ASTLowerTypePath::visit (AST::TypePath &path)
std::unique_ptr<HIR::TypePathSegment> (translated_segment));
}
auto crate_num = mappings->get_current_crate ();
auto hirid = mappings->get_next_hir_id (crate_num);
auto crate_num = mappings.get_current_crate ();
auto hirid = mappings.get_next_hir_id (crate_num);
Analysis::NodeMapping mapping (crate_num, path.get_node_id (), hirid,
mappings->get_next_localdef_id (crate_num));
mappings.get_next_localdef_id (crate_num));
translated
= new HIR::TypePath (std::move (mapping), std::move (translated_segments),
@ -136,8 +136,8 @@ ASTLowerQualifiedPathInType::translate (AST::QualifiedPathInType &type)
void
ASTLowerQualifiedPathInType::visit (AST::QualifiedPathInType &path)
{
auto crate_num = mappings->get_current_crate ();
auto hirid = mappings->get_next_hir_id (crate_num);
auto crate_num = mappings.get_current_crate ();
auto hirid = mappings.get_next_hir_id (crate_num);
Analysis::NodeMapping qual_mappings (
crate_num, path.get_qualified_path_type ().get_node_id (), hirid,
UNKNOWN_LOCAL_DEFID);
@ -170,7 +170,7 @@ ASTLowerQualifiedPathInType::visit (AST::QualifiedPathInType &path)
}
Analysis::NodeMapping mapping (crate_num, path.get_node_id (), hirid,
mappings->get_next_localdef_id (crate_num));
mappings.get_next_localdef_id (crate_num));
translated = new HIR::QualifiedPathInType (std::move (mapping),
std::move (qual_path_type),
std::move (associated_segment),
@ -185,8 +185,8 @@ ASTLoweringType::translate (AST::Type &type, bool default_to_static_lifetime)
type.accept_vis (resolver);
rust_assert (resolver.translated != nullptr);
resolver.mappings->insert_hir_type (resolver.translated);
resolver.mappings->insert_location (
resolver.mappings.insert_hir_type (resolver.translated);
resolver.mappings.insert_location (
resolver.translated->get_mappings ().get_hirid (),
resolver.translated->get_locus ());
@ -244,10 +244,10 @@ ASTLoweringType::visit (AST::BareFunctionType &fntype)
default_to_static_lifetime);
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, fntype.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::BareFunctionType (
std::move (mapping), std::move (lifetime_params), std::move (qualifiers),
@ -266,10 +266,10 @@ ASTLoweringType::visit (AST::TupleType &tuple)
elems.push_back (std::unique_ptr<HIR::Type> (t));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, tuple.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::TupleType (std::move (mapping), std::move (elems),
tuple.get_locus ());
@ -295,10 +295,10 @@ ASTLoweringType::visit (AST::ArrayType &type)
default_to_static_lifetime);
HIR::Expr *array_size = ASTLoweringExpr::translate (type.get_size_expr ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, type.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated
= new HIR::ArrayType (mapping, std::unique_ptr<HIR::Type> (translated_type),
@ -316,10 +316,10 @@ ASTLoweringType::visit (AST::ReferenceType &type)
= ASTLoweringType::translate (type.get_base_type (),
default_to_static_lifetime);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, type.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::ReferenceType (mapping,
type.get_has_mut () ? Mutability::Mut
@ -335,10 +335,10 @@ ASTLoweringType::visit (AST::RawPointerType &type)
= ASTLoweringType::translate (type.get_type_pointed_to (),
default_to_static_lifetime);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, type.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated
= new HIR::RawPointerType (mapping,
@ -357,10 +357,10 @@ ASTLoweringType::visit (AST::SliceType &type)
= ASTLoweringType::translate (type.get_elem_type (),
default_to_static_lifetime);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, type.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated
= new HIR::SliceType (mapping, std::unique_ptr<HIR::Type> (base_type),
@ -370,10 +370,10 @@ ASTLoweringType::visit (AST::SliceType &type)
void
ASTLoweringType::visit (AST::InferredType &type)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, type.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::InferredType (mapping, type.get_locus ());
}
@ -381,10 +381,10 @@ ASTLoweringType::visit (AST::InferredType &type)
void
ASTLoweringType::visit (AST::NeverType &type)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, type.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::NeverType (mapping, type.get_locus ());
}
@ -397,10 +397,10 @@ ASTLoweringType::visit (AST::TraitObjectTypeOneBound &type)
= ASTLoweringTypeBounds::translate (type.get_trait_bound ());
bounds.push_back (std::unique_ptr<HIR::TypeParamBound> (translated_bound));
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, type.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::TraitObjectType (mapping, std::move (bounds),
type.get_locus (), type.is_dyn ());
@ -419,10 +419,10 @@ ASTLoweringType::visit (AST::TraitObjectType &type)
std::unique_ptr<HIR::TypeParamBound> (translated_bound));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, type.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated = new HIR::TraitObjectType (mapping, std::move (bounds),
type.get_locus (), type.is_dyn ());
@ -435,9 +435,9 @@ ASTLowerGenericParam::translate (AST::GenericParam &param)
param.accept_vis (resolver);
rust_assert (resolver.translated != nullptr);
resolver.mappings->insert_location (
resolver.mappings.insert_location (
resolver.translated->get_mappings ().get_hirid (), param.get_locus ());
resolver.mappings->insert_hir_generic_param (resolver.translated);
resolver.mappings.insert_hir_generic_param (resolver.translated);
return resolver.translated;
}
@ -445,10 +445,10 @@ ASTLowerGenericParam::translate (AST::GenericParam &param)
void
ASTLowerGenericParam::visit (AST::LifetimeParam &param)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, param.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
HIR::Lifetime lt (mapping, param.get_lifetime ().get_lifetime_type (),
param.get_lifetime ().get_lifetime_name (),
@ -461,10 +461,10 @@ ASTLowerGenericParam::visit (AST::LifetimeParam &param)
void
ASTLowerGenericParam::visit (AST::ConstGenericParam &param)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, param.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
auto type = ASTLoweringType::translate (param.get_type ());
@ -498,10 +498,10 @@ ASTLowerGenericParam::visit (AST::TypeParam &param)
? ASTLoweringType::translate (param.get_type ())
: nullptr;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, param.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings->get_next_localdef_id (crate_num));
mappings.get_next_hir_id (crate_num),
mappings.get_next_localdef_id (crate_num));
translated
= new HIR::TypeParam (mapping, param.get_type_representation (),
@ -516,7 +516,7 @@ ASTLoweringTypeBounds::translate (AST::TypeParamBound &type)
type.accept_vis (resolver);
rust_assert (resolver.translated != nullptr);
resolver.mappings->insert_location (
resolver.mappings.insert_location (
resolver.translated->get_mappings ().get_hirid (),
resolver.translated->get_locus ());
@ -537,9 +537,9 @@ ASTLoweringTypeBounds::visit (AST::TraitBound &bound)
AST::TypePath &ast_trait_path = bound.get_type_path ();
HIR::TypePath *trait_path = ASTLowerTypePath::translate (ast_trait_path);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, bound.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
BoundPolarity polarity = bound.has_opening_question_mark ()
@ -565,7 +565,7 @@ ASTLowerWhereClauseItem::translate (AST::WhereClauseItem &item)
rust_assert (compiler.translated != nullptr);
// FIXME
// compiler.mappings->insert_location (
// compiler.mappings.insert_location (
// compiler.translated->get_mappings ().get_hirid (),
// compiler.translated->get_locus ());
@ -583,9 +583,9 @@ ASTLowerWhereClauseItem::visit (AST::LifetimeWhereClauseItem &item)
lifetime_bounds.push_back (std::move (ll));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, item.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::LifetimeWhereClauseItem (mapping, std::move (l),
@ -616,9 +616,9 @@ ASTLowerWhereClauseItem::visit (AST::TypeBoundWhereClauseItem &item)
type_param_bounds.push_back (std::unique_ptr<HIR::TypeParamBound> (b));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, item.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated

View File

@ -81,10 +81,10 @@ ASTLowering::go ()
items.push_back (std::unique_ptr<HIR::Item> (translated));
}
auto mappings = Analysis::Mappings::get ();
auto crate_num = mappings->get_current_crate ();
auto &mappings = Analysis::Mappings::get ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, astCrate.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
return std::unique_ptr<HIR::Crate> (
@ -137,9 +137,9 @@ ASTLoweringBlock::visit (AST::BlockExpr &expr)
}
bool tail_reachable = !block_did_terminate;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
= new HIR::BlockExpr (mapping, std::move (block_stmts),
@ -160,9 +160,9 @@ ASTLoweringIfBlock::visit (AST::IfExpr &expr)
HIR::BlockExpr *block
= ASTLoweringBlock::translate (expr.get_if_block (), &ignored_terminated);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::IfExpr (mapping, std::unique_ptr<HIR::Expr> (condition),
@ -187,9 +187,9 @@ ASTLoweringIfBlock::visit (AST::IfExprConseqElse &expr)
terminated = if_block_terminated && else_block_termianted;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::IfExprConseqElse (
@ -213,9 +213,9 @@ ASTLoweringIfLetBlock::visit (AST::IfLetExpr &expr)
HIR::BlockExpr *block
= ASTLoweringBlock::translate (expr.get_if_block (), &ignored_terminated);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::IfLetExpr (mapping, std::move (patterns),
@ -245,9 +245,9 @@ ASTLoweringIfLetBlock::visit (AST::IfLetExprConseqElse &expr)
rust_assert (else_block);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::IfLetExprConseqElse (
@ -263,9 +263,9 @@ ASTLowerStructExprField::visit (AST::StructExprFieldIdentifierValue &field)
{
HIR::Expr *value = ASTLoweringExpr::translate (field.get_value ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, field.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::StructExprFieldIdentifierValue (
@ -278,9 +278,9 @@ ASTLowerStructExprField::visit (AST::StructExprFieldIndexValue &field)
{
HIR::Expr *value = ASTLoweringExpr::translate (field.get_value ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, field.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -292,9 +292,9 @@ ASTLowerStructExprField::visit (AST::StructExprFieldIndexValue &field)
void
ASTLowerStructExprField::visit (AST::StructExprFieldIdentifier &field)
{
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, field.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -314,9 +314,9 @@ ASTLoweringExprWithBlock::visit (AST::WhileLoopExpr &expr)
HIR::Expr *loop_condition
= ASTLoweringExpr::translate (expr.get_predicate_expr (), &terminated);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -380,9 +380,9 @@ ASTLoweringExprWithBlock::visit (AST::MatchExpr &expr)
std::unique_ptr<HIR::Expr> (kase_guard_expr),
match_case.get_arm ().get_outer_attrs ());
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
HIR::MatchCase kase (std::move (mapping), std::move (arm),
@ -390,9 +390,9 @@ ASTLoweringExprWithBlock::visit (AST::MatchExpr &expr)
match_arms.push_back (std::move (kase));
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated
@ -414,11 +414,11 @@ ASTLowerPathInExpression::visit (AST::PathInExpression &expr)
// insert the mappings for the segment
HIR::PathExprSegment *lowered_seg = &path_segments.back ();
mappings->insert_hir_path_expr_seg (lowered_seg);
mappings.insert_hir_path_expr_seg (lowered_seg);
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::PathInExpression (mapping, std::move (path_segments),
@ -435,9 +435,9 @@ ASTLoweringBase::lower_qual_path_type (AST::QualifiedPathType &qualified_type)
? ASTLowerTypePath::translate (qualified_type.get_as_type_path ())
: nullptr;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, qualified_type.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
return HIR::QualifiedPathType (mapping, std::unique_ptr<HIR::Type> (type),
@ -459,12 +459,12 @@ ASTLowerQualPathInExpression::visit (AST::QualifiedPathInExpression &expr)
// insert the mappings for the segment
HIR::PathExprSegment *lowered_seg = &path_segments.back ();
mappings->insert_hir_path_expr_seg (lowered_seg);
mappings.insert_hir_path_expr_seg (lowered_seg);
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
translated = new HIR::QualifiedPathInExpression (mapping, qual_path_type,

View File

@ -58,7 +58,7 @@ ExportContext::emit_trait (const HIR::Trait &trait)
// lookup the AST node for this
AST::Item *item = nullptr;
bool ok
= mappings->lookup_ast_item (trait.get_mappings ().get_nodeid (), &item);
= mappings.lookup_ast_item (trait.get_mappings ().get_nodeid (), &item);
rust_assert (ok);
std::stringstream oss;
@ -73,7 +73,7 @@ ExportContext::emit_function (const HIR::Function &fn)
{
// lookup the AST node for this
AST::Item *item = nullptr;
bool ok = mappings->lookup_ast_item (fn.get_mappings ().get_nodeid (), &item);
bool ok = mappings.lookup_ast_item (fn.get_mappings ().get_nodeid (), &item);
rust_assert (ok);
// is this a CFG macro or not
@ -120,7 +120,7 @@ ExportContext::emit_macro (NodeId macro)
AST::Dump dumper (oss);
AST::Item *item;
auto ok = mappings->lookup_ast_item (macro, &item);
auto ok = mappings.lookup_ast_item (macro, &item);
rust_assert (ok);
dumper.go (*item);
@ -166,7 +166,7 @@ private:
};
PublicInterface::PublicInterface (HIR::Crate &crate)
: crate (crate), mappings (*Analysis::Mappings::get ()), context ()
: crate (crate), mappings (Analysis::Mappings::get ()), context ()
{}
void
@ -363,9 +363,9 @@ PublicInterface::is_crate_public (const HIR::VisItem &item)
std::string
PublicInterface::expected_metadata_filename ()
{
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
const std::string current_crate_name = mappings->get_current_crate_name ();
const std::string current_crate_name = mappings.get_current_crate_name ();
return current_crate_name + extension_path;
}

View File

@ -53,7 +53,7 @@ public:
const std::string &get_interface_buffer () const;
private:
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
std::vector<std::reference_wrapper<const HIR::Module>> module_stack;
std::string public_interface_buffer;

View File

@ -212,7 +212,7 @@ protected:
bool resolve_visibility (const AST::Visibility &vis);
Resolver *resolver;
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
NodeId resolved_node;
};

View File

@ -127,7 +127,7 @@ public:
rust_error_at (r, "redefined multiple times");
});
mappings->insert_canonical_path (function.get_node_id (), cpath);
mappings.insert_canonical_path (function.get_node_id (), cpath);
}
void visit (AST::TraitItemConst &constant) override
@ -147,7 +147,7 @@ public:
rust_error_at (r, "redefined multiple times");
});
mappings->insert_canonical_path (constant.get_node_id (), cpath);
mappings.insert_canonical_path (constant.get_node_id (), cpath);
}
void visit (AST::TraitItemType &type) override
@ -165,7 +165,7 @@ public:
rust_error_at (r, "redefined multiple times");
});
mappings->insert_canonical_path (type.get_node_id (), cpath);
mappings.insert_canonical_path (type.get_node_id (), cpath);
}
private:
@ -206,7 +206,7 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings.insert_module_child_item (current_module, decl);
}
void visit (AST::ExternalStaticItem &item) override
@ -225,7 +225,7 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings.insert_module_child_item (current_module, decl);
}
void visit (AST::ExternalTypeItem &type) override
@ -244,7 +244,7 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings.insert_module_child_item (current_module, decl);
}
private:

View File

@ -53,7 +53,7 @@ ResolveTraitItems::visit (AST::Function &function)
function.get_function_name ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (function.get_node_id (), cpath);
mappings.insert_canonical_path (function.get_node_id (), cpath);
NodeId scope_node_id = function.get_node_id ();
resolver->get_name_scope ().push (scope_node_id);
@ -140,7 +140,7 @@ ResolveTraitItems::visit (AST::TraitItemType &type)
type.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (type.get_node_id (), cpath);
mappings.insert_canonical_path (type.get_node_id (), cpath);
for (auto &bound : type.get_type_param_bounds ())
ResolveTypeBound::go (*bound);
@ -153,7 +153,7 @@ ResolveTraitItems::visit (AST::TraitItemConst &constant)
constant.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (constant.get_node_id (), cpath);
mappings.insert_canonical_path (constant.get_node_id (), cpath);
ResolveType::go (constant.get_type ());
@ -182,7 +182,7 @@ ResolveItem::visit (AST::TypeAlias &alias)
alias.get_new_type_name ().as_string ());
auto path = prefix.append (talias);
auto cpath = canonical_prefix.append (talias);
mappings->insert_canonical_path (alias.get_node_id (), cpath);
mappings.insert_canonical_path (alias.get_node_id (), cpath);
NodeId scope_node_id = alias.get_node_id ();
resolver->get_type_scope ().push (scope_node_id);
@ -206,7 +206,7 @@ ResolveItem::visit (AST::Module &module)
module.get_name ().as_string ());
auto path = prefix.append (mod);
auto cpath = canonical_prefix.append (mod);
mappings->insert_canonical_path (module.get_node_id (), cpath);
mappings.insert_canonical_path (module.get_node_id (), cpath);
resolve_visibility (module.get_visibility ());
@ -242,7 +242,7 @@ ResolveItem::visit (AST::TupleStruct &struct_decl)
struct_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
resolve_visibility (struct_decl.get_visibility ());
@ -276,7 +276,7 @@ ResolveItem::visit (AST::Enum &enum_decl)
enum_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (enum_decl.get_node_id (), cpath);
mappings.insert_canonical_path (enum_decl.get_node_id (), cpath);
resolve_visibility (enum_decl.get_visibility ());
@ -308,7 +308,7 @@ ResolveItem::visit (AST::EnumItem &item)
item.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
}
void
@ -318,7 +318,7 @@ ResolveItem::visit (AST::EnumItemTuple &item)
item.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
for (auto &field : item.get_tuple_fields ())
{
@ -336,7 +336,7 @@ ResolveItem::visit (AST::EnumItemStruct &item)
item.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
for (auto &field : item.get_struct_fields ())
{
@ -355,7 +355,7 @@ ResolveItem::visit (AST::EnumItemDiscriminant &item)
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
}
void
@ -366,7 +366,7 @@ ResolveItem::visit (AST::StructStruct &struct_decl)
struct_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
resolve_visibility (struct_decl.get_visibility ());
@ -401,7 +401,7 @@ ResolveItem::visit (AST::Union &union_decl)
union_decl.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (union_decl.get_node_id (), cpath);
mappings.insert_canonical_path (union_decl.get_node_id (), cpath);
resolve_visibility (union_decl.get_visibility ());
@ -433,7 +433,7 @@ ResolveItem::visit (AST::StaticItem &var)
var.get_identifier ().as_string ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (var.get_node_id (), cpath);
mappings.insert_canonical_path (var.get_node_id (), cpath);
ResolveType::go (var.get_type ());
ResolveExpr::go (var.get_expr (), path, cpath);
@ -446,7 +446,7 @@ ResolveItem::visit (AST::ConstantItem &constant)
constant.get_identifier ());
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (constant.get_node_id (), cpath);
mappings.insert_canonical_path (constant.get_node_id (), cpath);
resolve_visibility (constant.get_visibility ());
@ -463,7 +463,7 @@ ResolveItem::visit (AST::Function &function)
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (function.get_node_id (), cpath);
mappings.insert_canonical_path (function.get_node_id (), cpath);
resolve_visibility (function.get_visibility ());
@ -961,7 +961,7 @@ ResolveItem::visit (AST::UseDeclaration &use_item)
continue;
auto decl = CanonicalPath::new_seg (resolved_node_id, import.get_name ());
mappings->insert_module_child_item (current_module, decl);
mappings.insert_module_child_item (current_module, decl);
resolver->get_type_scope ().insert (decl, resolved_node_id,
path.get_locus (),
@ -1016,7 +1016,7 @@ ResolveExternItem::visit (AST::Function &function)
auto path = prefix.append (decl);
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (function.get_node_id (), cpath);
mappings.insert_canonical_path (function.get_node_id (), cpath);
resolve_visibility (function.get_visibility ());

View File

@ -165,8 +165,8 @@ ResolvePath::resolve_path (AST::PathInExpression &expr)
&& previous_resolved_node_id == module_scope_id)
{
tl::optional<CanonicalPath &> resolved_child
= mappings->lookup_module_child (module_scope_id,
ident_seg.as_string ());
= mappings.lookup_module_child (module_scope_id,
ident_seg.as_string ());
if (resolved_child.has_value ())
{
NodeId resolved_node = resolved_child->get_node_id ();
@ -197,8 +197,8 @@ ResolvePath::resolve_path (AST::PathInExpression &expr)
bool did_resolve_segment = resolved_node_id != UNKNOWN_NODEID;
if (did_resolve_segment)
{
if (mappings->node_is_module (resolved_node_id)
|| mappings->node_is_crate (resolved_node_id))
if (mappings.node_is_module (resolved_node_id)
|| mappings.node_is_crate (resolved_node_id))
{
module_scope_id = resolved_node_id;
}
@ -304,8 +304,8 @@ ResolvePath::resolve_path (AST::SimplePath &expr)
}
tl::optional<CanonicalPath &> resolved_child
= mappings->lookup_module_child (module_scope_id,
segment.get_segment_name ());
= mappings.lookup_module_child (module_scope_id,
segment.get_segment_name ());
if (resolved_child.has_value ())
{
NodeId resolved_node = resolved_child->get_node_id ();
@ -379,7 +379,7 @@ ResolvePath::resolve_path (AST::SimplePath &expr)
return UNKNOWN_NODEID;
}
if (mappings->node_is_module (resolved_node_id))
if (mappings.node_is_module (resolved_node_id))
{
module_scope_id = resolved_node_id;
}

View File

@ -55,7 +55,7 @@ public:
constant.get_identifier ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (constant.get_node_id (), cpath);
mappings.insert_canonical_path (constant.get_node_id (), cpath);
resolver->get_name_scope ().insert (
path, constant.get_node_id (), constant.get_locus (), false,
@ -89,7 +89,7 @@ public:
struct_decl.get_identifier ().as_string ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, struct_decl.get_node_id (), struct_decl.get_locus (), false,
@ -122,7 +122,7 @@ public:
enum_decl.get_identifier ().as_string ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (enum_decl.get_node_id (), cpath);
mappings.insert_canonical_path (enum_decl.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, enum_decl.get_node_id (), enum_decl.get_locus (), false,
@ -155,7 +155,7 @@ public:
item.get_identifier ().as_string ()));
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
@ -175,7 +175,7 @@ public:
item.get_identifier ().as_string ()));
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
@ -201,7 +201,7 @@ public:
item.get_identifier ().as_string ()));
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
@ -227,7 +227,7 @@ public:
item.get_identifier ().as_string ()));
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, item.get_node_id (), item.get_locus (), false, Rib::ItemType::Type,
@ -247,7 +247,7 @@ public:
struct_decl.get_identifier ().as_string ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, struct_decl.get_node_id (), struct_decl.get_locus (), false,
@ -285,7 +285,7 @@ public:
union_decl.get_identifier ().as_string ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (union_decl.get_node_id (), cpath);
mappings.insert_canonical_path (union_decl.get_node_id (), cpath);
resolver->get_type_scope ().insert (
path, union_decl.get_node_id (), union_decl.get_locus (), false,
@ -321,7 +321,7 @@ public:
function.get_function_name ().as_string ());
auto path = decl; // this ensures we have the correct relative resolution
auto cpath = canonical_prefix.append (decl);
mappings->insert_canonical_path (function.get_node_id (), cpath);
mappings.insert_canonical_path (function.get_node_id (), cpath);
resolver->get_name_scope ().insert (
path, function.get_node_id (), function.get_locus (), false,

View File

@ -41,7 +41,7 @@ public:
item.accept_vis (resolver);
NodeId current_module = resolver.resolver->peek_current_module_scope ();
resolver.mappings->insert_child_item_to_parent_module_mapping (
resolver.mappings.insert_child_item_to_parent_module_mapping (
item.get_node_id (), current_module);
}
@ -62,8 +62,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, mod);
mappings->insert_module_child (current_module, module.get_node_id ());
mappings.insert_module_child_item (current_module, mod);
mappings.insert_module_child (current_module, module.get_node_id ());
resolver->push_new_module_scope (module.get_node_id ());
for (auto &item : module.get_items ())
@ -71,7 +71,7 @@ public:
resolver->pop_module_scope ();
mappings->insert_canonical_path (module.get_node_id (), cpath);
mappings.insert_canonical_path (module.get_node_id (), cpath);
}
void visit (AST::TypeAlias &alias) override
@ -92,8 +92,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, talias);
mappings->insert_canonical_path (alias.get_node_id (), cpath);
mappings.insert_module_child_item (current_module, talias);
mappings.insert_canonical_path (alias.get_node_id (), cpath);
}
void visit (AST::TupleStruct &struct_decl) override
@ -114,8 +114,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
mappings.insert_module_child_item (current_module, decl);
mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
}
void visit (AST::Enum &enum_decl) override
@ -142,8 +142,8 @@ public:
resolver->pop_module_scope ();
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_canonical_path (enum_decl.get_node_id (), cpath);
mappings.insert_module_child_item (current_module, decl);
mappings.insert_canonical_path (enum_decl.get_node_id (), cpath);
}
void visit (AST::EnumItem &item) override
@ -161,11 +161,11 @@ public:
rust_error_at (r, "redefined multiple times");
});
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_module_child (current_module, item.get_node_id ());
mappings.insert_module_child_item (current_module, decl);
mappings.insert_module_child (current_module, item.get_node_id ());
}
void visit (AST::EnumItemTuple &item) override
@ -183,11 +183,11 @@ public:
rust_error_at (r, "redefined multiple times");
});
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_module_child (current_module, item.get_node_id ());
mappings.insert_module_child_item (current_module, decl);
mappings.insert_module_child (current_module, item.get_node_id ());
}
void visit (AST::EnumItemStruct &item) override
@ -205,11 +205,11 @@ public:
rust_error_at (r, "redefined multiple times");
});
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_module_child (current_module, item.get_node_id ());
mappings.insert_module_child_item (current_module, decl);
mappings.insert_module_child (current_module, item.get_node_id ());
}
void visit (AST::EnumItemDiscriminant &item) override
@ -227,11 +227,11 @@ public:
rust_error_at (r, "redefined multiple times");
});
mappings->insert_canonical_path (item.get_node_id (), cpath);
mappings.insert_canonical_path (item.get_node_id (), cpath);
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_module_child (current_module, item.get_node_id ());
mappings.insert_module_child_item (current_module, decl);
mappings.insert_module_child (current_module, item.get_node_id ());
}
void visit (AST::StructStruct &struct_decl) override
@ -252,8 +252,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_canonical_path (struct_decl.get_node_id (), cpath);
mappings.insert_module_child_item (current_module, decl);
mappings.insert_canonical_path (struct_decl.get_node_id (), cpath);
}
void visit (AST::Union &union_decl) override
@ -274,8 +274,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_canonical_path (union_decl.get_node_id (), cpath);
mappings.insert_module_child_item (current_module, decl);
mappings.insert_canonical_path (union_decl.get_node_id (), cpath);
}
void visit (AST::StaticItem &var) override
@ -294,8 +294,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_canonical_path (var.get_node_id (), cpath);
mappings.insert_module_child_item (current_module, decl);
mappings.insert_canonical_path (var.get_node_id (), cpath);
}
void visit (AST::ConstantItem &constant) override
@ -315,8 +315,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_canonical_path (constant.get_node_id (), cpath);
mappings.insert_module_child_item (current_module, decl);
mappings.insert_canonical_path (constant.get_node_id (), cpath);
}
void visit (AST::Function &function) override
@ -337,8 +337,8 @@ public:
});
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_canonical_path (function.get_node_id (), cpath);
mappings.insert_module_child_item (current_module, decl);
mappings.insert_canonical_path (function.get_node_id (), cpath);
}
void visit (AST::InherentImpl &impl_block) override
@ -408,8 +408,8 @@ public:
ResolveTopLevelTraitItems::go (item.get (), path, cpath);
NodeId current_module = resolver->peek_current_module_scope ();
mappings->insert_module_child_item (current_module, decl);
mappings->insert_canonical_path (trait.get_node_id (), cpath);
mappings.insert_module_child_item (current_module, decl);
mappings.insert_canonical_path (trait.get_node_id (), cpath);
}
void visit (AST::ExternBlock &extern_block) override
@ -428,16 +428,16 @@ public:
NodeId resolved_crate = UNKNOWN_NODEID;
if (extern_crate.references_self ())
{
CrateNum crate_num = mappings->get_current_crate ();
bool ok = mappings->crate_num_to_nodeid (crate_num, resolved_crate);
CrateNum crate_num = mappings.get_current_crate ();
bool ok = mappings.crate_num_to_nodeid (crate_num, resolved_crate);
rust_assert (ok);
}
else
{
CrateNum found_crate_num = UNKNOWN_CRATENUM;
bool found
= mappings->lookup_crate_name (extern_crate.get_referenced_crate (),
found_crate_num);
= mappings.lookup_crate_name (extern_crate.get_referenced_crate (),
found_crate_num);
if (!found)
{
rust_error_at (extern_crate.get_locus (), "unknown crate %<%s%>",
@ -446,7 +446,7 @@ public:
}
bool ok
= mappings->crate_num_to_nodeid (found_crate_num, resolved_crate);
= mappings.crate_num_to_nodeid (found_crate_num, resolved_crate);
if (!ok)
{
rust_internal_error_at (extern_crate.get_locus (),

View File

@ -84,7 +84,7 @@ bool
ResolveRelativeTypePath::go (AST::TypePath &path, NodeId &resolved_node_id)
{
auto resolver = Resolver::get ();
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
NodeId module_scope_id = resolver->peek_current_module_scope ();
NodeId previous_resolved_node_id = module_scope_id;
@ -199,8 +199,8 @@ ResolveRelativeTypePath::go (AST::TypePath &path, NodeId &resolved_node_id)
&& previous_resolved_node_id == module_scope_id)
{
tl::optional<CanonicalPath &> resolved_child
= mappings->lookup_module_child (module_scope_id,
ident_seg.as_string ());
= mappings.lookup_module_child (module_scope_id,
ident_seg.as_string ());
if (resolved_child.has_value ())
{
NodeId resolved_node = resolved_child->get_node_id ();
@ -231,8 +231,8 @@ ResolveRelativeTypePath::go (AST::TypePath &path, NodeId &resolved_node_id)
bool did_resolve_segment = resolved_node_id != UNKNOWN_NODEID;
if (did_resolve_segment)
{
if (mappings->node_is_module (resolved_node_id)
|| mappings->node_is_crate (resolved_node_id))
if (mappings.node_is_module (resolved_node_id)
|| mappings.node_is_crate (resolved_node_id))
{
module_scope_id = resolved_node_id;
}
@ -377,7 +377,7 @@ ResolveTypeToCanonicalPath::visit (AST::TypePath &path)
return;
const CanonicalPath *type_path = nullptr;
if (mappings->lookup_canonical_path (resolved_node, &type_path))
if (mappings.lookup_canonical_path (resolved_node, &type_path))
{
auto &final_seg = path.get_segments ().back ();
switch (final_seg->get_type ())

View File

@ -184,7 +184,7 @@ public:
rust_error_at (locus, "was defined here");
});
mappings->insert_canonical_path (param.get_node_id (), seg);
mappings.insert_canonical_path (param.get_node_id (), seg);
}
private:

View File

@ -46,7 +46,7 @@ NameResolution::NameResolution ()
: resolver (Resolver::get ()), mappings (Analysis::Mappings::get ())
{
// these are global
resolver->get_type_scope ().push (mappings->get_next_node_id ());
resolver->get_type_scope ().push (mappings.get_next_node_id ());
resolver->insert_builtin_types (resolver->get_type_scope ().peek ());
resolver->push_new_type_rib (resolver->get_type_scope ().peek ());
}
@ -62,9 +62,9 @@ void
NameResolution::go (AST::Crate &crate)
{
// lookup current crate name
CrateNum cnum = mappings->get_current_crate ();
CrateNum cnum = mappings.get_current_crate ();
std::string crate_name;
bool ok = mappings->get_crate_name (cnum, crate_name);
bool ok = mappings.get_crate_name (cnum, crate_name);
rust_assert (ok);
// setup the ribs

View File

@ -40,7 +40,7 @@ private:
NameResolution ();
Resolver *resolver;
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
};
} // namespace Resolver

View File

@ -175,25 +175,25 @@ Early::visit (AST::MacroInvocation &invoc)
// now do we need to keep mappings or something? or insert "uses" into our
// ForeverStack? can we do that? are mappings simpler?
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
AST::MacroRulesDefinition *rules_def = nullptr;
if (!mappings->lookup_macro_def (definition->get_node_id (), &rules_def))
if (!mappings.lookup_macro_def (definition->get_node_id (), &rules_def))
{
// Macro definition not found, maybe it is not expanded yet.
return;
}
AST::MacroRulesDefinition *tmp_def = nullptr;
if (mappings->lookup_macro_invocation (invoc, &tmp_def))
if (mappings.lookup_macro_invocation (invoc, &tmp_def))
return;
mappings->insert_macro_invocation (invoc, rules_def);
mappings.insert_macro_invocation (invoc, rules_def);
}
void
Early::visit_attributes (std::vector<AST::Attribute> &attrs)
{
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
for (auto &attr : attrs)
{
@ -214,13 +214,13 @@ Early::visit_attributes (std::vector<AST::Attribute> &attrs)
continue;
}
auto pm_def = mappings->lookup_derive_proc_macro_def (
auto pm_def = mappings.lookup_derive_proc_macro_def (
definition->get_node_id ());
rust_assert (pm_def.has_value ());
mappings->insert_derive_proc_macro_invocation (trait,
pm_def.value ());
mappings.insert_derive_proc_macro_invocation (trait,
pm_def.value ());
}
}
else if (Analysis::BuiltinAttributeMappings::get ()
@ -236,13 +236,13 @@ Early::visit_attributes (std::vector<AST::Attribute> &attrs)
"could not resolve attribute macro invocation");
return;
}
auto pm_def = mappings->lookup_attribute_proc_macro_def (
auto pm_def = mappings.lookup_attribute_proc_macro_def (
definition->get_node_id ());
rust_assert (pm_def.has_value ());
mappings->insert_attribute_proc_macro_invocation (attr.get_path (),
pm_def.value ());
mappings.insert_attribute_proc_macro_invocation (attr.get_path (),
pm_def.value ());
}
}
}

View File

@ -74,7 +74,7 @@ EarlyNameResolver::accumulate_escaped_macros (AST::Module &module)
EarlyNameResolver::EarlyNameResolver ()
: current_scope (UNKNOWN_NODEID), resolver (*Resolver::get ()),
mappings (*Analysis::Mappings::get ())
mappings (Analysis::Mappings::get ())
{}
void

View File

@ -34,13 +34,13 @@ Late::Late (NameResolutionContext &ctx) : DefaultResolver (ctx) {}
static NodeId
next_node_id ()
{
return Analysis::Mappings::get ()->get_next_node_id ();
return Analysis::Mappings::get ().get_next_node_id ();
};
static HirId
next_hir_id ()
{
return Analysis::Mappings::get ()->get_next_hir_id ();
return Analysis::Mappings::get ().get_next_hir_id ();
};
void

View File

@ -24,7 +24,7 @@ namespace Rust {
namespace Resolver2_0 {
NameResolutionContext::NameResolutionContext ()
: mappings (*Analysis::Mappings::get ())
: mappings (Analysis::Mappings::get ())
{}
tl::expected<NodeId, DuplicateNameError>

View File

@ -274,10 +274,10 @@ Scope::decl_was_declared_here (NodeId def) const
Resolver::Resolver ()
: mappings (Analysis::Mappings::get ()), tyctx (TypeCheckContext::get ()),
name_scope (Scope (mappings->get_current_crate ())),
type_scope (Scope (mappings->get_current_crate ())),
label_scope (Scope (mappings->get_current_crate ())),
macro_scope (Scope (mappings->get_current_crate ())),
name_scope (Scope (mappings.get_current_crate ())),
type_scope (Scope (mappings.get_current_crate ())),
label_scope (Scope (mappings.get_current_crate ())),
macro_scope (Scope (mappings.get_current_crate ())),
global_type_node_id (UNKNOWN_NODEID), unit_ty_node_id (UNKNOWN_NODEID)
{
generate_builtins ();
@ -383,34 +383,34 @@ void
Resolver::generate_builtins ()
{
auto u8
= new TyTy::UintType (mappings->get_next_hir_id (), TyTy::UintType::U8);
= new TyTy::UintType (mappings.get_next_hir_id (), TyTy::UintType::U8);
auto u16
= new TyTy::UintType (mappings->get_next_hir_id (), TyTy::UintType::U16);
= new TyTy::UintType (mappings.get_next_hir_id (), TyTy::UintType::U16);
auto u32
= new TyTy::UintType (mappings->get_next_hir_id (), TyTy::UintType::U32);
= new TyTy::UintType (mappings.get_next_hir_id (), TyTy::UintType::U32);
auto u64
= new TyTy::UintType (mappings->get_next_hir_id (), TyTy::UintType::U64);
= new TyTy::UintType (mappings.get_next_hir_id (), TyTy::UintType::U64);
auto u128
= new TyTy::UintType (mappings->get_next_hir_id (), TyTy::UintType::U128);
auto i8 = new TyTy::IntType (mappings->get_next_hir_id (), TyTy::IntType::I8);
= new TyTy::UintType (mappings.get_next_hir_id (), TyTy::UintType::U128);
auto i8 = new TyTy::IntType (mappings.get_next_hir_id (), TyTy::IntType::I8);
auto i16
= new TyTy::IntType (mappings->get_next_hir_id (), TyTy::IntType::I16);
= new TyTy::IntType (mappings.get_next_hir_id (), TyTy::IntType::I16);
auto i32
= new TyTy::IntType (mappings->get_next_hir_id (), TyTy::IntType::I32);
= new TyTy::IntType (mappings.get_next_hir_id (), TyTy::IntType::I32);
auto i64
= new TyTy::IntType (mappings->get_next_hir_id (), TyTy::IntType::I64);
= new TyTy::IntType (mappings.get_next_hir_id (), TyTy::IntType::I64);
auto i128
= new TyTy::IntType (mappings->get_next_hir_id (), TyTy::IntType::I128);
auto rbool = new TyTy::BoolType (mappings->get_next_hir_id ());
= new TyTy::IntType (mappings.get_next_hir_id (), TyTy::IntType::I128);
auto rbool = new TyTy::BoolType (mappings.get_next_hir_id ());
auto f32
= new TyTy::FloatType (mappings->get_next_hir_id (), TyTy::FloatType::F32);
= new TyTy::FloatType (mappings.get_next_hir_id (), TyTy::FloatType::F32);
auto f64
= new TyTy::FloatType (mappings->get_next_hir_id (), TyTy::FloatType::F64);
auto usize = new TyTy::USizeType (mappings->get_next_hir_id ());
auto isize = new TyTy::ISizeType (mappings->get_next_hir_id ());
auto char_tyty = new TyTy::CharType (mappings->get_next_hir_id ());
auto str = new TyTy::StrType (mappings->get_next_hir_id ());
auto never = new TyTy::NeverType (mappings->get_next_hir_id ());
= new TyTy::FloatType (mappings.get_next_hir_id (), TyTy::FloatType::F64);
auto usize = new TyTy::USizeType (mappings.get_next_hir_id ());
auto isize = new TyTy::ISizeType (mappings.get_next_hir_id ());
auto char_tyty = new TyTy::CharType (mappings.get_next_hir_id ());
auto str = new TyTy::StrType (mappings.get_next_hir_id ());
auto never = new TyTy::NeverType (mappings.get_next_hir_id ());
setup_builtin ("u8", u8);
setup_builtin ("u16", u16);
@ -433,7 +433,7 @@ Resolver::generate_builtins ()
// unit type ()
TyTy::TupleType *unit_tyty
= TyTy::TupleType::get_unit_type (mappings->get_next_hir_id ());
= TyTy::TupleType::get_unit_type (mappings.get_next_hir_id ());
std::vector<std::unique_ptr<AST::Type> > elems;
AST::TupleType *unit_type
= new AST::TupleType (std::move (elems), BUILTINS_LOCATION);
@ -455,8 +455,8 @@ Resolver::setup_builtin (const std::string &name, TyTy::BaseType *tyty)
= new AST::TypePath (::std::move (segs), BUILTINS_LOCATION, false);
builtins.push_back (builtin_type);
tyctx->insert_builtin (tyty->get_ref (), builtin_type->get_node_id (), tyty);
mappings->insert_node_to_hir (builtin_type->get_node_id (), tyty->get_ref ());
mappings->insert_canonical_path (
mappings.insert_node_to_hir (builtin_type->get_node_id (), tyty->get_ref ());
mappings.insert_canonical_path (
builtin_type->get_node_id (),
CanonicalPath::new_seg (builtin_type->get_node_id (), name));
}

View File

@ -210,7 +210,7 @@ private:
void generate_builtins ();
void setup_builtin (const std::string &name, TyTy::BaseType *tyty);
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
TypeCheckContext *tyctx;
std::vector<AST::Type *> builtins;

View File

@ -182,9 +182,9 @@ TopLevel::visit (AST::Module &module)
ctx.scoped (Rib::Kind::Module, module.get_node_id (), sub_visitor,
module.get_name ());
if (Analysis::Mappings::get ()->lookup_ast_module (module.get_node_id ())
if (Analysis::Mappings::get ().lookup_ast_module (module.get_node_id ())
== tl::nullopt)
Analysis::Mappings::get ()->insert_ast_module (&module);
Analysis::Mappings::get ().insert_ast_module (&module);
}
void
@ -230,17 +230,15 @@ insert_macros (std::vector<PROC_MACRO> &macros, NameResolutionContext &ctx)
void
TopLevel::visit (AST::ExternCrate &crate)
{
auto &mappings = Analysis::Mappings::get ();
CrateNum num;
rust_assert (Analysis::Mappings::get ()->lookup_crate_name (
crate.get_referenced_crate (), num));
rust_assert (mappings.lookup_crate_name (crate.get_referenced_crate (), num));
auto attribute_macros
= Analysis::Mappings::get ()->lookup_attribute_proc_macros (num);
auto attribute_macros = mappings.lookup_attribute_proc_macros (num);
auto bang_macros = Analysis::Mappings::get ()->lookup_bang_proc_macros (num);
auto bang_macros = mappings.lookup_bang_proc_macros (num);
auto derive_macros
= Analysis::Mappings::get ()->lookup_derive_proc_macros (num);
auto derive_macros = mappings.lookup_derive_proc_macros (num);
auto sub_visitor = [&] () {
// TODO: Find a way to keep this part clean without the double dispatch.
@ -248,19 +246,19 @@ TopLevel::visit (AST::ExternCrate &crate)
{
insert_macros (derive_macros.value (), ctx);
for (auto &macro : derive_macros.value ())
Analysis::Mappings::get ()->insert_derive_proc_macro_def (macro);
mappings.insert_derive_proc_macro_def (macro);
}
if (attribute_macros.has_value ())
{
insert_macros (attribute_macros.value (), ctx);
for (auto &macro : attribute_macros.value ())
Analysis::Mappings::get ()->insert_attribute_proc_macro_def (macro);
mappings.insert_attribute_proc_macro_def (macro);
}
if (bang_macros.has_value ())
{
insert_macros (bang_macros.value (), ctx);
for (auto &macro : bang_macros.value ())
Analysis::Mappings::get ()->insert_bang_proc_macro_def (macro);
mappings.insert_bang_proc_macro_def (macro);
}
};
@ -309,12 +307,12 @@ TopLevel::visit (AST::MacroRulesDefinition &macro)
if (macro.get_kind () == AST::MacroRulesDefinition::MacroKind::DeclMacro)
insert_or_error_out (macro.get_rule_name (), macro, Namespace::Macros);
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
AST::MacroRulesDefinition *tmp = nullptr;
if (mappings->lookup_macro_def (macro.get_node_id (), &tmp))
if (mappings.lookup_macro_def (macro.get_node_id (), &tmp))
return;
mappings->insert_macro_def (&macro);
mappings.insert_macro_def (&macro);
}
void
@ -442,7 +440,7 @@ TopLevel::handle_use_glob (AST::SimplePath &glob)
return false;
auto result
= Analysis::Mappings::get ()->lookup_ast_module (resolved->get_node_id ());
= Analysis::Mappings::get ().lookup_ast_module (resolved->get_node_id ());
if (!result.has_value ())
return false;

View File

@ -85,7 +85,7 @@ const size_t kMaxNameLength = 64;
Session &
Session::get_instance ()
{
static Session instance;
static Session instance{};
return instance;
}
@ -409,8 +409,8 @@ Session::handle_input_files (int num_files, const char **files)
options.set_crate_name (crate_name);
}
CrateNum crate_num = mappings->get_next_crate_num (options.get_crate_name ());
mappings->set_current_crate (crate_num);
CrateNum crate_num = mappings.get_next_crate_num (options.get_crate_name ());
mappings.set_current_crate (crate_num);
rust_debug ("Attempting to parse file: %s", file);
compile_crate (file);
@ -419,7 +419,7 @@ Session::handle_input_files (int num_files, const char **files)
void
Session::handle_crate_name (const AST::Crate &parsed_crate)
{
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
auto crate_name_changed = false;
auto error = Error (UNDEF_LOCATION, std::string ());
@ -454,7 +454,7 @@ Session::handle_crate_name (const AST::Crate &parsed_crate)
}
crate_name_changed = true;
options.set_crate_name (msg_str);
mappings->set_crate_name (mappings->get_current_crate (), msg_str);
mappings.set_crate_name (mappings.get_current_crate (), msg_str);
}
options.crate_name_set_manually |= crate_name_changed;
@ -549,9 +549,9 @@ Session::compile_crate (const char *filename)
return;
// setup the mappings for this AST
CrateNum current_crate = mappings->get_current_crate ();
CrateNum current_crate = mappings.get_current_crate ();
AST::Crate &parsed_crate
= mappings->insert_ast_crate (std::move (ast_crate), current_crate);
= mappings.insert_ast_crate (std::move (ast_crate), current_crate);
/* basic pipeline:
* - lex
@ -647,7 +647,7 @@ Session::compile_crate (const char *filename)
return;
// add the mappings to it
HIR::Crate &hir = mappings->insert_hir_crate (std::move (lowered));
HIR::Crate &hir = mappings.insert_hir_crate (std::move (lowered));
if (options.dump_option_enabled (CompileOptions::HIR_DUMP))
{
dump_hir (hir);
@ -1049,12 +1049,12 @@ Session::load_extern_crate (const std::string &crate_name, location_t locus)
{
// has it already been loaded?
CrateNum found_crate_num = UNKNOWN_CRATENUM;
bool found = mappings->lookup_crate_name (crate_name, found_crate_num);
bool found = mappings.lookup_crate_name (crate_name, found_crate_num);
if (found)
{
NodeId resolved_node_id = UNKNOWN_NODEID;
bool resolved
= mappings->crate_num_to_nodeid (found_crate_num, resolved_node_id);
= mappings.crate_num_to_nodeid (found_crate_num, resolved_node_id);
rust_assert (resolved);
return resolved_node_id;
@ -1107,7 +1107,7 @@ Session::load_extern_crate (const std::string &crate_name, location_t locus)
}
// ensure the current vs this crate name don't collide
const std::string current_crate_name = mappings->get_current_crate_name ();
const std::string current_crate_name = mappings.get_current_crate_name ();
if (current_crate_name.compare (extern_crate.get_crate_name ()) == 0)
{
rust_error_at (locus, "current crate name %<%s%> collides with this",
@ -1116,10 +1116,10 @@ Session::load_extern_crate (const std::string &crate_name, location_t locus)
}
// setup mappings
CrateNum saved_crate_num = mappings->get_current_crate ();
CrateNum saved_crate_num = mappings.get_current_crate ();
CrateNum crate_num
= mappings->get_next_crate_num (extern_crate.get_crate_name ());
mappings->set_current_crate (crate_num);
= mappings.get_next_crate_num (extern_crate.get_crate_name ());
mappings.set_current_crate (crate_num);
// then lets parse this as a 2nd crate
Lexer lex (extern_crate.get_metadata (), linemap);
@ -1127,7 +1127,7 @@ Session::load_extern_crate (const std::string &crate_name, location_t locus)
std::unique_ptr<AST::Crate> metadata_crate = parser.parse_crate ();
AST::Crate &parsed_crate
= mappings->insert_ast_crate (std::move (metadata_crate), crate_num);
= mappings.insert_ast_crate (std::move (metadata_crate), crate_num);
std::vector<AttributeProcMacro> attribute_macros;
std::vector<CustomDeriveProcMacro> derive_macros;
@ -1151,9 +1151,9 @@ Session::load_extern_crate (const std::string &crate_name, location_t locus)
}
}
mappings->insert_attribute_proc_macros (crate_num, attribute_macros);
mappings->insert_bang_proc_macros (crate_num, bang_macros);
mappings->insert_derive_proc_macros (crate_num, derive_macros);
mappings.insert_attribute_proc_macros (crate_num, attribute_macros);
mappings.insert_bang_proc_macros (crate_num, bang_macros);
mappings.insert_derive_proc_macros (crate_num, derive_macros);
// name resolve it
Resolver::NameResolution::Resolve (parsed_crate);
@ -1161,13 +1161,13 @@ Session::load_extern_crate (const std::string &crate_name, location_t locus)
// perform hir lowering
std::unique_ptr<HIR::Crate> lowered
= HIR::ASTLowering::Resolve (parsed_crate);
HIR::Crate &hir = mappings->insert_hir_crate (std::move (lowered));
HIR::Crate &hir = mappings.insert_hir_crate (std::move (lowered));
// perform type resolution
Resolver::TypeResolution::Resolve (hir);
// always restore the crate_num
mappings->set_current_crate (saved_crate_num);
mappings.set_current_crate (saved_crate_num);
return parsed_crate.get_node_id ();
}

View File

@ -354,13 +354,12 @@ struct Session
Linemap *linemap;
// mappings
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
public:
/* Get a reference to the static session instance */
static Session &get_instance ();
Session () = default;
~Session () = default;
/* This initializes the compiler session. Corresponds to langhook
@ -391,6 +390,7 @@ public:
NodeId load_extern_crate (const std::string &crate_name, location_t locus);
private:
Session () : mappings (Analysis::Mappings::get ()) {}
void compile_crate (const char *filename);
bool enable_dump (std::string arg);

View File

@ -104,14 +104,14 @@ Adjuster::try_unsize_type (TyTy::BaseType *ty)
if (!is_valid_type)
return Adjustment::get_error ();
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
auto context = TypeCheckContext::get ();
const auto ref_base = static_cast<const TyTy::ArrayType *> (ty);
auto slice_elem = ref_base->get_element_type ();
auto slice
= new TyTy::SliceType (mappings->get_next_hir_id (), ty->get_ident ().locus,
= new TyTy::SliceType (mappings.get_next_hir_id (), ty->get_ident ().locus,
TyTy::TyVar (slice_elem->get_ref ()));
context->insert_implicit_type (slice);
@ -125,13 +125,13 @@ resolve_operator_overload_fn (
Adjustment::AdjustmentType *requires_ref_adjustment)
{
auto context = TypeCheckContext::get ();
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
// look up lang item for arithmetic type
std::string associated_item_name = LangItem::ToString (lang_item_type);
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
= mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
= mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
if (!lang_item_defined)
return false;
@ -293,7 +293,7 @@ resolve_operator_overload_fn (
rust_assert (lookup->get_kind () == TyTy::TypeKind::FNDEF);
fn = static_cast<TyTy::FnType *> (lookup);
location_t unify_locus = mappings->lookup_location (lhs->get_ref ());
location_t unify_locus = mappings.lookup_location (lhs->get_ref ());
unify_site (lhs->get_ref (),
TyTy::TyWithLocation (fn->get_self_type ()),
TyTy::TyWithLocation (adjusted_self), unify_locus);

View File

@ -74,7 +74,7 @@ TypeCoercionRules::do_coercion (TyTy::BaseType *receiver)
// here, we would coerce from `!` to `?T`.
if (expected->has_substitutions_defined () && !expected->is_concrete ())
{
location_t locus = mappings->lookup_location (receiver->get_ref ());
location_t locus = mappings.lookup_location (receiver->get_ref ());
TyTy::TyVar implicit_var
= TyTy::TyVar::get_implicit_infer_var (locus);
try_result = CoercionResult{{}, implicit_var.get_tyty ()};
@ -116,8 +116,8 @@ TypeCoercionRules::do_coercion (TyTy::BaseType *receiver)
}
else if (unsafe_error)
{
// location_t lhs = mappings->lookup_location (receiver->get_ref ());
// location_t rhs = mappings->lookup_location (expected->get_ref ());
// location_t lhs = mappings.lookup_location (receiver->get_ref ());
// location_t rhs = mappings.lookup_location (expected->get_ref ());
// object_unsafe_error (locus, lhs, rhs);
return false;
}
@ -215,8 +215,8 @@ TypeCoercionRules::coerce_unsafe_ptr (TyTy::BaseType *receiver,
if (!coerceable_mutability (from_mutbl, to_mutbl))
{
location_t lhs = mappings->lookup_location (receiver->get_ref ());
location_t rhs = mappings->lookup_location (expected->get_ref ());
location_t lhs = mappings.lookup_location (receiver->get_ref ());
location_t rhs = mappings.lookup_location (expected->get_ref ());
mismatched_mutability_error (locus, lhs, rhs);
return TypeCoercionRules::CoercionResult::get_error ();
}
@ -294,8 +294,8 @@ TypeCoercionRules::coerce_borrowed_pointer (TyTy::BaseType *receiver,
if (!coerceable_mutability (from_mutbl, to_mutbl))
{
location_t lhs = mappings->lookup_location (receiver->get_ref ());
location_t rhs = mappings->lookup_location (expected->get_ref ());
location_t lhs = mappings.lookup_location (receiver->get_ref ());
location_t rhs = mappings.lookup_location (expected->get_ref ());
mismatched_mutability_error (locus, lhs, rhs);
return TypeCoercionRules::CoercionResult::get_error ();
}
@ -339,8 +339,8 @@ TypeCoercionRules::coerce_unsized (TyTy::BaseType *source,
if (!coerceable_mutability (from_mutbl, to_mutbl))
{
unsafe_error = true;
location_t lhs = mappings->lookup_location (source->get_ref ());
location_t rhs = mappings->lookup_location (target->get_ref ());
location_t lhs = mappings.lookup_location (source->get_ref ());
location_t rhs = mappings.lookup_location (target->get_ref ());
mismatched_mutability_error (locus, lhs, rhs);
return TypeCoercionRules::CoercionResult::get_error ();
}
@ -364,8 +364,8 @@ TypeCoercionRules::coerce_unsized (TyTy::BaseType *source,
if (!coerceable_mutability (from_mutbl, to_mutbl))
{
unsafe_error = true;
location_t lhs = mappings->lookup_location (source->get_ref ());
location_t rhs = mappings->lookup_location (target->get_ref ());
location_t lhs = mappings.lookup_location (source->get_ref ());
location_t rhs = mappings.lookup_location (target->get_ref ());
mismatched_mutability_error (locus, lhs, rhs);
return TypeCoercionRules::CoercionResult::get_error ();
}

View File

@ -81,7 +81,7 @@ protected:
private:
// context info
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
TypeCheckContext *context;
// search

View File

@ -122,7 +122,7 @@ MethodResolver::select (TyTy::BaseType &receiver)
// assemble inherent impl items
std::vector<impl_item_candidate> inherent_impl_fns;
mappings->iterate_impl_items (
mappings.iterate_impl_items (
[&] (HirId id, HIR::ImplItem *item, HIR::ImplBlock *impl) mutable -> bool {
bool is_trait_impl = impl->has_trait_ref ();
if (is_trait_impl)
@ -200,7 +200,7 @@ MethodResolver::select (TyTy::BaseType &receiver)
};
std::vector<trait_item_candidate> trait_fns;
mappings->iterate_impl_blocks (
mappings.iterate_impl_blocks (
[&] (HirId id, HIR::ImplBlock *impl) mutable -> bool {
bool is_trait_impl = impl->has_trait_ref ();
if (!is_trait_impl)

View File

@ -33,7 +33,7 @@ public:
OverlappingImplItemPass pass;
// generate mappings
pass.mappings->iterate_impl_items (
pass.mappings.iterate_impl_items (
[&] (HirId id, HIR::ImplItem *impl_item, HIR::ImplBlock *impl) -> bool {
// ignoring trait-impls might need thought later on
if (impl->has_trait_ref ())

View File

@ -277,7 +277,7 @@ PathProbeType::process_enum_item_for_candiates (const TyTy::ADTType *adt)
PathProbeCandidate::EnumItemCandidate enum_item_candidate{adt, v};
PathProbeCandidate candidate{PathProbeCandidate::CandidateType::ENUM_VARIANT,
receiver->clone (),
mappings->lookup_location (adt->get_ty_ref ()),
mappings.lookup_location (adt->get_ty_ref ()),
enum_item_candidate};
candidates.insert (std::move (candidate));
}
@ -285,7 +285,7 @@ PathProbeType::process_enum_item_for_candiates (const TyTy::ADTType *adt)
void
PathProbeType::process_impl_items_for_candidates ()
{
mappings->iterate_impl_items (
mappings.iterate_impl_items (
[&] (HirId id, HIR::ImplItem *item, HIR::ImplBlock *impl) mutable -> bool {
process_impl_item_candidate (id, item, impl);
return true;
@ -465,7 +465,7 @@ PathProbeImplTrait::Probe (const TyTy::BaseType *receiver,
void
PathProbeImplTrait::process_trait_impl_items_for_candidates ()
{
mappings->iterate_impl_items (
mappings.iterate_impl_items (
[&] (HirId id, HIR::ImplItem *item, HIR::ImplBlock *impl) mutable -> bool {
// just need to check if this is an impl block for this trait the next
// function checks the receiver

View File

@ -118,13 +118,13 @@ TraitResolver::resolve_path_to_trait (const HIR::TypePath &path,
}
HirId hir_node = UNKNOWN_HIRID;
if (!mappings->lookup_node_to_hir (ref, &hir_node))
if (!mappings.lookup_node_to_hir (ref, &hir_node))
{
rust_error_at (path.get_locus (), "Failed to resolve path to hir-id");
return false;
}
HIR::Item *resolved_item = mappings->lookup_hir_item (hir_node);
HIR::Item *resolved_item = mappings.lookup_hir_item (hir_node);
rust_assert (resolved_item != nullptr);
rust_assert (resolved_item->get_item_kind () == HIR::Item::ItemKind::Trait);
*resolved = static_cast<HIR::Trait *> (resolved_item);
@ -665,10 +665,10 @@ AssociatedImplTrait::reset_associated_types ()
Analysis::NodeMapping
TraitItemReference::get_parent_trait_mappings () const
{
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
HIR::Trait *trait
= mappings->lookup_trait_item_mapping (get_mappings ().get_hirid ());
= mappings.lookup_trait_item_mapping (get_mappings ().get_hirid ());
rust_assert (trait != nullptr);
return trait->get_mappings ();

View File

@ -238,9 +238,9 @@ TypeCheckBase::resolve_literal (const Analysis::NodeMapping &expr_mappings,
auto ok = context->lookup_builtin ("u8", &u8);
rust_assert (ok);
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping capacity_mapping (crate_num, UNKNOWN_NODEID,
mappings->get_next_hir_id (
mappings.get_next_hir_id (
crate_num),
UNKNOWN_LOCAL_DEFID);
@ -260,7 +260,7 @@ TypeCheckBase::resolve_literal (const Analysis::NodeMapping &expr_mappings,
context->insert_type (capacity_mapping, expected_ty);
Analysis::NodeMapping array_mapping (crate_num, UNKNOWN_NODEID,
mappings->get_next_hir_id (
mappings.get_next_hir_id (
crate_num),
UNKNOWN_LOCAL_DEFID);
@ -413,8 +413,8 @@ TypeCheckBase::resolve_generic_params (
TyTy::TypeBoundPredicate
TypeCheckBase::get_marker_predicate (LangItem::Kind item_type, location_t locus)
{
DefId item_id = mappings->get_lang_item (item_type, locus);
HIR::Item *item = mappings->lookup_defid (item_id);
DefId item_id = mappings.get_lang_item (item_type, locus);
HIR::Item *item = mappings.lookup_defid (item_id);
rust_assert (item != nullptr);
rust_assert (item->get_item_kind () == HIR::Item::ItemKind::Trait);

View File

@ -61,7 +61,7 @@ protected:
TyTy::TypeBoundPredicate get_marker_predicate (LangItem::Kind item_type,
location_t locus);
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
Resolver *resolver;
TypeCheckContext *context;
};

View File

@ -61,7 +61,7 @@ TypeCheckEnumItem::visit (HIR::EnumItem &item)
Analysis::NodeMapping mapping (item.get_mappings ().get_crate_num (),
item.get_mappings ().get_nodeid (),
mappings->get_next_hir_id (
mappings.get_next_hir_id (
item.get_mappings ().get_crate_num ()),
item.get_mappings ().get_local_defid ());
HIR::LiteralExpr *discim_expr
@ -76,8 +76,8 @@ TypeCheckEnumItem::visit (HIR::EnumItem &item)
context->insert_type (mapping, isize);
const CanonicalPath *canonical_path = nullptr;
ok = mappings->lookup_canonical_path (item.get_mappings ().get_nodeid (),
&canonical_path);
ok = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid (),
&canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, item.get_locus ()};
@ -107,8 +107,8 @@ TypeCheckEnumItem::visit (HIR::EnumItemDiscriminant &item)
TyTy::TyWithLocation (capacity_type), item.get_locus ());
const CanonicalPath *canonical_path = nullptr;
bool ok = mappings->lookup_canonical_path (item.get_mappings ().get_nodeid (),
&canonical_path);
bool ok = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid (),
&canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, item.get_locus ()};
@ -141,7 +141,7 @@ TypeCheckEnumItem::visit (HIR::EnumItemTuple &item)
Analysis::NodeMapping mapping (item.get_mappings ().get_crate_num (),
item.get_mappings ().get_nodeid (),
mappings->get_next_hir_id (
mappings.get_next_hir_id (
item.get_mappings ().get_crate_num ()),
item.get_mappings ().get_local_defid ());
HIR::LiteralExpr *discim_expr
@ -156,8 +156,8 @@ TypeCheckEnumItem::visit (HIR::EnumItemTuple &item)
context->insert_type (mapping, isize);
const CanonicalPath *canonical_path = nullptr;
ok = mappings->lookup_canonical_path (item.get_mappings ().get_nodeid (),
&canonical_path);
ok = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid (),
&canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, item.get_locus ()};
@ -189,7 +189,7 @@ TypeCheckEnumItem::visit (HIR::EnumItemStruct &item)
Analysis::NodeMapping mapping (item.get_mappings ().get_crate_num (),
item.get_mappings ().get_nodeid (),
mappings->get_next_hir_id (
mappings.get_next_hir_id (
item.get_mappings ().get_crate_num ()),
item.get_mappings ().get_local_defid ());
HIR::LiteralExpr *discrim_expr
@ -204,8 +204,8 @@ TypeCheckEnumItem::visit (HIR::EnumItemStruct &item)
context->insert_type (mapping, isize);
const CanonicalPath *canonical_path = nullptr;
ok = mappings->lookup_canonical_path (item.get_mappings ().get_nodeid (),
&canonical_path);
ok = mappings.lookup_canonical_path (item.get_mappings ().get_nodeid (),
&canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, item.get_locus ()};

View File

@ -630,7 +630,7 @@ TypeCheckExpr::visit (HIR::RangeFromToExpr &expr)
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
= mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
= mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// we need to have it maybe
if (!lang_item_defined)
@ -642,7 +642,7 @@ TypeCheckExpr::visit (HIR::RangeFromToExpr &expr)
}
// look it up and it _must_ be a struct definition
HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item != nullptr);
TyTy::BaseType *item_type = nullptr;
@ -685,7 +685,7 @@ TypeCheckExpr::visit (HIR::RangeFromExpr &expr)
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
= mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
= mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// we need to have it maybe
if (!lang_item_defined)
@ -697,7 +697,7 @@ TypeCheckExpr::visit (HIR::RangeFromExpr &expr)
}
// look it up and it _must_ be a struct definition
HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item != nullptr);
TyTy::BaseType *item_type = nullptr;
@ -733,7 +733,7 @@ TypeCheckExpr::visit (HIR::RangeToExpr &expr)
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
= mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
= mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// we need to have it maybe
if (!lang_item_defined)
@ -745,7 +745,7 @@ TypeCheckExpr::visit (HIR::RangeToExpr &expr)
}
// look it up and it _must_ be a struct definition
HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item != nullptr);
TyTy::BaseType *item_type = nullptr;
@ -780,7 +780,7 @@ TypeCheckExpr::visit (HIR::RangeFullExpr &expr)
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
= mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
= mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// we need to have it maybe
if (!lang_item_defined)
@ -792,7 +792,7 @@ TypeCheckExpr::visit (HIR::RangeFullExpr &expr)
}
// look it up and it _must_ be a struct definition
HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item != nullptr);
TyTy::BaseType *item_type = nullptr;
@ -811,7 +811,7 @@ TypeCheckExpr::visit (HIR::RangeFromToInclExpr &expr)
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
= mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
= mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// we need to have it maybe
if (!lang_item_defined)
@ -823,7 +823,7 @@ TypeCheckExpr::visit (HIR::RangeFromToInclExpr &expr)
}
// look it up and it _must_ be a struct definition
HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item != nullptr);
TyTy::BaseType *item_type = nullptr;
@ -982,9 +982,9 @@ TypeCheckExpr::visit (HIR::ArrayExpr &expr)
expr.get_locus ());
}
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, UNKNOWN_NODEID,
mappings->get_next_hir_id (crate_num),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
std::string capacity_str = std::to_string (elems.get_num_elements ());
capacity_expr = new HIR::LiteralExpr (mapping, capacity_str,
@ -1548,7 +1548,7 @@ TypeCheckExpr::visit (HIR::ClosureExpr &expr)
}
// we generate an implicit hirid for the closure args
HirId implicit_args_id = mappings->get_next_hir_id ();
HirId implicit_args_id = mappings.get_next_hir_id ();
TyTy::TupleType *closure_args
= new TyTy::TupleType (implicit_args_id, expr.get_locus (),
parameter_types);
@ -1587,7 +1587,7 @@ TypeCheckExpr::visit (HIR::ClosureExpr &expr)
LangItem::Kind lang_item_type = LangItem::Kind::FN_ONCE;
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
= mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
= mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
if (!lang_item_defined)
{
// FIXME
@ -1599,7 +1599,7 @@ TypeCheckExpr::visit (HIR::ClosureExpr &expr)
rust_assert (lang_item_defined);
// these lang items are always traits
HIR::Item *item = mappings->lookup_defid (respective_lang_item_id);
HIR::Item *item = mappings.lookup_defid (respective_lang_item_id);
rust_assert (item->get_item_kind () == HIR::Item::ItemKind::Trait);
HIR::Trait *trait_item = static_cast<HIR::Trait *> (item);
@ -1614,7 +1614,7 @@ TypeCheckExpr::visit (HIR::ClosureExpr &expr)
// lets generate an implicit Type so that it resolves to the implict tuple
// type we have created
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_mappings ().get_nodeid (),
implicit_args_id, UNKNOWN_LOCAL_DEFID);
HIR::TupleType *implicit_tuple
@ -1642,7 +1642,7 @@ TypeCheckExpr::resolve_operator_overload (LangItem::Kind lang_item_type,
std::string associated_item_name = LangItem::ToString (lang_item_type);
DefId respective_lang_item_id = UNKNOWN_DEFID;
bool lang_item_defined
= mappings->lookup_lang_item (lang_item_type, &respective_lang_item_id);
= mappings.lookup_lang_item (lang_item_type, &respective_lang_item_id);
// probe for the lang-item
if (!lang_item_defined)
@ -1972,8 +1972,8 @@ TypeCheckExpr::resolve_fn_trait_call (HIR::CallExpr &expr,
}
// crate implicit tuple
HirId implicit_arg_id = mappings->get_next_hir_id ();
Analysis::NodeMapping mapping (mappings->get_current_crate (), UNKNOWN_NODEID,
HirId implicit_arg_id = mappings.get_next_hir_id ();
Analysis::NodeMapping mapping (mappings.get_current_crate (), UNKNOWN_NODEID,
implicit_arg_id, UNKNOWN_LOCAL_DEFID);
TyTy::TupleType *tuple

View File

@ -134,9 +134,9 @@ TypeCheckTopLevelExternItem::visit (HIR::ExternalFunctionItem &function)
auto param_tyty = TypeCheckType::Resolve (param.get_type ().get ());
// these are implicit mappings and not used
auto crate_num = mappings->get_current_crate ();
Analysis::NodeMapping mapping (crate_num, mappings->get_next_node_id (),
mappings->get_next_hir_id (crate_num),
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, mappings.get_next_node_id (),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
HIR::IdentifierPattern *param_pattern
@ -377,9 +377,9 @@ TypeCheckImplItem::visit (HIR::Function &function)
if (function.is_method ())
{
// these are implicit mappings and not used
auto crate_num = mappings->get_current_crate ();
Analysis::NodeMapping mapping (crate_num, mappings->get_next_node_id (),
mappings->get_next_hir_id (crate_num),
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, mappings.get_next_node_id (),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
// add the synthetic self param at the front, this is a placeholder for
@ -463,8 +463,8 @@ TypeCheckImplItem::visit (HIR::Function &function)
const CanonicalPath *canonical_path = nullptr;
bool ok
= mappings->lookup_canonical_path (function.get_mappings ().get_nodeid (),
&canonical_path);
= mappings.lookup_canonical_path (function.get_mappings ().get_nodeid (),
&canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, function.get_locus ()};

View File

@ -206,7 +206,7 @@ TypeCheckItem::visit (HIR::TupleStruct &struct_decl)
else
{
const CanonicalPath *canonical_path = nullptr;
bool ok = mappings->lookup_canonical_path (
bool ok = mappings.lookup_canonical_path (
struct_decl.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);
@ -230,7 +230,7 @@ TypeCheckItem::visit (HIR::TupleStruct &struct_decl)
= parse_repr_options (attrs, struct_decl.get_locus ());
auto *type = new TyTy::ADTType (
struct_decl.get_mappings ().get_hirid (), mappings->get_next_hir_id (),
struct_decl.get_mappings ().get_hirid (), mappings.get_next_hir_id (),
struct_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::TUPLE_STRUCT, std::move (variants),
std::move (substitutions), repr,
@ -289,7 +289,7 @@ TypeCheckItem::visit (HIR::StructStruct &struct_decl)
else
{
const CanonicalPath *canonical_path = nullptr;
bool ok = mappings->lookup_canonical_path (
bool ok = mappings.lookup_canonical_path (
struct_decl.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);
@ -313,7 +313,7 @@ TypeCheckItem::visit (HIR::StructStruct &struct_decl)
= parse_repr_options (attrs, struct_decl.get_locus ());
auto *type = new TyTy::ADTType (
struct_decl.get_mappings ().get_hirid (), mappings->get_next_hir_id (),
struct_decl.get_mappings ().get_hirid (), mappings.get_next_hir_id (),
struct_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::STRUCT_STRUCT, std::move (variants),
std::move (substitutions), repr,
@ -349,15 +349,15 @@ TypeCheckItem::visit (HIR::Enum &enum_decl)
// get the path
const CanonicalPath *canonical_path = nullptr;
bool ok
= mappings->lookup_canonical_path (enum_decl.get_mappings ().get_nodeid (),
&canonical_path);
= mappings.lookup_canonical_path (enum_decl.get_mappings ().get_nodeid (),
&canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, enum_decl.get_locus ()};
// multi variant ADT
auto *type
= new TyTy::ADTType (enum_decl.get_mappings ().get_hirid (),
mappings->get_next_hir_id (),
mappings.get_next_hir_id (),
enum_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::ENUM, std::move (variants),
std::move (substitutions));
@ -399,8 +399,8 @@ TypeCheckItem::visit (HIR::Union &union_decl)
// get the path
const CanonicalPath *canonical_path = nullptr;
bool ok
= mappings->lookup_canonical_path (union_decl.get_mappings ().get_nodeid (),
&canonical_path);
= mappings.lookup_canonical_path (union_decl.get_mappings ().get_nodeid (),
&canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, union_decl.get_locus ()};
@ -415,7 +415,7 @@ TypeCheckItem::visit (HIR::Union &union_decl)
auto *type
= new TyTy::ADTType (union_decl.get_mappings ().get_hirid (),
mappings->get_next_hir_id (),
mappings.get_next_hir_id (),
union_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::UNION, std::move (variants),
std::move (substitutions));
@ -568,7 +568,7 @@ TypeCheckItem::visit (HIR::Function &function)
else
{
const CanonicalPath *canonical_path = nullptr;
bool ok = mappings->lookup_canonical_path (
bool ok = mappings.lookup_canonical_path (
function.get_mappings ().get_nodeid (), &canonical_path);
rust_assert (ok);

View File

@ -230,7 +230,7 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression &expr, size_t *offset,
// node back to HIR
HirId ref;
if (!mappings->lookup_node_to_hir (ref_node_id, &ref))
if (!mappings.lookup_node_to_hir (ref_node_id, &ref))
{
rust_error_at (seg.get_locus (), "456 reverse lookup failure");
rust_debug_loc (seg.get_locus (),
@ -242,8 +242,8 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression &expr, size_t *offset,
return new TyTy::ErrorType (expr.get_mappings ().get_hirid ());
}
auto seg_is_module = (nullptr != mappings->lookup_module (ref));
auto seg_is_crate = mappings->is_local_hirid_crate (ref);
auto seg_is_module = (nullptr != mappings.lookup_module (ref));
auto seg_is_crate = mappings.is_local_hirid_crate (ref);
if (seg_is_module || seg_is_crate)
{
// A::B::C::this_is_a_module::D::E::F
@ -279,7 +279,7 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression &expr, size_t *offset,
// is it an enum item?
std::pair<HIR::Enum *, HIR::EnumItem *> enum_item_lookup
= mappings->lookup_hir_enumitem (ref);
= mappings.lookup_hir_enumitem (ref);
bool is_enum_item = enum_item_lookup.first != nullptr
&& enum_item_lookup.second != nullptr;
if (is_enum_item)
@ -389,7 +389,7 @@ TypeCheckExpr::resolve_segments (NodeId root_resolved_node_id,
HirId variant_id = variant->get_id ();
std::pair<HIR::Enum *, HIR::EnumItem *> enum_item_lookup
= mappings->lookup_hir_enumitem (variant_id);
= mappings.lookup_hir_enumitem (variant_id);
bool enum_item_ok = enum_item_lookup.first != nullptr
&& enum_item_lookup.second != nullptr;
rust_assert (enum_item_ok);

View File

@ -421,7 +421,7 @@ TypeCheckPattern::emit_pattern_size_error (const HIR::Pattern &pattern,
size_t got_field_count)
{
rich_location r (line_table, pattern.get_locus ());
r.add_range (mappings->lookup_location (parent->get_ref ()));
r.add_range (mappings.lookup_location (parent->get_ref ()));
rust_error_at (r,
"expected a tuple with %lu %s, found one "
"with %lu %s",
@ -505,8 +505,8 @@ ClosureParamInfer::Resolve (HIR::Pattern *pattern)
if (resolver.infered->get_kind () != TyTy::TypeKind::ERROR)
{
resolver.context->insert_implicit_type (resolver.infered);
resolver.mappings->insert_location (resolver.infered->get_ref (),
pattern->get_locus ());
resolver.mappings.insert_location (resolver.infered->get_ref (),
pattern->get_locus ());
}
return resolver.infered;
}

View File

@ -195,12 +195,12 @@ TypeCheckStructExpr::resolve (HIR::StructExprStructFields &struct_expr)
HIR::StructExprField *implicit_field = nullptr;
AST::AttrVec outer_attribs;
auto crate_num = mappings->get_current_crate ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (
crate_num,
struct_expr.struct_base->base_struct->get_mappings ()
.get_nodeid (),
mappings->get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID);
mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID);
HIR::Expr *field_value = new HIR::FieldAccessExpr (
mapping, std::unique_ptr<HIR::Expr> (receiver), missing,

View File

@ -87,7 +87,7 @@ TypeCheckType::visit (HIR::BareFunctionType &fntype)
else
{
// needs a new implicit ID
HirId ref = mappings->get_next_hir_id ();
HirId ref = mappings.get_next_hir_id ();
return_type = TyTy::TupleType::get_unit_type (ref);
context->insert_implicit_type (ref, return_type);
}
@ -373,7 +373,7 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset,
// node back to HIR
HirId ref = UNKNOWN_HIRID;
if (!mappings->lookup_node_to_hir (ref_node_id, &ref))
if (!mappings.lookup_node_to_hir (ref_node_id, &ref))
{
if (is_root)
{
@ -390,8 +390,8 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset,
return root_tyty;
}
auto seg_is_module = (nullptr != mappings->lookup_module (ref));
auto seg_is_crate = mappings->is_local_hirid_crate (ref);
auto seg_is_module = (nullptr != mappings.lookup_module (ref));
auto seg_is_crate = mappings.is_local_hirid_crate (ref);
if (seg_is_module || seg_is_crate)
{
// A::B::C::this_is_a_module::D::E::F
@ -780,7 +780,7 @@ TypeResolveGenericParam::visit (HIR::TypeParam &param)
// We need two possible parameter types. One with no Bounds and one with
// the bounds. the Self type for the bounds cannot itself contain the
// bounds otherwise it will be a trait cycle
HirId implicit_id = mappings->get_next_hir_id ();
HirId implicit_id = mappings.get_next_hir_id ();
TyTy::ParamType *p
= new TyTy::ParamType (param.get_type_representation ().as_string (),
param.get_locus (), implicit_id, param,
@ -998,7 +998,7 @@ ResolveWhereClauseItem::visit (HIR::TypeBoundWhereClauseItem &item)
// node back to HIR
HirId ref;
if (!mappings->lookup_node_to_hir (ref_node_id, &ref))
if (!mappings.lookup_node_to_hir (ref_node_id, &ref))
{
// FIXME
rust_error_at (UNDEF_LOCATION, "where-clause reverse lookup failure");
@ -1009,7 +1009,7 @@ ResolveWhereClauseItem::visit (HIR::TypeBoundWhereClauseItem &item)
TyTy::BaseType *lookup;
if (!context->lookup_type (ref, &lookup))
{
rust_error_at (mappings->lookup_location (ref),
rust_error_at (mappings.lookup_location (ref),
"Failed to resolve where-clause binding type: %s",
binding_type_path->as_string ().c_str ());
return;

View File

@ -222,10 +222,10 @@ TraitItemReference::get_type_from_fn (/*const*/ HIR::TraitItemFunc &fn) const
if (function.is_method ())
{
// these are implicit mappings and not used
auto mappings = Analysis::Mappings::get ();
auto crate_num = mappings->get_current_crate ();
Analysis::NodeMapping mapping (crate_num, mappings->get_next_node_id (),
mappings->get_next_hir_id (crate_num),
auto &mappings = Analysis::Mappings::get ();
auto crate_num = mappings.get_current_crate ();
Analysis::NodeMapping mapping (crate_num, mappings.get_next_node_id (),
mappings.get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
// add the synthetic self param at the front, this is a placeholder
@ -298,10 +298,10 @@ TraitItemReference::get_type_from_fn (/*const*/ HIR::TraitItemFunc &fn) const
TypeCheckPattern::Resolve (param.get_param_name ().get (), param_tyty);
}
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
const CanonicalPath *canonical_path = nullptr;
bool ok = mappings->lookup_canonical_path (fn.get_mappings ().get_nodeid (),
&canonical_path);
bool ok = mappings.lookup_canonical_path (fn.get_mappings ().get_nodeid (),
&canonical_path);
rust_assert (ok);
RustIdent ident{*canonical_path, fn.get_locus ()};

View File

@ -33,7 +33,7 @@ namespace Resolver {
bool
query_type (HirId reference, TyTy::BaseType **result)
{
Analysis::Mappings *mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
TypeCheckContext *context = TypeCheckContext::get ();
if (context->query_in_progress (reference))
@ -45,7 +45,7 @@ query_type (HirId reference, TyTy::BaseType **result)
context->insert_query (reference);
std::pair<HIR::Enum *, HIR::EnumItem *> enum_candidiate
= mappings->lookup_hir_enumitem (reference);
= mappings.lookup_hir_enumitem (reference);
bool enum_candidiate_ok
= enum_candidiate.first != nullptr && enum_candidiate.second != nullptr;
if (enum_candidiate_ok)
@ -61,7 +61,7 @@ query_type (HirId reference, TyTy::BaseType **result)
return true;
}
HIR::Item *item = mappings->lookup_hir_item (reference);
HIR::Item *item = mappings.lookup_hir_item (reference);
if (item != nullptr)
{
rust_debug_loc (item->get_locus (), "resolved item {%u} to", reference);
@ -72,11 +72,11 @@ query_type (HirId reference, TyTy::BaseType **result)
HirId parent_impl_id = UNKNOWN_HIRID;
HIR::ImplItem *impl_item
= mappings->lookup_hir_implitem (reference, &parent_impl_id);
= mappings.lookup_hir_implitem (reference, &parent_impl_id);
if (impl_item != nullptr)
{
HIR::ImplBlock *impl_block
= mappings->lookup_hir_impl_block (parent_impl_id);
= mappings.lookup_hir_impl_block (parent_impl_id);
rust_assert (impl_block != nullptr);
// found an impl item
@ -91,7 +91,7 @@ query_type (HirId reference, TyTy::BaseType **result)
// is it an impl_type?
HIR::ImplBlock *impl_block_by_type = nullptr;
bool found_impl_block_type
= mappings->lookup_impl_block_type (reference, &impl_block_by_type);
= mappings.lookup_impl_block_type (reference, &impl_block_by_type);
if (found_impl_block_type)
{
*result = TypeCheckItem::ResolveImplBlockSelf (*impl_block_by_type);
@ -102,11 +102,11 @@ query_type (HirId reference, TyTy::BaseType **result)
// is it an extern item?
HirId parent_extern_block_id = UNKNOWN_HIRID;
HIR::ExternalItem *extern_item
= mappings->lookup_hir_extern_item (reference, &parent_extern_block_id);
= mappings.lookup_hir_extern_item (reference, &parent_extern_block_id);
if (extern_item != nullptr)
{
HIR::ExternBlock *block
= mappings->lookup_hir_extern_block (parent_extern_block_id);
= mappings.lookup_hir_extern_block (parent_extern_block_id);
rust_assert (block != nullptr);
*result = TypeCheckTopLevelExternItem::Resolve (extern_item, *block);
@ -115,7 +115,7 @@ query_type (HirId reference, TyTy::BaseType **result)
}
// more?
location_t possible_locus = mappings->lookup_location (reference);
location_t possible_locus = mappings.lookup_location (reference);
rust_debug_loc (possible_locus, "query system failed to resolve: [%u]",
reference);
context->query_completed (reference);

View File

@ -580,7 +580,7 @@ TypeCheckContext::regions_from_generic_args (const HIR::GenericArgs &args) const
void
TypeCheckContext::compute_inference_variables (bool error)
{
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
// default inference variables if possible
iterate ([&] (HirId id, TyTy::BaseType *ty) mutable -> bool {
@ -591,14 +591,14 @@ TypeCheckContext::compute_inference_variables (bool error)
TyTy::InferType *infer_var = static_cast<TyTy::InferType *> (ty);
TyTy::BaseType *default_type;
rust_debug_loc (mappings->lookup_location (id),
rust_debug_loc (mappings.lookup_location (id),
"trying to default infer-var: %s",
infer_var->as_string ().c_str ());
bool ok = infer_var->default_type (&default_type);
if (!ok)
{
if (error)
rust_error_at (mappings->lookup_location (id), ErrorCode::E0282,
rust_error_at (mappings.lookup_location (id), ErrorCode::E0282,
"type annotations needed");
return true;
}
@ -609,7 +609,7 @@ TypeCheckContext::compute_inference_variables (bool error)
rust_assert (result);
rust_assert (result->get_kind () != TyTy::TypeKind::ERROR);
result->set_ref (id);
insert_type (Analysis::NodeMapping (mappings->get_current_crate (), 0, id,
insert_type (Analysis::NodeMapping (mappings.get_current_crate (), 0, id,
UNKNOWN_LOCAL_DEFID),
result);

View File

@ -64,7 +64,7 @@ TypeBoundsProbe::scan ()
{
std::vector<std::pair<HIR::TypePath *, HIR::ImplBlock *>>
possible_trait_paths;
mappings->iterate_impl_blocks (
mappings.iterate_impl_blocks (
[&] (HirId id, HIR::ImplBlock *impl) mutable -> bool {
// we are filtering for trait-impl-blocks
if (!impl->has_trait_ref ())
@ -153,11 +153,11 @@ void
TypeBoundsProbe::assemble_builtin_candidate (LangItem::Kind lang_item)
{
DefId id;
bool found_lang_item = mappings->lookup_lang_item (lang_item, &id);
bool found_lang_item = mappings.lookup_lang_item (lang_item, &id);
if (!found_lang_item)
return;
HIR::Item *item = mappings->lookup_defid (id);
HIR::Item *item = mappings.lookup_defid (id);
if (item == nullptr)
return;
@ -167,7 +167,7 @@ TypeBoundsProbe::assemble_builtin_candidate (LangItem::Kind lang_item)
// assemble the reference
TraitReference *trait_ref = TraitResolver::Resolve (*trait);
trait_references.push_back ({trait_ref, mappings->lookup_builtin_marker ()});
trait_references.push_back ({trait_ref, mappings.lookup_builtin_marker ()});
rust_debug ("Added builtin lang_item: %s for %s",
LangItem::ToString (lang_item).c_str (),
@ -220,8 +220,8 @@ TypeCheckBase::get_predicate_from_bound (HIR::TypePath &type_path,
// we need to make implicit generic args which must be an implicit
// Tuple
auto crate_num = mappings->get_current_crate ();
HirId implicit_args_id = mappings->get_next_hir_id ();
auto crate_num = mappings.get_current_crate ();
HirId implicit_args_id = mappings.get_next_hir_id ();
Analysis::NodeMapping mapping (crate_num,
final_seg->get_mappings ().get_nodeid (),
implicit_args_id, UNKNOWN_LOCAL_DEFID);
@ -244,7 +244,7 @@ TypeCheckBase::get_predicate_from_bound (HIR::TypePath &type_path,
rust_assert (fn.has_return_type ());
TypeCheckType::Resolve (fn.get_return_type ().get ());
HIR::TraitItem *trait_item = mappings->lookup_trait_item_lang_item (
HIR::TraitItem *trait_item = mappings.lookup_trait_item_lang_item (
LangItem::Kind::FN_ONCE_OUTPUT, final_seg->get_locus ());
std::vector<HIR::GenericArgsBinding> bindings;

View File

@ -157,7 +157,7 @@ TypeCheckCallExpr::visit (FnType &type)
BaseType *param_ty = fnparam.second;
location_t param_locus
= fn_param_pattern == nullptr
? mappings->lookup_location (param_ty->get_ref ())
? mappings.lookup_location (param_ty->get_ref ())
: fn_param_pattern->get_locus ();
HirId coercion_side_id = argument->get_mappings ().get_hirid ();
@ -382,7 +382,7 @@ TypeCheckMethodCallExpr::check (FnType &type)
BaseType *param_ty = fnparam.second;
location_t param_locus
= fn_param_pattern == nullptr
? mappings->lookup_location (param_ty->get_ref ())
? mappings.lookup_location (param_ty->get_ref ())
: fn_param_pattern->get_locus ();
auto argument_expr_tyty = argument.get_argument_type ();

View File

@ -81,7 +81,7 @@ private:
HIR::CallExpr &call;
TyTy::VariantDef &variant;
Resolver::TypeCheckContext *context;
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
};
class Argument
@ -131,7 +131,7 @@ protected:
location_t receiver_locus;
TyTy::BaseType *adjusted_self;
Resolver::TypeCheckContext *context;
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
};
} // namespace TyTy

View File

@ -62,9 +62,9 @@ public:
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -78,9 +78,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -94,9 +94,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -110,9 +110,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -126,9 +126,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -142,9 +142,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -158,9 +158,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -174,9 +174,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -190,9 +190,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -206,9 +206,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -222,9 +222,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -238,9 +238,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -254,9 +254,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -270,9 +270,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -286,9 +286,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -302,9 +302,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -318,9 +318,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -334,9 +334,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -350,9 +350,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -366,9 +366,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -388,9 +388,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -404,9 +404,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -420,9 +420,9 @@ public:
ok = false;
if (emit_error_flag)
{
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
location_t base_locus
= mappings->lookup_location (get_base ()->get_ref ());
= mappings.lookup_location (get_base ()->get_ref ());
rich_location r (line_table, ref_locus);
r.add_range (base_locus);
rust_error_at (r, "expected [%s] got [%s]",
@ -438,7 +438,7 @@ protected:
emit_error_flag (emit_errors)
{}
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
Resolver::TypeCheckContext *context;
bool ok;
@ -1561,7 +1561,7 @@ public:
return;
}
location_t ref_locus = mappings->lookup_location (type.get_ref ());
location_t ref_locus = mappings.lookup_location (type.get_ref ());
ok = base->bounds_compatible (type, ref_locus, false);
}

View File

@ -157,10 +157,10 @@ SubstitutionParamMapping::override_context ()
if (!param->can_resolve ())
return;
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
auto context = Resolver::TypeCheckContext::get ();
context->insert_type (Analysis::NodeMapping (mappings->get_current_crate (),
context->insert_type (Analysis::NodeMapping (mappings.get_current_crate (),
UNKNOWN_NODEID,
param->get_ref (),
UNKNOWN_LOCAL_DEFID),
@ -940,7 +940,7 @@ SubstitutionRef::monomorphize ()
if (associated == nullptr && ambigious)
{
// go for the first one? or error out?
auto &mappings = *Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
const auto &type_param = subst.get_generic_param ();
const auto *trait_ref = bound.get ();

View File

@ -44,18 +44,18 @@ TyVar::get_tyty () const
TyVar
TyVar::get_implicit_infer_var (location_t locus)
{
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
auto context = Resolver::TypeCheckContext::get ();
InferType *infer = new InferType (mappings->get_next_hir_id (),
InferType *infer = new InferType (mappings.get_next_hir_id (),
InferType::InferTypeKind::GENERAL,
InferType::TypeHint::Default (), locus);
context->insert_type (Analysis::NodeMapping (mappings->get_current_crate (),
context->insert_type (Analysis::NodeMapping (mappings.get_current_crate (),
UNKNOWN_NODEID,
infer->get_ref (),
UNKNOWN_LOCAL_DEFID),
infer);
mappings->insert_location (infer->get_ref (), locus);
mappings.insert_location (infer->get_ref (), locus);
return TyVar (infer->get_ref ());
}
@ -87,15 +87,15 @@ TyVar::clone () const
TyVar
TyVar::monomorphized_clone () const
{
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
auto context = Resolver::TypeCheckContext::get ();
// this needs a new hirid
TyTy::BaseType *c = get_tyty ()->monomorphized_clone ();
c->set_ref (mappings->get_next_hir_id ());
c->set_ref (mappings.get_next_hir_id ());
// insert it
context->insert_type (Analysis::NodeMapping (mappings->get_current_crate (),
context->insert_type (Analysis::NodeMapping (mappings.get_current_crate (),
UNKNOWN_NODEID, c->get_ref (),
UNKNOWN_LOCAL_DEFID),
c);
@ -109,8 +109,8 @@ TyWithLocation::TyWithLocation (BaseType *ty, location_t locus)
TyWithLocation::TyWithLocation (BaseType *ty) : ty (ty)
{
auto mappings = Analysis::Mappings::get ();
locus = mappings->lookup_location (ty->get_ref ());
auto &mappings = Analysis::Mappings::get ();
locus = mappings.lookup_location (ty->get_ref ());
}
} // namespace TyTy

View File

@ -350,9 +350,9 @@ BaseType::satisfies_bound (const TypeBoundPredicate &predicate,
if (emit_error)
{
rich_location r (line_table,
mappings->lookup_location (get_ref ()));
mappings.lookup_location (get_ref ()));
r.add_range (predicate.get_locus ());
r.add_range (mappings->lookup_location (i.get_hirid ()));
r.add_range (mappings.lookup_location (i.get_hirid ()));
std::string rich_msg
= "expected " + bound_ty->destructure ()->get_name ()
@ -960,20 +960,20 @@ InferType::clone () const
// chain of references accordingly to ensure we don't loose the ability to
// update the inference variables when we solve the type
auto mappings = Analysis::Mappings::get ();
auto &mappings = Analysis::Mappings::get ();
auto context = Resolver::TypeCheckContext::get ();
InferType *clone
= new InferType (mappings->get_next_hir_id (), get_infer_kind (),
= new InferType (mappings.get_next_hir_id (), get_infer_kind (),
default_hint, get_ident ().locus, get_combined_refs ());
context->insert_type (Analysis::NodeMapping (mappings->get_current_crate (),
context->insert_type (Analysis::NodeMapping (mappings.get_current_crate (),
UNKNOWN_NODEID,
clone->get_ref (),
UNKNOWN_LOCAL_DEFID),
clone);
mappings->insert_location (clone->get_ref (),
mappings->lookup_location (get_ref ()));
mappings.insert_location (clone->get_ref (),
mappings.lookup_location (get_ref ()));
// setup the chain to reference this
clone->append_reference (get_ref ());
@ -1702,7 +1702,7 @@ ADTType *
ADTType::handle_substitions (SubstitutionArgumentMappings &subst_mappings)
{
auto adt = clone ()->as<ADTType> ();
adt->set_ty_ref (mappings->get_next_hir_id ());
adt->set_ty_ref (mappings.get_next_hir_id ());
adt->used_arguments = subst_mappings;
for (auto &sub : adt->get_substs ())
@ -1851,11 +1851,11 @@ TupleType::clone () const
TupleType *
TupleType::handle_substitions (SubstitutionArgumentMappings &mappings)
{
auto mappings_table = Analysis::Mappings::get ();
auto &mappings_table = Analysis::Mappings::get ();
auto tuple = clone ()->as<TupleType> ();
tuple->set_ref (mappings_table->get_next_hir_id ());
tuple->set_ty_ref (mappings_table->get_next_hir_id ());
tuple->set_ref (mappings_table.get_next_hir_id ());
tuple->set_ty_ref (mappings_table.get_next_hir_id ());
for (size_t i = 0; i < tuple->fields.size (); i++)
{
@ -1974,7 +1974,7 @@ FnType *
FnType::handle_substitions (SubstitutionArgumentMappings &subst_mappings)
{
FnType *fn = static_cast<FnType *> (clone ());
fn->set_ty_ref (mappings->get_next_hir_id ());
fn->set_ty_ref (mappings.get_next_hir_id ());
fn->used_arguments = subst_mappings;
for (auto &sub : fn->get_substs ())
@ -2220,16 +2220,16 @@ ClosureType::setup_fn_once_output () const
DefId trait_id = UNKNOWN_DEFID;
bool trait_lang_item_defined
= mappings->lookup_lang_item (fn_once_lang_item, &trait_id);
= mappings.lookup_lang_item (fn_once_lang_item, &trait_id);
rust_assert (trait_lang_item_defined);
DefId trait_item_id = UNKNOWN_DEFID;
bool trait_item_lang_item_defined
= mappings->lookup_lang_item (fn_once_output_lang_item, &trait_item_id);
= mappings.lookup_lang_item (fn_once_output_lang_item, &trait_item_id);
rust_assert (trait_item_lang_item_defined);
// resolve to the trait
HIR::Item *item = mappings->lookup_defid (trait_id);
HIR::Item *item = mappings.lookup_defid (trait_id);
rust_assert (item->get_item_kind () == HIR::Item::ItemKind::Trait);
HIR::Trait *trait = static_cast<HIR::Trait *> (item);
@ -2238,8 +2238,7 @@ ClosureType::setup_fn_once_output () const
rust_assert (!trait_ref->is_error ());
// resolve to trait item
HIR::TraitItem *trait_item
= mappings->lookup_trait_item_defid (trait_item_id);
HIR::TraitItem *trait_item = mappings.lookup_trait_item_defid (trait_item_id);
rust_assert (trait_item != nullptr);
rust_assert (trait_item->get_item_kind ()
== HIR::TraitItem::TraitItemKind::TYPE);
@ -2317,10 +2316,10 @@ ArrayType::clone () const
ArrayType *
ArrayType::handle_substitions (SubstitutionArgumentMappings &mappings)
{
auto mappings_table = Analysis::Mappings::get ();
auto &mappings_table = Analysis::Mappings::get ();
ArrayType *ref = static_cast<ArrayType *> (clone ());
ref->set_ty_ref (mappings_table->get_next_hir_id ());
ref->set_ty_ref (mappings_table.get_next_hir_id ());
// might be &T or &ADT so this needs to be recursive
auto base = ref->get_element_type ();
@ -2391,10 +2390,10 @@ SliceType::clone () const
SliceType *
SliceType::handle_substitions (SubstitutionArgumentMappings &mappings)
{
auto mappings_table = Analysis::Mappings::get ();
auto &mappings_table = Analysis::Mappings::get ();
SliceType *ref = static_cast<SliceType *> (clone ());
ref->set_ty_ref (mappings_table->get_next_hir_id ());
ref->set_ty_ref (mappings_table.get_next_hir_id ());
// might be &T or &ADT so this needs to be recursive
auto base = ref->get_element_type ();
@ -3005,10 +3004,10 @@ ReferenceType::clone () const
ReferenceType *
ReferenceType::handle_substitions (SubstitutionArgumentMappings &mappings)
{
auto mappings_table = Analysis::Mappings::get ();
auto &mappings_table = Analysis::Mappings::get ();
ReferenceType *ref = static_cast<ReferenceType *> (clone ());
ref->set_ty_ref (mappings_table->get_next_hir_id ());
ref->set_ty_ref (mappings_table.get_next_hir_id ());
// might be &T or &ADT so this needs to be recursive
auto base = ref->get_base ();
@ -3167,10 +3166,10 @@ PointerType::clone () const
PointerType *
PointerType::handle_substitions (SubstitutionArgumentMappings &mappings)
{
auto mappings_table = Analysis::Mappings::get ();
auto &mappings_table = Analysis::Mappings::get ();
PointerType *ref = static_cast<PointerType *> (clone ());
ref->set_ty_ref (mappings_table->get_next_hir_id ());
ref->set_ty_ref (mappings_table.get_next_hir_id ());
// might be &T or &ADT so this needs to be recursive
auto base = ref->get_base ();
@ -3339,7 +3338,7 @@ ParamType::handle_substitions (SubstitutionArgumentMappings &subst_mappings)
}
// this is the new subst that this needs to pass
p->set_ref (mappings->get_next_hir_id ());
p->set_ref (mappings.get_next_hir_id ());
p->set_ty_ref (arg.get_tyty ()->get_ref ());
return p;
@ -3668,7 +3667,7 @@ ProjectionType::handle_substitions (
// }
ProjectionType *projection = static_cast<ProjectionType *> (clone ());
projection->set_ty_ref (mappings->get_next_hir_id ());
projection->set_ty_ref (mappings.get_next_hir_id ());
projection->used_arguments = subst_mappings;
auto context = Resolver::TypeCheckContext::get ();

View File

@ -248,7 +248,7 @@ protected:
std::set<HirId> combined;
RustIdent ident;
Analysis::Mappings *mappings;
Analysis::Mappings &mappings;
};
/** Unified interface for all function-like types. */

View File

@ -28,7 +28,7 @@ UnifyRules::UnifyRules (TyTy::TyWithLocation lhs, TyTy::TyWithLocation rhs,
std::vector<InferenceSite> &infers)
: lhs (lhs), rhs (rhs), locus (locus), commit_flag (commit_flag),
emit_error (emit_error), infer_flag (infer), commits (commits),
infers (infers), mappings (*Analysis::Mappings::get ()),
infers (infers), mappings (Analysis::Mappings::get ()),
context (*TypeCheckContext::get ())
{}
@ -70,7 +70,7 @@ UnifyRules::commit (TyTy::BaseType *base, TyTy::BaseType *other,
TyTy::BaseType *resolved)
{
TypeCheckContext &context = *TypeCheckContext::get ();
Analysis::Mappings &mappings = *Analysis::Mappings::get ();
Analysis::Mappings &mappings = Analysis::Mappings::get ();
TyTy::BaseType *b = base->destructure ();
TyTy::BaseType *o = other->destructure ();

View File

@ -110,14 +110,11 @@ Mappings::Mappings ()
Mappings::~Mappings () { delete builtinMarker; }
Mappings *
Mappings &
Mappings::get ()
{
static std::unique_ptr<Mappings> instance;
if (!instance)
instance = std::unique_ptr<Mappings> (new Mappings ());
return instance.get ();
static Mappings instance{};
return instance;
}
CrateNum

View File

@ -74,7 +74,7 @@ private:
class Mappings
{
public:
static Mappings *get ();
static Mappings &get ();
~Mappings ();
CrateNum get_next_crate_num (const std::string &name);
@ -390,7 +390,7 @@ private:
std::map<HirId, HIR::Trait *> hirTraitItemsToTraitMappings;
std::map<HirId, HIR::Pattern *> hirPatternMappings;
std::map<LangItem::Kind, DefId> lang_item_mappings;
std::map<NodeId, const Resolver::CanonicalPath> paths;
std::map<NodeId, Resolver::CanonicalPath> paths;
std::map<NodeId, location_t> locations;
std::map<NodeId, HirId> nodeIdToHirMappings;
std::map<HirId, NodeId> hirIdToNodeMappings;