Exemplo n.º 1
0
 /// <summary>
 /// Creates a unary expression with symbol scope, context, script refernce set.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public static Expr Negate(Expr expr, TokenData token)
 {
     var exp = new NegateExpr();
     exp.Expression = expr;
     SetupContext(exp, token);
     return exp;
 }
Exemplo n.º 2
0
 public static object Negate(NegateExpr expr, IAstVisitor visitor)
 {
     var result = expr.Expression.Visit(visitor) as LObject;
     if (result == null)
         throw ExceptionHelper.BuildRunTimeException(expr, "Null value encountered");
     
     // Negate number.
     if(result.Type == LTypes.Number)
     {
         var retVal = ((LNumber) result).Value;
         retVal = retVal*-1;
         return new LNumber(retVal);
     }
     throw ExceptionHelper.BuildRunTimeException(expr, "Can only convert a number to a negative value");
 }
Exemplo n.º 3
0
 /// <summary>
 /// Evaluate
 /// </summary>
 /// <returns></returns>
 public object VisitNegate(NegateExpr expr)
 {
     return EvalHelper.Negate(expr, this);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Evaluate
 /// </summary>
 /// <returns></returns>
 public object VisitNegate(NegateExpr expr)
 {
     return null;
 }