X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Foptimize.cpp;h=08455c8ac61412d71fb8cfbb684c857f6a883169;hb=223e295e4404a3913b8243d3b7eb12da39a68144;hp=d26c6e2d519179ac531dd2a635c85e605d98e9e8;hpb=d5c7c7f0b15c407b3da2184936e6deed18554c6a;p=libs%2Fgl.git diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index d26c6e2d..08455c8a 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -1,4 +1,5 @@ #include +#include #include "optimize.h" using namespace std; @@ -198,6 +199,7 @@ void FunctionInliner::visit_and_inline(RefPtr &ptr) void FunctionInliner::visit(Block &block) { + SetForScope set_block(current_block, &block); SetForScope::iterator> save_insert_point(insert_point, block.body.begin()); for(NodeList::iterator i=block.body.begin(); i!=block.body.end(); ++i) { @@ -305,7 +307,7 @@ void ConstantConditionEliminator::visit(Block &block) void ConstantConditionEliminator::visit(UnaryExpression &unary) { if(VariableReference *var = dynamic_cast(unary.expression.get())) - if(unary.oper=="++" || unary.oper=="--") + if(unary.oper->token[1]=='+' || unary.oper->token[1]=='-') variable_values.erase(var->declaration); } @@ -441,13 +443,13 @@ void UnusedVariableRemover::visit(MemberAccess &memacc) void UnusedVariableRemover::visit(UnaryExpression &unary) { TraversingVisitor::visit(unary); - if(unary.oper=="++" || unary.oper=="--") + if(unary.oper->token[1]=='+' || unary.oper->token[1]=='-') side_effects = true; } void UnusedVariableRemover::visit(BinaryExpression &binary) { - if(binary.oper=="[") + if(binary.oper->token[0]=='[') { if(assignment_target) assign_to_subscript = true;