fix(php): 更新库文件引用和类型检查消息生成

- 将 libmpdec.lib 和 libmpdec++.lib 替换为带版本号的 libmpdec-4.0.1.dll.lib 和 libmpdec++-4.0.1.dll.lib
- 修改类型检查错误消息中的字符串拼接方式,使用 genCharPtr 方法处理函数名和类型字符串
- 修复返回值类型检查消息的字符串构造逻辑
pull/1/head
韩天峰 3 months ago
parent c7c9a8e263
commit c9d92e4581
  1. 4
      src/Php/CompilerBase.php
  2. 8
      src/Php/Generator/TypeCheckGenerator.php

@ -2202,8 +2202,8 @@ class CompilerBase extends \PhpAot\Core\Translator
$libraries[] = 'gmp.lib';
$libraries[] = 'gmpxx.lib';
$libraries[] = 'mpfr.lib';
$libraries[] = 'libmpdec.lib';
$libraries[] = 'libmpdec++.lib';
$libraries[] = 'libmpdec-4.0.1.dll.lib';
$libraries[] = 'libmpdec++-4.0.1.dll.lib';
} else {
// Linux/macOS: extension 和 bin 模式都需要添加 php 库
$libraries[] = 'php';

@ -139,8 +139,8 @@ trait TypeCheckGenerator
$orExpr = implode(' || ', $conditions);
$fnName = $this->functionDef->getNamespacedName();
$msgExpr = 'php::concat(php::concat(php::Str("' . $fnName . '(): Argument #' . ($argIndex + 1)
. ' ($' . $varName . ') must be of type ' . $argInfo->typeStr . ', "), '
$msgExpr = 'php::concat(php::concat(php::Str(' . $this->genCharPtr($fnName, true) . ' "(): Argument #' . ($argIndex + 1)
. ' ($' . $varName . ') must be of type " ' . $this->genCharPtr($argInfo->typeStr, true) . ' ", "), '
. $varName . '.typeStr()), php::Str(" given"))';
$code = $this->getIndent() . 'if (UNEXPECTED(!(' . $orExpr . '))) {' . PHP_EOL;
@ -174,8 +174,8 @@ trait TypeCheckGenerator
$fnName = $this->functionDef->getNamespacedName();
$typeStr = $this->functionDef->returnTypeStr;
$msgExpr = 'php::concat(php::concat(php::Str("' . $fnName . '(): Return value must be of type '
. $typeStr . ', "), ' . $varName . '.typeStr()), php::Str(" given"))';
$msgExpr = 'php::concat(php::concat(php::Str(' . $this->genCharPtr($fnName, true) . ' "(): Return value must be of type " '
. $this->genCharPtr($typeStr, true) . ' ", "), ' . $varName . '.typeStr()), php::Str(" given"))';
$code = $this->getIndent() . 'if (UNEXPECTED(!(' . $orExpr . '))) {' . PHP_EOL;
$this->indentLevel++;

Loading…
Cancel
Save