aboutsummaryrefslogtreecommitdiffstats
path: root/bruiser
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bruiser/autogen/wasm/ltg/luwasm.xml50
-rw-r--r--bruiser/lua-scripts/wasmtest.lua170
2 files changed, 188 insertions, 32 deletions
diff --git a/bruiser/autogen/wasm/ltg/luwasm.xml b/bruiser/autogen/wasm/ltg/luwasm.xml
index 3e10a40..6db8b7b 100644
--- a/bruiser/autogen/wasm/ltg/luwasm.xml
+++ b/bruiser/autogen/wasm/ltg/luwasm.xml
@@ -99,76 +99,76 @@
</Custom_Section>
</Read>
<Definition>
- <Init_Expr name="init_expr_t" isaggregate="true" luatype="table">
+ <Init_Expr name="init_expr_t" isaggregate="true" luatype="lightuserdata">
<Code name="code" type="string" count="1" size="-1" delimiter="11" luatype="integer"></Code>
</Init_Expr>
- <Resizable_Limit name="resizable_limit_t" isaggregate="true" luatype="table">
+ <Resizable_Limit name="resizable_limit_t" isaggregate="true" luatype="lightuserdata">
<Flags name="flags" encoding="leb128u" type="uint8" count="1" luatype="integer"></Flags>
<Initial name="initial" encoding="leb128u" type="uint32" count="1" luatype="integer"></Initial>
<Maximum name="maximum" encoding="leb128u" type="uint32" count="1" luatype="integer"></Maximum>
</Resizable_Limit>
- <Global_Type name="global_type_t" isaggregate="true" luatype="table">
+ <Global_Type name="global_type_t" isaggregate="true" luatype="lightuserdata">
<Value_Type name="value_type" type="uint32" count="1" luatype="integer"></Value_Type>
<Mutability name="mutability" encoding="leb128u" type="uint8" count="1" luatype="integer"></Mutability>
</Global_Type>
- <Table_Type name="table_type_t" isaggregate="true" luatype="table">
+ <Table_Type name="table_type_t" isaggregate="true" luatype="lightuserdata">
<Element_Type name="element_type" encoding="leb128u" type="uint8" count="1" luatype="integer"></Element_Type>
- <Resizable_Limit name="resizable_limit" count="1" type="self::Resizable_Limit" luatype="table"></Resizable_Limit>
+ <Resizable_Limit name="resizable_limit" count="1" type="self::Resizable_Limit" luatype="lightuserdata"></Resizable_Limit>
</Table_Type>
- <Memory_Type name="memory_type_t" isaggregate="true" luatype="table">
- <Resizable_Limit count="1" type="self::Resizable_Limit" name="resizable_limit" luatype="table"></Resizable_Limit>
+ <Memory_Type name="memory_type_t" isaggregate="true" luatype="lightuserdata">
+ <Resizable_Limit count="1" type="self::Resizable_Limit" name="resizable_limit" luatype="lightuserdata"></Resizable_Limit>
</Memory_Type>
- <Type_Section_Entry name="W_Type_Section_Entry" isaggregate="true" luatype="table">
+ <Type_Section_Entry name="W_Type_Section_Entry" isaggregate="true" luatype="lightuserdata">
<Form name="form" encoding="leb128u" type="uint8" count="1" luatype="integer"/>
<Param_Count name="param_count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
<Param_Types name="param_types" encoding="leb128u" type="uint8" count="self::Param_Count" luatype="integer"/>
<Return_Count name="return_count" encoding="leb128u" type="uint8" luatype="integer"/>
<Return_Types name="return_types" encoding="leb128u" type="uint8" count="self::Return_Count" luatype="integer"/>
</Type_Section_Entry>
- <Import_Section_Entry name="W_Import_Section_Entry" isaggregate="true" luatype="table">
+ <Import_Section_Entry name="W_Import_Section_Entry" isaggregate="true" luatype="lightuserdata">
<Module_Length name="module_length" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
<Module_Str name="module_str" type="string" count="1" size="self::Module_Length" luatype="string"/>
<Field_Len name="field_len" encoding="leb128u" type="uint32" couny="1" luatype="integer"/>
<Field_Str name="field_str" type="string" count="1" size="self::Field_Len" luatype="string"/>
<Kind name="kind" encoding="leb128u" type="uint8" count="1" luatype="integer"/>
<Type name="type" conditional="true" condition="self::Kind" type="FT::conditional" luatype="conditional">
- <condition0 name="type" encoding="leb128u" type="uint32" luatype="integer">0</condition0>
- <condition1 name="type" type="self::Table_Type" luatype="table">1</condition1>
- <condition2 name="type" type="self::Memory_Type" luatype="table">2</condition2>
- <condition3 name="type" type="self::Global_Type" luatype="table">3</condition3>
+ <condition0 name="type" encoding="leb128u" type="uint32" luatype="lightuserdata">0</condition0>
+ <condition1 name="type" type="self::Table_Type" luatype="lightuserdata">1</condition1>
+ <condition2 name="type" type="self::Memory_Type" luatype="lightuserdata">2</condition2>
+ <condition3 name="type" type="self::Global_Type" luatype="lightuserdata">3</condition3>
</Type>
</Import_Section_Entry>
- <Global_Entry name="W_Global_Entry" isaggregate="true" luatype="table">
- <Global_Type name="type" type="self::Global_Type" count="1" luatype="table"/>
- <Init name="init" type="self::Init_Expr" count="1" luatype="table"/>
+ <Global_Entry name="W_Global_Entry" isaggregate="true" luatype="lightuserdata">
+ <Global_Type name="type" type="self::Global_Type" count="1" luatype="lightuserdata"/>
+ <Init name="init" type="self::Init_Expr" count="1" luatype="lightuserdata"/>
</Global_Entry>
- <Export_Entry name="W_Export_Entry" isaggregate="true" luatype="table">
+ <Export_Entry name="W_Export_Entry" isaggregate="true" luatype="lightuserdata">
<Field_Len name="field_len" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
<Field_Str name="field_str" type="string" count="1" size="self::Field_Len" luatype="string"/>
<Kind name="kind" encoding="leb128u" type="uint8" count="1" luatype="integer"/>
<Index name="index" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
</Export_Entry>
- <Element_Segment name="W_Element_Segment" isaggregate="true" luatype="table">
+ <Element_Segment name="W_Element_Segment" isaggregate="true" luatype="lightuserdata">
<Index name="index" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
- <Init name="init" type="self::Init_Expr" count="1" luatype="table"/>
+ <Init name="init" type="self::Init_Expr" count="1" luatype="lightuserdata"/>
<Num_Length name="num_length" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
<Elems name="elems" encoding="leb128u" type="uint32" count="self::Num_Length" luatype="integer"/>
</Element_Segment>
- <Local_Entry name="W_Local_Entry" isaggregate="true" luatype="table">
+ <Local_Entry name="W_Local_Entry" isaggregate="true" luatype="lightuserdata">
<Count name="count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
<Type name="type" encoding="leb128u" type="uint16" count="self::Count" luatype="integer"/>
</Local_Entry>
- <Function_Body name="W_Function_Body" isaggregate="true" luatype="table">
+ <Function_Body name="W_Function_Body" isaggregate="true" luatype="lightuserdata">
<Body_size name="body_size" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
<Local_Count name="local_count" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
- <Local_Entries name="locals" type="self::Local_Entry" count="self::Local_Count" luatype="table"/>
+ <Local_Entries name="locals" type="self::Local_Entry" count="self::Local_Count" luatype="lightuserdata"/>
<Code name="code" type="uint8" count="self::Body_size" luatype="integer"/>
</Function_Body>
- <Data_Segment name="W_Data_Segment" isaggregate="true" luatype="table">
+ <Data_Segment name="W_Data_Segment" isaggregate="true" luatype="lightuserdata">
<Index name="index" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
- <Offset name="offset" type="self::Init_Expr" count="1" luatype="table"/>
+ <Offset name="offset" type="self::Init_Expr" count="1" luatype="lightuserdata"/>
<Size name="size" encoding="leb128u" type="uint32" count="1" luatype="integer"/>
- <Data name="data" type="uint8" count="self::Size" luatype="table"/>
+ <Data name="data" type="uint8" count="self::Size" luatype="lightuserdata"/>
</Data_Segment>
</Definition>
</FT>
diff --git a/bruiser/lua-scripts/wasmtest.lua b/bruiser/lua-scripts/wasmtest.lua
index a287b01..315c5f4 100644
--- a/bruiser/lua-scripts/wasmtest.lua
+++ b/bruiser/lua-scripts/wasmtest.lua
@@ -1,4 +1,7 @@
+colors = require("ansicolors")
+
+-- aka dump wasm
function demo4()
local a = getwasmobj("/home/bloodstalker/devi/hell2/bruiser/autogen/wasm/ft/test.wasm")
print(a)
@@ -6,13 +9,166 @@ function demo4()
for k, v in pairs(a) do
print(k, v, type(k), type(v))
end
- print("type section:")
- io.write(tostring(a["type_section"]:id()).."\n")
- io.write(tostring(a["type_section"]:payloadlength()).."\n")
- io.write(tostring(a["type_section"]:namelength()).."\n")
- io.write(tostring(a["type_section"]:name()).."\n")
- io.write(tostring(a["type_section"]:count()).."\n")
- io.write(tostring(a["type_section"]:entries()).."\n")
+
+ print(colors("%{green}".."\ntype section:"))
+ if a["type_section"] ~= nil then
+ io.write(tostring("id:"..a["type_section"]:id()).."\n")
+ io.write(tostring("payloadlength:"..a["type_section"]:payloadlength()).."\n")
+ io.write(tostring("namelength:"..a["type_section"]:namelength()).."\n")
+ io.write(tostring("name:"..a["type_section"]:name()).."\n")
+ io.write(tostring("count:"..a["type_section"]:count()).."\n")
+ io.write("entries"..tostring(a["type_section"]:entries()).."\n")
+ for k, v in pairs(a["type_section"]:entries()) do
+ io.write(v:form().."\t")
+ io.write(v:param_count().."\t")
+ io.write(v:param_types().."\t")
+ io.write(v:return_count().."\t")
+ io.write(v:return_types().."\n")
+ end
+ else
+ print(colors("%{red}".."section doesnt exist."))
+ end
+
+ print(colors("%{green}".."\nimport section:"))
+ if a["import_section"] ~= nil then
+ io.write("id:"..tostring(a["import_section"]:id()).."\n")
+ io.write("payloadlength:"..tostring(a["import_section"]:payloadlength()).."\n")
+ io.write("namelength:"..tostring(a["import_section"]:namelength()).."\n")
+ io.write("name:"..tostring(a["import_section"]:name()).."\n")
+ io.write("count:"..tostring(a["import_section"]:count()).."\n")
+ io.write("entries"..tostring(a["import_section"]:entries()).."\n")
+ for k, v in pairs(a["import_section"]:entries()) do
+ --print(k, v, type(v))
+ io.write(v:module_length().."\t")
+ io.write(v:module_str().."\t")
+ io.write(v:field_len().."\t")
+ io.write(v:field_str().."\t")
+ io.write(v:kind().."\n")
+ end
+ else
+ print(colors("%{red}".."section doesnt exist."))
+ end
+
+ print(colors("%{green}".."\nfunction section:"))
+ if a["function_section"] ~= nil then
+ io.write("id:"..tostring(a["function_section"]:id()).."\n")
+ io.write("payloadlength:"..tostring(a["function_section"]:payloadlength()).."\n")
+ io.write("namelength:"..tostring(a["function_section"]:namelength()).."\n")
+ io.write("name:"..tostring(a["function_section"]:name()).."\n")
+ io.write("count:"..tostring(a["function_section"]:count()).."\n")
+ io.write("types:"..tostring(a["function_section"]:types()).."\n")
+ else
+ print(colors("%{red}".."section doesnt exist."))
+ end
+
+ print(colors("%{green}".."\ntable section:"))
+ if a["table_section"] ~= nil then
+ io.write("id:"..tostring(a["table_section"]:id()).."\n")
+ io.write("payloadlength:"..tostring(a["table_section"]:payloadlength()).."\n")
+ io.write("namelength:"..tostring(a["table_section"]:namelength()).."\n")
+ io.write("name:"..tostring(a["table_section"]:name()).."\n")
+ io.write("count:"..tostring(a["table_section"]:count()).."\n")
+ io.write("entries:"..tostring(a["table_section"]:entries()).."\n")
+ else
+ print(colors("%{red}".."section doesnt exist."))
+ end
+
+ print(colors("%{green}".."\nmemory section:"))
+ if a["memory_section"] ~= nil then
+ io.write("id:"..tostring(a["memory_section"]:id()).."\n")
+ io.write("payloadlength:"..tostring(a["memory_section"]:payloadlength()).."\n")
+ io.write("namelength:"..tostring(a["memory_section"]:namelength()).."\n")
+ io.write("name:"..tostring(a["memory_section"]:name()).."\n")
+ --io.write("count:"..tostring(a["memory_section"]:count()).."\n")
+ io.write("entries:"..tostring(a["memory_section"]:entries()).."\n")
+ else
+ print(colors("%{red}".."section doesnt exist."))
+ end
+
+ print(colors("%{green}".."\nglobal section:"))
+ if (a["global_section"] ~= nil) then
+ io.write("id:"..tostring(a["global_section"]:id()).."\n")
+ io.write("payloadlength:"..tostring(a["global_section"]:payloadlength()).."\n")
+ io.write("namelength:"..tostring(a["global_section"]:namelength()).."\n")
+ io.write("name:"..tostring(a["global_section"]:name()).."\n")
+ io.write("count:"..tostring(a["global_section"]:count()).."\n")
+ io.write("globals:"..tostring(a["global_section"]:globals()).."\n")
+ else
+ print(colors("%{red}".."section doesnt exist."))
+ end
+
+ print(colors("%{green}".."\nexport section:"))
+ if (a["export_section"] ~= nil) then
+ io.write("id:"..tostring(a["export_section"]:id()).."\n")
+ io.write("payloadlength:"..tostring(a["export_section"]:payloadlength()).."\n")
+ io.write("namelength:"..tostring(a["export_section"]:namelength()).."\n")
+ io.write("name:"..tostring(a["export_section"]:name()).."\n")
+ io.write("count:"..tostring(a["export_section"]:count()).."\n")
+ io.write("entries:"..tostring(a["export_section"]:entries()).."\n")
+ else
+ print(colors("%{red}".."section doesnt exist."))
+ end
+
+ print(colors("%{green}".."\nstart section:"))
+ if (a["start_section"] ~= nil) then
+ io.write("id:"..tostring(a["start_section"]:id()).."\n")
+ io.write("payloadlength:"..tostring(a["start_section"]:payloadlength()).."\n")
+ io.write("namelength:"..tostring(a["start_section"]:namelength()).."\n")
+ io.write("name:"..tostring(a["start_section"]:name()).."\n")
+ io.write("index:"..tostring(a["start_section"]:index()).."\n")
+ else
+ print(colors("%{red}".."section doesnt exist."))
+ end
+
+ print(colors("%{green}".."\nelement section:"))
+ if (a["element_section"] ~= nil) then
+ io.write("id:"..tostring(a["element_section"]:id()).."\n")
+ io.write("payloadlength:"..tostring(a["element_section"]:payloadlength()).."\n")
+ io.write("namelength:"..tostring(a["element_section"]:namelength()).."\n")
+ io.write("name:"..tostring(a["element_section"]:name()).."\n")
+ io.write("count:"..tostring(a["element_section"]:count()).."\n")
+ io.write("entries:"..tostring(a["element_section"]:entries()).."\n")
+ else
+ print(colors("%{red}".."section doesnt exist."))
+ end
+
+ print(colors("%{green}".."\ncode section:"))
+ if (a["code_section"] ~= nil) then
+ io.write("id:"..tostring(a["code_section"]:id()).."\n")
+ io.write("payloadlength:"..tostring(a["code_section"]:payloadlength()).."\n")
+ io.write("namelength:"..tostring(a["code_section"]:namelength()).."\n")
+ io.write("name:"..tostring(a["code_section"]:name()).."\n")
+ io.write("count:"..tostring(a["code_section"]:count()).."\n")
+ io.write("bodies:"..tostring(a["code_section"]:bodies()).."\n")
+ for k,v in pairs(a["code_section"]:bodies()) do
+ io.write(v:body_size())
+ io.write(v:local_count())
+ --io.write(v:locals())
+ end
+ else
+ print(colors("%{red}".."section doesnt exist."))
+ end
+
+ print(colors("%{green}".."\ndata section:"))
+ if (a["data_section"] ~= nil) then
+ io.write("id:"..tostring(a["data_section"]:id()).."\n")
+ io.write("payloadlength:"..tostring(a["data_section"]:payloadlength()).."\n")
+ io.write("namelength:"..tostring(a["data_section"]:namelength()).."\n")
+ io.write("name:"..tostring(a["data_section"]:name()).."\n")
+ io.write("count:"..tostring(a["data_section"]:count()).."\n")
+ io.write("entries:"..tostring(a["data_section"]:entries()).."\n")
+ if type(a["data_section"]:entries()) == "table" then
+ for k,v in pairs(a["data_section"]:entries()) do
+ io.write(v:index().."\t")
+ io.write(tostring(v:offset()).."\t")
+ io.write(v:size().."\n")
+ --io.write(v:data().."\n")
+ end
+ end
+ else
+ print(colors("%{red}".."section doesnt exist."))
+ end
+
end
demo4()