summaryrefslogtreecommitdiff
path: root/mkopcodec.awk
diff options
context:
space:
mode:
authorHans-Christoph Steiner <hans@eds.org>2012-03-30 20:42:12 -0400
committerHans-Christoph Steiner <hans@eds.org>2012-03-30 20:42:12 -0400
commit7bb481fda9ecb134804b49c2ce77ca28f7eea583 (patch)
tree31b520b9914d3e2453968abe375f2c102772c3dc /mkopcodec.awk
Imported Upstream version 2.0.3
Diffstat (limited to 'mkopcodec.awk')
-rw-r--r--mkopcodec.awk36
1 files changed, 36 insertions, 0 deletions
diff --git a/mkopcodec.awk b/mkopcodec.awk
new file mode 100644
index 0000000..2ef77d4
--- /dev/null
+++ b/mkopcodec.awk
@@ -0,0 +1,36 @@
+#!/usr/bin/awk -f
+#
+# This AWK script scans the opcodes.h file (which is itself generated by
+# another awk script) and uses the information gleaned to create the
+# opcodes.c source file.
+#
+# Opcodes.c contains strings which are the symbolic names for the various
+# opcodes used by the VDBE. These strings are used when disassembling a
+# VDBE program during tracing or as a result of the EXPLAIN keyword.
+#
+BEGIN {
+ print "/* Automatically generated. Do not edit */"
+ print "/* See the mkopcodec.awk script for details. */"
+ printf "#if !defined(SQLITE_OMIT_EXPLAIN)"
+ printf " || !defined(NDEBUG)"
+ printf " || defined(VDBE_PROFILE)"
+ print " || defined(SQLITE_DEBUG)"
+ print "const char *sqlite3OpcodeName(int i){"
+ print " static const char *const azName[] = { \"?\","
+ mx = 0
+}
+/define OP_/ {
+ sub("OP_","",$2)
+ i = $3+0
+ label[i] = $2
+ if( mx<i ) mx = i
+}
+END {
+ for(i=1; i<=mx; i++){
+ printf " /* %3d */ \"%s\",\n", i, label[i]
+ }
+ print " };"
+ print " return azName[i];"
+ print "}"
+ print "#endif"
+}