mirror of
https://github.com/php/php-src.git
synced 2024-11-28 20:34:29 +08:00
Port __METHOD__
This commit is contained in:
parent
a75921dcb1
commit
64a7132185
@ -1490,18 +1490,24 @@ void zend_do_receive_param(zend_uchar op, znode *varname, znode *initialization,
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
zend_string *zend_concat_names(char *name1, size_t name1_len, char *name2, size_t name2_len) {
|
||||
size_t len = name1_len + name2_len + 1; /* name1\name2 */
|
||||
zend_string *zend_concat3(
|
||||
char *str1, size_t str1_len, char *str2, size_t str2_len, char *str3, size_t str3_len
|
||||
) {
|
||||
size_t len = str1_len + str2_len + str3_len;
|
||||
zend_string *res = STR_ALLOC(len, 0);
|
||||
|
||||
memcpy(res->val, name1, name1_len);
|
||||
res->val[name1_len] = '\\';
|
||||
memcpy(res->val + name1_len + 1, name2, name2_len);
|
||||
memcpy(res->val, str1, str1_len);
|
||||
memcpy(res->val + str1_len, str2, str2_len);
|
||||
memcpy(res->val + str1_len + str2_len, str3, str3_len);
|
||||
res->val[len] = '\0';
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
zend_string *zend_concat_names(char *name1, size_t name1_len, char *name2, size_t name2_len) {
|
||||
return zend_concat3(name1, name1_len, "\\", 1, name2, name2_len);
|
||||
}
|
||||
|
||||
void *zend_hash_find_ptr_lc(HashTable *ht, char *str, size_t len) {
|
||||
void *result;
|
||||
zend_string *lcname = STR_ALLOC(len, 0);
|
||||
@ -7680,6 +7686,7 @@ void zend_compile_encaps_list(znode *result, zend_ast *ast TSRMLS_DC) {
|
||||
|
||||
void zend_compile_magic_const(znode *result, zend_ast *ast TSRMLS_DC) {
|
||||
zend_op_array *op_array = CG(active_op_array);
|
||||
zend_class_entry *ce = CG(active_class_entry);
|
||||
zval *zv = &result->u.constant;
|
||||
result->op_type = IS_CONST;
|
||||
|
||||
@ -7691,6 +7698,20 @@ void zend_compile_magic_const(znode *result, zend_ast *ast TSRMLS_DC) {
|
||||
ZVAL_EMPTY_STRING(zv);
|
||||
}
|
||||
break;
|
||||
case T_METHOD_C:
|
||||
if (ce) {
|
||||
if (op_array && op_array->function_name) {
|
||||
ZVAL_STR(zv, zend_concat3(ce->name->val, ce->name->len, "::", 2,
|
||||
op_array->function_name->val, op_array->function_name->len));
|
||||
} else {
|
||||
ZVAL_STR(zv, STR_COPY(ce->name));
|
||||
}
|
||||
} else if (op_array && op_array->function_name) {
|
||||
ZVAL_STR(zv, STR_COPY(op_array->function_name));
|
||||
} else {
|
||||
ZVAL_EMPTY_STRING(zv);
|
||||
}
|
||||
break;
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
}
|
||||
}
|
||||
|
@ -964,7 +964,7 @@ scalar:
|
||||
| T_FILE { $$.u.ast = AST_ZVAL(&$1); }
|
||||
| T_DIR { $$.u.ast = AST_ZVAL(&$1); }
|
||||
| T_TRAIT_C { $$.u.ast = AST_ZVAL(&$1); }
|
||||
| T_METHOD_C { $$.u.ast = AST_ZVAL(&$1); }
|
||||
| T_METHOD_C { $$.u.ast = zend_ast_create_ex(0, ZEND_AST_MAGIC_CONST, T_METHOD_C); }
|
||||
| T_FUNC_C { $$.u.ast = zend_ast_create_ex(0, ZEND_AST_MAGIC_CONST, T_FUNC_C); }
|
||||
| T_NS_C { $$.u.ast = AST_ZVAL(&$1); }
|
||||
| T_CLASS_C
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1624,34 +1624,6 @@ NEWLINE ("\r"|"\n"|"\r\n")
|
||||
}
|
||||
|
||||
<ST_IN_SCRIPTING>"__METHOD__" {
|
||||
if (CG(active_class_entry)) {
|
||||
int len = 0;
|
||||
|
||||
if (CG(active_class_entry)->name) {
|
||||
len += CG(active_class_entry)->name->len;
|
||||
}
|
||||
if (CG(active_op_array) && CG(active_op_array)->function_name) {
|
||||
len += sizeof("::")-1;
|
||||
len += CG(active_op_array)->function_name->len;
|
||||
}
|
||||
ZVAL_NEW_STR(zendlval, STR_ALLOC(len, 0));
|
||||
len = 0;
|
||||
if (CG(active_class_entry)->name) {
|
||||
memcpy(Z_STRVAL_P(zendlval), CG(active_class_entry)->name->val, CG(active_class_entry)->name->len);
|
||||
len += CG(active_class_entry)->name->len;
|
||||
}
|
||||
if (CG(active_op_array) && CG(active_op_array)->function_name) {
|
||||
memcpy(Z_STRVAL_P(zendlval) + len, "::", sizeof("::")-1);
|
||||
len += sizeof("::")-1;
|
||||
memcpy(Z_STRVAL_P(zendlval) + len, CG(active_op_array)->function_name->val, CG(active_op_array)->function_name->len);
|
||||
len += CG(active_op_array)->function_name->len;
|
||||
}
|
||||
Z_STRVAL_P(zendlval)[len] = 0;
|
||||
} else if (CG(active_op_array) && CG(active_op_array)->function_name) {
|
||||
ZVAL_STR(zendlval, STR_COPY(CG(active_op_array)->function_name));
|
||||
} else {
|
||||
ZVAL_EMPTY_STRING(zendlval);
|
||||
}
|
||||
return T_METHOD_C;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user