Evaluate() 공개 메소드

Evaluates script
public Evaluate ( IScriptContext context ) : void
context IScriptContext
리턴 void
예제 #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;
        }
예제 #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");
            }
        }
예제 #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();
        }
예제 #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);
        }
예제 #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++;
         }
     }
 }
예제 #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++;
            }
        }
예제 #7
0
 protected static bool CheckCondition(ScriptAst cond, IScriptContext context)
 {
     cond.Evaluate(context);
     return((bool)context.Result);
 }
예제 #8
0
 public object Invoke(IScriptContext context, object[] args)
 {
     metaProg.Evaluate(context);
     return(context.Result);
 }
예제 #9
0
 protected static bool CheckCondition(ScriptAst cond, IScriptContext context)
 {
     cond.Evaluate(context);
       return (bool)context.Result;
 }