comparison python/irmach.py @ 274:ea93e0a7a31e

Move docs
author Windel Bouwman
date Wed, 04 Sep 2013 17:35:06 +0200
parents cdc76d183bcc
children 6f2423df0675
comparison
equal deleted inserted replaced
273:6b3a874edd6e 274:ea93e0a7a31e
5 This is the second intermediate representation. 5 This is the second intermediate representation.
6 6
7 Instructions are selected and scheduled at this stage. 7 Instructions are selected and scheduled at this stage.
8 """ 8 """
9 9
10 class Frame:
11 """
12 Activation record abstraction. This class contains a flattened
13 function. Instructions are selected and scheduled at this stage.
14 Frames differ per machine.
15 """
16 def __init__(self, name):
17 self.name = name
18 self.instructions = []
19
20 def __repr__(self):
21 return 'Frame'
22
10 23
11 class AbstractInstruction: 24 class AbstractInstruction:
12 """ Absract machine instruction """ 25 """
26 Abstract machine instruction class. This is a very simple
27 abstraction of machine instructions.
28 """
13 def __init__(self, assem, src=(), dst=(), jumps=()): 29 def __init__(self, assem, src=(), dst=(), jumps=()):
14 self.assem = assem 30 self.assem = assem
15 self.src = tuple(src) 31 self.src = tuple(src)
16 self.dst = tuple(dst) 32 self.dst = tuple(dst)
17 self.jumps = tuple(jumps) 33 self.jumps = tuple(jumps)
18 34
19 def __repr__(self): 35 def __repr__(self):
20 return self.assem + str(self.src) + str(self.dst) 36 s = str(self.src) if self.src else ''
37 d = str(self.dst) if self.dst else ''
38 l = str(self.jumps) if self.jumps else ''
39 return self.assem + s + d + l
21 40
22 41