ExprOptimizer.h
00001 #ifndef gridripper_math_expr_ExprOptimizer_h
00002 #define gridripper_math_expr_ExprOptimizer_h
00003
00004 #include <string>
00005 #include <gridripper/config.h>
00006 #include <gridripper/tvector.h>
00007
00008 namespace gridripper { namespace math { namespace expr {
00009
00010 class StkConst;
00011 class StkOp;
00012 class StkOpRepository;
00013
00014 using namespace std;
00015
00023 class ExprOptimizer
00024 {
00025 public:
00035 static StkConst* reuseConst(tvector<StkConst*>& nums,
00036 const string& name, GReal_t value);
00037
00041 static void performAll(tvector<StkOp*>& program,
00042 tvector<StkConst*>& nums,
00043 GReal_t* stack, StkOpRepository& rep);
00044
00046 static void inlineExprs(tvector<StkOp*>& program);
00047
00049 static void precalc(tvector<StkOp*>& program,
00050 tvector<StkConst*>& nums,
00051 GReal_t* stack);
00056 static void optimizePow(tvector<StkOp*>& program,
00057 StkOpRepository& rep);
00058
00063 static void optimizeMult(tvector<StkOp*>& program,
00064 StkOpRepository& rep);
00065
00070 static void optimizeDiv(tvector<StkOp*>& program,
00071 StkOpRepository& rep);
00072
00076 static void optimizePlus(tvector<StkOp*>& program,
00077 StkOpRepository& rep);
00078
00082 static void optimizeMinus(tvector<StkOp*>& program,
00083 StkOpRepository& rep);
00084
00085 private:
00086 static void precalc0(tvector<StkOp*>& program,
00087 tvector<StkConst*>& nums,
00088 GReal_t* stack);
00089 };
00090
00091 } } }
00092
00093 #endif