2015-10-07 15:11:36 +03:00
|
|
|
#!/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"
|
2016-02-01 20:20:08 +03:00
|
|
|
puts " static const char *const azName\[\] = \173"
|
2015-10-07 15:11:36 +03:00
|
|
|
set mx 0
|
|
|
|
|
2021-07-29 19:49:28 +03:00
|
|
|
set in [open [lindex $argv 0]]
|
|
|
|
fconfigure $in -translation binary
|
2015-10-07 15:11:36 +03:00
|
|
|
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
|
|
|
|
|
2016-02-01 20:20:08 +03:00
|
|
|
for {set i 0} {$i<=$mx} {incr i} {
|
2015-10-07 15:11:36 +03:00
|
|
|
puts [format " /* %3d */ %-18s OpHelp(\"%s\")," \
|
|
|
|
$i \"$label($i)\" $synopsis($i)]
|
|
|
|
}
|
|
|
|
puts " \175;"
|
|
|
|
puts " return azName\[i\];"
|
|
|
|
puts "\175"
|
|
|
|
puts "#endif"
|