-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the MethodCall.TryReplaceVariableCreationWithAssignment() funct…
…ionality for Wolverine. Bumps to 3.2
- Loading branch information
1 parent
f0752fd
commit d510764
Showing
5 changed files
with
117 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 15 additions & 3 deletions
18
src/JasperFx.CodeGeneration/Model/ValueTypeReturnVariable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
using System; | ||
using System.Linq; | ||
using JasperFx.CodeGeneration.Frames; | ||
using JasperFx.Core; | ||
|
||
namespace JasperFx.CodeGeneration.Model; | ||
|
||
public class ValueTypeReturnVariable : Variable | ||
{ | ||
private readonly Variable[] _inner; | ||
|
||
public ValueTypeReturnVariable(Type returnType, Variable[] inner) : base(returnType) | ||
{ | ||
_inner = inner; | ||
Inners = inner.Select(x => new TupleVariable(x, ReturnAction.Initialize)).ToArray(); | ||
} | ||
|
||
public override string Usage => "(" + _inner.Select(x => $"var {x.Usage}").Join(", ") + ")"; | ||
public override string Usage => "(" + Inners.Select(x => x.Usage()).Join(", ") + ")"; | ||
|
||
public TupleVariable[] Inners { get; } | ||
|
||
public record TupleVariable(Variable Inner, ReturnAction Action) | ||
{ | ||
public string Usage() => Action == ReturnAction.Initialize ? $"var {Inner.Usage}" : Inner.Usage; | ||
} | ||
|
||
public void AssignResultTo(int index, Variable variable) | ||
{ | ||
Inners[index] = new TupleVariable(variable, ReturnAction.Assign); | ||
} | ||
} |