diff options
40 files changed, 303 insertions, 304 deletions
diff --git a/src/apply-names.cc b/src/apply-names.cc index 76662fee..c78beb64 100644 --- a/src/apply-names.cc +++ b/src/apply-names.cc @@ -30,7 +30,7 @@ typedef WabtLabel* LabelPtr; WABT_DEFINE_VECTOR(label_ptr, LabelPtr); -typedef struct Context { +struct Context { WabtModule* module; WabtFunc* current_func; WabtExprVisitor visitor; @@ -38,7 +38,7 @@ typedef struct Context { WabtStringSliceVector param_index_to_name; WabtStringSliceVector local_index_to_name; LabelPtrVector labels; -} Context; +}; static void push_label(Context* ctx, WabtLabel* label) { wabt_append_label_ptr_value(&ctx->labels, &label); diff --git a/src/array.h b/src/array.h index 341c6243..766ff22d 100644 --- a/src/array.h +++ b/src/array.h @@ -22,10 +22,10 @@ #include "common.h" #define WABT_DEFINE_ARRAY(name, type) \ - typedef struct type##Array { \ + struct type##Array { \ type* data; \ size_t size; \ - } type##Array; \ + }; \ \ WABT_EXTERN_C_BEGIN \ static WABT_INLINE void wabt_destroy_##name##_array(type##Array* array) \ diff --git a/src/ast-lexer.cc b/src/ast-lexer.cc index 07fef8ee..3ded34d7 100644 --- a/src/ast-lexer.cc +++ b/src/ast-lexer.cc @@ -502,10 +502,10 @@ void wabt_destroy_ast_lexer(WabtAstLexer* lexer) { wabt_free(lexer); } -typedef enum WabtLineOffsetPosition { +enum WabtLineOffsetPosition { WABT_LINE_OFFSET_POSITION_START, WABT_LINE_OFFSET_POSITION_END, -} WabtLineOffsetPosition; +}; static WabtResult scan_forward_for_line_offset_in_buffer( const char* buffer_start, diff --git a/src/ast-lexer.h b/src/ast-lexer.h index 0b620be3..10c0f4c9 100644 --- a/src/ast-lexer.h +++ b/src/ast-lexer.h @@ -23,12 +23,12 @@ #include "common.h" #include "vector.h" -typedef enum WabtAstLexerSourceType { +enum WabtAstLexerSourceType { WABT_LEXER_SOURCE_TYPE_FILE, WABT_LEXER_SOURCE_TYPE_BUFFER, -} WabtAstLexerSourceType; +}; -typedef struct WabtAstLexerSource { +struct WabtAstLexerSource { WabtAstLexerSourceType type; union { FILE* file; @@ -38,9 +38,9 @@ typedef struct WabtAstLexerSource { size_t read_offset; } buffer; }; -} WabtAstLexerSource; +}; -typedef struct WabtAstLexer { +struct WabtAstLexer { WabtAstLexerSource source; const char* filename; int line; @@ -56,7 +56,7 @@ typedef struct WabtAstLexer { char* token; char* cursor; char* limit; -} WabtAstLexer; +}; WABT_EXTERN_C_BEGIN diff --git a/src/ast-parser-lexer-shared.h b/src/ast-parser-lexer-shared.h index 0b759556..1d599c5d 100644 --- a/src/ast-parser-lexer-shared.h +++ b/src/ast-parser-lexer-shared.h @@ -30,67 +30,67 @@ #define WABT_INVALID_LINE_OFFSET ((size_t)~0) -typedef struct WabtExprList { +struct WabtExprList { WabtExpr* first; WabtExpr* last; size_t size; -} WabtExprList; +}; -typedef struct WabtTextListNode { +struct WabtTextListNode { WabtStringSlice text; struct WabtTextListNode* next; -} WabtTextListNode; +}; -typedef struct WabtTextList { +struct WabtTextList { WabtTextListNode* first; WabtTextListNode* last; -} WabtTextList; +}; -typedef struct WabtOptionalExport { +struct WabtOptionalExport { WabtExport export_; bool has_export; -} WabtOptionalExport; +}; -typedef struct WabtExportedFunc { +struct WabtExportedFunc { WabtFunc* func; WabtOptionalExport export_; -} WabtExportedFunc; +}; -typedef struct WabtExportedGlobal { +struct WabtExportedGlobal { WabtGlobal global; WabtOptionalExport export_; -} WabtExportedGlobal; +}; -typedef struct WabtExportedTable { +struct WabtExportedTable { WabtTable table; WabtElemSegment elem_segment; WabtOptionalExport export_; bool has_elem_segment; -} WabtExportedTable; +}; -typedef struct WabtExportedMemory { +struct WabtExportedMemory { WabtMemory memory; WabtDataSegment data_segment; WabtOptionalExport export_; bool has_data_segment; -} WabtExportedMemory; +}; -typedef enum WabtFuncFieldType { +enum WabtFuncFieldType { WABT_FUNC_FIELD_TYPE_EXPRS, WABT_FUNC_FIELD_TYPE_PARAM_TYPES, WABT_FUNC_FIELD_TYPE_BOUND_PARAM, WABT_FUNC_FIELD_TYPE_RESULT_TYPES, WABT_FUNC_FIELD_TYPE_LOCAL_TYPES, WABT_FUNC_FIELD_TYPE_BOUND_LOCAL, -} WabtFuncFieldType; +}; -typedef struct WabtBoundType { +struct WabtBoundType { WabtLocation loc; WabtStringSlice name; WabtType type; -} WabtBoundType; +}; -typedef struct WabtFuncField { +struct WabtFuncField { WabtFuncFieldType type; union { WabtExpr* first_expr; /* WABT_FUNC_FIELD_TYPE_EXPRS */ @@ -98,9 +98,9 @@ typedef struct WabtFuncField { WabtBoundType bound_type; /* WABT_FUNC_FIELD_TYPE_BOUND_{LOCAL, PARAM} */ }; struct WabtFuncField* next; -} WabtFuncField; +}; -typedef union WabtToken { +union WabtToken { /* terminals */ WabtStringSlice text; WabtType type; @@ -144,9 +144,9 @@ typedef union WabtToken { uint64_t u64; WabtVar var; WabtVarVector vars; -} WabtToken; +}; -typedef struct WabtAstParser { +struct WabtAstParser { WabtScript script; WabtSourceErrorHandler* error_handler; int errors; @@ -154,7 +154,7 @@ typedef struct WabtAstParser { int16_t* yyssa; YYSTYPE* yyvsa; YYLTYPE* yylsa; -} WabtAstParser; +}; WABT_EXTERN_C_BEGIN int wabt_ast_lexer_lex(union WabtToken*, diff --git a/src/ast-parser.y b/src/ast-parser.y index abc2c640..d5f55e91 100644 --- a/src/ast-parser.y +++ b/src/ast-parser.y @@ -179,11 +179,11 @@ static bool is_empty_signature(WabtFuncSignature* sig); static void append_implicit_func_declaration(WabtLocation*, WabtModule*, WabtFuncDeclaration*); -typedef struct BinaryErrorCallbackData { +struct BinaryErrorCallbackData { WabtLocation* loc; WabtAstLexer* lexer; WabtAstParser* parser; -} BinaryErrorCallbackData; +}; static void on_read_binary_error(uint32_t offset, const char* error, void* user_data); diff --git a/src/ast-writer.cc b/src/ast-writer.cc index 3acc26ae..84296a40 100644 --- a/src/ast-writer.cc +++ b/src/ast-writer.cc @@ -44,14 +44,14 @@ static const uint8_t s_is_char_escaped[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; -typedef enum NextChar { +enum NextChar { NEXT_CHAR_NONE, NEXT_CHAR_SPACE, NEXT_CHAR_NEWLINE, NEXT_CHAR_FORCE_NEWLINE, -} NextChar; +}; -typedef struct Context { +struct Context { WabtStream stream; WabtResult result; int indent; @@ -65,7 +65,7 @@ typedef struct Context { int table_index; int memory_index; int func_type_index; -} Context; +}; static void indent(Context* ctx) { ctx->indent += INDENT_SIZE; @@ -26,25 +26,25 @@ #include "type-vector.h" #include "vector.h" -typedef enum WabtVarType { +enum WabtVarType { WABT_VAR_TYPE_INDEX, WABT_VAR_TYPE_NAME, -} WabtVarType; +}; -typedef struct WabtVar { +struct WabtVar { WabtLocation loc; WabtVarType type; union { int64_t index; WabtStringSlice name; }; -} WabtVar; +}; WABT_DEFINE_VECTOR(var, WabtVar); typedef WabtStringSlice WabtLabel; WABT_DEFINE_VECTOR(string_slice, WabtStringSlice); -typedef struct WabtConst { +struct WabtConst { WabtLocation loc; WabtType type; union { @@ -53,10 +53,10 @@ typedef struct WabtConst { uint32_t f32_bits; uint64_t f64_bits; }; -} WabtConst; +}; WABT_DEFINE_VECTOR(const, WabtConst); -typedef enum WabtExprType { +enum WabtExprType { WABT_EXPR_TYPE_BINARY, WABT_EXPR_TYPE_BLOCK, WABT_EXPR_TYPE_BR, @@ -84,17 +84,16 @@ typedef enum WabtExprType { WABT_EXPR_TYPE_TEE_LOCAL, WABT_EXPR_TYPE_UNARY, WABT_EXPR_TYPE_UNREACHABLE, -} WabtExprType; +}; typedef WabtTypeVector WabtBlockSignature; -typedef struct WabtBlock { +struct WabtBlock { WabtLabel label; WabtBlockSignature sig; struct WabtExpr* first; -} WabtBlock; +}; -typedef struct WabtExpr WabtExpr; struct WabtExpr { WabtLocation loc; WabtExprType type; @@ -113,15 +112,15 @@ struct WabtExpr { }; }; -typedef struct WabtFuncSignature { +struct WabtFuncSignature { WabtTypeVector param_types; WabtTypeVector result_types; -} WabtFuncSignature; +}; -typedef struct WabtFuncType { +struct WabtFuncType { WabtStringSlice name; WabtFuncSignature sig; -} WabtFuncType; +}; typedef WabtFuncType* WabtFuncTypePtr; WABT_DEFINE_VECTOR(func_type_ptr, WabtFuncTypePtr); @@ -132,64 +131,64 @@ enum { }; typedef uint32_t WabtFuncDeclarationFlags; -typedef struct WabtFuncDeclaration { +struct WabtFuncDeclaration { WabtFuncDeclarationFlags flags; WabtVar type_var; WabtFuncSignature sig; -} WabtFuncDeclaration; +}; -typedef struct WabtFunc { +struct WabtFunc { WabtStringSlice name; WabtFuncDeclaration decl; WabtTypeVector local_types; WabtBindingHash param_bindings; WabtBindingHash local_bindings; WabtExpr* first_expr; -} WabtFunc; +}; typedef WabtFunc* WabtFuncPtr; WABT_DEFINE_VECTOR(func_ptr, WabtFuncPtr); -typedef struct WabtGlobal { +struct WabtGlobal { WabtStringSlice name; WabtType type; bool mutable_; WabtExpr* init_expr; -} WabtGlobal; +}; typedef WabtGlobal* WabtGlobalPtr; WABT_DEFINE_VECTOR(global_ptr, WabtGlobalPtr); -typedef struct WabtTable { +struct WabtTable { WabtStringSlice name; WabtLimits elem_limits; -} WabtTable; +}; typedef WabtTable* WabtTablePtr; WABT_DEFINE_VECTOR(table_ptr, WabtTablePtr); -typedef struct WabtElemSegment { +struct WabtElemSegment { WabtVar table_var; WabtExpr* offset; WabtVarVector vars; -} WabtElemSegment; +}; typedef WabtElemSegment* WabtElemSegmentPtr; WABT_DEFINE_VECTOR(elem_segment_ptr, WabtElemSegmentPtr); -typedef struct WabtMemory { +struct WabtMemory { WabtStringSlice name; WabtLimits page_limits; -} WabtMemory; +}; typedef WabtMemory* WabtMemoryPtr; WABT_DEFINE_VECTOR(memory_ptr, WabtMemoryPtr); -typedef struct WabtDataSegment { +struct WabtDataSegment { WabtVar memory_var; WabtExpr* offset; void* data; size_t size; -} WabtDataSegment; +}; typedef WabtDataSegment* WabtDataSegmentPtr; WABT_DEFINE_VECTOR(data_segment_ptr, WabtDataSegmentPtr); -typedef struct WabtImport { +struct WabtImport { WabtStringSlice module_name; WabtStringSlice field_name; WabtExternalKind kind; @@ -202,19 +201,19 @@ typedef struct WabtImport { WabtMemory memory; WabtGlobal global; }; -} WabtImport; +}; typedef WabtImport* WabtImportPtr; WABT_DEFINE_VECTOR(import_ptr, WabtImportPtr); -typedef struct WabtExport { +struct WabtExport { WabtStringSlice name; WabtExternalKind kind; WabtVar var; -} WabtExport; +}; typedef WabtExport* WabtExportPtr; WABT_DEFINE_VECTOR(export_ptr, WabtExportPtr); -typedef enum WabtModuleFieldType { +enum WabtModuleFieldType { WABT_MODULE_FIELD_TYPE_FUNC, WABT_MODULE_FIELD_TYPE_GLOBAL, WABT_MODULE_FIELD_TYPE_IMPORT, @@ -225,9 +224,9 @@ typedef enum WabtModuleFieldType { WABT_MODULE_FIELD_TYPE_MEMORY, WABT_MODULE_FIELD_TYPE_DATA_SEGMENT, WABT_MODULE_FIELD_TYPE_START, -} WabtModuleFieldType; +}; -typedef struct WabtModuleField { +struct WabtModuleField { WabtLocation loc; WabtModuleFieldType type; struct WabtModuleField* next; @@ -243,9 +242,9 @@ typedef struct WabtModuleField { WabtDataSegment data_segment; WabtVar start; }; -} WabtModuleField; +}; -typedef struct WabtModule { +struct WabtModule { WabtLocation loc; WabtStringSlice name; WabtModuleField* first_field; @@ -275,19 +274,19 @@ typedef struct WabtModule { WabtBindingHash func_type_bindings; WabtBindingHash table_bindings; WabtBindingHash memory_bindings; -} WabtModule; +}; -typedef enum WabtRawModuleType { +enum WabtRawModuleType { WABT_RAW_MODULE_TYPE_TEXT, WABT_RAW_MODULE_TYPE_BINARY, -} WabtRawModuleType; +}; /* "raw" means that the binary module has not yet been decoded. This is only * necessary when embedded in assert_invalid. In that case we want to defer * decoding errors until wabt_check_assert_invalid is called. This isn't needed * when parsing text, as assert_invalid always assumes that text parsing * succeeds. */ -typedef struct WabtRawModule { +struct WabtRawModule { WabtRawModuleType type; union { WabtModule* text; @@ -298,23 +297,23 @@ typedef struct WabtRawModule { size_t size; } binary; }; -} WabtRawModule; +}; -typedef enum WabtActionType { +enum WabtActionType { WABT_ACTION_TYPE_INVOKE, WABT_ACTION_TYPE_GET, -} WabtActionType; +}; -typedef struct WabtActionInvoke { +struct WabtActionInvoke { WabtStringSlice name; WabtConstVector args; -} WabtActionInvoke; +}; -typedef struct WabtActionGet { +struct WabtActionGet { WabtStringSlice name; -} WabtActionGet; +}; -typedef struct WabtAction { +struct WabtAction { WabtLocation loc; WabtActionType type; WabtVar module_var; @@ -322,9 +321,9 @@ typedef struct WabtAction { WabtActionInvoke invoke; WabtActionGet get; }; -} WabtAction; +}; -typedef enum WabtCommandType { +enum WabtCommandType { WABT_COMMAND_TYPE_MODULE, WABT_COMMAND_TYPE_ACTION, WABT_COMMAND_TYPE_REGISTER, @@ -340,9 +339,9 @@ typedef enum WabtCommandType { WABT_COMMAND_TYPE_ASSERT_TRAP, WABT_COMMAND_TYPE_ASSERT_EXHAUSTION, WABT_NUM_COMMAND_TYPES, -} WabtCommandType; +}; -typedef struct WabtCommand { +struct WabtCommand { WabtCommandType type; union { WabtModule module; @@ -357,15 +356,15 @@ typedef struct WabtCommand { } assert_malformed, assert_invalid, assert_unlinkable, assert_uninstantiable; }; -} WabtCommand; +}; WABT_DEFINE_VECTOR(command, WabtCommand); -typedef struct WabtScript { +struct WabtScript { WabtCommandVector commands; WabtBindingHash module_bindings; -} WabtScript; +}; -typedef struct WabtExprVisitor { +struct WabtExprVisitor { void* user_data; WabtResult (*on_binary_expr)(WabtExpr*, void* user_data); WabtResult (*begin_block_expr)(WabtExpr*, void* user_data); @@ -398,7 +397,7 @@ typedef struct WabtExprVisitor { WabtResult (*on_tee_local_expr)(WabtExpr*, void* user_data); WabtResult (*on_unary_expr)(WabtExpr*, void* user_data); WabtResult (*on_unreachable_expr)(WabtExpr*, void* user_data); -} WabtExprVisitor; +}; WABT_EXTERN_C_BEGIN WabtModuleField* wabt_append_module_field(WabtModule*); diff --git a/src/binary-reader-ast.cc b/src/binary-reader-ast.cc index 3552c998..d22c1f3f 100644 --- a/src/binary-reader-ast.cc +++ b/src/binary-reader-ast.cc @@ -32,14 +32,14 @@ return WABT_ERROR; \ } while (0) -typedef struct LabelNode { +struct LabelNode { WabtLabelType label_type; WabtExpr** first; WabtExpr* last; -} LabelNode; +}; WABT_DEFINE_VECTOR(label_node, LabelNode); -typedef struct Context { +struct Context { WabtBinaryErrorHandler* error_handler; WabtModule* module; @@ -47,7 +47,7 @@ typedef struct Context { LabelNodeVector label_stack; uint32_t max_depth; WabtExpr** current_init_expr; -} Context; +}; static void handle_error(Context* ctx, uint32_t offset, const char* message); diff --git a/src/binary-reader-interpreter.cc b/src/binary-reader-interpreter.cc index ceff1454..fbe9fbfd 100644 --- a/src/binary-reader-interpreter.cc +++ b/src/binary-reader-interpreter.cc @@ -57,13 +57,13 @@ typedef uint32_t Uint32; WABT_DEFINE_VECTOR(uint32, Uint32); WABT_DEFINE_VECTOR(uint32_vector, Uint32Vector); -typedef struct Label { +struct Label { uint32_t offset; /* branch location in the istream */ uint32_t fixup_offset; -} Label; +}; WABT_DEFINE_VECTOR(label, Label); -typedef struct Context { +struct Context { WabtBinaryReader* reader; WabtBinaryErrorHandler* error_handler; WabtInterpreterEnvironment* env; @@ -90,7 +90,7 @@ typedef struct Context { bool is_host_import; WabtInterpreterModule* host_import_module; uint32_t import_env_index; -} Context; +}; static Label* get_label(Context* ctx, uint32_t depth) { assert(depth < ctx->label_stack.size); diff --git a/src/binary-reader-linker.cc b/src/binary-reader-linker.cc index 6eae025a..568bd1eb 100644 --- a/src/binary-reader-linker.cc +++ b/src/binary-reader-linker.cc @@ -21,14 +21,14 @@ #define RELOC_SIZE 5 -typedef struct Context { +struct Context { WabtLinkerInputBinary* binary; WabtSection* reloc_section; WabtStringSlice import_name; WabtSection* current_section; -} Context; +}; static WabtResult on_reloc_count(uint32_t count, WabtBinarySection section_code, diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index 50eb9df5..70bf4ae5 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -28,7 +28,7 @@ typedef uint32_t Uint32; WABT_DEFINE_VECTOR(uint32, Uint32); -typedef struct Context { +struct Context { WabtObjdumpOptions* options; WabtStream* out_stream; const uint8_t* data; @@ -48,7 +48,7 @@ typedef struct Context { WabtStringSlice import_field_name; uint32_t next_reloc; -} Context; +}; static bool should_print_details(Context* ctx) { if (ctx->options->mode != WABT_DUMP_DETAILS) diff --git a/src/binary-reader-objdump.h b/src/binary-reader-objdump.h index 7d313676..12e02e97 100644 --- a/src/binary-reader-objdump.h +++ b/src/binary-reader-objdump.h @@ -24,23 +24,23 @@ struct WabtModule; struct WabtReadBinaryOptions; -typedef struct WabtReloc { +struct WabtReloc { WabtRelocType type; size_t offset; -} WabtReloc; +}; WABT_DEFINE_VECTOR(reloc, WabtReloc); WABT_DEFINE_VECTOR(string_slice, WabtStringSlice); -typedef enum WabtObjdumpMode { +enum WabtObjdumpMode { WABT_DUMP_PREPASS, WABT_DUMP_HEADERS, WABT_DUMP_DETAILS, WABT_DUMP_DISASSEMBLE, WABT_DUMP_RAW_DATA, -} WabtObjdumpMode; +}; -typedef struct WabtObjdumpOptions { +struct WabtObjdumpOptions { bool headers; bool details; bool raw; @@ -53,7 +53,7 @@ typedef struct WabtObjdumpOptions { bool print_header; WabtStringSliceVector function_names; WabtRelocVector code_relocations; -} WabtObjdumpOptions; +}; WABT_EXTERN_C_BEGIN diff --git a/src/binary-reader-opcnt.cc b/src/binary-reader-opcnt.cc index b79e656a..18b37366 100644 --- a/src/binary-reader-opcnt.cc +++ b/src/binary-reader-opcnt.cc @@ -25,9 +25,9 @@ #include "binary-reader.h" #include "common.h" -typedef struct Context { +struct Context { WabtOpcntData* opcnt_data; -} Context; +}; static WabtResult add_int_counter_value(WabtIntCounterVector* vec, intmax_t value) { diff --git a/src/binary-reader-opcnt.h b/src/binary-reader-opcnt.h index 21c0d1d2..47fa4878 100644 --- a/src/binary-reader-opcnt.h +++ b/src/binary-reader-opcnt.h @@ -25,22 +25,22 @@ struct WabtReadBinaryOptions; WABT_EXTERN_C_BEGIN -typedef struct WabtIntCounter { +struct WabtIntCounter { intmax_t value; size_t count; -} WabtIntCounter; +}; WABT_DEFINE_VECTOR(int_counter, WabtIntCounter) -typedef struct WabtIntPairCounter { +struct WabtIntPairCounter { intmax_t first; intmax_t second; size_t count; -} WabtIntPairCounter; +}; WABT_DEFINE_VECTOR(int_pair_counter, WabtIntPairCounter); -typedef struct WabtOpcntData { +struct WabtOpcntData { WabtIntCounterVector opcode_vec; WabtIntCounterVector i32_const_vec; WabtIntCounterVector get_local_vec; @@ -48,7 +48,7 @@ typedef struct WabtOpcntData { WabtIntCounterVector tee_local_vec; WabtIntPairCounterVector i32_load_vec; WabtIntPairCounterVector i32_store_vec; -} WabtOpcntData; +}; void wabt_init_opcnt_data(WabtOpcntData* data); void wabt_destroy_opcnt_data(WabtOpcntData* data); diff --git a/src/binary-reader.cc b/src/binary-reader.cc index 8485d0d5..45f1a4ee 100644 --- a/src/binary-reader.cc +++ b/src/binary-reader.cc @@ -104,7 +104,7 @@ WABT_DEFINE_VECTOR(uint32, Uint32); if (!(cond)) \ RAISE_ERROR(__VA_ARGS__); -typedef struct Context { +struct Context { const uint8_t* data; size_t data_size; size_t offset; @@ -128,13 +128,13 @@ typedef struct Context { uint32_t num_globals; uint32_t num_exports; uint32_t num_function_bodies; -} Context; +}; -typedef struct LoggingContext { +struct LoggingContext { WabtStream* stream; WabtBinaryReader* reader; int indent; -} LoggingContext; +}; static WabtBinaryReaderContext* get_user_context(Context* ctx) { ctx->user_ctx.user_data = ctx->reader->user_data; diff --git a/src/binary-reader.h b/src/binary-reader.h index dab830d5..6007ac81 100644 --- a/src/binary-reader.h +++ b/src/binary-reader.h @@ -26,19 +26,19 @@ #define WABT_READ_BINARY_OPTIONS_DEFAULT \ { nullptr, false } -typedef struct WabtReadBinaryOptions { +struct WabtReadBinaryOptions { struct WabtStream* log_stream; bool read_debug_names; -} WabtReadBinaryOptions; +}; -typedef struct WabtBinaryReaderContext { +struct WabtBinaryReaderContext { const uint8_t* data; size_t size; size_t offset; void* user_data; -} WabtBinaryReaderContext; +}; -typedef struct WabtBinaryReader { +struct WabtBinaryReader { void* user_data; void (*on_error)(WabtBinaryReaderContext* ctx, const char* message); @@ -319,7 +319,7 @@ typedef struct WabtBinaryReader { WabtResult (*on_init_expr_i64_const_expr)(uint32_t index, uint64_t value, void* user_data); -} WabtBinaryReader; +}; WABT_EXTERN_C_BEGIN WabtResult wabt_read_binary(const void* data, diff --git a/src/binary-writer-spec.cc b/src/binary-writer-spec.cc index 19e61c62..c6b91e10 100644 --- a/src/binary-writer-spec.cc +++ b/src/binary-writer-spec.cc @@ -26,7 +26,7 @@ #include "stream.h" #include "writer.h" -typedef struct Context { +struct Context { WabtMemoryWriter json_writer; WabtStream json_stream; WabtStringSlice source_filename; @@ -35,7 +35,7 @@ typedef struct Context { const WabtWriteBinarySpecOptions* spec_options; WabtResult result; size_t num_modules; -} Context; +}; static void convert_backslash_to_slash(char* s, size_t length) { size_t i = 0; diff --git a/src/binary-writer-spec.h b/src/binary-writer-spec.h index bf470ca0..dd38e381 100644 --- a/src/binary-writer-spec.h +++ b/src/binary-writer-spec.h @@ -26,10 +26,10 @@ struct WabtWriter; #define WABT_WRITE_BINARY_SPEC_OPTIONS_DEFAULT \ { nullptr, WABT_WRITE_BINARY_OPTIONS_DEFAULT } -typedef struct WabtWriteBinarySpecOptions { +struct WabtWriteBinarySpecOptions { const char* json_filename; WabtWriteBinaryOptions write_binary_options; -} WabtWriteBinarySpecOptions; +}; WABT_EXTERN_C_BEGIN WabtResult wabt_write_binary_spec_script(struct WabtScript*, diff --git a/src/binary-writer.cc b/src/binary-writer.cc index e2ffa641..a0dbb5cc 100644 --- a/src/binary-writer.cc +++ b/src/binary-writer.cc @@ -40,20 +40,20 @@ static const size_t LEB_SECTION_SIZE_GUESS = 1; #define ALLOC_FAILURE \ fprintf(stderr, "%s:%d: allocation failed\n", __FILE__, __LINE__) -typedef struct Reloc { +struct Reloc { WabtRelocType type; size_t offset; -} Reloc; +}; WABT_DEFINE_VECTOR(reloc, Reloc); -typedef struct RelocSection { +struct RelocSection { const char* name; WabtBinarySection section_code; RelocVector relocations; -} RelocSection; +}; WABT_DEFINE_VECTOR(reloc_section, RelocSection); -typedef struct Context { +struct Context { WabtStream stream; WabtStream* log_stream; const WabtWriteBinaryOptions* options; @@ -65,7 +65,7 @@ typedef struct Context { size_t last_section_leb_size_guess; WabtBinarySection last_section_type; size_t last_section_payload_offset; -} Context; +}; void wabt_destroy_reloc_section(RelocSection* reloc_section) { wabt_destroy_reloc_vector(&reloc_section->relocations); diff --git a/src/binary-writer.h b/src/binary-writer.h index a5f3b94c..f34bb5c6 100644 --- a/src/binary-writer.h +++ b/src/binary-writer.h @@ -28,12 +28,12 @@ struct WabtStream; #define WABT_WRITE_BINARY_OPTIONS_DEFAULT \ { nullptr, true, false, false } -typedef struct WabtWriteBinaryOptions { +struct WabtWriteBinaryOptions { struct WabtStream* log_stream; bool canonicalize_lebs; bool relocatable; bool write_debug_names; -} WabtWriteBinaryOptions; +}; WABT_EXTERN_C_BEGIN WabtResult wabt_write_binary_module(struct WabtWriter*, diff --git a/src/binary.h b/src/binary.h index 4dc91de7..04059c54 100644 --- a/src/binary.h +++ b/src/binary.h @@ -41,12 +41,12 @@ V(DATA, data, 11) /* clang-format off */ -typedef enum WabtBinarySection { +enum WabtBinarySection { #define V(NAME, name, code) WABT_BINARY_SECTION_##NAME = code, WABT_FOREACH_BINARY_SECTION(V) #undef V WABT_NUM_BINARY_SECTIONS -} WabtBinarySection; +}; /* clang-format on */ WABT_EXTERN_C_BEGIN diff --git a/src/binding-hash.h b/src/binding-hash.h index e49cab12..df50c310 100644 --- a/src/binding-hash.h +++ b/src/binding-hash.h @@ -20,23 +20,23 @@ #include "common.h" #include "vector.h" -typedef struct WabtBinding { +struct WabtBinding { WabtLocation loc; WabtStringSlice name; int index; -} WabtBinding; +}; -typedef struct WabtBindingHashEntry { +struct WabtBindingHashEntry { WabtBinding binding; struct WabtBindingHashEntry* next; struct WabtBindingHashEntry* prev; /* only valid when this entry is unused */ -} WabtBindingHashEntry; +}; WABT_DEFINE_VECTOR(binding_hash_entry, WabtBindingHashEntry); -typedef struct WabtBindingHash { +struct WabtBindingHash { WabtBindingHashEntryVector entries; WabtBindingHashEntry* free_head; -} WabtBindingHash; +}; WABT_EXTERN_C_BEGIN WabtBinding* wabt_insert_binding(WabtBindingHash*, const WabtStringSlice*); diff --git a/src/common.h b/src/common.h index 0b303e20..e3d7c000 100644 --- a/src/common.h +++ b/src/common.h @@ -68,34 +68,34 @@ } \ va_end(args_copy) -typedef enum WabtResult { +enum WabtResult { WABT_OK, WABT_ERROR, -} WabtResult; +}; #define WABT_SUCCEEDED(x) ((x) == WABT_OK) #define WABT_FAILED(x) ((x) == WABT_ERROR) -typedef enum WabtLabelType { +enum WabtLabelType { WABT_LABEL_TYPE_FUNC, WABT_LABEL_TYPE_BLOCK, WABT_LABEL_TYPE_LOOP, WABT_LABEL_TYPE_IF, WABT_LABEL_TYPE_ELSE, WABT_NUM_LABEL_TYPES, -} WabtLabelType; +}; -typedef struct WabtStringSlice { +struct WabtStringSlice { const char* start; size_t length; -} WabtStringSlice; +}; -typedef struct WabtLocation { +struct WabtLocation { const char* filename; int line; int first_column; int last_column; -} WabtLocation; +}; typedef void (*WabtSourceErrorCallback)(const WabtLocation*, const char* error, @@ -104,12 +104,12 @@ typedef void (*WabtSourceErrorCallback)(const WabtLocation*, size_t source_line_column_offset, void* user_data); -typedef struct WabtSourceErrorHandler { +struct WabtSourceErrorHandler { WabtSourceErrorCallback on_error; /* on_error will be called with with source_line trimmed to this length */ size_t source_line_max_length; void* user_data; -} WabtSourceErrorHandler; +}; #define WABT_SOURCE_LINE_MAX_LENGTH_DEFAULT 80 #define WABT_SOURCE_ERROR_HANDLER_DEFAULT \ @@ -122,30 +122,30 @@ typedef void (*WabtBinaryErrorCallback)(uint32_t offset, const char* error, void* user_data); -typedef struct WabtBinaryErrorHandler { +struct WabtBinaryErrorHandler { WabtBinaryErrorCallback on_error; void* user_data; -} WabtBinaryErrorHandler; +}; #define WABT_BINARY_ERROR_HANDLER_DEFAULT \ { wabt_default_binary_error_callback, nullptr } /* This data structure is not required; it is just used by the default error * handler callbacks. */ -typedef enum WabtPrintErrorHeader { +enum WabtPrintErrorHeader { WABT_PRINT_ERROR_HEADER_NEVER, WABT_PRINT_ERROR_HEADER_ONCE, WABT_PRINT_ERROR_HEADER_ALWAYS, -} WabtPrintErrorHeader; +}; -typedef struct WabtDefaultErrorHandlerInfo { +struct WabtDefaultErrorHandlerInfo { const char* header; FILE* out_file; WabtPrintErrorHeader print_header; -} WabtDefaultErrorHandlerInfo; +}; /* matches binary format, do not change */ -typedef enum WabtType { +enum WabtType { WABT_TYPE_I32 = -0x01, WABT_TYPE_I64 = -0x02, WABT_TYPE_F32 = -0x03, @@ -155,31 +155,31 @@ typedef enum WabtType { WABT_TYPE_VOID = -0x40, WABT_TYPE____ = WABT_TYPE_VOID, /* convenient for the opcode table below */ WABT_TYPE_ANY = 0, /* Not actually specified, but useful for type-checking */ -} WabtType; +}; -typedef enum WabtRelocType { +enum WabtRelocType { WABT_RELOC_FUNC_INDEX_LEB = 0, /* e.g. immediate of call instruction */ WABT_RELOC_TABLE_INDEX_SLEB = 1, /* e.g. loading address of function */ WABT_RELOC_TABLE_INDEX_I32 = 2, /* e.g. function address in DATA */ WABT_RELOC_GLOBAL_INDEX_LEB = 3, /* e.g immediate of get_global inst */ WABT_RELOC_DATA = 4, WABT_NUM_RELOC_TYPES, -} WabtRelocType; +}; /* matches binary format, do not change */ -typedef enum WabtExternalKind { +enum WabtExternalKind { WABT_EXTERNAL_KIND_FUNC = 0, WABT_EXTERNAL_KIND_TABLE = 1, WABT_EXTERNAL_KIND_MEMORY = 2, WABT_EXTERNAL_KIND_GLOBAL = 3, WABT_NUM_EXTERNAL_KINDS, -} WabtExternalKind; +}; -typedef struct WabtLimits { +struct WabtLimits { uint64_t initial; uint64_t max; bool has_max; -} WabtLimits; +}; enum { WABT_USE_NATURAL_ALIGNMENT = 0xFFFFFFFF }; @@ -368,34 +368,34 @@ enum { WABT_USE_NATURAL_ALIGNMENT = 0xFFFFFFFF }; V(F32, I32, ___, 0, 0xbe, F32_REINTERPRET_I32, "f32.reinterpret/i32") \ V(F64, I64, ___, 0, 0xbf, F64_REINTERPRET_I64, "f64.reinterpret/i64") -typedef enum WabtOpcode { +enum WabtOpcode { #define V(rtype, type1, type2, mem_size, code, NAME, text) \ WABT_OPCODE_##NAME = code, WABT_FOREACH_OPCODE(V) #undef V WABT_NUM_OPCODES -} WabtOpcode; +}; -typedef struct WabtOpcodeInfo { +struct WabtOpcodeInfo { const char* name; WabtType result_type; WabtType param1_type; WabtType param2_type; int memory_size; -} WabtOpcodeInfo; +}; -typedef enum WabtLiteralType { +enum WabtLiteralType { WABT_LITERAL_TYPE_INT, WABT_LITERAL_TYPE_FLOAT, WABT_LITERAL_TYPE_HEXFLOAT, WABT_LITERAL_TYPE_INFINITY, WABT_LITERAL_TYPE_NAN, -} WabtLiteralType; +}; -typedef struct WabtLiteral { +struct WabtLiteral { WabtLiteralType type; WabtStringSlice text; -} WabtLiteral; +}; WABT_EXTERN_C_BEGIN static WABT_INLINE void* wabt_alloc(size_t size) { diff --git a/src/generate-names.cc b/src/generate-names.cc index 5778d1cd..2604adb1 100644 --- a/src/generate-names.cc +++ b/src/generate-names.cc @@ -27,12 +27,12 @@ return WABT_ERROR; \ } while (0) -typedef struct Context { +struct Context { WabtModule* module; WabtExprVisitor visitor; WabtStringSliceVector index_to_name; uint32_t label_count; -} Context; +}; static bool has_name(WabtStringSlice* str) { return str->length > 0; diff --git a/src/interpreter.h b/src/interpreter.h index c3f69c1e..bad6f151 100644 --- a/src/interpreter.h +++ b/src/interpreter.h @@ -64,11 +64,11 @@ struct WabtStream; /* the expected export kind doesn't match. */ \ V(EXPORT_KIND_MISMATCH, "export kind mismatch") -typedef enum WabtInterpreterResult { +enum WabtInterpreterResult { #define V(name, str) WABT_INTERPRETER_##name, FOREACH_INTERPRETER_RESULT(V) #undef V -} WabtInterpreterResult; +}; #define WABT_INVALID_INDEX ((uint32_t)~0) #define WABT_INVALID_OFFSET ((uint32_t)~0) @@ -92,47 +92,47 @@ typedef uint32_t WabtUint32; WABT_DEFINE_ARRAY(uint32, WabtUint32); /* TODO(binji): identical to WabtFuncSignature. Share? */ -typedef struct WabtInterpreterFuncSignature { +struct WabtInterpreterFuncSignature { WabtTypeVector param_types; WabtTypeVector result_types; -} WabtInterpreterFuncSignature; +}; WABT_DEFINE_VECTOR(interpreter_func_signature, WabtInterpreterFuncSignature); -typedef struct WabtInterpreterTable { +struct WabtInterpreterTable { WabtLimits limits; WabtUint32Array func_indexes; -} WabtInterpreterTable; +}; WABT_DEFINE_VECTOR(interpreter_table, WabtInterpreterTable); -typedef struct WabtInterpreterMemory { +struct WabtInterpreterMemory { void* data; WabtLimits page_limits; uint32_t byte_size; /* Cached from page_limits. */ -} WabtInterpreterMemory; +}; WABT_DEFINE_VECTOR(interpreter_memory, WabtInterpreterMemory); -typedef union WabtInterpreterValue { +union WabtInterpreterValue { uint32_t i32; uint64_t i64; uint32_t f32_bits; uint64_t f64_bits; -} WabtInterpreterValue; +}; WABT_DEFINE_ARRAY(interpreter_value, WabtInterpreterValue); -typedef struct WabtInterpreterTypedValue { +struct WabtInterpreterTypedValue { WabtType type; WabtInterpreterValue value; -} WabtInterpreterTypedValue; +}; WABT_DEFINE_VECTOR(interpreter_typed_value, WabtInterpreterTypedValue); -typedef struct WabtInterpreterGlobal { +struct WabtInterpreterGlobal { WabtInterpreterTypedValue typed_value; bool mutable_; uint32_t import_index; /* or INVALID_INDEX if not imported */ -} WabtInterpreterGlobal; +}; WABT_DEFINE_VECTOR(interpreter_global, WabtInterpreterGlobal); -typedef struct WabtInterpreterImport { +struct WabtInterpreterImport { WabtStringSlice module_name; WabtStringSlice field_name; WabtExternalKind kind; @@ -148,7 +148,7 @@ typedef struct WabtInterpreterImport { bool mutable_; } global; }; -} WabtInterpreterImport; +}; WABT_DEFINE_ARRAY(interpreter_import, WabtInterpreterImport); struct WabtInterpreterFunc; @@ -162,7 +162,7 @@ typedef WabtResult (*WabtInterpreterHostFuncCallback)( WabtInterpreterTypedValue* out_results, void* user_data); -typedef struct WabtInterpreterFunc { +struct WabtInterpreterFunc { uint32_t sig_index; bool is_host; union { @@ -179,22 +179,22 @@ typedef struct WabtInterpreterFunc { void* user_data; } host; }; -} WabtInterpreterFunc; +}; WABT_DEFINE_VECTOR(interpreter_func, WabtInterpreterFunc); -typedef struct WabtInterpreterExport { +struct WabtInterpreterExport { WabtStringSlice name; /* Owned by the export_bindings hash */ WabtExternalKind kind; uint32_t index; -} WabtInterpreterExport; +}; WABT_DEFINE_VECTOR(interpreter_export, WabtInterpreterExport); -typedef struct WabtPrintErrorCallback { +struct WabtPrintErrorCallback { void* user_data; void (*print_error)(const char* msg, void* user_data); -} WabtPrintErrorCallback; +}; -typedef struct WabtInterpreterHostImportDelegate { +struct WabtInterpreterHostImportDelegate { void *user_data; WabtResult (*import_func)(WabtInterpreterImport*, WabtInterpreterFunc*, @@ -213,9 +213,9 @@ typedef struct WabtInterpreterHostImportDelegate { WabtInterpreterGlobal*, WabtPrintErrorCallback, void* user_data); -} WabtInterpreterHostImportDelegate; +}; -typedef struct WabtInterpreterModule { +struct WabtInterpreterModule { WabtStringSlice name; WabtInterpreterExportVector exports; WabtBindingHash export_bindings; @@ -233,11 +233,11 @@ typedef struct WabtInterpreterModule { WabtInterpreterHostImportDelegate import_delegate; } host; }; -} WabtInterpreterModule; +}; WABT_DEFINE_VECTOR(interpreter_module, WabtInterpreterModule); /* Used to track and reset the state of the environment. */ -typedef struct WabtInterpreterEnvironmentMark { +struct WabtInterpreterEnvironmentMark { size_t modules_size; size_t sigs_size; size_t funcs_size; @@ -245,9 +245,9 @@ typedef struct WabtInterpreterEnvironmentMark { size_t tables_size; size_t globals_size; size_t istream_size; -} WabtInterpreterEnvironmentMark; +}; -typedef struct WabtInterpreterEnvironment { +struct WabtInterpreterEnvironment { WabtInterpreterModuleVector modules; WabtInterpreterFuncSignatureVector sigs; WabtInterpreterFuncVector funcs; @@ -257,9 +257,9 @@ typedef struct WabtInterpreterEnvironment { WabtOutputBuffer istream; WabtBindingHash module_bindings; WabtBindingHash registered_module_bindings; -} WabtInterpreterEnvironment; +}; -typedef struct WabtInterpreterThread { +struct WabtInterpreterThread { WabtInterpreterEnvironment* env; WabtInterpreterValueArray value_stack; WabtUint32Array call_stack; @@ -271,16 +271,16 @@ typedef struct WabtInterpreterThread { /* a temporary buffer that is for passing args to host functions */ WabtInterpreterTypedValueVector host_args; -} WabtInterpreterThread; +}; #define WABT_INTERPRETER_THREAD_OPTIONS_DEFAULT \ { 512 * 1024 / sizeof(WabtInterpreterValue), 64 * 1024, WABT_INVALID_OFFSET } -typedef struct WabtInterpreterThreadOptions { +struct WabtInterpreterThreadOptions { uint32_t value_stack_size; uint32_t call_stack_size; uint32_t pc; -} WabtInterpreterThreadOptions; +}; WABT_EXTERN_C_BEGIN bool wabt_is_nan_f32(uint32_t f32_bits); diff --git a/src/literal.h b/src/literal.h index 9c8ccf8a..5f237c0c 100644 --- a/src/literal.h +++ b/src/literal.h @@ -28,10 +28,10 @@ * result, the only validation that is done is for overflow, not for otherwise * bogus input. */ -typedef enum WabtParseIntType { +enum WabtParseIntType { WABT_PARSE_UNSIGNED_ONLY = 0, WABT_PARSE_SIGNED_AND_UNSIGNED = 1, -} WabtParseIntType; +}; /* Size of char buffer required to hold hex representation of a float/double */ #define WABT_MAX_FLOAT_HEX 20 diff --git a/src/option-parser.h b/src/option-parser.h index e130f55f..910464ac 100644 --- a/src/option-parser.h +++ b/src/option-parser.h @@ -19,10 +19,10 @@ #include "common.h" -typedef enum WabtHasArgument { +enum WabtHasArgument { WABT_OPTION_NO_ARGUMENT, WABT_OPTION_HAS_ARGUMENT, -} WabtHasArgument; +}; struct WabtOption; struct WabtOptionParser; @@ -34,16 +34,16 @@ typedef void (*WabtArgumentCallback)(struct WabtOptionParser*, typedef void (*WabtOptionErrorCallback)(struct WabtOptionParser*, const char* message); -typedef struct WabtOption { +struct WabtOption { int id; char short_name; const char* long_name; const char* metavar; WabtHasArgument has_argument; const char* help; -} WabtOption; +}; -typedef struct WabtOptionParser { +struct WabtOptionParser { const char* description; WabtOption* options; int num_options; @@ -54,7 +54,7 @@ typedef struct WabtOptionParser { /* cached after call to wabt_parse_options */ char* argv0; -} WabtOptionParser; +}; WABT_EXTERN_C_BEGIN void wabt_parse_options(WabtOptionParser* parser, diff --git a/src/prebuilt/ast-lexer-gen.cc b/src/prebuilt/ast-lexer-gen.cc index e90a39ae..6e8d9b5c 100644 --- a/src/prebuilt/ast-lexer-gen.cc +++ b/src/prebuilt/ast-lexer-gen.cc @@ -116,7 +116,7 @@ static WabtResult fill(WabtLocation* loc, /* TODO(binji): could just alloc instead, because we know we'll need to * memmove below */ char* new_buffer = (char*)wabt_realloc(lexer->buffer, new_buffer_size); - if (new_buffer == nullptr) { + if (!new_buffer) { wabt_ast_parser_error(loc, lexer, parser, "unable to reallocate lexer buffer."); return WABT_ERROR; @@ -6705,10 +6705,10 @@ void wabt_destroy_ast_lexer(WabtAstLexer* lexer) { wabt_free(lexer); } -typedef enum WabtLineOffsetPosition { +enum WabtLineOffsetPosition { WABT_LINE_OFFSET_POSITION_START, WABT_LINE_OFFSET_POSITION_END, -} WabtLineOffsetPosition; +}; static WabtResult scan_forward_for_line_offset_in_buffer( const char* buffer_start, diff --git a/src/prebuilt/ast-parser-gen.cc b/src/prebuilt/ast-parser-gen.cc index 9843231c..c99211b3 100644 --- a/src/prebuilt/ast-parser-gen.cc +++ b/src/prebuilt/ast-parser-gen.cc @@ -236,11 +236,11 @@ static bool is_empty_signature(WabtFuncSignature* sig); static void append_implicit_func_declaration(WabtLocation*, WabtModule*, WabtFuncDeclaration*); -typedef struct BinaryErrorCallbackData { +struct BinaryErrorCallbackData { WabtLocation* loc; WabtAstLexer* lexer; WabtAstParser* parser; -} BinaryErrorCallbackData; +}; static void on_read_binary_error(uint32_t offset, const char* error, void* user_data); diff --git a/src/resolve-names.cc b/src/resolve-names.cc index e2f28aca..f620a4ec 100644 --- a/src/resolve-names.cc +++ b/src/resolve-names.cc @@ -25,7 +25,7 @@ typedef WabtLabel* LabelPtr; WABT_DEFINE_VECTOR(label_ptr, LabelPtr); -typedef struct Context { +struct Context { WabtSourceErrorHandler* error_handler; WabtAstLexer* lexer; WabtScript* script; @@ -34,7 +34,7 @@ typedef struct Context { WabtExprVisitor visitor; LabelPtrVector labels; WabtResult result; -} Context; +}; static void WABT_PRINTF_FORMAT(3, 4) print_error(Context* ctx, const WabtLocation* loc, const char* fmt, ...) { @@ -54,10 +54,10 @@ static void pop_label(Context* ctx) { ctx->labels.size--; } -typedef struct FindDuplicateBindingContext { +struct FindDuplicateBindingContext { Context* ctx; const char* desc; -} FindDuplicateBindingContext; +}; static void on_duplicate_binding(WabtBindingHashEntry* a, WabtBindingHashEntry* b, diff --git a/src/stream.h b/src/stream.h index f34eb2da..c7daba11 100644 --- a/src/stream.h +++ b/src/stream.h @@ -22,25 +22,25 @@ #include "common.h" #include "writer.h" -typedef struct WabtStream { +struct WabtStream { WabtWriter* writer; size_t offset; WabtResult result; /* if non-null, log all writes to this stream */ struct WabtStream* log_stream; -} WabtStream; +}; -typedef struct WabtFileStream { +struct WabtFileStream { WabtStream base; WabtFileWriter writer; -} WabtFileStream; +}; /* whether to display the ASCII characters in the debug output for * wabt_write_memory */ -typedef enum WabtPrintChars { +enum WabtPrintChars { WABT_DONT_PRINT_CHARS, WABT_PRINT_CHARS, -} WabtPrintChars; +}; WABT_EXTERN_C_BEGIN diff --git a/src/tools/wasm-interp.cc b/src/tools/wasm-interp.cc index 5cbf7572..05642d47 100644 --- a/src/tools/wasm-interp.cc +++ b/src/tools/wasm-interp.cc @@ -53,10 +53,10 @@ static WabtStream s_log_stream; #define NOPE WABT_OPTION_NO_ARGUMENT #define YEP WABT_OPTION_HAS_ARGUMENT -typedef enum RunVerbosity { +enum RunVerbosity { RUN_QUIET = 0, RUN_VERBOSE = 1, -} RunVerbosity; +}; enum { FLAG_VERBOSE, @@ -636,7 +636,7 @@ WABT_DEFINE_VECTOR(interpreter_thread, WabtInterpreterThread); /* An extremely simple JSON parser that only knows how to parse the expected * format from wast2wabt. */ -typedef struct Context { +struct Context { WabtInterpreterEnvironment env; WabtInterpreterThread thread; WabtInterpreterModule* last_module; @@ -654,19 +654,19 @@ typedef struct Context { /* Test info */ int passed; int total; -} Context; +}; -typedef enum ActionType { +enum ActionType { ACTION_TYPE_INVOKE, ACTION_TYPE_GET, -} ActionType; +}; -typedef struct Action { +struct Action { ActionType type; WabtStringSlice module_name; WabtStringSlice field_name; WabtInterpreterTypedValueVector args; -} Action; +}; #define CHECK_RESULT(x) \ do { \ diff --git a/src/tools/wasm-link.cc b/src/tools/wasm-link.cc index 75a6b224..d4085e67 100644 --- a/src/tools/wasm-link.cc +++ b/src/tools/wasm-link.cc @@ -57,11 +57,11 @@ static StringVector s_infiles; static WabtFileWriter s_log_stream_writer; static WabtStream s_log_stream; -typedef struct Context { +struct Context { WabtStream stream; WabtLinkerInputBinaryVector inputs; ssize_t current_section_payload_offset; -} Context; +}; static void on_option(struct WabtOptionParser* parser, struct WabtOption* option, @@ -608,10 +608,10 @@ static bool write_combined_section(Context* ctx, return true; } -typedef struct ExportInfo { +struct ExportInfo { WabtExport* export_; WabtLinkerInputBinary* binary; -} ExportInfo; +}; WABT_DEFINE_VECTOR(export_info, ExportInfo); static void resolve_symbols(Context* ctx) { diff --git a/src/tools/wast-desugar.cc b/src/tools/wast-desugar.cc index 494938f0..84813c0e 100644 --- a/src/tools/wast-desugar.cc +++ b/src/tools/wast-desugar.cc @@ -115,14 +115,14 @@ static void parse_options(int argc, char** argv) { } } -typedef struct Context { +struct Context { WabtMemoryWriter json_writer; WabtMemoryWriter module_writer; WabtStream json_stream; WabtStringSlice output_filename_noext; char* module_filename; WabtResult result; -} Context; +}; int main(int argc, char** argv) { wabt_init_stdio(); diff --git a/src/type-checker.h b/src/type-checker.h index 31f80edb..b831574d 100644 --- a/src/type-checker.h +++ b/src/type-checker.h @@ -25,27 +25,27 @@ struct WabtAllocator; typedef void (*WabtTypeCheckerErrorCallback)(const char* msg, void* user_data); -typedef struct WabtTypeCheckerErrorHandler { +struct WabtTypeCheckerErrorHandler { WabtTypeCheckerErrorCallback on_error; void* user_data; -} WabtTypeCheckerErrorHandler; +}; -typedef struct WabtTypeCheckerLabel { +struct WabtTypeCheckerLabel { WabtLabelType label_type; WabtTypeVector sig; size_t type_stack_limit; bool unreachable; -} WabtTypeCheckerLabel; +}; WABT_DEFINE_VECTOR(type_checker_label, WabtTypeCheckerLabel); -typedef struct WabtTypeChecker { +struct WabtTypeChecker { WabtTypeCheckerErrorHandler* error_handler; WabtTypeVector type_stack; WabtTypeCheckerLabelVector label_stack; /* TODO(binji): will need to be complete signature when signatures with * multiple types are allowed. */ WabtType br_table_sig; -} WabtTypeChecker; +}; WABT_EXTERN_C_BEGIN diff --git a/src/validator.cc b/src/validator.cc index d7bbdaf7..61fb484f 100644 --- a/src/validator.cc +++ b/src/validator.cc @@ -28,21 +28,21 @@ #include "binary-reader.h" #include "type-checker.h" -typedef enum ActionResultKind { +enum ActionResultKind { ACTION_RESULT_KIND_ERROR, ACTION_RESULT_KIND_TYPES, ACTION_RESULT_KIND_TYPE, -} ActionResultKind; +}; -typedef struct ActionResult { +struct ActionResult { ActionResultKind kind; union { const WabtTypeVector* types; WabtType type; }; -} ActionResult; +}; -typedef struct Context { +struct Context { WabtSourceErrorHandler* error_handler; WabtAstLexer* lexer; const WabtScript* script; @@ -55,7 +55,7 @@ typedef struct Context { WabtTypeChecker typechecker; const WabtLocation* expr_loc; /* Cached for access by on_typechecker_error */ WabtResult result; -} Context; +}; static void WABT_PRINTF_FORMAT(3, 4) print_error(Context* ctx, const WabtLocation* loc, const char* fmt, ...) { diff --git a/src/vector.h b/src/vector.h index bb578abe..7f544ea4 100644 --- a/src/vector.h +++ b/src/vector.h @@ -26,11 +26,11 @@ * WABT_DEFINE_VECTOR(widget, WabtWidget) defines struct and functions like the * following: * - * typedef struct WabtWidgetVector { + * struct WabtWidgetVector { * WabtWidget* data; * size_t size; * size_t capacity; - * } WabtWidgetVector; + * }; * * void wabt_destroy_widget_vector(WabtWidgetVector* vec); * WabtWidget* wabt_append_widget(WabtWidgetVector* vec); @@ -42,11 +42,11 @@ */ #define WABT_DEFINE_VECTOR(name, type) \ - typedef struct type##Vector { \ + struct type##Vector { \ type* data; \ size_t size; \ size_t capacity; \ - } type##Vector; \ + }; \ \ WABT_EXTERN_C_BEGIN \ static WABT_INLINE void wabt_destroy_##name##_vector(type##Vector* vec) \ diff --git a/src/wasm-link.h b/src/wasm-link.h index 11ce629d..23c842e1 100644 --- a/src/wasm-link.h +++ b/src/wasm-link.h @@ -25,49 +25,49 @@ struct WabtLinkerInputBinary; -typedef struct WabtFunctionImport { +struct WabtFunctionImport { WabtStringSlice name; uint32_t sig_index; bool active; /* Is this import present in the linked binary */ struct WabtLinkerInputBinary* foreign_binary; uint32_t foreign_index; -} WabtFunctionImport; +}; WABT_DEFINE_VECTOR(function_import, WabtFunctionImport); -typedef struct WabtGlobalImport { +struct WabtGlobalImport { WabtStringSlice name; WabtType type; bool mutable_; -} WabtGlobalImport; +}; WABT_DEFINE_VECTOR(global_import, WabtGlobalImport); -typedef struct WabtDataSegment { +struct WabtDataSegment { uint32_t memory_index; uint32_t offset; const uint8_t* data; size_t size; -} WabtDataSegment; +}; WABT_DEFINE_VECTOR(data_segment, WabtDataSegment); -typedef struct WabtReloc { +struct WabtReloc { WabtRelocType type; size_t offset; -} WabtReloc; +}; WABT_DEFINE_VECTOR(reloc, WabtReloc); -typedef struct WabtExport { +struct WabtExport { WabtExternalKind kind; WabtStringSlice name; uint32_t index; -} WabtExport; +}; WABT_DEFINE_VECTOR(export, WabtExport); -typedef struct WabtSectionDataCustom { +struct WabtSectionDataCustom { /* Reference to string data stored in the containing InputBinary */ WabtStringSlice name; -} WabtSectionDataCustom; +}; -typedef struct WabtSection { +struct WabtSection { /* The binary to which this section belongs */ struct WabtLinkerInputBinary* binary; WabtRelocVector relocations; /* The relocations for this section */ @@ -94,7 +94,7 @@ typedef struct WabtSection { /* The offset at which this section appears within the combined output * section. */ size_t output_payload_offset; -} WabtSection; +}; WABT_DEFINE_VECTOR(section, WabtSection); typedef WabtSection* WabtSectionPtr; @@ -102,7 +102,7 @@ WABT_DEFINE_VECTOR(section_ptr, WabtSectionPtr); WABT_DEFINE_VECTOR(string_slice, WabtStringSlice); -typedef struct WabtLinkerInputBinary { +struct WabtLinkerInputBinary { const char* filename; uint8_t* data; size_t size; @@ -127,7 +127,7 @@ typedef struct WabtLinkerInputBinary { uint32_t table_elem_count; WabtStringSliceVector debug_names; -} WabtLinkerInputBinary; +}; WABT_DEFINE_VECTOR(binary, WabtLinkerInputBinary); #endif /* WABT_LINK_H_ */ diff --git a/src/writer.h b/src/writer.h index 6626eb8e..b4fb8b12 100644 --- a/src/writer.h +++ b/src/writer.h @@ -21,7 +21,7 @@ #include "common.h" -typedef struct WabtWriter { +struct WabtWriter { void* user_data; WabtResult (*write_data)(size_t offset, const void* data, @@ -31,24 +31,24 @@ typedef struct WabtWriter { size_t src_offset, size_t size, void* user_data); -} WabtWriter; +}; -typedef struct WabtOutputBuffer { +struct WabtOutputBuffer { void* start; size_t size; size_t capacity; -} WabtOutputBuffer; +}; -typedef struct WabtMemoryWriter { +struct WabtMemoryWriter { WabtWriter base; WabtOutputBuffer buf; -} WabtMemoryWriter; +}; -typedef struct WabtFileWriter { +struct WabtFileWriter { WabtWriter base; FILE* file; size_t offset; -} WabtFileWriter; +}; WABT_EXTERN_C_BEGIN |