summaryrefslogtreecommitdiff
path: root/src/expr.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-04-27 05:01:45 (GMT)
committerMarius Kintel <marius@kintel.net>2013-04-27 05:01:45 (GMT)
commit17df3f6275fce73119c311cc73a6ad057d3b47ee (patch)
tree6c907e241b53c40c10743bbf08754b86a13f6457 /src/expr.cc
parent6b3daa748543f13cc7cf8eff1c9efeebd6dc3a14 (diff)
parent7858b0443e7fb09134f2b69a535417688353c0bb (diff)
Merge pull request #328 from openscad/issue116
Issue116
Diffstat (limited to 'src/expr.cc')
-rw-r--r--src/expr.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/expr.cc b/src/expr.cc
index 75fc47a..7a8180f 100644
--- a/src/expr.cc
+++ b/src/expr.cc
@@ -26,7 +26,7 @@
#include "expression.h"
#include "value.h"
-#include "context.h"
+#include "evalcontext.h"
#include <assert.h>
#include <sstream>
#include <algorithm>
@@ -127,13 +127,18 @@ Value Expression::evaluate(const Context *context) const
return Value();
}
if (this->type == "F") {
- Value::VectorType argvalues;
- std::transform(this->children.begin(), this->children.end(),
- std::back_inserter(argvalues),
- boost::bind(&Expression::evaluate, _1, context));
+ EvalContext c(context);
+ for (size_t i=0; i < this->call_arguments.size(); i++) {
+ c.eval_arguments.push_back(std::make_pair(this->call_arguments[i].first,
+ this->call_arguments[i].second->evaluate(context)));
+ }
+ // Value::VectorType argvalues;
+ // std::transform(this->children.begin(), this->children.end(),
+ // std::back_inserter(argvalues),
+ // boost::bind(&Expression::evaluate, _1, context));
// for (size_t i=0; i < this->children.size(); i++)
// argvalues.push_back(this->children[i]->evaluate(context));
- return context->evaluate_function(this->call_funcname, this->call_argnames, argvalues);
+ return context->evaluate_function(this->call_funcname, &c);
}
abort();
}
@@ -178,10 +183,11 @@ std::string Expression::toString() const
}
else if (this->type == "F") {
stream << this->call_funcname << "(";
- for (size_t i=0; i < this->children.size(); i++) {
+ for (size_t i=0; i < this->call_arguments.size(); i++) {
+ const Assignment &arg = this->call_arguments[i];
if (i > 0) stream << ", ";
- if (!this->call_argnames[i].empty()) stream << this->call_argnames[i] << " = ";
- stream << *this->children[i];
+ if (!arg.first.empty()) stream << arg.first << " = ";
+ stream << *arg.second;
}
stream << ")";
}
contact: Jan Huwald // Impressum