blob: 2ef77d4cca86bcc4181d9e4c961ffdac6d9a753f [file] [log] [blame]
drhb327f772004-10-06 15:03:57 +00001#!/usr/bin/awk -f
2#
3# This AWK script scans the opcodes.h file (which is itself generated by
4# another awk script) and uses the information gleaned to create the
5# opcodes.c source file.
6#
7# Opcodes.c contains strings which are the symbolic names for the various
8# opcodes used by the VDBE. These strings are used when disassembling a
9# VDBE program during tracing or as a result of the EXPLAIN keyword.
10#
11BEGIN {
12 print "/* Automatically generated. Do not edit */"
drh279d4772005-01-20 23:23:29 +000013 print "/* See the mkopcodec.awk script for details. */"
drhb7f91642004-10-31 02:22:47 +000014 printf "#if !defined(SQLITE_OMIT_EXPLAIN)"
15 printf " || !defined(NDEBUG)"
16 printf " || defined(VDBE_PROFILE)"
17 print " || defined(SQLITE_DEBUG)"
drh46c99e02007-08-27 23:26:59 +000018 print "const char *sqlite3OpcodeName(int i){"
19 print " static const char *const azName[] = { \"?\","
drh307ff302011-08-30 01:29:04 +000020 mx = 0
drhb327f772004-10-06 15:03:57 +000021}
drhdaa28ff2004-12-10 17:17:18 +000022/define OP_/ {
drhb327f772004-10-06 15:03:57 +000023 sub("OP_","",$2)
drh307ff302011-08-30 01:29:04 +000024 i = $3+0
25 label[i] = $2
26 if( mx<i ) mx = i
drhb327f772004-10-06 15:03:57 +000027}
28END {
drh307ff302011-08-30 01:29:04 +000029 for(i=1; i<=mx; i++){
30 printf " /* %3d */ \"%s\",\n", i, label[i]
31 }
drh46c99e02007-08-27 23:26:59 +000032 print " };"
33 print " return azName[i];"
34 print "}"
drhb7f91642004-10-31 02:22:47 +000035 print "#endif"
drhb327f772004-10-06 15:03:57 +000036}