Class: Haxor::Linker

Inherits:
Object
  • Object
show all
Defined in:
lib/haxor/linker.rb

Constant Summary collapse

SECTIONS =
[:text, :data, :bss]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Linker

Returns a new instance of Linker.



7
8
9
10
11
12
13
# File 'lib/haxor/linker.rb', line 7

def initialize
  @cpu = Vm::Cpu::Core.new
  @units = []
  @tokens = []
  @labels = @cpu.labels.clone
  @stack = 4096
end

Instance Attribute Details

#stack ⇒ Object

Returns the value of attribute stack.



3
4
5
# File 'lib/haxor/linker.rb', line 3

def stack
  @stack
end

Instance Method Details



19
20
21
22
23
24
25
26
27
# File 'lib/haxor/linker.rb', line 19

def link(filename)
  calc_absolute_addr
  collect_labels
  unwind_pointers

  output = File.open(filename, 'wb')
  output.write build
  output.close
end

#load_unit(filename) ⇒ Object



15
16
17
# File 'lib/haxor/linker.rb', line 15

def load_unit(filename)
  @units << Haxor::Compiler::Unit.load(filename)
end