comparison python/ir.py @ 279:2ccd57b1d78c

Fix register allocator to do burn2 OK
author Windel Bouwman
date Sat, 12 Oct 2013 09:56:23 +0200
parents 046017431c6a
children 02385f62f250
comparison
equal deleted inserted replaced
278:9fca39eebe50 279:2ccd57b1d78c
272 272
273 def Add(a, b): 273 def Add(a, b):
274 """ Convenience call """ 274 """ Convenience call """
275 return Binop(a, '+', b) 275 return Binop(a, '+', b)
276 276
277 def Sub(a, b):
278 return Binop(a, '-', b)
279
280 def Mul(a, b):
281 return Binop(a, '*', b)
282
283 def Div(a, b):
284 return Binop(a, '/', b)
277 285
278 class Eseq(Expression): 286 class Eseq(Expression):
279 """ Sequence of instructions where the last is an expression """ 287 """ Sequence of instructions where the last is an expression """
280 def __init__(self, stmt, e): 288 def __init__(self, stmt, e):
281 self.stmt = stmt 289 self.stmt = stmt
395 403
396 def __repr__(self): 404 def __repr__(self):
397 return 'IF {} {} {} THEN {} ELSE {}'.format(self.a, self.cond, self.b, self.lab_yes, self.lab_no) 405 return 'IF {} {} {} THEN {} ELSE {}'.format(self.a, self.cond, self.b, self.lab_yes, self.lab_no)
398 406
399 407
408 # Constructing IR:
409
400 class NamedClassGenerator: 410 class NamedClassGenerator:
401 def __init__(self, prefix, cls): 411 def __init__(self, prefix, cls):
402 self.prefix = prefix 412 self.prefix = prefix
403 self.cls = cls 413 self.cls = cls
404 def NumGen(): 414 def NumGen():