| Line | |
|---|
| 1 | #!/usr/bin/gawk -f |
|---|
| 2 | # vim:ts=4:sw=4 |
|---|
| 3 | # process zend_vm_def.h or zend_compile.h |
|---|
| 4 | BEGIN { |
|---|
| 5 | FS=" " |
|---|
| 6 | max = 0; |
|---|
| 7 | delete opcodes; |
|---|
| 8 | } |
|---|
| 9 | |
|---|
| 10 | /^ZEND_VM_HANDLER\(/ { |
|---|
| 11 | # regex from php5.1+/Zend/zend_vm_gen.php |
|---|
| 12 | gsub(/ +/, ""); |
|---|
| 13 | if (!match($0, /^ZEND_VM_HANDLER\(([0-9]+),([A-Z_]+),([A-Z|]+),([A-Z|]+)\)/, array)) { |
|---|
| 14 | print "error unmatch $0"; |
|---|
| 15 | exit; |
|---|
| 16 | } |
|---|
| 17 | id = 0 + array[1]; |
|---|
| 18 | name = array[2]; |
|---|
| 19 | if (max < id) { |
|---|
| 20 | max = id; |
|---|
| 21 | } |
|---|
| 22 | opcodes[id] = name; |
|---|
| 23 | next; |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | /^#define +ZEND_[A-Z_]+[\t ]+[[:digit:]]+$/ { |
|---|
| 27 | id = 0 + $3; |
|---|
| 28 | name = $2; |
|---|
| 29 | if (max < id) { |
|---|
| 30 | max = id; |
|---|
| 31 | } |
|---|
| 32 | opcodes[id] = name; |
|---|
| 33 | next; |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | /end of block/ { |
|---|
| 37 | exit; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | END { |
|---|
| 41 | mymax = 112; |
|---|
| 42 | if (max < mymax) { |
|---|
| 43 | for (i = max + 1; i <= mymax; i ++) { |
|---|
| 44 | opcodes[i] = "UNDEF"; |
|---|
| 45 | } |
|---|
| 46 | max = mymax; |
|---|
| 47 | opcodes[110] = "ZEND_DO_FCALL_BY_FUNC"; |
|---|
| 48 | opcodes[111] = "ZEND_INIT_FCALL_BY_FUNC"; |
|---|
| 49 | opcodes[112] = "UNDEF"; |
|---|
| 50 | } |
|---|
| 51 | printf "/* size = %d */\n", max; |
|---|
| 52 | print "static const char *const xc_opcode_names[] = {"; |
|---|
| 53 | for (i = 0; i <= max; i ++) { |
|---|
| 54 | if (i != 0) { |
|---|
| 55 | print ","; |
|---|
| 56 | } |
|---|
| 57 | printf "/* %d */\t", i |
|---|
| 58 | if (i in opcodes) { |
|---|
| 59 | name = opcodes[i]; |
|---|
| 60 | sub(/^ZEND_/, "", name); |
|---|
| 61 | printf "\"%s\"", name; |
|---|
| 62 | } |
|---|
| 63 | else if (i == 137) { |
|---|
| 64 | printf "\"%s\"", "OP_DATA"; |
|---|
| 65 | } |
|---|
| 66 | else { |
|---|
| 67 | printf "\"UNDEF\""; |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | print ""; |
|---|
| 71 | print "};"; |
|---|
| 72 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.