build_runtime_definition_key returns zend_string*

This commit is contained in:
Nikita Popov 2014-07-29 20:01:11 +02:00
parent 18f0680779
commit 438b1e3d42

View File

@ -153,13 +153,14 @@ static zend_string *zend_new_interned_string_safe(zend_string *str TSRMLS_DC) {
}
}
static void build_runtime_defined_function_key(zval *result, zend_string *name, unsigned char *lex_pos TSRMLS_DC) /* {{{ */
{
static zend_string *zend_build_runtime_definition_key(
zend_string *name, unsigned char *lex_pos TSRMLS_DC
) {
zend_string *result;
char char_pos_buf[32];
uint char_pos_len;
const char *filename;
size_t char_pos_len = zend_sprintf(char_pos_buf, "%p", lex_pos);
char_pos_len = zend_sprintf(char_pos_buf, "%p", lex_pos);
const char *filename;
if (CG(active_op_array)->filename) {
filename = CG(active_op_array)->filename->val;
} else {
@ -167,13 +168,12 @@ static void build_runtime_defined_function_key(zval *result, zend_string *name,
}
/* NULL, name length, filename length, last accepting char position length */
ZVAL_NEW_STR(result, STR_ALLOC(1 + name->len + strlen(filename) + char_pos_len, 0));
result = STR_ALLOC(1 + name->len + strlen(filename) + char_pos_len, 0);
/* must be binary safe */
Z_STRVAL_P(result)[0] = '\0';
sprintf(Z_STRVAL_P(result)+1, "%s%s%s", name->val, filename, char_pos_buf);
result->val[0] = '\0';
sprintf(result->val + 1, "%s%s%s", name->val, filename, char_pos_buf);
return result;
}
/* }}} */
static void init_compiler_declarables(TSRMLS_D) /* {{{ */
{
@ -5547,13 +5547,12 @@ static void zend_begin_func_decl(
}
{
zval key;
build_runtime_defined_function_key(&key, lcname, decl->lex_pos TSRMLS_CC);
zend_string *key = zend_build_runtime_definition_key(lcname, decl->lex_pos TSRMLS_CC);
opline->op1_type = IS_CONST;
opline->op1.constant = zend_add_literal(CG(active_op_array), &key TSRMLS_CC);
LITERAL_STR(opline->op1, key);
zend_hash_update_ptr(CG(function_table), Z_STR(key), op_array);
zend_hash_update_ptr(CG(function_table), key, op_array);
}
STR_RELEASE(lcname);
@ -5973,12 +5972,12 @@ void zend_compile_class_decl(zend_ast *ast TSRMLS_DC) {
}
{
zval key;
build_runtime_defined_function_key(&key, lcname, decl->lex_pos TSRMLS_CC);
opline->op1_type = IS_CONST;
opline->op1.constant = zend_add_literal(CG(active_op_array), &key TSRMLS_CC);
zend_string *key = zend_build_runtime_definition_key(lcname, decl->lex_pos TSRMLS_CC);
zend_hash_update_ptr(CG(class_table), Z_STR(key), ce);
opline->op1_type = IS_CONST;
LITERAL_STR(opline->op1, key);
zend_hash_update_ptr(CG(class_table), key, ce);
}
CG(active_class_entry) = ce;