-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVariable.cpp
More file actions
29 lines (22 loc) · 853 Bytes
/
Copy pathVariable.cpp
File metadata and controls
29 lines (22 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "Variable.hpp"
#include "Operation.hpp"
#include "BinaryOperationExpression.hpp"
Variable::Variable(const std::string &variableName) : variableName(variableName) {
}
std::shared_ptr<Expression> Variable::add(std::shared_ptr<ASTNode> toAdd) {
return ASTBuilder::getSelf()->createBinaryOperationExpression(shared_from_this(),
std::static_pointer_cast<Operation>(toAdd),
nullptr);
}
long double Variable::resolve(std::map<std::string, long double> vars) const {
return vars[variableName];
}
std::shared_ptr<Expression> Variable::simplify() {
return shared_from_this();
}
bool Variable::openForInput() const {
return false;
}
std::string Variable::toString() const {
return variableName;
}