class CodeTools::AST::SendFastCoerceTo
Speeds up certain forms of Type.coerce_to
Public Class Methods
match?(line, receiver, name, arguments, privately)
click to toggle source
# File lib/rubinius/code/ast/transforms.rb, line 333 def self.match?(line, receiver, name, arguments, privately) methods = [:coerce_to, :check_convert_type, :try_convert] receiver.kind_of?(TypeConstant) && methods.include?(name) && arguments.body.size == 3 end
Public Instance Methods
bytecode(g)
click to toggle source
Calls superclass method
CodeTools::AST::SendWithArguments#bytecode
# File lib/rubinius/code/ast/transforms.rb, line 339 def bytecode(g) pos(g) var = @arguments.array[0] const = @arguments.array[1] if (var.kind_of?(LocalVariableAccess) || var.kind_of?(InstanceVariableAccess)) and (const.kind_of?(ConstantAccess) || const.kind_of?(ScopedConstant) || const.kind_of?(ToplevelConstant)) done = g.new_label var.bytecode(g) g.dup const.bytecode(g) g.swap g.kind_of g.goto_if_true done g.pop super(g) done.set! else super(g) end end