Small updates
This commit is contained in:
parent
da814a6b76
commit
a93c7fba9e
|
@ -100,17 +100,16 @@ int LenArray(ArrayId array_id)
|
||||||
return arr->size();
|
return arr->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProgramValue GetArray(ArrayId array_id, ProgramValue key)
|
ProgramValue GetArray(ArrayId array_id, const SFallScriptValue& key)
|
||||||
{
|
{
|
||||||
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto skey = SFallScriptValue(key);
|
|
||||||
// TODO assoc
|
// TODO assoc
|
||||||
|
|
||||||
auto element_index = skey.asInt();
|
auto element_index = key.asInt();
|
||||||
if (element_index < 0 || element_index >= arr->size()) {
|
if (element_index < 0 || element_index >= arr->size()) {
|
||||||
return SFallScriptValue(0);
|
return SFallScriptValue(0);
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@ ArrayId CreateArray(int len, uint32_t flags);
|
||||||
ArrayId CreateTempArray(int len, uint32_t flags);
|
ArrayId CreateTempArray(int len, uint32_t flags);
|
||||||
ProgramValue GetArrayKey(ArrayId array_id, int index);
|
ProgramValue GetArrayKey(ArrayId array_id, int index);
|
||||||
int LenArray(ArrayId array_id);
|
int LenArray(ArrayId array_id);
|
||||||
ProgramValue GetArray(ArrayId array_id, ProgramValue key);
|
ProgramValue GetArray(ArrayId array_id, const SFallScriptValue& key);
|
||||||
void SetArray(ArrayId array_id, const SFallScriptValue& key, const SFallScriptValue& val, bool allowUnset);
|
void SetArray(ArrayId array_id, const SFallScriptValue& key, const SFallScriptValue& val, bool allowUnset);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,7 +326,7 @@ static void opGetArray(Program* program)
|
||||||
{
|
{
|
||||||
auto key = programStackPopValue(program);
|
auto key = programStackPopValue(program);
|
||||||
auto arrayId = programStackPopInteger(program);
|
auto arrayId = programStackPopInteger(program);
|
||||||
auto value = GetArray(arrayId, key);
|
auto value = GetArray(arrayId, SFallScriptValue { key });
|
||||||
programStackPushValue(program, value);
|
programStackPushValue(program, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue