File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -158,10 +158,6 @@ struct ElementExprCollector: AnyInstructionVisitor {
158158 typealias Output = Void
159159
160160 var isAllRefFunc : Bool = true
161- var useExpression : Bool {
162- // if all instructions are ref.func, use function indices representation
163- return !isAllRefFunc
164- }
165161 var instructions : [ Instruction ] = [ ]
166162
167163 mutating func parse( indices: WatParser . ElementDecl . Indices , wat: inout Wat ) throws {
@@ -234,8 +230,11 @@ extension WAT.WatParser.ElementDecl {
234230
235231 var collector = ElementExprCollector ( )
236232 try collector. parse ( indices: indices, wat: & wat)
237-
238- if collector. useExpression {
233+ var useExpression : Bool {
234+ // if all instructions are ref.func, use function indices representation
235+ return !collector. isAllRefFunc || self . type != . funcRef
236+ }
237+ if useExpression {
239238 // use expression
240239 flags |= 0b0100
241240 }
@@ -262,15 +261,15 @@ extension WAT.WatParser.ElementDecl {
262261 }
263262 }
264263 if isPassive || hasTableIndex {
265- if collector . useExpression {
264+ if useExpression {
266265 encoder. encode ( type)
267266 } else {
268267 // Write ExternKind.func
269268 encoder. writeUnsignedLEB128 ( UInt8 ( 0x00 ) )
270269 }
271270 }
272271
273- if collector . useExpression {
272+ if useExpression {
274273 try encoder. encodeVector ( collector. instructions) { instruction, encoder in
275274 var exprEncoder = ExpressionEncoder ( )
276275 switch instruction {
You can’t perform that action at this time.
0 commit comments