1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-08 03:22:21 +03:00

More use of sqlite3NestedParse. This version of the code does not work. (CVS 2060)

FossilOrigin-Name: ac2d5a605c873cac68bfde4bbe3797608a47b21e
This commit is contained in:
drh
2004-11-05 05:10:28 +00:00
parent f197484617
commit 4e0cff6080
9 changed files with 78 additions and 73 deletions

View File

@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.167 2004/10/31 02:22:49 drh Exp $
** $Id: expr.c,v 1.168 2004/11/05 05:10:29 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -198,6 +198,34 @@ Expr *sqlite3Expr(int op, Expr *pLeft, Expr *pRight, Token *pToken){
return pNew;
}
/*
** When doing a nested parse, you can include terms in an expression
** that look like this: #0 #1 #2 ... These terms refer to elements
** on the stack. "#0" (or just "#") means the top of the stack.
** "#1" means the next down on the stack. And so forth.
**
** This routine is called by the parser to deal with on of those terms.
** It immediately generates code to store the value in a memory location.
** The returns an expression that will code to extract the value from
** that memory location as needed.
*/
Expr *sqlite3RegisterExpr(Parse *pParse, Token *pToken){
Vdbe *v = pParse->pVdbe;
Expr *p;
int depth;
if( v==0 ) return 0;
if( pParse->nested==0 ){
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", pToken);
return 0;
}
p = sqlite3Expr(TK_REGISTER, 0, 0, pToken);
depth = atoi(&pToken->z[1]);
p->iTable = pParse->nMem++;
sqlite3VdbeAddOp(v, OP_Dup, depth, 0);
sqlite3VdbeAddOp(v, OP_MemStore, p->iTable, 1);
return p;
}
/*
** Join two expressions using an AND operator. If either expression is
** NULL, then just return the other expression.
@@ -1239,6 +1267,10 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
}
break;
}
case TK_REGISTER: {
sqlite3VdbeAddOp(v, OP_MemLoad, pExpr->iTable, 0);
break;
}
case TK_LT:
case TK_LE:
case TK_GT: