mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Clean up comments and variable names prior to merge.
FossilOrigin-Name: 6445519e91c4f98b4a9a45d5091d733c31497ebf0eb23a76edce3091f626035d
This commit is contained in:
40
src/expr.c
40
src/expr.c
@@ -1734,8 +1734,8 @@ int sqlite3SelectWalkFail(Walker *pWalker, Select *NotUsed){
|
||||
|
||||
/*
|
||||
** If the input expression is an ID with the name "true" or "false"
|
||||
** then convert it into an appropriate TK_TRUEFALSE term. Return true
|
||||
** if a conversion occurred, and false if the expression is unaltered.
|
||||
** then convert it into an TK_TRUEFALSE term. Return non-zero if
|
||||
** the conversion happened, and zero if the expression is unaltered.
|
||||
*/
|
||||
int sqlite3ExprIdToTrueFalse(Expr *pExpr){
|
||||
assert( pExpr->op==TK_ID || pExpr->op==TK_STRING );
|
||||
@@ -1749,10 +1749,10 @@ int sqlite3ExprIdToTrueFalse(Expr *pExpr){
|
||||
}
|
||||
|
||||
/*
|
||||
** The argument is one of a TK_TRUEFALSE term. Return 1 if it is TRUE
|
||||
** The argument must be a TK_TRUEFALSE Expr node. Return 1 if it is TRUE
|
||||
** and 0 if it is FALSE.
|
||||
*/
|
||||
int sqlite3ExprTruthOperand(const Expr *pExpr){
|
||||
int sqlite3ExprTruthValue(const Expr *pExpr){
|
||||
assert( pExpr->op==TK_TRUEFALSE );
|
||||
assert( sqlite3StrICmp(pExpr->u.zToken,"true")==0
|
||||
|| sqlite3StrICmp(pExpr->u.zToken,"false")==0 );
|
||||
@@ -3578,7 +3578,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||
return target;
|
||||
}
|
||||
case TK_TRUEFALSE: {
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, sqlite3ExprTruthOperand(pExpr), target);
|
||||
sqlite3VdbeAddOp2(v, OP_Integer, sqlite3ExprTruthValue(pExpr), target);
|
||||
return target;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||
@@ -3737,12 +3737,15 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||
break;
|
||||
}
|
||||
case TK_TRUTH: {
|
||||
int isTrue;
|
||||
int isTrue; /* IS TRUE or IS NOT TRUE */
|
||||
int bNormal; /* IS TRUE or IS FALSE */
|
||||
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
|
||||
testcase( regFree1==0 );
|
||||
isTrue = sqlite3ExprTruthOperand(pExpr->pRight);
|
||||
sqlite3VdbeAddOp4Int(v, OP_IsTrue, r1, inReg, !isTrue,
|
||||
isTrue ^ (pExpr->op2==TK_IS));
|
||||
isTrue = sqlite3ExprTruthValue(pExpr->pRight);
|
||||
bNormal = pExpr->op2==TK_IS;
|
||||
testcase( isTrue && bNormal);
|
||||
testcase( !isTrue && bNormal);
|
||||
sqlite3VdbeAddOp4Int(v, OP_IsTrue, r1, inReg, !isTrue, isTrue ^ bNormal);
|
||||
break;
|
||||
}
|
||||
case TK_ISNULL:
|
||||
@@ -4521,13 +4524,13 @@ void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
|
||||
break;
|
||||
}
|
||||
case TK_TRUTH: {
|
||||
int isNot;
|
||||
int isTrue;
|
||||
int isNot; /* IS NOT TRUE or IS NOT FALSE */
|
||||
int isTrue; /* IS TRUE or IS NOT TRUE */
|
||||
testcase( jumpIfNull==0 );
|
||||
isNot = pExpr->op2==TK_ISNOT;
|
||||
isTrue = sqlite3ExprTruthOperand(pExpr->pRight);
|
||||
isTrue = sqlite3ExprTruthValue(pExpr->pRight);
|
||||
testcase( isTrue && isNot );
|
||||
testcase( isTrue && !isNot );
|
||||
testcase( !isTrue && isNot );
|
||||
if( isTrue ^ isNot ){
|
||||
sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest,
|
||||
isNot ? SQLITE_JUMPIFNULL : 0);
|
||||
@@ -4692,14 +4695,13 @@ void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
|
||||
break;
|
||||
}
|
||||
case TK_TRUTH: {
|
||||
int isNot;
|
||||
int isTrue;
|
||||
int isNot; /* IS NOT TRUE or IS NOT FALSE */
|
||||
int isTrue; /* IS TRUE or IS NOT TRUE */
|
||||
testcase( jumpIfNull==0 );
|
||||
assert( pExpr->op2==TK_IS || pExpr->op2==TK_ISNOT );
|
||||
isNot = pExpr->op2==TK_ISNOT;
|
||||
isTrue = sqlite3ExprTruthOperand(pExpr->pRight);
|
||||
isTrue = sqlite3ExprTruthValue(pExpr->pRight);
|
||||
testcase( isTrue && isNot );
|
||||
testcase( isTrue && !isNot );
|
||||
testcase( !isTrue && isNot );
|
||||
if( isTrue ^ isNot ){
|
||||
/* IS TRUE and IS NOT FALSE */
|
||||
sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest,
|
||||
@@ -4708,7 +4710,7 @@ void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
|
||||
}else{
|
||||
/* IS FALSE and IS NOT TRUE */
|
||||
sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest,
|
||||
isNot ? 0: SQLITE_JUMPIFNULL);
|
||||
isNot ? 0 : SQLITE_JUMPIFNULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ ccons ::= DEFAULT MINUS(A) term(X) scanpt(Z). {
|
||||
ccons ::= DEFAULT scanpt id(X). {
|
||||
Expr *p = tokenExpr(pParse, TK_STRING, X);
|
||||
sqlite3ExprIdToTrueFalse(p);
|
||||
testcase( p->op==TK_TRUEFALSE && sqlite3ExprTruthOperand(p) );
|
||||
testcase( p->op==TK_TRUEFALSE && sqlite3ExprTruthValue(p) );
|
||||
sqlite3AddDefaultValue(pParse,p,X.z,X.z+X.n);
|
||||
}
|
||||
|
||||
|
||||
@@ -3840,7 +3840,7 @@ void sqlite3Savepoint(Parse*, int, Token*);
|
||||
void sqlite3CloseSavepoints(sqlite3 *);
|
||||
void sqlite3LeaveMutexAndCloseZombie(sqlite3*);
|
||||
int sqlite3ExprIdToTrueFalse(Expr*);
|
||||
int sqlite3ExprTruthOperand(const Expr*);
|
||||
int sqlite3ExprTruthValue(const Expr*);
|
||||
int sqlite3ExprIsConstant(Expr*);
|
||||
int sqlite3ExprIsConstantNotJoin(Expr*);
|
||||
int sqlite3ExprIsConstantOrFunction(Expr*, u8);
|
||||
|
||||
@@ -294,7 +294,7 @@ void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){
|
||||
}
|
||||
case TK_TRUEFALSE: {
|
||||
sqlite3TreeViewLine(pView,
|
||||
sqlite3ExprTruthOperand(pExpr) ? "TRUE" : "FALSE");
|
||||
sqlite3ExprTruthValue(pExpr) ? "TRUE" : "FALSE");
|
||||
break;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_BLOB_LITERAL
|
||||
@@ -361,7 +361,7 @@ void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){
|
||||
assert( pExpr->op2==TK_IS || pExpr->op2==TK_ISNOT );
|
||||
assert( pExpr->pRight );
|
||||
assert( pExpr->pRight->op==TK_TRUEFALSE );
|
||||
x = (pExpr->op2==TK_ISNOT)*2 + sqlite3ExprTruthOperand(pExpr->pRight);
|
||||
x = (pExpr->op2==TK_ISNOT)*2 + sqlite3ExprTruthValue(pExpr->pRight);
|
||||
zUniOp = azOp[x];
|
||||
break;
|
||||
}
|
||||
|
||||
11
src/vdbe.c
11
src/vdbe.c
@@ -2197,7 +2197,7 @@ case OP_Or: { /* same as TK_OR, in1, in2, out3 */
|
||||
** This opcode implements the IS TRUE, IS FALSE, IS NOT TRUE, and
|
||||
** IS NOT FALSE operators.
|
||||
**
|
||||
** Interpret the value in register P1 as a boolean value. Store the that
|
||||
** Interpret the value in register P1 as a boolean value. Store that
|
||||
** boolean (a 0 or 1) in register P2. Or if the value in register P1 is
|
||||
** NULL, then the P3 is stored in register P2. Invert the answer if P4
|
||||
** is 1.
|
||||
@@ -2205,15 +2205,16 @@ case OP_Or: { /* same as TK_OR, in1, in2, out3 */
|
||||
** The logic is summarized like this:
|
||||
**
|
||||
** <ul>
|
||||
** <li> P3==0, P4==0 → r[P2] = r[P1] IS TRUE
|
||||
** <li> P3==1, P4==1 → r[P2] = r[P1] IS FALSE
|
||||
** <li> P3==0, P4==1 → r[P2] = r[P1] IS NOT TRUE
|
||||
** <li> P3==1, P4==0 → r[P2] = r[P1] IS NOT FALSE
|
||||
** <li> If P3==0 and P4==0 then r[P2] := r[P1] IS TRUE
|
||||
** <li> If P3==1 and P4==1 then r[P2] := r[P1] IS FALSE
|
||||
** <li> If P3==0 and P4==1 then r[P2] := r[P1] IS NOT TRUE
|
||||
** <li> If P3==1 and P4==0 then r[P2] := r[P1] IS NOT FALSE
|
||||
** </ul>
|
||||
*/
|
||||
case OP_IsTrue: { /* in1, out2 */
|
||||
assert( pOp->p4type==P4_INT32 );
|
||||
assert( pOp->p4.i==0 || pOp->p4.i==1 );
|
||||
assert( pOp->p3==0 || pOp->p3==1 );
|
||||
sqlite3VdbeMemSetInt64(&aMem[pOp->p2],
|
||||
sqlite3VdbeBooleanValue(&aMem[pOp->p1], pOp->p3) ^ pOp->p4.i);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user