From 1d3e61f3460f0d7af5bcd2245c1a773a369eafda Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Thu, 20 Apr 2023 02:53:49 +0300 Subject: [PATCH] Add opFixArray --- src/sfall_arrays.cc | 5 +++++ src/sfall_arrays.h | 1 + src/sfall_opcodes.cc | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/src/sfall_arrays.cc b/src/sfall_arrays.cc index c49eac4..4d3f4d2 100644 --- a/src/sfall_arrays.cc +++ b/src/sfall_arrays.cc @@ -145,6 +145,11 @@ void FreeArray(ArrayId array_id) arrays.erase(array_id); } +void FixArray(ArrayId id) +{ + temporaryArrays.erase(id); +} + void DeleteAllTempArrays() { for (auto it = temporaryArrays.begin(); it != temporaryArrays.end(); ++it) { diff --git a/src/sfall_arrays.h b/src/sfall_arrays.h index 098afe7..565f23f 100644 --- a/src/sfall_arrays.h +++ b/src/sfall_arrays.h @@ -21,6 +21,7 @@ int LenArray(ArrayId array_id); ProgramValue GetArray(ArrayId array_id, const SFallScriptValue& key); void SetArray(ArrayId array_id, const SFallScriptValue& key, const SFallScriptValue& val, bool allowUnset); void FreeArray(ArrayId array_id); +void FixArray(ArrayId id); void DeleteAllTempArrays(); } #endif /* SFALL_ARRAYS */ \ No newline at end of file diff --git a/src/sfall_opcodes.cc b/src/sfall_opcodes.cc index 70f6a42..6f08650 100644 --- a/src/sfall_opcodes.cc +++ b/src/sfall_opcodes.cc @@ -317,6 +317,13 @@ static void opTempArray(Program* program) programStackPushInteger(program, array_id); } +// fix_array +static void opFixArray(Program* program) +{ + auto array_id = programStackPopInteger(program); + FixArray(array_id); +} + // set_array static void opSetArray(Program* program) { @@ -410,6 +417,7 @@ void sfallOpcodesInit() interpreterRegisterOpcode(0x8230, opFreeArray); interpreterRegisterOpcode(0x8231, opLenArray); interpreterRegisterOpcode(0x8233, opTempArray); + interpreterRegisterOpcode(0x8233, opFixArray); interpreterRegisterOpcode(0x8237, opParseInt); interpreterRegisterOpcode(0x824F, opGetStringLength); interpreterRegisterOpcode(0x8256, opGetArrayKey);