ingests and deparses a given code block 'co'. If version is None,
    we will use the current Python interpreter version.
431108
def code_deparse(co, out=sys.stdout, version=None, debug_opts=DEFAULT_DEBUG_OPTS,
                 code_objects={}, compile_mode='exec', is_pypy=IS_PYPY, walker=SourceWalker):
    

    assert iscode(co)

    if version is None:
        version = float(sys.version[0:3])

    # store final output stream for case of error
    scanner = get_scanner(version, is_pypy=is_pypy)

    tokens, customize = scanner.ingest(co, code_objects=code_objects,
                                       show_asm=debug_opts['asm'])

    debug_parser = dict(PARSER_DEFAULT_DEBUG)
    if debug_opts.get('grammar', None):
        debug_parser['reduce'] = debug_opts['grammar']
        debug_parser['errorstack'] = 'full'

    #  Build Syntax Tree from disassembly.
    linestarts = dict(scanner.opc.findlinestarts(co))
    deparsed = walker(version, out, scanner, showast=debug_opts.get('ast', None),
                      debug_parser=debug_parser, compile_mode=compile_mode,
                      is_pypy=is_pypy, linestarts=linestarts)

    isTopLevel = co.co_name == '<module>'
    deparsed.ast = deparsed.build_ast(tokens, customize, isTopLevel=isTopLevel)

    #### XXX workaround for profiling
    if deparsed.ast is None:
        return None

    assert deparsed.ast == 'stmts', 'Should have parsed grammar start'

    # save memory
    del tokens

    deparsed.mod_globs, nonlocals = find_globals_and_nonlocals(deparsed.ast,
                                                               set(), set(),
                                                               co, version)

    assert not nonlocals

    # convert leading '__doc__ = "..." into doc string
    try:
        if deparsed.ast[0][0] == ASSIGN_DOC_STRING(co.co_consts[0]):
            print_docstring(deparsed, '', co.co_consts[0])
            del deparsed.ast[0]
        if deparsed.ast[-1] == RETURN_NONE:
            deparsed.ast.pop() # remove last node
            # todo: if empty, add 'pass'
    except:
        pass

    deparsed.FUTURE_UNICODE_LITERALS = (
        COMPILER_FLAG_BIT['FUTURE_UNICODE_LITERALS'] & co.co_flags != 0)

    # What we've been waiting for: Generate source from Syntax Tree!
    deparsed.gen_source(deparsed.ast, co.co_name, customize)

    for g in sorted(deparsed.mod_globs):
        deparsed.write('# global %s ## Warning: Unused global\n' % g)

    if deparsed.ast_errors:
        deparsed.write("# NOTE: have internal decompilation grammar errors.\n")
        deparsed.write("# Use -t option to show full context.")
        for err in deparsed.ast_errors:
            deparsed.write(err)
        raise SourceWalkerError("Deparsing hit an internal grammar-rule bug")

    if deparsed.ERROR:
        raise SourceWalkerError("Deparsing stopped due to parse error")
    return deparsed
888843
def detect_version(env, cc):
    """"""
    cc = env.subst(cc)
    if not cc:
        return None
    version = None
    #pipe = SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['-dumpversion'],
    pipe = SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['--version'],
                                 stdin = 'devnull',
                                 stderr = 'devnull',
                                 stdout = subprocess.PIPE)
    # -dumpversion was added in GCC 3.0.  As long as we're supporting
    # GCC versions older than that, we should use --version and a
    # regular expression.
    #line = pipe.stdout.read().strip()
    #if line:
    #    version = line
    line = SCons.Util.to_str(pipe.stdout.readline())
    match = re.search(r'[0-9]+(\.[0-9]+)+', line)
    if match:
        version = match.group(0)
    # Non-GNU compiler's output (like AIX xlc's) may exceed the stdout buffer:
    # So continue with reading to let the child process actually terminate.
    while SCons.Util.to_str(pipe.stdout.readline()):
        pass
    ret = pipe.wait()
    if ret != 0:
        return None
    return version
403822
def pycode_to_body(co, context):
    
    code = Code.from_pycode(co)

    # On each instruction, temporarily store all the jumps to the **next**
    # instruction.  This is used in _make_expr to determine when an expression
    # is part of a short-circuiting expression.
    for a, b in sliding_window(2, code.instrs):
        a._next_target_of = b._target_of
    b._next_target_of = set()

    try:
        body = instrs_to_body(deque(code.instrs), context)
        if context.in_function_block:
            return make_global_and_nonlocal_decls(code.instrs) + body
        return body
    finally:
        # Clean up jump target data.
        for i in code.instrs:
            del i._next_target_of
427266
def _handle_node(self, node, scope=None, ctxt=None, stream=None):
        
        if scope is None:
            if self._scope is None:
                self._scope = scope = self._create_scope()
            else:
                scope = self._scope

        if ctxt is None and self._ctxt is not None:
            ctxt = self._ctxt
        else:
            self._ctxt = ctxt

        if type(node) is tuple:
            node = node[1]

        # TODO probably a better way to do this...
        # this occurs with if-statements that have a single statement
        # instead of a compound statement (no curly braces)
        elif type(node) is list and len(list(filter(lambda x: isinstance(x, AST.Node), node))) == len(node):
            node = AST.Compound(
                block_items=node,
                coord=node[0].coord
            )
            return self._handle_node(node, scope, ctxt, stream)

        # need to check this so that debugger-eval'd statements
        # don't mess with the current state
        if not self._no_debug:
            self._coord = node.coord

        self._dlog("handling node type {}, line {}".format(node.__class__.__name__, node.coord.line if node.coord is not None else "?"))
        self._log.inc()

        breakable = self._node_is_breakable(node)

        if breakable and not self._no_debug and self._break_type != self.BREAK_NONE:
            # always break
            if self._break_type == self.BREAK_INTO:
                self._break_level = self._scope.level()
                self.debugger.cmdloop()

            # level <= _break_level
            elif self._break_type == self.BREAK_OVER:
                if self._scope.level() <= self._break_level:
                    self._break_level = self._scope.level()
                    self.debugger.cmdloop()
                else:
                    pass

        if node.__class__ not in self._node_switch:
            raise errors.UnsupportedASTNode(node.coord, node.__class__.__name__)

        res = self._node_switch[node.__class__](node, scope, ctxt, stream)

        self._log.dec()

        return res
4795
def disassembler(co, lasti= -1):
    

    code = co.co_code
    labels = dis.findlabels(code)
    linestarts = dict(dis.findlinestarts(co))
    i = 0
    extended_arg = 0
    lineno = 0
    free = None
    for i, op, oparg in _walk_ops(co):
        if i in linestarts:
            lineno = linestarts[i]
        instr = Instruction(i=i, op=op, lineno=lineno)
        instr.linestart = i in linestarts

        if i == lasti:
            instr.lasti = True
        else:
            instr.lasti = False

        if i in labels:
            instr.label = True
        else:
            instr.label = False

        instr.oparg = oparg
        extended_arg = 0
        if op == dis.EXTENDED_ARG:
            extended_arg = oparg * 65536
        instr.extended_arg = extended_arg
        if op >= dis.HAVE_ARGUMENT:
            if op in dis.hasconst:
                instr.arg = co.co_consts[oparg]
            elif op in dis.hasname:
                instr.arg = co.co_names[oparg]
            elif op in dis.hasjrel:
                instr.arg = i + oparg
            elif op in dis.haslocal:
                instr.arg = co.co_varnames[oparg]
            elif op in dis.hascompare:
                instr.arg = dis.cmp_op[oparg]
            elif op in dis.hasfree:
                if free is None:
                    free = co.co_cellvars + co.co_freevars
                instr.arg = free[oparg]

        yield instr
1231181
def dead_code_elimination(graph, du, ud):
    
    for node in graph.rpo:
        for i, ins in node.get_loc_with_ins():
            reg = ins.get_lhs()
            if reg is not None:
                # If the definition is not used, we check that the instruction
                # has no side effect. If there is one and this is a call, we
                # remove only the unused defined variable. else, this is
                # something like an array access, so we do nothing.
                # Otherwise (no side effect) we can remove the instruction from
                # the node.
                if (reg, i) not in du:
                    if ins.is_call():
                        ins.remove_defined_var()
                    elif ins.has_side_effect():
                        continue
                    else:
                        # We can delete the instruction. First update the DU
                        # chain of the variables used by the instruction to
                        # `let them know` that they are not used anymore by the
                        # deleted instruction.
                        # Then remove the instruction.
                        update_chain(graph, i, du, ud)
                        graph.remove_ins(i)
1359624
def get_code_object(x):
    """"""
    if hasattr(x, '__func__'): # Method
        x = x.__func__
    if hasattr(x, '__code__'): # Function
        x = x.__code__
    if hasattr(x, 'gi_code'):  # Generator
        x = x.gi_code
    if isinstance(x, str):     # Source code
        x = _try_compile(x, "<disassembly>")
    if hasattr(x, 'co_code'):  # Code object
        return x
    raise TypeError("don't know how to disassemble %s objects" %
                    type(x).__name__)
784781
def process_code_block(self, block):
        """"""
        if block['type'] != self.code:
            return block

        attr = PandocAttributes(block['attributes'], 'markdown')

        if self.match == 'all':
            pass

        elif self.match == 'fenced' and block.get('indent'):
            return self.new_text_block(content=('\n' +
                                                block['icontent'] +
                                                '\n'))

        elif self.match == 'strict' and 'input' not in attr.classes:
            return self.new_text_block(content=block['raw'])

        elif self.match not in list(attr.classes) + ['fenced', 'strict']:
            return self.new_text_block(content=block['raw'])

        # set input / output status of cell
        if 'output' in attr.classes and 'json' in attr.classes:
            block['IO'] = 'output'
        elif 'input' in attr.classes:
            block['IO'] = 'input'
            attr.classes.remove('input')
        else:
            block['IO'] = 'input'

        if self.caption_comments:
            # override attributes id and caption with those set in
            # comments, if they exist
            id, caption = get_caption_comments(block['content'])
            if id:
                attr.id = id
            if caption:
                attr['caption'] = caption

        try:
            # determine the language as the first class that
            # is in the block attributes and also in the list
            # of languages
            language = set(attr.classes).intersection(languages).pop()
            attr.classes.remove(language)
        except KeyError:
            language = None

        block['language'] = language
        block['attributes'] = attr

        # ensure one identifier for python code
        if language in ('python', 'py', '', None):
            block['language'] = self.python
        # add alternate language execution magic
        elif language != self.python and self.magic:
            block['content'] = CodeMagician.magic(language) + block['content']
            block['language'] = language

        return self.new_code_block(**block)
930951
def compile_to_python(exp, env, done=None): 
  ''''''
  original_exp = exp
  compiler = Compiler()
  if done is None:
    done = il.Done(compiler.new_var(il.ConstLocalVar('v')))
  compiler.exit_block_cont_map = {}
  compiler.continue_block_cont_map = {}
  compiler.protect_cont = done
  if env is None: env = Environment()
  exp = element(exp)
  exp = exp.alpha(env, compiler)
  exp = exp.cps(compiler, done)
  exp.analyse(compiler)
  env = Environment()
  exp = exp.optimize(env, compiler)
  #exp = exp.tail_recursive_convert()
  function = compiler.new_var(il.ConstLocalVar('compiled_dao_function'))
  exp = il.Function(function, (), exp)
  exp = il.begin(*exp.pythonize(env, compiler)[0])
  if isinstance(exp, il.Begin):
    exp = exp.statements[0]
  exp.body = exp.body.replace_return_with_yield()
  compiler = Compiler()
  result = exp.to_code(compiler)
  return prelude + result
750189
@Deprecated
  public final T parse(Readable readable, String moduleName) throws IOException {
    return parse(read(readable), moduleName);
  }
1070708
def parse(code):
    
    try:
        ast_tree = ast.parse(code)
    except Exception:
        raise RuntimeError('Bad Python code')

    transformer = Transformer()
    try:
        transformer.visit(ast_tree)
    except AssertionError as exc:
        raise RuntimeError('%d: %s' % (ast_tree.last_line, exc.args[0]))

    if not transformer.annotated:
        return None

    last_future_import = -1
    import_nni = ast.Import(names=[ast.alias(name='nni', asname=None)])
    nodes = ast_tree.body
    for i, _ in enumerate(nodes):
        if type(nodes[i]) is ast.ImportFrom and nodes[i].module == '__future__':
            last_future_import = i
    nodes.insert(last_future_import + 1, import_nni)

    return astor.to_source(ast_tree)
879086
def extract_code_objects(pe):
    """"""
    script_res = _get_scripts_resource(pe)
    dump = _resource_dump(pe, script_res)
    return _get_co_from_dump(dump)
538006
def parse_with_objects(code, var, **kwargs):
    

    deps = {}
    for key, value in kwargs.items():
        if isinstance(value, _compat.integer_types):
            value = str(value)

        if _compat.PY3:
            if value is None:
                value = str(value)

        if not isinstance(value, _compat.string_types) and \
                not isinstance(value, CodeBlock):
            new_var = var(value)
            deps[new_var] = value
            kwargs[key] = new_var

    block, var = parse_code(code, var, **kwargs)
    for key, dep in _compat.iteritems(deps):
        block.add_dependency(key, dep)

    return block, var
442557
def _parse_java_version(line: str) -> tuple:
    
    m = VERSION_RE.search(line)
    version_str = m and m.group(0).replace('"', '') or '0.0.0'
    if '_' in version_str:
        fst, snd = version_str.split('_', maxsplit=2)
        version = parse_version(fst)
        return (version[1], version[2], int(snd))
    else:
        return parse_version(version_str)
206726
def disasm_app(_parser, cmd, args):  # pragma: no cover
    

    parser = argparse.ArgumentParser(
        prog=_parser.prog,
        description=_parser.description,
    )
    parser.add_argument('code', help='the code to disassemble, read from stdin if omitted', nargs='?')
    pwnypack.main.add_target_arguments(parser)
    parser.add_argument(
        '--syntax', '-s',
        choices=AsmSyntax.__members__.keys(),
        default=None,
    )
    parser.add_argument(
        '--address', '-o',
        type=lambda v: int(v, 0),
        default=0,
        help='the address of the disassembled code',
    )
    parser.add_argument(
        '--format', '-f',
        choices=['hex', 'bin'],
        help='the input format (defaults to hex for commandline, bin for stdin)',
    )

    args = parser.parse_args(args)
    target = pwnypack.main.target_from_arguments(args)
    if args.syntax is not None:
        syntax = AsmSyntax.__members__[args.syntax]
    else:
        syntax = None

    if args.format is None:
        if args.code is None:
            args.format = 'bin'
        else:
            args.format = 'hex'

    if args.format == 'hex':
        code = pwnypack.codec.dehex(pwnypack.main.string_value_or_stdin(args.code))
    else:
        code = pwnypack.main.binary_value_or_stdin(args.code)

    print('\n'.join(disasm(code, args.address, syntax=syntax, target=target)))
1234591
def _from_deprecated_son(cls, id_dict, run):
        """"""
        cls._deprecation_warning()
        return BlockUsageLocator._from_deprecated_son(id_dict, run)
1148464
function(){
    var block = this.parent = this.root;
    if (Parser.cache.has(this.hash)) {
      block = Parser.cache.get(this.hash);
      // normalize cached imports
      if ('block' == block.nodeName) block.constructor = nodes.Root;
    } else {
      while ('eos' != this.peek().type) {
        this.skipWhitespace();
        if ('eos' == this.peek().type) break;
        var stmt = this.statement();
        this.accept(';');
        if (!stmt) this.error('unexpected token {peek}, not allowed at the root level');
        block.push(stmt);
      }
      Parser.cache.set(this.hash, block);
    }
    return block;
  }