From 2bc938b62a27c52666c2ac6787c468b66aa21553 Mon Sep 17 00:00:00 2001 From: A404M Date: Sun, 1 Jun 2025 01:05:15 +0330 Subject: add println fix @neg type --- code/lib/io.felan | 9 +++++++++ code/main.felan | 10 +--------- src/runner/runner.c | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/code/lib/io.felan b/code/lib/io.felan index ff697e2..c486902 100644 --- a/code/lib/io.felan +++ b/code/lib/io.felan @@ -5,6 +5,15 @@ libc :: @c_library("/usr/lib/libc.so.6"); puts :: @c_function(libc,"puts",(*u8)->i32); putchar :: @c_function(libc,"putchar",(i32)->void); +println :: () -> void { + print_char('\n'); +}; + +println :: (value:anytype) -> void { + print(value); + print_char('\n'); +}; + print :: (value:string) -> void { i := 0; while i < @cast(value.length,i64) { diff --git a/code/main.felan b/code/main.felan index f420f64..fca48b0 100644 --- a/code/main.felan +++ b/code/main.felan @@ -1,14 +1,6 @@ @import("basic.felan"); -st :: struct { -}; - -__get_item__ :: (left:st,index:i64,index2:i64)->i64{ - return index+index2; -}; - main :: () -> void { - a := "abcdef"; - print(a); + println(@cast(-1,i32)); }; diff --git a/src/runner/runner.c b/src/runner/runner.c index d493236..23b6d7e 100644 --- a/src/runner/runner.c +++ b/src/runner/runner.c @@ -303,7 +303,7 @@ AstTree *runAstTreeBuiltin(AstTree *tree, AstTreeScope *scope, default: UNREACHABLE; } - return newAstTree(AST_TREE_TOKEN_RAW_VALUE, ret, copyAstTree(left), NULL, + return newAstTree(AST_TREE_TOKEN_RAW_VALUE, ret, copyAstTree(left->type), NULL, NULL); } case AST_TREE_TOKEN_BUILTIN_ADD: { @@ -2345,7 +2345,7 @@ AstTree *castTo(AstTree *tree, AstTree *to) { case AST_TREE_TOKEN_TYPE_C_LIBRARY: case AST_TREE_TOKEN_TYPE_C_FUNCTION: } - printLog("%s", AST_TREE_TOKEN_STRINGS[tree->token]); + printLog("%s", AST_TREE_TOKEN_STRINGS[tree->type->token]); UNREACHABLE; } -- cgit v1.2.3