Problem with signed 32bits PMEM #525

This commit is contained in:
BADIM-PC\Vadim 2018-02-16 13:38:11 +03:00
parent c1ba0d1389
commit c419c5297d
4 changed files with 6 additions and 6 deletions

View File

@ -561,11 +561,11 @@ static duk_ret_t duk_pmem(duk_context* duk)
if(index < TIC_PERSISTENT_SIZE) if(index < TIC_PERSISTENT_SIZE)
{ {
s32 val = memory->persistent.data[index]; u32 val = memory->persistent.data[index];
if(!duk_is_null_or_undefined(duk, 1)) if(!duk_is_null_or_undefined(duk, 1))
{ {
memory->persistent.data[index] = duk_to_int(duk, 1); memory->persistent.data[index] = duk_to_uint(duk, 1);
machine->data->syncPMEM = true; machine->data->syncPMEM = true;
} }

View File

@ -1064,11 +1064,11 @@ static s32 lua_pmem(lua_State *lua)
if(index < TIC_PERSISTENT_SIZE) if(index < TIC_PERSISTENT_SIZE)
{ {
s32 val = memory->persistent.data[index]; u32 val = memory->persistent.data[index];
if(top >= 2) if(top >= 2)
{ {
memory->persistent.data[index] = getLuaNumber(lua, 2); memory->persistent.data[index] = lua_tointeger(lua, 2);
machine->data->syncPMEM = true; machine->data->syncPMEM = true;
} }

View File

@ -401,7 +401,7 @@ typedef union
typedef struct typedef struct
{ {
s32 data[TIC_PERSISTENT_SIZE]; u32 data[TIC_PERSISTENT_SIZE];
} tic_persistent; } tic_persistent;
typedef union typedef union

View File

@ -900,7 +900,7 @@ static void wren_pmem(WrenVM* vm)
if(index < TIC_PERSISTENT_SIZE) if(index < TIC_PERSISTENT_SIZE)
{ {
s32 val = memory->persistent.data[index]; u32 val = memory->persistent.data[index];
if(top > 2) if(top > 2)
{ {