diff --git a/src/sfall_script_value.cc b/src/sfall_script_value.cc deleted file mode 100644 index fa2d35b..0000000 --- a/src/sfall_script_value.cc +++ /dev/null @@ -1,109 +0,0 @@ - -#include "sfall_script_value.h" -#include - -namespace fallout { -SFallScriptValue::SFallScriptValue() -{ - opcode = VALUE_TYPE_INT; - integerValue = 0; -} -SFallScriptValue::SFallScriptValue(int value) -{ - opcode = VALUE_TYPE_INT; - integerValue = value; -}; -SFallScriptValue::SFallScriptValue(Object* value) -{ - opcode = VALUE_TYPE_PTR; - pointerValue = value; -}; -SFallScriptValue::SFallScriptValue(const ProgramValue& value) -{ - opcode = value.opcode; - - switch (opcode) { - case VALUE_TYPE_DYNAMIC_STRING: - case VALUE_TYPE_STRING: - pointerValue = value.pointerValue; - break; - case VALUE_TYPE_PTR: - pointerValue = value.pointerValue; - break; - case VALUE_TYPE_INT: - integerValue = value.integerValue; - break; - case VALUE_TYPE_FLOAT: - floatValue = value.floatValue; - break; - default: - throw(std::exception()); - } -} - -bool SFallScriptValue::isInt() const -{ - return opcode == VALUE_TYPE_INT; -} -bool SFallScriptValue::isFloat() const -{ - return opcode == VALUE_TYPE_FLOAT; -} -bool SFallScriptValue::isPointer() const -{ - return opcode == VALUE_TYPE_PTR; -} - -int SFallScriptValue::asInt() const -{ - switch (opcode) { - case VALUE_TYPE_INT: - return integerValue; - case VALUE_TYPE_FLOAT: - return static_cast(floatValue); - default: - return 0; - } -} - -bool SFallScriptValue::operator<(SFallScriptValue const& other) const -{ - if (opcode != other.opcode) { - return opcode < other.opcode; - } - - switch (opcode) { - case VALUE_TYPE_DYNAMIC_STRING: - case VALUE_TYPE_STRING: - case VALUE_TYPE_PTR: - return pointerValue < other.pointerValue; - case VALUE_TYPE_INT: - return integerValue < other.integerValue; - case VALUE_TYPE_FLOAT: - return floatValue < other.floatValue; - default: - throw(std::exception()); - } -} - -bool SFallScriptValue::operator==(SFallScriptValue const& other) const -{ - if (opcode != other.opcode) { - return false; - } - - switch (opcode) { - case VALUE_TYPE_DYNAMIC_STRING: - case VALUE_TYPE_STRING: - case VALUE_TYPE_PTR: - return pointerValue == other.pointerValue; - case VALUE_TYPE_INT: - return integerValue == other.integerValue; - case VALUE_TYPE_FLOAT: - return floatValue == other.floatValue; - default: - throw(std::exception()); - } -} - -} \ No newline at end of file diff --git a/src/sfall_script_value.h b/src/sfall_script_value.h deleted file mode 100644 index 05d6dcd..0000000 --- a/src/sfall_script_value.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef SFALL_SCRIPT_VALUE -#define SFALL_SCRIPT_VALUE - -#include "interpreter.h" -#include "object.h" - -namespace fallout { - -class SFallScriptValue : public ProgramValue { -public: - SFallScriptValue(); - SFallScriptValue(int value); - SFallScriptValue(Object* value); - SFallScriptValue(const ProgramValue& value); - - bool isInt() const; - bool isFloat() const; - bool isPointer() const; - int asInt() const; - - bool operator<(SFallScriptValue const& other) const; - bool operator==(SFallScriptValue const& other) const; -}; - -} - -#endif /* SFALL_SCRIPT_VALUE */ \ No newline at end of file