@@ -3,35 +3,6 @@ import WasmParser
33extension 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) )
0 commit comments