Class: Haxor::Compiler::Component::Arithmetic

Inherits:
Base
  • Object
show all
Defined in:
lib/haxor/compiler/component/arithmetic.rb

Instance Attribute Summary

Attributes inherited from Base

#compiler

Instance Method Summary collapse

Methods inherited from Base

#add, #bind_cmd, #offset?, #offset_flags, #parse_value, #strip_offset

Instance Method Details

#cmd_add(a, b) ⇒ Object



15
16
17
18
19
# File 'lib/haxor/compiler/component/arithmetic.rb', line 15

def cmd_add(a, b)
  add Token::Cmd.new(Vm::Cpu::Unit::Arithmetic::OP_ADD | offset_flags(a, b))
  parse_value a
  parse_value b
end

#cmd_cmp(a, b) ⇒ Object



37
38
39
40
41
# File 'lib/haxor/compiler/component/arithmetic.rb', line 37

def cmd_cmp(a, b)
  add Token::Cmd.new(Vm::Cpu::Unit::Arithmetic::OP_CMP | offset_flags(a, b))
  parse_value a
  parse_value b
end

#cmd_dec(a) ⇒ Object



48
49
50
51
# File 'lib/haxor/compiler/component/arithmetic.rb', line 48

def cmd_dec(a)
  add Token::Cmd.new(Vm::Cpu::Unit::Arithmetic::OP_DEC | offset_flags(a))
  parse_value a
end

#cmd_div(a) ⇒ Object



27
28
29
30
# File 'lib/haxor/compiler/component/arithmetic.rb', line 27

def cmd_div(a)
  add Token::Cmd.new(Vm::Cpu::Unit::Arithmetic::OP_DIV | offset_flags(a))
  parse_value a
end

#cmd_inc(a) ⇒ Object



43
44
45
46
# File 'lib/haxor/compiler/component/arithmetic.rb', line 43

def cmd_inc(a)
  add Token::Cmd.new(Vm::Cpu::Unit::Arithmetic::OP_INC | offset_flags(a))
  parse_value a
end

#cmd_mul(a) ⇒ Object



32
33
34
35
# File 'lib/haxor/compiler/component/arithmetic.rb', line 32

def cmd_mul(a)
  add Token::Cmd.new(Vm::Cpu::Unit::Arithmetic::OP_MUL | offset_flags(a))
  parse_value a
end

#cmd_sub(a, b) ⇒ Object



21
22
23
24
25
# File 'lib/haxor/compiler/component/arithmetic.rb', line 21

def cmd_sub(a, b)
  add Token::Cmd.new(Vm::Cpu::Unit::Arithmetic::OP_SUB | offset_flags(a, b))
  parse_value a
  parse_value b
end

#register ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/haxor/compiler/component/arithmetic.rb', line 5

def register
  bind_cmd 'inc', :cmd_inc
  bind_cmd 'dec', :cmd_dec
  bind_cmd 'add', :cmd_add
  bind_cmd 'sub', :cmd_sub
  bind_cmd 'div', :cmd_div
  bind_cmd 'mul', :cmd_mul
  bind_cmd 'cmp', :cmd_cmp
end