Skip to content

Commit 494e878

Browse files
committed
Fix for breaking ref.null
1 parent f1e14da commit 494e878

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Sources/WAT/Parser/WastParser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ struct WastParser {
6363
mutating func visitRefFunc(functionIndex: UInt32) throws {
6464
addValue(.ref(.function(FunctionAddress(functionIndex))))
6565
}
66-
mutating func visitRefNull(type: HeapType) throws {
66+
mutating func visitRefNull(type: ReferenceType) throws {
6767
let value: Reference
68-
switch type {
68+
switch type.heapType {
6969
case .externRef: value = .extern(nil)
7070
case .funcRef: value = .function(nil)
7171
}

Sources/WasmKit/Execution/Instructions/InstructionSupport.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ extension Int32: InstructionImmediate {
105105

106106
extension Instruction.RefNullOperand {
107107
init(result: VReg, type: ReferenceType) {
108-
self.init(result: result, rawType: 0) // need to figure out rawType here
108+
self.init(result: result, rawType: type.heapType.rawValue) // need to figure out rawType here
109109
}
110110

111111
var type: ReferenceType {
112-
ReferenceType(isNullable: true, heapType: .funcRef) // is this still a valid conversion?
112+
ReferenceType(isNullable: true, heapType: HeapType(rawValue: rawType)!) // is this still a valid conversion?
113113
}
114114
}
115115

Sources/WasmTypes/WasmTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public struct FunctionType: Equatable, Hashable {
1414
public let results: [ValueType]
1515
}
1616

17-
public enum HeapType: Equatable, Hashable {
17+
public enum HeapType: UInt8, Equatable, Hashable {
1818
/// A reference to any kind of function.
1919
case funcRef // -> to be renamed func
2020

0 commit comments

Comments
 (0)