From 75eecf7da3143ce81af9c576e450cf389643c067 Mon Sep 17 00:00:00 2001 From: Vasilii Rogin Date: Mon, 24 Apr 2023 16:17:33 +0300 Subject: [PATCH] Add todo for GetArray subscript operator --- src/interpreter.cc | 5 +++++ src/interpreter.h | 1 + src/sfall_opcodes.cc | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/interpreter.cc b/src/interpreter.cc index a5158a7..3068002 100644 --- a/src/interpreter.cc +++ b/src/interpreter.cc @@ -3293,6 +3293,11 @@ float ProgramValue::asFloat() const } } +bool ProgramValue::isString() const +{ + return opcode == VALUE_TYPE_STRING || opcode == VALUE_TYPE_DYNAMIC_STRING; +} + ProgramValue::ProgramValue() { opcode = VALUE_TYPE_INT; diff --git a/src/interpreter.h b/src/interpreter.h index 221a24a..225fb5e 100644 --- a/src/interpreter.h +++ b/src/interpreter.h @@ -157,6 +157,7 @@ public: bool isEmpty() const; bool isInt() const; bool isFloat() const; + bool isString() const; float asFloat() const; bool isPointer() const; int asInt() const; diff --git a/src/sfall_opcodes.cc b/src/sfall_opcodes.cc index 5ca218e..065924a 100644 --- a/src/sfall_opcodes.cc +++ b/src/sfall_opcodes.cc @@ -22,6 +22,7 @@ #include "svga.h" #include "tile.h" #include "worldmap.h" +#include #include namespace fallout { @@ -543,7 +544,8 @@ static void opGetArray(Program* program) if (arrayId.isInt()) { auto value = GetArray(arrayId.integerValue, key); programStackPushValue(program, value); - } else { + } else if (arrayId.isString()) { + throw std::invalid_argument("String subscript is not implemented yet!"); } }