Skip to content

Commit 57eb29f

Browse files
committed
Update zend_vm_gen.php with zend_vm_opcode.c/h changes
The generated files were modified directly, resulting in mysterious build failures depending on exact build order.
1 parent 7a306c0 commit 57eb29f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Zend/zend_vm_gen.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2374,7 +2374,8 @@ function gen_vm_opcodes_header(
23742374
$str .= "\n";
23752375
$str .= "BEGIN_EXTERN_C()\n\n";
23762376
$str .= "ZEND_API const char* ZEND_FASTCALL zend_get_opcode_name(zend_uchar opcode);\n";
2377-
$str .= "ZEND_API uint32_t ZEND_FASTCALL zend_get_opcode_flags(zend_uchar opcode);\n\n";
2377+
$str .= "ZEND_API uint32_t ZEND_FASTCALL zend_get_opcode_flags(zend_uchar opcode);\n";
2378+
$str .= "ZEND_API zend_uchar zend_get_opcode_id(const char *name, size_t length);\n\n";
23782379
$str .= "END_EXTERN_C()\n\n";
23792380

23802381
$code_len = strlen((string) $max_opcode);
@@ -2672,6 +2673,16 @@ function gen_vm($def, $skel) {
26722673
fputs($f, "\treturn zend_vm_opcodes_flags[opcode];\n");
26732674
fputs($f, "}\n");
26742675

2676+
fputs($f, "ZEND_API zend_uchar zend_get_opcode_id(const char *name, size_t length) {\n");
2677+
fputs($f, "\tzend_uchar opcode;\n");
2678+
fputs($f, "\tfor (opcode = 0; opcode < (sizeof(zend_vm_opcodes_names) / sizeof(zend_vm_opcodes_names[0])) - 1; opcode++) {\n");
2679+
fputs($f, "\t\tif (strncmp(zend_vm_opcodes_names[opcode], name, length) == 0) {\n");
2680+
fputs($f, "\t\t\treturn opcode;\n");
2681+
fputs($f, "\t\t}\n");
2682+
fputs($f, "\t}\n");
2683+
fputs($f, "\treturn ZEND_VM_LAST_OPCODE + 1;\n");
2684+
fputs($f, "}\n");
2685+
26752686
fclose($f);
26762687
echo "zend_vm_opcodes.c generated successfully.\n";
26772688

0 commit comments

Comments
 (0)