diff options
| -rw-r--r-- | examples/mathTest.nya | 12 | ||||
| -rw-r--r-- | src/codegen.zig | 3 | ||||
| -rw-r--r-- | std.c | 1 |
3 files changed, 8 insertions, 8 deletions
diff --git a/examples/mathTest.nya b/examples/mathTest.nya index f937b79..14e7f0a 100644 --- a/examples/mathTest.nya +++ b/examples/mathTest.nya @@ -6,13 +6,13 @@ fn test() -> i32 { } fn main() -> i32 { - const: i32 num = 5; + const: i32 num = 5 + 3 * 7; const: i32 num2 = test(); - if (num2 == test()) { + if (num2 == test()) puts("Hello World!"); - } - if (num2 == 0) { + + if (num2 == 0) puts("Shouldn't print"); - } - return num2; + + return num; } diff --git a/src/codegen.zig b/src/codegen.zig index 7aff0b6..9fb09cb 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -12,6 +12,7 @@ const CodegenError = error{ OutOfMemory, IncorrectType, UnknownIdentifier, + Unimplemented, }; fn toLLVMtype(typ: parse.TypeIdent, sym: *symb.SymbolTable, expr: ?parse.NodeExpr) types.LLVMTypeRef { @@ -270,7 +271,7 @@ pub const Generator = struct { .star => core.LLVMBuildMul(self.builder, lhs, rhs, "mul"), .slash => core.LLVMBuildSDiv(self.builder, lhs, rhs, "div"), .eqleql => core.LLVMBuildICmp(self.builder, types.LLVMIntPredicate.LLVMIntEQ, lhs, rhs, "eql"), - else => core.LLVMBuildICmp(self.builder, types.LLVMIntPredicate.LLVMIntEQ, lhs, rhs, "eql"), + else => return error.Unimplemented, }; }, .stringLit => |str| blk: { @@ -1,2 +1 @@ -int subtract(int a, int b) { return a - b; } int add(int a, int b) { return a + b; } |
