class Savi::AST::Try

Overview

A Try node indicates a fallback flow control where a block interrupted by a possible runtime error in the #body Term will fall back to executing the #else_body Term to obtain a result value for the overall result.

This is an internal AST type which has no corresponding source code syntax, because such a construct is only created inside macro expansions.

However, the most obvious example of use is in the try macro.

Defined in:

savi/ast.cr

Constructors

Instance Method Summary

Instance methods inherited from class Savi::AST::Node

accept(ctx : Compiler::Context, visitor : Visitor)
accept(ctx : Compiler::Context, visitor : CopyOnMutateVisitor)
accept
, annotations : Array(Annotation) | Nil annotations, annotations=(annotations : Array(Annotation) | Nil) annotations=, children_accept(ctx : Compiler::Context, visitor : Visitor)
children_accept(ctx : Compiler::Context, visitor : CopyOnMutateVisitor)
children_accept
, from(other : Node) from, pos pos, pos? : Savi::Source::Pos? pos?, span_pos(source) span_pos, with_pos(pos : Source::Pos) with_pos

Constructor Detail

def self.new(body : Savi::AST::Node, catch_expr : Savi::AST::Node | Nil, else_body : Savi::AST::Node, allow_non_partial_body : Bool = false) #

[View source]

Instance Method Detail

def allow_non_partial_body : Bool #

[View source]
def allow_non_partial_body=(allow_non_partial_body : Bool) #

[View source]
def body : Term #

[View source]
def body=(body : Term) #

[View source]
def catch_expr : Term | Nil #

[View source]
def catch_expr=(catch_expr : Term | Nil) #

[View source]
def children_accept(ctx : Compiler::Context, visitor : Visitor) #

[View source]
def children_accept(ctx : Compiler::Context, visitor : CopyOnMutateVisitor) #

[View source]
def else_body : Term #

[View source]
def else_body=(else_body : Term) #

[View source]
def name #

[View source]
def span_pos(source) #

[View source]
def to_a : Array(A) #

[View source]