Johan Rong 1 день назад
Родитель
Сommit
b5335264d8

+ 3 - 3
examples/testing/src/main.zk

@@ -10,12 +10,12 @@
     )
     )
 }
 }
 
 
-fn test(x: i64) -> i64 {
-    return 6 + x
+fn add(a: i64, b: i64) -> i64 {
+    return 0 + a + b
 }
 }
 
 
 fn main() -> void {
 fn main() -> void {
-    val test: i64 = test(12)
+    val test: i64 = add(3, 5)
     #print_i64(test)
     #print_i64(test)
     #print_i64(test + 1)
     #print_i64(test + 1)
     return
     return

+ 1 - 2
src/zelkelc/codegen/codegen.py

@@ -205,11 +205,10 @@ class Codegen:
                 sys.exit(1)
                 sys.exit(1)
 
 
     def get_function_args_llvm(self, node: types.FunctionCall) -> tuple[str, str]:
     def get_function_args_llvm(self, node: types.FunctionCall) -> tuple[str, str]:
-        print(node.args)
-
         ir = ""
         ir = ""
         args_str = ""
         args_str = ""
         for i, arg in enumerate(node.args):
         for i, arg in enumerate(node.args):
+            print(arg)
             if i != 0:
             if i != 0:
                 args_str += ", "
                 args_str += ", "
             count, arg_ir = self.gen_expression(arg)
             count, arg_ir = self.gen_expression(arg)

+ 2 - 1
src/zelkelc/validator/scope.py

@@ -107,6 +107,7 @@ class Scope:
         current: Scope | None = self
         current: Scope | None = self
         while current is not None:
         while current is not None:
             overloads = current.functions.get(name)
             overloads = current.functions.get(name)
+            print(overloads)
             if overloads:
             if overloads:
                 for candidate in overloads:
                 for candidate in overloads:
                     if list(candidate.args.values()) == arg_types:
                     if list(candidate.args.values()) == arg_types:
@@ -383,7 +384,7 @@ class ScopeChecker:
 
 
     def _infer_expression_type(
     def _infer_expression_type(
         self, expr: types.Expression, active_scope: Scope
         self, expr: types.Expression, active_scope: Scope
-    ) -> Optional[type[types.Integer64] | type[types.String] | type[types.Void]]:
+    ) -> type[types.Integer64 | types.String | types.Void] | None:
         match expr:
         match expr:
             case types.PrimaryExpression(types.Integer64()):
             case types.PrimaryExpression(types.Integer64()):
                 return types.Integer64
                 return types.Integer64

+ 2 - 2
src/zelkelc/validator/validator.py

@@ -1,7 +1,7 @@
 from __future__ import annotations
 from __future__ import annotations
 
 
-import src.zelkelc.ast.types as types
-import src.zelkelc.validator.scope as scope
+from src.zelkelc.ast import types
+from src.zelkelc.validator import scope
 
 
 
 
 class SemanticCheckFailed(Exception):
 class SemanticCheckFailed(Exception):