summaryrefslogtreecommitdiff
path: root/evaluator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'evaluator.cpp')
-rw-r--r--evaluator.cpp52
1 files changed, 51 insertions, 1 deletions
diff --git a/evaluator.cpp b/evaluator.cpp
index 1356258..c5721ae 100644
--- a/evaluator.cpp
+++ b/evaluator.cpp
@@ -6,11 +6,61 @@ evaluator::evaluator(const char * display_name) :
m_display_name(display_name)
{ }
+/* XXX: This is really ugly. I'm sure there is a way to do this with function
+ * overloads, but I can't figure out how. */
value *
evaluator::evaluate(
value * l,
value * r)
{
+ enum value_type l_type = l->get_type();
+ enum value_type r_type = r->get_type();
+ switch(l_type) {
+ case VALUE_TYPE_FLOAT:
+ return evaluate((float_value*)l, r);
+ default:
+ switch(r_type) {
+ case VALUE_TYPE_FLOAT:
+ return evaluate(l, (float_value*)r);
+ default:
+ return default_evaluate(l, r);
+ }
+ }
+}
+
+value *
+evaluator::evaluate(
+ float_value * l,
+ value * r)
+{
+ enum value_type r_type = r->get_type();
+ switch(r_type) {
+ case VALUE_TYPE_FLOAT:
+ return evaluate(l, (float_value*)r);
+ default:
+ return default_evaluate(l, r);
+ }
+}
+
+value *
+evaluator::evaluate(
+ value * l,
+ float_value * r)
+{
+ enum value_type l_type = l->get_type();
+ switch(l_type) {
+ case VALUE_TYPE_FLOAT:
+ return evaluate((float_value*)l, r);
+ default:
+ return default_evaluate(l, r);
+ }
+}
+
+value *
+evaluator::default_evaluate(
+ value * l,
+ value * r)
+{
return new tree_value(this, l, r);
}
@@ -31,7 +81,7 @@ add_evaluator::evaluate(
{
float_value * new_val;
if (!l->m_has_value || !r->m_has_value) {
- return this->evaluator::evaluate(l, r);
+ return default_evaluate(l, r);
}
new_val = new float_value();