aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2018-06-04 00:13:03 +0000
committerbloodstalker <thabogre@gmail.com>2018-06-04 00:13:03 +0000
commitefae8398853d1494a17351f855e261867922ba44 (patch)
tree049d49c9f8a4fa58b42d36804035de6f6e82c39b /bruiser
parentfixed a bug with default.lua. added the blueprint for the wasm interface to b... (diff)
downloadmutator-efae8398853d1494a17351f855e261867922ba44.tar.gz
mutator-efae8398853d1494a17351f855e261867922ba44.zip
fixes #40
Diffstat (limited to '')
-rw-r--r--bruiser/wasm.c15
-rw-r--r--bruiser/wasm.h20
-rwxr-xr-xbruiser/wasm.sh4
3 files changed, 26 insertions, 13 deletions
diff --git a/bruiser/wasm.c b/bruiser/wasm.c
index ac5143c..c517269 100644
--- a/bruiser/wasm.c
+++ b/bruiser/wasm.c
@@ -21,8 +21,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*
#include "./lua-5.3.4/src/lua.h"
#include "./lua-5.3.4/src/lauxlib.h"
#include "./lua-5.3.4/src/lualib.h"
-#include "wasm.h"
+#include "./wasm.h"
/**********************************************************************************************************************/
+static Wasm_Module* convert_wasm_module(lua_State* ls, int index) {
+ Wasm_Module* dummy = lua_touserdata(ls, index);
+ if (dummy == NULL) {printf("convert_wasm_module: bad userdata.\n");}
+ return dummy;
+}
+
+static Wasm_Module* check_wasm_module(lua_State* ls, int index) {
+ Wasm_Module* dummy;
+ luaL_checktype(ls, index, LUA_TUSERDATA);
+ dummy = (Wasm_Module*)luaL_checkudata(ls, index, "wasm_module");
+ if (dummy == NULL) {printf("check_wasm_module: bad userdata.\n");}
+ return dummy;
+}
#pragma weak main
int main(int argc, char** argv) {
diff --git a/bruiser/wasm.h b/bruiser/wasm.h
index af02a20..ec68553 100644
--- a/bruiser/wasm.h
+++ b/bruiser/wasm.h
@@ -192,16 +192,16 @@ typedef int32_t varuint32;
#endif
typedef struct Wasm_Module {
- W_Import_Section import_section;
- W_Function_Section function_section;
- W_Table_Section table_section;
- W_Memory_Section memory_section;
- W_Global_Section global_section;
- W_Export_Section export_section;
- W_Start_Section start_section;
- W_Element_Section element_section;
- W_Code_Section code_section;
- W_Data_Section data_section;
+ W_Import_Section* import_section;
+ W_Function_Section* function_section;
+ W_Table_Section* table_section;
+ W_Memory_Section* memory_section;
+ W_Global_Section* global_section;
+ W_Export_Section* export_section;
+ W_Start_Section* start_section;
+ W_Element_Section* element_section;
+ W_Code_Section* code_section;
+ W_Data_Section* data_section;
void** W_Custom_Sections;
char* name;
}Wasm_Module;
diff --git a/bruiser/wasm.sh b/bruiser/wasm.sh
index d8d4990..4863b9b 100755
--- a/bruiser/wasm.sh
+++ b/bruiser/wasm.sh
@@ -1,7 +1,7 @@
#!/bin/bash
cd $(dirname $0)
-gcc wasm.c -o wasme
-./wasme
+gcc wasm.c -o wasme -L ./lua-5.3.4/src/ -llua -lm -ldl
+./wasme || exit $?
rm ./wasme