tipc
A TIP to LLVM compiler
ASTFieldExpr.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ASTExpr.h"
4 
7 class ASTFieldExpr : public ASTExpr {
8  std::string FIELD;
9  std::shared_ptr<ASTExpr> INIT;
10 
11 public:
12  std::vector<std::shared_ptr<ASTNode>> getChildren() override;
13  ASTFieldExpr(const std::string &FIELD, std::shared_ptr<ASTExpr> INIT)
14  : FIELD(FIELD), INIT(INIT) {}
15  std::string getField() const { return FIELD; }
16  ASTExpr *getInitializer() const { return INIT.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 };
Abstract class for all expression subtypes.
Definition: ASTExpr.h:7
Class for the field of a record.
Definition: ASTFieldExpr.h:7
std::ostream & print(std::ostream &out) const override
Definition: ASTFieldExpr.cpp:11
ASTFieldExpr(const std::string &FIELD, std::shared_ptr< ASTExpr > INIT)
Definition: ASTFieldExpr.h:13
std::string getField() const
Definition: ASTFieldExpr.h:15
std::vector< std::shared_ptr< ASTNode > > getChildren() override
Return all of the children for the node.
Definition: ASTFieldExpr.cpp:16
void accept(ASTVisitor *visitor) override
Visit the children of this node and apply the visitor.
Definition: ASTFieldExpr.cpp:4
ASTExpr * getInitializer() const
Definition: ASTFieldExpr.h:16
llvm::Value * codegen() override
Perform code generation and return an LLVM value the code.
Definition: CodeGenFunctions.cpp:724
Base class for AST visitors.
Definition: ASTVisitor.h:23