Class: Haxor::Linker
- Inherits:
-
Object
- Object
- Haxor::Linker
- Defined in:
- lib/haxor/linker.rb
Constant Summary collapse
- SECTIONS =
[:text, :data, :bss]
Instance Attribute Summary collapse
-
#stack ⇒ Object
Returns the value of attribute stack.
Instance Method Summary collapse
-
#initialize ⇒ Linker
constructor
A new instance of Linker.
- #link(filename) ⇒ Object
- #load_unit(filename) ⇒ Object
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
#link(filename) ⇒ Object
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 |