コード例 #1
0
 def reduce_stack(self, stack, pre):
     sl = len(stack)
     stack = stack[:1] + stack[::-1][1:-1] + stack[-1:] + [pre]
     if sl == 2: return Types.SingleInstr(stack)
     elif sl == 3: return Types.DoubleInstr(stack)
     elif sl == 4: return Types.TripleInstr(stack)
     elif sl == 5: return Types.FourInstr(stack)
     raise Exception('Parsing error')
コード例 #2
0
 def pic_locating(self, i):
     if isinstance(i, Types.DoubleInstr):
         return Types.DoubleInstr((i[0], self.v_exp(i[1]), i[2], i[3]))
     elif isinstance(i, Types.TripleInstr):
         return Types.TripleInstr(
             (i[0], self.v_exp(i[1]), self.v_exp(i[2]), i[3], i[4]))
     elif isinstance(i, Types.FourInstr):
         return Types.FourInstr(
             (i[0], i[1], self.v_exp(i[2]), i[3], i[4], i[5]))
     return i
コード例 #3
0
 def vinst2(self, f, instr):
     if isinstance(instr, Types.SingleInstr): return instr
     elif isinstance(instr, Types.DoubleInstr):
         return Types.DoubleInstr(
             (instr[0], self.v_exp2(instr[1], instr, f,
                                    False), instr[2], instr[3]))
     elif isinstance(instr, Types.TripleInstr):
         is_test = instr[0].upper() in ['TEST', 'TESTL', 'TESTW', 'TESTB']
         return Types.TripleInstr(
             (instr[0], self.v_exp2(instr[1], instr, f, is_test),
              self.v_exp2(instr[2], instr, f, is_test), instr[3], instr[4]))
     elif isinstance(instr, Types.FourInstr):
         return Types.FourInstr(
             (instr[0], instr[1], self.v_exp2(instr[2], instr, f, False),
              instr[3], instr[4], instr[5]))
コード例 #4
0
ファイル: Parser.py プロジェクト: wwzcrack/RLOBF
 def reduce_stack(self, stack, pre):
     """
     Compose instruction tuple
     :param stack: list of parsed instruction components
     :param pre: True if instruction has prefix operator
     """
     sl = len(stack)
     stack = stack[:1] + \
             (stack[::-1][1:-1] if isinstance(self, parseX86) else stack[1:-1]) + \
             stack[-1:] + [pre]
     if sl == 2: return Types.SingleInstr(stack)
     elif sl == 3: return Types.DoubleInstr(stack)
     elif sl == 4: return Types.TripleInstr(stack)
     elif sl == 5: return Types.FourInstr(stack)
     elif sl == 6: return Types.FiveInstr(stack)
     elif config.arch == config.ARCH_ARMT and sl == 8: return Types.CoproInstr(stack)
     raise Exception('Parsing error, strange number of tokens: ' + str(sl))