mirror of
https://github.com/PashaBibko/LX.git
synced 2026-04-04 01:49:05 +00:00
Now supports function calling
This commit is contained in:
@@ -15,6 +15,9 @@ namespace LX
|
||||
llvm::LLVMContext context;
|
||||
llvm::Module module;
|
||||
llvm::IRBuilder<> builder;
|
||||
|
||||
// All IR functions that have been generated //
|
||||
std::unordered_map<std::string, llvm::Function*> functions;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,6 +35,9 @@ namespace LX::AST
|
||||
// Function to log the node to a file, will throw an error if called on this class //
|
||||
void Log(unsigned depth) override;
|
||||
|
||||
// Function to get the node's type name, will throw an error if called on this class //
|
||||
virtual const char* TypeName() override;
|
||||
|
||||
// The nodes that are contained within this node //
|
||||
std::vector<std::unique_ptr<Node>> nodes;
|
||||
};
|
||||
@@ -49,6 +55,9 @@ namespace LX::AST
|
||||
// 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;
|
||||
|
||||
private:
|
||||
// The number it stores //
|
||||
// Yes the number is stored as a string, It's horrible I know //
|
||||
@@ -68,6 +77,9 @@ namespace LX::AST
|
||||
// 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;
|
||||
|
||||
private:
|
||||
// The sides of the operation //
|
||||
// Unary operations are handled by a different class //
|
||||
@@ -90,6 +102,9 @@ namespace LX::AST
|
||||
// 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;
|
||||
|
||||
private:
|
||||
// What it is returning (can be null) //
|
||||
std::unique_ptr<Node> m_Val;
|
||||
@@ -108,6 +123,9 @@ namespace LX::AST
|
||||
// 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;
|
||||
|
||||
private:
|
||||
// Name of the variable //
|
||||
std::string m_Name;
|
||||
@@ -128,6 +146,9 @@ namespace LX::AST
|
||||
// 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;
|
||||
|
||||
private:
|
||||
// Name of the variable //
|
||||
std::string m_Name;
|
||||
@@ -149,8 +170,35 @@ namespace LX::AST
|
||||
// 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;
|
||||
|
||||
private:
|
||||
// The name of the variable //
|
||||
std::string m_Name;
|
||||
};
|
||||
|
||||
// Node to represent calling a function within the AST //
|
||||
class FunctionCall : public Node
|
||||
{
|
||||
public:
|
||||
// Constructor to set the name of the function and any args it may have //
|
||||
FunctionCall(const std::string& funcName, std::vector<std::unique_ptr<Node>>& args);
|
||||
|
||||
// Function for generating LLVM IR (Intermediate representation) //
|
||||
llvm::Value* GenIR(InfoLLVM& LLVM, FunctionScope& func) override;
|
||||
|
||||
// Function to log the niode to a file //
|
||||
void Log(unsigned depth) override;
|
||||
|
||||
// Function to get the node's type name //
|
||||
const char* TypeName() override;
|
||||
|
||||
private:
|
||||
// The name of the function //
|
||||
std::string m_Name;
|
||||
|
||||
// Any arguments to pass into the function //
|
||||
std::vector<std::unique_ptr<Node>> m_Args;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user