@@ -68,24 +68,11 @@ private static bool EmitFloatBuiltinWrapper(StringBuilder builder, TypeModel typ
6868 builder . AppendLine ( " public static TypeDefinition TypeDefinition { get; } =" ) ;
6969
7070 var assemblyFormatExpression = type . CsharpAssemblyFormat ;
71- var factoryExpression = assemblyFormatExpression == null
72- ? "static context => " + className + ".BindValue(context)"
73- : null ;
7471 EmitterHelpers . AppendDefinitionConstructor (
7572 builder ,
7673 "TypeDefinition" ,
7774 type . Name ,
78- assemblyFormatExpression ,
79- factoryExpression ) ;
80-
81- if ( factoryExpression != null )
82- {
83- builder . AppendLine ( ) ;
84- builder . AppendLine ( " public static " + className + " BindValue(TypeReferenceConstructionContext context)" ) ;
85- builder . AppendLine ( " {" ) ;
86- builder . AppendLine ( " return new " + className + "(context.Syntax as BuiltinFloatTypeSyntax);" ) ;
87- builder . AppendLine ( " }" ) ;
88- }
75+ assemblyFormatExpression ) ;
8976
9077 // Derive the scalar mnemonic from the canonical type name (e.g., "builtin.f32" -> "f32").
9178 // This ensures FloatTypeReference.Name carries the MLIR spelling, not the qualified registry key.
@@ -117,24 +104,11 @@ private static bool EmitIndexBuiltinWrapper(StringBuilder builder, TypeModel typ
117104 builder . AppendLine ( " public static TypeDefinition TypeDefinition { get; } =" ) ;
118105
119106 var assemblyFormatExpression = type . CsharpAssemblyFormat ;
120- var factoryExpression = assemblyFormatExpression == null
121- ? "static context => " + className + ".BindValue(context)"
122- : null ;
123107 EmitterHelpers . AppendDefinitionConstructor (
124108 builder ,
125109 "TypeDefinition" ,
126110 type . Name ,
127- assemblyFormatExpression ,
128- factoryExpression ) ;
129-
130- if ( factoryExpression != null )
131- {
132- builder . AppendLine ( ) ;
133- builder . AppendLine ( " public static " + className + " BindValue(TypeReferenceConstructionContext context)" ) ;
134- builder . AppendLine ( " {" ) ;
135- builder . AppendLine ( " return new " + className + "(context.Syntax);" ) ;
136- builder . AppendLine ( " }" ) ;
137- }
111+ assemblyFormatExpression ) ;
138112
139113 builder . AppendLine ( ) ;
140114 builder . AppendLine ( " public " + className + "(TypeSyntax? syntax = null)" ) ;
@@ -153,24 +127,11 @@ private static bool EmitNoneBuiltinWrapper(StringBuilder builder, TypeModel type
153127 builder . AppendLine ( " public static TypeDefinition TypeDefinition { get; } =" ) ;
154128
155129 var assemblyFormatExpression = type . CsharpAssemblyFormat ;
156- var factoryExpression = assemblyFormatExpression == null
157- ? "static context => " + className + ".BindValue(context)"
158- : null ;
159130 EmitterHelpers . AppendDefinitionConstructor (
160131 builder ,
161132 "TypeDefinition" ,
162133 type . Name ,
163- assemblyFormatExpression ,
164- factoryExpression ) ;
165-
166- if ( factoryExpression != null )
167- {
168- builder . AppendLine ( ) ;
169- builder . AppendLine ( " public static " + className + " BindValue(TypeReferenceConstructionContext context)" ) ;
170- builder . AppendLine ( " {" ) ;
171- builder . AppendLine ( " return new " + className + "(context.Syntax);" ) ;
172- builder . AppendLine ( " }" ) ;
173- }
134+ assemblyFormatExpression ) ;
174135
175136 builder . AppendLine ( ) ;
176137 builder . AppendLine ( " public " + className + "(TypeSyntax? syntax = null)" ) ;
@@ -192,13 +153,7 @@ private static void EmitPlainTypeClass(StringBuilder builder, TypeModel type, st
192153 EmitterHelpers . AppendDefinitionConstructor (
193154 builder ,
194155 "TypeDefinition" ,
195- type . Name ,
196- factoryExpression : "static context => " + className + ".BindValue(context)" ) ;
197- builder . AppendLine ( ) ;
198- builder . AppendLine ( " public static " + className + " BindValue(TypeReferenceConstructionContext context)" ) ;
199- builder . AppendLine ( " {" ) ;
200- builder . AppendLine ( " return new " + className + "(context.Syntax);" ) ;
201- builder . AppendLine ( " }" ) ;
156+ type . Name ) ;
202157 builder . AppendLine ( ) ;
203158 builder . AppendLine ( " public " + className + "(TypeSyntax? syntax = null)" ) ;
204159 builder . AppendLine ( " : base(syntax, syntax?.Location ?? MLIR.Semantics.SourceLocation.Unknown)" ) ;
@@ -214,20 +169,16 @@ private static void EmitParametrisedTypeClass(StringBuilder builder, TypeModel t
214169 {
215170 var parameters = type . Parameters ;
216171 var hasAssemblyFormat = type . AssemblyFormat != null ;
217- var syntaxClassName = hasAssemblyFormat ? className + "Syntax" : null ;
218172 var formatClassName = hasAssemblyFormat ? className + "AssemblyFormat" : null ;
219173 var assemblyFormatExpression = ! string . IsNullOrEmpty ( type . CsharpAssemblyFormat )
220174 ? type . CsharpAssemblyFormat
221175 : formatClassName != null
222176 ? "new " + formatClassName + "()"
223177 : null ;
224- var factoryExpression = formatClassName != null
225- ? "static context => " + formatClassName + ".BindValue(context.Syntax!)"
226- : null ;
227178
228179 builder . AppendLine ( "public partial class " + className + " : TypeReference" ) ;
229180 builder . AppendLine ( "{" ) ;
230- EmitTypeDefinition ( builder , type , assemblyFormatExpression , factoryExpression ) ;
181+ EmitTypeDefinition ( builder , type , assemblyFormatExpression ) ;
231182 builder . AppendLine ( ) ;
232183
233184 EmitTypeConstructor ( builder , className , parameters ) ;
@@ -250,11 +201,10 @@ private static void EmitParametrisedTypeClass(StringBuilder builder, TypeModel t
250201 private static void EmitTypeDefinition (
251202 StringBuilder builder ,
252203 TypeModel type ,
253- string ? assemblyFormatExpression ,
254- string ? factoryExpression )
204+ string ? assemblyFormatExpression )
255205 {
256206 builder . AppendLine ( " public static TypeDefinition TypeDefinition { get; } =" ) ;
257- EmitterHelpers . AppendDefinitionConstructor ( builder , "TypeDefinition" , type . Name , assemblyFormatExpression , factoryExpression ) ;
207+ EmitterHelpers . AppendDefinitionConstructor ( builder , "TypeDefinition" , type . Name , assemblyFormatExpression ) ;
258208 }
259209
260210 private static void EmitTypeConstructor ( StringBuilder builder , string className , IReadOnlyList < AttrOrTypeParameterModel > parameters )
0 commit comments