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