]> git.tdb.fi Git - libs/gl.git/blob - source/glsl/evaluate.h
Split SL::Compiler into several files
[libs/gl.git] / source / glsl / evaluate.h
1 #ifndef MSP_GL_SL_EVALUATE_H_
2 #define MSP_GL_SL_EVALUATE_H_
3
4 #include "visitor.h"
5
6 namespace Msp {
7 namespace GL {
8 namespace SL {
9
10 class ExpressionEvaluator: public NodeVisitor
11 {
12 public:
13         typedef std::map<VariableDeclaration *, Expression *> ValueMap;
14
15 private:
16         const ValueMap *variable_values;
17         float result;
18         bool result_valid;
19
20 public:
21         ExpressionEvaluator();
22         ExpressionEvaluator(const ValueMap &);
23
24         float get_result() const { return result; }
25         bool is_result_valid() const { return result_valid; }
26
27         using NodeVisitor::visit;
28         virtual void visit(Literal &);
29         virtual void visit(ParenthesizedExpression &);
30         virtual void visit(VariableReference &);
31         virtual void visit(UnaryExpression &);
32         virtual void visit(BinaryExpression &);
33 };
34
35 } // namespace SL
36 } // namespace GL
37 } // namespace Msp
38
39 #endif