From 7294673a9889f968eef86930d4e09f47070439fc Mon Sep 17 00:00:00 2001 From: Kimplul Date: Tue, 9 Apr 2024 18:43:02 +0300 Subject: formatting --- src/actualize.c | 180 ++++++++++++++++++++++++++++++-------------------- src/ast.c | 202 +++++++++++++++++++++++++++++--------------------------- src/debug.c | 4 +- src/lower.c | 3 +- 4 files changed, 214 insertions(+), 175 deletions(-) (limited to 'src') diff --git a/src/actualize.c b/src/actualize.c index 39f3ae3..7f17fbc 100644 --- a/src/actualize.c +++ b/src/actualize.c @@ -46,15 +46,16 @@ static int actualize(struct act_state *state, struct scope *scope, struct ast *node); static int actualize_list(struct act_state *state, struct scope *scope, - struct ast *l); + struct ast *l); static int actualize_type(struct act_state *state, struct scope *scope, - struct type *node); + struct type *node); static int actualize_type_list(struct act_state *state, struct scope *scope, - struct type *node); + struct type *node); -static struct ast *actualized_scope_find_symbol(struct act_state *state, struct scope *scope, char *id) +static struct ast *actualized_scope_find_symbol(struct act_state *state, + struct scope *scope, char *id) { struct ast *exists = scope_find_symbol(scope, id); if (!exists) @@ -66,7 +67,8 @@ static struct ast *actualized_scope_find_symbol(struct act_state *state, struct return exists; } -static struct ast *actualized_scope_find_type(struct act_state *state, struct scope *scope, char *id) +static struct ast *actualized_scope_find_type(struct act_state *state, + struct scope *scope, char *id) { struct ast *exists = scope_find_symbol(scope, id); if (!exists) @@ -78,7 +80,9 @@ static struct ast *actualized_scope_find_type(struct act_state *state, struct sc return exists; } -static struct ast *actualized_file_scope_find_symbol(struct act_state *state, struct scope *scope, char *id) +static struct ast *actualized_file_scope_find_symbol(struct act_state *state, + struct scope *scope, + char *id) { struct ast *exists = file_scope_find_symbol(scope, id); if (!exists) @@ -90,7 +94,9 @@ static struct ast *actualized_file_scope_find_symbol(struct act_state *state, st return exists; } -static struct ast *actualized_file_scope_find_type(struct act_state *state, struct scope *scope, char *id) +static struct ast *actualized_file_scope_find_type(struct act_state *state, + struct scope *scope, + char *id) { struct ast *exists = file_scope_find_type(scope, id); if (!exists) @@ -241,7 +247,7 @@ static int push_goto(struct act_state *state, struct ast *got) } static struct ast *clone_defers(struct act_state *state, - struct act_stack *to) + struct act_stack *to) { struct act_stack *from = state->defer_stack; @@ -299,13 +305,14 @@ static void destroy_act_state(struct act_state *state) clear_gotos(state, NULL); } -static void type_mismatch(struct scope *scope, char *s, struct ast *node, struct type *a, struct type *b) +static void type_mismatch(struct scope *scope, char *s, struct ast *node, + struct type *a, struct type *b) { char *left_type = type_str(a); char *right_type = type_str(b); semantic_error(scope->fctx, node, - "%s: %s vs %s", - s, left_type, right_type); + "%s: %s vs %s", + s, left_type, right_type); free(left_type); free(right_type); } @@ -319,7 +326,7 @@ static int eval_const_if(struct scope *scope, struct ast *node) && ast_flags(node, AST_FLAG_CONST)); semantic_error(scope->fctx, node, - "const if unimplemented"); + "const if unimplemented"); return -1; } @@ -339,7 +346,7 @@ static int analyze_visibility(struct scope *scope, struct ast *node) const char *file = import_file(node); return process_file(&scope, (int)ast_flags(node, AST_FLAG_PUBLIC), - file); + file); } case AST_IF: { @@ -449,7 +456,8 @@ static int analyze_proc(struct scope *scope, struct ast *node) if (!rtype) proc_rtype(node) = void_type(); - struct type *callable = tgen_callable(NULL, proc_rtype(node), node->loc); + struct type *callable = tgen_callable(NULL, proc_rtype(node), + node->loc); foreach_node(p, params) { /* we must manually 'start' the chain **/ if (!callable_ptypes(callable)) { @@ -464,7 +472,7 @@ static int analyze_proc(struct scope *scope, struct ast *node) } static struct ast *analyze_type_expand(struct scope *scope, - struct ast *n) + struct ast *n) { assert(n->k == AST_TYPE_EXPAND); struct ast *trait = file_scope_find_type(scope, type_expand_id(n)); @@ -522,8 +530,8 @@ static int analyze_trait(struct scope *scope, struct ast *node) ast_set_flags(node, AST_FLAG_GENERIC); struct type *type = tgen_type(TYPE_TRAIT, NULL, NULL, - node, NULL, strdup(trait_id(node)), - node->loc); + node, NULL, strdup(trait_id(node)), + node->loc); /* copy body */ node->a2 = clone_ast(trait_raw_body(node)); @@ -693,7 +701,7 @@ static int replace_id(struct ast *body, struct ast *id, } static int actualize_macro_def(struct act_state *state, - struct scope *scope, struct ast *n) + struct scope *scope, struct ast *n) { UNUSED(state); /* macro bodies, arguments, etc aren't expanded upon until the macro is @@ -758,14 +766,16 @@ static int actualize_macro_expand(struct act_state *state, /* actualize the new content */ if (actualize(state, scope, macro_expand)) { - semantic_info(scope->fctx, macro_expand, "while expanding %s", id); + semantic_info(scope->fctx, macro_expand, "while expanding %s", + id); return -1; } return 0; } -static int simplify_refderef(struct act_state *state, struct scope *scope, struct ast *n) +static int simplify_refderef(struct act_state *state, struct scope *scope, + struct ast *n) { if (!is_unop(n)) return 0; @@ -784,7 +794,8 @@ static int simplify_refderef(struct act_state *state, struct scope *scope, struc return 0; } -static int maybe_ufcs(struct act_state *state, struct scope *scope, struct ast *call) +static int maybe_ufcs(struct act_state *state, struct scope *scope, + struct ast *call) { assert(call->k == AST_CALL); struct ast *dot = call_expr(call); @@ -823,7 +834,7 @@ static int actualize_call(struct act_state *state, if (expr->t->k != TYPE_CALLABLE) { char *tstr = type_str(expr->t); semantic_error(scope->fctx, call, "not a callable type: %s", - tstr); + tstr); free(tstr); return -1; } @@ -841,7 +852,8 @@ static int actualize_call(struct act_state *state, } if (!types_match(p, arg->t)) { - type_mismatch(scope, "argument type mismatch", arg, p, arg->t); + type_mismatch(scope, "argument type mismatch", arg, p, + arg->t); return -1; } @@ -915,7 +927,8 @@ static int actualize_proc(struct act_state *state, return -1; } - struct type *callable = tgen_callable(NULL, proc_rtype(proc), proc->loc); + struct type *callable = tgen_callable(NULL, proc_rtype(proc), + proc->loc); foreach_node(p, proc_params(proc)) { /* we must manually 'start' the chain **/ if (!callable_ptypes(callable)) { @@ -989,7 +1002,8 @@ static int actualize_binop(struct act_state *state, return -1; if (!types_match(left->t, right->t)) { - type_mismatch(scope, "op type mismatch", binop, left->t, right->t); + type_mismatch(scope, "op type mismatch", binop, left->t, + right->t); return -1; } @@ -1068,7 +1082,8 @@ static int actualize_id(struct act_state *state, * Either add in some syntax to distinguish procedure calls and * pointer calls or make procs and vars share the same namespace. * */ - struct ast *decl = actualized_file_scope_find_symbol(state, scope, id_str(id)); + struct ast *decl = actualized_file_scope_find_symbol(state, scope, + id_str(id)); if (!decl) { semantic_error(scope->fctx, id, "no such symbol"); return -1; @@ -1097,7 +1112,8 @@ static int actualize_var(struct act_state *state, if (init && type) { /* make sure the asked type and the actualized types match */ if (!types_match(init->t, type)) { - type_mismatch(scope, "var type mismatch", var, init->t, type); + type_mismatch(scope, "var type mismatch", var, init->t, + type); return -1; } } @@ -1122,7 +1138,8 @@ static int actualize_var(struct act_state *state, return 0; } -static int actualize_tid(struct act_state *state, struct scope *scope, struct type *t) +static int actualize_tid(struct act_state *state, struct scope *scope, + struct type *t) { UNUSED(state); @@ -1161,7 +1178,8 @@ static int actualize_tid(struct act_state *state, struct scope *scope, struct ty return -1; } -static int actualize_ptr(struct act_state *state, struct scope *scope, struct type *t) +static int actualize_ptr(struct act_state *state, struct scope *scope, + struct type *t) { assert(ptr_base(t)); if (actualize_type(state, scope, ptr_base(t))) @@ -1170,7 +1188,8 @@ static int actualize_ptr(struct act_state *state, struct scope *scope, struct ty return 0; } -static int actualize_callable(struct act_state *state, struct scope *scope, struct type *t) +static int actualize_callable(struct act_state *state, struct scope *scope, + struct type *t) { struct type *ptypes = callable_ptypes(t); struct type *rtype = callable_rtype(t); @@ -1189,7 +1208,8 @@ static int actualize_callable(struct act_state *state, struct scope *scope, stru return 0; } -static int actualize_i27(struct act_state *state, struct scope *scope, struct type *t) +static int actualize_i27(struct act_state *state, struct scope *scope, + struct type *t) { UNUSED(state); /* not much to do */ @@ -1206,7 +1226,8 @@ static int actualize_i27(struct act_state *state, struct scope *scope, struct ty return 0; } -static int actualize_i9(struct act_state *state, struct scope *scope, struct type *t) +static int actualize_i9(struct act_state *state, struct scope *scope, + struct type *t) { UNUSED(state); /* not much to do */ @@ -1223,7 +1244,8 @@ static int actualize_i9(struct act_state *state, struct scope *scope, struct typ return 0; } -static int actualize_bool(struct act_state *state, struct scope *scope, struct type *t) +static int actualize_bool(struct act_state *state, struct scope *scope, + struct type *t) { UNUSED(state); /* not much to do */ @@ -1240,7 +1262,8 @@ static int actualize_bool(struct act_state *state, struct scope *scope, struct t return 0; } -static int actualize_tstruct(struct act_state *state, struct scope *scope, struct type *t) +static int actualize_tstruct(struct act_state *state, struct scope *scope, + struct type *t) { UNUSED(state); /* not much to do */ @@ -1259,7 +1282,7 @@ static int actualize_tstruct(struct act_state *state, struct scope *scope, struc static int actualize_type(struct act_state *state, struct scope *scope, - struct type *t) + struct type *t) { if (!t) return 0; @@ -1281,9 +1304,9 @@ static int actualize_type(struct act_state *state, default: type_info(scope->fctx, t, - "unimplemented type"); + "unimplemented type"); type_info(scope->fctx, t, - "continuing with compilation to see what breaks"); + "continuing with compilation to see what breaks"); return 0; } @@ -1291,8 +1314,8 @@ static int actualize_type(struct act_state *state, } static int actualize_type_list(struct act_state *state, - struct scope *scope, - struct type *l) + struct scope *scope, + struct type *l) { foreach_type(t, l) { if (actualize_type(state, scope, t)) @@ -1357,8 +1380,8 @@ static size_t member_count(struct ast *exists) } static struct ast *lookup_member_idx(struct ast *body, - char *find, - size_t *idx) + char *find, + size_t *idx) { /* micro-optimisation, likely way premature but speeds up selection * between lookup_struct_member_idx and *_name by a tiny amount */ @@ -1375,8 +1398,8 @@ static struct ast *lookup_member_idx(struct ast *body, } static struct ast *lookup_member_name(struct ast *body, - char *find, - size_t *idx) + char *find, + size_t *idx) { size_t i = 0; struct ast *m = body; @@ -1395,7 +1418,7 @@ static struct ast *lookup_member_name(struct ast *body, } static struct ast *lookup_struct_member(struct ast *struc, - char *find, size_t *idx) + char *find, size_t *idx) { if (find) return lookup_member_name(struct_body(struc), find, idx); @@ -1404,7 +1427,7 @@ static struct ast *lookup_struct_member(struct ast *struc, } static struct ast *lookup_enum_member(struct ast *enu, - char *find) + char *find) { size_t i = 0; struct ast *m = enum_body(enu); @@ -1610,7 +1633,8 @@ static int actualize_return(struct act_state *state, struct scope *scope, struct ast *cur_proc = state->cur_proc; struct type *rtype = proc_rtype(cur_proc); if (!types_match(node->t, rtype)) { - type_mismatch(scope, "return type mismatch", node, rtype, node->t); + type_mismatch(scope, "return type mismatch", node, rtype, + node->t); return -1; } @@ -1749,7 +1773,7 @@ static int actualize_unop(struct act_state *state, char *tstr = type_str(type); semantic_error(scope->fctx, expr, "not a pointer: %s", - tstr); + tstr); free(tstr); return -1; } @@ -1776,7 +1800,7 @@ static int actualize_unop(struct act_state *state, char *tstr = type_str(expr->t); semantic_error(scope->fctx, node, "'!' only implemented for primitive types: %s", - tstr); + tstr); free(tstr); return -1; } @@ -1952,18 +1976,18 @@ static int actualize_struct(struct act_state *state, } /* - foreach_node(n, struct_body(node)) { - switch (n->k) { - case AST_EMPTY: continue; - case AST_ID: continue; - case AST_PROC_DEF: if (!proc_body(n)) continue; - default: - } - - if (analyze_visibility(struct_scope, n)) - return -1; - } - */ + foreach_node(n, struct_body(node)) { + switch (n->k) { + case AST_EMPTY: continue; + case AST_ID: continue; + case AST_PROC_DEF: if (!proc_body(n)) continue; + default: + } + + if (analyze_visibility(struct_scope, n)) + return -1; + } + */ foreach_node(n, struct_body(node)) { struct act_state state = {0}; @@ -2026,7 +2050,8 @@ static int actualize_dot(struct act_state *state, } } - struct ast *exists = actualized_scope_find_symbol(state, def->scope, id); + struct ast *exists = actualized_scope_find_symbol(state, def->scope, + id); if (exists) { assert(exists->t); set_type(node, exists->t); @@ -2052,7 +2077,8 @@ static int actualize_init(struct act_state *state, struct scope *scope, struct ast *node) { assert(node->k == AST_INIT); - struct ast *def = actualized_file_scope_find_type(state, scope, init_id(node)); + struct ast *def = actualized_file_scope_find_type(state, scope, + init_id(node)); if (!def) { semantic_error(scope->fctx, node, "no such type"); return -1; @@ -2085,14 +2111,15 @@ static int actualize_init(struct act_state *state, if (vec_len(&init_args) != vec_len(&struct_members)) { semantic_error(scope->fctx, node, "expected %zs args, got %zs", - vec_len(&struct_members), - vec_len(&init_args)); + vec_len(&struct_members), + vec_len(&init_args)); goto err; } /* not insanely fast but good enough I suppose */ foreach_vec(ai, init_args) { - struct init_helper arg = vect_at(struct init_helper, init_args, ai); + struct init_helper arg = vect_at(struct init_helper, init_args, + ai); struct init_helper mem = {0}; foreach_vec(mi, struct_members) { @@ -2101,12 +2128,14 @@ static int actualize_init(struct act_state *state, goto ok; } - semantic_error(scope->fctx, arg.n, "unknown argument %s", arg.id); + semantic_error(scope->fctx, arg.n, "unknown argument %s", + arg.id); goto err; ok: if (!types_match(arg.n->t, mem.n->t)) { - type_mismatch(scope, "init type mismatch", arg.n, arg.n->t, mem.n->t); + type_mismatch(scope, "init type mismatch", arg.n, + arg.n->t, mem.n->t); goto err; } } @@ -2135,7 +2164,8 @@ static int actualize_assign(struct act_state *state, struct scope *scope, return -1; if (!types_match(to->t, from->t)) { - type_mismatch(scope, "assign type mismatch", node, to->t, from->t); + type_mismatch(scope, "assign type mismatch", node, to->t, + from->t); return -1; } @@ -2274,7 +2304,8 @@ static int actualize_for(struct act_state *state, struct scope *scope, return 0; } -static int actualize_comparison(struct act_state *state, struct scope *scope, struct ast *node) +static int actualize_comparison(struct act_state *state, struct scope *scope, + struct ast *node) { assert(is_comparison(node)); struct ast *left = comparison_left(node); @@ -2297,7 +2328,8 @@ static int actualize_comparison(struct act_state *state, struct scope *scope, st } if (!types_match(left->t, right->t)) { - type_mismatch(scope, "comparison type mismatch", node, left->t, right->t); + type_mismatch(scope, "comparison type mismatch", node, left->t, + right->t); return -1; } @@ -2352,7 +2384,8 @@ static int actualize(struct act_state *state, struct scope *scope, case AST_TRAIT_DEF: ret = actualize_trait(state, scope, node); break; case AST_ALIAS_DEF: ret = actualize_alias(state, scope, node); break; case AST_ENUM_DEF: ret = actualize_enum(state, scope, node); break; - case AST_MACRO_DEF: ret = actualize_macro_def(state, scope, node); break; + case AST_MACRO_DEF: ret = actualize_macro_def(state, scope, node); + break; case AST_STRUCT_DEF: ret = actualize_struct(state, scope, node); break; case AST_VAR_DEF: ret = actualize_var(state, scope, node); break; case AST_CALL: ret = actualize_call(state, scope, node); break; @@ -2371,7 +2404,8 @@ static int actualize(struct act_state *state, struct scope *scope, case AST_FETCH: ret = actualize_fetch(state, scope, node); break; case AST_IF: ret = actualize_if(state, scope, node); break; case AST_FOR: ret = actualize_for(state, scope, node); break; - case AST_MACRO_EXPAND: ret = actualize_macro_expand(state, scope, node); break; + case AST_MACRO_EXPAND: ret = actualize_macro_expand(state, scope, node); + break; default: /* more like internal_error, maybe? */ semantic_error(scope->fctx, node, @@ -2390,7 +2424,7 @@ out: } static int actualize_list(struct act_state *state, struct scope *scope, - struct ast *l) + struct ast *l) { foreach_node(n, l) { if (actualize(state, scope, n)) diff --git a/src/ast.c b/src/ast.c index 6677513..b3cf408 100644 --- a/src/ast.c +++ b/src/ast.c @@ -96,14 +96,14 @@ static struct type *create_empty_type() } struct ast *gen_ast(enum ast_kind kind, - struct ast *a0, - struct ast *a1, - struct ast *a2, - struct ast *a3, - struct type *t2, - char *s, - long long v, - struct src_loc loc) + struct ast *a0, + struct ast *a1, + struct ast *a2, + struct ast *a3, + struct type *t2, + char *s, + long long v, + struct src_loc loc) { struct ast *n = create_empty_ast(); n->k = kind; @@ -119,12 +119,12 @@ struct ast *gen_ast(enum ast_kind kind, } struct type *tgen_type(enum type_kind kind, - struct type *t0, - struct type *t1, - struct ast *d, - struct ast *a, - char *id, - struct src_loc loc) + struct type *t0, + struct type *t1, + struct ast *d, + struct ast *a, + char *id, + struct src_loc loc) { struct type *n = create_empty_type(); n->k = kind; @@ -217,73 +217,73 @@ void ast_dump(int depth, struct ast *n) #define DUMP(x) case x: dump(depth, #x); break; switch (n->k) { - DUMP(AST_FETCH); - DUMP(AST_INIT); - DUMP(AST_ASSIGN); - DUMP(AST_CALL); - DUMP(AST_ARR); - DUMP(AST_SIZEOF); - DUMP(AST_CAST); - DUMP(AST_DEFER); - DUMP(AST_MACRO_DEF); - DUMP(AST_MACRO_EXPAND); - DUMP(AST_TYPE_EXPAND); - DUMP(AST_PROC_DEF); - DUMP(AST_GOTO); - DUMP(AST_LABEL); - DUMP(AST_VAR_DEF); - DUMP(AST_FOR); - DUMP(AST_EMBED); - DUMP(AST_DOT); - DUMP(AST_WHILE); - DUMP(AST_DO_WHILE); - DUMP(AST_BREAK); - DUMP(AST_CONTINUE); - DUMP(AST_RETURN); - DUMP(AST_ALIAS_DEF); - DUMP(AST_TRAIT_DEF); - DUMP(AST_STRUCT_DEF); - DUMP(AST_IF); - DUMP(AST_BLOCK); - DUMP(AST_IMPORT); - DUMP(AST_ENUM_DEF); - DUMP(AST_VAL); - DUMP(AST_SWITCH); - DUMP(AST_CASE); - DUMP(AST_ID); - DUMP(AST_AS); - DUMP(AST_EMPTY); - DUMP(AST_ADD); - DUMP(AST_SUB); - DUMP(AST_MUL); - DUMP(AST_DIV); - DUMP(AST_REM); - DUMP(AST_LAND); - DUMP(AST_LOR); - DUMP(AST_LSHIFT); - DUMP(AST_RSHIFT); - DUMP(AST_ASSIGN_ADD); - DUMP(AST_ASSIGN_SUB); - DUMP(AST_ASSIGN_MUL); - DUMP(AST_ASSIGN_DIV); - DUMP(AST_ASSIGN_REM); - DUMP(AST_ASSIGN_LSHIFT); - DUMP(AST_ASSIGN_RSHIFT); - DUMP(AST_LT); - DUMP(AST_GT); - DUMP(AST_LE); - DUMP(AST_GE); - DUMP(AST_NE); - DUMP(AST_EQ); - DUMP(AST_NEG); - DUMP(AST_LNOT); - DUMP(AST_NOT); - DUMP(AST_REF); - DUMP(AST_DEREF); - DUMP(AST_CONST_INT); - DUMP(AST_CONST_CHAR); - DUMP(AST_CONST_BOOL); - DUMP(AST_CONST_STR); + DUMP(AST_FETCH); + DUMP(AST_INIT); + DUMP(AST_ASSIGN); + DUMP(AST_CALL); + DUMP(AST_ARR); + DUMP(AST_SIZEOF); + DUMP(AST_CAST); + DUMP(AST_DEFER); + DUMP(AST_MACRO_DEF); + DUMP(AST_MACRO_EXPAND); + DUMP(AST_TYPE_EXPAND); + DUMP(AST_PROC_DEF); + DUMP(AST_GOTO); + DUMP(AST_LABEL); + DUMP(AST_VAR_DEF); + DUMP(AST_FOR); + DUMP(AST_EMBED); + DUMP(AST_DOT); + DUMP(AST_WHILE); + DUMP(AST_DO_WHILE); + DUMP(AST_BREAK); + DUMP(AST_CONTINUE); + DUMP(AST_RETURN); + DUMP(AST_ALIAS_DEF); + DUMP(AST_TRAIT_DEF); + DUMP(AST_STRUCT_DEF); + DUMP(AST_IF); + DUMP(AST_BLOCK); + DUMP(AST_IMPORT); + DUMP(AST_ENUM_DEF); + DUMP(AST_VAL); + DUMP(AST_SWITCH); + DUMP(AST_CASE); + DUMP(AST_ID); + DUMP(AST_AS); + DUMP(AST_EMPTY); + DUMP(AST_ADD); + DUMP(AST_SUB); + DUMP(AST_MUL); + DUMP(AST_DIV); + DUMP(AST_REM); + DUMP(AST_LAND); + DUMP(AST_LOR); + DUMP(AST_LSHIFT); + DUMP(AST_RSHIFT); + DUMP(AST_ASSIGN_ADD); + DUMP(AST_ASSIGN_SUB); + DUMP(AST_ASSIGN_MUL); + DUMP(AST_ASSIGN_DIV); + DUMP(AST_ASSIGN_REM); + DUMP(AST_ASSIGN_LSHIFT); + DUMP(AST_ASSIGN_RSHIFT); + DUMP(AST_LT); + DUMP(AST_GT); + DUMP(AST_LE); + DUMP(AST_GE); + DUMP(AST_NE); + DUMP(AST_EQ); + DUMP(AST_NEG); + DUMP(AST_LNOT); + DUMP(AST_NOT); + DUMP(AST_REF); + DUMP(AST_DEREF); + DUMP(AST_CONST_INT); + DUMP(AST_CONST_CHAR); + DUMP(AST_CONST_BOOL); + DUMP(AST_CONST_STR); } #undef DUMP @@ -340,18 +340,18 @@ void type_dump(struct type *n) #define DUMP(x) case x: printf(#x); break; switch (n->k) { - DUMP(TYPE_VOID); - DUMP(TYPE_BOOL); - DUMP(TYPE_I9); - DUMP(TYPE_I27); - DUMP(TYPE_STR); - DUMP(TYPE_PTR); - DUMP(TYPE_ID); - DUMP(TYPE_CONSTRUCT); - DUMP(TYPE_STRUCT); - DUMP(TYPE_ENUM); - DUMP(TYPE_CALLABLE); - DUMP(TYPE_TRAIT); + DUMP(TYPE_VOID); + DUMP(TYPE_BOOL); + DUMP(TYPE_I9); + DUMP(TYPE_I27); + DUMP(TYPE_STR); + DUMP(TYPE_PTR); + DUMP(TYPE_ID); + DUMP(TYPE_CONSTRUCT); + DUMP(TYPE_STRUCT); + DUMP(TYPE_ENUM); + DUMP(TYPE_CALLABLE); + DUMP(TYPE_TRAIT); } } @@ -435,7 +435,7 @@ struct ast *clone_ast_list(struct ast *root) struct ast *new = clone_ast(n); if (prev) prev->n = new; - else new_root = new; + else new_root = new; prev = new; n = n->n; @@ -451,7 +451,7 @@ struct type *clone_type_list(struct type *root) struct type *new = clone_type(n); if (prev) prev->n = new; - else new_root = new; + else new_root = new; prev = new; n = n->n; @@ -460,7 +460,8 @@ struct type *clone_type_list(struct type *root) return new_root; } -int type_visit(type_callback_t before, type_callback_t after, struct type *n, void *d) +int type_visit(type_callback_t before, type_callback_t after, struct type *n, + void *d) { int ret = 0; if (!n) @@ -481,7 +482,8 @@ int type_visit(type_callback_t before, type_callback_t after, struct type *n, vo return ret; } -int ast_visit(ast_callback_t before, ast_callback_t after, struct ast *n, void *d) +int ast_visit(ast_callback_t before, ast_callback_t after, struct ast *n, + void *d) { int ret = 0; if (!n) @@ -508,7 +510,8 @@ int ast_visit(ast_callback_t before, ast_callback_t after, struct ast *n, void * return ret; } -int ast_visit_list(ast_callback_t before, ast_callback_t after, struct ast *l, void *d) +int ast_visit_list(ast_callback_t before, ast_callback_t after, struct ast *l, + void *d) { int ret = 0; foreach_node(n, l) { @@ -519,7 +522,8 @@ int ast_visit_list(ast_callback_t before, ast_callback_t after, struct ast *l, v return ret; } -int type_visit_list(type_callback_t before, type_callback_t after, struct type *l, void *d) +int type_visit_list(type_callback_t before, type_callback_t after, + struct type *l, void *d) { int ret = 0; foreach_type(n, l) { diff --git a/src/debug.c b/src/debug.c index 3be9d21..734ce0e 100644 --- a/src/debug.c +++ b/src/debug.c @@ -134,7 +134,7 @@ void semantic_error(struct file_ctx fctx, struct ast *node, } void type_error(struct file_ctx fctx, struct type *node, - const char *fmt, ...) + const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -173,7 +173,7 @@ void semantic_info(struct file_ctx fctx, struct ast *node, const char *fmt, } void type_info(struct file_ctx fctx, struct type *node, const char *fmt, - ...) + ...) { va_list args; va_start(args, fmt); diff --git a/src/lower.c b/src/lower.c index 9ad9a53..50e7ef8 100644 --- a/src/lower.c +++ b/src/lower.c @@ -625,7 +625,8 @@ static int lower_binop(struct lower_state *s, struct ast *i, return 0; } -static int lower_comparison(struct lower_state *s, struct ast *i, struct vec *retval) +static int lower_comparison(struct lower_state *s, struct ast *i, + struct vec *retval) { /* very similar to lower_binop, hmm */ struct vec l = retval_create(); -- cgit v1.3