|
10 | 10 | // |
11 | 11 | //===----------------------------------------------------------------------===// |
12 | 12 |
|
| 13 | +import AST |
13 | 14 | import SILBridging |
14 | 15 |
|
15 | 16 | /// A utility to create new instructions at a given insertion point. |
@@ -73,4 +74,42 @@ public struct Builder { |
73 | 74 | let dr = SILBuilder_createDeallocStackRef(bridgedInsPoint, location.bridgedLocation, operand.bridged) |
74 | 75 | return dr.getAs(DeallocStackRefInst.self) |
75 | 76 | } |
| 77 | + |
| 78 | + public func createUncheckedRefCast(object: Value, type: Type) -> UncheckedRefCastInst { |
| 79 | + notifyInstructionsChanged() |
| 80 | + let object = SILBuilder_createUncheckedRefCast( |
| 81 | + bridgedInsPoint, location.bridgedLocation, object.bridged, type.bridged) |
| 82 | + return object.getAs(UncheckedRefCastInst.self) |
| 83 | + } |
| 84 | + |
| 85 | + @discardableResult |
| 86 | + public func createSetDeallocating(operand: Value, isAtomic: Bool) -> SetDeallocatingInst { |
| 87 | + notifyInstructionsChanged() |
| 88 | + let setDeallocating = SILBuilder_createSetDeallocating( |
| 89 | + bridgedInsPoint, location.bridgedLocation, operand.bridged, isAtomic) |
| 90 | + return setDeallocating.getAs(SetDeallocatingInst.self) |
| 91 | + } |
| 92 | + |
| 93 | + public func createFunctionRef(_ function: Function) -> FunctionRefInst { |
| 94 | + notifyInstructionsChanged() |
| 95 | + let functionRef = SILBuilder_createFunctionRef( |
| 96 | + bridgedInsPoint, location.bridgedLocation, function.bridged) |
| 97 | + return functionRef.getAs(FunctionRefInst.self) |
| 98 | + } |
| 99 | + |
| 100 | + @discardableResult |
| 101 | + public func createApply( |
| 102 | + function: Value, |
| 103 | + _ substitutionMap: SubstitutionMap, |
| 104 | + arguments: [Value] |
| 105 | + ) -> FunctionRefInst { |
| 106 | + notifyInstructionsChanged() |
| 107 | + let functionRef = arguments.withBridgedValues { valuesRef in |
| 108 | + SILBuilder_createApply( |
| 109 | + bridgedInsPoint, location.bridgedLocation, function.bridged, |
| 110 | + substitutionMap.bridged, valuesRef |
| 111 | + ) |
| 112 | + } |
| 113 | + return functionRef.getAs(FunctionRefInst.self) |
| 114 | + } |
76 | 115 | } |
0 commit comments