Files
bluflame/intromat/Intromat/Nodes/Code/VariableReference.cs
2026-04-18 22:31:51 +02:00

32 lines
1.0 KiB
C#

using System;
using System.Diagnostics;
using System.Text;
using Intromat.Model;
using Intromat.Model.Compiler;
using Intromat.Model.Compiler.Error;
namespace Intromat.Nodes.Code
{
public class VariableReference<T> : ITypedExpression<T>
{
public string? PreviewValue => LocalVariable?.VariableName;
public ITypedVariableDefinition<T>? LocalVariable { get; set; }
public void Compile(CompilerContext context, StringBuilder sb)
{
var localVariable = LocalVariable;
Debug.Assert(localVariable != null, nameof(localVariable) + " != null");
Debug.Assert(localVariable.VariableName != null, $"{nameof(localVariable)}.{nameof(localVariable.VariableName)} != null");
if (!context.IsInScope(localVariable))
throw new VariableOutOfScopeException(localVariable.VariableName);
sb.Append(localVariable.VariableName);
}
public T Evaluate()
{
throw new NotImplementedException();
}
}
}