Example #1
0
        public override object Result(LogicExecutionState state)
        {
            var obj = this.Expression.Result(state);

            if (obj is float)
            {
                switch (this.Op)
                {
                case "-":
                    return(-(float)obj);

                default:
                    throw new InvalidOperationException();
                }
            }

            switch (this.Op)
            {
            case "-":
                return(LogicBuiltins.Negate(new List <object> {
                    obj
                }));

            default:
                throw new InvalidOperationException();
            }
        }
Example #2
0
        public override Expression Compile(ParameterExpression stateParameterExpression, LabelTarget returnTarget)
        {
            switch (this.Op)
            {
            case "-":
                return
                    (Expr.Invoke(
                         (Expression <Func <object, object> >)
                             (x => x is float? - (float)x: LogicBuiltins.Negate(new List <object> {
                    x
                })),
                         Expr.Convert(this.Expression.Compile(stateParameterExpression, returnTarget), typeof(object))));

            default:
                throw new InvalidOperationException();
            }
        }