Skip to content

Commit b1df00a

Browse files
committed
stop warnings from unused opcode map
1 parent c14388d commit b1df00a

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

Zend/zend_vm_gen.php

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

12041204
fputs($f, "#ifndef ZEND_VM_OPCODES_H\n#define ZEND_VM_OPCODES_H\n\n");
1205-
fputs($f, "extern ZEND_API const char *zend_vm_opcodes_map[".($max_opcode + 1)."];\n\n");
1206-
1205+
fputs($f, "ZEND_API const char *zend_get_opcode_name(zend_uchar opcode);\n\n");
1206+
12071207
foreach ($opcodes as $code => $dsc) {
12081208
$code = str_pad((string)$code,$code_len," ",STR_PAD_LEFT);
12091209
$op = str_pad($dsc["op"],$max_opcode_len);
@@ -1219,14 +1219,19 @@ function gen_vm($def, $skel) {
12191219

12201220
// Insert header
12211221
out($f, $GLOBALS['header_text']);
1222-
fputs($f,"#include <stdio.h>\n\n");
1223-
1222+
fputs($f,"#include <stdio.h>\n");
1223+
fputs($f,"#include <zend.h>\n\n");
1224+
12241225
fputs($f,"const char *zend_vm_opcodes_map[".($max_opcode + 1)."] = {\n");
12251226
for ($i = 0; $i <= $max_opcode; $i++) {
12261227
fputs($f,"\t".(isset($opcodes[$i]["op"])?'"'.$opcodes[$i]["op"].'"':"NULL").",\n");
12271228
}
1228-
fputs($f, "};\n");
1229-
1229+
fputs($f, "};\n\n");
1230+
1231+
fputs($f, "ZEND_API const char* zend_get_opcode_name(zend_uchar opcode) {\n");
1232+
fputs($f, "\treturn zend_vm_opcodes_map[opcode];\n");
1233+
fputs($f, "}\n");
1234+
12301235
fclose($f);
12311236
echo "zend_vm_opcodes.c generated successfully.\n";
12321237

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[159] = {
2425
"ZEND_NOP",
@@ -181,3 +182,7 @@ const char *zend_vm_opcodes_map[159] = {
181182
"ZEND_QM_ASSIGN_VAR",
182183
"ZEND_JMP_SET_VAR",
183184
};
185+
186+
ZEND_API const char* zend_get_opcode_name(zend_uchar opcode) {
187+
return zend_vm_opcodes_map[opcode];
188+
}

Zend/zend_vm_opcodes.h

Lines changed: 1 addition & 1 deletion
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[159];
24+
ZEND_API const char *zend_get_opcode_name(zend_uchar opcode);
2525

2626
#define ZEND_NOP 0
2727
#define ZEND_ADD 1

0 commit comments

Comments
 (0)