Class: Rubinius::AST::RescueCondition
- Defined in:
- lib/compiler/ast/exceptions.rb
Instance Attribute Summary collapse
-
#assignment ⇒ Object
Returns the value of attribute assignment.
-
#body ⇒ Object
Returns the value of attribute body.
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#next ⇒ Object
Returns the value of attribute next.
-
#splat ⇒ Object
Returns the value of attribute splat.
Attributes inherited from Node
Instance Method Summary collapse
- #assignment?(node) ⇒ Boolean
-
#initialize(line, conditions, body, nxt) ⇒ RescueCondition
constructor
A new instance of RescueCondition.
- #to_sexp ⇒ Object
Methods inherited from Node
#ascii_graph, #attributes, #children, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, node_name, #pos, #set_child, transform, #transform, transform_comment, transform_kind, transform_kind=, transform_name, #visit, #walk
Constructor Details
#initialize(line, conditions, body, nxt) ⇒ RescueCondition
Returns a new instance of RescueCondition.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/compiler/ast/exceptions.rb', line 56 def initialize(line, conditions, body, nxt) @line = line @next = nxt @splat = nil @assignment = nil case conditions when ArrayLiteral @conditions = conditions when ConcatArgs @conditions = conditions.array @splat = RescueSplat.new line, conditions.rest when SplatValue @splat = RescueSplat.new line, conditions.value when nil condition = ConstantAccess.new line, :StandardError @conditions = ArrayLiteral.new line, [condition] end case body when Block @assignment = body.array.shift if assignment? body.array.first @body = body when nil @body = NilLiteral.new line else if assignment? body @assignment = body @body = NilLiteral.new line else @body = body end end end |
Instance Attribute Details
#assignment ⇒ Object
Returns the value of attribute assignment.
54 55 56 |
# File 'lib/compiler/ast/exceptions.rb', line 54 def assignment @assignment end |
#body ⇒ Object
Returns the value of attribute body.
54 55 56 |
# File 'lib/compiler/ast/exceptions.rb', line 54 def body @body end |
#conditions ⇒ Object
Returns the value of attribute conditions.
54 55 56 |
# File 'lib/compiler/ast/exceptions.rb', line 54 def conditions @conditions end |
#next ⇒ Object
Returns the value of attribute next.
54 55 56 |
# File 'lib/compiler/ast/exceptions.rb', line 54 def next @next end |
#splat ⇒ Object
Returns the value of attribute splat.
54 55 56 |
# File 'lib/compiler/ast/exceptions.rb', line 54 def splat @splat end |
Instance Method Details
#assignment?(node) ⇒ Boolean
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/compiler/ast/exceptions.rb', line 91 def assignment?(node) case node when VariableAssignment value = node.value when AttributeAssignment value = node.arguments.array.last else return false end return true if value.kind_of? CurrentException end |
#to_sexp ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/compiler/ast/exceptions.rb', line 104 def to_sexp array = @conditions.to_sexp array << @assignment.to_sexp if @assignment array << @splat.to_sexp if @splat sexp = [:resbody, array] case @body when Block sexp << (@body ? @body.array.map { |x| x.to_sexp } : nil) when nil sexp << nil else sexp << @body.to_sexp end sexp << @next.to_sexp if @next sexp end |