summaryrefslogtreecommitdiffstats
path: root/tool/mkopcodec.tcl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 17:28:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 17:28:19 +0000
commit18657a960e125336f704ea058e25c27bd3900dcb (patch)
tree17b438b680ed45a996d7b59951e6aa34023783f2 /tool/mkopcodec.tcl
parentInitial commit. (diff)
downloadsqlite3-18657a960e125336f704ea058e25c27bd3900dcb.tar.xz
sqlite3-18657a960e125336f704ea058e25c27bd3900dcb.zip
Adding upstream version 3.40.1.upstream/3.40.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tool/mkopcodec.tcl')
-rw-r--r--tool/mkopcodec.tcl51
1 files changed, 51 insertions, 0 deletions
diff --git a/tool/mkopcodec.tcl b/tool/mkopcodec.tcl
new file mode 100644
index 0000000..5eac05f
--- /dev/null
+++ b/tool/mkopcodec.tcl
@@ -0,0 +1,51 @@
+#!/usr/bin/tclsh
+#
+# This TCL script scans the opcodes.h file (which is itself generated by
+# another TCL 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.
+#
+puts "/* Automatically generated. Do not edit */"
+puts "/* See the tool/mkopcodec.tcl script for details. */"
+puts "#if !defined(SQLITE_OMIT_EXPLAIN) \\"
+puts " || defined(VDBE_PROFILE) \\"
+puts " || defined(SQLITE_DEBUG)"
+puts "#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) || defined(SQLITE_DEBUG)"
+puts "# define OpHelp(X) \"\\0\" X"
+puts "#else"
+puts "# define OpHelp(X)"
+puts "#endif"
+puts "const char *sqlite3OpcodeName(int i)\173"
+puts " static const char *const azName\[\] = \173"
+set mx 0
+
+set in [open [lindex $argv 0]]
+fconfigure $in -translation binary
+while {![eof $in]} {
+ set line [gets $in]
+ if {[regexp {^#define OP_} $line]} {
+ set name [lindex $line 1]
+ regsub {^OP_} $name {} name
+ set i [lindex $line 2]
+ set label($i) $name
+ if {$mx<$i} {set mx $i}
+ if {[regexp {synopsis: (.*) \*/} $line all x]} {
+ set synopsis($i) [string trim $x]
+ } else {
+ set synopsis($i) {}
+ }
+ }
+}
+close $in
+
+for {set i 0} {$i<=$mx} {incr i} {
+ puts [format " /* %3d */ %-18s OpHelp(\"%s\")," \
+ $i \"$label($i)\" $synopsis($i)]
+}
+puts " \175;"
+puts " return azName\[i\];"
+puts "\175"
+puts "#endif"