diff options
Diffstat (limited to '')
-rw-r--r-- | bruiser/wasm.h | 13 | ||||
-rwxr-xr-x | bruiser/wasm/dwasm.py | 38 |
2 files changed, 8 insertions, 43 deletions
diff --git a/bruiser/wasm.h b/bruiser/wasm.h index ec68553..5c21c99 100644 --- a/bruiser/wasm.h +++ b/bruiser/wasm.h @@ -97,7 +97,7 @@ typedef int32_t varuint32; }W_Import_Section_Entry; typedef struct { - int count; + varuint32 count; W_Import_Section_Entry** entries; }W_Import_Section; @@ -119,7 +119,7 @@ typedef int32_t varuint32; typedef struct { global_type_t* type; - init_expr_t init; + init_expr_t* init; }W_Global_Entry; typedef struct { @@ -131,7 +131,7 @@ typedef int32_t varuint32; varuint32 field_len; char* field_str; enum external_kind_t kind; - int varuint32; + varuint32 index; }W_Export_Entry; typedef struct { @@ -145,7 +145,7 @@ typedef int32_t varuint32; typedef struct { varuint32 index; - init_expr_t offset; + init_expr_t* offset; varuint32 num_length; varuint32* elems; }W_Elem_Segment; @@ -175,14 +175,14 @@ typedef int32_t varuint32; typedef struct { varuint32 index; - init_expr_t offset; + init_expr_t* offset; varuint32 size; char* data; }W_Data_Segment; typedef struct { varuint32 count; - struct W_Data_Segment** entries; + W_Data_Segment** entries; }W_Data_Section; #if 0 @@ -192,6 +192,7 @@ typedef int32_t varuint32; #endif typedef struct Wasm_Module { + W_Type_Section* type_section; W_Import_Section* import_section; W_Function_Section* function_section; W_Table_Section* table_section; diff --git a/bruiser/wasm/dwasm.py b/bruiser/wasm/dwasm.py index 93217b4..28f3c4d 100755 --- a/bruiser/wasm/dwasm.py +++ b/bruiser/wasm/dwasm.py @@ -5,45 +5,9 @@ import code import readline import signal import sys -from parse import premain +from parse import Argparser, premain, SigHandler_SIGINT from utils import ParseFlags -def SigHandler_SIGINT(signum, frame): - print() - sys.exit(0) - -class Argparser(object): - def __init__(self): - parser = argparse.ArgumentParser() - parser.add_argument("--wast", type=str, help="path to the wasm text file") - parser.add_argument("--wasm", type=str, nargs='+', help="path to the wasm object file") - parser.add_argument("--asb", type=str, help="path to the wast file to assemble") - parser.add_argument("--dis", type=str, help="path to the wasm file to disassemble") - parser.add_argument("-o", type=str, help="the path to the output file") - parser.add_argument("--dbg", action='store_true', help="print debug info", default=False) - parser.add_argument("--unval", action='store_true', help="skips validation tests", default=False) - parser.add_argument("--memdump", type=int, help="dumps the linear memory") - parser.add_argument("--idxspc", action='store_true', help="print index space data", default=False) - parser.add_argument("--run", action='store_true', help="runs the start function", default=False) - parser.add_argument("--metric", action='store_true', help="print metrics", default=False) - parser.add_argument("--gas", action='store_true', help="print gas usage", default=False) - parser.add_argument("--entry", type=str, help="name of the function that will act as the entry point into execution") - parser.add_argument("--link", type=str, nargs="+", help="link the following wasm modules") - parser.add_argument("--sectiondump", type=str, help="dumps the section provided") - parser.add_argument("--hexdump", type=int, help="dumps all sections") - parser.add_argument("--dbgsection", type=str, help="dumps the parsed section provided", default="") - parser.add_argument("--interactive", action='store_true', help="open in cli mode", default=False) - parser.add_argument("--rawdump", type=int, nargs=2, help="dumps all sections") - self.args = parser.parse_args() - if self.args.wasm is not None and self.args.wast is not None: - raise Exception("the --wast option and the --wasm option cannot\ - be set at the same time. you need to choose one.") - - def getParseFlags(self): - return(ParseFlags(self.args.wast, self.args.wasm, self.args.asb, self.args.dis, - self.args.o, self.args.dbg, self.args.unval, self.args.memdump, - self.args.idxspc, self.args.run, self.args.metric, self.args.gas, self.args.entry)) - def main(): signal.signal(signal.SIGINT, SigHandler_SIGINT) argparser = Argparser() |