Class: NScript::TryNode
Constant Summary
Constants inherited from Node
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
- #compile_node(o) ⇒ Object
-
#initialize(try, error, recovery, finally = nil) ⇒ TryNode
constructor
A new instance of TryNode.
Methods inherited from Node
#children, children, #compile, #compile_closure, #contains?, #idt, statement, #statement?, statement_only, #statement_only?, top_sensitive, #top_sensitive?, #unwrap, #write
Constructor Details
#initialize(try, error, recovery, finally = nil) ⇒ TryNode
Returns a new instance of TryNode.
791 792 793 |
# File 'lib/nscript/parser/nodes.rb', line 791 def initialize(try, error, recovery, finally=nil) @try, @error, @recovery, @finally = try, error, recovery, finally end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
788 789 790 |
# File 'lib/nscript/parser/nodes.rb', line 788 def error @error end |
Instance Method Details
#compile_node(o) ⇒ Object
795 796 797 798 799 800 801 802 |
# File 'lib/nscript/parser/nodes.rb', line 795 def compile_node(o) o[:indent] = idt(1) o[:top] = true error_part = @error ? " (#{@error}) " : ' ' catch_part = @recovery && " catch#{error_part}{\n#{@recovery.compile(o)}\n#{idt}}" finally_part = @finally && " finally {\n#{@finally.compile(o.merge(:return => nil))}\n#{idt}}" write("#{idt}try {\n#{@try.compile(o)}\n#{idt}}#{catch_part}#{finally_part}") end |