Evaluate() public method

Evaluates script
public Evaluate ( IScriptContext context ) : void
context IScriptContext
return void
Exemplo n.º 1
0
        public override void Evaluate(IScriptContext context)
        {
            bool   condBool;
            object result = RuntimeHost.NullValue;

            init.Evaluate(context);
            cond.Evaluate(context);
            condBool = context.Result == null ? true : (bool)context.Result;

            while (condBool)
            {
                statement.Evaluate(context);
                result = context.Result;

                if (context.IsBreak() || context.IsReturn())
                {
                    context.SetBreak(false);
                    break;
                }

                if (context.IsContinue())
                {
                    context.SetContinue(false);
                }


                next.Evaluate(context);
                cond.Evaluate(context);
                condBool = context.Result == null ? true : (bool)context.Result;
            }

            context.Result = result;
        }
Exemplo n.º 2
0
        //TODO: reorganize switch
        public override void Evaluate(IScriptContext context)
        {
            switch (operation)
            {
            case "break":
                if (context.Result == null)
                {
                    context.Result = RuntimeHost.NullValue;
                }
                context.SetBreak(true);
                break;

            case "continue":
                if (context.Result == null)
                {
                    context.Result = RuntimeHost.NullValue;
                }
                context.SetContinue(true);
                break;

            case "return":
                expression.Evaluate(context);
                context.SetReturn(true);
                break;

            case "throw":
                expression.Evaluate(context);
                throw (Exception)context.Result;

            default:
                throw new ScriptException("This should never happen");
            }
        }
Exemplo n.º 3
0
        public override void Evaluate(IScriptContext context)
        {
            name.Evaluate(context);

            context.CreateScope(RuntimeHost.ScopeFactory.Create(ScopeTypes.Using, context.Scope, context.Result));
            statement.Evaluate(context);
            context.RemoveLocalScope();
        }
Exemplo n.º 4
0
        public object Invoke(IScriptContext context, object[] args)
        {
            activeContext = context;
            object result = RuntimeHost.NullValue;

            INotifyingScope functionScope = (INotifyingScope)RuntimeHost.ScopeFactory.Create(ScopeTypes.Function, context.Scope, context);

            context.CreateScope(functionScope);

            try
            {
                if (Parameters != null)
                {
                    context.Result = args;
                    Parameters.Evaluate(context);
                }

                functionScope.BeforeSetItem += ScopeBeforeSetItem;

                if (Contract != null)
                {
                    functionScope.AfterSetItem += CheckContractInvariant;
                    Contract.CheckPre(context);
                    Contract.CheckInv(context);
                }

                context.Result = RuntimeHost.NullValue;
                Body.Evaluate(context);
                result = context.Result;

                if (Contract != null)
                {
                    functionScope.AfterSetItem -= CheckContractInvariant;
                    Contract.CheckInv(context);
                    Contract.CheckPost(context);
                }
            }
            finally
            {
                context.RemoveLocalScope();
                context.SetBreak(false);
                context.SetContinue(false);
                context.SetReturn(false);
                context.Result = result;

                functionScope.BeforeSetItem -= ScopeBeforeSetItem;
                activeContext = null;
            }

            return(result);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Evaluates script
 /// </summary>
 /// <param name="Context">ScriptContext</param>
 public virtual void Evaluate(IScriptContext context)
 {
     if (ChildNodes.Count > 0)
     {
         int index = 0;
         while (index < ChildNodes.Count)
         {
             ScriptAst node = ChildNodes[index] as ScriptAst;
             if (node != null)
             {
                 node.Evaluate(context);
             }
             index++;
         }
     }
 }
Exemplo n.º 6
0
        //TODO: Implement Breaking, Returning, etc. here
        public override void Evaluate(IScriptContext context)
        {
            if (ChildNodes.Count == 0)
            {
                return;
            }

            int index = 0;

            while (index < ChildNodes.Count)
            {
                ScriptAst node = (ScriptAst)ChildNodes[index];
                node.Evaluate(context);

                if (context.IsBreak() || context.IsReturn() || context.IsContinue())
                {
                    break;
                }

                index++;
            }
        }
Exemplo n.º 7
0
 protected static bool CheckCondition(ScriptAst cond, IScriptContext context)
 {
     cond.Evaluate(context);
     return((bool)context.Result);
 }
Exemplo n.º 8
0
 public object Invoke(IScriptContext context, object[] args)
 {
     metaProg.Evaluate(context);
     return(context.Result);
 }
Exemplo n.º 9
0
 protected static bool CheckCondition(ScriptAst cond, IScriptContext context)
 {
     cond.Evaluate(context);
       return (bool)context.Result;
 }