32 lines
1.0 KiB
C#
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();
|
|
}
|
|
}
|
|
} |