Skip to content

Commit f620e6b

Browse files
Remove legacy types WasmKit.BlockType and WasmKit.LegacyBrTable
`WasmKit.BlockType` is now replaced with `WasmParser.BlockType` and `WasmKit.LegacyBrTable` is now replaced with `Wasm.BrTable`.
1 parent 3ece12e commit f620e6b

File tree

3 files changed

+0
-69
lines changed

3 files changed

+0
-69
lines changed

Sources/WasmKit/Execution/Instructions/Control.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ extension ExecutionState {
88
programCounter += 1
99
}
1010

11-
typealias BlockType = Instruction.BlockType
12-
1311
mutating func ifThen(runtime: Runtime, stack: inout Stack, elseOrEndRef: ExpressionRef) {
1412
let isTrue = stack.popValue().i32 != 0
1513
if isTrue {

Sources/WasmKit/Execution/Instructions/InstructionSupport.swift

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,6 @@ import WasmParser
33
extension Instruction {
44
typealias Memarg = MemArg
55

6-
struct BlockType: Equatable {
7-
let parameters: UInt16
8-
let results: UInt16
9-
10-
init(parameters: UInt16, results: UInt16) {
11-
self.parameters = parameters
12-
self.results = results
13-
}
14-
15-
init(blockType: WasmParser.BlockType, typeSection: [FunctionType]) throws {
16-
switch blockType {
17-
case .type:
18-
self = Instruction.BlockType(parameters: 0, results: 1)
19-
case .empty:
20-
self = Instruction.BlockType(parameters: 0, results: 0)
21-
case let .funcType(typeIndex):
22-
let typeIndex = Int(typeIndex)
23-
guard typeIndex < typeSection.count else {
24-
throw WasmParserError.invalidTypeSectionReference
25-
}
26-
let funcType = typeSection[typeIndex]
27-
self = Instruction.BlockType(
28-
parameters: UInt16(funcType.parameters.count),
29-
results: UInt16(funcType.results.count)
30-
)
31-
}
32-
}
33-
}
34-
356
struct BrTable: Equatable {
367
struct Entry {
378
var labelIndex: LabelIndex
@@ -46,38 +17,6 @@ extension Instruction {
4617
}
4718
}
4819

49-
struct LegacyBrTable: Equatable {
50-
private let bufferBase: UnsafePointer<LabelIndex>
51-
private let bufferCount: UInt32
52-
var labelIndices: UnsafeBufferPointer<LabelIndex> {
53-
UnsafeBufferPointer(start: bufferBase, count: Int(bufferCount - 1))
54-
}
55-
var defaultIndex: LabelIndex {
56-
bufferBase[Int(bufferCount - 1)]
57-
}
58-
59-
init(labelIndices: [LabelIndex], defaultIndex: LabelIndex) {
60-
let buffer = UnsafeMutableBufferPointer<LabelIndex>.allocate(capacity: labelIndices.count + 1)
61-
for (index, labelindex) in labelIndices.enumerated() {
62-
buffer[index] = labelindex
63-
}
64-
buffer[labelIndices.count] = defaultIndex
65-
self.bufferBase = UnsafePointer(buffer.baseAddress!)
66-
self.bufferCount = UInt32(buffer.count)
67-
}
68-
69-
static func == (lhs: Instruction.LegacyBrTable, rhs: Instruction.LegacyBrTable) -> Bool {
70-
lhs.labelIndices.baseAddress == rhs.labelIndices.baseAddress
71-
}
72-
}
73-
74-
// Just for migration purpose
75-
static func control(_ x: Instruction) -> Instruction { x }
76-
static func numeric(_ x: Instruction) -> Instruction { x }
77-
static func parametric(_ x: Instruction) -> Instruction { x }
78-
static func variable(_ x: Instruction) -> Instruction { x }
79-
static func reference(_ x: Instruction) -> Instruction { x }
80-
8120
static let f32Lt: Instruction = .numericFloatBinary(.lt(.f32))
8221
static let f32Gt: Instruction = .numericFloatBinary(.gt(.f32))
8322
static let f32Le: Instruction = .numericFloatBinary(.le(.f32))

Sources/WasmKit/Translator.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -970,9 +970,3 @@ fileprivate extension FunctionType {
970970
}
971971
}
972972
}
973-
974-
fileprivate extension Instruction.BlockType {
975-
init(_ functionType: FunctionType) {
976-
self.init(parameters: UInt16(functionType.parameters.count), results: UInt16(functionType.results.count))
977-
}
978-
}

0 commit comments

Comments
 (0)