diff --git a/.run/SnowCompiler.run.xml b/.run/SnowCompiler.run.xml
index bdc5c7f..bd7a495 100644
--- a/.run/SnowCompiler.run.xml
+++ b/.run/SnowCompiler.run.xml
@@ -14,4 +14,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.run/build_project2tar.ps1.run.xml b/.run/build_project2tar.ps1.run.xml
index a360594..19c0a66 100644
--- a/.run/build_project2tar.ps1.run.xml
+++ b/.run/build_project2tar.ps1.run.xml
@@ -3,4 +3,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/jcnc/snow/compiler/ir/core/IRFunction.java b/src/main/java/org/jcnc/snow/compiler/ir/core/IRFunction.java
index 37c6b3e..c223c4f 100644
--- a/src/main/java/org/jcnc/snow/compiler/ir/core/IRFunction.java
+++ b/src/main/java/org/jcnc/snow/compiler/ir/core/IRFunction.java
@@ -6,10 +6,9 @@ import java.util.ArrayList;
import java.util.List;
/**
- * An intermediate-representation function (IRFunction).
+ * An intermediate‑representation function (IRFunction).
*
- *
For every source-level function we build one IRFunction that
- * records:
+ *
For every source‑level function we build one IRFunction that records:
*
*
the function’s name,
*
a list of IR instructions (the body),
@@ -27,12 +26,12 @@ public class IRFunction {
/** linear list of IR instructions */
private final List body = new ArrayList<>();
- /* ---------- virtual-register management ---------- */
+ /* ---------- virtual‑register management ---------- */
/** running counter for new virtual registers */
private int regCounter = 0;
- /** list of formal-parameter registers in declaration order */
+ /** list of formal‑parameter registers in declaration order */
private final List parameters = new ArrayList<>();
/* ---------- construction ---------- */
@@ -43,7 +42,7 @@ public class IRFunction {
/* ---------- register helpers ---------- */
- /** Allocates and returns a brand-new virtual register. */
+ /** Allocates and returns a brand‑new virtual register. */
public IRVirtualRegister newRegister() {
return new IRVirtualRegister(regCounter++);
}
@@ -51,7 +50,7 @@ public class IRFunction {
/* ---------- parameter helpers ---------- */
/**
- * Adds a virtual register to the formal-parameter list.
+ * Adds a virtual register to the formal‑parameter list.
* Call this once for each parameter in declaration order
* when building the IR.
*/
@@ -79,9 +78,21 @@ public class IRFunction {
/* ---------- debugging ---------- */
- @Override public String toString() {
- StringBuilder sb = new StringBuilder("func " + name + " {\n");
+ @Override
+ public String toString() {
+ // Print function header with explicit parameter list: func name(%0, %1) {
+ StringBuilder sb = new StringBuilder("func ")
+ .append(name)
+ .append('(');
+ for (int i = 0; i < parameters.size(); i++) {
+ sb.append(parameters.get(i));
+ if (i < parameters.size() - 1) sb.append(", ");
+ }
+ sb.append(") {\n");
+
+ // Body instructions indented by two spaces
body.forEach(i -> sb.append(" ").append(i).append('\n'));
+
return sb.append('}').toString();
}
}
diff --git a/test b/test
index 835f755..7d48f42 100644
--- a/test
+++ b/test
@@ -1,14 +1,12 @@
module: CommonTasks
- function: main1
+ function: main
parameter:
- declare num1: int
- declare num2: int
+
return_type:int
body:
- num1 = 1
- num2=2
- return num1 + CommonTasks.test(3,4+1)
+
+ return CommonTasks.test(3,1)
end body
end function
@@ -19,8 +17,8 @@ module: CommonTasks
return_type:int
body:
declare result : int
- declare num3: int =4
- result = num1 + num2 +num3
+
+ result = num1 + num2
return result
end body
end function