@@ -898,7 +898,7 @@ private void GeneratePropertySetter<T>(T decl,
898
898
NewLine ( ) ;
899
899
WriteOpenBraceAndIndent ( ) ;
900
900
901
- this . GenerateMember ( @class , c => GenerateFunctionSetter ( c , property ) , true ) ;
901
+ this . GenerateMember ( @class , c => GenerateFunctionSetter ( c , property ) ) ;
902
902
}
903
903
else if ( decl is Variable )
904
904
{
@@ -907,8 +907,7 @@ private void GeneratePropertySetter<T>(T decl,
907
907
var var = decl as Variable ;
908
908
this . GenerateMember ( @class , c => GenerateVariableSetter (
909
909
c is ClassTemplateSpecialization ?
910
- c . Variables . First ( v => v . Name == decl . Name ) : var ) ,
911
- true ) ;
910
+ c . Variables . First ( v => v . Name == decl . Name ) : var ) ) ;
912
911
}
913
912
else if ( decl is Field )
914
913
{
@@ -925,7 +924,7 @@ c is ClassTemplateSpecialization ?
925
924
PopBlock ( NewLineKind . BeforeNextBlock ) ;
926
925
}
927
926
928
- private void GenerateVariableSetter ( Variable var )
927
+ private bool GenerateVariableSetter ( Variable var )
929
928
{
930
929
string ptr = GeneratePointerTo ( var ) ;
931
930
@@ -957,6 +956,8 @@ private void GenerateVariableSetter(Variable var)
957
956
958
957
if ( ctx . HasCodeBlock )
959
958
UnindentAndWriteCloseBrace ( ) ;
959
+
960
+ return true ;
960
961
}
961
962
962
963
private string GeneratePointerTo ( Variable var )
@@ -991,7 +992,7 @@ private string GeneratePointerTo(Variable var)
991
992
return ptr ;
992
993
}
993
994
994
- private void GenerateFunctionSetter ( Class @class , Property property )
995
+ private bool GenerateFunctionSetter ( Class @class , Property property )
995
996
{
996
997
var actualProperty = GetActualProperty ( property , @class ) ;
997
998
if ( actualProperty == null )
@@ -1000,8 +1001,7 @@ private void GenerateFunctionSetter(Class @class, Property property)
1000
1001
property . Name } missing from explicit specialization {
1001
1002
@class . Visit ( TypePrinter ) } ."");" ) ;
1002
1003
1003
- AddBlock ( new Block ( BlockKind . Unreachable ) ) ;
1004
- return ;
1004
+ return false ;
1005
1005
}
1006
1006
property = actualProperty ;
1007
1007
@@ -1010,6 +1010,7 @@ private void GenerateFunctionSetter(Class @class, Property property)
1010
1010
else
1011
1011
GenerateFunctionInProperty ( @class , property . SetMethod , actualProperty ,
1012
1012
new QualifiedType ( new BuiltinType ( PrimitiveType . Void ) ) ) ;
1013
+ return true ;
1013
1014
}
1014
1015
1015
1016
private void GenerateFieldSetter ( Field field , Class @class , QualifiedType fieldType )
@@ -1283,7 +1284,7 @@ c is ClassTemplateSpecialization ?
1283
1284
PopBlock ( NewLineKind . BeforeNextBlock ) ;
1284
1285
}
1285
1286
1286
- private void GenerateVariableGetter ( Variable var )
1287
+ private bool GenerateVariableGetter ( Variable var )
1287
1288
{
1288
1289
string ptr = GeneratePointerTo ( var ) ;
1289
1290
@@ -1320,9 +1321,11 @@ private void GenerateVariableGetter(Variable var)
1320
1321
1321
1322
if ( ctx . HasCodeBlock )
1322
1323
UnindentAndWriteCloseBrace ( ) ;
1324
+
1325
+ return true ;
1323
1326
}
1324
1327
1325
- private void GenerateFunctionGetter ( Class @class , Property property )
1328
+ private bool GenerateFunctionGetter ( Class @class , Property property )
1326
1329
{
1327
1330
var actualProperty = GetActualProperty ( property , @class ) ;
1328
1331
if ( actualProperty == null )
@@ -1331,8 +1334,7 @@ private void GenerateFunctionGetter(Class @class, Property property)
1331
1334
property . Name } missing from explicit specialization {
1332
1335
@class . Visit ( TypePrinter ) } ."");" ) ;
1333
1336
1334
- AddBlock ( new Block ( BlockKind . Unreachable ) ) ;
1335
- return ;
1337
+ return false ;
1336
1338
}
1337
1339
QualifiedType type = default ;
1338
1340
if ( actualProperty != property ||
@@ -1343,6 +1345,7 @@ private void GenerateFunctionGetter(Class @class, Property property)
1343
1345
type = property . QualifiedType ;
1344
1346
}
1345
1347
GenerateFunctionInProperty ( @class , actualProperty . GetMethod , actualProperty , type ) ;
1348
+ return false ;
1346
1349
}
1347
1350
1348
1351
private static Property GetActualProperty ( Property property , Class c )
@@ -2307,9 +2310,9 @@ private void GenerateDisposeMethods(Class @class)
2307
2310
if ( dtor . IsVirtual )
2308
2311
this . GenerateMember ( @class , c => GenerateDestructorCall (
2309
2312
c is ClassTemplateSpecialization ?
2310
- c . Methods . First ( m => m . InstantiatedFrom == dtor ) : dtor ) , true ) ;
2313
+ c . Methods . First ( m => m . InstantiatedFrom == dtor ) : dtor ) ) ;
2311
2314
else
2312
- this . GenerateMember ( @class , c => GenerateMethodBody ( c , dtor ) , true ) ;
2315
+ this . GenerateMember ( @class , c => GenerateMethodBody ( c , dtor ) ) ;
2313
2316
if ( @class . IsDependent || dtor . IsVirtual )
2314
2317
UnindentAndWriteCloseBrace ( ) ;
2315
2318
else
@@ -2337,7 +2340,7 @@ c is ClassTemplateSpecialization ?
2337
2340
PopBlock ( NewLineKind . BeforeNextBlock ) ;
2338
2341
}
2339
2342
2340
- private void GenerateDestructorCall ( Method dtor )
2343
+ private bool GenerateDestructorCall ( Method dtor )
2341
2344
{
2342
2345
var @class = ( Class ) dtor . Namespace ;
2343
2346
GenerateVirtualFunctionCall ( dtor , true ) ;
@@ -2349,6 +2352,7 @@ private void GenerateDestructorCall(Method dtor)
2349
2352
GenerateInternalFunctionCall ( dtor ) ;
2350
2353
Unindent ( ) ;
2351
2354
}
2355
+ return true ;
2352
2356
}
2353
2357
2354
2358
private void GenerateNativeConstructor ( Class @class )
@@ -2669,7 +2673,7 @@ public void GenerateMethod(Method method, Class @class)
2669
2673
var isVoid = method . OriginalReturnType . Type . Desugar ( ) . IsPrimitiveType ( PrimitiveType . Void ) ||
2670
2674
method . IsConstructor ;
2671
2675
this . GenerateMember ( @class , c => GenerateMethodBody (
2672
- c , method , method . OriginalReturnType ) , isVoid ) ;
2676
+ c , method , method . OriginalReturnType ) ) ;
2673
2677
}
2674
2678
2675
2679
SkipImpl :
@@ -2684,7 +2688,7 @@ public void GenerateMethod(Method method, Class @class)
2684
2688
PopBlock ( NewLineKind . BeforeNextBlock ) ;
2685
2689
}
2686
2690
2687
- private void GenerateMethodBody ( Class @class , Method method ,
2691
+ private bool GenerateMethodBody ( Class @class , Method method ,
2688
2692
QualifiedType returnType = default ( QualifiedType ) )
2689
2693
{
2690
2694
var specialization = @class as ClassTemplateSpecialization ;
@@ -2698,17 +2702,15 @@ private void GenerateMethodBody(Class @class, Method method,
2698
2702
method . Name } missing from explicit specialization {
2699
2703
@class . Visit ( TypePrinter ) } ."");" ) ;
2700
2704
2701
- AddBlock ( new Block ( BlockKind . Unreachable ) ) ;
2702
- return ;
2705
+ return false ;
2703
2706
}
2704
2707
if ( specializedMethod . Ignore )
2705
2708
{
2706
2709
WriteLine ( $@ "throw new MissingMethodException(""Method {
2707
2710
method . Name } ignored in specialization {
2708
2711
@class . Visit ( TypePrinter ) } ."");" ) ;
2709
2712
2710
- AddBlock ( new Block ( BlockKind . Unreachable ) ) ;
2711
- return ;
2713
+ return false ;
2712
2714
}
2713
2715
2714
2716
method = specializedMethod ;
@@ -2718,8 +2720,9 @@ private void GenerateMethodBody(Class @class, Method method,
2718
2720
if ( method . IsConstructor )
2719
2721
{
2720
2722
GenerateClassConstructor ( method , @class ) ;
2723
+ return true ;
2721
2724
}
2722
- else if ( method . IsOperator )
2725
+ if ( method . IsOperator )
2723
2726
{
2724
2727
GenerateOperator ( method , returnType ) ;
2725
2728
}
@@ -2755,6 +2758,8 @@ private void GenerateMethodBody(Class @class, Method method,
2755
2758
GenerateInternalFunctionCall ( method ) ;
2756
2759
}
2757
2760
}
2761
+
2762
+ return method . OriginalReturnType . Type . Desugar ( ) . IsPrimitiveType ( PrimitiveType . Void ) ;
2758
2763
}
2759
2764
2760
2765
private string OverloadParamNameWithDefValue ( Parameter p , ref int index )
@@ -2843,12 +2848,13 @@ private void GenerateEqualsAndGetHashCode(Function method, Class @class)
2843
2848
}
2844
2849
}
2845
2850
2846
- private void GenerateGetHashCode ( Class @class )
2851
+ private bool GenerateGetHashCode ( Class @class )
2847
2852
{
2848
2853
WriteLine ( $ "if ({ Helpers . InstanceIdentifier } == { TypePrinter . IntPtrType } .Zero)") ;
2849
2854
WriteLineIndent ( $ "return { TypePrinter . IntPtrType } .Zero.GetHashCode();") ;
2850
2855
WriteLine ( $@ "return (*({ TypePrinter . PrintNative ( @class ) } *) {
2851
2856
Helpers . InstanceIdentifier } ).GetHashCode();" ) ;
2857
+ return false ;
2852
2858
}
2853
2859
2854
2860
private void GenerateVirtualFunctionCall ( Method method ,
0 commit comments