Skip to content

Commit 4f70d97

Browse files
committed
markused: fix typedefs
1 parent 49c50bf commit 4f70d97

7 files changed

Lines changed: 21 additions & 28 deletions

File tree

‎vlib/crypto/md5/md5.v‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,8 @@ fn (d &Digest) clone() &Digest {
6464

6565
// new returns a new Digest (implementing hash.Hash) computing the MD5 checksum.
6666
pub fn new() &Digest {
67-
mut d := &Digest{
68-
s: []u32{len: 4}
69-
x: []u8{len: block_size}
70-
}
71-
d.reset()
67+
mut d := &Digest{}
68+
d.init()
7269
return d
7370
}
7471

‎vlib/crypto/sha1/sha1.v‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,8 @@ fn (d &Digest) clone() &Digest {
7070

7171
// new returns a new Digest (implementing hash.Hash) computing the SHA1 checksum.
7272
pub fn new() &Digest {
73-
mut d := &Digest{
74-
x: []u8{len: chunk}
75-
h: []u32{len: 5}
76-
}
77-
d.reset()
73+
mut d := &Digest{}
74+
d.init()
7875
return d
7976
}
8077

‎vlib/crypto/sha256/sha256.v‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,16 @@ fn (d &Digest) clone() &Digest {
9797

9898
// new returns a new Digest (implementing hash.Hash) computing the SHA256 checksum.
9999
pub fn new() &Digest {
100-
mut d := &Digest{
101-
h: []u32{len: 8}
102-
x: []u8{len: chunk}
103-
}
104-
d.reset()
100+
mut d := &Digest{}
101+
d.init()
105102
return d
106103
}
107104

108105
// new224 returns a new Digest (implementing hash.Hash) computing the SHA224 checksum.
109106
pub fn new224() &Digest {
110-
mut d := &Digest{
111-
h: []u32{len: 8}
112-
x: []u8{len: chunk}
113-
is224: true
114-
}
115-
d.reset()
107+
mut d := &Digest{}
108+
d.is224 = true
109+
d.init()
116110
return d
117111
}
118112

‎vlib/crypto/sha512/sha512.v‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,9 @@ fn (d &Digest) clone() &Digest {
143143
// internal
144144
fn new_digest(hash crypto.Hash) &Digest {
145145
mut d := &Digest{
146-
h: []u64{len: 8}
147-
x: []u8{len: chunk}
148146
function: hash
149147
}
150-
d.reset()
148+
d.init()
151149
return d
152150
}
153151

‎vlib/db/sqlite/sqlite.c.v‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ $if freebsd || openbsd {
55
#flag -L/usr/local/lib
66
}
77
#flag -I@VEXEROOT/thirdparty/sqlite
8+
$if tinyc {
9+
#flag -DSQLITE_DISABLE_INTRINSIC
10+
}
811
$if $pkgconfig('sqlite3') {
912
#pkgconfig sqlite3
1013
} $else $if windows {

‎vlib/v/gen/c/fn.v‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5691,10 +5691,6 @@ fn (mut g Gen) ref_or_deref_arg(arg ast.CallArg, expected_type_ ast.Type, lang a
56915691
exp_styp := g.styp(expected_type)
56925692
arg_styp := g.styp(arg_typ)
56935693
if exp_styp != arg_styp {
5694-
if g.pref.skip_unused {
5695-
mut muttable := unsafe { &ast.Table(g.table) }
5696-
muttable.used_features.used_syms[expected_type.idx()] = true
5697-
}
56985694
g.write('(${exp_styp})')
56995695
g.expr(arg.expr)
57005696
return

‎vlib/v/markused/walker.v‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,14 @@ pub fn (mut w Walker) call_expr(mut node ast.CallExpr) {
11261126
break
11271127
}
11281128
}
1129+
// Mark function pointer types used in expected arg types, so their typedefs are emitted.
1130+
// When cgen casts an argument to the expected function pointer type, the typedef must exist.
1131+
for exp_type in node.expected_arg_types {
1132+
exp_sym := w.table.sym(exp_type)
1133+
if exp_sym.kind == .function && !exp_sym.name.starts_with('fn ') {
1134+
w.mark_by_type(exp_type)
1135+
}
1136+
}
11291137
for concrete_type in node.concrete_types {
11301138
w.mark_by_type(concrete_type)
11311139
}

0 commit comments

Comments
 (0)