Exemple #1
0
 public ReturnStatement(IScope scope, Expression value, CallDepthProtection depthProtection)
     : base(scope)
 {
     if (scope.FunctionDepth == 0)
     {
         throw new InvalidOperationException("Return statement must be inside a function");
     }
     if (depthProtection != null)
     {
         Statements.Add(depthProtection.Cleanup);
     }
     Statements.Add(new _Return(value));
 }
Exemple #2
0
 public FunctionBody(FunctionExpression parent, CallDepthProtection protection, bool hasCatch)
 {
     parent.Require(GlobalVariable.CSUM);
     if (hasCatch)
     {
         CatchStatement = new CodeStatement($"return {CaughtErrorIdentifier};");
     }
     TryBody = new Block(parent);
     if (protection != null)
     {
         TryBody.Statements.Add(protection.Check);
         TryBody.Statements.Add(new ReturnStatement(parent.DefaultReturnValue));
         FinallyStatements.Add(_incrementCallSumDepth);
         //FinallyStatements.Add(protection.Cleanup);
     }
     else
     {
         FinallyStatements.Add(_incrementCallSum);
     }
 }