public TupleValue(Value[] Values) { this.Values = Values; }
/// <summary> /// Adds the universal type to the root scope. This variable is unique because it is its own type. /// </summary> protected Expression AddUniversalType(string Name, Value Value) { int i = this._RootVariables.Count; Expression exp = Expression.Variable(i); this._RootVariables.Add(new _RootVariable() { Name = Name, Type = exp, Value = Value }); return exp; }
public override Value Evaluate(IMutableVariableStack<Value> Stack) { if (this.Parts != null) { Value[] vals = new Value[this.Parts.Length]; for (int t = 0; t < this.Parts.Length; t++) { vals[t] = this.Parts[t].Evaluate(Stack); } return new TupleValue(vals); } else { return TupleValue.Empty; } }
public override Value Call(Value Argument) { return this.FixValue.Call(Argument); }
/// <summary> /// Adds a variable to the root scope, returning an expression that can be used to reference it. /// </summary> protected Expression AddRootVariable(string Name, Expression Type, Value Value) { int i = this._RootVariables.Count; this._RootVariables.Add(new _RootVariable() { Name = Name, Type = Type, Value = Value }); return Expression.Variable(i); }
public override Value Call(Value Argument) { TupleValue tv = (TupleValue)Argument; return this.Function(tv.Values[0], tv.Values[1]); }
public ValueExpression(Value Value, Expression Type) { this.Datum = new Datum(Value, Type); }
public override Value Call(Value Argument) { return this.Value; }
public override Value Call(Value Argument) { return this.Expression.Evaluate((IMutableVariableStack<Value>)this.BaseStack.Append(new Value[] { Argument })); }
public override Value Call(Value Argument) { return this.Function(Argument); }
public ConstantFunction(Value Value) { this.Value = Value; }
public override Value Call(Value Argument) { return Argument; }
/// <summary> /// Calls the function with the specified arguments. Type checking must be performed before calling. Arguments may not be changed /// after this call. An argument of null can be supplied if the function type does not require an argument. /// </summary> public abstract Value Call(Value Argument);
/// <summary> /// Creates a constant function for the specified value. /// </summary> public static ConstantFunction Constant(Value Value) { return new ConstantFunction(Value); }
/// <summary> /// Creates a tuple with one item. /// </summary> public static TupleValue Create(Value A) { return new TupleValue(new Value[] { A }); }
public override Value Call(Value Argument) { return new VariantValue(this.FormIndex, Argument); }
/// <summary> /// Creates a tuple with three items. /// </summary> public static TupleValue Create(Value A, Value B, Value C) { return new TupleValue(new Value[] { A, B, C }); }
public VariantValue(int FormIndex, Value Data) { this.FormIndex = FormIndex; this.Data = Data; }
/// <summary> /// Gets an integer from a value of the integer type. /// </summary> public static int GetIntValue(Value Value) { return ((_IntValue)Value).Value; }
/// <summary> /// Creates stacks and information about the root scope of this input. /// </summary> public void PrepareRootScope(out Scope Scope, out IMutableVariableStack<Value> Stack, out IVariableStack<Expression> TypeStack) { Dictionary<string, int> varmap = new Dictionary<string, int>(); Value[] vals = new Value[this._RootVariables.Count]; Expression[] types = new Expression[vals.Length]; for (int t = 0; t < vals.Length; t++) { vals[t] = this._RootVariables[t].Value; types[t] = this._RootVariables[t].Type; varmap.Add(this._RootVariables[t].Name, t); } Scope = new Scope() { Variables = varmap, NextFreeIndex = vals.Length }; Stack = new SpaghettiStack<Value>(vals); TypeStack = new SpaghettiStack<Expression>(types); }
/// <summary> /// Creates an expression that always evaluates to the same value. /// </summary> public static ValueExpression Constant(Expression Type, Value Value) { return new ValueExpression(Value, Type); }
public Datum(Value Value, Expression Type) { this.Value = Value; this.Type = Type; }