Add get_array_key
This commit is contained in:
parent
55774c2518
commit
e934cf1c09
|
@ -104,7 +104,17 @@ ProgramValue GetArrayKey(ArrayId array_id, int index)
|
||||||
if (index == -1) { // special index to indicate if array is associative
|
if (index == -1) { // special index to indicate if array is associative
|
||||||
throw(std::invalid_argument("Not implemented yet"));
|
throw(std::invalid_argument("Not implemented yet"));
|
||||||
};
|
};
|
||||||
|
// TODO: if assoc
|
||||||
return SFallArrayElement(index);
|
return SFallArrayElement(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LenArray(ArrayId array_id)
|
||||||
|
{
|
||||||
|
auto arr = get_array_by_id(array_id);
|
||||||
|
if (arr == nullptr) {
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
return arr->size();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -335,8 +335,7 @@ static void opGetArray(Program* program)
|
||||||
static void opLenArray(Program* program)
|
static void opLenArray(Program* program)
|
||||||
{
|
{
|
||||||
auto arrayId = programStackPopInteger(program);
|
auto arrayId = programStackPopInteger(program);
|
||||||
|
programStackPushInteger(program, LenArray(arrayId));
|
||||||
programStackPushInteger(program, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// party_member_list
|
// party_member_list
|
||||||
|
|
Loading…
Reference in New Issue