diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index ff53f32..3e680f9 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,8 +7,13 @@
-
+
+
+
+
+
+
@@ -152,7 +157,7 @@
-
+
@@ -330,7 +335,15 @@
1717794101530
-
+
+
+ 1717794233364
+
+
+
+ 1717794233364
+
+
@@ -362,6 +375,7 @@
-
+
+
\ No newline at end of file
diff --git a/build/out.asm b/build/out.asm
index b8b4c39..556c2a7 100644
--- a/build/out.asm
+++ b/build/out.asm
@@ -2,20 +2,6 @@
section .text
-_1:
- push rbp
- mov rbp, rsp
-
- mov rax, qword [rbp+16]
- mov qword [rbp-8], rax
- mov rax, qword [rbp+24]
- mov qword [rbp-16], rax
- mov rax, qword [rbp-8]
- add rax, qword [rbp-16]
- mov qword [rbp+32], rax
- leave
- ret
-
main:
push rbp
mov rbp, rsp
@@ -35,3 +21,41 @@ main:
leave
ret
+_1:
+ push rbp
+ mov rbp, rsp
+
+ mov rax, qword [rbp+16]
+ mov qword [rbp-8], rax
+ mov rax, qword [rbp+24]
+ mov qword [rbp-16], rax
+ mov rax, qword [rbp-8]
+ mov qword [rbp-40], rax
+ mov rax, qword [rbp-16]
+ mov qword [rbp-48], rax
+ sub rsp, 48
+ call _2
+ add rsp, 48
+ mov rax, qword [rbp-32]
+ mov qword [rbp+32], rax
+ leave
+ ret
+
+_2:
+ push rbp
+ mov rbp, rsp
+
+ mov rax, qword [rbp+16]
+ mov qword [rbp-16], rax
+ mov rax, qword [rbp+24]
+ mov qword [rbp-24], rax
+ mov rax, qword [rbp-16]
+ add rax, qword [rbp-24]
+ mov qword [rbp-8], rax
+ mov qword [rbp-32], 1
+ mov rax, qword [rbp-8]
+ add rax, qword [rbp-32]
+ mov qword [rbp+32], rax
+ leave
+ ret
+
diff --git a/build/out.o b/build/out.o
index 067be45..38cd473 100644
Binary files a/build/out.o and b/build/out.o differ
diff --git a/build/out.out b/build/out.out
index a8496cf..01b4f88 100755
Binary files a/build/out.out and b/build/out.out differ
diff --git a/main.why b/main.why
index af803de..09c2ada 100644
--- a/main.why
+++ b/main.why
@@ -1,7 +1,10 @@
-
impl int {
fn sub(lhs: int, rhs: int) -> int {
- return lhs + rhs + rhs;
+ return lhs == rhs;
+ }
+
+ fn eq(lhs: int, rhs: int) -> int {
+ return lhs + rhs + 1;
}
}
diff --git a/src/root/compiler/compile_evaluable.rs b/src/root/compiler/compile_evaluable.rs
index 237cc90..53a03ba 100644
--- a/src/root/compiler/compile_evaluable.rs
+++ b/src/root/compiler/compile_evaluable.rs
@@ -217,7 +217,18 @@ pub fn compile_evaluable_type_only(
let tid = literal.literal().default_type();
TypeRef::new(tid.clone(), Indirection(0))
}
- EvaluableTokens::InfixOperator(_, _, _) => todo!(),
+ EvaluableTokens::InfixOperator(lhs, op, _) => {
+ if op.is_prefix_opt_t() {
+ return Err(WErr::n(EvalErrs::FoundPrefixNotInfixOp(op.operator().to_str().to_string()), op.location().clone()));
+ }
+
+ // let (mut code, lhs) = compile_evaluable(fid, lhs, local_variables, global_table, function_calls)?;
+ let lhs_type = compile_evaluable_type_only(fid, lhs, local_variables, global_table, function_calls)?;
+ // code += "\n";
+ let op_fn = global_table.get_operator_function(*lhs_type.type_id(), op)?;
+ let signature = global_table.get_function_signature(op_fn);
+ signature.return_type().as_ref().unwrap().clone()
+ },
EvaluableTokens::PrefixOperator(_, _) => todo!(),
EvaluableTokens::DynamicAccess(_, _) => todo!(), // Accessed methods must be called
EvaluableTokens::StaticAccess(_, n) => return Err(WErr::n(NRErrors::CannotFindConstantAttribute(n.name().clone()), n.location().clone())), // Accessed methods must be called
diff --git a/todo.txt b/todo.txt
new file mode 100644
index 0000000..aaec117
--- /dev/null
+++ b/todo.txt
@@ -0,0 +1,6 @@
+Add support for multiple functions with the same name but different signatures
+Allow operators to be both prefix and infix i.e. -a or a - b
+Fix evaluables such as (a + b) or (a + b) + c or a + b + c not working
+Add rich parser errors
+Add all errors in
+All other todos, of course
\ No newline at end of file