Skip to content

Commit

Permalink
plot any function in module;
Browse files Browse the repository at this point in the history
  • Loading branch information
NateSeymour committed Nov 25, 2024
1 parent 51ed342 commit 15f2fc7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/compiler/transformer/IRGenerator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <iostream>
#include <format>
#include "IRGenerator.h"

void unlogic::IRGenerator::Visit(unlogic::NumericLiteralNode const *node)
Expand Down Expand Up @@ -160,16 +160,16 @@ void unlogic::IRGenerator::Visit(unlogic::PlotCommandNode const *node)
{
llvm::Value *scene = *this->ctx.scope.Lookup("__scene");
llvm::Value *name = this->builder.CreateGlobalStringPtr(node->function_name);
auto function = this->ctx.scope.Lookup(node->function_name);

auto function = this->ctx.module->getFunction(node->function_name);
if (!function)
{
throw std::runtime_error("function not found");
throw std::runtime_error(std::format("Function \"{}\" could not be found!", node->function_name));
}

auto scene_add_plot = this->ctx.module->getFunction("unlogic_scene_add_plot");

std::array<llvm::Value *, 3> args = {scene, name, (llvm::Function *)*function};
std::array<llvm::Value *, 3> args = {scene, name, function};

llvm::Value *ret = this->builder.CreateCall(scene_add_plot, args);

Expand Down

0 comments on commit 15f2fc7

Please sign in to comment.