param_vars.push_back (compiled_param_var);
const HIR::Pattern ¶m_pattern = *referenced_param.get_param_name ();
- ctx->insert_var_decl (param_pattern.get_pattern_mappings ().get_hirid (),
+ ctx->insert_var_decl (param_pattern.get_mappings ().get_hirid (),
compiled_param_var);
}
// Construct a TuplePattern from the rest of the patterns
result_pattern = std::unique_ptr<HIR::Pattern> (
- new HIR::TuplePattern (ref.get_pattern_mappings (),
+ new HIR::TuplePattern (ref.get_mappings (),
std::move (new_items),
ref.get_locus ()));
}
{
// Compile the literal
HIR::LiteralExpr *litexpr
- = new HIR::LiteralExpr (pattern.get_pattern_mappings (),
- pattern.get_literal (), pattern.get_locus (),
+ = new HIR::LiteralExpr (pattern.get_mappings (), pattern.get_literal (),
+ pattern.get_locus (),
std::vector<AST::Attribute> ());
// Note: Floating point literals are currently accepted but will likely be
CompilePatternCaseLabelExpr::visit (HIR::RangePattern &pattern)
{
tree upper = compile_range_pattern_bound (pattern.get_upper_bound ().get (),
- pattern.get_pattern_mappings (),
+ pattern.get_mappings (),
pattern.get_locus (), ctx);
tree lower = compile_range_pattern_bound (pattern.get_lower_bound ().get (),
- pattern.get_pattern_mappings (),
+ pattern.get_mappings (),
pattern.get_locus (), ctx);
case_label_expr = build_case_label (lower, upper, associated_case_label);
pattern->get_locus ());
ctx->insert_pattern_binding (
- pattern->get_pattern_mappings ().get_hirid (), binding);
+ pattern->get_mappings ().get_hirid (), binding);
}
}
else
pattern->get_locus ());
ctx->insert_pattern_binding (
- pattern->get_pattern_mappings ().get_hirid (), binding);
+ pattern->get_mappings ().get_hirid (), binding);
}
}
}
void
CompilePatternBindings::visit (HIR::IdentifierPattern &pattern)
{
- ctx->insert_pattern_binding (pattern.get_pattern_mappings ().get_hirid (),
+ ctx->insert_pattern_binding (pattern.get_mappings ().get_hirid (),
match_scrutinee_expr);
}
{
Bvariable *var = nullptr;
rust_assert (
- ctx->lookup_var_decl (pattern.get_pattern_mappings ().get_hirid (), &var));
+ ctx->lookup_var_decl (pattern.get_mappings ().get_hirid (), &var));
auto fnctx = ctx->peek_fn ();
if (ty->is_unit ())
for (auto &sub : items_lower)
{
TyTy::BaseType *ty_sub = nullptr;
- HirId pattern_id = pattern.get_pattern_mappings ().get_hirid ();
+ HirId pattern_id = pattern.get_mappings ().get_hirid ();
bool ok = ctx->get_tyctx ()->lookup_type (pattern_id, &ty_sub);
rust_assert (ok);
for (auto &sub : items_upper)
{
TyTy::BaseType *ty_sub = nullptr;
- HirId pattern_id = pattern.get_pattern_mappings ().get_hirid ();
+ HirId pattern_id = pattern.get_mappings ().get_hirid ();
bool ok = ctx->get_tyctx ()->lookup_type (pattern_id, &ty_sub);
rust_assert (ok);
for (auto &sub : items.get_patterns ())
{
TyTy::BaseType *ty_sub = nullptr;
- HirId pattern_id = pattern.get_pattern_mappings ().get_hirid ();
+ HirId pattern_id = pattern.get_mappings ().get_hirid ();
bool ok = ctx->get_tyctx ()->lookup_type (pattern_id, &ty_sub);
rust_assert (ok);
return;
HIR::Pattern &stmt_pattern = *stmt.get_pattern ();
- HirId stmt_id = stmt_pattern.get_pattern_mappings ().get_hirid ();
+ HirId stmt_id = stmt_pattern.get_mappings ().get_hirid ();
TyTy::BaseType *ty = nullptr;
if (!ctx->get_tyctx ()->lookup_type (stmt_id, &ty))
translated_type, NULL /*decl_var*/,
pattern.get_locus ());
- HirId stmt_id = pattern.get_pattern_mappings ().get_hirid ();
+ HirId stmt_id = pattern.get_mappings ().get_hirid ();
ctx->insert_var_decl (stmt_id, var);
locals.push_back (var);
resolver.mappings->insert_hir_pattern (resolver.translated);
resolver.mappings->insert_location (
- resolver.translated->get_pattern_mappings ().get_hirid (),
- pattern->get_locus ());
+ resolver.translated->get_mappings ().get_hirid (), pattern->get_locus ());
return resolver.translated;
}
{
begin ("LiteralPattern");
put_field ("lit", e.get_literal ().as_string ());
- do_mappings (e.get_pattern_mappings ());
+ do_mappings (e.get_mappings ());
end ("LiteralPattern");
}
Dump::visit (WildcardPattern &e)
{
begin ("WildcardPattern");
- do_mappings (e.get_pattern_mappings ());
+ do_mappings (e.get_mappings ());
end ("WildcardPattern");
}
Dump::visit (RangePattern &e)
{
begin ("RangePattern");
- do_mappings (e.get_pattern_mappings ());
+ do_mappings (e.get_mappings ());
put_field ("lower", e.get_lower_bound ()->as_string ());
put_field ("upper", e.get_upper_bound ()->as_string ());
put_field ("has_ellipsis_syntax",
Dump::visit (ReferencePattern &e)
{
begin ("ReferencePattern");
- do_mappings (e.get_pattern_mappings ());
+ do_mappings (e.get_mappings ());
put_field ("mut", std::to_string (e.is_mut ()));
put_field ("pattern", e.get_referenced_pattern ()->as_string ());
end ("ReferencePattern");
Dump::visit (TupleStructPattern &e)
{
begin ("TupleStructPattern");
- do_mappings (e.get_pattern_mappings ());
+ do_mappings (e.get_mappings ());
put_field ("path", e.get_path ().as_string ());
Dump::visit (TuplePattern &e)
{
begin ("TuplePattern");
- do_mappings (e.get_pattern_mappings ());
+ do_mappings (e.get_mappings ());
visit_field ("items", e.get_items ());
end ("TuplePattern");
}
Dump::visit (SlicePattern &e)
{
begin ("SlicePattern");
- do_mappings (e.get_pattern_mappings ());
+ do_mappings (e.get_mappings ());
visit_collection ("items", e.get_items ());
end ("SlicePattern");
}
Dump::visit (AltPattern &e)
{
begin ("AltPattern");
- do_mappings (e.get_pattern_mappings ());
+ do_mappings (e.get_mappings ());
visit_collection ("alts", e.get_alts ());
end ("AltPattern");
}
== 0;
}
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
- return get_mappings ();
+ return mappings;
}
protected:
location_t get_locus () { return locus; }
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
- return get_mappings ();
+ return mappings;
}
protected:
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRPatternVisitor &vis) override;
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
return mappings;
}
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRPatternVisitor &vis) override;
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
return mappings;
}
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRPatternVisitor &vis) override;
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
return mappings;
}
bool get_has_ellipsis_syntax () { return has_ellipsis_syntax; };
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
return mappings;
}
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRPatternVisitor &vis) override;
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
return mappings;
}
PathInExpression &get_path () { return path; }
StructPatternElements &get_struct_pattern_elems () { return elems; }
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
return mappings;
}
std::unique_ptr<TupleStructItems> &get_items () { return items; }
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
return mappings;
}
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRPatternVisitor &vis) override;
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
return mappings;
}
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRPatternVisitor &vis) override;
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
return mappings;
}
void accept_vis (HIRFullVisitor &vis) override;
void accept_vis (HIRPatternVisitor &vis) override;
- const Analysis::NodeMapping &get_pattern_mappings () const override final
+ const Analysis::NodeMapping &get_mappings () const override final
{
return mappings;
}
virtual void accept_vis (HIRPatternVisitor &vis) = 0;
- virtual const Analysis::NodeMapping &get_pattern_mappings () const = 0;
+ virtual const Analysis::NodeMapping &get_mappings () const = 0;
virtual location_t get_locus () const = 0;
pattern->accept_vis (resolver);
if (resolver.infered == nullptr)
- return new TyTy::ErrorType (pattern->get_pattern_mappings ().get_hirid ());
+ return new TyTy::ErrorType (pattern->get_mappings ().get_hirid ());
- resolver.context->insert_type (pattern->get_pattern_mappings (),
- resolver.infered);
+ resolver.context->insert_type (pattern->get_mappings (), resolver.infered);
return resolver.infered;
}
TyTy::BaseType *fty = field->get_field_type ();
// setup the type on this pattern type
- context->insert_type (pattern->get_pattern_mappings (), fty);
+ context->insert_type (pattern->get_mappings (), fty);
}
}
break;
// wildcard patterns within the MatchArm's are simply just the same type as
// the parent
infered = parent->clone ();
- infered->set_ref (pattern.get_pattern_mappings ().get_hirid ());
+ infered->set_ref (pattern.get_mappings ().get_hirid ());
}
void
= TypeCheckPattern::Resolve (p.get (), par_type);
pattern_elems.push_back (TyTy::TyVar (elem->get_ref ()));
}
- infered
- = new TyTy::TupleType (pattern.get_pattern_mappings ().get_hirid (),
- pattern.get_locus (), pattern_elems);
+ infered = new TyTy::TupleType (pattern.get_mappings ().get_hirid (),
+ pattern.get_locus (), pattern_elems);
}
break;
void
TypeCheckPattern::visit (HIR::LiteralPattern &pattern)
{
- infered = resolve_literal (pattern.get_pattern_mappings (),
- pattern.get_literal (), pattern.get_locus ());
+ infered = resolve_literal (pattern.get_mappings (), pattern.get_literal (),
+ pattern.get_locus ());
}
void
TyTy::BaseType *upper = nullptr, *lower = nullptr;
upper = typecheck_range_pattern_bound (pattern.get_upper_bound (),
- pattern.get_pattern_mappings (),
+ pattern.get_mappings (),
pattern.get_locus ());
lower = typecheck_range_pattern_bound (pattern.get_lower_bound (),
- pattern.get_pattern_mappings (),
+ pattern.get_mappings (),
pattern.get_locus ());
- infered = unify_site (pattern.get_pattern_mappings ().get_hirid (),
+ infered = unify_site (pattern.get_mappings ().get_hirid (),
TyTy::TyWithLocation (upper),
TyTy::TyWithLocation (lower), pattern.get_locus ());
}
TyTy::BaseType *infered_base
= TypeCheckPattern::Resolve (pattern.get_referenced_pattern ().get (),
ref_ty_ty->get_base ());
- infered
- = new TyTy::ReferenceType (pattern.get_pattern_mappings ().get_hirid (),
- TyTy::TyVar (infered_base->get_ref ()),
- pattern.is_mut () ? Mutability::Mut
- : Mutability::Imm);
+ infered = new TyTy::ReferenceType (pattern.get_mappings ().get_hirid (),
+ TyTy::TyVar (infered_base->get_ref ()),
+ pattern.is_mut () ? Mutability::Mut
+ : Mutability::Imm);
}
void
for (auto &type : types)
{
alt_pattern_type
- = unify_site (pattern.get_pattern_mappings ().get_hirid (),
+ = unify_site (pattern.get_mappings ().get_hirid (),
TyTy::TyWithLocation (alt_pattern_type),
TyTy::TyWithLocation (type, type->get_locus ()),
pattern.get_locus ());
void
ClosureParamInfer::visit (HIR::WildcardPattern &pattern)
{
- HirId id = pattern.get_pattern_mappings ().get_hirid ();
+ HirId id = pattern.get_mappings ().get_hirid ();
infered = new TyTy::InferType (id, TyTy::InferType::InferTypeKind::GENERAL,
TyTy::InferType::TypeHint::Default (),
pattern.get_locus ());
void
ClosureParamInfer::visit (HIR::IdentifierPattern &pattern)
{
- HirId id = pattern.get_pattern_mappings ().get_hirid ();
+ HirId id = pattern.get_mappings ().get_hirid ();
infered = new TyTy::InferType (id, TyTy::InferType::InferTypeKind::GENERAL,
TyTy::InferType::TypeHint::Default (),
pattern.get_locus ());
TyTy::BaseType *element
= ClosureParamInfer::Resolve (pattern.get_referenced_pattern ().get ());
- HirId id = pattern.get_pattern_mappings ().get_hirid ();
+ HirId id = pattern.get_mappings ().get_hirid ();
infered = new TyTy::ReferenceType (id, TyTy::TyVar (element->get_ref ()),
pattern.get_mutability ());
}
return;
init_expr_ty->append_reference (
- stmt_pattern.get_pattern_mappings ().get_hirid ());
+ stmt_pattern.get_mappings ().get_hirid ());
}
TyTy::BaseType *specified_ty = nullptr;
// let x;
else
{
- auto infer = new TyTy::InferType (
- stmt_pattern.get_pattern_mappings ().get_hirid (),
- TyTy::InferType::InferTypeKind::GENERAL,
- TyTy::InferType::TypeHint::Default (), stmt.get_locus ());
+ auto infer
+ = new TyTy::InferType (stmt_pattern.get_mappings ().get_hirid (),
+ TyTy::InferType::InferTypeKind::GENERAL,
+ TyTy::InferType::TypeHint::Default (),
+ stmt.get_locus ());
TypeCheckPattern::Resolve (&stmt_pattern, infer);
}
}
void
Mappings::insert_hir_pattern (HIR::Pattern *pattern)
{
- auto id = pattern->get_pattern_mappings ().get_hirid ();
+ auto id = pattern->get_mappings ().get_hirid ();
rust_assert (lookup_hir_pattern (id) == nullptr);
hirPatternMappings[id] = pattern;
- insert_node_to_hir (pattern->get_pattern_mappings ().get_nodeid (), id);
+ insert_node_to_hir (pattern->get_mappings ().get_nodeid (), id);
}
HIR::Pattern *