public IType Evaluate(Dictionary <string, IType> lookups) { IType[] evalTuple = new IType[items.Length]; for (int i = 0; i < items.Length; i++) { if (items[i] is IUnevaluated u) { evalTuple[i] = u.Evaluate(lookups); if (evalTuple[i] is Union un) { for (int k = i; k < items.Length; k++) { evalTuple[k] = items[k]; } IType[] tuples = new IType[un.values.Length]; for (int j = 0; j < tuples.Length; j++) { var unTuple = evalTuple.ToArray(); unTuple[i] = un.values[j]; tuples[j] = new UnevaluatedTuple(unTuple).Evaluate(lookups); } return(new Union(tuples)); } } else { evalTuple[i] = items[i]; } } return(new Tuple(evalTuple)); }
public IType Evaluate(Scope scope) { IType[] evalTuple = new IType[items.Length]; bool incomplete = false; for (int i = 0; i < items.Length; i++) { if (items[i] is IUnevaluated u) { evalTuple[i] = u.Evaluate(scope); if (evalTuple[i] is Union un) { for (int k = i; k < items.Length; k++) { evalTuple[k] = items[k]; } IType[] tuples = new IType[un.values.Length]; for (int j = 0; j < tuples.Length; j++) { var unTuple = evalTuple.ToArray(); unTuple[i] = un.values[j]; tuples[j] = new UnevaluatedTuple(unTuple).Evaluate(scope); } return(new Union(tuples)); } if (evalTuple[i] is IUnevaluated) { incomplete = true; } } else { evalTuple[i] = items[i]; } } if (incomplete) { return(new BakedExpression(new UnevaluatedTuple(evalTuple), scope)); } return(new Tuple(evalTuple)); }