@@ -84,15 +84,16 @@ extension ASTGenVisitor {
8484 case . differentiable:
8585 fatalError ( " unimplemented " )
8686 case . convention:
87+ return self . generateConventionTypeAttr ( attribute: node) ? . asTypeAttribute
8788 fatalError ( " unimplemented " )
8889 case . opaqueReturnTypeOf:
8990 fatalError ( " unimplemented " )
9091
9192 case . isolated:
92- return self . generateIsolatedTypeAttr ( attribute: node)
93+ return self . generateIsolatedTypeAttr ( attribute: node) ? . asTypeAttribute
9394
9495 case . execution:
95- return self . generateExecutionTypeAttr ( attribute: node)
96+ return self . generateExecutionTypeAttr ( attribute: node) ? . asTypeAttribute
9697
9798 // SIL type attributes are not supported.
9899 case . autoreleased,
@@ -145,8 +146,41 @@ extension ASTGenVisitor {
145146 nameLoc: self . generateSourceLoc ( node. attributeName)
146147 )
147148 }
148-
149- func generateIsolatedTypeAttr( attribute node: AttributeSyntax ) -> BridgedTypeAttribute ? {
149+
150+ func generateConventionTypeAttr( attribute node: AttributeSyntax ) -> BridgedConventionTypeAttr ? {
151+ // FIXME: This don't need custom attribute arguments syntax.
152+ // FIXME: Support 'witness_method' argument.
153+ guard let args = node. arguments? . as ( ConventionAttributeArgumentsSyntax . self) else {
154+ // TODO: Diangose.
155+ return nil
156+ }
157+
158+ let cTypeName : BridgedStringRef ?
159+ let cTypeNameLoc : BridgedSourceLoc ?
160+ if let ctypeString = args. cTypeString {
161+ cTypeName = self . generateStringLiteralTextIfNotInterpolated ( expr: ctypeString)
162+ cTypeNameLoc = cTypeName != nil ? self . generateSourceLoc ( ctypeString) : nil
163+ } else {
164+ cTypeName = nil
165+ cTypeNameLoc = nil
166+ }
167+
168+ let witnessMethodProtocol : BridgedDeclNameRef = BridgedDeclNameRef ( )
169+
170+ return . createParsed(
171+ self . ctx,
172+ atLoc: self . generateSourceLoc ( node. atSign) ,
173+ nameLoc: self . generateSourceLoc ( node. attributeName) ,
174+ parensRange: self . generateSourceRange ( start: node. leftParen!, end: node. rightParen!) ,
175+ name: ctx. allocateCopy ( string: args. conventionLabel. rawText. bridged) ,
176+ nameLoc: self . generateSourceLoc ( args. conventionLabel) ,
177+ witnessMethodProtocol: witnessMethodProtocol,
178+ clangType: cTypeName ?? BridgedStringRef ( ) ,
179+ clangTypeLoc: cTypeNameLoc ?? BridgedSourceLoc ( )
180+ )
181+ }
182+
183+ func generateIsolatedTypeAttr( attribute node: AttributeSyntax ) -> BridgedIsolatedTypeAttr ? {
150184 guard case . argumentList( let isolatedArgs) = node. arguments,
151185 isolatedArgs. count == 1 ,
152186 let labelArg = isolatedArgs. first,
@@ -167,17 +201,18 @@ extension ASTGenVisitor {
167201 return nil
168202 }
169203
170- return BridgedTypeAttribute . createIsolated (
204+ return BridgedIsolatedTypeAttr . createParsed (
171205 self . ctx,
172206 atLoc: self . generateSourceLoc ( node. atSign) ,
173207 nameLoc: self . generateSourceLoc ( node. attributeName) ,
174208 lpLoc: self . generateSourceLoc ( node. leftParen!) ,
175209 isolationKindLoc: self . generateSourceLoc ( isolationKindExpr. baseName) ,
176210 isolationKind: isolationKind,
177- rpLoc: self . generateSourceLoc ( node. rightParen!) )
211+ rpLoc: self . generateSourceLoc ( node. rightParen!)
212+ )
178213 }
179214
180- func generateExecutionTypeAttr( attribute node: AttributeSyntax ) -> BridgedTypeAttribute ? {
215+ func generateExecutionTypeAttr( attribute node: AttributeSyntax ) -> BridgedExecutionTypeAttr ? {
181216 guard case . argumentList( let executionArgs) = node. arguments,
182217 executionArgs. count == 1 ,
183218 let labelArg = executionArgs. first,
@@ -198,13 +233,14 @@ extension ASTGenVisitor {
198233 return nil
199234 }
200235
201- return BridgedTypeAttribute . createExecution (
236+ return BridgedExecutionTypeAttr . createParsed (
202237 self . ctx,
203238 atLoc: self . generateSourceLoc ( node. atSign) ,
204239 nameLoc: self . generateSourceLoc ( node. attributeName) ,
205240 lpLoc: self . generateSourceLoc ( node. leftParen!) ,
206241 behaviorLoc: self . generateSourceLoc ( behaviorExpr. baseName) ,
207242 behavior: behavior,
208- rpLoc: self . generateSourceLoc ( node. rightParen!) )
243+ rpLoc: self . generateSourceLoc ( node. rightParen!)
244+ )
209245 }
210246}
0 commit comments