Initialize() public méthode

public Initialize ( ScriptObject>.Dictionary variable ) : void
variable ScriptObject>.Dictionary
Résultat void
        void ProcessCallFor()
        {
            CodeFor       code         = (CodeFor)m_scriptInstruction.Operand0;
            ScriptContext context      = code.Context;
            ScriptContext blockContext = code.BlockContext;

            context.Initialize(this);
            context.Execute(code.BeginExecutable);
            ScriptBoolean Condition;

            for ( ; ;)
            {
                if (code.Condition != null)
                {
                    Condition = context.ResolveOperand(code.Condition) as ScriptBoolean;
                    if (Condition == null)
                    {
                        throw new ExecutionException("for 跳出条件必须是一个bool型");
                    }
                    if (!Condition.Value)
                    {
                        break;
                    }
                }
                blockContext.Initialize(context);
                blockContext.Execute();
                if (blockContext.IsBreak)
                {
                    break;
                }
                context.Execute(code.LoopExecutable);
            }
        }
        private void ProcessCallForeach()
        {
            object       obj3;
            CodeForeach  @foreach = (CodeForeach)this.m_scriptInstruction.operand0;
            ScriptObject obj2     = this.ResolveOperand(@foreach.LoopObject);

            if (!(obj2 is ScriptFunction))
            {
                throw new ExecutionException(this.m_script, "foreach函数必须返回一个ScriptFunction");
            }
            ScriptFunction function = (ScriptFunction)obj2;

Label_003E:
            obj3 = function.Call();
            if (obj3 != null)
            {
                ScriptContext context = new ScriptContext(this.m_script, @foreach.BlockExecutable, this, Executable_Block.Foreach);
                context.Initialize(@foreach.Identifier, this.m_script.CreateObject(obj3));
                context.Execute();
                if (!context.IsOver)
                {
                    goto Label_003E;
                }
            }
        }
        void ProcessCallBlock()
        {
            ScriptContext context = (ScriptContext)m_scriptInstruction.Value;

            context.Initialize(this);
            context.Execute();
        }
Exemple #4
0
        void ProcessCallBlock()
        {
            ScriptContext context = new ScriptContext(m_script, (ScriptExecutable)m_scriptInstruction.Value);

            context.Initialize(this);
            context.Execute();
        }
        void ProcessCallForeach()
        {
            CodeForeach  code = (CodeForeach)m_scriptInstruction.Operand0;
            ScriptObject loop = ResolveOperand(code.LoopObject);

            if (!(loop is ScriptFunction))
            {
                throw new ExecutionException(m_script, "foreach函数必须返回一个ScriptFunction");
            }
            object         obj;
            ScriptFunction func = (ScriptFunction)loop;
            ScriptContext  context;

            for ( ; ;)
            {
                obj = func.Call();
                if (obj == null)
                {
                    return;
                }
                context = new ScriptContext(m_script, code.BlockExecutable, this, Executable_Block.Foreach);
                context.Initialize(code.Identifier, m_script.CreateObject(obj));
                context.Execute();
                if (context.IsOver)
                {
                    break;
                }
            }
        }
Exemple #6
0
        void ProcessCallSwitch()
        {
            CodeSwitch   code = (CodeSwitch)m_scriptInstruction.Operand0;
            ScriptObject obj  = ResolveOperand(code.Condition);
            bool         exec = false;

            foreach (TempCase c in code.Cases)
            {
                foreach (object a in c.Allow)
                {
                    if (a.Equals(obj.ObjectValue))
                    {
                        exec = true;
                        ScriptContext context = c.GetContext();
                        context.Initialize(this);
                        context.Execute();
                        break;
                    }
                }
            }
            if (exec == false && code.Default != null)
            {
                ScriptContext context = code.Default.GetContext();
                context.Initialize(this);
                context.Execute();
            }
        }
Exemple #7
0
        void ProcessCallForeach()
        {
            CodeForeach  code = (CodeForeach)m_scriptInstruction.Operand0;
            ScriptObject loop = ResolveOperand(code.LoopObject);

            if (!loop.IsFunction)
            {
                throw new ExecutionException(m_script, "foreach函数必须返回一个ScriptFunction");
            }
            ScriptObject obj;

            for ( ; ;)
            {
                ScriptContext context = code.GetBlockContext();
                obj = m_script.CreateObject(((ScriptFunction)loop).Call());
                if (obj == null || obj is ScriptNull)
                {
                    return;
                }
                context.Initialize(this, code.Identifier, obj);
                context.Execute();
                if (context.IsOver)
                {
                    break;
                }
            }
        }
        void ProcessTry()
        {
            CodeTry code = (CodeTry)m_scriptInstruction.Operand0;

            try {
                new ScriptContext(m_script, code.TryExecutable, this).Execute();
            } catch (InteriorException ex) {
                ScriptContext context = new ScriptContext(m_script, code.CatchExecutable, this);
                context.Initialize(code.Identifier, ex.obj);
                context.Execute();
            } catch (System.Exception ex) {
                ScriptContext context = new ScriptContext(m_script, code.CatchExecutable, this);
                context.Initialize(code.Identifier, m_script.CreateObject(ex));
                context.Execute();
            }
        }
Exemple #9
0
        void ProcessCallForSimple()
        {
            CodeForSimple code        = (CodeForSimple)m_scriptInstruction.Operand0;
            ScriptNumber  beginNumber = ResolveOperand(code.Begin) as ScriptNumber;

            if (beginNumber == null)
            {
                throw new ExecutionException(m_script, "forsimple 初始值必须是number");
            }
            ScriptNumber finishedNumber = ResolveOperand(code.Finished) as ScriptNumber;

            if (finishedNumber == null)
            {
                throw new ExecutionException(m_script, "forsimple 最大值必须是number");
            }
            int begin    = beginNumber.ToInt32();
            int finished = finishedNumber.ToInt32();
            int step;

            if (code.Step != null)
            {
                ScriptNumber stepNumber = ResolveOperand(code.Step) as ScriptNumber;
                if (stepNumber == null)
                {
                    throw new ExecutionException(m_script, "forsimple Step必须是number");
                }
                step = stepNumber.ToInt32();
            }
            else
            {
                step = 1;
            }
            var variables = new Dictionary <String, ScriptObject>();

            for (int i = begin; i <= finished; i += step)
            {
                ScriptContext context = code.GetBlockContext();
                variables[code.Identifier] = m_script.CreateNumber(i);
                context.Initialize(this, variables);
                context.Execute();
                if (context.IsOver)
                {
                    break;
                }
            }
        }
        void ProcessCallForSimple()
        {
            CodeForSimple code        = (CodeForSimple)m_scriptInstruction.operand0;
            ScriptNumber  beginNumber = ResolveOperand(code.Begin) as ScriptNumber;

            if (beginNumber == null)
            {
                throw new ExecutionException(m_script, "forsimple 初始值必须是number");
            }
            ScriptNumber finishedNumber = ResolveOperand(code.Finished) as ScriptNumber;

            if (finishedNumber == null)
            {
                throw new ExecutionException(m_script, "forsimple 最大值必须是number");
            }
            int begin    = beginNumber.ToInt32();
            int finished = finishedNumber.ToInt32();
            int step;

            if (code.Step != null)
            {
                ScriptNumber stepNumber = ResolveOperand(code.Step) as ScriptNumber;
                if (stepNumber == null)
                {
                    throw new ExecutionException(m_script, "forsimple Step必须是number");
                }
                step = stepNumber.ToInt32();
            }
            else
            {
                step = 1;
            }
            int           i = begin;
            ScriptContext context;

            for (; i <= finished; i += step)
            {
                context = new ScriptContext(m_script, code.BlockExecutable, this, Executable_Block.For);
                context.Initialize(code.Identifier, new ScriptNumberDouble(m_script, i));
                context.Execute();
                if (context.IsOver)
                {
                    break;
                }
            }
        }
Exemple #11
0
        void ProcessTry()
        {
            CodeTry code = (CodeTry)m_scriptInstruction.Operand0;

            try {
                ScriptContext context = code.GetTryContext();
                context.Initialize(this);
                context.Execute();
            } catch (InteriorException ex) {
                ScriptContext context = code.GetCatchContext();
                context.Initialize(this, code.Identifier, ex.obj);
                context.Execute();
            } catch (System.Exception ex) {
                ScriptContext context = code.GetCatchContext();
                context.Initialize(this, code.Identifier, m_script.CreateObject(ex));
                context.Execute();
            }
        }
Exemple #12
0
 bool ProcessCondition(TempCondition con, ScriptContext context, Executable_Block block)
 {
     if (con == null)
     {
         return(false);
     }
     if (con.Allow != null)
     {
         object b = ResolveOperand(con.Allow).ObjectValue;
         if (b == null || b.Equals(false))
         {
             return(false);
         }
     }
     context.Initialize(this);
     context.Execute();
     return(true);
 }
        private void ProcessCallForSimple()
        {
            int           num3;
            CodeForSimple simple = (CodeForSimple)this.m_scriptInstruction.operand0;
            ScriptNumber  number = this.ResolveOperand(simple.Begin) as ScriptNumber;

            if (number == null)
            {
                throw new ExecutionException(this.m_script, "forsimple 初始值必须是number");
            }
            ScriptNumber number2 = this.ResolveOperand(simple.Finished) as ScriptNumber;

            if (number2 == null)
            {
                throw new ExecutionException(this.m_script, "forsimple 最大值必须是number");
            }
            int num  = number.ToInt32();
            int num2 = number2.ToInt32();

            if (simple.Step != null)
            {
                ScriptNumber number3 = this.ResolveOperand(simple.Step) as ScriptNumber;
                if (number3 == null)
                {
                    throw new ExecutionException(this.m_script, "forsimple Step必须是number");
                }
                num3 = number3.ToInt32();
            }
            else
            {
                num3 = 1;
            }
            for (double i = num; i <= num2; i += num3)
            {
                ScriptContext context = new ScriptContext(this.m_script, simple.BlockExecutable, this, Executable_Block.For);
                context.Initialize(simple.Identifier, new ScriptNumberDouble(this.m_script, i));
                context.Execute();
                if (context.IsOver)
                {
                    return;
                }
            }
        }
 public ScriptObject Call(ScriptContext parentContext, Dictionary<String, ScriptObject> objs, ScriptObject[] parameters) {
     int length = parameters.Length;
     if (m_Params) {
         ScriptArray paramsArray = m_Script.CreateArray();
         for (int i = 0; i < m_ParameterCount - 1; ++i) {
             objs[m_ListParameters[i]] = (parameters != null && length > i) ? parameters[i] : m_Script.Null;
         }
         for (int i = m_ParameterCount - 1; i < length; ++i) {
             paramsArray.Add(parameters[i]);
         }
         objs[m_ListParameters[m_ParameterCount - 1]] = paramsArray;
     } else {
         for (int i = 0; i < m_ParameterCount; ++i) {
             objs[m_ListParameters[i]] = (parameters != null && length > i) ? parameters[i] : m_Script.Null;
         }
     }
     ScriptContext context = new ScriptContext(m_Script, m_ScriptExecutable, parentContext, Executable_Block.Function);
     context.Initialize(objs);
     return context.Execute();
 }
        private void ProcessTry()
        {
            CodeTry @try = (CodeTry)this.m_scriptInstruction.operand0;

            try
            {
                new ScriptContext(this.m_script, @try.TryExecutable, this).Execute();
            }
            catch (InteriorException exception)
            {
                ScriptContext context = new ScriptContext(this.m_script, @try.CatchExecutable, this);
                context.Initialize(@try.Identifier, exception.obj);
                context.Execute();
            }
            catch (Exception exception2)
            {
                ScriptContext context2 = new ScriptContext(this.m_script, @try.CatchExecutable, this);
                context2.Initialize(@try.Identifier, this.m_script.CreateObject(exception2));
                context2.Execute();
            }
        }
 void ProcessCallBlock()
 {
     ScriptContext context = new ScriptContext(m_script, (ScriptExecutable)m_scriptInstruction.Value);
     context.Initialize(this);
     context.Execute();
 }
 void ProcessTry()
 {
     CodeTry code = (CodeTry)m_scriptInstruction.Operand0;
     try {
         new ScriptContext(m_script, code.TryExecutable, this).Execute();
     } catch (InteriorException ex) {
         ScriptContext context = new ScriptContext(m_script, code.CatchExecutable, this);
         context.Initialize(code.Identifier, ex.obj);
         context.Execute();
     } catch (System.Exception ex) {
         ScriptContext context = new ScriptContext(m_script, code.CatchExecutable, this);
         context.Initialize(code.Identifier, m_script.CreateObject(ex));
         context.Execute();
     }
 }
 void ProcessCallForeach()
 {
     CodeForeach code = (CodeForeach)m_scriptInstruction.Operand0;
     ScriptObject loop = ResolveOperand(code.LoopObject);
     if (!(loop is ScriptFunction)) throw new ExecutionException(m_script, "foreach函数必须返回一个ScriptFunction");
     object obj;
     ScriptFunction func = (ScriptFunction)loop;
     ScriptContext context;
     for ( ; ; ) {
         obj = func.Call();
         if (obj == null) return;
         context = new ScriptContext(m_script, code.BlockExecutable, this, Executable_Block.Foreach);
         context.Initialize(code.Identifier, m_script.CreateObject(obj));
         context.Execute();
         if (context.IsOver) break;
     }
 }
 void ProcessCallForSimple()
 {
     CodeForSimple code = (CodeForSimple)m_scriptInstruction.Operand0;
     ScriptNumber beginNumber = ResolveOperand(code.Begin) as ScriptNumber;
     if (beginNumber == null) throw new ExecutionException(m_script, "forsimple 初始值必须是number");
     ScriptNumber finishedNumber = ResolveOperand(code.Finished) as ScriptNumber;
     if (finishedNumber == null) throw new ExecutionException(m_script, "forsimple 最大值必须是number");
     int begin = beginNumber.ToInt32();
     int finished = finishedNumber.ToInt32();
     int step;
     if (code.Step != null) {
         ScriptNumber stepNumber = ResolveOperand(code.Step) as ScriptNumber;
         if (stepNumber == null) throw new ExecutionException(m_script, "forsimple Step必须是number");
         step = stepNumber.ToInt32();
     } else {
         step = 1;
     }
     ScriptContext context;
     for (double i = begin; i <= finished; i += step) {
         context = new ScriptContext(m_script, code.BlockExecutable, this, Executable_Block.For);
         context.Initialize(code.Identifier, new ScriptNumberDouble(m_script, i));
         context.Execute();
         if (context.IsOver) break;
     }
 }
 bool ProcessCondition(TempCondition con, ScriptContext context, Executable_Block block)
 {
     if (con == null) return false;
     if (con.Allow != null) {
         object b = ResolveOperand(con.Allow).ObjectValue;
         if (b == null || b.Equals(false)) return false;
     }
     context.Initialize(this);
     context.Execute();
     return true;
 }