port from perforce
This commit is contained in:
32
intromat/Intromat/Nodes/Code/VariableReference.cs
Normal file
32
intromat/Intromat/Nodes/Code/VariableReference.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user