MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::ast::MatchExpr::Arm Class Reference

ptrn => body, ctor ptrn => body, or index [ptrn] => body of a MatchExpr. More...

#include <mim/ast/ast.h>

Inheritance diagram for mim::ast::MatchExpr::Arm:
[legend]

Public Member Functions

 Arm (Loc loc, std::optional< nat_t > index, Dbg ctor, Ptr< Ptrn > ptrn, Ptr< Expr > body)
const Ptrn * ptrn () const
const Expr * body () const
std::optional< nat_t > index () const
 The case this arm selects by literal index, as in 1 (h, t).
Dbg ctor () const
 The constructor in Cons (h, t); a bare Nil is an unannotated IdPtrn instead.
virtual void bind (Scopes &) const
Lam * emit (Emitter &, const Def *dom=nullptr) const
 dom is the case's payload type if the scrutinee is a Variant; otherwise ptrn() determines the domain.
void stream (fe::Tab &, std::ostream &) const override
Public Member Functions inherited from mim::ast::Node
Loc loc () const
void dump () const

Additional Inherited Members

Protected Member Functions inherited from mim::ast::Node
 Node (Loc loc)

Detailed Description

ptrn => body, ctor ptrn => body, or index [ptrn] => body of a MatchExpr.

Definition at line 692 of file ast.h.

Constructor & Destructor Documentation

◆ Arm()

mim::ast::MatchExpr::Arm::Arm ( Loc loc,
std::optional< nat_t > index,
Dbg ctor,
Ptr< Ptrn > ptrn,
Ptr< Expr > body )
inline

Definition at line 694 of file ast.h.

References body(), ctor(), index(), mim::ast::Node::loc(), mim::ast::Node::Node(), and ptrn().

Member Function Documentation

◆ bind()

void mim::ast::MatchExpr::Arm::bind ( Scopes & s) const
virtual

Definition at line 269 of file bind.cpp.

References mim::ast::Expr::bind(), mim::ast::Ptrn::bind(), body(), and ptrn().

Referenced by mim::ast::MatchExpr::bind().

◆ body()

const Expr * mim::ast::MatchExpr::Arm::body ( ) const
inline

Definition at line 702 of file ast.h.

References mim::ast::Expr::Expr().

Referenced by Arm(), bind(), emit(), and stream().

◆ ctor()

Dbg mim::ast::MatchExpr::Arm::ctor ( ) const
inline

The constructor in Cons (h, t); a bare Nil is an unannotated IdPtrn instead.

Definition at line 706 of file ast.h.

Referenced by Arm(), and mim::ast::MatchExpr::emit_().

◆ emit()

Lam * mim::ast::MatchExpr::Arm::emit ( Emitter & e,
const Def * dom = nullptr ) const

dom is the case's payload type if the scrutinee is a Variant; otherwise ptrn() determines the domain.

Definition at line 644 of file emit.cpp.

References mim::Check::alpha(), body(), emit(), mim::ast::Ptrn::emit_type(), mim::ast::Ptrn::emit_value(), mim::ast::Node::loc(), ptrn(), and mim::Def::set().

Referenced by emit(), and mim::ast::MatchExpr::emit_().

◆ index()

std::optional< nat_t > mim::ast::MatchExpr::Arm::index ( ) const
inline

The case this arm selects by literal index, as in 1 (h, t).

Definition at line 704 of file ast.h.

Referenced by Arm(), mim::ast::MatchExpr::emit_(), and stream().

◆ ptrn()

const Ptrn * mim::ast::MatchExpr::Arm::ptrn ( ) const
inline

Definition at line 701 of file ast.h.

Referenced by Arm(), bind(), emit(), and stream().

◆ stream()

void mim::ast::MatchExpr::Arm::stream ( fe::Tab & tab,
std::ostream & os ) const
overridevirtual

Implements mim::ast::Node.

Definition at line 173 of file stream.cpp.

References body(), index(), ptrn(), and mim::ast::S::S().


The documentation for this class was generated from the following files: