# Path: prolog/interpreter/term.py
# class NumberedVar(PrologObject):
#     _immutable_fields_ = ["num"]
#     def __init__(self, index):
#         self.num = index
#     
#     def copy_standardize_apart(self, heap, env):
#         if self.num < 0:
#             return heap.newvar()
#         res = env[self.num]
#         if res is None:
#             res = env[self.num] = heap.newvar()
#         return res
# 
#     def copy_standardize_apart_as_child_of(self, heap, env, parent, index):
#         if self.num < 0:
#             return heap.newvar_in_term(parent, index)
#         res = env[self.num]
#         if res is None:
#             res = env[self.num] = heap.newvar_in_term(parent, index)
#         return res
# 
#     def unify_and_standardize_apart(self, other, heap, env):
#         if self.num < 0:
#             return other
#         res = env[self.num]
#         if res is None:
#             other = env[self.num] = other #.dereference(heap)
#             return other
#         res.unify(other, heap)
#         return res
#     
#     def dereference(self, heap):
#         return self
#     
#     def __repr__(self):
#         return "NumberedVar(%s)" % (self.num, )


from prolog.interpreter.term import NumberedVar

class EnumerationMemo(object):
    """A memo object to enumerate the variables in a term"""
    def __init__(self):
        self.seen = {}
        self.varcount = 0

    def get(self, var):
        res = self.seen.get(var, None)
        if not res:

# Path: prolog/interpreter/term.py
# class NumberedVar(PrologObject):
#     _immutable_fields_ = ["num"]
#     def __init__(self, index):
#         self.num = index
#     
#     def copy_standardize_apart(self, heap, env):
#         if self.num < 0:
#             return heap.newvar()
#         res = env[self.num]
#         if res is None:
#             res = env[self.num] = heap.newvar()
#         return res
# 
#     def copy_standardize_apart_as_child_of(self, heap, env, parent, index):
#         if self.num < 0:
#             return heap.newvar_in_term(parent, index)
#         res = env[self.num]
#         if res is None:
#             res = env[self.num] = heap.newvar_in_term(parent, index)
#         return res
# 
#     def unify_and_standardize_apart(self, other, heap, env):
#         if self.num < 0:
#             return other
#         res = env[self.num]
#         if res is None:
#             other = env[self.num] = other #.dereference(heap)
#             return other
#         res.unify(other, heap)
#         return res
#     
#     def dereference(self, heap):
#         return self
#     
#     def __repr__(self):
#         return "NumberedVar(%s)" % (self.num, )


# Path: prolog/interpreter/memo.py
from prolog.interpreter.term import NumberedVar


class EnumerationMemo(object):
    """A memo object to enumerate the variables in a term"""
    def __init__(self):
        self.seen = {}
        self.varcount = 0

    def get(self, var):
        res = self.seen.get(var, None)
        if not res:

            self.seen[var] = res = NumberedVar(-1)