@@ -59,10 +59,31 @@ public struct ApplyOperandConventions : Collection {
59
59
}
60
60
61
61
public func convention( of operand: Operand ) -> ArgumentConvention ? {
62
- guard let argIdx = calleeArgumentIndex ( of: operand) else { return nil }
62
+ guard let argIdx = calleeArgumentIndex ( of: operand) else {
63
+ return nil
64
+ }
63
65
return calleeArgumentConventions [ argIdx]
64
66
}
65
67
68
+ public func originalParameter( of operand: Operand ) -> ParameterInfo ? {
69
+ guard let argIdx = calleeArgumentIndex ( of: operand) else {
70
+ return nil
71
+ }
72
+ guard argIdx >= calleeArgumentConventions. firstParameterIndex else {
73
+ return nil
74
+ }
75
+ return calleeArgumentConventions. originalParameters [ argIdx]
76
+ }
77
+
78
+ public var firstParameterOperandIndex : Int {
79
+ return ApplyOperandConventions . firstArgumentIndex +
80
+ calleeArgumentConventions. firstParameterIndex
81
+ }
82
+
83
+ // TODO: rewrite uses of this API to pass an Operand instead, and
84
+ // make this private. No client should have multiple integer
85
+ // indices, some of which are caller indices, and some of which are
86
+ // callee indices.
66
87
public func calleeArgumentIndex( ofOperandIndex index: Int ) -> Int ? {
67
88
let callerArgIdx = index - ApplyOperandConventions. firstArgumentIndex
68
89
guard callerArgIdx >= 0 else { return nil }
@@ -108,22 +129,24 @@ extension ApplySite {
108
129
argumentOperands. values
109
130
}
110
131
111
- public var substitutionMap : SubstitutionMap {
112
- SubstitutionMap ( bridged. ApplySite_getSubstitutionMap ( ) )
113
- }
114
-
115
- /// Get the conventions of the callee without the applied substitutions.
116
- public var originalCalleeConvention : FunctionConvention {
117
- FunctionConvention ( for: callee. type. bridged. getASTType ( ) , in: parentFunction)
132
+ /// Indirect results including the error result.
133
+ public var indirectResultOperands : OperandArray {
134
+ let offset = ApplyOperandConventions . firstArgumentIndex
135
+ return operands [ offset..< operandConventions. firstParameterOperandIndex]
118
136
}
119
137
120
- /// Get the conventions of the callee with the applied substitutions.
121
- public var substitutedCalleeConvention : FunctionConvention {
122
- FunctionConvention ( for: bridged. ApplySite_getSubstitutedCalleeType ( ) , in: parentFunction)
138
+ public var substitutionMap : SubstitutionMap {
139
+ SubstitutionMap ( bridged. ApplySite_getSubstitutionMap ( ) )
123
140
}
124
141
125
142
public var calleeArgumentConventions : ArgumentConventions {
126
- ArgumentConventions ( functionConvention: substitutedCalleeConvention)
143
+ let originalConv = FunctionConvention ( for: callee. type. bridged. getASTType ( ) ,
144
+ in: parentFunction)
145
+ let substConv = FunctionConvention (
146
+ for: bridged. ApplySite_getSubstitutedCalleeType ( ) ,
147
+ in: parentFunction)
148
+ return ArgumentConventions ( originalFunctionConvention: originalConv,
149
+ substitutedFunctionConvention: substConv)
127
150
}
128
151
129
152
public var operandConventions : ApplyOperandConventions {
0 commit comments