Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/tool/mkopcodec.tcl # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / tool / mkopcodec.tcl` 51 lines ยท 1552 bytes Raw Blame History 1 #!/usr/bin/tclsh 2 # 3 # This TCL script scans the opcodes.h file (which is itself generated by 4 # another TCL 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 # 11 puts "/* Automatically generated. Do not edit */" 12 puts "/* See the tool/mkopcodec.tcl script for details. */" 13 puts "#if !defined(SQLITE_OMIT_EXPLAIN) \\" 14 puts " || defined(VDBE_PROFILE) \\" 15 puts " || defined(SQLITE_DEBUG)" 16 puts "#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) || defined(SQLITE_DEBUG)" 17 puts "# define OpHelp(X) \"\\0\" X" 18 puts "#else" 19 puts "# define OpHelp(X)" 20 puts "#endif" 21 puts "const char *sqlite3OpcodeName(int i)\173" 22 puts " static const char *const azName\[\] = \173" 23 set mx 0 24 25 set in [open [lindex $argv 0]] 26 fconfigure $in -translation binary 27 while {![eof $in]} { 28 set line [gets $in] 29 if {[regexp {^#define OP_} $line]} { 30 set name [lindex $line 1] 31 regsub {^OP_} $name {} name 32 set i [lindex $line 2] 33 set label($i) $name 34 if {$mx<$i} {set mx $i} 35 if {[regexp {synopsis: (.*) \*/} $line all x]} { 36 set synopsis($i) [string trim $x] 37 } else { 38 set synopsis($i) {} 39 } 40 } 41 } 42 close $in 43 44 for {set i 0} {$i<=$mx} {incr i} { 45 puts [format " /* %3d */ %-18s OpHelp(\"%s\")," \ 46 $i \"$label($i)\" $synopsis($i)] 47 } 48 puts " \175;" 49 puts " return azName\[i\];" 50 puts "\175" 51 puts "#endif"