1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-02 05:54:29 +03:00

Add the sqlite3VdbeLoadString() and sqlite3VdbeMultiLoad() routines to help

with code generation, especially on PRAGMAs.  Rename sqlite3VdbeAddGoto()
to just sqlite3VdbeGoto().

FossilOrigin-Name: 847387ec8e6fef283899578fb232b2c23b00ee5b
This commit is contained in:
drh
2015-09-03 13:46:12 +00:00
parent 7cc023c7fa
commit 076e85f59c
17 changed files with 170 additions and 153 deletions

View File

@@ -214,10 +214,45 @@ int sqlite3VdbeAddOp1(Vdbe *p, int op, int p1){
int sqlite3VdbeAddOp2(Vdbe *p, int op, int p1, int p2){
return sqlite3VdbeAddOp3(p, op, p1, p2, 0);
}
int sqlite3VdbeAddGoto(Vdbe *p, int iDest){
/* Generate code for an unconditional jump to instruction iDest
*/
int sqlite3VdbeGoto(Vdbe *p, int iDest){
return sqlite3VdbeAddOp3(p, OP_Goto, 0, iDest, 0);
}
/* Generate code to cause the string zStr to be loaded into
** register iDest
*/
int sqlite3VdbeLoadString(Vdbe *p, int iDest, const char *zStr){
return sqlite3VdbeAddOp4(p, OP_String8, 0, iDest, 0, zStr, 0);
}
/*
** Generate code that initializes multiple registers to string or integer
** constants. The registers begin with iDest and increase consecutively.
** One register is initialized for each characgter in zTypes[]. For each
** "s" character in zTypes[], the register is a string if the argument is
** not NULL, or OP_Null if the value is a null pointer. For each "i" character
** in zTypes[], the register is initialized to an integer.
*/
void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){
va_list ap;
int i;
char c;
va_start(ap, zTypes);
for(i=0; (c = zTypes[i])!=0; i++){
if( c=='s' ){
const char *z = va_arg(ap, const char*);
int addr = sqlite3VdbeAddOp2(p, z==0 ? OP_Null : OP_String8, 0, iDest++);
if( z ) sqlite3VdbeChangeP4(p, addr, z, 0);
}else{
assert( c=='i' );
sqlite3VdbeAddOp2(p, OP_Integer, va_arg(ap, int), iDest++);
}
}
va_end(ap);
}
/*
** Add an opcode that includes the p4 value as a pointer.