diff options
Diffstat (limited to 'value.cc')
-rw-r--r-- | value.cc | 78 |
1 files changed, 78 insertions, 0 deletions
@@ -73,6 +73,30 @@ Value& Value::operator = (const Value &v) return *this; } +Value Value::operator ! () const +{ + if (type == BOOL) { + return Value(!b); + } + return Value(); +} + +Value Value::operator && (const Value &v) const +{ + if (type == BOOL && v.type == BOOL) { + return Value(b && v.b); + } + return Value(); +} + +Value Value::operator || (const Value &v) const +{ + if (type == BOOL && v.type == BOOL) { + return Value(b || v.b); + } + return Value(); +} + Value Value::operator + (const Value &v) const { if (type == VECTOR && v.type == VECTOR) { @@ -155,6 +179,60 @@ Value Value::operator % (const Value &v) const return Value(); } +Value Value::operator < (const Value &v) const +{ + if (type == NUMBER && v.type == NUMBER) { + return Value(num < v.num); + } + return Value(); +} + +Value Value::operator <= (const Value &v) const +{ + if (type == NUMBER && v.type == NUMBER) { + return Value(num <= v.num); + } + return Value(); +} + +Value Value::operator == (const Value &v) const +{ + if (type == BOOL && v.type == BOOL) { + return Value(b == v.b); + } + if (type == NUMBER && v.type == NUMBER) { + return Value(num == v.num); + } + return Value(); +} + +Value Value::operator != (const Value &v) const +{ + if (type == BOOL && v.type == BOOL) { + return Value(b != v.b); + } + if (type == NUMBER && v.type == NUMBER) { + return Value(num != v.num); + } + return Value(); +} + +Value Value::operator >= (const Value &v) const +{ + if (type == NUMBER && v.type == NUMBER) { + return Value(num >= v.num); + } + return Value(); +} + +Value Value::operator > (const Value &v) const +{ + if (type == NUMBER && v.type == NUMBER) { + return Value(num > v.num); + } + return Value(); +} + Value Value::inv() const { if (type == VECTOR) { |