File tree Expand file tree Collapse file tree 6 files changed +64
-2
lines changed Expand file tree Collapse file tree 6 files changed +64
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ file(GLOB SOURCE_FILES
2222add_library (${PROJECT_NAME} SHARED ${SOURCE_FILES} )
2323set_target_properties (${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node" )
2424
25- llvm_map_components_to_libnames(llvm_libs ${LLVM_TARGETS_TO_BUILD} bitwriter codegen core support tablegen target )
25+ llvm_map_components_to_libnames(llvm_libs ${LLVM_TARGETS_TO_BUILD} bitwriter codegen core support tablegen target executionengine )
2626
2727# Link against LLVM libraries
2828target_link_libraries (${PROJECT_NAME} ${llvm_libs} ${CMAKE_JS_LIB} )
Original file line number Diff line number Diff line change @@ -669,6 +669,9 @@ declare namespace llvm {
669669 getTypeByName ( name : string ) : StructType | null ;
670670 }
671671
672+ class ExecutionEngine {
673+ }
674+
672675 // support
673676 class TargetRegistry {
674677 private constructor ( ) ;
Original file line number Diff line number Diff line change 1+
2+ #ifndef LLVM_NODE_EXECUTION_ENGINE_MODULE_H
3+ #define LLVM_NODE_EXECUTION_ENGINE_MODULE_H
4+
5+ #include <nan.h>
6+ #include "execution-engine.h"
7+
8+ NAN_MODULE_INIT (InitExecutionEngine ) {
9+ ExecutionEngineWrapper ::Init (target );
10+ }
11+
12+ #endif //LLVM_NODE_EXECUTION_ENGINE_MODULE_H
Original file line number Diff line number Diff line change 1+
2+ #include " execution-engine.h"
3+ #include " ../ir/data-layout.h"
4+
5+ Nan::Persistent<v8::ObjectTemplate> ExecutionEngineWrapper::executionEngineTemplate {};
6+
7+ NAN_MODULE_INIT (ExecutionEngineWrapper::Init) {
8+ auto objectTemplate = Nan::New<v8::ObjectTemplate>();
9+ objectTemplate->SetInternalFieldCount (1 );
10+
11+ executionEngineTemplate.Reset (objectTemplate);
12+ }
13+
14+ v8::Local<v8::Object> ExecutionEngineWrapper::of (const llvm::ExecutionEngine *executionEnginePtr) {
15+ Nan::EscapableHandleScope escapeScope {};
16+ v8::Local<v8::ObjectTemplate> tpl = Nan::New (executionEngineTemplate);
17+
18+ auto object = Nan::NewInstance (tpl).ToLocalChecked ();
19+ auto * wrapper = new ExecutionEngineWrapper { executionEnginePtr };
20+ wrapper->Wrap (object);
21+
22+ return escapeScope.Escape (object);
23+ }
Original file line number Diff line number Diff line change 1+
2+ #ifndef LLVM_NODE_EXECUTION_ENGINE_H
3+ #define LLVM_NODE_EXECUTION_ENGINE_H
4+
5+ #include < nan.h>
6+ #include < llvm/ExecutionEngine/ExecutionEngine.h>
7+ #include " ../util/from-value-mixin.h"
8+
9+ class ExecutionEngineWrapper : public Nan ::ObjectWrap, public FromValueMixin<ExecutionEngineWrapper> {
10+ public:
11+ static NAN_MODULE_INIT (Init);
12+ static v8::Local<v8::Object> of (const llvm::ExecutionEngine *ptr);
13+
14+ private:
15+ const llvm::ExecutionEngine* executionEngine;
16+ static Nan::Persistent<v8::ObjectTemplate> executionEngineTemplate;
17+
18+ explicit ExecutionEngineWrapper (const llvm::ExecutionEngine* executionEngine): executionEngine { executionEngine } {
19+ assert (executionEngine && " No execute engine passed" );
20+ }
21+ };
22+
23+ #endif // LLVM_NODE_EXECUTION_ENGINE_H
Original file line number Diff line number Diff line change 55#include " config/config.h"
66#include " support/support.h"
77#include " target/target.h"
8+ #include " execution-engine/execution-engine-module.h"
89
910NAN_MODULE_INIT (InitAll) {
1011 InitBitCode (target);
1112 InitConfig (target);
1213 InitIR (target);
1314 InitSupport (target);
14- InitTarget (target);
15+ InitExecutionEngine (target);
1516}
1617
1718NODE_MODULE (llvm, InitAll)
You can’t perform that action at this time.
0 commit comments