]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Modify the build process so that the VDBE opcode numbers and the table
authordrh <drh@noemail.net>
Sun, 8 Sep 2002 00:04:50 +0000 (00:04 +0000)
committerdrh <drh@noemail.net>
Sun, 8 Sep 2002 00:04:50 +0000 (00:04 +0000)
that contains the opcode names are both automatically generated. This makes
it much easier to create new VDBE opcodes. (CVS 746)

FossilOrigin-Name: eb54d455b0325d3be96daf6c220c4ee3e0da1a85

Makefile.in
main.mk
manifest
manifest.uuid
src/expr.c
src/vdbe.c
src/vdbe.h
tool/opNames.awk [deleted file]
tool/renumberOps.awk [deleted file]

index 86a635cc665881df43500f1f1f951db5f14cac1c..4d656d1795c94fd482f13932fcc68455ec2dc1a2 100644 (file)
@@ -63,8 +63,9 @@ ENCODING = @ENCODING@
 # Object files for the SQLite library.
 #
 LIBOBJ = btree.lo build.lo delete.lo expr.lo func.lo hash.lo insert.lo \
-         main.lo os.lo pager.lo parse.lo printf.lo random.lo select.lo \
-         table.lo tokenize.lo update.lo util.lo vdbe.lo where.lo trigger.lo
+         main.lo opcodes.lo os.lo pager.lo parse.lo printf.lo random.lo \
+         select.lo table.lo tokenize.lo update.lo util.lo vdbe.lo \
+         where.lo trigger.lo
 
 # All of the source code files.
 #
@@ -76,6 +77,7 @@ SRC = \
   $(TOP)/src/expr.c \
   $(TOP)/src/func.c \
   $(TOP)/src/hash.c \
+  $(TOP)/src/hash.h \
   $(TOP)/src/insert.c \
   $(TOP)/src/main.c \
   $(TOP)/src/os.c \
@@ -91,12 +93,12 @@ SRC = \
   $(TOP)/src/table.c \
   $(TOP)/src/tclsqlite.c \
   $(TOP)/src/tokenize.c \
+  $(TOP)/src/trigger.c \
   $(TOP)/src/update.c \
   $(TOP)/src/util.c \
   $(TOP)/src/vdbe.c \
   $(TOP)/src/vdbe.h \
-  $(TOP)/src/where.c \
-  $(TOP)/src/trigger.c
+  $(TOP)/src/where.c
 
 # Source code to the test files.
 #
@@ -110,6 +112,18 @@ TESTSRC = \
   $(TOP)/src/test3.c \
   $(TOP)/src/md5.c
 
+# Header files used by all library source files.
+#
+HDR = \
+   sqlite.h  \
+   $(TOP)/src/btree.h \
+   $(TOP)/src/hash.h \
+   opcodes.h \
+   $(TOP)/src/os.h \
+   $(TOP)/src/sqliteInt.h  \
+   $(TOP)/src/vdbe.h  \
+   parse.h
+
 # This is the default Makefile target.  The objects listed here
 # are what get build when you type just "make" with no arguments.
 #
@@ -133,22 +147,25 @@ sqlite:   $(TOP)/src/shell.c libsqlite.la sqlite.h
        $(LIBTOOL) $(TCC) $(READLINE_FLAGS) -o sqlite $(TOP)/src/shell.c \
                libsqlite.la $(LIBREADLINE) -rpath $(exec_prefix)/lib
 
+# This target creates a directory named "tsrc" and fills it with
+# copies of all of the C source code and header files needed to
+# build on the target system.  Some of the C source code and header
+# files are automatically generated.  This target takes care of
+# all that automatic generation.
+#
+target_source: $(SRC) $(HDR) 
+       rm -rf tsrc
+       mkdir tsrc
+       cp $(SRC) $(HDR) tsrc
+       rm tsrc/sqlite.h.in tsrc/parse.y
+       cp parse.c tsrc
+
 # Rules to build the LEMON compiler generator
 #
 lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
        $(BCC) -o lemon $(TOP)/tool/lemon.c
        cp $(TOP)/tool/lempar.c .
 
-# Header files used by all library source files.
-#
-HDR = \
-   sqlite.h  \
-   $(TOP)/src/btree.h \
-   $(TOP)/src/os.h \
-   $(TOP)/src/sqliteInt.h  \
-   $(TOP)/src/vdbe.h  \
-   parse.h
-
 btree.lo:      $(TOP)/src/btree.c $(HDR) $(TOP)/src/pager.h
        $(LIBTOOL) $(TCC) -c $(TOP)/src/btree.c
 
@@ -161,6 +178,22 @@ main.lo:   $(TOP)/src/main.c $(HDR)
 pager.lo:      $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
        $(LIBTOOL) $(TCC) -c $(TOP)/src/pager.c
 
+opcodes.lo:    opcodes.c
+       $(LIBTOOL) $(TCC) -c opcodes.c
+
+opcodes.c:     $(TOP)/src/vdbe.c
+       echo '/* Automatically generated file.  Do not edit */' >opcodes.c
+       echo 'char *sqliteOpcodeNames[] = { "???", ' >>opcodes.c
+       grep '^case OP_' $(TOP)/src/vdbe.c | \
+         sed -e 's/^.*OP_/  "/' -e 's/:.*$$/", /' >>opcodes.c
+       echo '};' >>opcodes.c
+
+opcodes.h:     $(TOP)/src/vdbe.h
+       echo '/* Automatically generated file.  Do not edit */' >opcodes.h
+       grep '^case OP_' $(TOP)/src/vdbe.c | \
+         sed -e 's/://' | \
+         awk '{printf "#define %-30s %3d\n", $$2, ++cnt}' >>opcodes.h
+
 os.lo: $(TOP)/src/os.c $(HDR)
        $(LIBTOOL) $(TCC) -c $(TOP)/src/os.c
 
@@ -283,9 +316,30 @@ speed.html:        $(TOP)/www/speed.tcl
 faq.html:      $(TOP)/www/faq.tcl
        tclsh $(TOP)/www/faq.tcl >faq.html
 
+formatchng.html:       $(TOP)/www/formatchng.tcl
+       tclsh $(TOP)/www/formatchng.tcl >formatchng.html
+
+conflict.html: $(TOP)/www/conflict.tcl
+       tclsh $(TOP)/www/conflict.tcl >conflict.html
+
 download.html: $(TOP)/www/download.tcl
        tclsh $(TOP)/www/download.tcl >download.html
 
+omitted.html:  $(TOP)/www/omitted.tcl
+       tclsh $(TOP)/www/omitted.tcl >omitted.html
+
+datatypes.html:        $(TOP)/www/datatypes.tcl
+       tclsh $(TOP)/www/datatypes.tcl >datatypes.html
+
+quickstart.html:       $(TOP)/www/quickstart.tcl
+       tclsh $(TOP)/www/quickstart.tcl >quickstart.html
+
+fileformat.html:       $(TOP)/www/fileformat.tcl
+       tclsh $(TOP)/www/fileformat.tcl >fileformat.html
+
+nulls.html:    $(TOP)/www/nulls.tcl
+       tclsh $(TOP)/www/nulls.tcl >nulls.html
+
 
 # Files to be published on the website.
 #
@@ -304,7 +358,14 @@ DOC = \
   tclsqlite.html \
   download.html \
   speed.html \
-  faq.html
+  faq.html \
+  formatchng.html \
+  conflict.html \
+  omitted.html \
+  datatypes.html \
+  quickstart.html \
+  fileformat.html \
+  nulls.html
 
 doc:   $(DOC)
        mkdir -p doc
@@ -319,7 +380,7 @@ install:    sqlite libsqlite.la sqlite.h
        $(INSTALL) -m 0644 sqlite.h $(prefix)/include
 
 clean: 
-       rm -f *.lo *.la *.o sqlite libsqlite.la sqlite.h
+       rm -f *.lo *.la *.o sqlite libsqlite.la sqlite.h opcodes.*
        rm -rf .libs .deps 
        rm -f lemon lempar.c parse.* sqlite*.tar.gz
        rm -f $(PUBLISH)
diff --git a/main.mk b/main.mk
index a44f9f0fed7afbe6f57e217f6c52e2508d9e7560..92b940891bd380d36e40a41acc02062dad30cf57 100644 (file)
--- a/main.mk
+++ b/main.mk
@@ -54,8 +54,8 @@ TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
 
 # Object files for the SQLite library.
 #
-LIBOBJ = btree.o build.o delete.o expr.o func.o hash.o insert.o \
-         main.o os.o pager.o parse.o printf.o random.o select.o table.o \
+LIBOBJ = btree.o build.o delete.o expr.o func.o hash.o insert.o main.o \
+         opcodes.o os.o pager.o parse.o printf.o random.o select.o table.o \
          tokenize.o trigger.o update.o util.o vdbe.o where.o tclsqlite.o
 
 # All of the source code files.
@@ -109,6 +109,7 @@ HDR = \
    sqlite.h  \
    $(TOP)/src/btree.h \
    $(TOP)/src/hash.h \
+   opcodes.h \
    $(TOP)/src/os.h \
    $(TOP)/src/sqliteInt.h  \
    $(TOP)/src/vdbe.h  \
@@ -165,6 +166,22 @@ main.o:    $(TOP)/src/main.c $(HDR)
 pager.o:       $(TOP)/src/pager.c $(HDR) $(TOP)/src/pager.h
        $(TCCX) -c $(TOP)/src/pager.c
 
+opcodes.o:     opcodes.c
+       $(TCCX) -c opcodes.c
+
+opcodes.c:     $(TOP)/src/vdbe.c
+       echo '/* Automatically generated file.  Do not edit */' >opcodes.c
+       echo 'char *sqliteOpcodeNames[] = { "???", ' >>opcodes.c
+       grep '^case OP_' $(TOP)/src/vdbe.c | \
+         sed -e 's/^.*OP_/  "/' -e 's/:.*$$/", /' >>opcodes.c
+       echo '};' >>opcodes.c
+
+opcodes.h:     $(TOP)/src/vdbe.h
+       echo '/* Automatically generated file.  Do not edit */' >opcodes.h
+       grep '^case OP_' $(TOP)/src/vdbe.c | \
+         sed -e 's/://' | \
+         awk '{printf "#define %-30s %3d\n", $$2, ++cnt}' >>opcodes.h
+
 os.o:  $(TOP)/src/os.c $(HDR)
        $(TCCX) -c $(TOP)/src/os.c
 
@@ -348,7 +365,7 @@ install:    sqlite libsqlite.a sqlite.h
        mv sqlite.h /usr/include
 
 clean: 
-       rm -f *.o sqlite libsqlite.a sqlite.h
+       rm -f *.o sqlite libsqlite.a sqlite.h opcodes.*
        rm -f lemon lempar.c parse.* sqlite*.tar.gz
        rm -f $(PUBLISH)
        rm -f *.da *.bb *.bbg gmon.out
index 6df6fb8a834c37d0fd1eefa17faf97c7d64488bf..da524f1fcfe3918c779d64947ecc8681a3259ea0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,6 +1,6 @@
-C Fix\sa\smemory\sleak\sthat\soccurred\swhen\ssqlite_open()\sfailed.\s(CVS\s745)
-D 2002-09-05T23:21:37
-F Makefile.in 420fada882179cb72ffd07313f3fd693f9f06640
+C Modify\sthe\sbuild\sprocess\sso\sthat\sthe\sVDBE\sopcode\snumbers\sand\sthe\stable\nthat\scontains\sthe\sopcode\snames\sare\sboth\sautomatically\sgenerated.\sThis\smakes\nit\smuch\seasier\sto\screate\snew\sVDBE\sopcodes.\s(CVS\s746)
+D 2002-09-08T00:04:51
+F Makefile.in d6c9a85c2a5e696843201d090dcf8bf2f8716f2a
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
 F VERSION 32d9c5fea1bc2db8fb2e5e460a166301d0c1a901
@@ -14,7 +14,7 @@ F doc/report1.txt a031aaf37b185e4fa540223cb516d3bccec7eeac
 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
 F libtool c56e618713c9510a103bda6b95f3ea3900dcacd6
 F ltmain.sh e9ed72eb1d690f447c13945eaf69e28af531eda1
-F main.mk 14a6933b738143bf939e9c04c59163d738239fae
+F main.mk e9c6f552f230b8befc25346c515c494fecd2e823
 F publish.sh a7a8d23e6525bd25d4f5ba9b0fc6edc107d94050
 F spec.template 238f7db425a78dc1bb7682e56e3834c7270a3f5e
 F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
@@ -23,7 +23,7 @@ F src/btree.h 0ca6c2631338df62e4f7894252d9347ae234eda9
 F src/build.c 0116afe4f67687206364c4d1e88dc07aefc661de
 F src/delete.c c9f59ee217e062eb9de7b64b76b5cfff42b2f028
 F src/encode.c 346b12b46148506c32038524b95c4631ab46d760
-F src/expr.c ee027b908a1e157fc21644121811fa6ec1eec798
+F src/expr.c e1327eb020a68ff7c49382e121ad4b71b3441b2a
 F src/func.c e45cd908b9b723d9b91473d09e12c23f786b3fc2
 F src/hash.c 6a6236b89c8c060c65dabd300a1c8ce7c10edb72
 F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
@@ -52,8 +52,8 @@ F src/tokenize.c 62c98842447effe92eba9622bb2f9a2a8a4b97ad
 F src/trigger.c c90a292a4bef25e478fd5deda6d300319be6a023
 F src/update.c f07e6ed2c517c92871e54d3f5886d1cf56121b11
 F src/util.c c70d5da5357e01b58392faebae3c3620c1d71f14
-F src/vdbe.c b746742d6ba103e21e37db3c012ac0bbbd0d0928
-F src/vdbe.h 7cfeb3aab6a901336532d93494cdedbddf30b7ec
+F src/vdbe.c 8637ddb9072df676f50dce3f7894cdaec714fe4a
+F src/vdbe.h b7584044223104ba7896a7f87b66daebdd6022ba
 F src/where.c 53959c9d94adaf93b409271815e26eafa6ddd515
 F test/all.test efd958d048c70a3247997c482f0b33561f7759f0
 F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
@@ -118,9 +118,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
 F tool/lemon.c 022adc2830c2705828f744d2c59798bd462eb465
 F tool/lempar.c 73a991cc3017fb34804250fa901488b5147b3717
 F tool/memleak.awk 16ef9493dcd36146f806e75148f4bb0201a123ec
-F tool/opNames.awk 5ba1f48aa854ee3b7c3d2b54233665bc3e649ea2
 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
-F tool/renumberOps.awk 6d067177ad5f8d711b79577b462da9b3634bd0a9
 F tool/report1.txt 9eae07f26a8fc53889b45fc833a66a33daa22816
 F tool/showdb.c 3559eac5a3b46e9b558d50856946b25e77633236
 F tool/showjournal.c 9a37d7b05de0591e3102aaf774d01fbc0d053a8b
@@ -151,7 +149,7 @@ F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P f4288520dfd1587446e50fa7ef23f75f6f63a7cf
-R b654a135f51d4e05c88ecdd8c52d16ce
+P a876021304a5de7ede1bf835971da7e328d1af07
+R ec4eceb930ae5f7d03668e5150997da1
 U drh
-Z 9f9892a64753c83b38229bcb1fa2dd28
+Z 19db40a2a17437704a985384e7939b07
index 195ca11c4321e9de1f25ae2fede0ef425585e898..f3320e6f078ebd230c64516d323a44ae65f574e6 100644 (file)
@@ -1 +1 @@
-a876021304a5de7ede1bf835971da7e328d1af07
\ No newline at end of file
+eb54d455b0325d3be96daf6c220c4ee3e0da1a85
\ No newline at end of file
index 9a358c9fb2146a2e1dca29be230e692fcd5d8a1a..0aaaf0e879860983dadb3f2e0a9ce2de89145ca8 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.80 2002/08/24 18:24:54 drh Exp $
+** $Id: expr.c,v 1.81 2002/09/08 00:04:52 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1369,7 +1369,13 @@ void sqliteExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
     case TK_NE:
     case TK_EQ: {
       if( pParse->db->file_format>=4 && sqliteExprType(pExpr)==SQLITE_SO_TEXT ){
-        op += 6;  /* Convert numeric opcodes to text opcodes */
+        /* Convert numeric comparison opcodes into text comparison opcodes.
+        ** This step depends on the fact that the text comparision opcodes are
+        ** always 6 greater than their corresponding numeric comparison
+        ** opcodes.
+        */
+        assert( OP_Eq+6 == OP_StrEq );
+        op += 6;
       }
       sqliteExprCode(pParse, pExpr->pLeft);
       sqliteExprCode(pParse, pExpr->pRight);
index 1f0ac36d11cbc80b29f5c270755129e65ac06b56..c227ef930acc889b08087ffcac8b3dc637eae505 100644 (file)
 ** But other routines are also provided to help in building up
 ** a program instruction by instruction.
 **
-** $Id: vdbe.c,v 1.175 2002/09/03 19:43:24 drh Exp $
+** $Id: vdbe.c,v 1.176 2002/09/08 00:04:52 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
 
+/*
+** The makefile scans this source file and creates the following
+** array of string constants which are the names of all VDBE opcodes.
+** This array is defined in a separate source code file named opcode.c
+** which is automatically generated by the makefile.
+*/
+extern char *sqliteOpcodeNames[];
+
 /*
 ** The following global variable is incremented every time a cursor
 ** moves, either by the OP_MoveTo or the OP_Next opcode.  The test
@@ -1066,65 +1074,6 @@ void sqliteVdbeDelete(Vdbe *p){
   sqliteFree(p);
 }
 
-/*
-** A translation from opcode numbers to opcode names.  Used for testing
-** and debugging only.
-**
-** If any of the numeric OP_ values for opcodes defined in sqliteVdbe.h
-** change, be sure to change this array to match.  You can use the
-** "opNames.awk" awk script which is part of the source tree to regenerate
-** this array, then copy and paste it into this file, if you want.
-*/
-static char *zOpName[] = { 0,
-  "Transaction",       "Checkpoint",        "Commit",            "Rollback",
-  "ReadCookie",        "SetCookie",         "VerifyCookie",      "Open",
-  "OpenTemp",          "OpenWrite",         "OpenAux",           "OpenWrAux",
-  "RenameCursor",      "Close",             "MoveTo",            "NewRecno",
-  "PutIntKey",         "PutStrKey",         "Distinct",          "Found",
-  "NotFound",          "IsUnique",          "NotExists",         "Delete",
-  "Column",            "KeyAsData",         "Recno",             "FullKey",
-  "NullRow",           "Last",              "Rewind",            "Next",
-  "Destroy",           "Clear",             "CreateIndex",       "CreateTable",
-  "IntegrityCk",       "IdxPut",            "IdxDelete",         "IdxRecno",
-  "IdxGT",             "IdxGE",             "MemLoad",           "MemStore",
-  "MemIncr",           "ListWrite",         "ListRewind",        "ListRead",
-  "ListReset",         "ListPush",          "ListPop",           "SortPut",
-  "SortMakeRec",       "SortMakeKey",       "Sort",              "SortNext",
-  "SortCallback",      "SortReset",         "FileOpen",          "FileRead",
-  "FileColumn",        "AggReset",          "AggFocus",          "AggNext",
-  "AggSet",            "AggGet",            "AggFunc",           "AggInit",
-  "AggPush",           "AggPop",            "SetInsert",         "SetFound",
-  "SetNotFound",       "SetFirst",          "SetNext",           "MakeRecord",
-  "MakeKey",           "MakeIdxKey",        "IncrKey",           "Goto",
-  "If",                "IfNot",             "Halt",              "Gosub",
-  "Return",            "ColumnCount",       "ColumnName",        "Callback",
-  "NullCallback",      "Integer",           "String",            "Pop",
-  "Dup",               "Pull",              "Push",              "MustBeInt",
-  "Add",               "AddImm",            "Subtract",          "Multiply",
-  "Divide",            "Remainder",         "BitAnd",            "BitOr",
-  "BitNot",            "ShiftLeft",         "ShiftRight",        "AbsValue",
-  "Eq",                "Ne",                "Lt",                "Le",
-  "Gt",                "Ge",                "StrEq",             "StrNe",
-  "StrLt",             "StrLe",             "StrGt",             "StrGe",
-  "IsNull",            "NotNull",           "Negative",          "And",
-  "Or",                "Not",               "Concat",            "Noop",
-  "Function",        
-};
-
-/*
-** Given the name of an opcode, return its number.  Return 0 if
-** there is no match.
-**
-** This routine is used for testing and debugging.
-*/
-int sqliteVdbeOpcode(const char *zName){
-  int i;
-  for(i=1; i<=OP_MAX; i++){
-    if( sqliteStrICmp(zName, zOpName[i])==0 ) return i;
-  }
-  return 0;
-}
-
 /*
 ** Give a listing of the program in the virtual machine.
 **
@@ -1175,7 +1124,7 @@ int sqliteVdbeList(
     }else{
       azValue[4] = p->aOp[i].p3;
     }
-    azValue[1] = zOpName[p->aOp[i].opcode];
+    azValue[1] = sqliteOpcodeNames[p->aOp[i].opcode];
     if( sqliteSafetyOff(db) ){
       rc = SQLITE_MISUSE;
       break;
@@ -1310,7 +1259,7 @@ static void vdbePrintOp(FILE *pOut, int pc, Op *pOp){
   }
   if( pOut==0 ) pOut = stdout;
   fprintf(pOut,"%4d %-12s %4d %4d %s\n",
-      pc, zOpName[pOp->opcode], pOp->p1, pOp->p2, zP3 ? zP3 : "");
+      pc, sqliteOpcodeNames[pOp->opcode], pOp->p1, pOp->p2, zP3 ? zP3 : "");
   fflush(pOut);
 }
 #endif
@@ -2283,7 +2232,18 @@ case OP_Ge: {
   }
   break;
 }
-
+/* INSERT NO CODE HERE!
+**
+** The opcode numbers are extracted from this source file by doing
+**
+**    grep '^case OP_' vdbe.c | ... >opcodes.h
+**
+** The opcodes are numbered in the order that they appear in this file.
+** But in order for the expression generating code to work right, the
+** string comparison operators that follow must be numbered exactly 6
+** greater than the numeric comparison opcodes above.  So no other
+** cases can appear between the two.
+*/
 /* Opcode: StrEq P1 P2 *
 **
 ** Pop the top two elements from the stack.  If they are equal, then
@@ -2403,13 +2363,18 @@ case OP_StrGe: {
     if( Stringify(p, tos) || Stringify(p, nos) ) goto no_mem;
     c = strcmp(zStack[nos], zStack[tos]);
   }
+  /* The asserts on each case of the following switch are there to verify
+  ** that string comparison opcodes are always exactly 6 greater than the
+  ** corresponding numeric comparison opcodes.  The code generator depends
+  ** on this fact.
+  */
   switch( pOp->opcode ){
-    case OP_StrEq:    c = c==0;     break;
-    case OP_StrNe:    c = c!=0;     break;
-    case OP_StrLt:    c = c<0;      break;
-    case OP_StrLe:    c = c<=0;     break;
-    case OP_StrGt:    c = c>0;      break;
-    default:          c = c>=0;     break;
+    case OP_StrEq:    c = c==0;    assert( pOp->opcode-6==OP_Eq );   break;
+    case OP_StrNe:    c = c!=0;    assert( pOp->opcode-6==OP_Ne );   break;
+    case OP_StrLt:    c = c<0;     assert( pOp->opcode-6==OP_Lt );   break;
+    case OP_StrLe:    c = c<=0;    assert( pOp->opcode-6==OP_Le );   break;
+    case OP_StrGt:    c = c>0;     assert( pOp->opcode-6==OP_Gt );   break;
+    default:          c = c>=0;    assert( pOp->opcode-6==OP_Ge );   break;
   }
   POPSTACK;
   POPSTACK;
@@ -3789,6 +3754,9 @@ case OP_Column: {
   break;
 }
 
+/* Opcode: Extract * * *
+*/
+
 /* Opcode: Recno P1 * *
 **
 ** Push onto the stack an integer which is the first 4 bytes of the
index 39a2aa56a49c740bfa1ac780b91c688e4e41f026..53d6a1cdbad15194c1136e34aace93b92c28f7a2 100644 (file)
@@ -15,7 +15,7 @@
 ** or VDBE.  The VDBE implements an abstract machine that runs a
 ** simple program to access and modify the underlying database.
 **
-** $Id: vdbe.h,v 1.59 2002/08/28 03:01:01 drh Exp $
+** $Id: vdbe.h,v 1.60 2002/09/08 00:04:53 drh Exp $
 */
 #ifndef _SQLITE_VDBE_H_
 #define _SQLITE_VDBE_H_
@@ -59,165 +59,10 @@ typedef struct VdbeOp VdbeOp;
 #define ADDR(X)  (-1-(X))
 
 /*
-** These are the available opcodes.
-**
-** If any of the values changes or if opcodes are added or removed,
-** be sure to also update the zOpName[] array in sqliteVdbe.c to
-** mirror the change.
-**
-** The source tree contains an AWK script named renumberOps.awk that
-** can be used to renumber these opcodes when new opcodes are inserted.
+** The makefile scans the vdbe.c source file and creates the "opcodes.h"
+** header file that defines a number for each opcode used by the VDBE.
 */
-#define OP_Transaction         1
-#define OP_Checkpoint          2
-#define OP_Commit              3
-#define OP_Rollback            4
-
-#define OP_ReadCookie          5
-#define OP_SetCookie           6
-#define OP_VerifyCookie        7
-
-#define OP_Open                8
-#define OP_OpenTemp            9
-#define OP_OpenWrite          10
-#define OP_OpenAux            11
-#define OP_OpenWrAux          12
-#define OP_RenameCursor       13
-#define OP_Close              14
-#define OP_MoveTo             15
-#define OP_NewRecno           16
-#define OP_PutIntKey          17
-#define OP_PutStrKey          18
-#define OP_Distinct           19
-#define OP_Found              20
-#define OP_NotFound           21
-#define OP_IsUnique           22
-#define OP_NotExists          23
-#define OP_Delete             24
-#define OP_Column             25
-#define OP_KeyAsData          26
-#define OP_Recno              27
-#define OP_FullKey            28
-#define OP_NullRow            29
-#define OP_Last               30
-#define OP_Rewind             31
-#define OP_Next               32
-
-#define OP_Destroy            33
-#define OP_Clear              34
-#define OP_CreateIndex        35
-#define OP_CreateTable        36
-#define OP_IntegrityCk        37
-
-#define OP_IdxPut             38
-#define OP_IdxDelete          39
-#define OP_IdxRecno           40
-#define OP_IdxGT              41
-#define OP_IdxGE              42
-
-#define OP_MemLoad            43
-#define OP_MemStore           44
-#define OP_MemIncr            45
-
-#define OP_ListWrite          46
-#define OP_ListRewind         47
-#define OP_ListRead           48
-#define OP_ListReset          49
-#define OP_ListPush           50
-#define OP_ListPop            51
-
-#define OP_SortPut            52
-#define OP_SortMakeRec        53
-#define OP_SortMakeKey        54
-#define OP_Sort               55
-#define OP_SortNext           56
-#define OP_SortCallback       57
-#define OP_SortReset          58
-
-#define OP_FileOpen           59
-#define OP_FileRead           60
-#define OP_FileColumn         61
-
-#define OP_AggReset           62
-#define OP_AggFocus           63
-#define OP_AggNext            64
-#define OP_AggSet             65
-#define OP_AggGet             66
-#define OP_AggFunc            67
-#define OP_AggInit            68
-#define OP_AggPush            69
-#define OP_AggPop             70
-
-#define OP_SetInsert          71
-#define OP_SetFound           72
-#define OP_SetNotFound        73
-#define OP_SetFirst           74
-#define OP_SetNext            75
-
-#define OP_MakeRecord         76
-#define OP_MakeKey            77
-#define OP_MakeIdxKey         78
-#define OP_IncrKey            79
-
-#define OP_Goto               80
-#define OP_If                 81
-#define OP_IfNot              82
-#define OP_Halt               83
-#define OP_Gosub              84
-#define OP_Return             85
-
-#define OP_ColumnCount        86
-#define OP_ColumnName         87
-#define OP_Callback           88
-#define OP_NullCallback       89
-
-#define OP_Integer            90
-#define OP_String             91
-#define OP_Pop                92
-#define OP_Dup                93
-#define OP_Pull               94
-#define OP_Push               95
-#define OP_MustBeInt          96
-
-#define OP_Add                97
-#define OP_AddImm             98
-#define OP_Subtract           99
-#define OP_Multiply          100
-#define OP_Divide            101
-#define OP_Remainder         102
-#define OP_BitAnd            103
-#define OP_BitOr             104
-#define OP_BitNot            105
-#define OP_ShiftLeft         106
-#define OP_ShiftRight        107
-#define OP_AbsValue          108
-
-/***** IMPORTANT NOTE: The code generator assumes that OP_XX+6==OP_StrXX *****/
-#define OP_Eq                109
-#define OP_Ne                110
-#define OP_Lt                111
-#define OP_Le                112
-#define OP_Gt                113
-#define OP_Ge                114
-#define OP_StrEq             115
-#define OP_StrNe             116
-#define OP_StrLt             117
-#define OP_StrLe             118
-#define OP_StrGt             119
-#define OP_StrGe             120
-/***** IMPORTANT NOTE: the code generator assumes that OP_XX+6==OP_StrXX *****/
-
-#define OP_IsNull            121
-#define OP_NotNull           122
-#define OP_Negative          123
-#define OP_And               124
-#define OP_Or                125
-#define OP_Not               126
-#define OP_Concat            127
-#define OP_Noop              128
-#define OP_Function          129
-
-#define OP_MAX               129
+#include "opcodes.h"
 
 /*
 ** Prototypes for the VDBE interface.  See comments on the implementation
@@ -234,7 +79,6 @@ void sqliteVdbeDequoteP3(Vdbe*, int addr);
 int sqliteVdbeFindOp(Vdbe*, int, int);
 int sqliteVdbeMakeLabel(Vdbe*);
 void sqliteVdbeDelete(Vdbe*);
-int sqliteVdbeOpcode(const char *zName);
 int sqliteVdbeExec(Vdbe*,sqlite_callback,void*,char**,void*,
                    int(*)(void*,const char*,int));
 int sqliteVdbeList(Vdbe*,sqlite_callback,void*,char**);
diff --git a/tool/opNames.awk b/tool/opNames.awk
deleted file mode 100644 (file)
index b1f7e3a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# Read the sqliteVdbe.h file and generate a table of opcode names.
-#
-BEGIN {
-  printf "static char *zOpName[] = { 0,\n"
-  n = 0
-}
-/^#define OP_MAX/ {
-  next
-}
-/^#define OP_/ {
-  name = "\"" substr($2,4) "\","
-  if( n<3 ){
-    printf "  %-19s", name
-    n++
-  } else {
-    printf "  %s\n", name
-    n = 0
-  }
-}
-END {
-  if( n ){ printf "\n" }
-  printf "};\n"
-}
diff --git a/tool/renumberOps.awk b/tool/renumberOps.awk
deleted file mode 100644 (file)
index 098c4d8..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# Run this script on sqliteVdbe.h to renumber the opcodes sequentially.
-#
-BEGIN { cnt = 1 }
-/^#define OP_MAX/ {
-  printf "#define %-20s %3d\n",$2, cnt-1
-  next
-}
-/^#define OP_/ {
-  printf "#define %-20s %3d\n",$2, cnt++
-  next
-}
-{ print }