Commits

gstarnberger committed fe1456b

added some additional stmts from depyc

Comments (0)

Files changed (2)

uncompyle/Parser.py

         ifforstmt ::= expr condjmp SETUP_LOOP expr _for designator
         stmts_opt JUMP_ABSOLUTE
         COME_FROM POP_BLOCK _jump COME_FROM
+        POP_TOP COME_FROM COME_FROM
 
         _jump ::= JUMP_ABSOLUTE
         _jump ::= JUMP_FORWARD
 
-        ifstmt ::= expr condjmp stmts_opt
+        jmp_false    ::= JUMP_IF_FALSE POP_TOP
+        jmp_true    ::= JUMP_IF_TRUE  POP_TOP
+        ifstmt ::= expr jmp_false stmts_opt
+                _jump COME_FROM POP_TOP COME_FROM
+
+        ifstmt ::= expr jmp_false stmts_opt
                 _jump COME_FROM POP_TOP COME_FROM
 
-        ifelsestmt ::= expr condjmp stmts_opt
+        ifelsestmt ::= expr jmp_false stmts_opt
                 _jump COME_FROM
                 POP_TOP stmts COME_FROM
-                
+
         _25_ifstmt ::= _25_bexp _25_jumptarget_e _jump _25_jumptarget_e COME_FROM
         _25_ifelsestmt ::= _25_bexp _25_jumptarget_e _jump _25_jumptarget_s COME_FROM
-        
+
         _25_jumptarget_e ::= _25_come_froms stmts_opt
         _25_jumptarget_s ::= _25_come_froms stmts
-        
+
         _25_come_froms ::= COME_FROM _25_come_froms
         _25_come_froms ::= POP_TOP
 
+        stmt ::= ifandstmt
+        ifandstmt ::= expr JUMP_IF_FALSE POP_TOP expr JUMP_IF_FALSE POP_TOP stmt _jump COME_FROM COME_FROM POP_TOP COME_FROM
+        ifandstmt ::= expr JUMP_IF_FALSE POP_TOP expr JUMP_IF_FALSE POP_TOP stmt _jump COME_FROM COME_FROM POP_TOP
+
+        stmt ::= ifnotstmt
+        stmt ::= ifnotelsestmt
+        ifnotstmt ::= expr jmp_true stmts_opt
+                    _jump COME_FROM POP_TOP
+
+        ifnotstmt ::= expr jmp_true stmts_opt
+                    _jump COME_FROM POP_TOP COME_FROM
+
+        ifnotelsestmt ::= expr jmp_true stmts_opt
+                    _jump COME_FROM
+                    POP_TOP stmts COME_FROM
+
         trystmt ::= SETUP_EXCEPT stmts_opt
                 POP_BLOCK _jump
                 COME_FROM except_stmt
                 stmts_opt JUMP_ABSOLUTE
                 COME_FROM POP_BLOCK stmts COME_FROM
 
+        stmt ::= ifforelsestmt
+        ifforelsestmt ::= expr condjmp SETUP_LOOP expr _for designator
+        stmts_opt JUMP_ABSOLUTE
+        COME_FROM POP_BLOCK _jump COME_FROM
+        POP_TOP stmts COME_FROM COME_FROM
+
         stmt ::= ifforstmt
         ifforstmt ::= expr condjmp SETUP_LOOP expr _for designator
         stmts_opt JUMP_ABSOLUTE

uncompyle/Walker.py

     'elifstmt':		( '%|elif %c:\n%+%c%-', 0, 2 ),
     'elifelsestmt':	( '%|elif %c:\n%+%c%-%|else:\n%+%c%-', 0, 2, -2 ),
 
+    'ifnotstmt':( '%|if not(%c):\n%+%c%-', 0, 2 ),
+    'ifnotelsestmt':( '%|if not(%c):\n%+%c%-%|else:\n%+%c%-', 0, 2, -2 ),
+
+    'ifandstmt':    ( '%|if(%c and %c):\n%+%c%-', 0, 3, 6),
+    'ifforstmt':( '%|if %c:\n%+%|for %c in %c:\n%+%c%-%-\n', 0, 5, 3, 6 ),
+    'ifforelsestmt':( '%|if %c:\n%+%|for %c in %c:\n%+%c%-%-\n%|else:\n%+%c%-', 0, 5, 3, 6, -3 ),
+
     'whilestmt':	( '%|while %c:\n%+%c%-\n', 1, 4 ),
     'while1stmt':	( '%|while 1:\n%+%c%-\n', 5 ),
     'whileelsestmt':	( '%|while %c:\n%+%c%-%|else:\n%+%c%-\n', 1, 4, -2 ),
         elif data is None:
             # LOAD_CONST 'None' only occurs, when None is
             # implicit eg. in 'return' w/o params
-            pass
+            # pass
+            self.write('None')
         else:
             self.write(repr(data))
         # LOAD_CONST is a terminal, so stop processing/recursing early
             self.print_("(", ", ".join(params), "):")
             #self.print_(indent, '#flags:\t', int(code.co_flags))
 
-        if code.co_consts and code.co_consts[0] != None: 
+        if len(code.co_consts)>0 and code.co_consts[0] != None: 
             # docstring exists, dump it
             self.print_docstring(indent, code.co_consts[0])