예제 #1
0
 def MAKE_FUNCTION(decompiler, argc):
     defaults = []
     flags = 0
     if sys.version_info >= (3, 6):
         qualname = decompiler.stack.pop()
         tos = decompiler.stack.pop()
         if argc & 0x08:
             func_closure = decompiler.stack.pop()
         if argc & 0x04:
             annotations = decompiler.stack.pop()
         if argc & 0x02:
             kwonly_defaults = decompiler.stack.pop()
         if argc & 0x01:
             defaults = decompiler.stack.pop()
             throw(DecompileError)
     else:
         if not PY2:
             qualname = decompiler.stack.pop()
         tos = decompiler.stack.pop()
         if argc:
             defaults = [ decompiler.stack.pop() for i in range(argc) ]
             defaults.reverse()
     codeobject = tos.value
     func_decompiler = Decompiler(codeobject)
     # decompiler.names.update(decompiler.names)  ???
     if codeobject.co_varnames[:1] == ('.0',):
         return func_decompiler.ast  # generator
     argnames, varargs, keywords = inspect.getargs(codeobject)
     if varargs:
         argnames.append(varargs)
         flags |= inspect.CO_VARARGS
     if keywords:
         argnames.append(keywords)
         flags |= inspect.CO_VARKEYWORDS
     return ast.Lambda(argnames, defaults, flags, func_decompiler.ast)
예제 #2
0
파일: decompiling.py 프로젝트: thedrow/pony
 def MAKE_FUNCTION(decompiler, argc):
     if argc: throw(NotImplementedError)
     tos = decompiler.stack.pop()
     if not PY2: tos = decompiler.stack.pop()
     codeobject = tos.value
     func_decompiler = Decompiler(codeobject)
     # decompiler.names.update(decompiler.names)  ???
     if codeobject.co_varnames[:1] == ('.0', ):
         return func_decompiler.ast  # generator
     argnames = codeobject.co_varnames[:codeobject.co_argcount]
     defaults = []  # todo
     flags = 0  # todo
     return ast.Lambda(argnames, defaults, flags, func_decompiler.ast)
예제 #3
0
 def MAKE_FUNCTION(decompiler, argc):
     if sys.version_info >= (3, 6):
         if argc:
             if argc != 0x08: throw(NotImplementedError, argc)
         qualname = decompiler.stack.pop()
         tos = decompiler.stack.pop()
         if (argc & 0x08): func_closure = decompiler.stack.pop()
     else:
         if argc: throw(NotImplementedError)
         tos = decompiler.stack.pop()
         if not PY2: tos = decompiler.stack.pop()
     codeobject = tos.value
     func_decompiler = Decompiler(codeobject)
     # decompiler.names.update(decompiler.names)  ???
     if codeobject.co_varnames[:1] == ('.0', ):
         return func_decompiler.ast  # generator
     argnames = codeobject.co_varnames[:codeobject.co_argcount]
     defaults = []  # todo
     flags = 0  # todo
     return ast.Lambda(argnames, defaults, flags, func_decompiler.ast)