summaryrefslogtreecommitdiff
path: root/value.cc
diff options
context:
space:
mode:
authorclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-07-01 08:06:06 (GMT)
committerclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-07-01 08:06:06 (GMT)
commit27ecd0b1d0bf0114b465beeb4db482f0f1f87c52 (patch)
treefbf5c869321f15b75b6f5c1c2299b5f5fd960e18 /value.cc
parentb7ca4bfdb38b8caf153f6d93b1d3959f8ffd53ca (diff)
Clifford Wolf:
Another cleanup in expression handling git-svn-id: http://svn.clifford.at/openscad/trunk@43 b57f626f-c46c-0410-a088-ec61d464b74c
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