From 15f2fc7c34ff6411901b4ffe437b766a2d24c0c4 Mon Sep 17 00:00:00 2001 From: Nathan Seymour Date: Mon, 25 Nov 2024 10:26:22 -0600 Subject: [PATCH] plot any function in module; --- src/compiler/transformer/IRGenerator.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/transformer/IRGenerator.cpp b/src/compiler/transformer/IRGenerator.cpp index ee1f2b8..bb934d2 100644 --- a/src/compiler/transformer/IRGenerator.cpp +++ b/src/compiler/transformer/IRGenerator.cpp @@ -1,4 +1,4 @@ -#include +#include #include "IRGenerator.h" void unlogic::IRGenerator::Visit(unlogic::NumericLiteralNode const *node) @@ -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 args = {scene, name, (llvm::Function *)*function}; + std::array args = {scene, name, function}; llvm::Value *ret = this->builder.CreateCall(scene_add_plot, args);