fix: 部分代码嵌套模式数不正确的问题
This commit is contained in:
parent
43fd1d175d
commit
237c35f0a0
@ -66,12 +66,12 @@ public class StatementBuilder {
|
|||||||
buildIf(ifNode);
|
buildIf(ifNode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stmt instanceof ExpressionStatementNode(ExpressionNode exp)) {
|
if (stmt instanceof ExpressionStatementNode(ExpressionNode exp, _, _, _)) {
|
||||||
// 纯表达式语句,如 foo();
|
// 纯表达式语句,如 foo();
|
||||||
expr.build(exp);
|
expr.build(exp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stmt instanceof AssignmentNode(String var, ExpressionNode rhs)) {
|
if (stmt instanceof AssignmentNode(String var, ExpressionNode rhs, _, _, _)) {
|
||||||
// 赋值语句,如 a = b + 1;
|
// 赋值语句,如 a = b + 1;
|
||||||
|
|
||||||
final String type = ctx.getScope().lookupType(var);
|
final String type = ctx.getScope().lookupType(var);
|
||||||
@ -208,7 +208,10 @@ public class StatementBuilder {
|
|||||||
if (cond instanceof BinaryExpressionNode(
|
if (cond instanceof BinaryExpressionNode(
|
||||||
ExpressionNode left,
|
ExpressionNode left,
|
||||||
String operator,
|
String operator,
|
||||||
ExpressionNode right
|
ExpressionNode right,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_
|
||||||
)
|
)
|
||||||
&& ComparisonUtils.isComparisonOperator(operator)) {
|
&& ComparisonUtils.isComparisonOperator(operator)) {
|
||||||
|
|
||||||
|
|||||||
@ -51,8 +51,8 @@ public class CallExpressionAnalyzer implements ExpressionAnalyzer<CallExpression
|
|||||||
ExpressionNode callee = call.callee();
|
ExpressionNode callee = call.callee();
|
||||||
|
|
||||||
// 支持模块调用形式:ModuleName.FunctionName(...)
|
// 支持模块调用形式:ModuleName.FunctionName(...)
|
||||||
if (callee instanceof MemberExpressionNode(var obj, String member)
|
if (callee instanceof MemberExpressionNode(var obj, String member, _, _, _)
|
||||||
&& obj instanceof IdentifierNode(String mod)) {
|
&& obj instanceof IdentifierNode(String mod, _, _, _)) {
|
||||||
// 验证模块是否存在并已导入
|
// 验证模块是否存在并已导入
|
||||||
if (!ctx.getModules().containsKey(mod)
|
if (!ctx.getModules().containsKey(mod)
|
||||||
|| (!mi.getImports().contains(mod) && !mi.getName().equals(mod))) {
|
|| (!mi.getImports().contains(mod) && !mi.getName().equals(mod))) {
|
||||||
@ -65,7 +65,7 @@ public class CallExpressionAnalyzer implements ExpressionAnalyzer<CallExpression
|
|||||||
functionName = member;
|
functionName = member;
|
||||||
|
|
||||||
// 简单函数名形式:func(...)
|
// 简单函数名形式:func(...)
|
||||||
} else if (callee instanceof IdentifierNode(String name)) {
|
} else if (callee instanceof IdentifierNode(String name, _, _, _)) {
|
||||||
functionName = name;
|
functionName = name;
|
||||||
|
|
||||||
// 不支持的 callee 形式
|
// 不支持的 callee 形式
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user