using System.Collections.Immutable; using System.Runtime.CompilerServices; using imm; namespace exp; abstract public record class Exp : imm.Versioned> { protected Exp() : base() { } abstract public T exec(); } public record class ConstantExp( T value ) : Exp { public override T exec() => value; } public record class VarExp : Exp { public T val = default!; public VarExp() { } public override T exec() => val; public VarExp set( T newVal ) { return this with { val = newVal }; } } public ref struct RefHolder { public T val = default!; public RefHolder() { } public RefHolder( T initial ) { val = initial; } } /* public record class Op( EntityId id, Func fn, [CallerMemberName] string dbgMethod = "", [CallerFilePath] string dbgPath = "", [CallerLineNumber] int dbgLine = 0, [CallerArgumentExpression("fn")] string dbgExp = "" ) : Exp { public override T exec() { var ent = ent.Entity.Get( id ); if( ent == null ) throw new System.Exception( $"Op<{typeof(T).Name}>: Entity {id} not found" ); return fn( ent ); } } */ public record class StackExp( VarExp BaseVal ) : Exp { public VarExp ModValue = BaseVal; public ImmutableArray> Adds = ImmutableArray>.Empty; public ImmutableArray> Mults = ImmutableArray>.Empty; public override T exec() { return ModValue.exec(); } } /// //