From caa62b0bfbbf676c6075016073f62e4939409c67 Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 26 Aug 2025 18:08:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=A7=81=E6=9C=89=E5=87=BD=E6=95=B0=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增规则:以"_"开头的函数名只允许在本模块访问,禁止跨模块访问 - 在 CallExpressionAnalyzer 中实现该规则的检查逻辑 --- .../expression/CallExpressionAnalyzer.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/jcnc/snow/compiler/semantic/analyzers/expression/CallExpressionAnalyzer.java b/src/main/java/org/jcnc/snow/compiler/semantic/analyzers/expression/CallExpressionAnalyzer.java index 250e12e..c71f54a 100644 --- a/src/main/java/org/jcnc/snow/compiler/semantic/analyzers/expression/CallExpressionAnalyzer.java +++ b/src/main/java/org/jcnc/snow/compiler/semantic/analyzers/expression/CallExpressionAnalyzer.java @@ -25,6 +25,7 @@ import java.util.List; *
  • 支持数值参数的宽化转换(如 int → double);
  • *
  • 支持数值到字符串的隐式转换(自动视为调用 {@code to_string});
  • *
  • 在发生类型不匹配、未导入模块或函数未定义等情况下记录语义错误。
  • + *
  • 新增:以"_"开头的函数名只允许在本模块访问,禁止跨模块访问。
  • * */ public class CallExpressionAnalyzer implements ExpressionAnalyzer { @@ -64,20 +65,32 @@ public class CallExpressionAnalyzer implements ExpressionAnalyzer Date: Tue, 26 Aug 2025 18:09:01 +0800 Subject: [PATCH 2/3] =?UTF-8?q?test:=20=E6=B7=BB=E5=8A=A0=20Demo25=20?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playground/Demo/Demo25/Main.snow | 23 +++++++++++++++++++++++ playground/Demo/Demo25/OS.snow | 11 +++++++++++ 2 files changed, 34 insertions(+) create mode 100644 playground/Demo/Demo25/Main.snow create mode 100644 playground/Demo/Demo25/OS.snow diff --git a/playground/Demo/Demo25/Main.snow b/playground/Demo/Demo25/Main.snow new file mode 100644 index 0000000..d83e6a4 --- /dev/null +++ b/playground/Demo/Demo25/Main.snow @@ -0,0 +1,23 @@ +module: Main + import: os,ModuleA + globals: + declare c: int = 10 + function: main + returns: void + body: + c = ModuleA.getA() + os.print(c) + end body + end function +end module + +module: ModuleA + globals: + declare a: int = 2 + function: getA + returns: int + body: + return a + end body + end function +end module diff --git a/playground/Demo/Demo25/OS.snow b/playground/Demo/Demo25/OS.snow new file mode 100644 index 0000000..1982627 --- /dev/null +++ b/playground/Demo/Demo25/OS.snow @@ -0,0 +1,11 @@ +module: os + import: os + function: print + params: + declare i1: int + returns: void + body: + syscall("PRINT",i1) + end body + end function +end module \ No newline at end of file -- Gitee From 19e473e93c118e06ddc71389a998b6b190cd7a74 Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 26 Aug 2025 18:09:15 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0=20Demo25?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .run/Demo25.run.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .run/Demo25.run.xml diff --git a/.run/Demo25.run.xml b/.run/Demo25.run.xml new file mode 100644 index 0000000..95ec15e --- /dev/null +++ b/.run/Demo25.run.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file -- Gitee