fixed failing tests

This commit is contained in:
Sven Vogel 2024-08-05 21:21:25 +02:00
parent 5fa5345dea
commit 57d80cda62
8 changed files with 55 additions and 53 deletions

View File

@ -89,7 +89,7 @@ void AST_init() {
lookup_table[AST_AddressOf] = "address of";
lookup_table[AST_Dereference] = "deref";
lookup_table[AST_Reference] = "ref";
lookup_table[AST_Reference] = "ret";
lookup_table[AST_Return] = "ret";
}
const char* AST_node_to_string(const struct AST_Node_t* node) {

View File

@ -9,7 +9,7 @@
Type* SET_function_get_return_type(Function* function) {
assert(NULL != function);
const Type* return_type = NULL;
Type* return_type = NULL;
switch (function->kind) {
case FunctionDeclarationKind:
@ -25,4 +25,6 @@ Type* SET_function_get_return_type(Function* function) {
if (NULL == return_type) {
ERROR("Function return type is nullptr");
}
return return_type;
}

View File

@ -65,27 +65,31 @@ def run_check_print_node():
34 typedef
35 box
36 fun
37 value
38 list
39 expr list
40 arg list
41 param list
42 stmt list
43 ident list
44 value
45 type
46 value
37 fun
38 fun
39 fun
40 value
41 list
42 expr list
43 arg list
44 param list
45 stmt list
46 ident list
47 value
48 value
49 -
50 parameter
48 type
49 value
50 value
51 value
52 parameter-declaration
53 address of
54 deref
55 ref
56 value
57 value
52 -
53 parameter
54 value
55 parameter-declaration
56 address of
57 deref
58 ref
59 value
60 value
61 ret
""" == p.stdout
@ -95,7 +99,7 @@ def run_check_print_graphviz():
info("creating temporary folder...")
if not os.path.exists("tmp"):
os.mkdir("tmp")
os.makedirs("tmp", exist_ok=True)
info("cleaning temporary folder...")

View File

@ -1,28 +1,27 @@
import "std"
fun cstrlen(in cstr: str)(out u32: len) {
fun u32:cstrlen(in cstr: str) {
u32: idx = 0 as u32
while !(str[idx] == 0) {
idx = idx + 1 as u32
}
len = idx
ret idx
}
fun printcstr(in cstr: msg) {
u32: len = 0 as u32
cstrlen(msg)(len)
u32: len = cstrlen(msg)
handle: stdout = 0 as u32
getStdoutHandle()(stdout)
handle: stdout = getStdoutHandle()
u32: written = 0 as u32
writeBytes(stdout, msg, len)(written)
writeBytes(stdout, msg, len)
}
fun main() {
fun int:main() {
cstr: msg = "Hello, world!\n"
printcstr(msg)
ret 0
}

View File

@ -1,28 +1,27 @@
import "std"
fun cstrlen(in cstr: str)(out u32: len) {
fun u32:cstrlen(in cstr: str) {
u32: idx = 0 as u32
while !(str[idx] == 0) {
idx = idx + 1 as u32
}
len = idx
ret idx
}
fun printcstr(in cstr: msg) {
u32: len = 0 as u32
cstrlen(msg)(len)
u32: len = cstrlen(msg)
handle: stdout = 0 as u32
getStdoutHandle()(stdout)
handle: stdout = getStdoutHandle()
u32: written = 0 as u32
writeBytes(stdout, msg, len)(written)
writeBytes(stdout, msg, len)
}
fun main() {
fun int:main() {
cstr: msg = "Hello, world!\n"
printcstr(msg)
ret 0
}

View File

@ -1,27 +1,25 @@
import "std"
fun cstrlen(in cstr: str)(out u32: len) {
fun u32:cstrlen(in cstr: str) {
u32: idx = 0 as u32
while !(str[idx] == 0) {
idx = idx + 1
idx = idx + 1 as u32
}
len = idx
ret idx
}
fun printcstr(in cstr: msg) {
u32: len = 0
cstrlen(msg)(len)
u32: len = cstrlen(msg)
handle: stdout = 0
getStdoutHandle()(stdout)
handle: stdout = getStdoutHandle()
u32: written = 0
writeBytes(stdout, msg, len)(written)
writeBytes(stdout, msg, len)
}
fun main() {
fun int:main() {
printcstr("Hello, world!\n")
ret 0
}

View File

@ -1,4 +1,4 @@
fun main(out int: ret) {
ret = 56 as int
fun int:main() {
ret 56 as int
}

View File

@ -22,7 +22,7 @@ def check_abort():
logging.basicConfig(level=logging.INFO)
p = subprocess.run(["./gsc", "compile"], capture_output=True, text=True)
p = subprocess.run(["./gsc", "compile", "foo.gsc"], capture_output=True, text=True)
assert p.returncode == 1