/// <summary> /// Execute /// </summary> public object VisitTryCatch(TryCatchExpr expr) { var tryScopePopped = false; var catchScopePopped = false; try { this.Ctx.Memory.Push(); LangHelper.Evaluate(expr.Statements, expr, this); this.Ctx.Memory.Pop(); tryScopePopped = true; } // Force the langlimit excpetion to propegate // do not allow to flow through to the catch all "Exception ex". catch (LangLimitException) { throw; } catch (LangFailException) { throw; } catch (Exception ex) { this.Ctx.Limits.CheckExceptions(expr); // Pop the try scope. if (!tryScopePopped) { this.Ctx.Memory.Pop(); } // Push the scope in the catch block this.Ctx.Memory.Push(); var lException = LangTypeHelper.ConvertToLangClass(LError.FromException(ex)); this.Ctx.Memory.SetValue(expr.ErrorName, lException); // Run statements in catch block. if (expr.Catch != null && expr.Catch.Statements.Count > 0) { LangHelper.Evaluate(expr.Catch.Statements, expr.Catch, this); } // Pop the catch scope. this.Ctx.Memory.Pop(); catchScopePopped = true; } finally { // Pop the catch scope in case there was an error. if (!catchScopePopped) { this.Ctx.Memory.Remove(expr.ErrorName); } } return(LObjects.Null); }
/// <summary> /// Execute /// </summary> public override object DoEvaluate() { bool tryScopePopped = false; bool catchScopePopped = false; try { Ctx.Memory.Push(); LangHelper.Evaluate(_statements, this); Ctx.Memory.Pop(); tryScopePopped = true; } // Force the langlimit excpetion to propegate // do not allow to flow through to the catch all "Exception ex". catch (LangLimitException) { throw; } catch (LangFailException) { throw; } catch (Exception ex) { Ctx.Limits.CheckExceptions(this); // Pop the try scope. if (!tryScopePopped) { Ctx.Memory.Pop(); } // Push the scope in the catch block Ctx.Memory.Push(); Ctx.Memory.SetValue(ErrorName, new LClass(LError.FromException(ex))); // Run statements in catch block. if (Catch != null && Catch.Statements.Count > 0) { LangHelper.Evaluate(Catch.Statements, Catch); } // Pop the catch scope. Ctx.Memory.Pop(); catchScopePopped = true; } finally { // Pop the catch scope in case there was an error. if (!catchScopePopped) { Ctx.Memory.Remove(ErrorName); } } return(LObjects.Null); }
/// <summary> /// Execute /// </summary> public override object DoEvaluate() { // Case 1: If is true if (this.Condition.EvaluateAs <bool>()) { LangHelper.Evaluate(_statements, this); } // Case 2: Else available to execute else if (Else != null) { Else.Evaluate(); } return(LObjects.Null); }
/// <summary> /// Executes the block with callback/template methods. /// </summary> public object VisitBlock(BlockExpr expr) { object result = LObjects.Null; try { //expr.OnBlockEnter(); expr.Ctx.Memory.Push(); LangHelper.Evaluate(expr.Statements, expr.Parent, this); } finally { //expr.OnBlockExit(); expr.Ctx.Memory.Pop(); } return(result); }
public override object DoEvaluate(IAstVisitor visitor) { LangHelper.Evaluate(Statements, this, visitor); SetupPlugin(); return(LObjects.Null); }
/// <summary> /// Execute the statements. /// </summary> public override object DoEvaluate(IAstVisitor visitor) { LangHelper.Evaluate(_statements, Parent, visitor); return(LObjects.Null); }
/// <summary> /// Execute the statements. /// </summary> public override object DoEvaluate() { LangHelper.Evaluate(this._statements, this.Parent); return(LObjects.Null); }