Class: CodeTools::AST::ElementAssignment
- Inherits:
-
SendWithArguments
- Object
- Node
- Send
- SendWithArguments
- CodeTools::AST::ElementAssignment
- Defined in:
- lib/rubinius/code/ast/sends.rb
Instance Attribute Summary
Attributes inherited from SendWithArguments
Attributes inherited from Send
#block, #name, #privately, #receiver, #variable, #vcall_style
Attributes inherited from Node
Instance Method Summary collapse
- #bytecode(g) ⇒ Object
-
#initialize(line, receiver, arguments) ⇒ ElementAssignment
constructor
A new instance of ElementAssignment.
- #masgn_bytecode(g) ⇒ Object
- #sexp_name ⇒ Object
Methods inherited from SendWithArguments
Methods inherited from Send
#arguments_sexp, #check_local_reference, #defined, #receiver_sexp, #to_sexp, #value_defined
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, #to_sexp, #transform, transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk
Constructor Details
#initialize(line, receiver, arguments) ⇒ ElementAssignment
Returns a new instance of ElementAssignment.
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/rubinius/code/ast/sends.rb', line 210 def initialize(line, receiver, arguments) @line = line @receiver = receiver @privately = receiver.kind_of?(Self) ? true : false @name = :[]= case arguments when PushArgs @arguments = PushArguments.new line, arguments else @arguments = Arguments.new line, arguments end end |
Instance Method Details
#bytecode(g) ⇒ Object
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/rubinius/code/ast/sends.rb', line 234 def bytecode(g) return masgn_bytecode(g) if g.state.masgn? @receiver.bytecode(g) @arguments.bytecode(g) g.dup if @arguments.splat? case @arguments when PushArguments g.move_down @arguments.size + 2 g.swap flag = true when Arguments # TODO: Optimize bytecode for x[a, *b, c, d] = e g.send :last, 0, true g.move_down @arguments.size + 2 flag = false end g.push :nil g.send_with_splat @name, @arguments.size, @privately, flag else g.move_down @arguments.size + 1 g.send @name, @arguments.size, @privately end g.pop end |
#masgn_bytecode(g) ⇒ Object
226 227 228 229 230 231 232 |
# File 'lib/rubinius/code/ast/sends.rb', line 226 def masgn_bytecode(g) @receiver.bytecode(g) g.swap @arguments.masgn_bytecode(g) g.send @name, @arguments.size + 1, @privately # TODO: splat end |
#sexp_name ⇒ Object
265 266 267 |
# File 'lib/rubinius/code/ast/sends.rb', line 265 def sexp_name :attrasgn end |