Mercurial > repos > blastem
comparison cpu_dsl.py @ 1619:0e8438a4c76f
Clean up warnings from -1 case
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 01 Oct 2018 19:16:54 -0700 |
parents | 5dbc453cd345 |
children | a172f97d873f |
comparison
equal
deleted
inserted
replaced
1618:5dbc453cd345 | 1619:0e8438a4c76f |
---|---|
487 self.default = None | 487 self.default = None |
488 self.default_locals = None | 488 self.default_locals = None |
489 | 489 |
490 def addOp(self, op): | 490 def addOp(self, op): |
491 if op.op == 'case': | 491 if op.op == 'case': |
492 self.cases[int(op.params[0])] = self.current_case = [] | 492 val = int(op.params[0], 16) if op.params[0].startswith('0x') else int(op.params[0]) |
493 self.case_locals[int(op.params[0])] = self.current_locals = {} | 493 self.cases[val] = self.current_case = [] |
494 self.case_locals[val] = self.current_locals = {} | |
494 elif op.op == 'default': | 495 elif op.op == 'default': |
495 self.default = self.current_case = [] | 496 self.default = self.current_case = [] |
496 self.default_locals = self.current_locals = {} | 497 self.default_locals = self.current_locals = {} |
497 elif self.current_case == None: | 498 elif self.current_case == None: |
498 raise ion('Orphan instruction in switch') | 499 raise ion('Orphan instruction in switch') |
541 output.append('\n\tswitch(' + param + ')') | 542 output.append('\n\tswitch(' + param + ')') |
542 output.append('\n\t{') | 543 output.append('\n\t{') |
543 for case in self.cases: | 544 for case in self.cases: |
544 self.current_locals = self.case_locals[case] | 545 self.current_locals = self.case_locals[case] |
545 self.regValues = dict(self.parent.regValues) | 546 self.regValues = dict(self.parent.regValues) |
546 output.append('\n\tcase {0}: '.format(case) + '{') | 547 output.append('\n\tcase {0}U: '.format(case) + '{') |
547 for local in self.case_locals[case]: | 548 for local in self.case_locals[case]: |
548 output.append('\n\tuint{0}_t {1};'.format(self.case_locals[case][local], local)) | 549 output.append('\n\tuint{0}_t {1};'.format(self.case_locals[case][local], local)) |
549 for op in self.cases[case]: | 550 for op in self.cases[case]: |
550 op.generate(prog, self, fieldVals, output, otype) | 551 op.generate(prog, self, fieldVals, output, otype) |
551 output.append('\n\tbreak;') | 552 output.append('\n\tbreak;') |