Пример #1
0
        private WatchItem Debugger_RefreshWatch(ScriptExecutionContext context, DynamicExpression dynExpr)
        {
            try
            {
                SymbolRef L = dynExpr.FindSymbol(context);
                DynValue  v = dynExpr.Evaluate(context);

                return(new WatchItem()
                {
                    IsError = dynExpr.IsConstant(),
                    LValue = L,
                    Value = v,
                    Name = dynExpr.ExpressionCode
                });
            }
            catch (Exception ex)
            {
                return(new WatchItem()
                {
                    IsError = true,
                    Value = DynValue.NewString(ex.Message),
                    Name = dynExpr.ExpressionCode
                });
            }
        }
Пример #2
0
 public static DynValue eval(ScriptExecutionContext executionContext, CallbackArguments args)
 {
     try
     {
         if (args[0].Type == DataType.UserData)
         {
             UserData ud = args[0].UserData;
             if (ud.Object is DynamicExprWrapper)
             {
                 return(((DynamicExprWrapper)ud.Object).Expr.Evaluate(executionContext));
             }
             else
             {
                 throw ScriptRuntimeException.BadArgument(0, "dynamic.eval", "A userdata was passed, but was not a previously prepared expression.");
             }
         }
         else
         {
             DynValue          vs   = args.AsType(0, "dynamic.eval", DataType.String, false);
             DynamicExpression expr = executionContext.GetScript().CreateDynamicExpression(vs.String);
             return(expr.Evaluate(executionContext));
         }
     }
     catch (SyntaxErrorException ex)
     {
         throw new ScriptRuntimeException(ex);
     }
 }
		private WatchItem Debugger_RefreshWatch(ScriptExecutionContext context, DynamicExpression dynExpr)
		{
			try
			{
				SymbolRef L = dynExpr.FindSymbol(context);
				DynValue v = dynExpr.Evaluate(context);

				return new WatchItem()
				{
					IsError = dynExpr.IsConstant(),
					LValue = L,
					Value = v,
					Name = dynExpr.ExpressionCode
				};
			}
			catch (Exception ex)
			{
				return new WatchItem()
				{
					IsError = true,
					Value = DynValue.NewString(ex.Message),
					Name = dynExpr.ExpressionCode
				};
			}
		}
Пример #4
0
        public DynValue Evaluate(string expression)
        {
            DynamicExpression expr = CreateDynExpr(expression);

            return(expr.Evaluate());
        }