diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 614245b0..42dc99e5 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -216,6 +216,14 @@ class CompilerBase extends \PhpAot\Core\Translator 'phpx_big_float.h', 'phpx_decimal.h', 'php_aot_helper.h', + 'php_std_core.h', + 'php_std_url.h', + 'php_std_string.h', + 'php_std_misc.h', + 'php_std_array.h', + 'php_std_datetime.h', + 'php_std_fs.h', + 'php_std_math.h', ]; protected array $localHeaders = []; protected array $internalFunctions = []; diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 22d5a79a..84b9e016 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -972,6 +972,16 @@ CODE; // 生成扩展模块的源文件 $sourceFiles[] = $this->genExtension(); + // stdlib: 直接 C++ 包装的 Zend 内置函数 + $sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_core.cpp'; + $sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_array.cpp'; + $sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_string.cpp'; + $sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_url.cpp'; + $sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_datetime.cpp'; + $sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_fs.cpp'; + $sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_math.cpp'; + $sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_misc.cpp'; + // embed 需要 main 函数,以及 cli 的内置函数定义 if ($this->isBuildModeBin()) { $sourceFiles[] = $this->getPhpxDir() . '/src/misc/main.cc'; diff --git a/src/Php/UniversalMethodCall.php b/src/Php/UniversalMethodCall.php index 6e20f390..0bb75f0e 100644 --- a/src/Php/UniversalMethodCall.php +++ b/src/Php/UniversalMethodCall.php @@ -90,7 +90,7 @@ trait UniversalMethodCall 'trim' => ['handler' => 'php_fn', 'fn' => 'trim', 'return_type' => CompilerBase::TYPE_STR, 'min_args' => 0, 'max_args' => 2], 'lTrim' => ['handler' => 'php_fn', 'fn' => 'ltrim', 'return_type' => CompilerBase::TYPE_STR, 'min_args' => 0, 'max_args' => 1], 'rTrim' => ['handler' => 'php_fn', 'fn' => 'rtrim', 'return_type' => CompilerBase::TYPE_STR, 'min_args' => 0, 'max_args' => 1], - 'parseStr' => ['handler' => 'cpp_fn', 'fn' => 'php::fn::parse_str', 'return_type' => CompilerBase::TYPE_ARRAY, 'min_args' => 0, 'max_args' => 0], + 'parseStr' => ['handler' => 'cpp_fn', 'fn' => 'php::std::parse_str', 'return_type' => CompilerBase::TYPE_ARRAY, 'min_args' => 0, 'max_args' => 0], 'parseUrl' => ['handler' => 'php_fn', 'fn' => 'parse_url', 'return_type' => CompilerBase::TYPE_VAR, 'min_args' => 0, 'max_args' => 1], 'contains' => ['handler' => 'php_fn', 'fn' => 'str_contains', 'return_type' => CompilerBase::TYPE_BOOL, 'min_args' => 1, 'max_args' => 1], 'incr' => ['handler' => 'php_fn', 'fn' => 'str_increment', 'return_type' => CompilerBase::TYPE_STR, 'min_args' => 0, 'max_args' => 0],