]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Register-ify the OP_AddImm and all casting opcodes. Omit the
authordrh <drh@noemail.net>
Sat, 5 Jan 2008 05:20:10 +0000 (05:20 +0000)
committerdrh <drh@noemail.net>
Sat, 5 Jan 2008 05:20:10 +0000 (05:20 +0000)
OP_MemIncr opcode. (CVS 4683)

FossilOrigin-Name: 3e8a07dd3cc9921ad39e379576abb0b485a42202

12 files changed:
manifest
manifest.uuid
src/analyze.c
src/build.c
src/delete.c
src/expr.c
src/insert.c
src/pragma.c
src/select.c
src/update.c
src/vdbe.c
src/vdbeaux.c

index 216763e303988c7ebaf5b31983e861ef40e0c706..a6dd62160059e5b63abecc68a41baed7a25567ff 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Get\srid\sof\sOP_Dup,\sOP_MemStore,\sOP_MemLoad,\sand\sOP_MemMove.\s\sReplace\nwith\sOP_Copy,\sOP_SCopy,\sand\sOP_Move.\s\sAdd\sthe\sinfrastructure\sfor\noperation\sproperties\sin1,\sin2,\sin3,\sout2,\sand\sout3\sbut\sdo\snot\syet\nuse\sany\sof\sthese.\s(CVS\s4682)
-D 2008-01-05T04:06:04
+C Register-ify\sthe\sOP_AddImm\sand\sall\scasting\sopcodes.\s\sOmit\sthe\nOP_MemIncr\sopcode.\s(CVS\s4683)
+D 2008-01-05T05:20:10
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in 30789bf70614bad659351660d76b8e533f3340e9
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -79,24 +79,24 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
 F sqlite3.def a96c1d0d39362b763d2ddba220a32da41a15c4b4
 F sqlite3.pc.in abed4664817e1cd500f2276142c71958087c16bc
 F src/alter.c 5a54f58d9481ac14c4e58b702f3f8758dee84d04
-F src/analyze.c 4e24deeee2b93e91a2197953515fa175bfab27f2
+F src/analyze.c d80f65d2a02c69ac72a00c6aeb91513a26a9aca3
 F src/attach.c 1c96631e56cdc51d3d70736bf61f1fe01c62cbea
 F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
 F src/btmutex.c 5d39da37c9d1282f3c6f9967afae6a34ee36b7ff
 F src/btree.c 5164b32950cfd41f2c5c31e8ff82c4a499918aef
 F src/btree.h 19dcf5ad23c17b98855da548e9a8e3eb4429d5eb
 F src/btreeInt.h 1c5a9da165718ef7de81e35ce9ab5d9ba9283f76
-F src/build.c 739eeee868e97a69c27e72636ca5be824da87703
+F src/build.c 60a3ec74b45634654e06a72224ac01bd33ac69f1
 F src/callback.c 77b302b0d41468dcda78c70e706e5b84577f0fa0
 F src/complete.c 4cf68fd75d60257524cbe74f87351b9848399131
 F src/date.c 49c5a6d2de6c12000905b4d36868b07d3011bbf6
-F src/delete.c f943c27bf37f2f37d7e16dc4e94421870ce68c6c
+F src/delete.c cb1d5be17c99e41d1675763a57848bb5dd45191c
 F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
-F src/expr.c d317c8081a05eaa5720a10e0067dfa0864f762db
+F src/expr.c 743e8f1da26816cf0767fb7cfb442a2d8996154d
 F src/func.c 996071cf0af9d967e58b69fce1909555059ebc7d
 F src/hash.c 45a7005aac044b6c86bd7e49c44bc15d30006d6c
 F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
-F src/insert.c fb46be04638fca9b319a216e83e2bb57e8621fcc
+F src/insert.c 7082993775c4c17edbb6cb8a042d5e399c721a54
 F src/journal.c 807bed7a158979ac8d63953e1774e8d85bff65e2
 F src/legacy.c 4ac53191fad2e3c4d59bde1228879b2dc5a96d66
 F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
@@ -127,11 +127,11 @@ F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
 F src/pager.c 0cb6ccea4b9615627d61d7c4417cedc45776d429
 F src/pager.h f504f7ae84060fee0416a853e368d3d113c3d6fa
 F src/parse.y 2ae06e8d3190faace49c5b82e7cea1fc60d084a1
-F src/pragma.c 6f5918141e1a100975666d88a4bd3c6cd6da4f3d
+F src/pragma.c 1627b350b4d3b807f36185bfe7aab34be4a6e40c
 F src/prepare.c f1bb8eb642082e618a359c08e3e107490eafe0e3
 F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910
 F src/random.c 4a22746501bf36b0a088c66e38dde5daba6a35da
-F src/select.c 1a6664131fb0e250826fd26189b0e615d726fbcd
+F src/select.c 102eb03b6daa3c113fac32019dd281f01a38baa8
 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
 F src/shell.c 5391e889384d2062249f668110d64ed16f601c4b
 F src/sqlite.h.in 2a7e3776534bbe6ff2cdc058f3abebe91e7e429f
@@ -164,15 +164,15 @@ F src/test_tclvar.c b2d1115e4d489179d3f029e765211b2ad527ba59
 F src/test_thread.c e297dd41db0b249646e69f97d36ec13e56e8b730
 F src/tokenize.c a4e04438c11fed2c67ec47fe3edbef9cca2d1b48
 F src/trigger.c 91ff1552b5c2cd66a077563a026d183c1dc993d6
-F src/update.c 3dc744343c81c7ed97d9e1ed5e5887e256921062
+F src/update.c ac6cdfebf88340fd68550b1d7fd6a15ad7144fd8
 F src/utf.c ef4b7d83bae533b76c3e1bf635b113fdad86a736
 F src/util.c 05f31144bbd3f1a24f4139ae029c42545cb72624
 F src/vacuum.c 3f34f278809bf3eb0b62ec46ff779e9c385b28f0
-F src/vdbe.c 8a2d438d47e38542ca4ee519528ea859cee9ecfa
+F src/vdbe.c f8aabf9ae1e013ae837e2620d39533189396fa58
 F src/vdbe.h bb128757b84280504a1243c450fd13ead248ede5
 F src/vdbeInt.h 31bd686595356284d5484592e2dc6e58025aa346
 F src/vdbeapi.c f14174843bf4be2c9afdf2ef48b61e7c3ac62d7c
-F src/vdbeaux.c ae45ffeee9f503e2cce2f1db51893934e7c669a5
+F src/vdbeaux.c b5437d3afb5552675603ed73058b3a7184dc81df
 F src/vdbeblob.c b90f7494c408d47ce6835000b01e40b371e27baf
 F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
 F src/vdbemem.c 123994fcd344993d2fb050a83b91b341bbbd08b4
@@ -603,7 +603,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P fe057a88d0038ac349ea41883b979ceba6ae410a
-R 42deacb2e7b246f14ca2d74e7526fed1
+P cc149eb9ca3c672cc6fea3528353234ac2ed5745
+R 9381db31828d60007b12e8ca022919a2
 U drh
-Z b60a5382e66d036aa3cd3e890b046e32
+Z 6bb8ea814574f175721b7ff6434341e5
index 57dc5a4c21d5a2cb7414aaf38abc4f146a6ab818..265f768825d21ac2a1ce1a42fd182e21938e280a 100644 (file)
@@ -1 +1 @@
-cc149eb9ca3c672cc6fea3528353234ac2ed5745
\ No newline at end of file
+3e8a07dd3cc9921ad39e379576abb0b485a42202
\ No newline at end of file
index c44e300606c7e9e431512920dc157432eb588834..54d985510dd4401c75930d68ee8926a264dd33cc 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file contains code associated with the ANALYZE command.
 **
-** @(#) $Id: analyze.c,v 1.32 2008/01/05 04:06:04 drh Exp $
+** @(#) $Id: analyze.c,v 1.33 2008/01/05 05:20:10 drh Exp $
 */
 #ifndef SQLITE_OMIT_ANALYZE
 #include "sqliteInt.h"
@@ -155,7 +155,7 @@ static void analyzeOneTable(
     endOfLoop = sqlite3VdbeMakeLabel(v);
     sqlite3VdbeAddOp2(v, OP_Rewind, iIdxCur, endOfLoop);
     topOfLoop = sqlite3VdbeCurrentAddr(v);
-    sqlite3VdbeAddOp2(v, OP_MemIncr, 1, iMem);
+    sqlite3VdbeAddOp2(v, OP_AddImm, iMem, 1);
     for(i=0; i<nCol; i++){
       sqlite3VdbeAddOp2(v, OP_Column, iIdxCur, i);
       sqlite3VdbeAddOp1(v, OP_SCopy, iMem+nCol+i+1);
@@ -163,7 +163,7 @@ static void analyzeOneTable(
     }
     sqlite3VdbeAddOp2(v, OP_Goto, 0, endOfLoop);
     for(i=0; i<nCol; i++){
-      addr = sqlite3VdbeAddOp2(v, OP_MemIncr, 1, iMem+i+1);
+      addr = sqlite3VdbeAddOp2(v, OP_AddImm, iMem+i+1, 1);
       sqlite3VdbeChangeP2(v, topOfLoop + 3*i + 3, addr);
       sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, iMem+nCol+i+1);
     }
@@ -200,7 +200,7 @@ static void analyzeOneTable(
       sqlite3VdbeAddOp1(v, OP_SCopy, iMem);
       sqlite3VdbeAddOp1(v, OP_SCopy, iMem+i+1);
       sqlite3VdbeAddOp0(v, OP_Add);
-      sqlite3VdbeAddOp1(v, OP_AddImm, -1);
+      sqlite3VdbeAddOp2(v, OP_AddImm, 0, -1);
       sqlite3VdbeAddOp1(v, OP_SCopy, iMem+i+1);
       sqlite3VdbeAddOp0(v, OP_Divide);
       sqlite3VdbeAddOp0(v, OP_ToInt);
index ab134d6a4321ff227df3b5a4a3f4b4bcdc302ef4..177c1e80563bd2042d1d8d2ba43616f65df2261f 100644 (file)
@@ -22,7 +22,7 @@
 **     COMMIT
 **     ROLLBACK
 **
-** $Id: build.c,v 1.458 2008/01/05 04:06:04 drh Exp $
+** $Id: build.c,v 1.459 2008/01/05 05:20:10 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -2252,7 +2252,7 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
     int addr2 = curaddr+4;
     sqlite3VdbeChangeP2(v, curaddr-1, addr2);
     sqlite3VdbeAddOp1(v, OP_Rowid, iTab);
-    sqlite3VdbeAddOp1(v, OP_AddImm, 1);
+    sqlite3VdbeAddOp2(v, OP_AddImm, 0, 1);
     sqlite3VdbeAddOp2(v, OP_IsUnique, iIdx, addr2);
     sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, OE_Abort, 0,
                     "indexed columns are not unique", P4_STATIC);
index 6ce8ad8f5ceca0aded0a9390bfe445237d7d1958..3fce44414488d21e6ed13f1555b21a839d94b317 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** in order to generate code for DELETE FROM statements.
 **
-** $Id: delete.c,v 1.149 2008/01/05 04:06:04 drh Exp $
+** $Id: delete.c,v 1.150 2008/01/05 05:20:10 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -290,7 +290,7 @@ void sqlite3DeleteFrom(
         sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead);
       }
       sqlite3VdbeAddOp2(v, OP_Rewind, iCur, sqlite3VdbeCurrentAddr(v)+2);
-      addr2 = sqlite3VdbeAddOp2(v, OP_MemIncr, 1, memCnt);
+      addr2 = sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
       sqlite3VdbeAddOp2(v, OP_Next, iCur, addr2);
       sqlite3VdbeAddOp1(v, OP_Close, iCur);
     }
@@ -321,7 +321,7 @@ void sqlite3DeleteFrom(
     sqlite3VdbeAddOp2(v, IsVirtual(pTab) ? OP_VRowid : OP_Rowid, iCur, iRowid);
     sqlite3VdbeAddOp1(v, OP_FifoWrite, iRowid);
     if( db->flags & SQLITE_CountRows ){
-      sqlite3VdbeAddOp2(v, OP_MemIncr, 1, memCnt);
+      sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
     }
 
     /* End the database scan loop.
index 2586885e0842ca364e2f5521a4267d90dab9f569..b5dd63909b23c06eb9dff39e0463759fad6af6bd 100644 (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.331 2008/01/05 04:06:04 drh Exp $
+** $Id: expr.c,v 1.332 2008/01/05 05:20:10 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -2127,7 +2127,7 @@ int sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){
       sqlite3ExprCode(pParse, pExpr->pLeft, 0);
       dest = sqlite3VdbeCurrentAddr(v) + 2;
       sqlite3VdbeAddOp2(v, op, 1, dest);
-      sqlite3VdbeAddOp1(v, OP_AddImm, -1);
+      sqlite3VdbeAddOp2(v, OP_AddImm, 0, -1);
       stackChng = 0;
       break;
     }
@@ -2242,7 +2242,7 @@ int sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){
                              &affinity, 1);   /* addr + 4 */
         sqlite3VdbeAddOp2(v, OP_Found, pExpr->iTable, iLabel);
       }
-      sqlite3VdbeAddOp1(v, OP_AddImm, -1);                     /* addr + 6 */
+      sqlite3VdbeAddOp2(v, OP_AddImm, 0, -1);                  /* addr + 6 */
       sqlite3VdbeResolveLabel(v, iLabel);
 
       break;
index 9762ab7394311c7f199f6eb6227a3c0de4b0a6e5..54e18dc2207ed9055c6fbb51b1564ff4eacd464d 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle INSERT statements in SQLite.
 **
-** $Id: insert.c,v 1.212 2008/01/05 04:06:04 drh Exp $
+** $Id: insert.c,v 1.213 2008/01/05 05:20:10 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -822,7 +822,7 @@ void sqlite3Insert(
   /* Update the count of rows that are inserted
   */
   if( (db->flags & SQLITE_CountRows)!=0 ){
-    sqlite3VdbeAddOp2(v, OP_MemIncr, 1, iCntMem);
+    sqlite3VdbeAddOp2(v, OP_AddImm, iCntMem, 1);
   }
 
   if( triggers_exist ){
index a63459f4289ffe1bf8071b4519d2fd3abab69db8..ec4a0f80f593d07131adac39fc2219f41fc5b3f5 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file contains code used to implement the PRAGMA command.
 **
-** $Id: pragma.c,v 1.159 2008/01/05 04:06:04 drh Exp $
+** $Id: pragma.c,v 1.160 2008/01/05 05:20:10 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -495,7 +495,7 @@ void sqlite3Pragma(
     sqlite3VdbeAddOp2(v, OP_Integer, iLimit, 1);
     addr = sqlite3VdbeAddOp2(v, OP_IncrVacuum, iDb, 0);
     sqlite3VdbeAddOp2(v, OP_Callback, 0, 0);
-    sqlite3VdbeAddOp2(v, OP_MemIncr, -1, 1);
+    sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);
     sqlite3VdbeAddOp2(v, OP_IfMemPos, 1, addr);
     sqlite3VdbeJumpHere(v, addr);
   }else
@@ -905,11 +905,11 @@ void sqlite3Pragma(
         sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead);
         sqlite3VdbeAddOp2(v, OP_Integer, 0, 2);
         loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0);
-        sqlite3VdbeAddOp2(v, OP_MemIncr, 1, 2);
+        sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1);
         for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
           int jmp2;
           static const VdbeOpList idxErr[] = {
-            { OP_MemIncr,    -1,  1,  0},
+            { OP_AddImm,      1, -1,  0},
             { OP_String8,     0,  0,  0},    /* 1 */
             { OP_Rowid,       1,  0,  0},
             { OP_String8,     0,  0,  0},    /* 3 */
@@ -931,12 +931,12 @@ void sqlite3Pragma(
           static const VdbeOpList cntIdx[] = {
              { OP_Integer,      0,  3,  0},
              { OP_Rewind,       0,  0,  0},  /* 1 */
-             { OP_MemIncr,      1,  3,  0},
+             { OP_AddImm,       3,  1,  0},
              { OP_Next,         0,  0,  0},  /* 3 */
              { OP_SCopy,        2,  0,  0},
              { OP_SCopy,        3,  0,  0},
              { OP_Eq,           0,  0,  0},  /* 6 */
-             { OP_MemIncr,     -1,  1,  0},
+             { OP_AddImm,       1, -1,  0},
              { OP_String8,      0,  0,  0},  /* 8 */
              { OP_String8,      0,  0,  0},  /* 9 */
              { OP_Concat,       0,  0,  0},
index dd768646bf8e46d98065000a5269d75f345020d2..4ccaf79799fecdec9c60f1e72f2bdda9be7d5b49 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements in SQLite.
 **
-** $Id: select.c,v 1.385 2008/01/05 04:06:04 drh Exp $
+** $Id: select.c,v 1.386 2008/01/05 05:20:10 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -395,7 +395,7 @@ static void pushOntoSorter(
   if( pSelect->iLimit>=0 ){
     int addr1, addr2;
     addr1 = sqlite3VdbeAddOp2(v, OP_IfMemZero, pSelect->iLimit+1, 0);
-    sqlite3VdbeAddOp2(v, OP_MemIncr, -1, pSelect->iLimit+1);
+    sqlite3VdbeAddOp2(v, OP_AddImm, pSelect->iLimit+1, -1);
     addr2 = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0);
     sqlite3VdbeJumpHere(v, addr1);
     sqlite3VdbeAddOp2(v, OP_Last, pOrderBy->iECursor, 0);
@@ -416,7 +416,7 @@ static void codeOffset(
 ){
   if( p->iOffset>=0 && iContinue!=0 ){
     int addr;
-    sqlite3VdbeAddOp2(v, OP_MemIncr, -1, p->iOffset);
+    sqlite3VdbeAddOp2(v, OP_AddImm, p->iOffset, -1);
     addr = sqlite3VdbeAddOp2(v, OP_IfMemNeg, p->iOffset, 0);
     if( nPop>0 ){
       sqlite3VdbeAddOp2(v, OP_Pop, nPop, 0);
@@ -703,7 +703,7 @@ static int selectInnerLoop(
   /* Jump to the end of the loop if the LIMIT is reached.
   */
   if( p->iLimit>=0 && pOrderBy==0 ){
-    sqlite3VdbeAddOp2(v, OP_MemIncr, -1, p->iLimit);
+    sqlite3VdbeAddOp2(v, OP_AddImm, p->iLimit, -1);
     sqlite3VdbeAddOp2(v, OP_IfMemZero, p->iLimit, iBreak);
   }
   return 0;
@@ -834,7 +834,7 @@ static void generateSortTail(
   /* Jump to the end of the loop when the LIMIT is reached
   */
   if( p->iLimit>=0 ){
-    sqlite3VdbeAddOp2(v, OP_MemIncr, -1, p->iLimit);
+    sqlite3VdbeAddOp2(v, OP_AddImm, p->iLimit, -1);
     sqlite3VdbeAddOp2(v, OP_IfMemZero, p->iLimit, brk);
   }
 
index 467352cdf40c2a0c54bd98348ebed9e0aef713a4..0966802d18551230f5d260c223554954bf3aa44d 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle UPDATE statements.
 **
-** $Id: update.c,v 1.159 2008/01/05 04:06:04 drh Exp $
+** $Id: update.c,v 1.160 2008/01/05 05:20:10 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -506,7 +506,7 @@ void sqlite3Update(
   /* Increment the row counter 
   */
   if( db->flags & SQLITE_CountRows && !pParse->trigStack){
-    sqlite3VdbeAddOp2(v, OP_MemIncr, 1, memCnt);
+    sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
   }
 
   /* If there are triggers, close all the cursors after each iteration
index 558b75bfddde8cc8bff51dd4136bbe7ed576ffa4..d5177df191dc11f02dd26176a5409ef6667d034e 100644 (file)
@@ -43,7 +43,7 @@
 ** in this file for details.  If in doubt, do not deviate from existing
 ** commenting and indentation practices when changing or adding code.
 **
-** $Id: vdbe.c,v 1.680 2008/01/05 04:06:04 drh Exp $
+** $Id: vdbe.c,v 1.681 2008/01/05 05:20:10 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1600,17 +1600,17 @@ case OP_ShiftRight: {           /* same as TK_RSHIFT, no-push */
   break;
 }
 
-/* Opcode: AddImm  P1 * *
+/* Opcode: AddImm  P1 P2 * * *
 ** 
-** Add the value P1 to whatever is on top of the stack.  The result
-** is always an integer.
+** Add P2 the value in register P1.
+** The result is always an integer.
 **
-** To force the top of the stack to be an integer, just add 0.
+** To force any register to be an integer, just add 0.
 */
-case OP_AddImm: {            /* no-push */
-  assert( pTos>=p->aStack );
-  sqlite3VdbeMemIntegerify(pTos);
-  pTos->u.i += pOp->p1;
+case OP_AddImm: {            /* no-push, in1 */
+  nPop = 0;
+  sqlite3VdbeMemIntegerify(pIn1);
+  pIn1->u.i += pOp->p2;
   break;
 }
 
@@ -1683,7 +1683,7 @@ case OP_MustBeInt: {            /* no-push, jump */
   break;
 }
 
-/* Opcode: RealAffinity P1 * *
+/* Opcode: RealAffinity P1 * * * *
 **
 ** If register P1 holds an integer convert it to a real value.
 **
@@ -1692,67 +1692,60 @@ case OP_MustBeInt: {            /* no-push, jump */
 ** integers, for space efficiency, but after extraction we want them
 ** to have only a real value.
 */
-case OP_RealAffinity: {                  /* no-push */
-  assert( pOp->p1>=0 && pOp->p1<=p->nMem );
-  if( pOp->p1==0 ){
-    if( pTos->flags & MEM_Int ){
-      sqlite3VdbeMemRealify(pTos);
-    }
-  }else{
-    Mem *pX = &p->aMem[pOp->p1];
-    if( pX->flags & MEM_Int ){
-      sqlite3VdbeMemRealify(pX);
-    }
+case OP_RealAffinity: {                  /* no-push, in1 */
+  nPop = 0;
+  if( pIn1->flags & MEM_Int ){
+    sqlite3VdbeMemRealify(pIn1);
   }
   break;
 }
 
 #ifndef SQLITE_OMIT_CAST
-/* Opcode: ToText * * *
+/* Opcode: ToText P1 * * * *
 **
-** Force the value on the top of the stack to be text.
+** Force the value in register P1 to be text.
 ** If the value is numeric, convert it to a string using the
 ** equivalent of printf().  Blob values are unchanged and
 ** are afterwards simply interpreted as text.
 **
 ** A NULL value is not changed by this routine.  It remains NULL.
 */
-case OP_ToText: {                  /* same as TK_TO_TEXT, no-push */
-  assert( pTos>=p->aStack );
-  if( pTos->flags & MEM_Null ) break;
+case OP_ToText: {                  /* same as TK_TO_TEXT, no-push, in1 */
+  nPop = 0;
+  if( pIn1->flags & MEM_Null ) break;
   assert( MEM_Str==(MEM_Blob>>3) );
-  pTos->flags |= (pTos->flags&MEM_Blob)>>3;
-  applyAffinity(pTos, SQLITE_AFF_TEXT, encoding);
-  rc = ExpandBlob(pTos);
-  assert( pTos->flags & MEM_Str );
-  pTos->flags &= ~(MEM_Int|MEM_Real|MEM_Blob);
+  pIn1->flags |= (pIn1->flags&MEM_Blob)>>3;
+  applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding);
+  rc = ExpandBlob(pIn1);
+  assert( pIn1->flags & MEM_Str );
+  pIn1->flags &= ~(MEM_Int|MEM_Real|MEM_Blob);
   break;
 }
 
-/* Opcode: ToBlob * * *
+/* Opcode: ToBlob P1 * * * *
 **
-** Force the value on the top of the stack to be a BLOB.
+** Force the value in register P1 to be a BLOB.
 ** If the value is numeric, convert it to a string first.
 ** Strings are simply reinterpreted as blobs with no change
 ** to the underlying data.
 **
 ** A NULL value is not changed by this routine.  It remains NULL.
 */
-case OP_ToBlob: {                  /* same as TK_TO_BLOB, no-push */
-  assert( pTos>=p->aStack );
-  if( pTos->flags & MEM_Null ) break;
-  if( (pTos->flags & MEM_Blob)==0 ){
-    applyAffinity(pTos, SQLITE_AFF_TEXT, encoding);
-    assert( pTos->flags & MEM_Str );
-    pTos->flags |= MEM_Blob;
+case OP_ToBlob: {                  /* same as TK_TO_BLOB, no-push, in1 */
+  nPop = 0;
+  if( pIn1->flags & MEM_Null ) break;
+  if( (pIn1->flags & MEM_Blob)==0 ){
+    applyAffinity(pIn1, SQLITE_AFF_TEXT, encoding);
+    assert( pIn1->flags & MEM_Str );
+    pIn1->flags |= MEM_Blob;
   }
-  pTos->flags &= ~(MEM_Int|MEM_Real|MEM_Str);
+  pIn1->flags &= ~(MEM_Int|MEM_Real|MEM_Str);
   break;
 }
 
-/* Opcode: ToNumeric * * *
+/* Opcode: ToNumeric P1 * * * *
 **
-** Force the value on the top of the stack to be numeric (either an
+** Force the value in register P1 to be numeric (either an
 ** integer or a floating-point number.)
 ** If the value is text or blob, try to convert it to an using the
 ** equivalent of atoi() or atof() and store 0 if no such conversion 
@@ -1760,46 +1753,46 @@ case OP_ToBlob: {                  /* same as TK_TO_BLOB, no-push */
 **
 ** A NULL value is not changed by this routine.  It remains NULL.
 */
-case OP_ToNumeric: {                  /* same as TK_TO_NUMERIC, no-push */
-  assert( pTos>=p->aStack );
-  if( (pTos->flags & (MEM_Null|MEM_Int|MEM_Real))==0 ){
-    sqlite3VdbeMemNumerify(pTos);
+case OP_ToNumeric: {                  /* same as TK_TO_NUMERIC, no-push, in1 */
+  nPop = 0;
+  if( (pIn1->flags & (MEM_Null|MEM_Int|MEM_Real))==0 ){
+    sqlite3VdbeMemNumerify(pIn1);
   }
   break;
 }
 #endif /* SQLITE_OMIT_CAST */
 
-/* Opcode: ToInt * * *
+/* Opcode: ToInt P1 * * * *
 **
-** Force the value on the top of the stack to be an integer.  If
+** Force the value in register P1 be an integer.  If
 ** The value is currently a real number, drop its fractional part.
 ** If the value is text or blob, try to convert it to an integer using the
 ** equivalent of atoi() and store 0 if no such conversion is possible.
 **
 ** A NULL value is not changed by this routine.  It remains NULL.
 */
-case OP_ToInt: {                  /* same as TK_TO_INT, no-push */
-  assert( pTos>=p->aStack );
-  if( (pTos->flags & MEM_Null)==0 ){
-    sqlite3VdbeMemIntegerify(pTos);
+case OP_ToInt: {                  /* same as TK_TO_INT, no-push, in1 */
+  nPop = 0;
+  if( (pIn1->flags & MEM_Null)==0 ){
+    sqlite3VdbeMemIntegerify(pIn1);
   }
   break;
 }
 
 #ifndef SQLITE_OMIT_CAST
-/* Opcode: ToReal * * *
+/* Opcode: ToReal P1 * * * *
 **
-** Force the value on the top of the stack to be a floating point number.
+** Force the value in register P1 to be a floating point number.
 ** If The value is currently an integer, convert it.
 ** If the value is text or blob, try to convert it to an integer using the
 ** equivalent of atoi() and store 0 if no such conversion is possible.
 **
 ** A NULL value is not changed by this routine.  It remains NULL.
 */
-case OP_ToReal: {                  /* same as TK_TO_REAL, no-push */
-  assert( pTos>=p->aStack );
-  if( (pTos->flags & MEM_Null)==0 ){
-    sqlite3VdbeMemRealify(pTos);
+case OP_ToReal: {                  /* same as TK_TO_REAL, no-push, in1 */
+  nPop = 0;
+  if( (pIn1->flags & MEM_Null)==0 ){
+    sqlite3VdbeMemRealify(pIn1);
   }
   break;
 }
@@ -4755,23 +4748,6 @@ case OP_MemMax: {        /* no-push */
 }
 #endif /* SQLITE_OMIT_AUTOINCREMENT */
 
-/* Opcode: MemIncr P1 P2 *
-**
-** Increment the integer valued memory cell P2 by the value in P1.
-**
-** It is illegal to use this instruction on a memory cell that does
-** not contain an integer.  An assertion fault will result if you try.
-*/
-case OP_MemIncr: {        /* no-push */
-  int i = pOp->p2;
-  Mem *pMem;
-  assert( i>0 && i<=p->nMem );
-  pMem = &p->aMem[i];
-  assert( pMem->flags==MEM_Int );
-  pMem->u.i += pOp->p1;
-  break;
-}
-
 /* Opcode: IfMemPos P1 P2 *
 **
 ** If the value of memory cell P1 is 1 or greater, jump to P2.
index 123078c8f3452e80fa4d518ee83a29ff359a394b..79109adffba2ed4dbf282694fd4d8b9dfe783be4 100644 (file)
@@ -355,7 +355,11 @@ int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp){
       VdbeOp *pOut = &p->aOp[i+addr];
       pOut->opcode = pIn->opcode;
       pOut->p1 = pIn->p1;
-      pOut->p2 = p2<0 ? addr + ADDR(p2) : p2;
+      if( p2<0 && sqlite3VdbeOpcodeHasProperty(pOut->opcode, OPFLG_JUMP) ){
+        pOut->p2 = addr + ADDR(p2);
+      }else{
+        pOut->p2 = p2;
+      }
       pOut->p3 = pIn->p3;
       pOut->p4type = P4_NOTUSED;
       pOut->p4.p = 0;