php-src/Zend/zend_vm_execute.skl
Peter Kokot 1ad08256f3 Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:56:38 +02:00

123 lines
2.8 KiB
Plaintext

{%DEFINES%}
ZEND_API void {%EXECUTOR_NAME%}_ex(zend_execute_data *ex)
{
DCL_OPLINE
{%HELPER_VARS%}
{%INTERNAL_LABELS%}
LOAD_OPLINE();
ZEND_VM_LOOP_INTERRUPT_CHECK();
while (1) {
{%ZEND_VM_CONTINUE_LABEL%}
{%ZEND_VM_DISPATCH%} {
{%INTERNAL_EXECUTOR%}
}
}
zend_error_noreturn(E_CORE_ERROR, "Arrived at end of main loop which shouldn't happen");
}
ZEND_API void zend_{%EXECUTOR_NAME%}(zend_op_array *op_array, zval *return_value)
{
zend_execute_data *execute_data;
if (EG(exception) != NULL) {
return;
}
execute_data = zend_vm_stack_push_call_frame(ZEND_CALL_TOP_CODE | ZEND_CALL_HAS_SYMBOL_TABLE,
(zend_function*)op_array, 0, zend_get_called_scope(EG(current_execute_data)), zend_get_this_object(EG(current_execute_data)));
if (EG(current_execute_data)) {
execute_data->symbol_table = zend_rebuild_symbol_table();
} else {
execute_data->symbol_table = &EG(symbol_table);
}
EX(prev_execute_data) = EG(current_execute_data);
i_init_code_execute_data(execute_data, op_array, return_value);
zend_{%EXECUTOR_NAME%}_ex(execute_data);
zend_vm_stack_free_call_frame(execute_data);
}
{%EXTERNAL_EXECUTOR%}
void {%INITIALIZER_NAME%}(void)
{
{%EXTERNAL_LABELS%}
VM_TRACE_START();
}
void zend_vm_dtor(void)
{
VM_TRACE_END();
}
static HashTable *zend_handlers_table = NULL;
static void init_opcode_serialiser(void)
{
int i;
zval tmp;
zend_handlers_table = malloc(sizeof(HashTable));
zend_hash_init_ex(zend_handlers_table, zend_handlers_count, NULL, NULL, 1, 0);
zend_hash_real_init(zend_handlers_table, 0);
Z_TYPE_INFO(tmp) = IS_LONG;
for (i = 0; i < zend_handlers_count; i++) {
Z_LVAL(tmp) = i;
zend_hash_index_add(zend_handlers_table, (zend_long)(zend_uintptr_t)zend_opcode_handlers[i], &tmp);
}
}
ZEND_API void ZEND_FASTCALL zend_serialize_opcode_handler(zend_op *op)
{
zval *zv;
if (!zend_handlers_table) {
init_opcode_serialiser();
}
zv = zend_hash_index_find(zend_handlers_table, (zend_long)(zend_uintptr_t)op->handler);
ZEND_ASSERT(zv != NULL);
op->handler = (const void *)(zend_uintptr_t)Z_LVAL_P(zv);
}
ZEND_API void ZEND_FASTCALL zend_deserialize_opcode_handler(zend_op *op)
{
op->handler = zend_opcode_handlers[(zend_uintptr_t)op->handler];
}
ZEND_API const void* ZEND_FASTCALL zend_get_opcode_handler_func(const zend_op *op)
{
#if ZEND_VM_KIND == ZEND_VM_KIND_CALL
return op->handler;
#elif ZEND_VM_KIND == ZEND_VM_KIND_HYBRID
zval *zv;
if (!zend_handlers_table) {
init_opcode_serialiser();
}
zv = zend_hash_index_find(zend_handlers_table, (zend_long)(zend_uintptr_t)op->handler);
ZEND_ASSERT(zv != NULL);
return zend_opcode_handler_funcs[Z_LVAL_P(zv)];
#else
return NULL;
#endif
}
ZEND_API const zend_op *zend_get_halt_op(void)
{
#if ZEND_VM_KIND == ZEND_VM_KIND_HYBRID
return &hybrid_halt_op;
#else
return NULL;
#endif
}
ZEND_API int zend_vm_kind(void)
{
return ZEND_VM_KIND;
}