From a186d329a47ebe7f4a2481016407898028454fde Mon Sep 17 00:00:00 2001 From: geniusgogo Date: Wed, 13 Nov 2013 22:27:45 +0800 Subject: add SQLite-3.8.1 authority original source tree --- components/external/SQLite-3.8.1/mkopcodeh.awk | 183 +++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 components/external/SQLite-3.8.1/mkopcodeh.awk (limited to 'components/external/SQLite-3.8.1/mkopcodeh.awk') diff --git a/components/external/SQLite-3.8.1/mkopcodeh.awk b/components/external/SQLite-3.8.1/mkopcodeh.awk new file mode 100644 index 0000000000..9685c3a0e8 --- /dev/null +++ b/components/external/SQLite-3.8.1/mkopcodeh.awk @@ -0,0 +1,183 @@ +#!/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: /* jump, in1, in2, in3, out2-prerelease, out3 */ +# +# When such comments are found on an opcode, it means that certain +# properties apply to that opcode. Set corresponding flags using the +# OPFLG_INITIALIZER macro. +# + + +# Remember the TK_ values from the parse.h file +/^#define TK_/ { + tk[$2] = 0+$3 # tk[x] holds the numeric value for TK symbol X +} + +# Scan for "case OP_aaaa:" lines in the vdbe.c file +/^case OP_/ { + name = $2 + sub(/:/,"",name) + sub("\r","",name) + op[name] = -1 # op[x] holds the numeric value for OP symbol x + jump[name] = 0 + out2_prerelease[name] = 0 + in1[name] = 0 + in2[name] = 0 + in3[name] = 0 + out2[name] = 0 + out3[name] = 0 + for(i=3; i=0 ) continue; + if( name=="OP_Function" \ + || name=="OP_AggStep" \ + || name=="OP_Transaction" \ + || name=="OP_AutoCommit" \ + || name=="OP_Savepoint" \ + || name=="OP_Checkpoint" \ + || name=="OP_Vacuum" \ + || name=="OP_JournalMode" \ + || name=="OP_VUpdate" \ + || name=="OP_VFilter" \ + || name=="OP_Next" \ + || name=="OP_SorterNext" \ + || name=="OP_Prev" \ + ){ + cnt++ + while( used[cnt] ) cnt++ + op[name] = cnt + used[cnt] = 1 + def[cnt] = name + } + } + + # Generate the numeric values for opcodes + for(i=0; i