Skip to content

Commit e80b1d4

Browse files
committed
refs: fix refs for struct member fn
1 parent 4c3895e commit e80b1d4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

ast/type_ref.c2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ fn bool TypeRef.isBuiltin(const TypeRef* r) {
299299
return r.flags.kind == TypeRefKind.Builtin;
300300
}
301301

302+
public fn bool TypeRef.isStructMemberFn(const TypeRef* r) {
303+
return r.flags.kind == TypeRefKind.StructMemberType;
304+
}
305+
302306
public fn bool TypeRef.isVoid(const TypeRef* r) {
303307
return r.isBuiltin() && r.flags.num_ptrs == 0 && r.getBuiltinKind() == BuiltinKind.Void;
304308
}

generator/ast_visitor.c2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,16 @@ fn void Visitor.handleTypeRef(Visitor* v, const TypeRef* r) {
119119

120120
const Ref* user = r.getUser();
121121
v.on_ref(v.arg, user);
122+
} else if (r.isStructMemberFn()) {
123+
const Ref* member = r.getStructMemberType();
124+
v.handleFunction((FunctionDecl*)member.decl);
122125
}
123126

124127
u32 num_arrays = r.getNumArrays();
125128
for (u32 i=0; i<num_arrays; i++) {
126129
Expr* e = r.getArray(i);
127130
if (e) v.handleExpr(e); // could be foo[]
128131
}
129-
130132
}
131133

132134
/*

generator/c2refs.c2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ fn u32 Lengths.get_offset(const Lengths* l, u32 start, u32 line, u32 column) {
361361
}
362362

363363
fn void Lengths.dump(const Lengths* f, bool verbose) {
364-
printf(" Lengths: %7d bytes %d/%d entries\n", f.total_size, f.count, f.cap);
364+
printf(" line lengths: %7d bytes %d/%d entries\n", f.total_size, f.count, f.cap);
365365
if (verbose) {
366366
for (u32 i=0; i<f.count; i++) {
367367
printf(" [%4d] %4d\n", i, f.lengths[i]);

0 commit comments

Comments
 (0)