summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 2a8980f23b..c8f2eefa7d 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1830,6 +1830,28 @@ zend_ast *zend_ast_append_str(zend_ast *left_ast, zend_ast *right_ast) /* {{{ */
}
/* }}} */
+zend_ast *zend_negate_num_string(zend_ast *ast) /* {{{ */
+{
+ zval *zv = zend_ast_get_zval(ast);
+ if (Z_TYPE_P(zv) == IS_LONG) {
+ if (Z_LVAL_P(zv) == 0) {
+ ZVAL_NEW_STR(zv, zend_string_init("-0", sizeof("-0")-1, 0));
+ } else {
+ ZEND_ASSERT(Z_LVAL_P(zv) > 0);
+ Z_LVAL_P(zv) *= -1;
+ }
+ } else if (Z_TYPE_P(zv) == IS_STRING) {
+ size_t orig_len = Z_STRLEN_P(zv);
+ zend_string_extend(Z_STR_P(zv), orig_len + 1, 0);
+ memmove(Z_STRVAL_P(zv) + 1, Z_STRVAL_P(zv), orig_len + 1);
+ Z_STRVAL_P(zv)[0] = '-';
+ } else {
+ ZEND_ASSERT(0);
+ }
+ return ast;
+}
+/* }}} */
+
void zend_verify_namespace(void) /* {{{ */
{
if (FC(has_bracketed_namespaces) && !FC(in_namespace)) {