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; } } }
private void ProcessCallFor() { CodeFor @for = (CodeFor)this.m_scriptInstruction.operand0; ScriptContext parent = new ScriptContext(this.m_script, null, this, Executable_Block.For); parent.Execute(@for.BeginExecutable); while ((@for.Condition == null) || parent.ResolveOperand(@for.Condition).LogicOperation()) { ScriptContext context2 = new ScriptContext(this.m_script, @for.BlockExecutable, parent, Executable_Block.For); context2.Execute(); if (context2.IsOver) { return; } parent.Execute(@for.LoopExecutable); } return; }
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(); } }
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; } } }
void ProcessCallFor() { CodeFor code = (CodeFor)m_scriptInstruction.operand0; ScriptContext context = new ScriptContext(m_script, null, this, Executable_Block.For); context.Execute(code.BeginExecutable); ScriptContext blockContext; while (code.Condition == null || context.ResolveOperand(code.Condition).LogicOperation()) { blockContext = new ScriptContext(m_script, code.BlockExecutable, context, Executable_Block.For); blockContext.Execute(); if (blockContext.IsOver) { break; } context.Execute(code.LoopExecutable); } }
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(); }
void ProcessCallWhile() { CodeWhile code = (CodeWhile)m_scriptInstruction.Operand0; TempCondition condition = code.While; ScriptContext context; for ( ; ;) { if (!ProcessAllow(condition)) { break; } context = new ScriptContext(m_script, condition.Executable, this, Executable_Block.While); context.Execute(); if (context.IsOver) { break; } } }
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 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(); } finally { if (code.FinallyExecutable != null) { new ScriptContext(m_script, code.FinallyExecutable, this).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 ProcessCallWhile() { CodeWhile code = (CodeWhile)m_scriptInstruction.Operand0; TempCondition condition = code.While; ScriptContext context; for ( ; ; ) { if (!ProcessAllow(condition)) { break; } context = new ScriptContext(m_script, condition.Executable, this, Executable_Block.While); context.Execute(); if (context.IsOver) { break; } } }
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; } }
void ProcessCallFor() { CodeFor code = (CodeFor)m_scriptInstruction.Operand0; ScriptContext context = new ScriptContext(m_script, null, this, Executable_Block.For); context.Execute(code.BeginExecutable); for ( ; ; ) { if (code.Condition != null) { if (!context.ResolveOperand(code.Condition).LogicOperation()) break; } ScriptContext blockContext = new ScriptContext(m_script, code.BlockExecutable, context, Executable_Block.For); blockContext.Execute(); if (blockContext.IsOver) break; context.Execute(code.LoopExecutable); } }
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; }