summaryrefslogtreecommitdiff
path: root/value.cc
diff options
context:
space:
mode:
Diffstat (limited to 'value.cc')
-rw-r--r--value.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/value.cc b/value.cc
index 0eeec36..7168fc0 100644
--- a/value.cc
+++ b/value.cc
@@ -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) {
contact: Jan Huwald // Impressum