예제 #1
0
 private SyntaxToken EvalFunction(ConstantSyntaxToken[] values, FunctionType type)
 {
     switch (type)
     {
         case FunctionType.Sin: return SyntaxToken.Constant(Math.Sin(values[0].Value));
         case FunctionType.Cos: return SyntaxToken.Constant(Math.Cos(values[0].Value));
         case FunctionType.Tan: return SyntaxToken.Constant(Math.Tan(values[0].Value));
         case FunctionType.Cot: return SyntaxToken.Constant(MathEx.Cot(values[0].Value));
         case FunctionType.Asin: return SyntaxToken.Constant(Math.Asin(values[0].Value));
         case FunctionType.Acos: return SyntaxToken.Constant(Math.Acos(values[0].Value));
         case FunctionType.Atan: return SyntaxToken.Constant(Math.Atan(values[0].Value));
         case FunctionType.Acot: return SyntaxToken.Constant(MathEx.Acot(values[0].Value));
         case FunctionType.Log: return SyntaxToken.Constant(Math.Log(values[0].Value, values[1].Value));
         case FunctionType.Ln: return SyntaxToken.Constant(Math.Log(values[0].Value));
         case FunctionType.Abs: return SyntaxToken.Constant(Math.Abs(values[0].Value));
         default: throw new NotSupportedException();
     }
 }