# 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
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals




def _resolve_constant_value(name):
    """Get the AST node representing the constant value of a name."""
    decl = name.declaration

    if isinstance(decl, ast.Assign):

        target = decl.targets[0]
        value = decl.value

        if isinstance(target, ast.Tuple) and isinstance(value, ast.Tuple):

            for idx, elt in enumerate(target.elts):

                if isinstance(elt, ast.Name) and elt.id == name.token:

                    return value.elts[idx]

        else:

            return value



# 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

from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals




def _resolve_constant_value(name):
    """Get the AST node representing the constant value of a name."""
    decl = name.declaration

    if isinstance(decl, ast.Assign):

        target = decl.targets[0]
        value = decl.value

        if isinstance(target, ast.Tuple) and isinstance(value, ast.Tuple):

            for idx, elt in enumerate(target.elts):

                if isinstance(elt, ast.Name) and elt.id == name.token:

                    return value.elts[idx]

        else:

            return value



class ConstantInliner(visitor.NodeTransformer):