public static DMExpression Create(DMObject dmObject, DMProc proc, DMASTExpression expression, DreamPath?inferredPath = null) { var instance = new DMVisitorExpression(dmObject, proc, inferredPath); expression.Visit(instance); return(instance.Result); }
// Emits a reference that is to be used in an opcode that assigns/gets a value // May throw if this expression is unable to be referenced public virtual (DMReference Reference, bool Conditional) EmitReference(DMObject dmObject, DMProc proc) { throw new CompileErrorException(Location, $"attempt to reference r-value"); }
// Emits code that pushes the result of this expression to the proc's stack // May throw if this expression is unable to be pushed to the stack public abstract void EmitPushValue(DMObject dmObject, DMProc proc);
public static bool TryConstant(DMObject dmObject, DMProc proc, DMASTExpression expression, out Expressions.Constant constant) { var expr = Create(dmObject, proc, expression, null); return(expr.TryAsConstant(out constant)); }
public static void Emit(DMObject dmObject, DMProc proc, DMASTExpression expression, DreamPath?inferredPath = null) { var expr = Create(dmObject, proc, expression, inferredPath); expr.EmitPushValue(dmObject, proc); }