File tree Expand file tree Collapse file tree 5 files changed +18
-3
lines changed Expand file tree Collapse file tree 5 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,8 @@ public static IEnumerable<CodeHint> GetHints(this SyntaxNode rootNode)
48
48
private static IEnumerable < CodeHint > DetectFunctionsToInline ( SyntaxNode rootNode )
49
49
{
50
50
var localFunctions = rootNode . FunctionDefinitions ( ) . ToList ( ) ;
51
- foreach ( var function in localFunctions )
51
+ var nonMainFunctions = localFunctions . Where ( o => ! o . IsMain ( ) ) . ToList ( ) ;
52
+ foreach ( var function in nonMainFunctions )
52
53
{
53
54
var callSites =
54
55
localFunctions
@@ -68,8 +69,8 @@ private static IEnumerable<CodeHint> DetectFunctionsToInline(SyntaxNode rootNode
68
69
69
70
private static IEnumerable < CodeHint > DetectUnusedFunctionParam ( SyntaxNode rootNode )
70
71
{
71
- var localFunctions = rootNode . FunctionDefinitions ( ) . ToList ( ) ;
72
- foreach ( var function in localFunctions . Where ( o => ! o . IsMain ( ) ) )
72
+ var localFunctions = rootNode . FunctionDefinitions ( ) . Where ( o => ! o . IsMain ( ) ) . ToList ( ) ;
73
+ foreach ( var function in localFunctions )
73
74
{
74
75
foreach ( var paramName in function . ParamNames . Select ( o => o . Token . Content ) )
75
76
{
Original file line number Diff line number Diff line change 13
13
using System . Collections . Generic ;
14
14
using System . Linq ;
15
15
using Shrinker . Parser . SyntaxNodes ;
16
+ // ReSharper disable StringLiteralTypo
16
17
17
18
namespace Shrinker . Parser . Optimizations
18
19
{
Original file line number Diff line number Diff line change @@ -652,6 +652,7 @@ namespace $NAMESPACE$
652
652
<s : Boolean x : Key =" /Default/UserDictionary/Words/=nums/@EntryIndexedValue" >True</s : Boolean >
653
653
<s : Boolean x : Key =" /Default/UserDictionary/Words/=Plex/@EntryIndexedValue" >True</s : Boolean >
654
654
<s : Boolean x : Key =" /Default/UserDictionary/Words/=printrun/@EntryIndexedValue" >True</s : Boolean >
655
+ <s : Boolean x : Key =" /Default/UserDictionary/Words/=Renamable/@EntryIndexedValue" >True</s : Boolean >
655
656
<s : Boolean x : Key =" /Default/UserDictionary/Words/=screenpro/@EntryIndexedValue" >True</s : Boolean >
656
657
<s : Boolean x : Key =" /Default/UserDictionary/Words/=Shadertoy/@EntryIndexedValue" >True</s : Boolean >
657
658
<s : Boolean x : Key =" /Default/UserDictionary/Words/=Shrinker/@EntryIndexedValue" >True</s : Boolean >
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ public void CheckGolfingCodeNames(
63
63
"void foo() { int a = 1; }|void f() { int a = 1; }" ,
64
64
"void foo() { int _a = 1; }|void f() { int a = 1; }" ,
65
65
"void main() { int number = 1; }|void main() { int n = 1; }" ,
66
+ "void mainImage() { int number = 1; }|void mainImage() { int n = 1; }" ,
66
67
"int foo() { int number = 1; number++; return number; }|int f() { int n = 1; n++; return n; }" ,
67
68
"int foo() { int number = 1; return ++number; }|int f() { int n = 1; return ++n; }" ,
68
69
"int foo() { int number = 1; return number++; }|int f() { int n = 1; return n++; }" ,
Original file line number Diff line number Diff line change @@ -42,6 +42,17 @@ public void CheckDetectingFunctionToInline()
42
42
Assert . That ( rootNode . GetHints ( ) . OfType < FunctionToInlineHint > ( ) . ToList ( ) , Has . Count . EqualTo ( 1 ) ) ;
43
43
}
44
44
45
+ [ Test ]
46
+ public void CheckInlineHintNotGivenForMainFunctions ( )
47
+ {
48
+ var lexer = new Lexer ( ) ;
49
+ lexer . Load ( "vec3 mainImage() { return vec3(0); } vec3 main() { return mainImage(); }" ) ;
50
+
51
+ var rootNode = new Parser ( lexer ) . Parse ( ) ;
52
+
53
+ Assert . That ( rootNode . GetHints ( ) . OfType < FunctionToInlineHint > ( ) . ToList ( ) , Is . Empty ) ;
54
+ }
55
+
45
56
[ Test , Sequential ]
46
57
public void CheckDetectingFunctionWithUnusedParam (
47
58
[ Values (
You can’t perform that action at this time.
0 commit comments