Skip to content

Commit ff44b0a

Browse files
Merge pull request #68 from MaxDesiatov/maxd/internalize-guest-function
Mark `Function` as `internal` and rename it as `GuestFunction`
2 parents ddf4b2f + f8ebe85 commit ff44b0a

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

Sources/WasmKit/Execution/Runtime/Store.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ extension Store {
321321

322322
/// > Note:
323323
/// <https://webassembly.github.io/spec/core/exec/modules.html#alloc-func>
324-
func allocate(function: Function, module: ModuleInstance) -> FunctionAddress {
324+
func allocate(function: GuestFunction, module: ModuleInstance) -> FunctionAddress {
325325
let address = functions.count
326326
let instance = FunctionInstance(function, module: module)
327327
functions.append(instance)

Sources/WasmKit/Execution/Types/Instances.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public final class ModuleInstance {
3737
public struct FunctionInstance {
3838
public let type: FunctionType
3939
public let module: ModuleInstance
40-
public var code: Function
40+
var code: GuestFunction
4141

42-
init(_ function: Function, module: ModuleInstance) {
42+
init(_ function: GuestFunction, module: ModuleInstance) {
4343
type = module.types[Int(function.type)]
4444
self.module = module
4545
code = function

Sources/WasmKit/Parser/Wasm/WasmParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ extension WasmParser {
12651265
}
12661266

12671267
let functions = codes.enumerated().map { [hasDataCount, features] index, code in
1268-
Function(
1268+
GuestFunction(
12691269
type: typeIndices[index], locals: code.locals,
12701270
body: {
12711271
let stream = StaticByteStream(bytes: Array(code.expression))

Sources/WasmKit/Types/Module.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/// <https://webassembly.github.io/spec/core/syntax/modules.html#modules>
55
public struct Module {
66
public internal(set) var types: [FunctionType]
7-
public internal(set) var functions: [Function]
7+
var functions: [GuestFunction]
88
public internal(set) var tables: [Table]
99
public internal(set) var memories: [Memory]
1010
public internal(set) var globals: [Global]
@@ -16,9 +16,9 @@ public struct Module {
1616
public internal(set) var exports: [Export]
1717
public internal(set) var customSections = [CustomSection]()
1818

19-
public init(
19+
init(
2020
types: [FunctionType] = [],
21-
functions: [Function] = [],
21+
functions: [GuestFunction] = [],
2222
tables: [Table] = [],
2323
memories: [Memory] = [],
2424
globals: [Global] = [],
@@ -67,7 +67,7 @@ public typealias LabelIndex = UInt32
6767

6868
/// > Note:
6969
/// <https://webassembly.github.io/spec/core/syntax/modules.html#functions>
70-
public struct Function {
70+
struct GuestFunction {
7171
init(type: TypeIndex, locals: [ValueType], body: @escaping () throws -> Expression) {
7272
self.type = type
7373
self.locals = locals

Tests/WasmKitTests/Execution/Instructions/ControlInstructionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ final class ControlInstructionTests: XCTestCase {
398398
}
399399
}
400400

401-
extension Function {
401+
extension GuestFunction {
402402
init(type: TypeIndex, locals: [ValueType], body: Expression) {
403403
self.init(type: type, locals: locals, body: { body })
404404
}

0 commit comments

Comments
 (0)