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 : ITypedExpression { public string? PreviewValue => LocalVariable?.VariableName; public ITypedVariableDefinition? 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(); } } }