- 新增 src/compiler-build.php 作为编译器入口文件 - 在 extension.cc.php 中添加 zend 异常处理保护机制 - 更新 project.yml 将项目类型从 ext 改为 bin,版本升级到 0.1.0 - 添加新的依赖文件路径到项目配置中 - 在 Php/Symbol.php 中添加 getClassEntrySafe 方法 - 修改 Php/Translator.php 使用安全的类入口获取方法 - 修复 __toString 方法的返回类型声明 - 添加 examples/error/impl.php 示例文件pull/1/head
parent
f8e1c771e4
commit
9744cc9e86
7 changed files with 62 additions and 14 deletions
@ -0,0 +1,12 @@ |
||||
<?php |
||||
class Foo implements InterfaceA { |
||||
public function foo() |
||||
{ |
||||
return "foo"; |
||||
} |
||||
} |
||||
function main() |
||||
{ |
||||
$o = new Foo; |
||||
echo $o->foo(); |
||||
} |
||||
@ -0,0 +1,26 @@ |
||||
<?php |
||||
use PhpAot\Php\Translator; |
||||
|
||||
function main(int $argc, array $argv): void |
||||
{ |
||||
define("ROOT_PATH", getcwd()); |
||||
define('DEBUG', true); |
||||
|
||||
require ROOT_PATH . '/vendor/autoload.php'; |
||||
|
||||
if (empty($argv[1])) { |
||||
die("php compiler.php [file]\n"); |
||||
} |
||||
|
||||
$path = $argv[1]; |
||||
$translator = new Translator(ROOT_PATH); |
||||
$translator->setIndent(' '); |
||||
// 扫描所有 PHP 文件,预处理 |
||||
$files = $translator->prepare($path); |
||||
// 生成 C++ 文件 |
||||
$sourceFiles = $translator->convert($files); |
||||
// 编译所有 C++ 文件 |
||||
$objectFiles = $translator->compile($sourceFiles); |
||||
// 连接所有目标文件,生成可执行文件 |
||||
$translator->build($objectFiles); |
||||
} |
||||
Loading…
Reference in new issue