Skip to content

Commit f9affb5

Browse files
krakjoeweltling
authored andcommitted
stop warnings from unused opcode map
1 parent aaca4ed commit f9affb5

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

Zend/zend_vm_gen.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,8 +1208,8 @@ function gen_vm($def, $skel) {
12081208
out($f, $GLOBALS['header_text']);
12091209

12101210
fputs($f, "#ifndef ZEND_VM_OPCODES_H\n#define ZEND_VM_OPCODES_H\n\n");
1211-
fputs($f, "extern ZEND_API const char *zend_vm_opcodes_map[".($max_opcode + 1)."];\n\n");
1212-
1211+
fputs($f, "ZEND_API const char *zend_get_opcode_name(zend_uchar opcode);\n\n");
1212+
12131213
foreach ($opcodes as $code => $dsc) {
12141214
$code = str_pad((string)$code,$code_len," ",STR_PAD_LEFT);
12151215
$op = str_pad($dsc["op"],$max_opcode_len);
@@ -1225,14 +1225,19 @@ function gen_vm($def, $skel) {
12251225

12261226
// Insert header
12271227
out($f, $GLOBALS['header_text']);
1228-
fputs($f,"#include <stdio.h>\n\n");
1229-
1228+
fputs($f,"#include <stdio.h>\n");
1229+
fputs($f,"#include <zend.h>\n\n");
1230+
12301231
fputs($f,"const char *zend_vm_opcodes_map[".($max_opcode + 1)."] = {\n");
12311232
for ($i = 0; $i <= $max_opcode; $i++) {
12321233
fputs($f,"\t".(isset($opcodes[$i]["op"])?'"'.$opcodes[$i]["op"].'"':"NULL").",\n");
12331234
}
1234-
fputs($f, "};\n");
1235-
1235+
fputs($f, "};\n\n");
1236+
1237+
fputs($f, "ZEND_API const char* zend_get_opcode_name(zend_uchar opcode) {\n");
1238+
fputs($f, "\treturn zend_vm_opcodes_map[opcode];\n");
1239+
fputs($f, "}\n");
1240+
12361241
fclose($f);
12371242
echo "zend_vm_opcodes.c generated successfully.\n";
12381243

Zend/zend_vm_opcodes.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020

2121
#include <stdio.h>
22+
#include <zend.h>
2223

2324
const char *zend_vm_opcodes_map[165] = {
2425
"ZEND_NOP",
@@ -187,3 +188,7 @@ const char *zend_vm_opcodes_map[165] = {
187188
"ZEND_FAST_RET",
188189
"ZEND_RECV_VARIADIC",
189190
};
191+
192+
ZEND_API const char* zend_get_opcode_name(zend_uchar opcode) {
193+
return zend_vm_opcodes_map[opcode];
194+
}

Zend/zend_vm_opcodes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#ifndef ZEND_VM_OPCODES_H
2222
#define ZEND_VM_OPCODES_H
2323

24-
extern ZEND_API const char *zend_vm_opcodes_map[165];
24+
ZEND_API const char *zend_get_opcode_name(zend_uchar opcode);
2525

2626
#define ZEND_NOP 0
2727
#define ZEND_ADD 1
@@ -171,4 +171,4 @@ extern ZEND_API const char *zend_vm_opcodes_map[165];
171171
#define ZEND_FAST_RET 163
172172
#define ZEND_RECV_VARIADIC 164
173173

174-
#endif
174+
#endif

0 commit comments

Comments
 (0)