@@ -63,9 +63,6 @@ enum WasmGen {
6363 /// The visitor pattern is used while parsing WebAssembly expressions to allow for easy extensibility.
6464 /// See the expression parsing method ``Code/parseExpression(visitor:)``
6565 public protocol InstructionVisitor {
66-
67- /// The return type of visitor methods.
68- associatedtype Output
6966 """
7067
7168 for instruction in instructions {
@@ -75,7 +72,7 @@ enum WasmGen {
7572 code += instruction. immediates. map { i in
7673 " \( i. label) : \( i. type) "
7774 } . joined ( separator: " , " )
78- code += " ) throws -> Output "
75+ code += " ) throws "
7976 }
8077
8178 code += """
@@ -88,7 +85,7 @@ enum WasmGen {
8885
8986 extension InstructionVisitor {
9087 /// Visits an instruction.
91- public mutating func visit(_ instruction: Instruction) throws -> Output {
88+ public mutating func visit(_ instruction: Instruction) throws {
9289 switch instruction {
9390
9491 """
@@ -113,19 +110,16 @@ enum WasmGen {
113110
114111 code += """
115112
116-
117- /// A visitor for WebAssembly instructions that returns `Void` with default implementations.
118- public protocol VoidInstructionVisitor: InstructionVisitor where Output == Void {}
119-
120- extension VoidInstructionVisitor {
113+ // MARK: - Placeholder implementations
114+ extension InstructionVisitor {
121115
122116 """
123117 for instruction in instructions {
124118 code += " public mutating func \( instruction. visitMethodName) ( "
125119 code += instruction. immediates. map { i in
126120 " \( i. label) : \( i. type) "
127121 } . joined ( separator: " , " )
128- code += " ) throws -> Void {} \n "
122+ code += " ) throws {} \n "
129123 }
130124 code += " } \n "
131125
@@ -176,7 +170,7 @@ enum WasmGen {
176170 /// A visitor that visits all instructions by a single visit method.
177171 public protocol AnyInstructionVisitor: InstructionVisitor {
178172 /// Visiting any instruction.
179- mutating func visit(_ instruction: Instruction) throws -> Output
173+ mutating func visit(_ instruction: Instruction) throws
180174 }
181175
182176 extension AnyInstructionVisitor {
@@ -188,7 +182,7 @@ enum WasmGen {
188182 code += instruction. immediates. map { i in
189183 " \( i. label) : \( i. type) "
190184 } . joined ( separator: " , " )
191- code += " ) throws -> Output { "
185+ code += " ) throws { "
192186 code += " return try self.visit( " + buildInstructionInstanceFromContext( instruction) + " ) "
193187 code += " } \n "
194188 }
@@ -224,7 +218,7 @@ enum WasmGen {
224218 code += instruction. immediates. map { i in
225219 " \( i. label) : \( i. type) "
226220 } . joined ( separator: " , " )
227- code += " ) throws -> V.Output { \n "
221+ code += " ) throws { \n "
228222 code += " trace( "
229223 code += buildInstructionInstanceFromContext ( instruction)
230224 code += " ) \n "
@@ -253,7 +247,7 @@ enum WasmGen {
253247 /// - Returns: A closure that invokes the corresponding visitor method. Nil if the keyword is not recognized.
254248 ///
255249 /// Note: The returned closure does not consume any tokens.
256- func parseTextInstruction<V: InstructionVisitor>(keyword: String, expressionParser: inout ExpressionParser<V>, wat: inout Wat) throws -> ((inout V) throws -> V.Output )? {
250+ func parseTextInstruction<V: InstructionVisitor>(keyword: String, expressionParser: inout ExpressionParser<V>, wat: inout Wat) throws -> ((inout V) throws -> Void )? {
257251 switch keyword {
258252
259253 """
0 commit comments