diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index df0f3539..312b60cf 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -33,7 +33,7 @@ class CompilerBase extends \PhpAot\Core\Translator public const string TYPE_OBJECT = 'php::Object'; public const string TYPE_ARRAY = 'php::Array'; public const string TYPE_STR = 'php::Str'; - public const string TYPE_REF = 'php::Var'; + public const string TYPE_REF = 'php::Ref'; public const string TYPE_VOID = 'void'; public const string VALUE_NAN = 'std::numeric_limits::quiet_NaN()'; @@ -1493,8 +1493,7 @@ class CompilerBase extends \PhpAot\Core\Translator $tmpVar = $this->genTmpVarName(); $this->addLocalVar($tmpVar, self::TYPE_REF); $this->beforeStmtLines[] = $tmpVar . ' = ' . $this->parseExpr($arg->value) . '.toReference();'; - $this->afterStmtLines[] = $name . ' = *' . $tmpVar . ';'; - $list_args[] = $tmpVar; + $list_args[] = '&' . $tmpVar; continue; } } elseif ($this->isPropertyFetch($arg->value)) { @@ -1539,7 +1538,7 @@ class CompilerBase extends \PhpAot\Core\Translator $this->afterStmtLines[] = 'php::setStaticProperty(' . $class . ', ' . $prop . ', ' . $tmpVar . ' ' . $op . ' 1);'; return $tmpVar; } - $this->parsePostOp($expr, "Post-increment operator is not supported for non-variable expressions"); + $this->fatalError($expr, "Post-increment operator is not supported for non-variable expressions"); } protected function parsePostDec($expr): string @@ -2394,10 +2393,10 @@ class CompilerBase extends \PhpAot\Core\Translator if ($this->isVarExpr($expr->var)) { $var = $this->parseIdentifier($expr->var); if (!$this->hasVar($var)) { - $this->addLocalVar($var, self::TYPE_VAR); + $this->addLocalVar($var, self::TYPE_REF); } if ($this->isVarExpr($expr->expr)) { - return $var . ' = &' . $this->parseIdentifier($expr->expr); + return $var . ' = ' . $this->parseIdentifier($expr->expr) . '.toReference()'; } elseif ($expr->expr->getType() === self::EXPR_ARRAY_DIM_FETCH) { return $var . ' = ' . $this->parseIdentifier($expr->expr); } elseif ($this->isPropertyFetch($expr->expr)) { diff --git a/tests/aot/ref.phpt b/tests/aot/ref.phpt new file mode 100644 index 00000000..5b6714cd --- /dev/null +++ b/tests/aot/ref.phpt @@ -0,0 +1,19 @@ +--TEST-- +object link operator +--FILE-- + +--EXPECT--