summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-03-14 15:02:29 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-03-14 15:02:29 -0400
commit6b62b3caada6ce2859dfda24d6eb6fb273ca1a3f (patch)
tree6f822e745a4d60f229284d3f821c5d82145d8f6d
parentb3e83e42b63ca7f4e8e38e3dae9a14c1de531c07 (diff)
fixed indentation
-rw-r--r--cgen.c50
-rw-r--r--copy.c8
-rw-r--r--data_structures.c2
-rw-r--r--err.c2
-rw-r--r--eval.c14
-rw-r--r--foreign.c2
-rw-r--r--identifiers.c8
-rw-r--r--infer.c4
-rw-r--r--instance_table.c4
-rw-r--r--main.c10
-rw-r--r--parse.c26
-rw-r--r--sdecls_cgen.c12
-rw-r--r--types.c46
-rw-r--r--types.h10
14 files changed, 99 insertions, 99 deletions
diff --git a/cgen.c b/cgen.c
index 2f1fa0d..75d3803 100644
--- a/cgen.c
+++ b/cgen.c
@@ -226,7 +226,7 @@ static void cgen_ident(CGenerator *g, Identifier i) {
/* don't conflict with C's main! */
cgen_write(g, "main_");
} else {
- cgen_ident_simple(g, i);
+ cgen_ident_simple(g, i);
}
}
@@ -351,7 +351,7 @@ static void cgen_type_post(CGenerator *g, Type *t) {
switch (t->kind) {
case TYPE_PTR:
cgen_write(g, ")");
- cgen_type_post(g, t->ptr);
+ cgen_type_post(g, t->ptr);
break;
case TYPE_ARR:
assert(t->flags & TYPE_IS_RESOLVED);
@@ -448,7 +448,7 @@ static void cgen_val_ptr_pre(CGenerator *g, void *v, Type *t) {
for (I64 i = 0; i < s->n; ++i) {
cgen_val_ptr_pre(g, (char *)s->data + (U64)i * compiler_sizeof(t->slice), t->slice);
}
- cgen_type_pre(g, t->slice);
+ cgen_type_pre(g, t->slice);
cgen_write(g, "(d%p_[])", v); /* TODO: improve this somehow? */
cgen_type_post(g, t->slice);
cgen_write(g, " = {");
@@ -577,7 +577,7 @@ static void cgen_fn_params(CGenerator *g, FnExpr *f, U64 which_are_const) {
&& (which_are_const & (((U64)1) << semi_const_idx++))) {
/* semi constant argument is constant */
} else {
- int idx = 0;
+ int idx = 0;
arr_foreach(d->idents, Identifier, i) {
if (any_params)
cgen_write(g, ", ");
@@ -655,7 +655,7 @@ static void cgen_fn_header(CGenerator *g, FnExpr *f, U64 which_are_const) {
cgen_write(g, " ");
}
cgen_full_fn_name(g, f);
- cgen_fn_params(g, f, which_are_const);
+ cgen_fn_params(g, f, which_are_const);
if (!out_param) {
cgen_type_post(g, &f->ret_type);
}
@@ -1128,7 +1128,7 @@ static void cgen_expr_pre(CGenerator *g, Expression *e) {
break;
case EXPR_CALL: {
cgen_expr_pre(g, e->call.fn);
- size_t i = 0;
+ size_t i = 0;
Constness *constness = e->call.fn->type.fn.constness;
size_t nparams = arr_len(e->call.fn->type.fn.types)-1;
arr_foreach(e->call.arg_exprs, Expression, arg) {
@@ -1150,7 +1150,7 @@ static void cgen_expr_pre(CGenerator *g, Expression *e) {
cgen_type_post(g, &t->tuple[i]);
cgen_write(g, "; ");
}
- cgen_expr(g, e->call.fn);
+ cgen_expr(g, e->call.fn);
if (e->call.instance) {
cgen_fn_instance_number(g, e->call.instance->fn->instance_id);
}
@@ -1301,7 +1301,7 @@ static void cgen_expr_pre(CGenerator *g, Expression *e) {
cgen_write(g, "extern void *stdin;");
cgen_nl(g);
break;
- default:
+ default:
break;
}
break;
@@ -1349,7 +1349,7 @@ static void cgen_expr(CGenerator *g, Expression *e) {
bool handled = false;
if (e->type.kind == TYPE_FN) {
/* generate the right function name, because it might be anonymous */
- Identifier i = e->ident;
+ Identifier i = e->ident;
if (i->decl_kind == IDECL_DECL) {
Declaration *d = i->decl;
if (d->flags & DECL_IS_CONST) {
@@ -1437,7 +1437,7 @@ static void cgen_expr(CGenerator *g, Expression *e) {
cgen_write(g, "]");
break;
case TYPE_BUILTIN:
- if (lhs_type->builtin == BUILTIN_VARARGS) {
+ if (lhs_type->builtin == BUILTIN_VARARGS) {
assert(lhs->kind == EXPR_IDENT);
assert(rhs->kind == EXPR_VAL);
assert(type_is_builtin(&rhs->type, BUILTIN_I64));
@@ -1571,7 +1571,7 @@ static void cgen_expr(CGenerator *g, Expression *e) {
}
cgen_write(g, "(");
bool first_arg = true;
- size_t i = 0;
+ size_t i = 0;
size_t nparams = arr_len(fn_type->types)-1;
arr_foreach(e->call.arg_exprs, Expression, arg) {
if (!fn_type->constness || !arg_is_const(arg, fn_type->constness[i])) {
@@ -1823,16 +1823,16 @@ static void cgen_decl(CGenerator *g, Declaration *d) {
Identifier i = d->idents[idx];
Type *type = decl_type_at_index(d, idx);
if (type_is_compileonly(&d->type)) {
- continue;
+ continue;
}
Value *val = decl_val_at_index(d, idx);
if (has_expr) {
cgen_val_pre(g, val, type);
}
- cgen_type_pre(g, type);
+ cgen_type_pre(g, type);
cgen_write(g, " ");
cgen_ident(g, i);
- cgen_type_post(g, type);
+ cgen_type_post(g, type);
if (has_expr) {
cgen_write(g, " = ");
cgen_val(g, val, type);
@@ -1850,10 +1850,10 @@ static void cgen_decl(CGenerator *g, Declaration *d) {
Identifier i = d->idents[idx];
if (ident_eq_str(i, "_")) continue;
Type *type = decl_type_at_index(d, idx);
- cgen_type_pre(g, type);
+ cgen_type_pre(g, type);
cgen_write(g, " ");
cgen_ident(g, i);
- cgen_type_post(g, type);
+ cgen_type_post(g, type);
if (!has_expr) {
cgen_write(g, " = ");
cgen_zero_value(g, type);
@@ -1873,7 +1873,7 @@ static void cgen_decl(CGenerator *g, Declaration *d) {
cgen_nl(g);
cgen_type_pre(g, &d->type);
cgen_write(g, " expr_");
- cgen_type_post(g, &d->type);
+ cgen_type_post(g, &d->type);
cgen_write(g, "; ");
cgen_set(g, NULL, "expr_", &d->expr, NULL);
@@ -1923,7 +1923,7 @@ static void cgen_ret(CGenerator *g, Expression *ret) {
++idx;
}
}
- cgen_set_tuple(g, NULL, NULL, "*ret__", &ret_expr);
+ cgen_set_tuple(g, NULL, NULL, "*ret__", &ret_expr);
arr_clear(&ret_expr.tuple);
} else if (cgen_uses_ptr(&f->ret_type)) {
Expression ret_expr = {0};
@@ -1951,12 +1951,12 @@ static void cgen_ret(CGenerator *g, Expression *ret) {
if (f->ret_type.kind == TYPE_TUPLE) {
cgen_set_tuple(g, NULL, NULL, "*ret__", ret);
} else {
- cgen_set(g, NULL, "*ret__", ret, NULL);
+ cgen_set(g, NULL, "*ret__", ret, NULL);
}
cgen_write(g, " return");
} else {
cgen_write(g, "return ");
- cgen_expr(g, ret);
+ cgen_expr(g, ret);
}
cgen_writeln(g, ";");
}
@@ -1973,7 +1973,7 @@ static void cgen_stmt(CGenerator *g, Statement *s) {
break;
case STMT_EXPR:
if ((g->block != NULL || s->expr.kind == EXPR_C) && !type_is_compileonly(&s->expr.type)) {
- cgen_expr_pre(g, &s->expr);
+ cgen_expr_pre(g, &s->expr);
cgen_expr(g, &s->expr);
if (s->expr.kind != EXPR_C)
cgen_writeln(g, ";");
@@ -1990,8 +1990,8 @@ static void cgen_stmt(CGenerator *g, Statement *s) {
if (s->inc.inc_file) s->inc.inc_file->flags |= INC_FILE_CGEND;
arr_foreach(s->inc.stmts, Statement, sub)
cgen_stmt(g, sub);
- }
- break;
+ }
+ break;
}
}
@@ -2013,7 +2013,7 @@ static void cgen_defs_fn(CGenerator *g, FnExpr *f) {
static void cgen_defs_expr(CGenerator *g, Expression *e) {
if (e->kind == EXPR_FN) {
- cgen_defs_fn(g, e->fn);
+ cgen_defs_fn(g, e->fn);
}
cgen_recurse_subexprs(g, e, cgen_defs_expr, cgen_defs_block, cgen_defs_decl);
}
@@ -2041,7 +2041,7 @@ static void cgen_defs_stmt(CGenerator *g, Statement *s) {
if (s->inc.inc_file && (s->inc.inc_file->flags & INC_FILE_CGEND_DEFS)) {
/* already generated */
} else {
- if (s->inc.inc_file) s->inc.inc_file->flags |= INC_FILE_CGEND_DEFS;
+ if (s->inc.inc_file) s->inc.inc_file->flags |= INC_FILE_CGEND_DEFS;
arr_foreach(s->inc.stmts, Statement, sub)
cgen_defs_stmt(g, sub);
}
diff --git a/copy.c b/copy.c
index 4f6402c..00d3106 100644
--- a/copy.c
+++ b/copy.c
@@ -204,7 +204,7 @@ static void copy_fn_expr(Copier *c, FnExpr *fout, FnExpr *fin, U8 flags) {
copy_type(c, &fout->foreign.type, &fin->foreign.type);
size_t nctypes = arr_len(fin->foreign.type.fn.types);
fout->foreign.ctypes = copier_malloc(c, nctypes * sizeof(CType));
- memcpy(fout->foreign.ctypes, fin->foreign.ctypes, nctypes * sizeof(CType));
+ memcpy(fout->foreign.ctypes, fin->foreign.ctypes, nctypes * sizeof(CType));
} else {
Block *prev = c->block;
if (copy_body) {
@@ -284,8 +284,8 @@ static void copy_expr(Copier *c, Expression *out, Expression *in) {
copy_block(c, &wout->body, &win->body, 0);
} break;
case EXPR_FOR: {
- ForExpr *fin = in->for_;
- ForExpr *fout = allocr_malloc(a, sizeof *fout);
+ ForExpr *fin = in->for_;
+ ForExpr *fout = allocr_malloc(a, sizeof *fout);
out->for_ = fout;
*fout = *fin;
@@ -412,7 +412,7 @@ static void copy_decl(Copier *c, Declaration *out, Declaration *in) {
copier_ident_translate(c, &out->idents[i]);
out->idents[i]->decl_kind = IDECL_DECL;
- out->idents[i]->decl = out;
+ out->idents[i]->decl = out;
}
}
diff --git a/data_structures.c b/data_structures.c
index c736662..494aaf1 100644
--- a/data_structures.c
+++ b/data_structures.c
@@ -243,7 +243,7 @@ static U64 str_hash(const char *s, size_t len) {
U32 x = 0xabcdef01;
U32 y = 0x31415926;
U64 hash = 0;
- for (size_t i = 0; i < len; ++i) {
+ for (size_t i = 0; i < len; ++i) {
hash += (U64)x * (unsigned char)(*s) + y;
x = rand_u32(x);
y = rand_u32(y);
diff --git a/err.c b/err.c
index 3a74595..571b7b7 100644
--- a/err.c
+++ b/err.c
@@ -189,7 +189,7 @@ static void err_print_footer_(Location where, bool show_ctx_stack) {
if (ctx && show_ctx_stack) {
arr_foreach(ctx->instance_stack, Location, inst) {
err_fprint(ctx, "While generating this instance of a function or struct:\n\t");
- print_location_highlight(err_ctx_file(ctx), *inst);
+ print_location_highlight(err_ctx_file(ctx), *inst);
}
}
}
diff --git a/eval.c b/eval.c
index b024b8b..5385771 100644
--- a/eval.c
+++ b/eval.c
@@ -717,7 +717,7 @@ static inline bool eval_address_of_ident(Identifier i, Location where, Type *typ
err_print(where, "Cannot access value of variable %s at compile time.", s);
return false;
}
- *ptr = val_get_ptr(val, type);
+ *ptr = val_get_ptr(val, type);
return true;
}
@@ -736,17 +736,17 @@ static Status eval_ptr_to_struct_field(Evaluator *ev, Expression *dot_expr, void
struc_data = struc.ptr;
if (struc_data == NULL) {
err_print(dot_expr->where, "Attempt to dereference NULL pointer.");
- return false;
+ return false;
}
} else {
struc_data = struc.struc;
}
- *p = (char *)struc_data + dot_expr->binary.dot.field->offset;
+ *p = (char *)struc_data + dot_expr->binary.dot.field->offset;
} else {
void *ptr;
Identifier ident = dot_expr->binary.rhs->ident;
assert(type_is_builtin(struct_type, BUILTIN_NMS));
- if (!eval_address_of_ident(ident, dot_expr->where, &dot_expr->type, &ptr))
+ if (!eval_address_of_ident(ident, dot_expr->where, &dot_expr->type, &ptr))
return false;
*p = ptr;
}
@@ -890,7 +890,7 @@ static void eval_numerical_bin_op(Value lhs, Type *lhs_type, BinaryOp op, Value
eval_binary_op_one(u64, U64, op);
#define eval_binary_op_nums(builtin, op) \
- eval_binary_op_ints(builtin, op); \
+ eval_binary_op_ints(builtin, op); \
eval_binary_op_one(f32, F32, op); \
eval_binary_op_one(f64, F64, op)
@@ -1273,7 +1273,7 @@ static Status eval_expr(Evaluator *ev, Expression *e, Value *v) {
index_val = NULL;
}
if (fo->value) {
- value_val = fo->index ? &for_valp->tuple[1] : for_valp;
+ value_val = fo->index ? &for_valp->tuple[1] : for_valp;
} else {
value_val = NULL;
}
@@ -1490,7 +1490,7 @@ static Status eval_expr(Evaluator *ev, Expression *e, Value *v) {
Value *ival = multiple_idents ? &dval->tuple[idx] : dval;
Type *type = is_tuple ? &d->type.tuple[idx] : &d->type;
if (d->flags & DECL_HAS_EXPR) {
- *ival = d->type.kind == TYPE_TUPLE ? ret_decl_val.tuple[idx] : ret_decl_val;
+ *ival = d->type.kind == TYPE_TUPLE ? ret_decl_val.tuple[idx] : ret_decl_val;
} else {
*ival = val_zero(type);
}
diff --git a/foreign.c b/foreign.c
index ef028ba..6018487 100644
--- a/foreign.c
+++ b/foreign.c
@@ -259,7 +259,7 @@ static bool arg_list_add(av_alist *arg_list, Value val, Type *type, Location whe
break;
case BUILTIN_VARARGS:
arr_foreach(val.varargs, VarArg, arg) {
- arg_list_add(arg_list, arg->val, arg->type, where);
+ arg_list_add(arg_list, arg->val, arg->type, where);
}
break;
}
diff --git a/identifiers.c b/identifiers.c
index abf8958..585ee52 100644
--- a/identifiers.c
+++ b/identifiers.c
@@ -61,7 +61,7 @@ static inline bool ident_eq_str(Identifier i, const char *s) {
static Identifier ident_insert(Identifiers *ids, char **s) {
char *original = *s;
size_t len = ident_str_len_advance(s);
- IdentSlot *slot = (IdentSlot *)str_hash_table_insert_(&ids->table, original, len);
+ IdentSlot *slot = (IdentSlot *)str_hash_table_insert_(&ids->table, original, len);
slot->idents = ids;
return slot;
}
@@ -112,7 +112,7 @@ static void fprint_ident_reduced_charset(FILE *out, Identifier id) {
if (c > 127) {
fprintf(out, "x__%02x", c);
} else {
- putc(*s, out);
+ putc(*s, out);
}
}
}
@@ -157,14 +157,14 @@ static inline Identifier ident_get(Identifiers *ids, char *s) {
/* translate and insert if not already there */
static inline Identifier ident_translate_forced(Identifier i, Identifiers *to_idents) {
char *p = i->str;
- Identifier translated = ident_insert(to_idents, &p);
+ Identifier translated = ident_insert(to_idents, &p);
assert(translated->idents == to_idents);
return translated;
}
/* translate but don't add it if it's not there */
static inline Identifier ident_translate(Identifier i, Identifiers *to_idents) {
- return ident_get(to_idents, i->str);
+ return ident_get(to_idents, i->str);
}
/* returns true if i and j are equal, even if they're not in the same table */
diff --git a/infer.c b/infer.c
index 544ca78..348b43b 100644
--- a/infer.c
+++ b/infer.c
@@ -33,8 +33,8 @@ static bool infer_from_expr(Typer *tr, Expression *match, Expression *to, Identi
case EXPR_CALL: {
if (!types_expr(tr, match->call.fn))
return false;
- if (type_is_builtin(&match->call.fn->type, BUILTIN_TYPE)) {
- /* it's a parameterized struct */
+ if (type_is_builtin(&match->call.fn->type, BUILTIN_TYPE)) {
+ /* it's a parameterized struct */
Value fn_val;
if (!eval_expr(tr->evalr, to, &fn_val))
return false;
diff --git a/instance_table.c b/instance_table.c
index 571a529..d1533cd 100644
--- a/instance_table.c
+++ b/instance_table.c
@@ -225,7 +225,7 @@ static bool val_ptr_eq(void *u, void *v, Type *t) {
case BUILTIN_BOOL: return *(bool *)u == *(bool *)v;
case BUILTIN_CHAR: return *(char *)u == *(char *)v;
case BUILTIN_VARARGS: {
- VarArg *us = *(VarArg **)u, *vs = *(VarArg **)v;
+ VarArg *us = *(VarArg **)u, *vs = *(VarArg **)v;
size_t n = arr_len(us);
if (arr_len(vs) != n)
return false;
@@ -238,7 +238,7 @@ static bool val_ptr_eq(void *u, void *v, Type *t) {
return true;
}
case BUILTIN_TYPE:
- return type_eq(*(Type **)u, *(Type **)v);
+ return type_eq(*(Type **)u, *(Type **)v);
case BUILTIN_NMS:
return *(Namespace **)u == *(Namespace **)v;
}
diff --git a/main.c b/main.c
index a574f4b..906b22a 100644
--- a/main.c
+++ b/main.c
@@ -42,7 +42,7 @@ macros
#include <execinfo.h>
#include <unistd.h>
static void signal_handler(int num) {
- switch (num) {
+ switch (num) {
case SIGABRT:
fprintf(stderr, "Aborted.\n");
break;
@@ -50,14 +50,14 @@ static void signal_handler(int num) {
fprintf(stderr, "Segmentation fault.\n");
break;
default:
- fprintf(stderr, "Terminated for unknown reason.\n");
+ fprintf(stderr, "Terminated for unknown reason.\n");
break;
}
fprintf(stderr, "Stack trace:\n");
static void *addrs[30];
- int naddrs = (int)(sizeof addrs / sizeof *addrs);
- naddrs = backtrace(addrs, naddrs);
+ int naddrs = (int)(sizeof addrs / sizeof *addrs);
+ naddrs = backtrace(addrs, naddrs);
/* char **syms = backtrace_symbols(addrs, naddrs); */
char command[2048] = "addr2line -p -f -a -e toc ";
for (int i = 4; i < naddrs; ++i) {
@@ -159,7 +159,7 @@ int main(int argc, char **argv) {
Evaluator ev;
evalr_create(&ev, &tr, &main_allocr);
typer_create(&tr, &ev, &err_ctx, &main_allocr, &globals);
-
+
if (!types_file(&tr, &f)) {
err_text_important(&err_ctx, "Errors occured while determining types.\n");
allocr_free_all(&main_allocr);
diff --git a/parse.c b/parse.c
index 704d867..a448c76 100644
--- a/parse.c
+++ b/parse.c
@@ -622,7 +622,7 @@ static Status parse_type(Parser *p, Type *type, Location *where) {
struc->where.start = t->token;
memset(&struc->scope, 0, sizeof struc->scope);
idents_create(&struc->scope.idents, p->allocr, &struc->scope);
- memset(&struc->instances, 0, sizeof struc->instances);
+ memset(&struc->instances, 0, sizeof struc->instances);
struc->scope.parent = p->block;
Block *prev_block = p->block;
@@ -987,7 +987,7 @@ static Status parse_fn_expr(Parser *p, FnExpr *f) {
if (t->token->kind == TOKEN_EOF) {
tokr_err(t, "End of file encountered while parsing parameter list.");
- success = false; goto ret;
+ success = false; goto ret;
}
if (token_is_kw(t->token, KW_LBRACE) || token_is_kw(t->token, KW_WHERE)) {
@@ -1111,7 +1111,7 @@ static BuiltinType uint_with_size(size_t size) {
}
static Status ctype_to_type(Allocator *a, CType *ctype, Type *type, Location where) {
- memset(type, 0, sizeof *type);
+ memset(type, 0, sizeof *type);
type->kind = TYPE_BUILTIN;
size_t size = 0;
switch (ctype->kind) {
@@ -1127,7 +1127,7 @@ static Status ctype_to_type(Allocator *a, CType *ctype, Type *type, Location whe
break;
case CTYPE_SHORT:
case CTYPE_UNSIGNED_SHORT:
- size = sizeof(short);
+ size = sizeof(short);
break;
case CTYPE_INT:
case CTYPE_UNSIGNED_INT:
@@ -1479,7 +1479,7 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) {
&& token_is_kw(t->token + 3, KW_COLON))))) {
if (t->token->kind == TOKEN_IDENT) {
fo->value = parser_ident_insert(p, t->token->ident);
- if (!check_ident_redecl(p, fo->value))
+ if (!check_ident_redecl(p, fo->value))
goto for_fail;
fo->value->decl_kind = IDECL_EXPR;
fo->value->decl_expr = e;
@@ -1526,7 +1526,7 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) {
Token *first_end; first_end = expr_find_end(p, EXPR_CAN_END_WITH_COMMA|EXPR_CAN_END_WITH_DOTDOT|EXPR_CAN_END_WITH_LBRACE);
Expression *first; first = parser_new_expr(p);
if (!parse_expr(p, first, first_end))
- goto for_fail;
+ goto for_fail;
if (token_is_kw(first_end, KW_LBRACE)) {
fo->of = first;
} else if (token_is_kw(first_end, KW_DOTDOT) || token_is_kw(first_end, KW_COMMA)) {
@@ -1561,12 +1561,12 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) {
}
} else {
err_print(token_location(p->file, first_end), "Expected { or .. to follow expression in for statement.");
- goto for_fail;
+ goto for_fail;
}
e->where.end = t->token; /* temporarily set end so that redeclaration errors aren't messed up */
p->block = prev_block;
if (!parse_block(p, &fo->body, PARSE_BLOCK_DONT_CREATE_IDENTS))
- goto for_fail;
+ goto for_fail;
goto success;
for_fail:
p->block = prev_block;
@@ -1945,7 +1945,7 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) {
Type *fn_t = &fn->foreign.type;
fn_t->kind = TYPE_FN;
FnType *fn_type = &fn_t->fn;
- fn_type->constness = NULL;
+ fn_type->constness = NULL;
fn_type->types = NULL;
Type *ret_type = parser_arr_add(p, &fn_type->types);
CType *ret_ctype = parser_arr_add(p, &fn->foreign.ctypes);
@@ -2110,7 +2110,7 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) {
return false;
}
t->token = opening_bracket;
- if (!parse_args(p, &e->call.args))
+ if (!parse_args(p, &e->call.args))
return false;
goto success;
}
@@ -2309,7 +2309,7 @@ static Status parse_decl(Parser *p, Declaration *d, DeclEndKind ends_with, U16 f
is_varargs = true;
if (d->flags & DECL_SEMI_CONST) {
tokr_err(t, "Semi-constant varargs are not allowed. Sorry!");
- goto ret_false;
+ goto ret_false;
}
++t->token;
} else {
@@ -2502,7 +2502,7 @@ static Status parse_stmt(Parser *p, Statement *s, bool *was_a_statement) {
if (!check_ident_redecl(p, ident)) {
tokr_skip_semicolon(t);
- return false;
+ return false;
}
ident->decl_kind = IDECL_DECL;
ident->decl = d;
@@ -2901,7 +2901,7 @@ static void fprint_stmt(FILE *out, Statement *s) {
break;
case STMT_INCLUDE:
if (s->flags & STMT_TYPED) {
- arr_foreach(s->inc.stmts, Statement, sub)
+ arr_foreach(s->inc.stmts, Statement, sub)
fprint_stmt(out, sub);
} else {
fprintf(out, "#include ");
diff --git a/sdecls_cgen.c b/sdecls_cgen.c
index e490fc8..f186792 100644
--- a/sdecls_cgen.c
+++ b/sdecls_cgen.c
@@ -43,8 +43,8 @@ static void cgen_sdecls_block(CGenerator *g, Block *b) {
}
static char *cgen_nms_prefix_part(CGenerator *g, Namespace *n) {
- char *s;
- while (n->points_to) {
+ char *s;
+ while (n->points_to) {
n = n->points_to;
}
if (n->associated_ident) {
@@ -103,7 +103,7 @@ static void cgen_sdecls_expr(CGenerator *g, Expression *e) {
static void cgen_sdecls_decl(CGenerator *g, Declaration *d) {
- cgen_sdecls_type(g, &d->type);
+ cgen_sdecls_type(g, &d->type);
if (cgen_fn_is_direct(g, d)) {
d->expr.fn->c.name = d->idents[0];
}
@@ -112,11 +112,11 @@ static void cgen_sdecls_decl(CGenerator *g, Declaration *d) {
if (type_is_builtin(type, BUILTIN_TYPE) && !(d->flags & DECL_IS_PARAM)) {
Value *val = decl_val_at_index(d, idx);
- cgen_sdecls_type(g, val->type);
+ cgen_sdecls_type(g, val->type);
}
}
if (d->flags & DECL_HAS_EXPR) {
- cgen_sdecls_expr(g, &d->expr);
+ cgen_sdecls_expr(g, &d->expr);
if (d->flags & DECL_EXPORT) {
if (d->expr.kind == EXPR_FN)
d->expr.fn->flags |= FN_EXPR_EXPORT;
@@ -145,7 +145,7 @@ static void cgen_sdecls_stmt(CGenerator *g, Statement *s) {
arr_foreach(s->inc.stmts, Statement, sub)
cgen_sdecls_stmt(g, sub);
}
- break;
+ break;
}
}
diff --git a/types.c b/types.c
index 8a4d36d..b584528 100644
--- a/types.c
+++ b/types.c
@@ -320,7 +320,7 @@ static Status expr_must_lval(Expression *e) {
return false;
}
return true;
- default: {
+ default: {
err_print(e->where, "Cannot use %s as l-value.", expr_kind_to_str(e->kind));
return false;
}
@@ -543,7 +543,7 @@ static Status type_of_fn(Typer *tr, FnExpr *f, Type *t, U16 flags) {
}
if (type_is_builtin(&f->ret_type, BUILTIN_VARARGS)) {
err_print(f->where, "Functions cannot return varargs.");
- success = false;
+ success = false;
goto ret;
}
if (type_is_compileonly(&f->ret_type)) {
@@ -591,7 +591,7 @@ static Status type_of_ident(Typer *tr, Location where, Identifier *ident, Type *
print_block_location(tr->block);
printf("But the identifier's scope is:\n");
print_block_location(i->idents->scope);
- abort();
+ abort();
}
#else
assert(i->idents->scope == tr->block);
@@ -696,7 +696,7 @@ static Status type_of_ident(Typer *tr, Location where, Identifier *ident, Type *
}
/* let's type the declaration, and redo this (for evaling future functions) */
if (!types_decl(tr, d)) return false;
- return type_of_ident(tr, where, ident, t);
+ return type_of_ident(tr, where, ident, t);
}
return false;
}
@@ -1108,7 +1108,7 @@ static Status call_arg_param_order(FnExpr *fn, Type *fn_type, Argument *args, Lo
nparams, plural_suffix(nparams), nargs);
return false;
}
-
+
I16 *order = *orderp =
/* thanks, gcc, for making me do this! (getting erroneous -Walloc-size-larger-than) */
@@ -1294,7 +1294,7 @@ static Status parameterized_struct_arg_order(StructDef *struc, Argument *args, I
free(s);
return false;
}
- (*order)[param_idx] = argno;
+ (*order)[param_idx] = argno;
++argno;
}
@@ -1534,7 +1534,7 @@ static Status types_expr(Typer *tr, Expression *e) {
char *s = type_to_str(tt);
err_print(e->where, "to expression of for loop must be a builtin numerical type, not %s", s);
free(s);
- goto for_fail;
+ goto for_fail;
}
}
@@ -1632,8 +1632,8 @@ static Status types_expr(Typer *tr, Expression *e) {
/* TODO(eventually): don't put a decl in each block, just put one at the start */
Statement *s = &sub->stmts[0];
s->flags = 0;
- s->kind = STMT_DECL;
- s->where = e->where;
+ s->kind = STMT_DECL;
+ s->where = e->where;
/* declare value */
Declaration *decl = s->decl = typer_calloc(tr, 1, sizeof *decl);
@@ -1657,8 +1657,8 @@ static Status types_expr(Typer *tr, Expression *e) {
/* TODO(eventually): don't put a decl in each block, just put one at the start */
Statement *s = &sub->stmts[has_val];
s->flags = 0;
- s->kind = STMT_DECL;
- s->where = e->where;
+ s->kind = STMT_DECL;
+ s->where = e->where;
/* declare value */
Declaration *decl = s->decl = typer_calloc(tr, 1, sizeof *decl);
@@ -1930,7 +1930,7 @@ static Status types_expr(Typer *tr, Expression *e) {
info_print(base->struc->where, "struct was declared here.");
return false;
}
- Copier cop = copier_create(tr->allocr, base->struc->scope.parent);
+ Copier cop = copier_create(tr->allocr, base->struc->scope.parent);
HashTable *table = &base->struc->instances;
StructDef struc;
copy_struct(&cop, &struc, base->struc);
@@ -1958,7 +1958,7 @@ static Status types_expr(Typer *tr, Expression *e) {
/* temporarily add this instance to the stack, while we type the decl, in case you, e.g., pass t = float to struct(t::Type, u::t = "hello") */
*(Location *)arr_add(&err_ctx->instance_stack) = e->where;
typer_block_enter(tr, &struc.scope);
- bool success = types_decl(tr, param);
+ bool success = types_decl(tr, param);
arr_remove_last(&err_ctx->instance_stack);
typer_block_exit(tr);
if (!success) return false;
@@ -1968,7 +1968,7 @@ static Status types_expr(Typer *tr, Expression *e) {
arg_types[p] = *type;
Value ident_val;
if (order[p] == -1) {
- ident_val = *decl_val_at_index(param, ident_idx);
+ ident_val = *decl_val_at_index(param, ident_idx);
} else {
Argument *arg = &c->args[order[p]];
assert(arg->val.type.flags & TYPE_IS_RESOLVED);
@@ -2003,7 +2003,7 @@ static Status types_expr(Typer *tr, Expression *e) {
inst->struc = struc;
size_t i = 0;
arr_foreach(inst->struc.params, Declaration, param) {
- param->flags |= DECL_FOUND_VAL;
+ param->flags |= DECL_FOUND_VAL;
if (arr_len(param->idents) == 1) {
param->val = arg_vals[i];
++i;
@@ -2026,7 +2026,7 @@ static Status types_expr(Typer *tr, Expression *e) {
tr->block = &inst->struc.scope;
bool success = type_resolve(tr, &struct_t, e->where); /* resolve the struct */
tr->block = prev_block;
- arr_remove_last(&err_ctx->instance_stack);
+ arr_remove_last(&err_ctx->instance_stack);
if (!success) return false;
inst->struc.instance_id = table->n;
@@ -2039,7 +2039,7 @@ static Status types_expr(Typer *tr, Expression *e) {
e->typeval->kind = TYPE_STRUCT;
e->typeval->flags = TYPE_IS_RESOLVED;
e->typeval->struc = &inst->struc;
- t->kind = TYPE_BUILTIN;
+ t->kind = TYPE_BUILTIN;
t->builtin = BUILTIN_TYPE;
arr_clear(&arg_types);
goto ret;
@@ -2479,7 +2479,7 @@ static Status types_expr(Typer *tr, Expression *e) {
} else {
c->instance->fn = fn_copy;
/* fix parameter and return types (they were kind of problematic before, because we didn't know about the instance) */
- fn_copy->instance_id = 1+original_fn->instances->n; /* let's help cgen out and assign a non-zero ID to this */
+ fn_copy->instance_id = 1+original_fn->instances->n; /* let's help cgen out and assign a non-zero ID to this */
/* type this instance */
/* if anything happens, make sure we let the user know that this happened while generating a fn */
@@ -2911,7 +2911,7 @@ static Status types_expr(Typer *tr, Expression *e) {
lhs->kind = EXPR_VAL;
lhs->flags = EXPR_FOUND_TYPE;
lhs->val = lval;
- Type *struc = lhs->val.type;
+ Type *struc = lhs->val.type;
if (struc->kind != TYPE_STRUCT) {
char *s = type_to_str(struc);
err_print(lhs->where, "Cannot access member from non-struct type (%s).", s);
@@ -3034,14 +3034,14 @@ static Status types_expr(Typer *tr, Expression *e) {
case EXPR_NMS: {
Namespace *prev_nms = tr->nms;
Namespace *n = tr->nms = e->nms;
- n->points_to = NULL;
+ n->points_to = NULL;
n->body.flags |= BLOCK_IS_NMS;
if (!types_block(tr, &n->body)) {
tr->nms = prev_nms;
return false;
}
tr->nms = prev_nms;
- n->associated_ident = NULL; /* set when we type the declaration which contains this namespace */
+ n->associated_ident = NULL; /* set when we type the declaration which contains this namespace */
t->kind = TYPE_BUILTIN;
t->builtin = BUILTIN_NMS;
} break;
@@ -3231,7 +3231,7 @@ static Status types_decl(Typer *tr, Declaration *d) {
if (d->type.kind == TYPE_PTR) {
err_print(d->where, "You can't have a constant pointer.");
success = false;
- goto ret;
+ goto ret;
}
}
@@ -3376,7 +3376,7 @@ static Status types_stmt(Typer *tr, Statement *s) {
if (inc_f) {
inc_f->stmts = stmts_inc;
}
- s->inc.stmts = stmts_inc;
+ s->inc.stmts = stmts_inc;
arr_foreach(stmts_inc, Statement, s_incd) {
if (!types_stmt(tr, s_incd))
return false;
diff --git a/types.h b/types.h
index 2ecb331..aa50567 100644
--- a/types.h
+++ b/types.h
@@ -384,8 +384,8 @@ typedef struct Location {
Token *start;
union {
Token *end; /* Exclusive */
- struct {
- U32 line; /* if 0, this is a null location */
+ struct {
+ U32 line; /* if 0, this is a null location */
} simple_location;
};
} Location;
@@ -510,7 +510,7 @@ enum {
};
typedef struct StructDef {
Field *fields;
- struct Declaration *constants;
+ struct Declaration *constants;
Location where;
U8 flags;
Block scope; /* to make sure that parameters and constants live somewhere. fields are not kept here. */
@@ -796,7 +796,7 @@ typedef struct Expression {
Type type;
Location where;
ExprKind kind : 8;
- ExprFlags flags;
+ ExprFlags flags;
struct {
IdentID id; /* cgen ID used for this expression */
} cgen;
@@ -825,7 +825,7 @@ typedef struct Expression {
struct {
union {
struct Expression *expr;
- BuiltinVal val;
+ BuiltinVal val;
} which;
} builtin;
Identifier ident;