From e36d23a85ebff914d74bb541558c2b6082b78edb Mon Sep 17 00:00:00 2001 From: dan miller Date: Sat, 20 Oct 2007 02:49:29 +0000 Subject: sqlite source (unix build) added to libraries --- libraries/sqlite/unix/sqlite-3.5.1/mkopcodeh.awk | 127 +++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 libraries/sqlite/unix/sqlite-3.5.1/mkopcodeh.awk (limited to 'libraries/sqlite/unix/sqlite-3.5.1/mkopcodeh.awk') diff --git a/libraries/sqlite/unix/sqlite-3.5.1/mkopcodeh.awk b/libraries/sqlite/unix/sqlite-3.5.1/mkopcodeh.awk new file mode 100644 index 0000000..c0874b1 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/mkopcodeh.awk @@ -0,0 +1,127 @@ +#!/usr/bin/awk -f +# +# Generate the file opcodes.h. +# +# This AWK script scans a concatenation of the parse.h output file from the +# parser and the vdbe.c source file in order to generate the opcodes numbers +# for all opcodes. +# +# The lines of the vdbe.c that we are interested in are of the form: +# +# case OP_aaaa: /* same as TK_bbbbb */ +# +# The TK_ comment is optional. If it is present, then the value assigned to +# the OP_ is the same as the TK_ value. If missing, the OP_ value is assigned +# a small integer that is different from every other OP_ value. +# +# We go to the trouble of making some OP_ values the same as TK_ values +# as an optimization. During parsing, things like expression operators +# are coded with TK_ values such as TK_ADD, TK_DIVIDE, and so forth. Later +# during code generation, we need to generate corresponding opcodes like +# OP_Add and OP_Divide. By making TK_ADD==OP_Add and TK_DIVIDE==OP_Divide, +# code to translate from one to the other is avoided. This makes the +# code generator run (infinitesimally) faster and more importantly it makes +# the library footprint smaller. +# +# This script also scans for lines of the form: +# +# case OP_aaaa: /* no-push */ +# +# When the no-push comment is found on an opcode, it means that that +# opcode does not leave a result on the stack. By identifying which +# opcodes leave results on the stack it is possible to determine a +# much smaller upper bound on the size of the stack. This allows +# a smaller stack to be allocated, which is important to embedded +# systems with limited memory space. This script generates a series +# of "NOPUSH_MASK" defines that contain bitmaps of opcodes that leave +# results on the stack. The NOPUSH_MASK defines are used in vdbeaux.c +# to help determine the maximum stack size. +# + + +# Remember the TK_ values from the parse.h file +/^#define TK_/ { + tk[$2] = $3 +} + +# Scan for "case OP_aaaa:" lines in the vdbe.c file +/^case OP_/ { + name = $2 + sub(/:/,"",name) + sub("\r","",name) + op[name] = -1 + for(i=3; imax ) max = op[name] + printf "#define %-25s %15d", name, op[name] + if( sameas[op[name]] ) { + printf " /* same as %-12s*/", sameas[op[name]] + } + printf "\n" + + } + seenUnused = 0; + for(i=1; i