1
//=============================================================================
3
// File : KviKvsTreeNodeExpression.cpp
4
// Creation date : Mon 06 Oct 2003 01.35 CEST by Szymon Stefanek
6
// This file is part of the KVIrc irc client distribution
7
// Copyright (C) 2003-2010 Szymon Stefanek (pragma at kvirc dot net)
9
// This program is FREE software. You can redistribute it and/or
10
// modify it under the terms of the GNU General Public License
11
// as published by the Free Software Foundation; either version 2
12
// of the License, or (at your opinion) any later version.
14
// This program is distributed in the HOPE that it will be USEFUL,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
// See the GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program. If not, write to the Free Software Foundation,
21
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
//=============================================================================
25
#include "KviKvsTreeNodeExpression.h"
26
#include "KviLocale.h"
30
KviKvsTreeNodeExpression::KviKvsTreeNodeExpression(const QChar * pLocation)
31
: KviKvsTreeNodeData(pLocation)
33
m_pParentExpression = 0;
36
KviKvsTreeNodeExpression::~KviKvsTreeNodeExpression()
40
void KviKvsTreeNodeExpression::contextDescription(QString &szBuffer)
42
szBuffer = "Expression Evaluation";
45
void KviKvsTreeNodeExpression::dump(const char * prefix)
47
qDebug("%s Expression",prefix);
50
int KviKvsTreeNodeExpression::precedence()
55
KviKvsTreeNodeExpression * KviKvsTreeNodeExpression::left()
57
qDebug("KviKvsTreeNodeExpression::left() : should never end up here!");
61
KviKvsTreeNodeExpression * KviKvsTreeNodeExpression::right()
63
qDebug("KviKvsTreeNodeExpression::right() : should never end up here!");
67
void KviKvsTreeNodeExpression::setLeft(KviKvsTreeNodeExpression *)
69
qDebug("KviKvsTreeNodeExpression::setLeft() : should never end up here!");
72
void KviKvsTreeNodeExpression::setRight(KviKvsTreeNodeExpression *)
74
qDebug("KviKvsTreeNodeExpression::setRight() : should never end up here!");
77
KviKvsTreeNodeExpression * KviKvsTreeNodeExpression::parentWithPrecedenceLowerThan(int iPrec)
79
if(precedence() > iPrec)return this;
80
if(!parentExpression())return 0;
81
return parentExpression()->parentWithPrecedenceLowerThan(iPrec);
84
int KviKvsTreeNodeExpression::firstBinaryOperator()
86
if(!left())return precedence();
87
return left()->firstBinaryOperator();
90
///////////////////////////////////////////////////////////////////////////////
93
KviKvsTreeNodeExpressionVariableOperand::KviKvsTreeNodeExpressionVariableOperand(const QChar * pLocation,KviKvsTreeNodeData * pData)
94
: KviKvsTreeNodeExpression(pLocation)
97
m_pData->setParent(this);
100
KviKvsTreeNodeExpressionVariableOperand::~KviKvsTreeNodeExpressionVariableOperand()
105
void KviKvsTreeNodeExpressionVariableOperand::contextDescription(QString &szBuffer)
107
szBuffer = "Expression Variable Operand Evaluation";
110
void KviKvsTreeNodeExpressionVariableOperand::dump(const char * prefix)
112
qDebug("%s ExpressionVariableOperand",prefix);
113
QString tmp = prefix;
115
m_pData->dump(tmp.toUtf8().data());
118
bool KviKvsTreeNodeExpressionVariableOperand::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
120
return m_pData->evaluateReadOnly(c,pBuffer);
124
///////////////////////////////////////////////////////////////////////////////
126
KviKvsTreeNodeExpressionConstantOperand::KviKvsTreeNodeExpressionConstantOperand(const QChar * pLocation,KviKvsVariant * pConstant)
127
: KviKvsTreeNodeExpression(pLocation)
129
m_pConstant = pConstant;
132
KviKvsTreeNodeExpressionConstantOperand::~KviKvsTreeNodeExpressionConstantOperand()
137
void KviKvsTreeNodeExpressionConstantOperand::contextDescription(QString &szBuffer)
139
szBuffer = "Expression Constant Operand Evaluation";
143
void KviKvsTreeNodeExpressionConstantOperand::dump(const char * prefix)
145
qDebug("%s ExpressionConstantOperand",prefix);
146
QString tmp = prefix;
148
m_pConstant->dump(tmp.toUtf8().data());
151
bool KviKvsTreeNodeExpressionConstantOperand::evaluateReadOnly(KviKvsRunTimeContext *,KviKvsVariant * pBuffer)
153
pBuffer->copyFrom(m_pConstant);
157
///////////////////////////////////////////////////////////////////////////////
160
KviKvsTreeNodeExpressionOperator::KviKvsTreeNodeExpressionOperator(const QChar * pLocation)
161
: KviKvsTreeNodeExpression(pLocation)
165
KviKvsTreeNodeExpressionOperator::~KviKvsTreeNodeExpressionOperator()
169
void KviKvsTreeNodeExpressionOperator::contextDescription(QString &szBuffer)
171
szBuffer = "Expression Operator Evaluation";
175
void KviKvsTreeNodeExpressionOperator::dump(const char * prefix)
177
qDebug("%s ExpressionOperator",prefix);
182
///////////////////////////////////////////////////////////////////////////////
185
KviKvsTreeNodeExpressionUnaryOperator::KviKvsTreeNodeExpressionUnaryOperator(const QChar * pLocation,KviKvsTreeNodeExpression * pData)
186
: KviKvsTreeNodeExpressionOperator(pLocation)
189
m_pData->setParent(this);
190
m_pData->setParentExpression(this);
193
KviKvsTreeNodeExpressionUnaryOperator::~KviKvsTreeNodeExpressionUnaryOperator()
198
void KviKvsTreeNodeExpressionUnaryOperator::contextDescription(QString &szBuffer)
200
szBuffer = "Expression Unary Operator Evaluation";
203
void KviKvsTreeNodeExpressionUnaryOperator::dump(const char * prefix)
205
qDebug("%s ExpressionUnaryOperator",prefix);
206
QString tmp = prefix;
208
m_pData->dump(tmp.toUtf8().data());
211
bool KviKvsTreeNodeExpressionUnaryOperator::evaluateOperand(KviKvsRunTimeContext * c)
214
if(!m_pData->evaluateReadOnly(c,&v))return false;
216
if(!v.asNumber(m_nData))
218
c->error(this,__tr2qs_ctx("Operand of unary operator didn't evaluate to a number","kvs"));
224
///////////////////////////////////////////////////////////////////////////////
227
KviKvsTreeNodeExpressionUnaryOperatorNegate::KviKvsTreeNodeExpressionUnaryOperatorNegate(const QChar * pLocation,KviKvsTreeNodeExpression * pData)
228
: KviKvsTreeNodeExpressionUnaryOperator(pLocation,pData)
232
KviKvsTreeNodeExpressionUnaryOperatorNegate::~KviKvsTreeNodeExpressionUnaryOperatorNegate()
237
void KviKvsTreeNodeExpressionUnaryOperatorNegate::contextDescription(QString &szBuffer)
239
szBuffer = "Expression Unary Operator Negate";
243
void KviKvsTreeNodeExpressionUnaryOperatorNegate::dump(const char * prefix)
245
qDebug("%s ExpressionUnaryOperatorNegate",prefix);
246
QString tmp = prefix;
248
m_pData->dump(tmp.toUtf8().data());
251
int KviKvsTreeNodeExpressionUnaryOperatorNegate::precedence()
253
return PREC_OP_NEGATE;
256
bool KviKvsTreeNodeExpressionUnaryOperatorNegate::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
258
if(!evaluateOperand(c))return false;
259
if(m_nData.isReal())pBuffer->setReal(-m_nData.real());
260
else pBuffer->setInteger(-m_nData.integer());
265
///////////////////////////////////////////////////////////////////////////////
268
KviKvsTreeNodeExpressionUnaryOperatorBitwiseNot::KviKvsTreeNodeExpressionUnaryOperatorBitwiseNot(const QChar * pLocation,KviKvsTreeNodeExpression * pData)
269
: KviKvsTreeNodeExpressionUnaryOperator(pLocation,pData)
273
KviKvsTreeNodeExpressionUnaryOperatorBitwiseNot::~KviKvsTreeNodeExpressionUnaryOperatorBitwiseNot()
277
void KviKvsTreeNodeExpressionUnaryOperatorBitwiseNot::contextDescription(QString &szBuffer)
279
szBuffer = "Expression Unary Operator Bitwise Not";
282
void KviKvsTreeNodeExpressionUnaryOperatorBitwiseNot::dump(const char * prefix)
284
qDebug("%s ExpressionUnaryOperatorBitwiseNot",prefix);
285
QString tmp = prefix;
287
m_pData->dump(tmp.toUtf8().data());
290
int KviKvsTreeNodeExpressionUnaryOperatorBitwiseNot::precedence()
292
return PREC_OP_BITWISENOT;
295
bool KviKvsTreeNodeExpressionUnaryOperatorBitwiseNot::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
297
if(!evaluateOperand(c))return false;
298
if(m_nData.isReal())pBuffer->setInteger(~(int)(m_nData.real()));
299
else pBuffer->setInteger(~m_nData.integer());
304
///////////////////////////////////////////////////////////////////////////////
307
KviKvsTreeNodeExpressionUnaryOperatorLogicalNot::KviKvsTreeNodeExpressionUnaryOperatorLogicalNot(const QChar * pLocation,KviKvsTreeNodeExpression * pData)
308
: KviKvsTreeNodeExpressionUnaryOperator(pLocation,pData)
312
KviKvsTreeNodeExpressionUnaryOperatorLogicalNot::~KviKvsTreeNodeExpressionUnaryOperatorLogicalNot()
316
void KviKvsTreeNodeExpressionUnaryOperatorLogicalNot::contextDescription(QString &szBuffer)
318
szBuffer = "Expression Unary Operator Logical Not";
321
void KviKvsTreeNodeExpressionUnaryOperatorLogicalNot::dump(const char * prefix)
323
qDebug("%s ExpressionUnaryOperatorLogicalNot",prefix);
324
QString tmp = prefix;
326
m_pData->dump(tmp.toUtf8().data());
329
int KviKvsTreeNodeExpressionUnaryOperatorLogicalNot::precedence()
331
return PREC_OP_LOGICALNOT;
334
bool KviKvsTreeNodeExpressionUnaryOperatorLogicalNot::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
337
if(!m_pData->evaluateReadOnly(c,&v))return false;
338
//#warning "FIXME: We could use setNothing() for false and setInteger(1) for true: this would save memory allocations for false conditions"
339
pBuffer->setBoolean(!v.asBoolean());
345
///////////////////////////////////////////////////////////////////////////////
348
KviKvsTreeNodeExpressionBinaryOperator::KviKvsTreeNodeExpressionBinaryOperator(const QChar * pLocation)
349
: KviKvsTreeNodeExpressionOperator(pLocation)
355
KviKvsTreeNodeExpressionBinaryOperator::~KviKvsTreeNodeExpressionBinaryOperator()
357
if(m_pLeft)delete m_pLeft;
358
if(m_pRight)delete m_pRight;
361
bool KviKvsTreeNodeExpressionBinaryOperator::evaluateOperands(KviKvsRunTimeContext * c)
364
if(!m_pLeft->evaluateReadOnly(c,&v1))return false;
365
if(!v1.asNumber(m_nLeft))
367
c->error(this,__tr2qs_ctx("Left operand didn't evaluate to a number","kvs"));
371
if(!m_pRight->evaluateReadOnly(c,&v2))return false;
372
if(!v2.asNumber(m_nRight))
374
c->error(this,__tr2qs_ctx("Right operand didn't evaluate to a number","kvs"));
380
KviKvsTreeNodeExpression * KviKvsTreeNodeExpressionBinaryOperator::left()
385
KviKvsTreeNodeExpression * KviKvsTreeNodeExpressionBinaryOperator::right()
390
int KviKvsTreeNodeExpressionBinaryOperator::firstBinaryOperator()
395
void KviKvsTreeNodeExpressionBinaryOperator::setLeft(KviKvsTreeNodeExpression * pLeft)
398
m_pLeft->setParent(this);
399
m_pLeft->setParentExpression(this);
402
void KviKvsTreeNodeExpressionBinaryOperator::setRight(KviKvsTreeNodeExpression * pRight)
405
m_pRight->setParent(this);
406
m_pRight->setParentExpression(this);
410
void KviKvsTreeNodeExpressionBinaryOperator::dumpOperands(const char * prefix)
412
QString tmp = prefix;
414
if(m_pLeft)m_pLeft->dump(tmp.toUtf8().data());
415
if(m_pRight)m_pRight->dump(tmp.toUtf8().data());
418
void KviKvsTreeNodeExpressionBinaryOperator::contextDescription(QString &szBuffer)
420
szBuffer = "Expression Binary Operator";
423
void KviKvsTreeNodeExpressionBinaryOperator::dump(const char * prefix)
425
qDebug("%s ExpressionBinaryOperator",prefix);
426
dumpOperands(prefix);
429
////////////////////////////////////////////////////////////////////////////////
432
#define PREIMPLEMENT_BINARY_OPERATOR(__name,__stringname,__contextdescription,__precedence) \
433
__name::__name(const QChar * pLocation) \
434
: KviKvsTreeNodeExpressionBinaryOperator(pLocation){} \
435
__name::~__name(){} \
436
void __name::dump(const char * prefix){ qDebug("%s " __stringname,prefix); dumpOperands(prefix); } \
437
void __name::contextDescription(QString &szBuffer){ szBuffer = __contextdescription; } \
438
int __name::precedence(){ return __precedence; };
440
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorSum,"ExpressionBinaryOperatorSum","Expression Binary Operator \"+\"",PREC_OP_SUM)
442
bool KviKvsTreeNodeExpressionBinaryOperatorSum::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
444
if(!evaluateOperands(c))return false;
445
if(m_nLeft.isInteger())
447
if(m_nRight.isInteger())pBuffer->setInteger(m_nLeft.integer() + m_nRight.integer());
448
else pBuffer->setReal(m_nLeft.integer() + m_nRight.real());
450
if(m_nRight.isInteger())pBuffer->setReal(m_nLeft.real() + m_nRight.integer());
451
else pBuffer->setReal(m_nLeft.real() + m_nRight.real());
456
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorSubtraction,"ExpressionBinaryOperatorSubtraction","Expression Binary Operator \"-\"",PREC_OP_SUBTRACTION)
458
bool KviKvsTreeNodeExpressionBinaryOperatorSubtraction::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
460
if(!evaluateOperands(c))return false;
461
if(m_nLeft.isInteger())
463
if(m_nRight.isInteger())pBuffer->setInteger(m_nLeft.integer() - m_nRight.integer());
464
else pBuffer->setReal(((kvs_real_t)(m_nLeft.integer())) - m_nRight.real());
466
if(m_nRight.isInteger())pBuffer->setReal(m_nLeft.real() - ((kvs_real_t)(m_nRight.integer())));
467
else pBuffer->setReal(m_nLeft.real() - m_nRight.real());
472
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorMultiplication,"ExpressionBinaryOperatorMultiplication","Expression Binary Operator \"*\"",PREC_OP_MULTIPLICATION)
474
bool KviKvsTreeNodeExpressionBinaryOperatorMultiplication::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
476
if(!evaluateOperands(c))return false;
477
if(m_nLeft.isInteger())
479
if(m_nRight.isInteger())pBuffer->setInteger(m_nLeft.integer() * m_nRight.integer());
480
else pBuffer->setReal(((kvs_real_t)(m_nLeft.integer())) * m_nRight.real());
482
if(m_nRight.isInteger())pBuffer->setReal(m_nLeft.real() * ((kvs_real_t)(m_nRight.integer())));
483
else pBuffer->setReal(m_nLeft.real() * m_nRight.real());
489
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorDivision,"ExpressionBinaryOperatorDivision","Expression Binary Operator \"/\"",PREC_OP_DIVISION)
491
bool KviKvsTreeNodeExpressionBinaryOperatorDivision::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
493
if(!evaluateOperands(c))return false;
495
if(m_nRight.isInteger())
497
if(m_nRight.integer() == 0)
499
c->error(this,__tr2qs_ctx("Division by zero","kvs"));
502
if(m_nLeft.isInteger())pBuffer->setInteger(m_nLeft.integer() / m_nRight.integer());
503
else pBuffer->setReal(m_nLeft.real() / ((kvs_real_t)(m_nRight.integer())));
505
if(m_nRight.real() == 0.0)
507
c->error(this,__tr2qs_ctx("Division by zero","kvs"));
510
if(m_nLeft.isInteger())pBuffer->setReal(((kvs_real_t)(m_nLeft.integer())) / m_nRight.real());
511
else pBuffer->setReal(m_nLeft.real() / m_nRight.real());
517
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorModulus,"ExpressionBinaryOperatorModulus","Expression Binary Operator \"modulus\"",PREC_OP_MODULUS)
519
bool KviKvsTreeNodeExpressionBinaryOperatorModulus::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
521
if(!evaluateOperands(c))return false;
523
if(m_nRight.isInteger())
525
if(m_nRight.integer() == 0)
527
c->error(this,__tr2qs_ctx("Division by zero","kvs"));
530
if(m_nLeft.isInteger())pBuffer->setInteger(m_nLeft.integer() % m_nRight.integer());
531
else pBuffer->setReal(fmod(m_nLeft.real(),((kvs_real_t)(m_nRight.integer()))));
533
if(m_nRight.real() == 0.0)
535
c->error(this,__tr2qs_ctx("Division by zero","kvs"));
538
if(m_nLeft.isInteger())pBuffer->setReal(fmod(((kvs_real_t)(m_nLeft.integer())),m_nRight.real()));
539
else pBuffer->setReal(fmod(m_nLeft.real(),m_nRight.real()));
544
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorBitwiseAnd,"ExpressionBinaryOperatorBitwiseAnd","Expression Binary Operator \"&\"",PREC_OP_BITWISEAND)
546
bool KviKvsTreeNodeExpressionBinaryOperatorBitwiseAnd::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
548
if(!evaluateOperands(c))return false;
549
int iLeft = m_nLeft.isInteger() ? m_nLeft.integer() : (kvs_int_t)m_nLeft.real();
550
int iRight = m_nRight.isInteger() ? m_nRight.integer() : (kvs_int_t)m_nRight.real();
551
pBuffer->setInteger(iLeft & iRight);
555
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorBitwiseOr,"ExpressionBinaryOperatorBitwiseOr","Expression Binary Operator \"|\"",PREC_OP_BITWISEOR)
557
bool KviKvsTreeNodeExpressionBinaryOperatorBitwiseOr::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
559
if(!evaluateOperands(c))return false;
560
int iLeft = m_nLeft.isInteger() ? m_nLeft.integer() : (kvs_int_t)m_nLeft.real();
561
int iRight = m_nRight.isInteger() ? m_nRight.integer() : (kvs_int_t)m_nRight.real();
562
pBuffer->setInteger(iLeft | iRight);
566
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorBitwiseXor,"ExpressionBinaryOperatorBitwiseXor","Expression Binary Operator \"^\"",PREC_OP_BITWISEXOR)
568
bool KviKvsTreeNodeExpressionBinaryOperatorBitwiseXor::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
570
if(!evaluateOperands(c))return false;
571
int iLeft = m_nLeft.isInteger() ? m_nLeft.integer() : (kvs_int_t)m_nLeft.real();
572
int iRight = m_nRight.isInteger() ? m_nRight.integer() : (kvs_int_t)m_nRight.real();
573
pBuffer->setInteger(iLeft ^ iRight);
577
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorShiftLeft,"ExpressionBinaryOperatorShiftLeft","Expression Binary Operator \"<<\"",PREC_OP_SHIFTLEFT)
579
bool KviKvsTreeNodeExpressionBinaryOperatorShiftLeft::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
581
if(!evaluateOperands(c))return false;
582
int iLeft = m_nLeft.isInteger() ? m_nLeft.integer() : (kvs_int_t)(m_nLeft.real());
583
int iRight = m_nRight.isInteger() ? m_nRight.integer() : (kvs_int_t)(m_nRight.real());
584
pBuffer->setInteger(iLeft << iRight);
588
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorShiftRight,"ExpressionBinaryOperatorShiftRight","Expression Binary Operator \">>\"",PREC_OP_SHIFTRIGHT)
590
bool KviKvsTreeNodeExpressionBinaryOperatorShiftRight::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
592
if(!evaluateOperands(c))return false;
593
int iLeft = m_nLeft.isInteger() ? m_nLeft.integer() : (kvs_int_t)(m_nLeft.real());
594
int iRight = m_nRight.isInteger() ? m_nRight.integer() : (kvs_int_t)(m_nRight.real());
595
pBuffer->setInteger(iLeft >> iRight);
599
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorAnd,"ExpressionBinaryOperatorAnd","Expression Binary Operator \"&&\"",PREC_OP_AND)
601
bool KviKvsTreeNodeExpressionBinaryOperatorAnd::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
605
if(!m_pLeft->evaluateReadOnly(c,&v1))return false;
606
//#warning "FIXME: We could use setNothing() as false: this would save memory allocations (and thus time)"
609
pBuffer->setBoolean(false);
612
if(!m_pRight->evaluateReadOnly(c,&v2))return false;
613
pBuffer->setBoolean(v2.asBoolean());
618
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorOr,"ExpressionBinaryOperatorOr","Expression Binary Operator \"||\"",PREC_OP_OR)
620
bool KviKvsTreeNodeExpressionBinaryOperatorOr::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
624
if(!m_pLeft->evaluateReadOnly(c,&v1))return false;
625
//#warning "FIXME: We could use setNothing() as false: this would save memory allocations (and thus time)"
628
pBuffer->setBoolean(true);
631
if(!m_pRight->evaluateReadOnly(c,&v2))return false;
632
pBuffer->setBoolean(v2.asBoolean());
637
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorXor,"ExpressionBinaryOperatorXor","Expression Binary Operator \"^^\"",PREC_OP_XOR)
639
bool KviKvsTreeNodeExpressionBinaryOperatorXor::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
643
if(!m_pLeft->evaluateReadOnly(c,&v1))return false;
644
if(!m_pRight->evaluateReadOnly(c,&v2))return false;
645
//#warning "FIXME: We could use setNothing() as false: this would save memory allocations (and thus time)"
647
pBuffer->setBoolean(!v2.asBoolean());
650
pBuffer->setBoolean(!v1.asBoolean());
652
pBuffer->setBoolean(false);
657
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorLowerThan,"ExpressionBinaryOperatorLowerThan","Expression Binary Operator \"<\"",PREC_OP_LOWERTHAN)
659
bool KviKvsTreeNodeExpressionBinaryOperatorLowerThan::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
663
if(!m_pLeft->evaluateReadOnly(c,&v1))return false;
664
if(!m_pRight->evaluateReadOnly(c,&v2))return false;
665
pBuffer->setBoolean(v1.compare(&v2,true) > 0);
669
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorGreaterThan,"ExpressionBinaryOperatorGreaterThan","Expression Binary Operator \">\"",PREC_OP_GREATERTHAN)
671
bool KviKvsTreeNodeExpressionBinaryOperatorGreaterThan::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
675
if(!m_pLeft->evaluateReadOnly(c,&v1))return false;
676
if(!m_pRight->evaluateReadOnly(c,&v2))return false;
677
pBuffer->setBoolean(v1.compare(&v2,true) < 0);
681
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorLowerOrEqualTo,"ExpressionBinaryOperatorLowerOrEqualTo","Expression Binary Operator \"<=\"",PREC_OP_LOWEROREQUALTO)
683
bool KviKvsTreeNodeExpressionBinaryOperatorLowerOrEqualTo::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
687
if(!m_pLeft->evaluateReadOnly(c,&v1))return false;
688
if(!m_pRight->evaluateReadOnly(c,&v2))return false;
689
pBuffer->setBoolean(v1.compare(&v2,true) >= 0);
693
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorGreaterOrEqualTo,"ExpressionBinaryOperatorGreaterOrEqualTo","Expression Binary Operator \">=\"",PREC_OP_GREATEROREQUALTO)
695
bool KviKvsTreeNodeExpressionBinaryOperatorGreaterOrEqualTo::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
699
if(!m_pLeft->evaluateReadOnly(c,&v1))return false;
700
if(!m_pRight->evaluateReadOnly(c,&v2))return false;
701
pBuffer->setBoolean(v1.compare(&v2,true) <= 0);
705
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorEqualTo,"ExpressionBinaryOperatorEqualTo","Expression Binary Operator \"==\"",PREC_OP_EQUALTO)
707
bool KviKvsTreeNodeExpressionBinaryOperatorEqualTo::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
711
if(!m_pLeft->evaluateReadOnly(c,&v1))return false;
712
if(!m_pRight->evaluateReadOnly(c,&v2))return false;
713
pBuffer->setBoolean(v1.compare(&v2,true) == 0);
718
PREIMPLEMENT_BINARY_OPERATOR(KviKvsTreeNodeExpressionBinaryOperatorNotEqualTo,"ExpressionBinaryOperatorNotEqualTo","Expression Binary Operator \"!=\"",PREC_OP_NOTEQUALTO)
720
bool KviKvsTreeNodeExpressionBinaryOperatorNotEqualTo::evaluateReadOnly(KviKvsRunTimeContext * c,KviKvsVariant * pBuffer)
724
if(!m_pLeft->evaluateReadOnly(c,&v1))return false;
725
if(!m_pRight->evaluateReadOnly(c,&v2))return false;
726
pBuffer->setBoolean(v1.compare(&v2,true) != 0);