Add setArray
This commit is contained in:
parent
4662314839
commit
9549bab517
|
@ -102,6 +102,8 @@ int LenArray(ArrayId array_id)
|
||||||
|
|
||||||
ProgramValue GetArray(ArrayId array_id, const SFallScriptValue& key)
|
ProgramValue GetArray(ArrayId array_id, const SFallScriptValue& key)
|
||||||
{
|
{
|
||||||
|
// TODO: If type is string then do substr
|
||||||
|
|
||||||
auto arr = get_array_by_id(array_id);
|
auto arr = get_array_by_id(array_id);
|
||||||
if (arr == nullptr) {
|
if (arr == nullptr) {
|
||||||
return SFallScriptValue(0);
|
return SFallScriptValue(0);
|
||||||
|
|
|
@ -317,6 +317,16 @@ static void opTempArray(Program* program)
|
||||||
programStackPushInteger(program, array_id);
|
programStackPushInteger(program, array_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set_array
|
||||||
|
static void opSetArray(Program* program)
|
||||||
|
{
|
||||||
|
auto value = programStackPopValue(program);
|
||||||
|
auto key = programStackPopValue(program);
|
||||||
|
auto arrayId = programStackPopInteger(program);
|
||||||
|
|
||||||
|
SetArray(arrayId, SFallScriptValue { key }, SFallScriptValue { value }, true);
|
||||||
|
}
|
||||||
|
|
||||||
// get_array
|
// get_array
|
||||||
static void opGetArray(Program* program)
|
static void opGetArray(Program* program)
|
||||||
{
|
{
|
||||||
|
@ -395,6 +405,7 @@ void sfallOpcodesInit()
|
||||||
interpreterRegisterOpcode(0x8220, opGetScreenWidth);
|
interpreterRegisterOpcode(0x8220, opGetScreenWidth);
|
||||||
interpreterRegisterOpcode(0x8221, opGetScreenHeight);
|
interpreterRegisterOpcode(0x8221, opGetScreenHeight);
|
||||||
interpreterRegisterOpcode(0x822D, opCreateArray);
|
interpreterRegisterOpcode(0x822D, opCreateArray);
|
||||||
|
interpreterRegisterOpcode(0x822E, opSetArray);
|
||||||
interpreterRegisterOpcode(0x822F, opGetArray);
|
interpreterRegisterOpcode(0x822F, opGetArray);
|
||||||
interpreterRegisterOpcode(0x8230, opFreeArray);
|
interpreterRegisterOpcode(0x8230, opFreeArray);
|
||||||
interpreterRegisterOpcode(0x8231, opLenArray);
|
interpreterRegisterOpcode(0x8231, opLenArray);
|
||||||
|
|
Loading…
Reference in New Issue