mirror of
https://github.com/samsonjs/compiler.git
synced 2026-03-25 08:45:52 +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.
|
||||
def rm?(op, size=DefaultOperandSize)
|
||||
# register
|
||||
register?(op, size) ||
|
||||
|
||||
is_register = register?(op, size)
|
||||
|
||||
if op.is_a?(Array)
|
||||
case op.size
|
||||
|
||||
# [register/memory]
|
||||
(op.is_a?(Array) && op.size == 1 &&
|
||||
[Numeric, RegisterProxy, VariableProxy].any?{|c| c == op[0].class}) ||
|
||||
when 1
|
||||
is_reg_or_mem = [Numeric, RegisterProxy, VariableProxy].include?(op[0].class)
|
||||
|
||||
# [<size>, memory]
|
||||
(op.is_a?(Array) && op.size == 2 && op[0] == size &&
|
||||
[Numeric, RegisterProxy, VariableProxy].any?{|c| c == op[1].class})
|
||||
when 2
|
||||
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
|
||||
|
||||
def offset?(addr, size=DefaultOperandSize)
|
||||
|
|
|
|||
Loading…
Reference in a new issue