Class: Yadriggy::Return

Inherits:
ASTnode show all
Includes:
AstHelper
Defined in:
lib/yadriggy/ast.rb

Overview

Return.

Instance Attribute Summary collapse

Attributes inherited from ASTnode

#parent, #usertype

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AstHelper

#has_tag?, #to_node, #to_nodes

Methods inherited from ASTnode

#add_child, #add_children, #const_value, #const_value_in_class, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string, #value, #value_in_class

Constructor Details

#initialize(sexp) ⇒ Return

Returns a new instance of Return.



1256
1257
1258
1259
1260
1261
1262
1263
1264
# File 'lib/yadriggy/ast.rb', line 1256

def initialize(sexp)
  if sexp.length < 2    # return0
    @values = []
  else
    values = has_tag?(sexp[1], :args_add_block)[1]
    @values = to_nodes(values)
    add_children(@values)
  end
end

Instance Attribute Details

#valuesArray<ASTnode> (readonly)

Gets the returned values.

Returns:

  • (Array<ASTnode>)

    the returned values. It may be an empty array.



1252
1253
1254
# File 'lib/yadriggy/ast.rb', line 1252

def values
  @values
end

Class Method Details

.tagsObject



1254
# File 'lib/yadriggy/ast.rb', line 1254

def self.tags() [:return, :return0] end

Instance Method Details

#accept(evaluator) ⇒ void

This method returns an undefined value.

A method for Visitor pattern.

Parameters:

  • evaluator (Eval)

    the visitor of Visitor pattern.



1269
1270
1271
# File 'lib/yadriggy/ast.rb', line 1269

def accept(evaluator)
  evaluator.return_values(self)
end