Add get_array_key

This commit is contained in:
Vasilii Rogin 2023-04-20 01:21:56 +03:00
parent 55774c2518
commit e934cf1c09
2 changed files with 11 additions and 2 deletions

View File

@ -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();
}
} }

View File

@ -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