unlogic
Loading...
Searching...
No Matches
RuntimeLibrary.cpp
Go to the documentation of this file.
1#include "RuntimeLibrary.h"
2#include "graphic/Scene.h"
3
4using namespace unlogic;
5
6extern "C"
7{
8 void unlogic_scene_add_plot(Scene *scene, char const *name, Plot2dFunctionType function)
9 {
10 scene->AddPlot(name, function);
11 }
12}
13
14Library unlogic::runtime("runtime");
15
16LibrarySymbol scene_add_plot(runtime, "unlogic_scene_add_plot", (void *)unlogic_scene_add_plot, [](llvm::LLVMContext &ctx, llvm::Module &mod) {
17 std::array<llvm::Type *, 1> plot_function_args = {
18 llvm::Type::getDoubleTy(ctx),
19 };
20 llvm::FunctionType *plot_function_type = llvm::FunctionType::get(llvm::Type::getDoubleTy(ctx), plot_function_args, false);
21
22 std::array<llvm::Type *, 3> args = {
23 llvm::PointerType::getUnqual(ctx),
24 llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(ctx)),
25 llvm::PointerType::getUnqual(plot_function_type),
26 };
27 llvm::Type *ret = llvm::Type::getVoidTy(ctx);
28
29 llvm::FunctionType *fn = llvm::FunctionType::get(ret, args, false);
30 llvm::Function::Create(fn, llvm::GlobalValue::ExternalLinkage, "unlogic_scene_add_plot", mod);
31});
void unlogic_scene_add_plot(Scene *scene, char const *name, Plot2dFunctionType function)
LibrarySymbol scene_add_plot(runtime, "unlogic_scene_add_plot",(void *) unlogic_scene_add_plot, [](llvm::LLVMContext &ctx, llvm::Module &mod) { std::array< llvm::Type *, 1 > plot_function_args={ llvm::Type::getDoubleTy(ctx), };llvm::FunctionType *plot_function_type=llvm::FunctionType::get(llvm::Type::getDoubleTy(ctx), plot_function_args, false);std::array< llvm::Type *, 3 > args={ llvm::PointerType::getUnqual(ctx), llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(ctx)), llvm::PointerType::getUnqual(plot_function_type), };llvm::Type *ret=llvm::Type::getVoidTy(ctx);llvm::FunctionType *fn=llvm::FunctionType::get(ret, args, false);llvm::Function::Create(fn, llvm::GlobalValue::ExternalLinkage, "unlogic_scene_add_plot", mod);})
Library runtime
double(*)(double) Plot2dFunctionType
Definition Plot.h:15
void AddPlot(char const *name, Plot2dFunctionType function)
Definition Scene.cpp:11