@@ -109,26 +109,42 @@ namespace irgen {
109109 NecessaryBindings bindings;
110110 SmallVector<ArgumentInfo, 4 > argumentInfos;
111111
112+ unsigned getErrorIndex () { return (unsigned )FixedIndex::Error; }
113+ unsigned getFirstIndirectReturnIndex () {
114+ return getErrorIndex () + getErrorCount ();
115+ }
116+ unsigned getLocalContextIndex () {
117+ assert (hasLocalContext ());
118+ return getFirstIndirectReturnIndex () + getIndirectReturnCount ();
119+ }
120+ unsigned getIndexAfterLocalContext () {
121+ return getFirstIndirectReturnIndex () + getIndirectReturnCount () +
122+ (hasLocalContext () ? 1 : 0 );
123+ }
124+ unsigned getBindingsIndex () {
125+ assert (hasBindings ());
126+ return getIndexAfterLocalContext ();
127+ }
128+ unsigned getFirstArgumentIndex () {
129+ return getIndexAfterLocalContext () + (hasBindings () ? 1 : 0 );
130+ }
131+ unsigned getIndexAfterArguments () {
132+ return getFirstArgumentIndex () + getArgumentCount ();
133+ }
134+ unsigned getFirstDirectReturnIndex () { return getIndexAfterArguments (); }
135+
112136 public:
113137 bool canHaveError () { return canHaveValidError; }
114- unsigned getErrorIndex () { return (unsigned )FixedIndex::Error; }
115138 ElementLayout getErrorLayout () { return getElement (getErrorIndex ()); }
116139 unsigned getErrorCount () { return (unsigned )FixedCount::Error; }
117140 SILType getErrorType () { return errorType; }
118141
119- unsigned getFirstIndirectReturnIndex () {
120- return getErrorIndex () + getErrorCount ();
121- }
122142 ElementLayout getIndirectReturnLayout (unsigned index) {
123143 return getElement (getFirstIndirectReturnIndex () + index);
124144 }
125145 unsigned getIndirectReturnCount () { return indirectReturnInfos.size (); }
126146
127147 bool hasLocalContext () { return (bool )localContextInfo; }
128- unsigned getLocalContextIndex () {
129- assert (hasLocalContext ());
130- return getFirstIndirectReturnIndex () + getIndirectReturnCount ();
131- }
132148 ElementLayout getLocalContextLayout () {
133149 assert (hasLocalContext ());
134150 return getElement (getLocalContextIndex ());
@@ -141,48 +157,30 @@ namespace irgen {
141157 assert (hasLocalContext ());
142158 return localContextInfo->type ;
143159 }
144- unsigned getIndexAfterLocalContext () {
145- return getFirstIndirectReturnIndex () + getIndirectReturnCount () +
146- (hasLocalContext () ? 1 : 0 );
147- }
148160
149161 bool hasBindings () const { return !bindings.empty (); }
150- unsigned getBindingsIndex () {
151- assert (hasBindings ());
152- return getIndexAfterLocalContext ();
153- }
154162 ElementLayout getBindingsLayout () {
155163 assert (hasBindings ());
156164 return getElement (getBindingsIndex ());
157165 }
158- ParameterConvention getBindingsConvention () {
159- return ParameterConvention::Direct_Unowned;
160- }
161166 const NecessaryBindings &getBindings () const { return bindings; }
162167
163- unsigned getFirstArgumentIndex () {
164- return getIndexAfterLocalContext () + (hasBindings () ? 1 : 0 );
165- }
166168 ElementLayout getArgumentLayout (unsigned index) {
167169 return getElement (getFirstArgumentIndex () + index);
168170 }
169- ParameterConvention getArgumentConvention (unsigned index) {
170- return argumentInfos[index].convention ;
171- }
172171 SILType getArgumentType (unsigned index) {
173172 return argumentInfos[index].type ;
174173 }
174+ // Returns the type of a parameter of the substituted function using the
175+ // indexing of the function parameters, *not* the indexing of
176+ // AsyncContextLayout.
175177 SILType getParameterType (unsigned index) {
176178 SILFunctionConventions origConv (substitutedType, IGF.getSILModule ());
177179 return origConv.getSILArgumentType (
178180 index, IGF.IGM .getMaximalTypeExpansionContext ());
179181 }
180182 unsigned getArgumentCount () { return argumentInfos.size (); }
181- unsigned getIndexAfterArguments () {
182- return getFirstArgumentIndex () + getArgumentCount ();
183- }
184183
185- unsigned getFirstDirectReturnIndex () { return getIndexAfterArguments (); }
186184 unsigned getDirectReturnCount () { return directReturnInfos.size (); }
187185 ElementLayout getDirectReturnLayout (unsigned index) {
188186 return getElement (getFirstDirectReturnIndex () + index);
0 commit comments