本文整理汇总了PHP中gen_labels函数的典型用法代码示例。如果您正苦于以下问题:PHP gen_labels函数的具体用法?PHP gen_labels怎么用?PHP gen_labels使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gen_labels函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gen_executor
//.........这里部分代码省略.........
case "HELPER_VARS":
if ($kind != ZEND_VM_KIND_CALL) {
if ($kind == ZEND_VM_KIND_SWITCH) {
out($f, $m[1] . "const void *dispatch_handler;\n");
}
// Emit local variables those are used for helpers' parameters
foreach ($params as $param => $x) {
out($f, $m[1] . $param . ";\n");
}
out($f, "#ifdef ZEND_VM_FP_GLOBAL_REG\n");
out($f, $m[1] . "register zend_execute_data *execute_data __asm__(ZEND_VM_FP_GLOBAL_REG) = ex;\n");
out($f, "#else\n");
out($f, $m[1] . "zend_execute_data *execute_data = ex;\n");
out($f, "#endif\n");
} else {
out($f, "#ifdef ZEND_VM_IP_GLOBAL_REG\n");
out($f, $m[1] . "const zend_op *orig_opline = opline;\n");
out($f, "#endif\n");
out($f, "#ifdef ZEND_VM_FP_GLOBAL_REG\n");
out($f, $m[1] . "zend_execute_data *orig_execute_data = execute_data;\n");
out($f, $m[1] . "execute_data = ex;\n");
out($f, "#else\n");
out($f, $m[1] . "zend_execute_data *execute_data = ex;\n");
out($f, "#endif\n");
}
break;
case "INTERNAL_LABELS":
if ($kind == ZEND_VM_KIND_GOTO) {
// Emit array of labels of opcode handlers and code for
// zend_opcode_handlers initialization
$prolog = $m[1];
out($f, $prolog . "if (UNEXPECTED(execute_data == NULL)) {\n");
out($f, $prolog . "\tstatic const void* labels[] = {\n");
gen_labels($f, $spec, $kind, $prolog . "\t\t");
out($f, $prolog . "\t};\n");
out($f, $prolog . "\tzend_opcode_handlers = (const void **)labels;\n");
out($f, $prolog . "\treturn;\n");
out($f, $prolog . "}\n");
} else {
skip_blanks($f, $m[1], $m[3]);
}
break;
case "ZEND_VM_CONTINUE_LABEL":
if ($kind == ZEND_VM_KIND_CALL) {
// Only SWITCH dispatch method use it
out($f, "#if !defined(ZEND_VM_FP_GLOBAL_REG) || !defined(ZEND_VM_IP_GLOBAL_REG)\n");
out($f, $m[1] . "\tint ret;" . $m[3] . "\n");
out($f, "#endif\n");
} else {
if ($kind == ZEND_VM_KIND_SWITCH) {
// Only SWITCH dispatch method use it
out($f, "zend_vm_continue:" . $m[3] . "\n");
} else {
skip_blanks($f, $m[1], $m[3]);
}
}
break;
case "ZEND_VM_DISPATCH":
// Emit code that dispatches to opcode handler
switch ($kind) {
case ZEND_VM_KIND_CALL:
out($f, "#if defined(ZEND_VM_FP_GLOBAL_REG) && defined(ZEND_VM_IP_GLOBAL_REG)\n");
out($f, $m[1] . "((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
out($f, $m[1] . "if (UNEXPECTED(!OPLINE))" . $m[3] . "\n");
out($f, "#else\n");
out($f, $m[1] . "if (UNEXPECTED((ret = ((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)) != 0))" . $m[3] . "\n");
示例2: gen_executor
//.........这里部分代码省略.........
out($f, "#define LOAD_REGS()\n");
out($f, "#define ZEND_VM_CONTINUE() goto *(void**)(OPLINE->handler)\n");
out($f, "#define ZEND_VM_RETURN() EG(in_execution) = original_in_execution; return\n");
out($f, "#define ZEND_VM_ENTER() goto zend_vm_enter\n");
out($f, "#define ZEND_VM_LEAVE() ZEND_VM_CONTINUE()\n");
out($f, "#define ZEND_VM_DISPATCH(opcode, opline) goto *(void**)(zend_vm_get_opcode_handler(opcode, opline));\n\n");
out($f, "#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
break;
}
break;
case "EXECUTOR_NAME":
out($f, $m[1] . $executor_name . $m[3] . "\n");
break;
case "HELPER_VARS":
if ($kind != ZEND_VM_KIND_CALL) {
if ($kind == ZEND_VM_KIND_SWITCH) {
out($f, $m[1] . "opcode_handler_t dispatch_handler;\n");
}
// Emit local variables those are used for helpers' parameters
foreach ($params as $param => $x) {
out($f, $m[1] . $param . ";\n");
}
} else {
skip_blanks($f, $m[1], $m[3] . "\n");
}
break;
case "INTERNAL_LABELS":
if ($kind == ZEND_VM_KIND_GOTO) {
// Emit array of labels of opcode handlers and code for
// zend_opcode_handlers initialization
$prolog = $m[1];
out($f, $prolog . "if (execute_data == NULL) {\n");
out($f, $prolog . "\tstatic const opcode_handler_t labels[] = {\n");
gen_labels($f, $spec, $kind, $prolog . "\t\t");
out($f, $prolog . "\t};\n");
out($f, $prolog . "\tzend_opcode_handlers = (opcode_handler_t*)labels;\n");
out($f, $prolog . "\treturn;\n");
out($f, $prolog . "}\n");
} else {
skip_blanks($f, $m[1], $m[3]);
}
break;
case "ZEND_VM_CONTINUE_LABEL":
if ($kind == ZEND_VM_KIND_CALL) {
// Only SWITCH dispatch method use it
out($f, $m[1] . "\tint ret;" . $m[3] . "\n");
} else {
if ($kind == ZEND_VM_KIND_SWITCH) {
// Only SWITCH dispatch method use it
out($f, "zend_vm_continue:" . $m[3] . "\n");
} else {
skip_blanks($f, $m[1], $m[3]);
}
}
break;
case "ZEND_VM_DISPATCH":
// Emit code that dispatches to opcode handler
switch ($kind) {
case ZEND_VM_KIND_CALL:
out($f, $m[1] . "if ((ret = OPLINE->handler(execute_data TSRMLS_CC)) > 0)" . $m[3] . "\n");
break;
case ZEND_VM_KIND_SWITCH:
out($f, $m[1] . "dispatch_handler = OPLINE->handler;\nzend_vm_dispatch:\n" . $m[1] . "switch ((int)dispatch_handler)" . $m[3] . "\n");
break;
case ZEND_VM_KIND_GOTO:
out($f, $m[1] . "goto *(void**)(OPLINE->handler);" . $m[3] . "\n");
示例3: gen_executor
function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name, $old)
{
global $params, $skeleton_file, $line_no;
$lineno = 0;
foreach ($skl as $line) {
// Skeleton file contains special markers in form %NAME% those are
// substituted by custom code
if (preg_match("/(.*)[{][%]([A-Z_]*)[%][}](.*)/", $line, $m)) {
switch ($m[2]) {
case "DEFINES":
if (ZEND_VM_OLD_EXECUTOR) {
out($f, "static int zend_vm_old_executor = 0;\n\n");
}
out($f, "static opcode_handler_t zend_vm_get_opcode_handler(zend_uchar opcode, int op1_type, int op2_type);\n\n");
switch ($kind) {
case ZEND_VM_KIND_CALL:
out($f, "\n");
out($f, "#define ZEND_VM_CONTINUE() return 0\n");
out($f, "#define ZEND_VM_RETURN() return 1\n");
out($f, "#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline->op1.op_type, opline->op2.op_type)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n\n");
out($f, "#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
break;
case ZEND_VM_KIND_SWITCH:
out($f, "\n");
out($f, "#define ZEND_VM_CONTINUE() goto zend_vm_continue\n");
out($f, "#define ZEND_VM_RETURN() return\n");
out($f, "#define ZEND_VM_DISPATCH(opcode, opline) dispatch_handler = zend_vm_get_opcode_handler(opcode, opline->op1.op_type, opline->op2.op_type); goto zend_vm_dispatch;\n\n");
out($f, "#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL &execute_data TSRMLS_CC\n");
break;
case ZEND_VM_KIND_GOTO:
out($f, "\n");
out($f, "#define ZEND_VM_CONTINUE() goto *(void**)(EX(opline)->handler)\n");
out($f, "#define ZEND_VM_RETURN() return\n");
out($f, "#define ZEND_VM_DISPATCH(opcode, opline) goto *(void**)(zend_vm_get_opcode_handler(opcode, opline->op1.op_type, opline->op2.op_type));\n\n");
out($f, "#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL &execute_data TSRMLS_CC\n");
break;
case ZEND_VM_KIND_GOTO2:
out($f, "\n");
out($f, "#define ZEND_VM_CONTINUE() goto *(void**)(EX(opline)->handler)\n");
//out($f,"#define ZEND_VM_RETURN() return\n");
out($f, "#define ZEND_VM_RETURN() goto ZEND_RETURN_HANDLER\n");
out($f, "#define ZEND_VM_DISPATCH(opcode, opline) goto *(void**)(zend_vm_get_opcode_handler(opcode, opline->op1.op_type, opline->op2.op_type));\n\n");
out($f, "#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
break;
}
out($f, "#undef EX\n");
if ($kind == ZEND_VM_KIND_GOTO2) {
out($f, "#define EX(element) execute_data->element\n");
} else {
out($f, "#define EX(element) execute_data.element\n");
}
out($f, "#define ZEND_OPCODE_HANDLER_ARGS zend_execute_data *execute_data TSRMLS_DC\n");
out($f, "#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU execute_data TSRMLS_CC\n");
break;
case "EXECUTOR_NAME":
out($f, $m[1] . $executor_name . $m[3] . "\n");
break;
case "HELPER_VARS":
if ($kind != ZEND_VM_KIND_CALL) {
if ($kind == ZEND_VM_KIND_SWITCH) {
out($f, $m[1] . "opcode_handler_t dispatch_handler;\n");
}
// Emit local variables those are used for helpers' parameters
foreach ($params as $param => $x) {
out($f, $m[1] . $param . ";\n");
}
} else {
skip_blanks($f, $m[1], $m[3] . "\n");
}
if ($kind == ZEND_VM_KIND_GOTO2) {
out($f, $m[1] . "zend_execute_data* execute_data = do_alloca(sizeof(zend_execute_data));\n");
} else {
out($f, $m[1] . "zend_execute_data execute_data;\n");
}
break;
case "INTERNAL_LABELS":
if ($kind == ZEND_VM_KIND_GOTO || $kind == ZEND_VM_KIND_GOTO2) {
// Emit array of labels of opcode handlers and code for
// zend_opcode_handlers initialization
$prolog = $m[1];
out($f, $prolog . "if (op_array == NULL) {\n");
out($f, $prolog . "\tstatic const opcode_handler_t labels[] = {\n");
gen_labels($f, $spec, $kind, $prolog . "\t\t");
out($f, $prolog . "\t};\n");
out($f, $prolog . "\tzend_opcode_handlers = (opcode_handler_t*)labels;\n");
out($f, $prolog . "\treturn;\n");
out($f, $prolog . "}\n");
} else {
skip_blanks($f, $m[1], $m[3]);
}
break;
case "ZEND_VM_CONTINUE_LABEL":
if ($kind == ZEND_VM_KIND_SWITCH) {
// Only SWITCH dispatch method use it
out($f, "zend_vm_continue:" . $m[3] . "\n");
} else {
skip_blanks($f, $m[1], $m[3]);
}
break;
case "ZEND_VM_DISPATCH":
//.........这里部分代码省略.........