# Path: supplement/tree.py
# class CtxNodeProvider(NodeProvider):
#     def __init__(self, ctx, node):
#         self.node = node
#         self.ctx = ctx
# 
#     def get_node(self):
#         return self.node
# 
# Path: supplement/common.py
# class Object(object):
#     def get_location(self):
#         raise NotImplementedError()
#         return None, None
# 
#     def get_names(self):
#         return set()
# 
#     def __contains__(self, name):
#         return name in self.get_names()
# 
#     def __getitem__(self, name):
#         return UnknownObject()
# 
#     def op_call(self, *args):
#         return UnknownObject()
# 
#     def op_getitem(self, idx):
#         return UnknownObject()
# 
#     def op_setitem(self, idx, value):
#         logging.getLogger(__name__).info('Try to set item on unknown object %s', self)
# 
#     def is_descriptor(self):
#         return False
# 
#     def get_assigned_attributes(self):
#         return {}
# 
#     def get_docstring(self):
#         return None
# 
#     def get_signature(self):
#         return None
# 
#     def get_scope(self):
#         return None
# 
#     def op_common_item(self):
#         return UnknownObject()
# 
# class GetObjectDelegate(object):
#     def get_names(self):
#         return self.get_object().get_names()
# 
#     def __getitem__(self, name):
#         return self.get_object()[name]
# 
#     def __contains__(self, name):
#         return name in self.get_object()
# 
#     def op_call(self, args):
#         return self.get_object().op_call(args)
# 
#     def op_getitem(self, idx):
#         return self.get_object().op_getitem(idx)
# 
#     def op_setitem(self, idx, value):
#         return self.get_object().op_setitem(idx, value)
# 
#     def get_location(self):
#         return self.get_object().get_location()
# 
#     def is_descriptor(self):
#         return self.get_object().is_descriptor()
# 
#     def get_assigned_attributes(self):
#         return self.get_object().get_assigned_attributes()
# 
#     def get_docstring(self):
#         return self.get_object().get_docstring()
# 
#     def get_signature(self):
#         return self.get_object().get_signature()
# 
#     def get_scope(self):
#         return self.get_object().get_scope()
# 
#     def op_common_item(self):
#         return self.get_object().op_common_item()
# 
# class MethodObject(GetObjectDelegate):
#     def __init__(self, obj, func_obj):
#         self.object = obj
#         self.function = func_obj
# 
#     def get_scope(self):
#         return self.function.get_scope()
# 
#     def get_object(self):
#         return self.function
# 
#     def op_call(self, args):
#         return self.function.op_call([self.object] + args)
# 
#     def get_signature(self):
#         sig = self.function.get_signature()
#         if sig:
#             name, args, vararg, kwarg, defaults = sig
#             return name, args[1:], vararg, kwarg, defaults
#         else:
#             return None
# 
# class UnknownObject(Object): pass


import logging
from types import FunctionType, ClassType, ModuleType, BuiltinFunctionType
from inspect import getargspec, getdoc
from .tree import CtxNodeProvider
from .common import Object, GetObjectDelegate, MethodObject, UnknownObject
        module = self.project.get_module(mname, self.filename)
        return module[name]


class FunctionObject(LocationObject):
    def __init__(self, node, func):
        LocationObject.__init__(self, node)
        self.func = func

    def __repr__(self):
        return '<FunctionObject %s %s>' % (self.func.__name__, getattr(self, 'filename', 'No file'))

    def get_scope(self):
        module = getattr(self, 'declared_in', None)
        if not module:
            module_name = getattr(self.func, '__module__', None)
            if module_name:
                module = self.project.get_module(module_name)

        if module:
            code = getattr(self.func, '__code__', None)
            if code:
                return module.get_scope_at(code.co_firstlineno)

        return None

    def op_call(self, args):
        scope = self.get_scope()
        if scope:
            return scope.function.op_call(args)

# Path: supplement/tree.py
# class CtxNodeProvider(NodeProvider):
#     def __init__(self, ctx, node):
#         self.node = node
#         self.ctx = ctx
# 
#     def get_node(self):
#         return self.node
# 
# Path: supplement/common.py
# class Object(object):
#     def get_location(self):
#         raise NotImplementedError()
#         return None, None
# 
#     def get_names(self):
#         return set()
# 
#     def __contains__(self, name):
#         return name in self.get_names()
# 
#     def __getitem__(self, name):
#         return UnknownObject()
# 
#     def op_call(self, *args):
#         return UnknownObject()
# 
#     def op_getitem(self, idx):
#         return UnknownObject()
# 
#     def op_setitem(self, idx, value):
#         logging.getLogger(__name__).info('Try to set item on unknown object %s', self)
# 
#     def is_descriptor(self):
#         return False
# 
#     def get_assigned_attributes(self):
#         return {}
# 
#     def get_docstring(self):
#         return None
# 
#     def get_signature(self):
#         return None
# 
#     def get_scope(self):
#         return None
# 
#     def op_common_item(self):
#         return UnknownObject()
# 
# class GetObjectDelegate(object):
#     def get_names(self):
#         return self.get_object().get_names()
# 
#     def __getitem__(self, name):
#         return self.get_object()[name]
# 
#     def __contains__(self, name):
#         return name in self.get_object()
# 
#     def op_call(self, args):
#         return self.get_object().op_call(args)
# 
#     def op_getitem(self, idx):
#         return self.get_object().op_getitem(idx)
# 
#     def op_setitem(self, idx, value):
#         return self.get_object().op_setitem(idx, value)
# 
#     def get_location(self):
#         return self.get_object().get_location()
# 
#     def is_descriptor(self):
#         return self.get_object().is_descriptor()
# 
#     def get_assigned_attributes(self):
#         return self.get_object().get_assigned_attributes()
# 
#     def get_docstring(self):
#         return self.get_object().get_docstring()
# 
#     def get_signature(self):
#         return self.get_object().get_signature()
# 
#     def get_scope(self):
#         return self.get_object().get_scope()
# 
#     def op_common_item(self):
#         return self.get_object().op_common_item()
# 
# class MethodObject(GetObjectDelegate):
#     def __init__(self, obj, func_obj):
#         self.object = obj
#         self.function = func_obj
# 
#     def get_scope(self):
#         return self.function.get_scope()
# 
#     def get_object(self):
#         return self.function
# 
#     def op_call(self, args):
#         return self.function.op_call([self.object] + args)
# 
#     def get_signature(self):
#         sig = self.function.get_signature()
#         if sig:
#             name, args, vararg, kwarg, defaults = sig
#             return name, args[1:], vararg, kwarg, defaults
#         else:
#             return None
# 
# class UnknownObject(Object): pass


# Path: supplement/objects.py
import logging
from types import FunctionType, ClassType, ModuleType, BuiltinFunctionType
from inspect import getargspec, getdoc
from .tree import CtxNodeProvider
from .common import Object, GetObjectDelegate, MethodObject, UnknownObject

        module = self.project.get_module(mname, self.filename)
        return module[name]


class FunctionObject(LocationObject):
    def __init__(self, node, func):
        LocationObject.__init__(self, node)
        self.func = func

    def __repr__(self):
        return '<FunctionObject %s %s>' % (self.func.__name__, getattr(self, 'filename', 'No file'))

    def get_scope(self):
        module = getattr(self, 'declared_in', None)
        if not module:
            module_name = getattr(self.func, '__module__', None)
            if module_name:
                module = self.project.get_module(module_name)

        if module:
            code = getattr(self.func, '__code__', None)
            if code:
                return module.get_scope_at(code.co_firstlineno)

        return None

    def op_call(self, args):
        scope = self.get_scope()
        if scope:
            return scope.function.op_call(args)

        else: