Skip to content

Commit ee3df04

Browse files
WAT: Rename parser and encoder file names
1 parent 73fd965 commit ee3df04

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

Sources/WAT/InstructionEncoder.swift renamed to Sources/WAT/BinaryInstructionEncoder.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import WasmParser
66
import WasmTypes
77

8-
/// An instruction encoder that is responsible for encoding opcodes and immediates.
9-
protocol InstructionEncoder: InstructionVisitor {
8+
/// An instruction encoder that is responsible for encoding opcodes and immediates
9+
/// in Wasm binary format.
10+
protocol BinaryInstructionEncoder: InstructionVisitor {
1011
/// Encodes an instruction opcode.
1112
mutating func encodeInstruction(_ opcode: UInt8, _ prefix: UInt8?) throws
1213

@@ -34,8 +35,8 @@ protocol InstructionEncoder: InstructionVisitor {
3435
mutating func encodeImmediates(typeIndex: UInt32, tableIndex: UInt32) throws
3536
}
3637

37-
// InstructionEncoder implements the InstructionVisitor protocol to call the corresponding encode method.
38-
extension InstructionEncoder {
38+
// BinaryInstructionEncoder implements the InstructionVisitor protocol to call the corresponding encode method.
39+
extension BinaryInstructionEncoder {
3940
mutating func visitUnreachable() throws { try encodeInstruction(0x00, nil) }
4041
mutating func visitNop() throws { try encodeInstruction(0x01, nil) }
4142
mutating func visitBlock(blockType: BlockType) throws {

Sources/WAT/Encoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ extension WatParser.DataSegmentDecl {
441441
}
442442
}
443443

444-
struct ExpressionEncoder: InstructionEncoder {
444+
struct ExpressionEncoder: BinaryInstructionEncoder {
445445
var encoder = Encoder()
446446
var hasDataSegmentInstruction: Bool = false
447447

Utilities/Sources/WasmGen.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ enum WasmGen {
314314
return code
315315
}
316316

317-
static func generateTextParser(_ instructions: InstructionSet) -> String {
317+
static func generateTextInstructionParser(_ instructions: InstructionSet) -> String {
318318
var code = """
319319
import WasmParser
320320
import WasmTypes
@@ -399,13 +399,14 @@ enum WasmGen {
399399
return code
400400
}
401401

402-
static func generateInstructionEncoder(_ instructions: InstructionSet) -> String {
402+
static func generateBinaryInstructionEncoder(_ instructions: InstructionSet) -> String {
403403
var code = """
404404
import WasmParser
405405
import WasmTypes
406406
407-
/// An instruction encoder that is responsible for encoding opcodes and immediates.
408-
protocol InstructionEncoder: InstructionVisitor {
407+
/// An instruction encoder that is responsible for encoding opcodes and immediates
408+
/// in Wasm binary format.
409+
protocol BinaryInstructionEncoder: InstructionVisitor {
409410
/// Encodes an instruction opcode.
410411
mutating func encodeInstruction(_ opcode: UInt8, _ prefix: UInt8?) throws
411412
@@ -443,8 +444,8 @@ enum WasmGen {
443444
code += """
444445
}
445446
446-
// InstructionEncoder implements the InstructionVisitor protocol to call the corresponding encode method.
447-
extension InstructionEncoder {
447+
// BinaryInstructionEncoder implements the InstructionVisitor protocol to call the corresponding encode method.
448+
extension BinaryInstructionEncoder {
448449
449450
"""
450451

@@ -613,12 +614,12 @@ enum WasmGen {
613614
+ "\n"
614615
),
615616
GeneratedFile(
616-
projectSources + ["WAT", "ParseInstruction.swift"],
617-
header + generateTextParser(instructions)
617+
projectSources + ["WAT", "ParseTextInstruction.swift"],
618+
header + generateTextInstructionParser(instructions)
618619
),
619620
GeneratedFile(
620-
projectSources + ["WAT", "InstructionEncoder.swift"],
621-
header + generateInstructionEncoder(instructions)
621+
projectSources + ["WAT", "BinaryInstructionEncoder.swift"],
622+
header + generateBinaryInstructionEncoder(instructions)
622623
),
623624
]
624625

0 commit comments

Comments
 (0)