From c0bfd4757ffbf706c7761b1a13a011d74b06e9c8 Mon Sep 17 00:00:00 2001 From: Stefano Sanfilippo Date: Sat, 7 Mar 2015 14:06:58 +0100 Subject: [PATCH] Implementing system module loading for register runtime functions. --- BitcodeEmitter.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/BitcodeEmitter.cpp b/BitcodeEmitter.cpp index 251c087..e43fa83 100644 --- a/BitcodeEmitter.cpp +++ b/BitcodeEmitter.cpp @@ -518,13 +518,31 @@ bool BitcodeEmitter::emit(Function const& node) { } bool BitcodeEmitter::emit(Module const& node) { + llvm::Function *dummy; + + if (node.getType() == Module::SYSTEM) { + auto module = STANDARD_MODULES.find(node.getName()); + + if (module == STANDARD_MODULES.end()) { + return reportError({ + "Unknown system module", node.getName() + }); + } + + for (Function const* func: module->second) { + if (!emitFunctionPrototype(*func, &dummy)) return false; + } + } + + // TODO (maybe) user modules + return true; } bool BitcodeEmitter::emit(Program const& program) { -// for (Module const& module: program.getModules()) { -// GUARDED(module.emit(this)); -// } + for (Module const& module: program.getModules()) { + GUARDED(module.emit(this)); + } for (Function const* function: program.getFunctions()) { GUARDED(function->emit(this));