comparison python/ppci/outstream.py @ 381:6df89163e114

Fix section and ldr pseudo instruction
author Windel Bouwman
date Sat, 26 Apr 2014 17:41:56 +0200
parents 39bf68bf1891
children
comparison
equal deleted inserted replaced
380:67a584582aee 381:6df89163e114
21 class BinaryOutputStream(OutputStream): 21 class BinaryOutputStream(OutputStream):
22 """ Output stream that writes to object file """ 22 """ Output stream that writes to object file """
23 def __init__(self, obj_file): 23 def __init__(self, obj_file):
24 super().__init__() 24 super().__init__()
25 self.obj_file = obj_file 25 self.obj_file = obj_file
26 self.literal_pool = []
26 27
27 def emit(self, item): 28 def emit(self, item):
28 """ Encode instruction and add symbol and relocation information """ 29 """ Encode instruction and add symbol and relocation information """
29 assert isinstance(item, Instruction), str(item) + str(type(item)) 30 assert isinstance(item, Instruction), str(item) + str(type(item))
30 assert self.currentSection 31 assert self.currentSection
81 output_stream.emit(item) 82 output_stream.emit(item)
82 83
83 def select_section(self, sname): 84 def select_section(self, sname):
84 for output_stream in self.substreams: 85 for output_stream in self.substreams:
85 output_stream.select_section(sname) 86 output_stream.select_section(sname)
87
88
89 def BinaryAndLoggingStream(output):
90 """ Create a stream object that both logs and writes to an object file """
91 o2 = BinaryOutputStream(output)
92 o1 = LoggerOutputStream()
93 ostream = MasterOutputStream([o1, o2])
94 return ostream