mirror of
https://github.com/PashaBibko/LX.git
synced 2026-04-04 01:49:05 +00:00
Added IfBranch class
This commit is contained in:
@@ -201,4 +201,31 @@ namespace LX::AST
|
||||
// Any arguments to pass into the function //
|
||||
std::vector<std::unique_ptr<Node>> m_Args;
|
||||
};
|
||||
|
||||
// Node to represent a if-statement within the AST //
|
||||
class IfBranch : public Node
|
||||
{
|
||||
public:
|
||||
// Constructor to set the name of the function and any args it may have //
|
||||
IfBranch();
|
||||
|
||||
// Function for generating LLVM IR (Intermediate representation) //
|
||||
llvm::Value* GenIR(InfoLLVM& LLVM, FunctionScope& func) override;
|
||||
|
||||
// Function to log the node to a file //
|
||||
void Log(unsigned depth) override;
|
||||
|
||||
// Function to get the node's type name //
|
||||
const char* TypeName() override;
|
||||
|
||||
// Function to add a node to the branch //
|
||||
inline void Push(std::unique_ptr<Node>& node) { m_Body.push_back(std::move(node)); }
|
||||
|
||||
private:
|
||||
// The condition of the branch //
|
||||
std::unique_ptr<Node> m_Condition;
|
||||
|
||||
// The body of the if-statement //
|
||||
std::vector<std::unique_ptr<Node>> m_Body;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user