aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2004-11-05 05:10:28 +0000
committerdrh <drh@noemail.net>2004-11-05 05:10:28 +0000
commit4e0cff6080890479afb9e418f6edebf45be35e36 (patch)
treede43ca47520c4f4802a279c2744ac091def2d5a2 /src/expr.c
parentf19748461779835a1fcc0626b95d66972278139b (diff)
downloadsqlite-4e0cff6080890479afb9e418f6edebf45be35e36.tar.gz
sqlite-4e0cff6080890479afb9e418f6edebf45be35e36.zip
More use of sqlite3NestedParse. This version of the code does not work. (CVS 2060)
FossilOrigin-Name: ac2d5a605c873cac68bfde4bbe3797608a47b21e
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/expr.c b/src/expr.c
index daf7dc492..8eec92c64 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -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>
@@ -199,6 +199,34 @@ Expr *sqlite3Expr(int op, Expr *pLeft, Expr *pRight, Token *pToken){
}
/*
+** 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: