Removing TODOs
This commit is contained in:
parent
c463583891
commit
81a8b75e62
|
@ -7,6 +7,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <string.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -24,7 +25,6 @@ static ArrayId stackArrayId = 0;
|
||||||
#define ARRAY_ACTION_REVERSE (-4)
|
#define ARRAY_ACTION_REVERSE (-4)
|
||||||
#define ARRAY_ACTION_SHUFFLE (-5)
|
#define ARRAY_ACTION_SHUFFLE (-5)
|
||||||
|
|
||||||
// TODO: Move me into separate file "sfall_arrays_utils"
|
|
||||||
template <class T, typename Compare>
|
template <class T, typename Compare>
|
||||||
static void ListSort(std::vector<T>& arr, int type, Compare cmp)
|
static void ListSort(std::vector<T>& arr, int type, Compare cmp)
|
||||||
{
|
{
|
||||||
|
@ -70,14 +70,16 @@ private:
|
||||||
union {
|
union {
|
||||||
int integerValue;
|
int integerValue;
|
||||||
float floatValue;
|
float floatValue;
|
||||||
unsigned char* stringValue;
|
char* stringValue;
|
||||||
void* pointerValue;
|
void* pointerValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ArrayElement() {
|
ArrayElement()
|
||||||
// todo
|
: type(ArrayElementType::INT)
|
||||||
};
|
, integerValue(0) {
|
||||||
|
// nothing here
|
||||||
|
};
|
||||||
|
|
||||||
ArrayElement(const ArrayElement& other) = delete;
|
ArrayElement(const ArrayElement& other) = delete;
|
||||||
ArrayElement& operator=(const ArrayElement& rhs) = delete;
|
ArrayElement& operator=(const ArrayElement& rhs) = delete;
|
||||||
|
@ -90,8 +92,6 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove all other constructors
|
|
||||||
|
|
||||||
ArrayElement(ProgramValue programValue, Program* program)
|
ArrayElement(ProgramValue programValue, Program* program)
|
||||||
{
|
{
|
||||||
// todo
|
// todo
|
||||||
|
@ -104,27 +104,39 @@ public:
|
||||||
|
|
||||||
bool operator<(ArrayElement const& other) const
|
bool operator<(ArrayElement const& other) const
|
||||||
{
|
{
|
||||||
// todo
|
if (type != other.type) {
|
||||||
return false;
|
return type < other.type;
|
||||||
|
};
|
||||||
|
switch (type) {
|
||||||
|
case ArrayElementType::INT:
|
||||||
|
return integerValue < other.integerValue;
|
||||||
|
case ArrayElementType::FLOAT:
|
||||||
|
return floatValue < other.floatValue;
|
||||||
|
case ArrayElementType::POINTER:
|
||||||
|
return pointerValue < other.pointerValue;
|
||||||
|
case ArrayElementType::STRING:
|
||||||
|
return strcmp(stringValue, other.stringValue) < 0;
|
||||||
|
default:
|
||||||
|
throw(std::exception());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool operator==(ArrayElement const& other) const
|
bool operator==(ArrayElement const& other) const
|
||||||
{
|
{
|
||||||
// todo
|
if (type != other.type) {
|
||||||
/*
|
|
||||||
if (!a.isString()) {
|
|
||||||
return a == b;
|
|
||||||
};
|
|
||||||
if (!b.isString()) {
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
auto str1 = programGetString(program, a.opcode, a.integerValue);
|
switch (type) {
|
||||||
auto str2 = programGetString(program, a.opcode, a.integerValue);
|
case ArrayElementType::INT:
|
||||||
if (!str1 || !str2) {
|
return integerValue == other.integerValue;
|
||||||
return false;
|
case ArrayElementType::FLOAT:
|
||||||
};
|
return floatValue == other.floatValue;
|
||||||
return strcmp(str1, str2) == 0;
|
case ArrayElementType::POINTER:
|
||||||
*/
|
return pointerValue == other.pointerValue;
|
||||||
return false;
|
case ArrayElementType::STRING:
|
||||||
|
return strcmp(stringValue, other.stringValue) == 0;
|
||||||
|
default:
|
||||||
|
throw(std::exception());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -143,48 +155,6 @@ public:
|
||||||
virtual ~SFallArray() = default;
|
virtual ~SFallArray() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
bool ProgramValue::operator<(ProgramValue const& other) const
|
|
||||||
{
|
|
||||||
if (opcode != other.opcode) {
|
|
||||||
return opcode < other.opcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (opcode) {
|
|
||||||
case VALUE_TYPE_INT:
|
|
||||||
case VALUE_TYPE_STRING:
|
|
||||||
case VALUE_TYPE_DYNAMIC_STRING:
|
|
||||||
return integerValue < other.integerValue;
|
|
||||||
case VALUE_TYPE_PTR:
|
|
||||||
return pointerValue < other.pointerValue;
|
|
||||||
case VALUE_TYPE_FLOAT:
|
|
||||||
return floatValue < other.floatValue;
|
|
||||||
default:
|
|
||||||
throw(std::exception());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProgramValue::operator==(ProgramValue const& other) const
|
|
||||||
{
|
|
||||||
if (opcode != other.opcode) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (opcode) {
|
|
||||||
case VALUE_TYPE_INT:
|
|
||||||
case VALUE_TYPE_STRING:
|
|
||||||
case VALUE_TYPE_DYNAMIC_STRING:
|
|
||||||
return integerValue == other.integerValue;
|
|
||||||
case VALUE_TYPE_PTR:
|
|
||||||
return pointerValue == other.pointerValue;
|
|
||||||
case VALUE_TYPE_FLOAT:
|
|
||||||
return floatValue == other.floatValue;
|
|
||||||
default:
|
|
||||||
throw(std::exception());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
class SFallArrayList : public SFallArray {
|
class SFallArrayList : public SFallArray {
|
||||||
private:
|
private:
|
||||||
std::vector<ArrayElement> values;
|
std::vector<ArrayElement> values;
|
||||||
|
|
Loading…
Reference in New Issue