# Path: prolog/interpreter/parsing.py
# def parse_query_term(s):
#     return get_query_and_vars(s)[0]
# 
# def get_engine(source, create_files=False, load_system=False, **modules):
#     from prolog.interpreter.continuation import Engine
#     from prolog.interpreter.test.tool import create_file, delete_file
#     e = Engine(load_system)
#     for name, module in modules.iteritems():
#         if create_files:
#             create_file(name, module)
#         else:
#             e.runstring(module)
#     try:
#         e.modulewrapper.current_module = e.modulewrapper.user_module
#         e.runstring(source)
#     finally:
#         if create_files:
#             for name in modules.keys():
#                 delete_file(name)
#     return e
# 
# Path: prolog/interpreter/parsing.py
# def get_query_and_vars(s):
#     tokens = lexer.tokenize(s, eof=True)
#     s = parser_query.parse(tokens, lazy=False)
#     builder = TermBuilder()
#     query = builder.build_query(s)
#     return query, builder.varname_to_var
# 
# Path: prolog/interpreter/continuation.py
# def get_printable_location(rule, sconttype):
# def get_jitcell_at(where, rule):
# def set_jitcell_at(newcell, where, rule):
# def driver(scont, fcont, heap):
# def _process_hooks(scont, fcont, heap):
#     def __init__(self, load_system=False):
#     def _freeze_(self):
#     def add_rule(self, ruleterm, end=True):
#     def make_rule(self, ruleterm, module):
#     def get_builtin(self, signature):
#     def _build_and_run(self, tree, source_string, file_name):
#     def _term_expand(self, term):
#     def runstring(self, s, file_name=None):
#     def parse(self, s, file_name=None):
#     def getoperations(self):
#     def run_query(self, query, module, continuation=None):
#     def run_query_in_current(self, query, continuation=None):
#     def call(self, query, rule, scont, fcont, heap):
#     def call_in_module(self, query, module, scont, fcont, heap):
#     def _get_function(self, signature, module, query): 
#     def switch_module(self, modulename):
#     def throw(self, exc, scont, fcont, heap, rule_likely_source=None):
#     def __freeze__(self):
# def _make_rule_conts(engine, scont, fcont, heap, query, rulechain):
# def _dot(self, seen):
#     def __new__(cls, name, bases, dct):
#     def __init__(self, engine, nextcont):
#     def activate(self, fcont, heap):
#     def is_done(self):
#     def find_end_of_cut(self):
#     def __init__(self, engine, nextcont, rule):
# def view(*objects, **names):
#     def __init__(self, engine, nextcont, orig_fcont, heap):
#     def fail(self, heap):
#     def cut(self, upto, heap):
#     def is_done(self):
# def make_failure_continuation(make_func):
#         def __init__(self, engine, scont, fcont, heap, *state):
#         def fail(self, heap):
#     def make_func_wrapper(*args):
#     def __init__(self, engine):
#     def is_done(self):
#     def __init__(self, engine):
#     def fail(self, heap):
#     def is_done(self):
#     def __init__(self, engine, rule, nextcont, body):
#     def activate(self, fcont, heap):
#     def __repr__(self):
#     def __init__(self, engine, rule, nextcont, builtin, query):
#     def activate(self, fcont, heap):
#     def __repr__(self):
#     def __init__(self, engine, nextcont, orig_fcont, heap, query, rulechain):
#     def fail(self, heap):
#     def __repr__(self):
#     def __init__(self, engine, nextcont, rule, query):
#     def activate(self, fcont, heap):
#     def __repr__(self):
#     def __init__(self, engine, nextcont, fcont_after_cut):
#     def insert_scope_notifier(engine, nextcont, fcont):
#     def find_end_of_cut(self):
#     def activate(self, fcont, heap):
#     def __init__(self, engine, rule, nextcont, fcont, catcher, recover, heap):
#     def activate(self, fcont, heap):
#     def __repr__(self):
# class Engine(object):
# class MetaCont(type):
# class Continuation(object):
# class ContinuationWithRule(Continuation):
# class FailureContinuation(object):
#     class C(FailureContinuation):
# class DoneSuccessContinuation(Continuation):
# class DoneFailureContinuation(FailureContinuation):
# class BodyContinuation(ContinuationWithRule):
# class BuiltinContinuation(ContinuationWithRule):
# class UserCallContinuation(FailureContinuation):
# class RuleContinuation(ContinuationWithRule):
# class CutScopeNotifier(Continuation):
# class CatchingDelimiter(ContinuationWithRule):


import sys
from rpython import conftest
from rpython.jit.metainterp.test.test_ajit import LLJitMixin
from prolog.interpreter.parsing import parse_query_term, get_engine
from prolog.interpreter.parsing import get_query_and_vars
from prolog.interpreter.continuation import jitdriver
            X =< Y, !,
            partition(L,Y,L1,L2).
        partition([X|L],Y,L1,[X|L2]) :-
            partition(L,Y,L1,L2).

        loop_mod(0).
        loop_mod(N) :-
            N > 0,
            f(N, N1),
            loop_mod(N1).

        loop_when(0).
        loop_when(N) :-
            N > 0,
            when(nonvar(X), loop_when(X)),
            X is N - 1.

        freeze_list(Num, Millis) :-
            make_varlist(Num, List),
            statistics(walltime, [T1, _]),
            freeze_list_inner(List),
            statistics(walltime, [T2, _]),
            Millis is T2 - T1.

        freeze_list_inner(List) :-
            freeze_list_inner_2(List),
            melt_list(List).

        freeze_list_inner_2([]).
        freeze_list_inner_2([H|Rest]) :-

# Path: prolog/interpreter/parsing.py
# def parse_query_term(s):
#     return get_query_and_vars(s)[0]
# 
# def get_engine(source, create_files=False, load_system=False, **modules):
#     from prolog.interpreter.continuation import Engine
#     from prolog.interpreter.test.tool import create_file, delete_file
#     e = Engine(load_system)
#     for name, module in modules.iteritems():
#         if create_files:
#             create_file(name, module)
#         else:
#             e.runstring(module)
#     try:
#         e.modulewrapper.current_module = e.modulewrapper.user_module
#         e.runstring(source)
#     finally:
#         if create_files:
#             for name in modules.keys():
#                 delete_file(name)
#     return e
# 
# Path: prolog/interpreter/parsing.py
# def get_query_and_vars(s):
#     tokens = lexer.tokenize(s, eof=True)
#     s = parser_query.parse(tokens, lazy=False)
#     builder = TermBuilder()
#     query = builder.build_query(s)
#     return query, builder.varname_to_var
# 
# Path: prolog/interpreter/continuation.py
# def get_printable_location(rule, sconttype):
# def get_jitcell_at(where, rule):
# def set_jitcell_at(newcell, where, rule):
# def driver(scont, fcont, heap):
# def _process_hooks(scont, fcont, heap):
#     def __init__(self, load_system=False):
#     def _freeze_(self):
#     def add_rule(self, ruleterm, end=True):
#     def make_rule(self, ruleterm, module):
#     def get_builtin(self, signature):
#     def _build_and_run(self, tree, source_string, file_name):
#     def _term_expand(self, term):
#     def runstring(self, s, file_name=None):
#     def parse(self, s, file_name=None):
#     def getoperations(self):
#     def run_query(self, query, module, continuation=None):
#     def run_query_in_current(self, query, continuation=None):
#     def call(self, query, rule, scont, fcont, heap):
#     def call_in_module(self, query, module, scont, fcont, heap):
#     def _get_function(self, signature, module, query): 
#     def switch_module(self, modulename):
#     def throw(self, exc, scont, fcont, heap, rule_likely_source=None):
#     def __freeze__(self):
# def _make_rule_conts(engine, scont, fcont, heap, query, rulechain):
# def _dot(self, seen):
#     def __new__(cls, name, bases, dct):
#     def __init__(self, engine, nextcont):
#     def activate(self, fcont, heap):
#     def is_done(self):
#     def find_end_of_cut(self):
#     def __init__(self, engine, nextcont, rule):
# def view(*objects, **names):
#     def __init__(self, engine, nextcont, orig_fcont, heap):
#     def fail(self, heap):
#     def cut(self, upto, heap):
#     def is_done(self):
# def make_failure_continuation(make_func):
#         def __init__(self, engine, scont, fcont, heap, *state):
#         def fail(self, heap):
#     def make_func_wrapper(*args):
#     def __init__(self, engine):
#     def is_done(self):
#     def __init__(self, engine):
#     def fail(self, heap):
#     def is_done(self):
#     def __init__(self, engine, rule, nextcont, body):
#     def activate(self, fcont, heap):
#     def __repr__(self):
#     def __init__(self, engine, rule, nextcont, builtin, query):
#     def activate(self, fcont, heap):
#     def __repr__(self):
#     def __init__(self, engine, nextcont, orig_fcont, heap, query, rulechain):
#     def fail(self, heap):
#     def __repr__(self):
#     def __init__(self, engine, nextcont, rule, query):
#     def activate(self, fcont, heap):
#     def __repr__(self):
#     def __init__(self, engine, nextcont, fcont_after_cut):
#     def insert_scope_notifier(engine, nextcont, fcont):
#     def find_end_of_cut(self):
#     def activate(self, fcont, heap):
#     def __init__(self, engine, rule, nextcont, fcont, catcher, recover, heap):
#     def activate(self, fcont, heap):
#     def __repr__(self):
# class Engine(object):
# class MetaCont(type):
# class Continuation(object):
# class ContinuationWithRule(Continuation):
# class FailureContinuation(object):
#     class C(FailureContinuation):
# class DoneSuccessContinuation(Continuation):
# class DoneFailureContinuation(FailureContinuation):
# class BodyContinuation(ContinuationWithRule):
# class BuiltinContinuation(ContinuationWithRule):
# class UserCallContinuation(FailureContinuation):
# class RuleContinuation(ContinuationWithRule):
# class CutScopeNotifier(Continuation):
# class CatchingDelimiter(ContinuationWithRule):


# Path: prolog/jittest/interpjit.py
import sys
from rpython import conftest
from rpython.jit.metainterp.test.test_ajit import LLJitMixin
from prolog.interpreter.parsing import parse_query_term, get_engine
from prolog.interpreter.parsing import get_query_and_vars
from prolog.interpreter.continuation import jitdriver

            X =< Y, !,
            partition(L,Y,L1,L2).
        partition([X|L],Y,L1,[X|L2]) :-
            partition(L,Y,L1,L2).

        loop_mod(0).
        loop_mod(N) :-
            N > 0,
            f(N, N1),
            loop_mod(N1).

        loop_when(0).
        loop_when(N) :-
            N > 0,
            when(nonvar(X), loop_when(X)),
            X is N - 1.

        freeze_list(Num, Millis) :-
            make_varlist(Num, List),
            statistics(walltime, [T1, _]),
            freeze_list_inner(List),
            statistics(walltime, [T2, _]),
            Millis is T2 - T1.

        freeze_list_inner(List) :-
            freeze_list_inner_2(List),
            melt_list(List).

        freeze_list_inner_2([]).
        freeze_list_inner_2([H|Rest]) :-

            freeze(H, true),