remove some of the node mess

This commit is contained in:
Torsten Ruger 2014-04-21 17:34:24 +03:00
parent ff38bde44e
commit fc3f5d5402
4 changed files with 19 additions and 24 deletions

View File

@ -55,7 +55,7 @@ module Asm
else
# raise Asm::AssemblyError.new(Asm::ERRSTR_INVALID_ARG, arg)
end
elsif (arg.is_a?(Asm::LabelRefArgNode) or arg.is_a?(Asm::NumEquivAddrArgNode))
elsif (arg.is_a?(Asm::LabelRefArgNode) or arg.is_a?(Asm::NumLiteralArgNode))
@pre_post_index = 1
@rn = 15 # pc
@use_addrtable_reloc = true
@ -78,10 +78,10 @@ module Asm
(inst_class << 12+4+4+1+1+1+1+1+1) | (cond << 12+4+4+1+1+1+1+1+1+2)
if (@use_addrtable_reloc)
# closest_addrtable = Asm::Arm.closest_addrtable(as)
if (@addrtable_reloc_target.is_a?(Asm::LabelEquivAddrArgNode))
if (@addrtable_reloc_target.is_a?(Asm::LabelRefArgNode))
obj = ast_asm.object_for_label(@addrtable_reloc_target.label, inst)
ref_label = closest_addrtable.add_label(obj)
elsif (@addrtable_reloc_target.is_a?(Asm::NumEquivAddrArgNode))
elsif (@addrtable_reloc_target.is_a?(Asm::NumLiteralArgNode))
ref_label = closest_addrtable.add_const(@addrtable_reloc_target.value)
end
as.add_relocation io.tell, ref_label, Asm::Arm::R_ARM_PC12,

View File

@ -18,7 +18,7 @@ module Asm
def add_relocation(*args)
reloc = Asm::Relocation.new(*args)
raise "reloc #{reloc.inspect}"
#raise "reloc #{reloc.inspect}"
@relocations << reloc
end
@ -29,7 +29,7 @@ module Asm
@relocations.delete_if do |reloc|
io.seek reloc.position
puts "reloc #{reloc.inspect}"
#puts "reloc #{reloc.inspect}"
if (reloc.label.extern?)
reloc.handler.call(io, io.tell, reloc.type)
else

View File

@ -1,21 +1,6 @@
module Asm
class Node
def initialize(s = nil)
yield self if block_given?
end
end
class ToplevelNode < Node
attr_accessor :children
end
class DirectiveNode < Node
attr_accessor :name, :value
end
class LabelNode < Node
attr_accessor :name
end
class InstructionNode < Node
@ -58,8 +43,6 @@ module Asm
end
end
class NumEquivAddrArgNode < NumLiteralArgNode
end
class LabelRefArgNode < ArgNode
attr_accessor :label, :label_object
def initialize label , object = nil
@ -67,8 +50,6 @@ module Asm
@label_object = object
end
end
class LabelEquivAddrArgNode < LabelRefArgNode
end
class ParseError < StandardError
def initialize(message, s)

View File

@ -1,5 +1,19 @@
require_relative 'str_scanner'
require_relative 'nodes'
class NumEquivAddrArgNode < NumLiteralArgNode
end
class LabelEquivAddrArgNode < LabelRefArgNode
end
class ToplevelNode < Node
attr_accessor :children
end
class DirectiveNode < Node
attr_accessor :name, :value
end
class LabelNode < Node
attr_accessor :name
end
module Asm
class Parser