CValue* SCA_ILogicBrick::Calc(VALUE_OPERATOR op, CValue *val) { CValue* temp = new CBoolValue(false,""); CValue* result = temp->Calc(op,val); temp->Release(); return result; }
CValue * COperator1Expr::Calculate() /* pre: ret: a new object containing the result of applying the operator m_op to the value of m_lhs */ { CValue *ret; CValue *temp = m_lhs->Calculate(); CValue* empty = new CEmptyValue(); ret = empty->Calc(m_op, temp); empty->Release(); temp->Release(); return ret; }
CValue* COperator2Expr::Calculate() /* pre: ret: a new object containing the result of applying operator m_op to m_lhs and m_rhs */ { bool leftmodified,rightmodified; leftmodified = m_lhs->NeedsRecalculated(); rightmodified = m_rhs->NeedsRecalculated(); // if no modifications on both left and right subtree, and result is already calculated // then just return cached result... if (!leftmodified && !rightmodified && (m_cached_calculate)) { // not modified, just return m_cached_calculate } else { // if not yet calculated, or modified... if (m_cached_calculate) { m_cached_calculate->Release(); m_cached_calculate=NULL; } CValue* ffleft = m_lhs->Calculate(); CValue* ffright = m_rhs->Calculate(); ffleft->SetOwnerExpression(this);//->m_pOwnerExpression=this; ffright->SetOwnerExpression(this);//->m_pOwnerExpression=this; m_cached_calculate = ffleft->Calc(m_op,ffright); //if (m_cached_calculate) // m_cached_calculate->Action(CValue::SETOWNEREXPR,&CVoidValue(this,false,CValue::STACKVALUE)); ffleft->Release(); ffright->Release(); } return m_cached_calculate->AddRef(); }