refactor(php): 将平台检测和编译功能从CompilerBase迁移到Translator

- 从CompilerBase.php移除平台检测相关方法(detectPlatform, initializeNewArchitecture, setCppCompiler)
- 从CompilerBase.php移除代码格式化方法(formatCppCode)和save方法
- 从CompilerBase.php移除编译命令选项相关方法(getCompileCommandOptions等)
- 在Translator.php中新增平台检测方法(detectPlatform)
- 在Translator.php中新增代码格式化方法(formatCppCode)和save方法
- 在Translator.php中新增编译命令选项相关方法(getCompileCommandOptions等)
- 移除CompilerBase.php中未使用的SsaBuilder导入
- 在Translator.php中新增必要的平台和编译器工厂类导入
pull/1/head
韩天峰 3 months ago
parent 79d4c28c91
commit 96b4fefb58
  1. 9
      src/Php/Preprocessor.php
  2. 33
      tests/aot/type_hits/007.phpt

@ -269,7 +269,14 @@ class Preprocessor extends CompilerBase
if ($this->classDef->hasProperty($name)) {
$this->fatalError($param, "Duplicate property `{$name}`");
}
$propertyDef = new PropertyDef($name, $param->flags, $type, $default, $nullable);
// 将类型标准化为内部类型格式(如 array -> php::Array)
if ($type instanceof NodeAbstract) {
$dummyClass = '';
$propType = $this->parseTypeDecl($type, self::DECL_TYPE_OF_PROPERTY, $dummyClass);
} else {
$propType = $this->zendTypeMap[strtolower($type)] ?? self::TYPE_VAR;
}
$propertyDef = new PropertyDef($name, $param->flags, $propType, $default, $nullable);
$this->classDef->properties[$name] = $propertyDef;
}
if ($param->variadic) {

@ -0,0 +1,33 @@
--TEST--
type hits
--FILE--
<?php
class Foo {
public function __construct(
private array $stmts
) {
}
private function collectLabels(array $stmts): void
{
var_dump($stmts);
}
public function buildCfg(): void
{
$this->collectLabels($this->stmts);
}
}
function main()
{
$obj = new Foo(['Hello World']);
$obj->buildCfg();
}
?>
--EXPECT--
array(1) {
[0]=>
string(11) "Hello World"
}
Loading…
Cancel
Save