static E Compile(
ElementExpression expression,
Dictionary <string, ParameterExpression> spans,
Dictionary <string, ParameterExpression> indices)
{
switch (expression.ArityKind)
{
case ArityKind.Element:
return(Compile(expression.Element, spans, indices));
case ArityKind.Unary:
switch (expression.UnaryKind)
{
case UnaryExpressionKind.Exp:
throw new NotImplementedException();
case UnaryExpressionKind.Log:
throw new NotImplementedException();
default:
throw new NotSupportedException();
}
case ArityKind.Binary:
switch (expression.BinaryKind)
{
case BinaryExpressionKind.Add:
return(E.Add(
Compile(expression.Expr1, spans, indices),
Compile(expression.Expr2, spans, indices)));
case BinaryExpressionKind.Subtract:
return(E.Add(
Compile(expression.Expr1, spans, indices),
E.Negate(Compile(expression.Expr2, spans, indices))));
case BinaryExpressionKind.Multiply:
return(E.Multiply(
Compile(expression.Expr1, spans, indices),
Compile(expression.Expr2, spans, indices)));
case BinaryExpressionKind.Divide:
return(E.Divide(
Compile(expression.Expr1, spans, indices),
Compile(expression.Expr2, spans, indices)));
default:
throw new NotSupportedException();
}
case ArityKind.Ternary:
throw new NotImplementedException();
default:
throw new NotSupportedException();
}
}