tipc
A TIP to LLVM compiler
ASTBinaryExpr.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ASTExpr.h"
4 
7 class ASTBinaryExpr : public ASTExpr {
8  std::string OP;
9  std::shared_ptr<ASTExpr> LEFT, RIGHT;
10 
11 public:
12  std::vector<std::shared_ptr<ASTNode>> getChildren() override;
13  ASTBinaryExpr(const std::string &OP, std::shared_ptr<ASTExpr> LEFT,
14  std::shared_ptr<ASTExpr> RIGHT)
15  : OP(OP), LEFT(LEFT), RIGHT(RIGHT) {}
16  std::string getOp() const { return OP; }
17  ASTExpr *getLeft() const { return LEFT.get(); }
18  ASTExpr *getRight() const { return RIGHT.get(); }
19  void accept(ASTVisitor *visitor) override;
20  llvm::Value *codegen() override;
21 
22 protected:
23  std::ostream &print(std::ostream &out) const override;
24 };
Class for a binary operator.
Definition: ASTBinaryExpr.h:7
ASTBinaryExpr(const std::string &OP, std::shared_ptr< ASTExpr > LEFT, std::shared_ptr< ASTExpr > RIGHT)
Definition: ASTBinaryExpr.h:13
std::string getOp() const
Definition: ASTBinaryExpr.h:16
ASTExpr * getRight() const
Definition: ASTBinaryExpr.h:18
std::ostream & print(std::ostream &out) const override
Definition: ASTBinaryExpr.cpp:12
std::vector< std::shared_ptr< ASTNode > > getChildren() override
Return all of the children for the node.
Definition: ASTBinaryExpr.cpp:17
void accept(ASTVisitor *visitor) override
Visit the children of this node and apply the visitor.
Definition: ASTBinaryExpr.cpp:4
llvm::Value * codegen() override
Perform code generation and return an LLVM value the code.
Definition: CodeGenFunctions.cpp:426
ASTExpr * getLeft() const
Definition: ASTBinaryExpr.h:17
Abstract class for all expression subtypes.
Definition: ASTExpr.h:7
Base class for AST visitors.
Definition: ASTVisitor.h:23