mirror of
https://github.com/samsonjs/compiler.git
synced 2026-04-27 14:57:45 +00:00
use intermediate variables to clean up a method
I want Ruby to be Lisp, but it isn't.
This commit is contained in:
parent
8013b8796c
commit
7fbee3ae4f
1 changed files with 18 additions and 7 deletions
|
|
@ -467,16 +467,27 @@ module Assembler
|
||||||
#
|
#
|
||||||
# XXX This method is pretty ugly.
|
# XXX This method is pretty ugly.
|
||||||
def rm?(op, size=DefaultOperandSize)
|
def rm?(op, size=DefaultOperandSize)
|
||||||
# register
|
is_register = register?(op, size)
|
||||||
register?(op, size) ||
|
|
||||||
|
if op.is_a?(Array)
|
||||||
|
case op.size
|
||||||
|
|
||||||
# [register/memory]
|
# [register/memory]
|
||||||
(op.is_a?(Array) && op.size == 1 &&
|
when 1
|
||||||
[Numeric, RegisterProxy, VariableProxy].any?{|c| c == op[0].class}) ||
|
is_reg_or_mem = [Numeric, RegisterProxy, VariableProxy].include?(op[0].class)
|
||||||
|
|
||||||
# [<size>, memory]
|
# [<size>, memory]
|
||||||
(op.is_a?(Array) && op.size == 2 && op[0] == size &&
|
when 2
|
||||||
[Numeric, RegisterProxy, VariableProxy].any?{|c| c == op[1].class})
|
is_size_and_mem = op[0] == size && [Numeric, RegisterProxy, VariableProxy].include?(op[1].class)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
is_reg_or_mem = false
|
||||||
|
is_size_and_mem = false
|
||||||
|
end
|
||||||
|
|
||||||
|
is_register || is_reg_or_mem || is_size_and_mem
|
||||||
end
|
end
|
||||||
|
|
||||||
def offset?(addr, size=DefaultOperandSize)
|
def offset?(addr, size=DefaultOperandSize)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue