diff options
Diffstat (limited to 'src/lower.c')
| -rw-r--r-- | src/lower.c | 17 | 
1 files changed, 16 insertions, 1 deletions
| diff --git a/src/lower.c b/src/lower.c index 35d16fe..4b9fae9 100644 --- a/src/lower.c +++ b/src/lower.c @@ -123,6 +123,11 @@ static int lower_type_construct(struct type *type)  static int lower_type_callable(struct type *type)  { +	/* std::function has a slight overhead compared to just using auto here, +	 * but auto doesn't play well with recursive templates like with our +	 * fib.fwd example, so use std::function for now. Eventually I might +	 * instead write a C backend or something to have more control over the +	 * exact semantics, but for now this is good enough. */  	printf("std::function<void(");  	if (lower_types(tcallable_args(type))) @@ -317,8 +322,10 @@ static int lower_if(struct state *state, struct ast *stmt)  	if (lower_block(state, if_body(stmt)))  		return -1; -	if (!if_else(stmt)) +	if (!if_else(stmt)) { +		printf("\n");  		return 0; +	}  	printf(" else ");  	if (lower_block(state, if_else(stmt))) @@ -403,6 +410,11 @@ static int lower_closure(struct state *state, struct ast *closure)  static int lower_proto(struct ast *proc)  { +	/* 'extern' functions should be provided to us by whatever framework the +	 * user is using */ +	if (!proc_body(proc)) +		return 0; +  	if (strcmp("main", proc_id(proc)) == 0)  		printf("int ");  	else @@ -419,6 +431,9 @@ static int lower_proto(struct ast *proc)  static int lower_proc(struct ast *proc)  { +	if (!proc_body(proc)) +		return 0; +  	if (strcmp("main", proc_id(proc)) == 0)  		printf("int ");  	else | 
