00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00035 #include "roundingexpression.h"
00036
00037 RoundingExpression::RoundingExpression(EXP_TYPE _type,
00038 AggregateFunctExpression *
00039 _aggfunct):OperandExpression(_type,
00040 et_operandrounding),
00041 aggfunct(_aggfunct) {
00042 }
00043
00044 RoundingExpression::~RoundingExpression() {
00045 delete aggfunct;
00046 }
00047
00048 void RoundingExpression::scopeCheck(vector < unsigned >&def_vars,
00049 vector < unsigned >&introduced_vars,
00050 vector < unsigned >&violating_vars) {
00051 aggfunct->scopeCheck(def_vars, introduced_vars, violating_vars);
00052 }
00053
00054 void RoundingExpression::replaceVarId(unsigned old_id, unsigned new_id) {
00055 aggfunct->replaceVarId(old_id, new_id);
00056 }
00057
00058 void RoundingExpression::extractFSAMap(FSAMap * fsamap, unsigned parent_var) {
00059 aggfunct->extractFSAMap(fsamap, parent_var);
00060 }
00061
00062 void RoundingExpression::extractParVarMap(ParVarMap * parvarmap) {
00063 aggfunct->extractParVarMap(parvarmap);
00064 }
00065
00066 void RoundingExpression::extractDependencies(vector < DependencySet * >*depset) {
00067 aggfunct->extractDependencies(depset);
00068 }
00069
00070 Expression *RoundingExpression::placeSignOffs(vector <
00071 SignOffExpression * >&signoffs) {
00072 aggfunct->placeSignOffs(signoffs);
00073
00074 return this;
00075 }
00076
00077 void RoundingExpression::rewriteAggregateFuncts() {
00078 aggfunct->rewriteAggregateFuncts();
00079 }
00080
00081 void RoundingExpression::print(OutputStream & dos) const {
00082 switch (type) {
00083 case et_abs:
00084 dos << "fn:abs(" << (*aggfunct) << ")";
00085 break;
00086 case et_ceiling:
00087 dos << "fn:ceiling(" << (*aggfunct) << ")";
00088 break;
00089 case et_cover:
00090 dos << "fn:cover(" << (*aggfunct) << ")";
00091 break;
00092 case et_floor:
00093 dos << "fn:floor(" << (*aggfunct) << ")";
00094 break;
00095 case et_round:
00096 dos << "fn:round(" << (*aggfunct) << ")";
00097 break;
00098 case et_roundhalftoeven:
00099 dos << "fn:round-half-to-even(" << (*aggfunct) << ")";
00100 break;
00101 case et_truncate:
00102 dos << "fn:truncate(" << (*aggfunct) << ")";
00103 break;
00104 default:
00105 break;
00106 }
00107 }
00108
00109 void RoundingExpression::init(BufferNode * root) {
00110 aggfunct->init(root);
00111 }
00112
00113 void RoundingExpression::prepareOperand(OutputStream & eos, Environment * env,
00114 unsigned modus) {
00115 eval(eos, env, EVAL_QUERY_SILENT);
00116 }
00117
00118 Value *RoundingExpression::getNextValue() {
00119 if (initial) {
00120 initial = false;
00121 return &cur_val;
00122 } else {
00123 initial = true;
00124 return NULL;
00125 }
00126 }