port from perforce
This commit is contained in:
25
intromat/Intromat/Model/InlineVariableDefinition.cs
Normal file
25
intromat/Intromat/Model/InlineVariableDefinition.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using Intromat.Model.Compiler;
|
||||
|
||||
namespace Intromat.Model
|
||||
{
|
||||
public class InlineVariableDefinition<T> : ITypedVariableDefinition<T>
|
||||
{
|
||||
public ITypedExpression<T>? Value { get; set; }
|
||||
public string? VariableName { get; private set; }
|
||||
|
||||
public void Compile(CompilerContext context, StringBuilder sb)
|
||||
{
|
||||
VariableName = context.FindFreeVariableName();
|
||||
context.AddVariableToCurrentScope(this);
|
||||
sb.Append($"{VariableName} = ");
|
||||
Debug.Assert(Value != null, nameof(Value) + " != null");
|
||||
Value.Compile(context, sb);
|
||||
}
|
||||
|
||||
public void CompileHeader(CompilerContext context, StringBuilder sb)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user