From ef59f8b2bf9bb0b8deb3cc700cc2f3d8730f2cdf Mon Sep 17 00:00:00 2001 From: Volodymyr Shymanskyy Date: Sun, 27 Oct 2019 15:25:22 +0200 Subject: [PATCH] =?UTF-8?q?Convert=20constants=20to=20defines,=20so=20it?= =?UTF-8?q?=20actually=20compiles=20=F0=9F=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/m3_compile.c | 13 ++++++------- source/m3_core.h | 31 +++++++++++++++---------------- source/m3_exec_defs.h | 7 +++---- source/m3_info.c | 5 ++--- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/source/m3_compile.c b/source/m3_compile.c index 41df346..5653516 100644 --- a/source/m3_compile.c +++ b/source/m3_compile.c @@ -79,13 +79,12 @@ void log_opcode (IM3Compilation o, u8 i_opcode) //------------------------------------------------------------------------------------------------------------------------- // just want less letter and numbers to stare at down the way in the compiler table -const u8 i_32 = c_m3Type_i32, - i_64 = c_m3Type_i64, - f_32 = c_m3Type_f32, - f_64 = c_m3Type_f64, - none = c_m3Type_none, - any = -1 - ; +#define i_32 c_m3Type_i32 +#define i_64 c_m3Type_i64 +#define f_32 c_m3Type_f32 +#define f_64 c_m3Type_f64 +#define none c_m3Type_none +#define any (u8)-1 bool IsRegisterLocation (i16 i_location) { return (i_location >= c_m3Reg0Id); } diff --git a/source/m3_core.h b/source/m3_core.h index d23280e..7ef07b8 100644 --- a/source/m3_core.h +++ b/source/m3_core.h @@ -171,28 +171,27 @@ typedef struct M3CodePageInfo M3CodePageHeader; -static const u32 c_m3CodePageFreeLinesThreshold = 10; +#define c_m3CodePageFreeLinesThreshold 10 -static const u32 c_m3MemPageSize = 65536; -static const u32 c_m3MaxFunctionStackHeight = d_m3MaxFunctionStackHeight; -static const u32 c_m3MaxFunctionLocals = 512; +#define c_m3MemPageSize 65536 +#define c_m3MaxFunctionStackHeight d_m3MaxFunctionStackHeight +#define c_m3MaxFunctionLocals 512 -static const u32 c_m3Reg0Id = c_m3MaxFunctionStackHeight + 1; -static const u32 c_m3Fp0Id = c_m3MaxFunctionStackHeight + 2; +#define c_m3Reg0Id c_m3MaxFunctionStackHeight + 1 +#define c_m3Fp0Id c_m3MaxFunctionStackHeight + 2 -static const u32 c_m3MaxNumFunctionConstants = 60; +#define c_m3MaxNumFunctionConstants 60 -static const bool c_m3AlignWasmMemoryToPages = d_m3AlignWasmMemoryToPages; +#define c_m3AlignWasmMemoryToPages d_m3AlignWasmMemoryToPages -//static const u32 c_m3MaxSaneWasmSize = 1000000000; -static const u32 c_m3MaxSaneUtf8Length = 2000; -static const u32 c_m3MaxNumFunctionArgs = d_m3MaxNumFunctionArgs; +//#define c_m3MaxSaneWasmSize 1000000000 +#define c_m3MaxSaneUtf8Length 2000 +#define c_m3MaxNumFunctionArgs d_m3MaxNumFunctionArgs -static const u8 c_externalKind_function = 0, - c_externalKind_table = 1, - c_externalKind_memory = 2, - c_externalKind_global = 3 - ; +#define c_externalKind_function 0 +#define c_externalKind_table 1 +#define c_externalKind_memory 2 +#define c_externalKind_global 3 static const char * const c_waTypes [] = { "nil", "i32", "i64", "f32", "f64", "void", "void *" }; diff --git a/source/m3_exec_defs.h b/source/m3_exec_defs.h index 5eb650a..a28fb82 100644 --- a/source/m3_exec_defs.h +++ b/source/m3_exec_defs.h @@ -40,8 +40,9 @@ typedef i64 arch_i; //--------------------------------------------------------------------------------------------------------------- -static const i64 c_m3NumIntRegisters = 1; -static const i64 c_m3NumFpRegisters = 1; +#define c_m3NumIntRegisters 1 +#define c_m3NumFpRegisters 1 +#define c_m3NumRegisters (c_m3NumIntRegisters + c_m3NumFpRegisters) # define d_m3OpSig pc_t _pc, u64 * _sp, u8 * _mem, m3reg_t _r0, f64 _fp0 # define d_m3OpArgs _sp, _mem, _r0, _fp0 @@ -49,8 +50,6 @@ static const i64 c_m3NumFpRegisters = 1; # define d_m3OpDefaultArgs 666, NAN -static const i64 c_m3NumRegisters = c_m3NumIntRegisters + c_m3NumFpRegisters; - typedef m3ret_t (vectorcall * IM3Operation) (d_m3OpSig); diff --git a/source/m3_info.c b/source/m3_info.c index 3cf1386..017a971 100644 --- a/source/m3_info.c +++ b/source/m3_info.c @@ -92,11 +92,10 @@ size_t SPrintArg (char * o_string, size_t i_n, m3stack_t i_sp, u8 i_type) ccstr_t SPrintFunctionArgList (IM3Function i_function, m3stack_t i_sp) { - const u32 bufferSize = 1000; - static char string [bufferSize]; + static char string [256]; char * s = string; - ccstr_t e = string + bufferSize - 1; + ccstr_t e = string + sizeof(string) - 1; s += max (0, snprintf (s, e-s, "("));