diff options
-rw-r--r-- | parse.c | 4 | ||||
-rw-r--r-- | test.toc | 15 | ||||
-rw-r--r-- | types.h | 2 |
3 files changed, 5 insertions, 16 deletions
@@ -1380,9 +1380,7 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) { ++t->token; Type *fn_t = &fn->foreign.type; fn_t->kind = TYPE_FN; - FnType *fn_type = fn_t->fn = parser_malloc(p, sizeof *fn_t); - fn_type->constness = NULL; - fn_type->types = NULL; + FnType *fn_type = fn_t->fn = parser_calloc(p, 1, sizeof *fn_type); /* reserve space for return type (Type + CType) */ parser_arr_add_ptr(p, fn_type->types); parser_arr_add_ptr(p, fn->foreign.ctypes); @@ -1,13 +1,4 @@ -#include "std/io.toc", io; -#include "std/mem.toc"; - -main ::= fn() { - file, err := io.fopen_write("test.txt"); - - for i := 0.,1000000 { - io.fputs(file, "!"); - } - - io.fclose(file); +n ::= nms { + putchar ::= #foreign("putchar") fn(#C int) #C int; } -main(); +main ::= fn(){} @@ -648,11 +648,11 @@ enum { typedef struct FnExpr { Location where; Block *declaration_block; /* block wherein this function is declared */ + U64 instance_id; /* 0 if not an instance. needs to be available even for #foreign functions */ union { struct { struct Declaration *params; /* declarations of the parameters to this function */ struct Declaration *ret_decls; /* array of decls, if this has named return values. otherwise, NULL */ - U64 instance_id; /* 0 if not an instance */ Type ret_type; Block body; }; |