private static IExpression HandleOp(IFuncExpression op) { var e1 = op.Value; var e1s = e1.Simplify(); // If e1s is a Num then preform System.Math.[op] on value else continue simplifying. if (e1s != e1) { switch (op) { case Exp _: return(e1s is Num n1 ? new Num(Math.Exp(n1.Value)) : new Exp(e1s).Simplify()); case Log _: return(e1s is Num n2 ? new Num(Math.Log(n2.Value)) : new Log(e1s).Simplify()); case Sin _: return(e1s is Num n3 ? new Num(Math.Sin(n3.Value)) : new Sin(e1s).Simplify()); case Cos _: return(e1s is Num n4 ? new Num(Math.Cos(n4.Value)) : new Cos(e1s).Simplify()); } } return(op); }
public ForCatchExpression(INameExpression index, IRightExpression begin, IRightExpression end, IExpression entry) { _index = index; _begin = begin; _end = end; _step = new NumberExpression(1); _entry = new FuncExpression(new[] { _index.Name }, entry); }
public void Eval(IFuncExpression expr) { if (expr is StackOpExpression) { var st = (StackOpExpression) expr; st.Eval(this); //maybe this should be some sort of message? RefreshStackView(); return; } var vals = _expressions .AsEnumerable() .Reverse() .Take(expr.StackArgs) .ToList(); var eVal = expr.Eval(vals); _expressions.RemoveRange(_expressions.Count - expr.StackArgs, expr.StackArgs); if (expr is NullExpression) return; Push(eVal); }
public ForEachCatchExpression(INameExpression index, IRightExpression list, IExpression entry) { _index = index; _list = list; _entry = new FuncExpression(new[] { _index.Name }, entry); }
public ESFunction(ESDomain domain, IFuncExpression value, int count) { _domain = domain; _value = value; _count = count; }
public ESFunction(ESDomain domain, IFuncExpression value) : this(domain, value, value.Count) { // ignored }
public void Function(IFuncExpression expr) { NewLine(); VIMMessageService.SendMessage<IVIMExpressionProcessor>(a => a.Eval(expr)); }