Commit 7222d588
7222d5888da6Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · ~4 modified
Description
Apply }-else-on-newline everywhere
- Reformat hand-written src/ C:
} else->}newlineelse. - Generated C: restructure the puts/p string idioms to drop the
} elseentirely (print, then add a trailing newline unless already terminated) -- equivalent behavior, no same-line else. Generated output now contains zero} else.
Output verified unchanged; make test: 22.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 7222d5888da6
- Parent
- 7d0ffa899c0a
src/analyze.cmodifiedView file
@@ -384,10 +384,12 @@
384384
if (cname && comp_class_index(c, cname) < 0) {385385
comp_class_new(c, cname, id);386386
child_class = c->nclasses - 1;387-
} else if (cname) {387+
}388+
else if (cname) {388389
child_class = comp_class_index(c, cname); /* reopened class */389390
}390-
} else if (ty && !strcmp(ty, "DefNode")) {391+
}392+
else if (ty && !strcmp(ty, "DefNode")) {391393
const char *name = nt_str(c->nt, id, "name");392394
Scope *s = comp_scope_new(c, name, id);393395
int new_idx = c->nscopes - 1;@@ -502,7 +504,8 @@
502504
!strcmp(ty, "GlobalVariableOperatorWriteNode") || !strcmp(ty, "GlobalVariableTargetNode")) {503505
const char *nm = nt_str(nt, id, "name");504506
if (nm && nm[0] == '$' && is_c_ident(nm + 1)) comp_gvar_intern(c, nm + 1);505-
} else if (!strcmp(ty, "ConstantWriteNode")) {507+
}508+
else if (!strcmp(ty, "ConstantWriteNode")) {506509
const char *nm = nt_str(nt, id, "name");507510
if (nm && is_c_ident(nm)) comp_const_intern(c, nm);508511
}@@ -522,7 +525,8 @@
522525
if (nm) lv = comp_gvar(c, nm + 1);523526
vt = infer_type(c, nt_ref(nt, id, "value"));524527
if (vt == TY_NIL) continue;525-
} else if (!strcmp(ty, "GlobalVariableOperatorWriteNode")) {528+
}529+
else if (!strcmp(ty, "GlobalVariableOperatorWriteNode")) {526530
const char *nm = nt_str(nt, id, "name");527531
if (nm) lv = comp_gvar(c, nm + 1);528532
TyKind cur = lv ? lv->type : TY_UNKNOWN;@@ -530,11 +534,13 @@
530534
if (cur == TY_STRING) vt = TY_STRING;531535
else if (ty_is_numeric(cur) && ty_is_numeric(v)) vt = (cur == TY_FLOAT || v == TY_FLOAT) ? TY_FLOAT : TY_INT;532536
else vt = cur;533-
} else if (!strcmp(ty, "ConstantWriteNode")) {537+
}538+
else if (!strcmp(ty, "ConstantWriteNode")) {534539
const char *nm = nt_str(nt, id, "name");535540
if (nm) lv = comp_const(c, nm);536541
vt = infer_type(c, nt_ref(nt, id, "value"));537-
} else {542+
}543+
else {538544
continue;539545
}540546
if (!lv) continue;@@ -621,7 +627,8 @@
621627
if (iv < 0) continue;622628
TyKind merged = ty_unify(ci->ivar_types[iv], vt);623629
if (merged != ci->ivar_types[iv]) { ci->ivar_types[iv] = merged; changed = 1; }624-
} else if (!strcmp(ty, "CallNode")) {630+
}631+
else if (!strcmp(ty, "CallNode")) {625632
/* attr-writer assignment: obj.x = v (CallNode "x=") */626633
const char *nm = nt_str(nt, id, "name");627634
int recv = nt_ref(nt, id, "receiver");@@ -679,7 +686,8 @@
679686
/* a `x = nil` write doesn't pin the type: nil is the absent/default680687
value, so the variable takes its non-nil assignments' type */681688
if (newt == TY_NIL) newt = TY_UNKNOWN;682-
} else if (!strcmp(ty, "LocalVariableOperatorWriteNode")) {689+
}690+
else if (!strcmp(ty, "LocalVariableOperatorWriteNode")) {683691
nm = nt_str(nt, id, "name");684692
Scope *s = comp_scope_of(c, id);685693
LocalVar *cur = nm ? scope_local(s, nm) : NULL;@@ -689,7 +697,8 @@
689697
else if (ty_is_numeric(ct) && ty_is_numeric(vt))690698
newt = (ct == TY_FLOAT || vt == TY_FLOAT) ? TY_FLOAT : TY_INT;691699
else newt = ct;692-
} else {700+
}701+
else {693702
continue;694703
}695704
if (!nm) continue;src/codegen.cmodifiedView file
Loading diff…
src/main.cmodifiedView file
Loading diff…
src/node_table.cmodifiedView file
Loading diff…