Mercurial > lcfOS
comparison python/ppci/ir.py @ 304:fa99f36fabb5
Fix docs
author | Windel Bouwman |
---|---|
date | Fri, 06 Dec 2013 12:45:02 +0100 |
parents | be7f60545368 |
children | 0615b5308710 |
comparison
equal
deleted
inserted
replaced
303:be7f60545368 | 304:fa99f36fabb5 |
---|---|
235 else: | 235 else: |
236 return False, {} | 236 return False, {} |
237 | 237 |
238 | 238 |
239 class Expression: | 239 class Expression: |
240 """ Base class for an expression """ | |
240 pass | 241 pass |
241 | 242 |
242 | 243 |
243 class Const(Expression): | 244 class Const(Expression): |
245 """ Represents a constant value """ | |
244 def __init__(self, value): | 246 def __init__(self, value): |
245 self.value = value | 247 self.value = value |
246 | 248 |
247 def __repr__(self): | 249 def __repr__(self): |
248 return 'Const {}'.format(self.value) | 250 return 'Const {}'.format(self.value) |
260 return '{}({})'.format(self.f.name, args) | 262 return '{}({})'.format(self.f.name, args) |
261 | 263 |
262 | 264 |
263 # Data operations | 265 # Data operations |
264 class Binop(Expression): | 266 class Binop(Expression): |
267 """ Generic binary operation """ | |
265 ops = ['+', '-', '*', '/', '|', '&', '<<', '>>'] | 268 ops = ['+', '-', '*', '/', '|', '&', '<<', '>>'] |
266 def __init__(self, value1, operation, value2): | 269 def __init__(self, value1, operation, value2): |
267 assert operation in Binop.ops | 270 assert operation in Binop.ops |
268 self.a = value1 | 271 self.a = value1 |
269 self.b = value2 | 272 self.b = value2 |
382 def __repr__(self): | 385 def __repr__(self): |
383 return 'Terminator' | 386 return 'Terminator' |
384 | 387 |
385 | 388 |
386 class Jump(LastStatement): | 389 class Jump(LastStatement): |
390 """ Jump statement to some target location """ | |
387 def __init__(self, target): | 391 def __init__(self, target): |
388 self.Targets = [target] | 392 self.Targets = [target] |
389 | 393 |
390 def setTarget(self, t): | 394 def setTarget(self, t): |
391 self.Targets[0] = t | 395 self.Targets[0] = t |