25 lines
765 B
C#
25 lines
765 B
C#
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)
|
|
{
|
|
}
|
|
}
|
|
} |