Skip to content

Commit 5726968

Browse files
committed
BridgeJS: Move usesSideChannelForOptionalReturn and usesStackLifting into descriptor, unify return-type switches
BridgeJS: Code review polish — descriptor-driven liftExpression/emitOptionalPlaceholders, trailing comma fix, throw on unknown types BridgeJS: Use descriptor-driven handling in JSGlueGen to eliminate per-type switches BridgeJS: Delete dead code and fix nullable descriptor transparency in catch blocks
1 parent a3ef1e9 commit 5726968

File tree

15 files changed

+707
-1113
lines changed

15 files changed

+707
-1113
lines changed

Plugins/BridgeJS/Sources/BridgeJSCore/ClosureCodegen.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,12 @@ public struct ClosureCodegen {
148148
let abiReturnWasmType: WasmCoreType?
149149
if signature.returnType == .void {
150150
abiReturnWasmType = nil
151-
} else if let wasmType = try signature.returnType.loweringReturnInfo().returnType {
151+
} else if let wasmType = try signature.returnType.loweringReturnInfo() {
152152
abiReturnWasmType = wasmType
153153
} else {
154154
abiReturnWasmType = nil
155155
}
156156

157-
let throwReturn = abiReturnWasmType?.swiftReturnPlaceholderStmt ?? "return"
158-
159157
// Build signature using SwiftSignatureBuilder
160158
let funcSignature = SwiftSignatureBuilder.buildABIFunctionSignature(
161159
abiParameters: abiParams,

Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift

Lines changed: 52 additions & 161 deletions
Large diffs are not rendered by default.

Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,15 +1535,15 @@ public struct BridgeJSLink {
15351535

15361536
switch enumDefinition.enumType {
15371537
case .simple:
1538-
let fragment = IntrinsicJSFragment.simpleEnumHelper(enumDefinition: enumDefinition)
1538+
let fragment = IntrinsicJSFragment.caseEnumHelper(enumDefinition: enumDefinition)
15391539
_ = try fragment.printCode([enumValuesName], context)
15401540
jsTopLevelLines.append(contentsOf: printer.lines)
15411541
case .rawValue:
15421542
guard enumDefinition.rawType != nil else {
15431543
throw BridgeJSLinkError(message: "Raw value enum \(enumDefinition.name) is missing rawType")
15441544
}
15451545

1546-
let fragment = IntrinsicJSFragment.rawValueEnumHelper(enumDefinition: enumDefinition)
1546+
let fragment = IntrinsicJSFragment.caseEnumHelper(enumDefinition: enumDefinition)
15471547
_ = try fragment.printCode([enumValuesName], context)
15481548
jsTopLevelLines.append(contentsOf: printer.lines)
15491549
case .associatedValue:
@@ -2172,7 +2172,7 @@ extension BridgeJSLink {
21722172
printer.write("} catch (error) {")
21732173
printer.indent {
21742174
printer.write("setException(error);")
2175-
if let abiReturnType = returnType.abiReturnType {
2175+
if !returnType.isOptional, let abiReturnType = returnType.descriptor.wasmReturnType {
21762176
printer.write("return \(abiReturnType.placeholderValue)")
21772177
}
21782178
}

0 commit comments

Comments
 (0)