diff options
Diffstat (limited to 'bruiser')
-rw-r--r-- | bruiser/asmrewriter.c | 1 | ||||
-rwxr-xr-x | bruiser/autogen/wasm/ltg.sh | 2 | ||||
-rw-r--r-- | bruiser/lua-scripts/wasm.lua | 204 | ||||
-rw-r--r-- | bruiser/lua-scripts/wasmtest.lua | 34 | ||||
m--------- | bruiser/tablegen | 0 |
5 files changed, 36 insertions, 205 deletions
diff --git a/bruiser/asmrewriter.c b/bruiser/asmrewriter.c index 899c5eb..b082a2d 100644 --- a/bruiser/asmrewriter.c +++ b/bruiser/asmrewriter.c @@ -302,6 +302,7 @@ int jmpt_register(lua_State* __ls) { lua_newtable(__ls); luaL_setfuncs(__ls, jmpt_methods, 0); luaL_newmetatable(__ls, "jmp_s_t"); + luaL_setfuncs(__ls, jmpt_methods, 0); luaL_setfuncs(__ls, jmpt_meta, 0); lua_pushliteral(__ls, "__index"); lua_pushvalue(__ls, -3); diff --git a/bruiser/autogen/wasm/ltg.sh b/bruiser/autogen/wasm/ltg.sh index 9adecef..3014c00 100755 --- a/bruiser/autogen/wasm/ltg.sh +++ b/bruiser/autogen/wasm/ltg.sh @@ -1,6 +1,6 @@ #!/bin/sh cd $(dirname $0) -"../../tablegen/luatablegen.py" --out ./ltg/ --luaheader ../../../lua-5.3.4/src --headeraggr ./ltg/wasm_tables.h --lualibpath ./ltg/wasm.lua --docpath ./ltg/wasm.md --xml ./wasm.xml --tbldefs ./ltg/ --name wasm --anon +"../../tablegen/luatablegen.py" --out ./ltg/ --luaheader ../../../lua-5.3.4/src --headeraggr ./ltg/wasm_tables.h --lualibpath ../../lua-scripts/wasmextra.lua --docpath ./ltg/wasm.md --xml ./wasm.xml --tbldefs ./ltg/ --name wasm --anon --lualibname wasmextra clang-format ./ltg/*.c ./ltg/*.h -i for filename in ./ltg/*.c; do gcc -c $filename > /dev/null 2>&1 diff --git a/bruiser/lua-scripts/wasm.lua b/bruiser/lua-scripts/wasm.lua deleted file mode 100644 index 88588a6..0000000 --- a/bruiser/lua-scripts/wasm.lua +++ /dev/null @@ -1,204 +0,0 @@ --- automatically generated by luatablegen -local wasm = {} - -setmetatable(init_expr_t, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(resizable_limit_t, {__call = - function(self, arg0, arg1, arg2) - local t = self.new(arg0, arg1, arg2) - return t - end - } -) - -setmetatable(global_type_t, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(table_type_t, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(memory_type_t, {__call = - function(self, arg0) - local t = self.new(arg0) - return t - end - } -) - -setmetatable(W_Type_Section_Entry, {__call = - function(self, arg0, arg1, arg2, arg3, arg4) - local t = self.new(arg0, arg1, arg2, arg3, arg4) - return t - end - } -) - -setmetatable(W_Type_Section, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(W_Import_Section_Entry, {__call = - function(self, arg0, arg1, arg2, arg3, arg4, arg5) - local t = self.new(arg0, arg1, arg2, arg3, arg4, arg5) - return t - end - } -) - -setmetatable(W_Import_Section, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(W_Function_Section, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(W_Table_Section, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(W_Memory_Section, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(W_Global_Entry, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(W_Global_Section, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(W_Export_Entry, {__call = - function(self, arg0, arg1, arg2, arg3) - local t = self.new(arg0, arg1, arg2, arg3) - return t - end - } -) - -setmetatable(W_Export_Section, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(W_Start_Section, {__call = - function(self, arg0) - local t = self.new(arg0) - return t - end - } -) - -setmetatable(W_Elem_Segment, {__call = - function(self, arg0, arg1, arg2, arg3) - local t = self.new(arg0, arg1, arg2, arg3) - return t - end - } -) - -setmetatable(W_Element_Section, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(W_Local_Entry, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(W_Function_Body, {__call = - function(self, arg0, arg1, arg2, arg3) - local t = self.new(arg0, arg1, arg2, arg3) - return t - end - } -) - -setmetatable(W_Code_Section, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(W_Data_Segment, {__call = - function(self, arg0, arg1, arg2, arg3) - local t = self.new(arg0, arg1, arg2, arg3) - return t - end - } -) - -setmetatable(W_Data_Section, {__call = - function(self, arg0, arg1) - local t = self.new(arg0, arg1) - return t - end - } -) - -setmetatable(Wasm_Module, {__call = - function(self, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) - local t = self.new(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) - return t - end - } -) - -return wasm diff --git a/bruiser/lua-scripts/wasmtest.lua b/bruiser/lua-scripts/wasmtest.lua index 50dfa4f..fef8858 100644 --- a/bruiser/lua-scripts/wasmtest.lua +++ b/bruiser/lua-scripts/wasmtest.lua @@ -284,6 +284,7 @@ end function libwasm.demo_setters(wasm_path) local a = getwasmobj(wasm_path) + wasmextra = require("wasmextra") --type section setters do @@ -333,6 +334,9 @@ function libwasm.demo_setters(wasm_path) pre = a["type_section"]:count() a["type_section"]:set_count(13) post = a["type_section"]:count() + -- not necessary anymore since the library code checks for null before dereferencing + -- though that only works if we used calloc instead of malloc + a["type_section"]:set_count(pre) if pre == post then io.write(colors("%{red}".."type_section:count:failure\n")) success = false @@ -341,6 +345,36 @@ function libwasm.demo_setters(wasm_path) end --FIXME-entries + --for k,v in pairs(W_Type_Section_Entry) do + --print(k, v) + --end + print(#a["type_section"]:entries()) + local entry1 = W_Type_Section_Entry(1,2,3,4,5) + local entry2 = W_Type_Section_Entry(1,2,3,4,5) + local entry3 = W_Type_Section_Entry(1,2,3,4,5) + local new_entries = {} + new_entries[1] = entry1 + new_entries[2] = entry2 + new_entries[3] = entry2 + pre = a["type_section"]:entries() + a["type_section"]:set_entries(new_entries) + a["type_section"]:set_count(3) + print(#a["type_section"]:entries()) + post = a["type_section"]:entries() + if pre == post then + io.write(colors("%{red}".."type_section:entries:failure\n")) + success = false + else + io.write(colors("%{green}".."type_section:entries:pass\n")) + end + for k,v in pairs(a["type_section"]:entries()) do + print("fuckkkkk") + print("form:"..v:form()) + print("param_count:"..v:param_count()) + print("param_types:"..v:param_types()) + print("return_count:"..v:return_count()) + print("return_types:"..v:return_types()) + end end end diff --git a/bruiser/tablegen b/bruiser/tablegen -Subproject ec0f1d881c9f0da07e57f1c4a307fbc4e96313c +Subproject 47c85761f66dadd4e492a641fbd66893649ea83 |