tan  0.0.1
tanlang::BinaryOperator Class Reference
Inheritance diagram for tanlang::BinaryOperator:
Collaboration diagram for tanlang::BinaryOperator:

Public Member Functions

void set_lhs (Expr *lhs)
 
void set_rhs (Expr *rhs)
 
Exprget_lhs () const
 
Exprget_rhs () const
 
BinaryOpKind get_op () const
 
vector< ASTBase * > get_children () const override
 Get a ordered list of child nodes. More...
 
- Public Member Functions inherited from tanlang::Expr
virtual bool is_comptime_known ()
 
virtual bool is_lvalue ()
 
virtual void set_lvalue (bool is_lvalue)
 
bool is_expr () const override
 
bool is_stmt () const override
 
- Public Member Functions inherited from tanlang::ASTBase
 ASTBase (ASTNodeType node_type, TokenizedSourceFile *src, int bp)
 
ASTNodeType get_node_type () const
 
void set_node_type (ASTNodeType node_type)
 
int get_bp () const
 
Contextctx ()
 
str repr (const str &prefix="-") const
 AST tree string representation. More...
 
virtual str terminal_token () const
 Which terminal token is expected immediately after this node. More...
 
- Public Member Functions inherited from tanlang::SourceTraceable
 SourceTraceable (TokenizedSourceFile *src)
 
uint32_t start () const
 
uint32_t end () const
 
void set_start (uint32_t val)
 
void set_end (uint32_t val)
 
TokenizedSourceFilesrc () const
 
- Public Member Functions inherited from tanlang::Typed
virtual Typeget_type () const
 
virtual void set_type (Type *type)
 

Static Public Member Functions

static BinaryOperatorCreate (BinaryOpKind op, TokenizedSourceFile *src)
 
static BinaryOperatorCreate (BinaryOpKind op, TokenizedSourceFile *src, Expr *lhs, Expr *rhs)
 

Static Public Attributes

static umap< BinaryOpKind, int > BOPPrecedence
 binary operator precedence More...
 
- Static Public Attributes inherited from tanlang::ASTBase
static umap< ASTNodeType, str > ASTTypeNames
 string representation of ASTNodeType More...
 
static umap< ASTNodeType, int > OpPrecedence
 operator precedence of tokens More...
 

Protected Member Functions

 BinaryOperator (BinaryOpKind op, TokenizedSourceFile *src)
 
- Protected Member Functions inherited from tanlang::Expr
 Expr (ASTNodeType type, TokenizedSourceFile *src, int bp)
 
- Protected Member Functions inherited from tanlang::ASTBase
virtual str to_string (bool include_source_code=false) const
 Different from repr, to_string output doesn't include child nodes. More...
 
virtual ASTBaseget () const
 Get the "actual" this. Used for implementing proxy classes. More...
 

Protected Attributes

BinaryOpKind _op
 
Expr_lhs = nullptr
 
Expr_rhs = nullptr
 
- Protected Attributes inherited from tanlang::Expr
bool _is_lvalue = false
 

Detailed Description

Definition at line 200 of file expr.h.

Constructor & Destructor Documentation

◆ BinaryOperator()

BinaryOperator::BinaryOperator ( BinaryOpKind  op,
TokenizedSourceFile src 
)
protected

operators

Definition at line 145 of file expr.cpp.

Member Function Documentation

◆ get_children()

vector< ASTBase * > BinaryOperator::get_children ( ) const
overridevirtual

Get a ordered list of child nodes.

Reimplemented from tanlang::Expr.

Definition at line 189 of file expr.cpp.

Member Data Documentation

◆ BOPPrecedence

umap< BinaryOpKind, int > BinaryOperator::BOPPrecedence
static
Initial value:
= {
{BinaryOpKind::SUM, PREC_TERM },
{BinaryOpKind::SUBTRACT, PREC_TERM },
{BinaryOpKind::BOR, PREC_TERM },
{BinaryOpKind::XOR, PREC_TERM },
{BinaryOpKind::MULTIPLY, PREC_FACTOR },
{BinaryOpKind::DIVIDE, PREC_FACTOR },
{BinaryOpKind::MOD, PREC_FACTOR },
{BinaryOpKind::BAND, PREC_FACTOR },
{BinaryOpKind::GT, PREC_COMPARISON },
{BinaryOpKind::GE, PREC_COMPARISON },
{BinaryOpKind::NE, PREC_COMPARISON },
{BinaryOpKind::LT, PREC_COMPARISON },
{BinaryOpKind::LE, PREC_COMPARISON },
{BinaryOpKind::EQ, PREC_COMPARISON },
{BinaryOpKind::LAND, PREC_LOGICAL_AND},
{BinaryOpKind::LOR, PREC_LOGICAL_OR },
{BinaryOpKind::MEMBER_ACCESS, PREC_HIGHEST }
}

binary operator precedence

Definition at line 209 of file expr.h.


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