remove some of the node mess
This commit is contained in:
parent
ff38bde44e
commit
fc3f5d5402
@ -55,7 +55,7 @@ module Asm
|
|||||||
else
|
else
|
||||||
# raise Asm::AssemblyError.new(Asm::ERRSTR_INVALID_ARG, arg)
|
# raise Asm::AssemblyError.new(Asm::ERRSTR_INVALID_ARG, arg)
|
||||||
end
|
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
|
@pre_post_index = 1
|
||||||
@rn = 15 # pc
|
@rn = 15 # pc
|
||||||
@use_addrtable_reloc = true
|
@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)
|
(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)
|
if (@use_addrtable_reloc)
|
||||||
# closest_addrtable = Asm::Arm.closest_addrtable(as)
|
# 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)
|
obj = ast_asm.object_for_label(@addrtable_reloc_target.label, inst)
|
||||||
ref_label = closest_addrtable.add_label(obj)
|
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)
|
ref_label = closest_addrtable.add_const(@addrtable_reloc_target.value)
|
||||||
end
|
end
|
||||||
as.add_relocation io.tell, ref_label, Asm::Arm::R_ARM_PC12,
|
as.add_relocation io.tell, ref_label, Asm::Arm::R_ARM_PC12,
|
||||||
|
@ -18,7 +18,7 @@ module Asm
|
|||||||
|
|
||||||
def add_relocation(*args)
|
def add_relocation(*args)
|
||||||
reloc = Asm::Relocation.new(*args)
|
reloc = Asm::Relocation.new(*args)
|
||||||
raise "reloc #{reloc.inspect}"
|
#raise "reloc #{reloc.inspect}"
|
||||||
@relocations << reloc
|
@relocations << reloc
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ module Asm
|
|||||||
|
|
||||||
@relocations.delete_if do |reloc|
|
@relocations.delete_if do |reloc|
|
||||||
io.seek reloc.position
|
io.seek reloc.position
|
||||||
puts "reloc #{reloc.inspect}"
|
#puts "reloc #{reloc.inspect}"
|
||||||
if (reloc.label.extern?)
|
if (reloc.label.extern?)
|
||||||
reloc.handler.call(io, io.tell, reloc.type)
|
reloc.handler.call(io, io.tell, reloc.type)
|
||||||
else
|
else
|
||||||
|
@ -1,21 +1,6 @@
|
|||||||
module Asm
|
module Asm
|
||||||
|
|
||||||
class Node
|
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
|
end
|
||||||
|
|
||||||
class InstructionNode < Node
|
class InstructionNode < Node
|
||||||
@ -58,8 +43,6 @@ module Asm
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class NumEquivAddrArgNode < NumLiteralArgNode
|
|
||||||
end
|
|
||||||
class LabelRefArgNode < ArgNode
|
class LabelRefArgNode < ArgNode
|
||||||
attr_accessor :label, :label_object
|
attr_accessor :label, :label_object
|
||||||
def initialize label , object = nil
|
def initialize label , object = nil
|
||||||
@ -67,8 +50,6 @@ module Asm
|
|||||||
@label_object = object
|
@label_object = object
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class LabelEquivAddrArgNode < LabelRefArgNode
|
|
||||||
end
|
|
||||||
|
|
||||||
class ParseError < StandardError
|
class ParseError < StandardError
|
||||||
def initialize(message, s)
|
def initialize(message, s)
|
||||||
|
@ -1,5 +1,19 @@
|
|||||||
require_relative 'str_scanner'
|
require_relative 'str_scanner'
|
||||||
require_relative 'nodes'
|
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
|
module Asm
|
||||||
class Parser
|
class Parser
|
||||||
|
Loading…
x
Reference in New Issue
Block a user