# Path: pycc/asttools/name.py
# NAME_SOURCE = enum.Enum(('DEFINED', 'ADOPTED', 'IMPORTED', 'BUILTIN'))
# def declaration(node, start=None):
# def name_source(node, declared=None):
#     def visit_Name(self, node):
#     def visit_alias(self, node):
#     def visit_FunctionDef(self, node):
#     def visit_Global(self, node):
#     def visit_arguments(self, node):
#     def visit_arg(self, node):
# class NameVisitorMixin(object):
# 
# Path: pycc/asttools/visitor.py
# class NodeVisitor(object):
# class NodeVisitorIter(NodeVisitor):
# class NodeTransformer(NodeVisitor):
#     def __init__(self, node):
#     def generic_visit(self, node):
#     def visit(self):
#     def visit(self):
#     def __init__(self, *args, **kwargs):
#     def modified(self):
#     def _replace(self, new, old):
#     def visit(self):
# 
# Path: pycc/astwrappers/name.py
# class NameGenerator(visitortools.NodeVisitorIter, nametools.NameVisitorMixin):
# class Name(object):
#     def visit(self):
#     def __init__(self, node):
#     def node(self):
#     def declaration(self):
#     def source(self):
#     def token(self):
#     def uses(self):
#     def assignments(self):
#     def constant(self):
#     def __repr__(self):
#     def __lt__(self, other):
#     def __gt__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __le__(self, other):
#     def __ge__(self, other):
#     def __hash__(self):


import ast
from ..asttools import name as nametools
from ..asttools import visitor
from ..astwrappers import name as namewrap

            return value


class ConstantInliner(visitor.NodeTransformer):

    """NodeTransformer which places constant values in-line."""

    def visit_Name(self, node):
        """Replace ast.Name with a value if it is a constant reference."""
        n = namewrap.Name(node)

        # Skip if not loading the value from memory.
        if not isinstance(node.ctx, ast.Load):

            return node

        # Skip if value is not constant.
        if not n.constant or n.node is n.declaration:

            return node

        # Skip if the node represents the initial assignment.
        if n.node is n.declaration:

            return node

        # Skip if the constant value cannot be found.
        if n.source in (
            nametools.NAME_SOURCE.BUILTIN,

# Path: pycc/asttools/name.py
# NAME_SOURCE = enum.Enum(('DEFINED', 'ADOPTED', 'IMPORTED', 'BUILTIN'))
# def declaration(node, start=None):
# def name_source(node, declared=None):
#     def visit_Name(self, node):
#     def visit_alias(self, node):
#     def visit_FunctionDef(self, node):
#     def visit_Global(self, node):
#     def visit_arguments(self, node):
#     def visit_arg(self, node):
# class NameVisitorMixin(object):
# 
# Path: pycc/asttools/visitor.py
# class NodeVisitor(object):
# class NodeVisitorIter(NodeVisitor):
# class NodeTransformer(NodeVisitor):
#     def __init__(self, node):
#     def generic_visit(self, node):
#     def visit(self):
#     def visit(self):
#     def __init__(self, *args, **kwargs):
#     def modified(self):
#     def _replace(self, new, old):
#     def visit(self):
# 
# Path: pycc/astwrappers/name.py
# class NameGenerator(visitortools.NodeVisitorIter, nametools.NameVisitorMixin):
# class Name(object):
#     def visit(self):
#     def __init__(self, node):
#     def node(self):
#     def declaration(self):
#     def source(self):
#     def token(self):
#     def uses(self):
#     def assignments(self):
#     def constant(self):
#     def __repr__(self):
#     def __lt__(self, other):
#     def __gt__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __le__(self, other):
#     def __ge__(self, other):
#     def __hash__(self):


# Path: pycc/optimizers/constant.py
import ast
from ..asttools import name as nametools
from ..asttools import visitor
from ..astwrappers import name as namewrap


            return value


class ConstantInliner(visitor.NodeTransformer):

    """NodeTransformer which places constant values in-line."""

    def visit_Name(self, node):
        """Replace ast.Name with a value if it is a constant reference."""
        n = namewrap.Name(node)

        # Skip if not loading the value from memory.
        if not isinstance(node.ctx, ast.Load):

            return node

        # Skip if value is not constant.
        if not n.constant or n.node is n.declaration:

            return node

        # Skip if the node represents the initial assignment.
        if n.node is n.declaration:

            return node

        # Skip if the constant value cannot be found.
        if n.source in (
            nametools.NAME_SOURCE.BUILTIN,

            nametools.NAME_SOURCE.IMPORTED,