Skip to content

Commit

Permalink
🔥 unpointerize Exp
Browse files Browse the repository at this point in the history
  • Loading branch information
fennecdjay committed Jan 31, 2024
1 parent 379c80d commit a1d3a16
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion include/gwfmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ANN void gwfmt_lparen(Gwfmt *a);
ANN void gwfmt_rparen(Gwfmt *a);
ANN void gwfmt_lbrace(Gwfmt *a);
ANN void gwfmt_rbrace(Gwfmt *a);
ANN void gwfmt_exp(Gwfmt *a, Exp b);
ANN void gwfmt_exp(Gwfmt *a, Exp* b);
ANN void gwfmt_func_def(Gwfmt *a, Func_Def b);
ANN void gwfmt_class_def(Gwfmt *a, Class_Def b);
ANN void gwfmt_enum_def(Gwfmt *a, Enum_Def b);
Expand Down
4 changes: 2 additions & 2 deletions include/gwfmt_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ ANN static void gwfmt_prim_float(Gwfmt *a, m_float *b);
ANN static void gwfmt_prim_str(Gwfmt *a, struct AstString *b);
ANN static void gwfmt_prim_array(Gwfmt *a, Array_Sub *b);
ANN static void gwfmt_prim_range(Gwfmt *a, Range **b);
ANN static void gwfmt_prim_hack(Gwfmt *a, Exp *b);
ANN static void gwfmt_prim_interp(Gwfmt *a, Exp *b);
ANN static void gwfmt_prim_hack(Gwfmt *a, Exp* *b);
ANN static void gwfmt_prim_interp(Gwfmt *a, Exp* *b);
ANN static void gwfmt_prim_char(Gwfmt *a, m_str *b);
ANN static void gwfmt_prim_nil(Gwfmt *a, void *b);
ANN static void gwfmt_prim(Gwfmt *a, Exp_Primary *b);
Expand Down
2 changes: 1 addition & 1 deletion src/gwfmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ ANN static bool arg_parse(GwArg *a, int argc, char **argv) {
}

int main(int argc, char **argv) {
MemPool mp = mempool_ini(sizeof(struct Exp_));
MemPool mp = mempool_ini(sizeof(Exp));
SymTable * st = new_symbol_table(mp, 65347); // could be smaller
struct PPArg_ ppa = {.fmt = 1};
pparg_ini(mp, &ppa);
Expand Down
28 changes: 14 additions & 14 deletions src/lint.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ ANN void gwfmt_indent(Gwfmt *a) {
}
}

ANN static void paren_exp(Gwfmt *a, Exp b);
ANN static void maybe_paren_exp(Gwfmt *a, Exp b);
ANN static void paren_exp(Gwfmt *a, Exp* b);
ANN static void maybe_paren_exp(Gwfmt *a, Exp* b);
ANN static void gwfmt_array_sub2(Gwfmt *a, Array_Sub b);
ANN static void gwfmt_prim_interp(Gwfmt *a, Exp *b);
ANN static void gwfmt_prim_interp(Gwfmt *a, Exp* *b);

#define _FLAG(a, b) (((a)&ae_flag_##b) == (ae_flag_##b))
ANN static void gwfmt_flag(Gwfmt *a, ae_flag b) {
Expand Down Expand Up @@ -306,13 +306,13 @@ ANN static void gwfmt_range(Gwfmt *a, Range *b) {
gwfmt_rbrack(a);
}

ANN static void gwfmt_prim_dict(Gwfmt *a, Exp *b) {
Exp e = *b;
ANN static void gwfmt_prim_dict(Gwfmt *a, Exp* *b) {
Exp* e = *b;
gwfmt_lbrace(a);
gwfmt_space(a);
do {
const Exp next = e->next;
const Exp nnext = next->next;
Exp* next = e->next;
Exp* nnext = next->next;
e->next = NULL;
next->next = NULL;
gwfmt_exp(a, e);
Expand Down Expand Up @@ -563,7 +563,7 @@ ANN static void gwfmt_prim_array(Gwfmt *a, Array_Sub *b) {

ANN static void gwfmt_prim_range(Gwfmt *a, Range **b) { gwfmt_range(a, *b); }

ANN static void gwfmt_prim_hack(Gwfmt *a, Exp *b) {
ANN static void gwfmt_prim_hack(Gwfmt *a, Exp* *b) {
COLOR(a, "{-R}", "<<<");
gwfmt_space(a);
gwfmt_exp(a, *b);
Expand Down Expand Up @@ -772,15 +772,15 @@ ANN static void gwfmt_exp_lambda(Gwfmt *a, Exp_Lambda *b) {
}

DECL_EXP_FUNC(gwfmt, void, Gwfmt *)
ANN void gwfmt_exp(Gwfmt *a, Exp b) {
ANN void gwfmt_exp(Gwfmt *a, Exp* b) {
if(b->paren) gwfmt_lparen(a);
gwfmt_exp_func[b->exp_type](a, &b->d);
if(b->paren) gwfmt_rparen(a);
NEXT(a, b, gwfmt_exp)
}

ANN static void gwfmt_prim_interp(Gwfmt *a, Exp *b) {
Exp e = *b;
ANN static void gwfmt_prim_interp(Gwfmt *a, Exp* *b) {
Exp* e = *b;
const uint16_t delim = e->d.prim.d.string.delim;
gwfmt_delim(a, delim);
color(a, "{/Y}");
Expand All @@ -802,7 +802,7 @@ ANN static void gwfmt_prim_interp(Gwfmt *a, Exp *b) {
}

ANN static void gwfmt_array_sub2(Gwfmt *a, Array_Sub b) {
Exp e = b->exp;
Exp* e = b->exp;
for (m_uint i = 0; i < b->depth; ++i) {
gwfmt_lbrack(a);
if (e) {
Expand All @@ -813,15 +813,15 @@ ANN static void gwfmt_array_sub2(Gwfmt *a, Array_Sub b) {
}
}

ANN static void paren_exp(Gwfmt *a, Exp b) {
ANN static void paren_exp(Gwfmt *a, Exp* b) {
gwfmt_lparen(a);
//if(b->exp_type != ae_exp_primary &&
// b->d.prim.prim_type != ae_prim_nil)
gwfmt_exp(a, b);
gwfmt_rparen(a);
}

ANN static void maybe_paren_exp(Gwfmt *a, Exp b) {
ANN static void maybe_paren_exp(Gwfmt *a, Exp* b) {
if (b->next)
paren_exp(a, b);
else
Expand Down

0 comments on commit a1d3a16

Please sign in to comment.