version 1.16, 2006/06/21 21:55:43
|
version 1.17, 2007/07/25 07:16:01
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Markus Mueller (sedgewick_de@yahoo.de) |
|
// |
|
// Modified By: Adrian Schuur, schuur@de.ibm.com |
|
// Konrad Rzeszutek, konradr@us.ibm.com |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
| |
|
|
{ | { |
switch (op) | switch (op) |
{ | { |
case WQL_EQ: op = WQL_NE; break; |
case WQL_EQ: op = WQL_NE; |
case WQL_NE: op = WQL_EQ; break; |
break; |
case WQL_LT: op = WQL_GE; break; |
case WQL_NE: op = WQL_EQ; |
case WQL_LE: op = WQL_GT; break; |
break; |
case WQL_GT: op = WQL_LE; break; |
case WQL_LT: op = WQL_GE; |
case WQL_GE: op = WQL_LT; break; |
break; |
default: break; |
case WQL_LE: op = WQL_GT; |
|
break; |
|
case WQL_GT: op = WQL_LE; |
|
break; |
|
case WQL_GE: op = WQL_LT; |
|
break; |
|
default: |
|
break; |
} | } |
}; | }; |
| |
/* | /* |
String opnd2string(const WQLOperand &o) { |
String opnd2string(const WQLOperand &o) |
|
{ |
switch (o.getType()) { | switch (o.getType()) { |
case WQLOperand::PROPERTY_NAME: | case WQLOperand::PROPERTY_NAME: |
return o.getPropertyName(); | return o.getPropertyName(); |
|
|
} | } |
| |
| |
CMPIPredOp mapOperation(WQLOperation op) { |
CMPIPredOp mapOperation(WQLOperation op) |
|
{ |
static CMPIPredOp ops[]={(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0, | static CMPIPredOp ops[]={(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0, |
CMPI_PredOp_Equals, | CMPI_PredOp_Equals, |
CMPI_PredOp_NotEquals, | CMPI_PredOp_NotEquals, |
|
|
CMPI_PredOp_LessThanOrEquals, | CMPI_PredOp_LessThanOrEquals, |
CMPI_PredOp_GreaterThan, | CMPI_PredOp_GreaterThan, |
CMPI_PredOp_GreaterThanOrEquals, | CMPI_PredOp_GreaterThanOrEquals, |
(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0}; |
(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0, |
|
(CMPIPredOp)0,(CMPIPredOp)0}; |
return ops[(int)op]; | return ops[(int)op]; |
} | } |
| |
CMPIType mapType(WQLOperand::Type typ) { |
CMPIType mapType(WQLOperand::Type typ) |
|
{ |
switch (typ) { | switch (typ) { |
case WQLOperand::PROPERTY_NAME: | case WQLOperand::PROPERTY_NAME: |
return CMPI_nameString; | return CMPI_nameString; |
|
|
return CMPI_null; | return CMPI_null; |
} | } |
| |
int term_el::toStrings(CMPIType &typ, CMPIPredOp &opr, String &o1, String &o2) const { |
int term_el::toStrings( |
|
CMPIType &typ, |
|
CMPIPredOp &opr, |
|
String &o1, |
|
String &o2 ) const |
|
{ |
opr=mapOperation(op); | opr=mapOperation(op); |
o1=opnd2string(opn1); | o1=opnd2string(opn1); |
o2=opnd2string(opn2); | o2=opnd2string(opn2); |
|
|
} | } |
*/ | */ |
| |
CMPIPredOp mapOperation(WQLOperation op) { |
CMPIPredOp mapOperation(WQLOperation op) |
|
{ |
static CMPIPredOp ops[]={(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0, | static CMPIPredOp ops[]={(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0, |
CMPI_PredOp_Equals, | CMPI_PredOp_Equals, |
CMPI_PredOp_NotEquals, | CMPI_PredOp_NotEquals, |
|
|
CMPI_PredOp_LessThanOrEquals, | CMPI_PredOp_LessThanOrEquals, |
CMPI_PredOp_GreaterThan, | CMPI_PredOp_GreaterThan, |
CMPI_PredOp_GreaterThanOrEquals, | CMPI_PredOp_GreaterThanOrEquals, |
(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0}; |
(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0, |
|
(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0}; |
return ops[(int)op]; | return ops[(int)op]; |
} | } |
| |
CMPIType mapType(WQLOperand::Type typ) { |
CMPIType mapType(WQLOperand::Type typ) |
switch (typ) { |
{ |
|
switch( typ ) |
|
{ |
case WQLOperand::PROPERTY_NAME: | case WQLOperand::PROPERTY_NAME: |
return CMPI_nameString; | return CMPI_nameString; |
case WQLOperand::STRING_VALUE: | case WQLOperand::STRING_VALUE: |
|
|
| |
static bool operator==(const WQLOperand& x, const WQLOperand& y) | static bool operator==(const WQLOperand& x, const WQLOperand& y) |
{ | { |
if (x.getType()==y.getType()) switch (x.getType()) { |
if( x.getType()==y.getType() ) |
|
{ |
|
switch( x.getType() ) |
|
{ |
case WQLOperand::PROPERTY_NAME: | case WQLOperand::PROPERTY_NAME: |
return x.getPropertyName()==y.getPropertyName(); | return x.getPropertyName()==y.getPropertyName(); |
case WQLOperand::INTEGER_VALUE: | case WQLOperand::INTEGER_VALUE: |
|
|
case WQLOperand::NULL_VALUE: | case WQLOperand::NULL_VALUE: |
return true; | return true; |
} | } |
|
} |
return false; | return false; |
} | } |
| |
|
|
| |
static void addIfNotExists(TableauRow_WQL &tr, const term_el_WQL& el) | static void addIfNotExists(TableauRow_WQL &tr, const term_el_WQL& el) |
{ | { |
for (int i=0,m=tr.size(); i<m; i++) { |
for( int i=0,m=tr.size(); i<m; i++ ) |
if (tr[i]==el) return; |
{ |
|
if( tr[i]==el ) |
|
{ |
|
return; |
|
} |
} | } |
tr.append(el); | tr.append(el); |
} | } |
|
|
compile(wqs); | compile(wqs); |
} | } |
| |
CMPI_Wql2Dnf::~CMPI_Wql2Dnf() {} |
CMPI_Wql2Dnf::~CMPI_Wql2Dnf() |
|
{ |
|
} |
| |
void CMPI_Wql2Dnf::compile(const WQLSelectStatement * wqs) | void CMPI_Wql2Dnf::compile(const WQLSelectStatement * wqs) |
{ | { |
if (!wqs->hasWhereClause()) return; |
if( !wqs->hasWhereClause() ) |
|
{ |
|
return; |
|
} |
_tableau.clear(); | _tableau.clear(); |
| |
_buildEvalHeap(wqs); | _buildEvalHeap(wqs); |
|
|
Array<CMPI_stack_el> disj; | Array<CMPI_stack_el> disj; |
_gatherDisj(disj); | _gatherDisj(disj); |
if (disj.size() == 0) | if (disj.size() == 0) |
|
{ |
if (terminal_heap.size() > 0) | if (terminal_heap.size() > 0) |
|
{ |
// point to the remaining terminal element | // point to the remaining terminal element |
disj.append(CMPI_stack_el(0,true)); | disj.append(CMPI_stack_el(0,true)); |
|
} |
|
} |
| |
for (Uint32 i=0, n =disj.size(); i< n; i++) | for (Uint32 i=0, n =disj.size(); i< n; i++) |
{ | { |
|
|
{ | { |
_gatherConj(conj, disj[i]); | _gatherConj(conj, disj[i]); |
for( Uint32 j=0, m = conj.size(); j < m; j++) | for( Uint32 j=0, m = conj.size(); j < m; j++) |
|
{ |
addIfNotExists(tr,terminal_heap[conj[j].opn]); | addIfNotExists(tr,terminal_heap[conj[j].opn]); |
// tr.append(terminal_heap[conj[j].opn]); | // tr.append(terminal_heap[conj[j].opn]); |
} | } |
|
} |
else | else |
|
{ |
addIfNotExists(tr,terminal_heap[disj[i].opn]); | addIfNotExists(tr,terminal_heap[disj[i].opn]); |
// tr.append(terminal_heap[disj[i].opn]); | // tr.append(terminal_heap[disj[i].opn]); |
|
} |
_tableau.append(tr); | _tableau.append(tr); |
} | } |
| |
|
|
CMPI_Wql2Dnf::_ResolveProperty(rhs,source); | CMPI_Wql2Dnf::_ResolveProperty(rhs,source); |
| |
if (rhs.getType() != lhs.getType()) | if (rhs.getType() != lhs.getType()) |
|
{ |
throw TypeMismatchException(); | throw TypeMismatchException(); |
|
} |
| |
if (!_Evaluate(lhs, rhs, tr[j].op)) | if (!_Evaluate(lhs, rhs, tr[j].op)) |
{ | { |
|
|
break; | break; |
} | } |
else | else |
|
{ |
b = true; | b = true; |
} | } |
if (b) return true; |
} |
|
if( b ) |
|
{ |
|
return true; |
|
} |
} | } |
return false; | return false; |
} | } |
| |
void CMPI_Wql2Dnf::print(void) | void CMPI_Wql2Dnf::print(void) |
{ | { |
for (Uint32 i=0, n=eval_heap.size();i < n;i++) { |
for( Uint32 i=0, n=eval_heap.size();i < n;i++ ) |
|
{ |
WQLOperation wop = eval_heap[i].op; | WQLOperation wop = eval_heap[i].op; |
if (wop == WQL_IS_TRUE) continue; |
if( wop == WQL_IS_TRUE ) |
|
{ |
|
continue; |
|
} |
cout << "Eval element " << i << ": "; | cout << "Eval element " << i << ": "; |
if (eval_heap[i].is_terminal1) cout << "T("; |
if( eval_heap[i].is_terminal1 ) |
else cout << "E("; |
{ |
|
cout << "T("; |
|
} |
|
else |
|
{ |
|
cout << "E("; |
|
} |
cout << eval_heap[i].opn1 << ") "; | cout << eval_heap[i].opn1 << ") "; |
cout << WQLOperationToString(eval_heap[i].op); | cout << WQLOperationToString(eval_heap[i].op); |
if (eval_heap[i].is_terminal2) cout << " T("; |
if( eval_heap[i].is_terminal2 ) |
else cout << " E("; |
{ |
|
cout << " T("; |
|
} |
|
else |
|
{ |
|
cout << " E("; |
|
} |
cout << eval_heap[i].opn2 << ")" << endl; | cout << eval_heap[i].opn2 << ")" << endl; |
} | } |
for (Uint32 i=0, n=terminal_heap.size();i < n;i++) { |
|
|
for( Uint32 i=0, n=terminal_heap.size();i < n;i++ ) |
|
{ |
cout << "Terminal expression " << i << ": "; | cout << "Terminal expression " << i << ": "; |
cout << terminal_heap[i].opn1.toString() << " "; | cout << terminal_heap[i].opn1.toString() << " "; |
cout << WQLOperationToString(terminal_heap[i].op) << " " | cout << WQLOperationToString(terminal_heap[i].op) << " " |
|
|
cout << WQLOperationToString(tr[j].op) << " " | cout << WQLOperationToString(tr[j].op) << " " |
<< tr[j].opn2.toString() << endl; | << tr[j].opn2.toString() << endl; |
} | } |
|
|
} | } |
| |
} | } |
| |
String |
String WQL2String(const WQLOperand &o) |
WQL2String(const WQLOperand &o) { |
{ |
switch (o.getType()) { |
switch( o.getType() ) |
|
{ |
case WQLOperand::PROPERTY_NAME: | case WQLOperand::PROPERTY_NAME: |
return o.getPropertyName(); | return o.getPropertyName(); |
case WQLOperand::STRING_VALUE: | case WQLOperand::STRING_VALUE: |
|
|
return "NULL_VALUE"; | return "NULL_VALUE"; |
} | } |
| |
CMPIPredOp |
CMPIPredOp WQL2PredOp(const WQLOperation &op) |
WQL2PredOp(const WQLOperation &op) { |
{ |
| |
static CMPIPredOp ops[]={(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0, | static CMPIPredOp ops[]={(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0, |
CMPI_PredOp_Equals, | CMPI_PredOp_Equals, |
|
|
CMPI_PredOp_LessThanOrEquals, | CMPI_PredOp_LessThanOrEquals, |
CMPI_PredOp_GreaterThan, | CMPI_PredOp_GreaterThan, |
CMPI_PredOp_GreaterThanOrEquals, | CMPI_PredOp_GreaterThanOrEquals, |
(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0}; |
(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0, |
|
(CMPIPredOp)0,(CMPIPredOp)0,(CMPIPredOp)0}; |
| |
return ops[(int)op]; | return ops[(int)op]; |
} | } |
| |
CMPI_QueryOperand::Type |
CMPI_QueryOperand::Type WQL2Type(WQLOperand::Type typ) |
WQL2Type(WQLOperand::Type typ) { |
{ |
switch (typ) { |
switch( typ ) |
|
{ |
case WQLOperand::PROPERTY_NAME: | case WQLOperand::PROPERTY_NAME: |
return CMPI_QueryOperand::PROPERTY_TYPE; | return CMPI_QueryOperand::PROPERTY_TYPE; |
case WQLOperand::STRING_VALUE: | case WQLOperand::STRING_VALUE: |
|
|
term_el_WQL t = tr_wql[j]; | term_el_WQL t = tr_wql[j]; |
| |
CMPI_TableauRow tr; | CMPI_TableauRow tr; |
CMPI_QueryOperand lhs(WQL2String(t.opn1), WQL2Type(t.opn1.getType())); |
CMPI_QueryOperand lhs(WQL2String(t.opn1), |
CMPI_QueryOperand rhs(WQL2String(t.opn2), WQL2Type(t.opn2.getType())); |
WQL2Type(t.opn1.getType())); |
|
CMPI_QueryOperand rhs(WQL2String(t.opn2), |
|
WQL2Type(t.opn2.getType())); |
| |
tr.append(CMPI_term_el(t.mark, WQL2PredOp(t.op), lhs, rhs)); | tr.append(CMPI_term_el(t.mark, WQL2PredOp(t.op), lhs, rhs)); |
_CMPI_tableau.append (tr); | _CMPI_tableau.append (tr); |
|
|
CMPI_stack_el op2 = stack.top(); | CMPI_stack_el op2 = stack.top(); |
| |
// generate Eval expression | // generate Eval expression |
eval_heap.append(CMPI_eval_el(0, op , op1.opn, op1.is_terminal, |
eval_heap.append(CMPI_eval_el( |
op2.opn , op2.is_terminal)); |
0, op , op1.opn, |
|
op1.is_terminal,op2.opn , |
|
op2.is_terminal)); |
| |
stack.top() = CMPI_stack_el(eval_heap.size()-1, false); | stack.top() = CMPI_stack_el(eval_heap.size()-1, false); |
| |
|
|
CMPI_stack_el op1 = stack.top(); | CMPI_stack_el op1 = stack.top(); |
| |
// generate Eval expression | // generate Eval expression |
eval_heap.append(CMPI_eval_el(0, op , op1.opn, op1.is_terminal, |
eval_heap.append(CMPI_eval_el( |
-1, true)); |
0, op , op1.opn, |
|
op1.is_terminal,-1, true)); |
| |
stack.top() = CMPI_stack_el(eval_heap.size()-1, false); | stack.top() = CMPI_stack_el(eval_heap.size()-1, false); |
| |
|
|
{ | { |
// Test first operand | // Test first operand |
if ((!eval_heap[j].is_terminal1) && (eval_heap[j].opn1 == i)) | if ((!eval_heap[j].is_terminal1) && (eval_heap[j].opn1 == i)) |
|
{ |
| |
eval_heap[j].assign_unary_to_first(eval_heap[i]); | eval_heap[j].assign_unary_to_first(eval_heap[i]); |
|
} |
| |
// Test second operand | // Test second operand |
if ((!eval_heap[j].is_terminal2) && (eval_heap[j].opn2 == i)) | if ((!eval_heap[j].is_terminal2) && (eval_heap[j].opn2 == i)) |
|
{ |
| |
eval_heap[j].assign_unary_to_second(eval_heap[i]); | eval_heap[j].assign_unary_to_second(eval_heap[i]); |
} | } |
|
} |
| |
// Test: Double NOT created by moving down | // Test: Double NOT created by moving down |
| |
if (eval_heap[i].mark) | if (eval_heap[i].mark) |
|
{ |
eval_heap[i].mark = false; | eval_heap[i].mark = false; |
|
} |
else | else |
|
{ |
_found = true; | _found = true; |
|
} |
// else indicate a pending NOT to be pushed down further | // else indicate a pending NOT to be pushed down further |
} | } |
| |
|
|
// further and switch operators (AND / OR) | // further and switch operators (AND / OR) |
| |
eval_heap[i].mark=false; | eval_heap[i].mark=false; |
if (eval_heap[i].op == WQL_OR) eval_heap[i].op = WQL_AND; |
if( eval_heap[i].op == WQL_OR ) |
else if (eval_heap[i].op == WQL_AND) eval_heap[i].op = WQL_OR; |
{ |
|
eval_heap[i].op = WQL_AND; |
|
} |
|
else |
|
{ |
|
if( eval_heap[i].op == WQL_AND ) |
|
{ |
|
eval_heap[i].op = WQL_OR; |
|
} |
|
} |
| |
// NOT operator is already ruled out | // NOT operator is already ruled out |
_found = true; | _found = true; |
|
|
| |
int j = eval_heap[i].opn1; | int j = eval_heap[i].opn1; |
if (eval_heap[i].is_terminal1) | if (eval_heap[i].is_terminal1) |
|
{ |
// Flip NOT mark | // Flip NOT mark |
terminal_heap[j].negate(); | terminal_heap[j].negate(); |
|
} |
else | else |
|
{ |
eval_heap[j].mark = !(eval_heap[j].mark); | eval_heap[j].mark = !(eval_heap[j].mark); |
|
} |
| |
//Second operand (if it exists) | //Second operand (if it exists) |
| |
if ((j = eval_heap[i].opn2) >= 0) | if ((j = eval_heap[i].opn2) >= 0) |
{ | { |
if (eval_heap[i].is_terminal2) | if (eval_heap[i].is_terminal2) |
|
{ |
// Flip NOT mark | // Flip NOT mark |
terminal_heap[j].negate(); | terminal_heap[j].negate(); |
|
} |
else | else |
|
{ |
eval_heap[j].mark = !(eval_heap[j].mark); | eval_heap[j].mark = !(eval_heap[j].mark); |
} | } |
} | } |
} | } |
} | } |
|
} |
| |
void CMPI_Wql2Dnf::_factoring(void) | void CMPI_Wql2Dnf::_factoring(void) |
{ | { |
|
|
if (!eval_heap[i].is_terminal1) | if (!eval_heap[i].is_terminal1) |
{ | { |
index = eval_heap[i].opn1; // remember the index | index = eval_heap[i].opn1; // remember the index |
if (eval_heap[index].op == WQL_OR) _found = 1; |
if( eval_heap[index].op == WQL_OR ) |
|
{ |
|
_found = 1; |
} | } |
| |
if ((_found == 0) && (!eval_heap[i].is_terminal2)) | if ((_found == 0) && (!eval_heap[i].is_terminal2)) |
{ | { |
index = eval_heap[i].opn2; // remember the index | index = eval_heap[i].opn2; // remember the index |
if (eval_heap[index].op == WQL_OR) _found = 2; |
if( eval_heap[index].op == WQL_OR ) |
|
{ |
|
_found = 2; |
|
} |
} | } |
| |
if (_found != 0) | if (_found != 0) |
|
|
CMPI_stack_el s; | CMPI_stack_el s; |
| |
if (_found == 1) | if (_found == 1) |
|
{ |
s = eval_heap[i].getSecond(); | s = eval_heap[i].getSecond(); |
|
} |
else | else |
|
{ |
s = eval_heap[i].getFirst(); | s = eval_heap[i].getFirst(); |
|
} |
| |
// insert two new expression before entry i | // insert two new expression before entry i |
CMPI_eval_el evl; | CMPI_eval_el evl; |
| |
evl = CMPI_eval_el(false, WQL_OR, i+1, false, i, false); | evl = CMPI_eval_el(false, WQL_OR, i+1, false, i, false); |
if ((Uint32 )i < eval_heap.size()-1) | if ((Uint32 )i < eval_heap.size()-1) |
|
{ |
eval_heap.insert(i+1, evl); | eval_heap.insert(i+1, evl); |
|
} |
else | else |
|
{ |
eval_heap.append(evl); | eval_heap.append(evl); |
|
} |
eval_heap.insert(i+1, evl); | eval_heap.insert(i+1, evl); |
| |
for (int j=eval_heap.size()-1; j > i + 2; j--) | for (int j=eval_heap.size()-1; j > i + 2; j--) |
|
|
| |
if ((!eval_heap[j].is_terminal1)&& | if ((!eval_heap[j].is_terminal1)&& |
(eval_heap[j].opn1 >= i)) | (eval_heap[j].opn1 >= i)) |
|
{ |
eval_heap[j].opn1 += 2; | eval_heap[j].opn1 += 2; |
|
} |
|
|
if ((!eval_heap[j].is_terminal2)&& | if ((!eval_heap[j].is_terminal2)&& |
(eval_heap[j].opn2 >= i)) | (eval_heap[j].opn2 >= i)) |
|
{ |
eval_heap[j].opn2 += 2; | eval_heap[j].opn2 += 2; |
} | } |
|
} |
| |
n+=2; // increase size of array | n+=2; // increase size of array |
| |
|
|
i++; // increase pointer | i++; // increase pointer |
} | } |
} | } |
|
} |
void CMPI_Wql2Dnf::_gatherDisj(Array<CMPI_stack_el>& stk) | void CMPI_Wql2Dnf::_gatherDisj(Array<CMPI_stack_el>& stk) |
{ | { |
_gather(stk, CMPI_stack_el(0,true), true); | _gather(stk, CMPI_stack_el(0,true), true); |
} | } |
| |
void CMPI_Wql2Dnf::_gatherConj(Array<CMPI_stack_el>& stk, CMPI_stack_el sel) |
void CMPI_Wql2Dnf::_gatherConj( |
|
Array<CMPI_stack_el>& stk, |
|
CMPI_stack_el sel) |
{ | { |
_gather(stk, sel, false); | _gather(stk, sel, false); |
} | } |
| |
void CMPI_Wql2Dnf::_gather(Array<CMPI_stack_el>& stk, CMPI_stack_el sel, Boolean or_flag) |
void CMPI_Wql2Dnf::_gather( |
|
Array<CMPI_stack_el>& stk, |
|
CMPI_stack_el sel, |
|
Boolean or_flag) |
{ | { |
Uint32 i = 0; | Uint32 i = 0; |
| |
stk.clear(); | stk.clear(); |
stk.reserveCapacity(16); | stk.reserveCapacity(16); |
| |
if ((i = eval_heap.size()) == 0) return; |
if( (i = eval_heap.size()) == 0 ) |
|
{ |
|
return; |
|
} |
| |
while (eval_heap[i-1].op == WQL_IS_TRUE) | while (eval_heap[i-1].op == WQL_IS_TRUE) |
{ | { |
eval_heap.remove(i-1); | eval_heap.remove(i-1); |
i--; | i--; |
if (i == 0) return; |
if( i == 0 ) |
|
{ |
|
return; |
|
} |
} | } |
//if (i == 0) return; | //if (i == 0) return; |
| |
if (or_flag) | if (or_flag) |
|
{ |
stk.append(CMPI_stack_el(i-1,false)); | stk.append(CMPI_stack_el(i-1,false)); |
|
} |
else | else |
{ | { |
if (sel.is_terminal) return; |
if( sel.is_terminal ) |
|
{ |
|
return; |
|
} |
stk.append(sel); | stk.append(sel); |
} | } |
| |
|
|
int k = stk[i].opn; | int k = stk[i].opn; |
| |
if ((k < 0) || (stk[i].is_terminal)) | if ((k < 0) || (stk[i].is_terminal)) |
|
{ |
i++; | i++; |
|
} |
else | else |
{ | { |
if ( ((eval_heap[k].op != WQL_OR) && (or_flag)) || | if ( ((eval_heap[k].op != WQL_OR) && (or_flag)) || |
((eval_heap[k].op != WQL_AND) && (!or_flag)) ) | ((eval_heap[k].op != WQL_AND) && (!or_flag)) ) |
|
{ |
i++; | i++; |
|
} |
else | else |
{ | { |
// replace the element with disjunction | // replace the element with disjunction |
stk[i] = eval_heap[k].getSecond(); | stk[i] = eval_heap[k].getSecond(); |
stk.insert(i, eval_heap[k].getFirst()); | stk.insert(i, eval_heap[k].getFirst()); |
if (or_flag) | if (or_flag) |
|
{ |
eval_heap[k].op = WQL_IS_TRUE; | eval_heap[k].op = WQL_IS_TRUE; |
} | } |
} | } |
} | } |
} | } |
|
} |
| |
//============================================================================== |
//============================================================================= |
// | // |
// class CMPI_stack_el | // class CMPI_stack_el |
// | // |
//============================================================================== |
//============================================================================= |
| |
//============================================================================== |
//============================================================================= |
// | // |
// class CMPI_eval_el | // class CMPI_eval_el |
// | // |
//============================================================================== |
//============================================================================= |
| |
CMPI_stack_el CMPI_eval_el::getFirst() | CMPI_stack_el CMPI_eval_el::getFirst() |
{ | { |
|
|
opn2 = opn1; | opn2 = opn1; |
opn1 = k; | opn1 = k; |
} | } |
else if ((is_terminal1) && (!is_terminal2)) |
else |
|
{ |
|
if( (is_terminal1) && (!is_terminal2) ) |
|
{ |
if ((k = opn2) > opn1) | if ((k = opn2) > opn1) |
{ | { |
opn2 = opn1; | opn2 = opn1; |
|
|
is_terminal2 = true; | is_terminal2 = true; |
} | } |
} | } |
|
} |
|
} |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |