Skip to content

Commit 68f511f

Browse files
chqrliebvdberg
authored andcommitted
initialisers: use init calls on object definitions
1 parent f7a7880 commit 68f511f

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

compiler/c2module_loader.c2

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ fn void create_signed(ast_context.Context* context,
4949
QualType qt = ast.builtins[kind];
5050
Expr* ie = cast<Expr*>(IntegerLiteral.createSignedConstant(context, 0, value, qt));
5151
u32 name2 = pool.addStr(name, true);
52-
TypeRefHolder ref;
53-
ref.init();
52+
TypeRefHolder ref.init();
5453
ref.setBuiltin(kind, 0);
5554
VarDecl* var = VarDecl.create(context, VarDeclKind.GlobalVar, name2, 0, true, &ref, a.getIdx(), 0, ie);
5655
Decl* d = cast<Decl*>(var);
@@ -71,8 +70,7 @@ fn void create_unsigned(ast_context.Context* context,
7170
QualType qt = ast.builtins[kind];
7271
Expr* ie = cast<Expr*>(IntegerLiteral.createUnsignedConstant(context, 0, value, qt));
7372
u32 name2 = pool.addStr(name, true);
74-
TypeRefHolder ref;
75-
ref.init();
73+
TypeRefHolder ref.init();
7674
ref.setBuiltin(kind, 0);
7775
VarDecl* var = VarDecl.create(context, VarDeclKind.GlobalVar, name2, 0, true, &ref, a.getIdx(), 0, ie);
7876
Decl* d = cast<Decl*>(var);
@@ -90,8 +88,7 @@ fn void add_ctype(ast_context.Context* context,
9088
BuiltinKind kind)
9189
{
9290
u32 type_name = pool.addStr(name, true);
93-
TypeRefHolder ref;
94-
ref.init();
91+
TypeRefHolder ref.init();
9592
ref.setBuiltin(kind, 0);
9693
AliasTypeDecl* t = AliasTypeDecl.create(context, type_name, 0, true, a.getIdx(), &ref);
9794
Decl* d = t.asDecl();

compiler/compiler_libs.c2

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ fn void Compiler.open_lib(Compiler* c, Component* comp) {
104104
u32 dirname = c.auxPool.addStr(libdir, false);
105105

106106
comp.setPath(dirname);
107-
string_list.List mods;
108-
mods.init(c.astPool);
107+
string_list.List mods.init(c.astPool);
109108
bool ok = manifest.parse(c.sm, file_id, c.astPool, comp, &mods);
110109
if (!ok) {
111110
stdlib.exit(-1);
@@ -267,8 +266,7 @@ fn void Compiler.showLibs(Compiler* c, string_buffer.Buf* out, const char* dirna
267266
name_idx,
268267
Kind.ExternalStatic, // doesn't matter
269268
true);
270-
string_list.List mods;
271-
mods.init(c.auxPool); // need to be astPool, but here it doesn't matter
269+
string_list.List mods.init(c.auxPool); // need to be astPool, but here it doesn't matter
272270
manifest.parse(c.sm, file_id, c.astPool, comp, &mods);
273271
c.components.add(comp);
274272
mods.free();

compiler/main.c2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,7 @@ fn void Context.free(Context* c) {
653653
public fn i32 main(i32 argc, char** argv) {
654654
console.init();
655655

656-
Context c;
657-
c.init();
656+
Context c.init();
658657
c.handle_args(argc, argv);
659658
c.handle_plugins();
660659
bool hasError = c.build_targets();

plugins/git_version_plugin.c2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ fn void generate_module(void* arg) {
8787
u32 var_name = p.info.astPool.addStr("Describe", true);
8888

8989
// create type
90-
ast.TypeRefHolder ref;
91-
ref.init();
90+
ast.TypeRefHolder ref.init();
9291
ref.setConst();
9392
ref.addArray(nil);
9493
ref.setBuiltin(ast.BuiltinKind.Char, 0);

0 commit comments

Comments
 (0)