% compiler: GNU Prolog 0.9.0 (Mar 16 1999)
% file    : catch.pl
% date    : 4 16 1999
% time    : 15:53:41


file_name('/home/loews/loco/diaz/GNU-Prolog/src/BipsPl/catch.pl').


predicate('$use_catch'/0,27,static,private,built_in,[
    proceed]).


predicate('$catch'/6,33,static,private,built_in,[
    call_c('Save_Call_Info_3',[3,4,5]),
    put_integer(0,3),
    execute('$catch1'/4)]).


predicate('$catch1'/4,37,static,private,built_in,[
    put_integer(3,4),
    call_c('Load_Call_Info_Arg_1',[4]),
    execute('$catch_internal'/4)]).


predicate('$catch_internal'/4,42,static,private,built_in,[
    allocate(5),
    get_variable(y(0),0),
    get_variable(y(1),1),
    get_variable(y(2),2),
    get_variable(y(3),3),
    put_integer(7,0),
    put_variable(y(4),1),
    call('$sys_var_read'/2),
    put_integer(8,0),
    put_atom('$no_ball$',1),
    call('$sys_var_put'/2),
    put_value(y(0),0),
    put_value(y(1),1),
    put_value(y(2),2),
    put_value(y(3),3),
    put_unsafe_value(y(4),4),
    deallocate,
    execute('$catch_internal1'/5)]).


predicate('$catch_internal1'/5,48,static,private,built_in,[
    load_cut_level(5),
    try_me_else(1),
    allocate(6),
    get_variable(y(0),0),
    get_variable(y(1),3),
    get_variable(y(2),4),
    get_variable(y(3),5),
    put_variable(y(4),0),
    call('$get_current_B'/1),
    put_integer(7,0),
    put_value(y(4),1),
    call('$sys_var_write'/2),
    put_value(y(0),0),
    put_value(y(1),1),
    call('$call_internal'/2),
    put_variable(y(5),0),
    call('$get_current_B'/1),
    put_value(y(5),0),
    put_value(y(4),1),
    put_value(y(3),2),
    call('$$catch_internal1/5_$aux1'/3),
    put_integer(7,0),
    put_value(y(2),1),
    deallocate,
    execute('$sys_var_write'/2),

label(1),
    trust_me_else_fail,
    allocate(5),
    get_variable(y(0),1),
    get_variable(y(1),2),
    get_variable(y(2),3),
    get_variable(y(3),4),
    put_integer(7,0),
    put_value(y(3),1),
    call('$sys_var_write'/2),
    put_integer(8,0),
    put_variable(y(4),1),
    call('$sys_var_get'/2),
    put_unsafe_value(y(4),0),
    put_atom('$no_ball$',1),
    call_c_test('Blt_Term_Neq',[0,1]),
    put_unsafe_value(y(4),0),
    put_value(y(0),1),
    put_value(y(1),2),
    put_value(y(2),3),
    put_value(y(3),4),
    deallocate,
    execute('$catch_a_throw'/5)]).


predicate('$$catch_internal1/5_$aux1'/3,48,static,private,built_in,[
    load_cut_level(3),
    try_me_else(1),
    put_atom(>,2),
    put_integer(2,4),
    call_c('Set_Bip_Name_2',[2,4]),
    math_load_value(x(0),0),
    math_load_value(x(1),2),
    call_c_test('Blt_Gt',[0,2]),
    cut(x(3)),
    put_value(x(1),0),
    execute('$trail_handler'/1),

label(1),
    trust_me_else_fail,
    cut(x(2)),
    proceed]).


predicate('$catch_a_throw'/5,75,static,private,built_in,[
    load_cut_level(5),
    try_me_else(1),
    call_c_test('Blt_Non_Var',[0]),
    get_structure('$catch_sync'/1,0),
    unify_variable(x(1)),
    cut(x(5)),
    put_value(x(4),0),
    execute('$$catch_a_throw/5_$aux1'/2),

label(1),
    retry_me_else(2),
    allocate(2),
    get_variable(y(0),2),
    get_variable(y(1),3),
    get_value(x(1),0),
    cut(x(5)),
    put_integer(8,0),
    put_atom('$no_ball$',1),
    call('$sys_var_put'/2),
    put_value(y(0),0),
    put_value(y(1),1),
    deallocate,
    execute('$call_internal'/2),

label(2),
    trust_me_else_fail,
    execute('$unwind'/1)]).


predicate('$$catch_a_throw/5_$aux1'/2,75,static,private,built_in,[
    load_cut_level(2),
    try_me_else(1),
    put_atom(>,3),
    put_integer(2,4),
    call_c('Set_Bip_Name_2',[3,4]),
    math_load_value(x(0),0),
    math_load_value(x(1),3),
    call_c_test('Blt_Gt',[0,3]),
    cut(x(2)),
    put_structure('$catch_sync'/1,0),
    unify_local_value(x(1)),
    execute('$unwind'/1),

label(1),
    trust_me_else_fail,
    put_value(x(1),0),
    execute('$catch_fail_now'/1)]).


predicate('$trail_handler'/1,92,static,private,built_in,[
    try_me_else(1),
    proceed,

label(1),
    trust_me_else_fail,
    allocate(0),
    put_value(x(0),1),
    put_integer(7,0),
    call('$sys_var_write'/2),
    fail]).


predicate('$catch_sync_for_fail_at'/1,101,static,private,built_in,[
    allocate(2),
    get_variable(y(0),0),
    put_integer(7,0),
    put_variable(y(1),1),
    call('$sys_var_read'/2),
    put_unsafe_value(y(1),0),
    put_value(y(0),1),
    deallocate,
    execute('$$catch_sync_for_fail_at/1_$aux1'/2)]).


predicate('$$catch_sync_for_fail_at/1_$aux1'/2,101,static,private,built_in,[
    load_cut_level(2),
    try_me_else(1),
    put_atom(>,3),
    put_integer(2,4),
    call_c('Set_Bip_Name_2',[3,4]),
    math_load_value(x(0),0),
    math_load_value(x(1),3),
    call_c_test('Blt_Gt',[0,3]),
    cut(x(2)),
    put_structure('$catch_sync'/1,0),
    unify_local_value(x(1)),
    put_atom('$catch_sync_for_fail_at',1),
    put_integer(1,2),
    put_atom(true,3),
    execute('$throw'/4),

label(1),
    trust_me_else_fail,
    put_value(x(1),0),
    execute('$catch_fail_now'/1)]).


predicate('$catch_fail_now'/1,110,static,private,built_in,[
    allocate(0),
    call('$set_current_B'/1),
    fail]).
