Example #1
0
 public TupleValue(Value[] Values)
 {
     this.Values = Values;
 }
Example #2
0
 /// <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;
 }
Example #3
0
 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;
     }
 }
Example #4
0
 public override Value Call(Value Argument)
 {
     return this.FixValue.Call(Argument);
 }
Example #5
0
 /// <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);
 }
Example #6
0
 public override Value Call(Value Argument)
 {
     TupleValue tv = (TupleValue)Argument;
     return this.Function(tv.Values[0], tv.Values[1]);
 }
Example #7
0
 public ValueExpression(Value Value, Expression Type)
 {
     this.Datum = new Datum(Value, Type);
 }
Example #8
0
 public override Value Call(Value Argument)
 {
     return this.Value;
 }
Example #9
0
 public override Value Call(Value Argument)
 {
     return this.Expression.Evaluate((IMutableVariableStack<Value>)this.BaseStack.Append(new Value[] { Argument }));
 }
Example #10
0
 public override Value Call(Value Argument)
 {
     return this.Function(Argument);
 }
Example #11
0
 public ConstantFunction(Value Value)
 {
     this.Value = Value;
 }
Example #12
0
 public override Value Call(Value Argument)
 {
     return Argument;
 }
Example #13
0
 /// <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);
Example #14
0
 /// <summary>
 /// Creates a constant function for the specified value.
 /// </summary>
 public static ConstantFunction Constant(Value Value)
 {
     return new ConstantFunction(Value);
 }
Example #15
0
 /// <summary>
 /// Creates a tuple with one item.
 /// </summary>
 public static TupleValue Create(Value A)
 {
     return new TupleValue(new Value[] { A });
 }
Example #16
0
 public override Value Call(Value Argument)
 {
     return new VariantValue(this.FormIndex, Argument);
 }
Example #17
0
 /// <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 });
 }
Example #18
0
 public VariantValue(int FormIndex, Value Data)
 {
     this.FormIndex = FormIndex;
     this.Data = Data;
 }
Example #19
0
 /// <summary>
 /// Gets an integer from a value of the integer type.
 /// </summary>
 public static int GetIntValue(Value Value)
 {
     return ((_IntValue)Value).Value;
 }
Example #20
0
 /// <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);
 }
Example #21
0
 /// <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);
 }
Example #22
0
 public Datum(Value Value, Expression Type)
 {
     this.Value = Value;
     this.Type = Type;
 }