void visit (HIR::TupleStructPattern &) override;
// Empty visit for unused Pattern HIR nodes.
- void visit (HIR::GroupedPattern &) override {}
void visit (HIR::LiteralPattern &) override {}
void visit (HIR::PathInExpression &) override {}
void visit (HIR::QualifiedPathInExpression &) override {}
case_label_expr = build_case_label (lower, upper, associated_case_label);
}
-void
-CompilePatternCaseLabelExpr::visit (HIR::GroupedPattern &pattern)
-{
- pattern.get_item ()->accept_vis (*this);
-}
-
// setup the bindings
void
}
void
-CompilePatternBindings::visit (HIR::GroupedPattern &pattern)
-{
- pattern.get_item ()->accept_vis (*this);
-}
-
-void
CompilePatternLet::visit (HIR::IdentifierPattern &pattern)
{
Bvariable *var = nullptr;
void visit (HIR::TupleStructPattern &pattern) override;
void visit (HIR::WildcardPattern &pattern) override;
void visit (HIR::RangePattern &pattern) override;
- void visit (HIR::GroupedPattern &pattern) override;
// Empty visit for unused Pattern HIR nodes.
void visit (HIR::IdentifierPattern &) override {}
void visit (HIR::StructPattern &pattern) override;
void visit (HIR::TupleStructPattern &pattern) override;
- void visit (HIR::GroupedPattern &) override;
// Empty visit for unused Pattern HIR nodes.
void visit (HIR::IdentifierPattern &) override {}
void visit (HIR::WildcardPattern &) override;
// check for unimplemented Pattern HIR nodes.
- void visit (HIR::GroupedPattern &pattern) override
- {
- rust_sorry_at (pattern.get_locus (),
- "grouped pattern let statements not supported");
- }
-
void visit (HIR::LiteralPattern &pattern) override
{
rust_sorry_at (pattern.get_locus (),
void visit (HIR::QualifiedPathInExpression &expr) override;
// Empty visit for unused Pattern HIR nodes.
- void visit (HIR::GroupedPattern &) override {}
void visit (HIR::IdentifierPattern &) override {}
void visit (HIR::LiteralPattern &) override {}
void visit (HIR::RangePattern &) override {}
}
// Empty visit for unused Pattern HIR nodes.
- void visit (HIR::GroupedPattern &) override {}
void visit (HIR::LiteralPattern &) override {}
void visit (HIR::PathInExpression &) override {}
void visit (HIR::QualifiedPathInExpression &) override {}
{}
void
-ConstChecker::visit (GroupedPattern &)
-{}
-
-void
ConstChecker::visit (SlicePattern &)
{}
virtual void visit (TuplePatternItemsMultiple &tuple_items) override;
virtual void visit (TuplePatternItemsRanged &tuple_items) override;
virtual void visit (TuplePattern &pattern) override;
- virtual void visit (GroupedPattern &pattern) override;
virtual void visit (SlicePattern &pattern) override;
virtual void visit (EmptyStmt &stmt) override;
virtual void visit (LetStmt &stmt) override;
{}
void
-UnsafeChecker::visit (GroupedPattern &)
-{}
-
-void
UnsafeChecker::visit (SlicePattern &)
{}
virtual void visit (TuplePatternItemsMultiple &tuple_items) override;
virtual void visit (TuplePatternItemsRanged &tuple_items) override;
virtual void visit (TuplePattern &pattern) override;
- virtual void visit (GroupedPattern &pattern) override;
virtual void visit (SlicePattern &pattern) override;
virtual void visit (EmptyStmt &stmt) override;
virtual void visit (LetStmt &stmt) override;
Dump::visit (TuplePattern &)
{}
void
-Dump::visit (GroupedPattern &)
-{}
-void
Dump::visit (SlicePattern &)
{}
virtual void visit (TuplePatternItemsMultiple &) override;
virtual void visit (TuplePatternItemsRanged &) override;
virtual void visit (TuplePattern &) override;
- virtual void visit (GroupedPattern &) override;
virtual void visit (SlicePattern &) override;
virtual void visit (EmptyStmt &) override;
class TuplePatternItemsMultiple;
class TuplePatternItemsRanged;
class TuplePattern;
-class GroupedPattern;
class SlicePattern;
// rust-type.h
}
void
-GroupedPattern::accept_vis (HIRFullVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
SlicePattern::accept_vis (HIRFullVisitor &vis)
{
vis.visit (*this);
}
void
-GroupedPattern::accept_vis (HIRPatternVisitor &vis)
-{
- vis.visit (*this);
-}
-
-void
WildcardPattern::accept_vis (HIRPatternVisitor &vis)
{
vis.visit (*this);
}
};
-// HIR node representing a pattern in parentheses, used to control precedence
-class GroupedPattern : public Pattern
-{
- std::unique_ptr<Pattern> pattern_in_parens;
- Location locus;
- Analysis::NodeMapping mappings;
-
-public:
- std::string as_string () const override
- {
- return "(" + pattern_in_parens->as_string () + ")";
- }
-
- GroupedPattern (Analysis::NodeMapping mappings,
- std::unique_ptr<Pattern> pattern_in_parens, Location locus)
- : pattern_in_parens (std::move (pattern_in_parens)), locus (locus),
- mappings (mappings)
- {}
-
- // Copy constructor uses clone
- GroupedPattern (GroupedPattern const &other)
- : pattern_in_parens (other.pattern_in_parens->clone_pattern ()),
- locus (other.locus), mappings (other.mappings)
- {}
-
- // Overload assignment operator to clone
- GroupedPattern &operator= (GroupedPattern const &other)
- {
- pattern_in_parens = other.pattern_in_parens->clone_pattern ();
- locus = other.locus;
- mappings = other.mappings;
-
- return *this;
- }
-
- // default move semantics
- GroupedPattern (GroupedPattern &&other) = default;
- GroupedPattern &operator= (GroupedPattern &&other) = default;
-
- Location get_locus () const override { return locus; }
-
- void accept_vis (HIRFullVisitor &vis) override;
- void accept_vis (HIRPatternVisitor &vis) override;
-
- Analysis::NodeMapping get_pattern_mappings () const override final
- {
- return mappings;
- }
-
- PatternType get_pattern_type () const override final
- {
- return PatternType::GROUPED;
- }
-
- std::unique_ptr<Pattern> &get_item () { return pattern_in_parens; }
- const std::unique_ptr<Pattern> &get_item () const
- {
- return pattern_in_parens;
- }
-
-protected:
- /* Use covariance to implement clone function as returning this object rather
- * than base */
- GroupedPattern *clone_pattern_impl () const override
- {
- return new GroupedPattern (*this);
- }
-};
-
// HIR node representing patterns that can match slices and arrays
class SlicePattern : public Pattern
{
virtual void visit (TuplePatternItemsMultiple &tuple_items) = 0;
virtual void visit (TuplePatternItemsRanged &tuple_items) = 0;
virtual void visit (TuplePattern &pattern) = 0;
- virtual void visit (GroupedPattern &pattern) = 0;
virtual void visit (SlicePattern &pattern) = 0;
virtual void visit (EmptyStmt &stmt) = 0;
virtual void visit (LetStmt &stmt) = 0;
virtual void visit (TuplePatternItemsMultiple &) override {}
virtual void visit (TuplePatternItemsRanged &) override {}
virtual void visit (TuplePattern &) override {}
- virtual void visit (GroupedPattern &) override {}
virtual void visit (SlicePattern &) override {}
virtual void visit (EmptyStmt &) override {}
class HIRPatternVisitor
{
public:
- virtual void visit (GroupedPattern &) = 0;
virtual void visit (IdentifierPattern &) = 0;
virtual void visit (LiteralPattern &) = 0;
virtual void visit (PathInExpression &) = 0;
}
void
-TypeCheckPattern::visit (HIR::GroupedPattern &pattern)
-{
- TyTy::BaseType *inner_ty
- = TypeCheckPattern::Resolve (pattern.get_item ().get (), parent);
- infered = inner_ty->clone ();
- infered->set_ref (pattern.get_pattern_mappings ().get_hirid ());
-}
-
-void
TypeCheckPattern::visit (HIR::QualifiedPathInExpression &)
{
// TODO
void visit (HIR::LiteralPattern &pattern) override;
void visit (HIR::RangePattern &pattern) override;
void visit (HIR::IdentifierPattern &pattern) override;
- void visit (HIR::GroupedPattern &pattern) override;
void visit (HIR::QualifiedPathInExpression &pattern) override;
void visit (HIR::ReferencePattern &pattern) override;
void visit (HIR::SlicePattern &pattern) override;