本文整理汇总了PHP中gen_code函数的典型用法代码示例。如果您正苦于以下问题:PHP gen_code函数的具体用法?PHP gen_code怎么用?PHP gen_code使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gen_code函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gen_vm
//.........这里部分代码省略.........
out($f, "#endif\n");
out($f, "\n");
out($f, "\tLOAD_OPLINE();\n");
out($f, "#if defined(ZEND_VM_FP_GLOBAL_REG) && defined(ZEND_VM_IP_GLOBAL_REG)\n");
out($f, "\t((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
out($f, "\tif (EXPECTED(opline)) {\n");
out($f, "\t\tret = execute_data != ex ? (int)(execute_data->prev_execute_data != ex) + 1 : 0;\n");
out($f, "\t\tSAVE_OPLINE();\n");
out($f, "\t} else {\n");
out($f, "\t\tret = -1;\n");
out($f, "\t}\n");
out($f, "#else\n");
out($f, "\tret = ((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
out($f, "\tSAVE_OPLINE();\n");
out($f, "#endif\n");
out($f, "#ifdef ZEND_VM_FP_GLOBAL_REG\n");
out($f, "\texecute_data = orig_execute_data;\n");
out($f, "#endif\n");
out($f, "#ifdef ZEND_VM_IP_GLOBAL_REG\n");
out($f, "\topline = orig_opline;\n");
out($f, "#endif\n");
out($f, "\treturn ret;\n");
out($f, "}\n\n");
} else {
out($f, "ZEND_API int zend_vm_call_opcode_handler(zend_execute_data* ex)\n");
out($f, "{\n");
out($f, "\tzend_error_noreturn(E_CORE_ERROR, \"zend_vm_call_opcode_handler() is not supported\");\n");
out($f, "\treturn 0;\n");
out($f, "}\n\n");
}
// Export handlers and helpers
if (count($export) > 0 && ZEND_VM_KIND != ZEND_VM_KIND_CALL) {
out($f, "#undef OPLINE\n");
out($f, "#undef DCL_OPLINE\n");
out($f, "#undef USE_OPLINE\n");
out($f, "#undef LOAD_OPLINE\n");
out($f, "#undef LOAD_NEXT_OPLINE\n");
out($f, "#undef SAVE_OPLINE\n");
out($f, "#define OPLINE EX(opline)\n");
out($f, "#define DCL_OPLINE\n");
out($f, "#define USE_OPLINE const zend_op *opline = EX(opline);\n");
out($f, "#define LOAD_OPLINE()\n");
out($f, "#define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE()\n");
out($f, "#define SAVE_OPLINE()\n");
out($f, "#undef HANDLE_EXCEPTION\n");
out($f, "#undef HANDLE_EXCEPTION_LEAVE\n");
out($f, "#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
out($f, "#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
out($f, "#undef ZEND_VM_CONTINUE\n");
out($f, "#undef ZEND_VM_RETURN\n");
out($f, "#undef ZEND_VM_ENTER\n");
out($f, "#undef ZEND_VM_LEAVE\n");
out($f, "#undef ZEND_VM_DISPATCH\n");
out($f, "#define ZEND_VM_CONTINUE() return 0\n");
out($f, "#define ZEND_VM_RETURN() return -1\n");
out($f, "#define ZEND_VM_ENTER() return 1\n");
out($f, "#define ZEND_VM_LEAVE() return 2\n");
out($f, "#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\n");
out($f, "\n");
}
foreach ($export as $dsk) {
list($kind, $func, $name) = $dsk;
out($f, "ZEND_API int {$func}(");
if ($kind == "handler") {
out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
$code = $opcodes[$opnames[$name]]['code'];
} else {
$h = $helpers[$name];
if ($h['param'] == null) {
out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
} else {
out($f, $h['param'] . " ZEND_OPCODE_HANDLER_ARGS_DC)\n");
}
$code = $h['code'];
}
$done = 0;
if (ZEND_VM_KIND == ZEND_VM_KIND_CALL) {
if ($kind == "handler") {
$op = $opcodes[$opnames[$name]];
if (isset($op['op1']["ANY"]) && isset($op['op2']["ANY"])) {
out($f, "{\n\treturn " . $name . (ZEND_VM_SPEC ? "_SPEC" : "") . "_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
$done = 1;
}
} else {
if ($helpers[$name]["param"] == null) {
$h = $helpers[$name];
if (isset($h['op1']["ANY"]) && isset($h['op2']["ANY"])) {
out($f, "{\n\treturn " . $name . (ZEND_VM_SPEC ? "_SPEC" : "") . "(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
$done = 1;
}
}
}
}
if (!$done) {
gen_code($f, 0, ZEND_VM_KIND_CALL, 1, $code, 'ANY', 'ANY', $name);
}
}
fclose($f);
echo "zend_vm_execute.h generated successfully.\n";
}
示例2: gen_vm
//.........这里部分代码省略.........
out($f, "\t\t\t_UNUSED_CODE, /* 12 */\n");
out($f, "\t\t\t_UNUSED_CODE, /* 13 */\n");
out($f, "\t\t\t_UNUSED_CODE, /* 14 */\n");
out($f, "\t\t\t_UNUSED_CODE, /* 15 */\n");
out($f, "\t\t\t_CV_CODE /* 16 = IS_CV */\n");
out($f, "\t\t};\n");
out($f, "\t\treturn zend_opcode_handlers[opcode * 25 + zend_vm_decode[op->op1_type] * 5 + zend_vm_decode[op->op2_type]];\n");
if (ZEND_VM_OLD_EXECUTOR) {
out($f, "\t}\n");
}
}
out($f, "}\n\n");
// Generate zend_vm_get_opcode_handler() function
out($f, "ZEND_API void zend_vm_set_opcode_handler(zend_op* op)\n");
out($f, "{\n");
out($f, "\top->handler = zend_vm_get_opcode_handler(zend_user_opcodes[op->opcode], op);\n");
out($f, "}\n\n");
// Export handlers and helpers
if (count($export) > 0 && !ZEND_VM_OLD_EXECUTOR && ZEND_VM_KIND != ZEND_VM_KIND_CALL) {
out($f, "#undef OPLINE\n");
out($f, "#undef DCL_OPLINE\n");
out($f, "#undef USE_OPLINE\n");
out($f, "#undef LOAD_OPLINE\n");
out($f, "#undef SAVE_OPLINE\n");
out($f, "#define OPLINE EX(opline)\n");
out($f, "#define DCL_OPLINE\n");
out($f, "#define USE_OPLINE zend_op *opline = EX(opline);\n");
out($f, "#define LOAD_OPLINE()\n");
out($f, "#define SAVE_OPLINE()\n");
out($f, "#undef CHECK_EXCEPTION\n");
out($f, "#undef HANDLE_EXCEPTION\n");
out($f, "#undef HANDLE_EXCEPTION_LEAVE\n");
out($f, "#define CHECK_EXCEPTION() LOAD_OPLINE()\n");
out($f, "#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
out($f, "#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
out($f, "#undef ZEND_VM_CONTINUE\n");
out($f, "#undef ZEND_VM_RETURN\n");
out($f, "#undef ZEND_VM_ENTER\n");
out($f, "#undef ZEND_VM_LEAVE\n");
out($f, "#undef ZEND_VM_DISPATCH\n");
out($f, "#undef ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL\n\n");
out($f, "#define ZEND_VM_CONTINUE() return 0\n");
out($f, "#define ZEND_VM_RETURN() return 1\n");
out($f, "#define ZEND_VM_ENTER() return 2\n");
out($f, "#define ZEND_VM_LEAVE() return 3\n");
out($f, "#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\n");
out($f, "#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n\n");
}
foreach ($export as $dsk) {
list($kind, $func, $name) = $dsk;
out($f, "ZEND_API int {$func}(");
if ($kind == "handler") {
out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
$code = $opcodes[$opnames[$name]]['code'];
} else {
$h = $helpers[$name];
if ($h['param'] == null) {
out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
} else {
out($f, $h['param'] . ", ZEND_OPCODE_HANDLER_ARGS)\n");
}
$code = $h['code'];
}
$done = 0;
if (ZEND_VM_OLD_EXECUTOR) {
if ($kind == "handler") {
out($f, "{\n\treturn " . $name . "_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
$done = 1;
} else {
if ($helpers[$name]["param"] == null) {
out($f, "{\n\treturn " . $name . "(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
$done = 1;
}
}
} else {
if (ZEND_VM_KIND == ZEND_VM_KIND_CALL) {
if ($kind == "handler") {
$op = $opcodes[$opnames[$name]];
if (isset($op['op1']["ANY"]) && isset($op['op2']["ANY"])) {
out($f, "{\n\treturn " . $name . (ZEND_VM_SPEC ? "_SPEC" : "") . "_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
$done = 1;
}
} else {
if ($helpers[$name]["param"] == null) {
$h = $helpers[$name];
if (isset($h['op1']["ANY"]) && isset($h['op2']["ANY"])) {
out($f, "{\n\treturn " . $name . (ZEND_VM_SPEC ? "_SPEC" : "") . "(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
$done = 1;
}
}
}
}
}
if (!$done) {
gen_code($f, 0, ZEND_VM_KIND_CALL, 1, $code, 'ANY', 'ANY', $name);
}
}
fclose($f);
echo "zend_vm_execute.h generated successfully.\n";
}
示例3: gen_vm
//.........这里部分代码省略.........
out($f, "\n");
out($f, "\tLOAD_OPLINE();\n");
out($f, "#if defined(ZEND_VM_FP_GLOBAL_REG) && defined(ZEND_VM_IP_GLOBAL_REG)\n");
out($f, "\t((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
out($f, "\tif (EXPECTED(opline)) {\n");
out($f, "\t\tret = execute_data != ex ? (int)(execute_data->prev_execute_data != ex) + 1 : 0;\n");
out($f, "\t\tSAVE_OPLINE();\n");
out($f, "\t} else {\n");
out($f, "\t\tret = -1;\n");
out($f, "\t}\n");
out($f, "#else\n");
out($f, "\tret = ((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
out($f, "\tSAVE_OPLINE();\n");
out($f, "#endif\n");
out($f, "#ifdef ZEND_VM_FP_GLOBAL_REG\n");
out($f, "\texecute_data = orig_execute_data;\n");
out($f, "#endif\n");
out($f, "#ifdef ZEND_VM_IP_GLOBAL_REG\n");
out($f, "\topline = orig_opline;\n");
out($f, "#endif\n");
out($f, "\treturn ret;\n");
out($f, "}\n\n");
} else {
out($f, "ZEND_API int zend_vm_call_opcode_handler(zend_execute_data* ex)\n");
out($f, "{\n");
out($f, "\tzend_error_noreturn(E_CORE_ERROR, \"zend_vm_call_opcode_handler() is not supported\");\n");
out($f, "\treturn 0;\n");
out($f, "}\n\n");
}
// Export handlers and helpers
if (count($export) > 0 && ZEND_VM_KIND != ZEND_VM_KIND_CALL) {
out($f, "#undef OPLINE\n");
out($f, "#undef DCL_OPLINE\n");
out($f, "#undef USE_OPLINE\n");
out($f, "#undef LOAD_OPLINE\n");
out($f, "#undef LOAD_NEXT_OPLINE\n");
out($f, "#undef SAVE_OPLINE\n");
out($f, "#define OPLINE EX(opline)\n");
out($f, "#define DCL_OPLINE\n");
out($f, "#define USE_OPLINE const zend_op *opline = EX(opline);\n");
out($f, "#define LOAD_OPLINE()\n");
out($f, "#define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE()\n");
out($f, "#define SAVE_OPLINE()\n");
out($f, "#undef HANDLE_EXCEPTION\n");
out($f, "#undef HANDLE_EXCEPTION_LEAVE\n");
out($f, "#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
out($f, "#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
out($f, "#undef ZEND_VM_CONTINUE\n");
out($f, "#undef ZEND_VM_RETURN\n");
out($f, "#undef ZEND_VM_ENTER\n");
out($f, "#undef ZEND_VM_LEAVE\n");
out($f, "#undef ZEND_VM_DISPATCH\n");
out($f, "#define ZEND_VM_CONTINUE() return 0\n");
out($f, "#define ZEND_VM_RETURN() return -1\n");
out($f, "#define ZEND_VM_ENTER() return 1\n");
out($f, "#define ZEND_VM_LEAVE() return 2\n");
out($f, "#define ZEND_VM_INTERRUPT() return zend_interrupt_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
out($f, "#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\n");
out($f, "\n");
}
foreach ($export as $dsk) {
list($kind, $func, $name) = $dsk;
out($f, "ZEND_API int {$func}(");
if ($kind == "handler") {
out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
$code = $opcodes[$opnames[$name]]['code'];
} else {
$h = $helpers[$name];
if ($h['param'] == null) {
out($f, "ZEND_OPCODE_HANDLER_ARGS)\n");
} else {
out($f, $h['param'] . " ZEND_OPCODE_HANDLER_ARGS_DC)\n");
}
$code = $h['code'];
}
$done = 0;
if (ZEND_VM_KIND == ZEND_VM_KIND_CALL) {
if ($kind == "handler") {
$op = $opcodes[$opnames[$name]];
if (isset($op['op1']["ANY"]) && isset($op['op2']["ANY"])) {
out($f, "{\n\treturn " . $name . (ZEND_VM_SPEC ? "_SPEC" : "") . "_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
$done = 1;
}
} else {
if ($helpers[$name]["param"] == null) {
$h = $helpers[$name];
if (isset($h['op1']["ANY"]) && isset($h['op2']["ANY"])) {
out($f, "{\n\treturn " . $name . (ZEND_VM_SPEC ? "_SPEC" : "") . "(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n}\n\n");
$done = 1;
}
}
}
}
if (!$done) {
gen_code($f, 0, ZEND_VM_KIND_CALL, 1, $code, 'ANY', 'ANY', $name);
}
}
fclose($f);
echo "zend_vm_execute.h generated successfully.\n";
}