diff --git a/src/sfall_arrays.cc b/src/sfall_arrays.cc index c561151..3b805e9 100644 --- a/src/sfall_arrays.cc +++ b/src/sfall_arrays.cc @@ -104,7 +104,17 @@ ProgramValue GetArrayKey(ArrayId array_id, int index) if (index == -1) { // special index to indicate if array is associative throw(std::invalid_argument("Not implemented yet")); }; + // TODO: if assoc return SFallArrayElement(index); } +int LenArray(ArrayId array_id) +{ + auto arr = get_array_by_id(array_id); + if (arr == nullptr) { + return -1; + }; + return arr->size(); +} + } \ No newline at end of file diff --git a/src/sfall_opcodes.cc b/src/sfall_opcodes.cc index 6c92042..c9db981 100644 --- a/src/sfall_opcodes.cc +++ b/src/sfall_opcodes.cc @@ -335,8 +335,7 @@ static void opGetArray(Program* program) static void opLenArray(Program* program) { auto arrayId = programStackPopInteger(program); - - programStackPushInteger(program, 100); + programStackPushInteger(program, LenArray(arrayId)); } // party_member_list