protected override ICode VisitThrow(StmtThrow s)
 {
     this.NewLine();
     this.code.Append("throw");
     if (s.Expr != null)
     {
         this.code.Append(" ");
         this.Visit(s.Expr);
     }
     return(s);
 }
示例#2
0
        public static Stmt get_Value(Ctx ctx)
        {
            var excCtor = ctx.Module.Import(typeof(InvalidOperationException).GetConstructor(Type.EmptyTypes));
            var invalidOperationException      = new ExprNewObj(ctx, excCtor);
            var throwInvalidOperationException = new StmtThrow(ctx, invalidOperationException);
            var cond    = new ExprJsExplicit(ctx, "(this === null)", ctx.Boolean, ctx.ThisNamed);
            var throwIf = new StmtIf(ctx, cond, throwInvalidOperationException, null);
            var ret     = new StmtReturn(ctx, ctx.This);
            var stmt    = new StmtBlock(ctx, throwIf, ret);

            return(stmt);
        }
        protected virtual ICode VisitThrow(StmtThrow s)
        {
            this.ThrowOnNoOverride();
            var expr = this.Visit(s.Expr);

            if (expr != s.Expr)
            {
                return(new StmtThrow(s.Ctx, (Expr)expr));
            }
            else
            {
                return(s);
            }
        }