TERM bpx_get_car(TERM t) { XDEREF(t); if (ISLIST(t)) { return GET_CAR(t); } else { bpx_raise("list expected"); } }
int pc_add_egraph_path_3(void) { TERM p_node_id,p_children,p_sws; int node_id; /* children_prolog and sws_prolog must be in the table area */ p_node_id = bpx_get_call_arg(1,3); p_children = bpx_get_call_arg(2,3); p_sws = bpx_get_call_arg(3,3); if (!bpx_is_integer(p_node_id)) RET_ERR(err_invalid_goal_id); node_id = bpx_get_integer(p_node_id); XDEREF(p_children); XDEREF(p_sws); RET_ON_ERR(add_egraph_path(node_id,p_children,p_sws)); return BP_TRUE; }
BPLONG bpx_get_integer(TERM t) { XDEREF(t); if (ISINT(t)) { return INTVAL(t); } else { bpx_raise("integer expected"); } return 0; /* should not be reached */ }
TERM bpx_get_cdr(TERM t) { XDEREF(t); if (ISLIST(t)) { return GET_CDR(t); } else { bpx_raise("list expected"); } return NULL_TERM; /* should not be reached */ }
double bpx_get_float(TERM t) { XDEREF(t); if (ISINT(t)) { return (double)(INTVAL(t)); } else if (ISFLOAT(t)) { return floatval(t); } else { bpx_raise("integer or floating number expected"); } return 0.0; /* should not be reached */ }
const char * bpx_get_name(TERM t) { XDEREF(t); switch (XTAG(t)) { case STR: return GET_NAME(GET_STR_SYM_REC(t)); case ATM: return GET_NAME(GET_ATM_SYM_REC(t)); case LST: return "."; default: bpx_raise("callable expected"); } return NULL; /* should not be reached */ }
int bpx_get_arity(TERM t) { XDEREF(t); switch (XTAG(t)) { case STR: return GET_ARITY(GET_STR_SYM_REC(t)); case ATM: return GET_ARITY(GET_ATM_SYM_REC(t)); case LST: return 2; default: bpx_raise("callable expected"); } return -1; /* should not be reached */ }
TERM bpx_get_arg(BPLONG i, TERM t) { BPLONG n, j; XDEREF(t); switch (XTAG(t)) { case STR: n = GET_ARITY(GET_STR_SYM_REC(t)); j = 0; break; case LST: n = 2; j = 1; break; default: bpx_raise("compound expected"); } if (i < 1 || i > n) { bpx_raise("bad argument index"); } return GET_ARG(t, i - j); }
bool bpx_is_float(TERM t) { XDEREF(t); return ISNUM(t); }
bool bpx_is_integer(TERM t) { XDEREF(t); return ISINT(t); }
bool bpx_is_atom(TERM t) { XDEREF(t); return ISATOM(t); }
bool bpx_is_var(TERM t) { XDEREF(t); return ISREF(t); }
bool bpx_is_identical(TERM t1, TERM t2) { XDEREF(t1); XDEREF(t2); return (bool)(is_IDENTICAL(t1, t2)); }
bool bpx_is_unifiable(TERM t1, TERM t2) { XDEREF(t1); XDEREF(t2); return (bool)(is_UNIFIABLE(t1, t2)); }
bool bpx_is_compound(TERM t) { XDEREF(t); return ISCOMPOUND(t); }
bool bpx_is_nil(TERM t) { XDEREF(t); return ISNIL(t); }
void bpx_write(TERM t) { XDEREF(t); write_term(t); }
int bpx_mount_query_term(TERM t) { XDEREF(t); return bp_mount_query_term(t); }
int bpx_call_term(TERM t) { XDEREF(t); return bp_call_term(t); }
char * bpx_term_2_string(TERM t) { XDEREF(t); return bp_term_2_string(t); }
bool bpx_is_list(TERM t) { XDEREF(t); return ISLIST(t); }
bool bpx_is_structure(TERM t) { XDEREF(t); return ISSTRUCT(t); }