Class: CodeTools::AST::ForParameters
- Defined in:
- lib/rubinius/code/ast/sends.rb
Instance Attribute Summary collapse
-
#assignments ⇒ Object
Returns the value of attribute assignments.
-
#block_index ⇒ Object
Returns the value of attribute block_index.
-
#keywords ⇒ Object
Returns the value of attribute keywords.
-
#kwrest_index ⇒ Object
Returns the value of attribute kwrest_index.
-
#post_args ⇒ Object
Returns the value of attribute post_args.
-
#required_args ⇒ Object
(also: #total_args, #arity)
Returns the value of attribute required_args.
-
#splat_index ⇒ Object
Returns the value of attribute splat_index.
Attributes inherited from Node
Instance Method Summary collapse
- #bytecode(g) ⇒ Object
-
#initialize(line, assignments) ⇒ ForParameters
constructor
A new instance of ForParameters.
- #map_arguments(scope) ⇒ Object
- #to_sexp ⇒ Object
Methods inherited from Node
#ascii_graph, #attributes, #children, #defined, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, #or_bytecode, #pos, #set_child, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk
Constructor Details
#initialize(line, assignments) ⇒ ForParameters
Returns a new instance of ForParameters.
907 908 909 910 911 912 913 914 915 916 |
# File 'lib/rubinius/code/ast/sends.rb', line 907 def initialize(line, assignments) @line = line @assignments = assignments @splat_index = assignments.kind_of?(MultipleAssignment) ? 0 : nil @required_args = @splat_index ? 0 : 1 @post_args = 0 @keywords = nil @block_index = nil @kwrest_index = nil end |
Instance Attribute Details
#assignments ⇒ Object
Returns the value of attribute assignments.
904 905 906 |
# File 'lib/rubinius/code/ast/sends.rb', line 904 def assignments @assignments end |
#block_index ⇒ Object
Returns the value of attribute block_index.
904 905 906 |
# File 'lib/rubinius/code/ast/sends.rb', line 904 def block_index @block_index end |
#keywords ⇒ Object
Returns the value of attribute keywords.
904 905 906 |
# File 'lib/rubinius/code/ast/sends.rb', line 904 def keywords @keywords end |
#kwrest_index ⇒ Object
Returns the value of attribute kwrest_index.
904 905 906 |
# File 'lib/rubinius/code/ast/sends.rb', line 904 def kwrest_index @kwrest_index end |
#post_args ⇒ Object
Returns the value of attribute post_args.
904 905 906 |
# File 'lib/rubinius/code/ast/sends.rb', line 904 def post_args @post_args end |
#required_args ⇒ Object Also known as: total_args, arity
Returns the value of attribute required_args.
904 905 906 |
# File 'lib/rubinius/code/ast/sends.rb', line 904 def required_args @required_args end |
#splat_index ⇒ Object
Returns the value of attribute splat_index.
904 905 906 |
# File 'lib/rubinius/code/ast/sends.rb', line 904 def splat_index @splat_index end |
Instance Method Details
#bytecode(g) ⇒ Object
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 |
# File 'lib/rubinius/code/ast/sends.rb', line 928 def bytecode(g) map_arguments(g.state.scope) if @splat_index g.push_rubinius g.find_const :Runtime g.push_local 0 g.send :unwrap_block_arg, 1 else g.push_local 0 end g.state.push_masgn @assignments.bytecode(g) g.state.pop_masgn end |
#map_arguments(scope) ⇒ Object
921 922 923 924 925 926 |
# File 'lib/rubinius/code/ast/sends.rb', line 921 def map_arguments(scope) case @assignments when LocalVariable scope.assign_local_reference @assignments end end |
#to_sexp ⇒ Object
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 |
# File 'lib/rubinius/code/ast/sends.rb', line 945 def to_sexp sexp = [:args] case @assignments when ArrayLiteral @assignments.each do |a| case a when Symbol sexp << a when Node sexp << a.to_sexp end end else sexp << @assignments.to_sexp end sexp end |