fix compiler bug in 1 << X, found by Nuno Fonseca.
compiler internal errors get their own message. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1291 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
f78cc61bc8
commit
b2dfcf33a1
43
C/amasm.c
43
C/amasm.c
@ -11,8 +11,11 @@
|
||||
* File: amasm.c *
|
||||
* comments: abstract machine assembler *
|
||||
* *
|
||||
* Last rev: $Date: 2005-04-10 04:01:09 $ *
|
||||
* Last rev: $Date: 2005-05-25 21:43:32 $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.73 2005/04/10 04:01:09 vsc
|
||||
* bug fixes, I hope!
|
||||
*
|
||||
* Revision 1.72 2005/03/04 20:30:10 ricroc
|
||||
* bug fixes for YapTab support
|
||||
*
|
||||
@ -909,7 +912,7 @@ a_p(op_numbers opcode, clause_info *clinfo, yamop *code_p, int pass_no, struct i
|
||||
break;
|
||||
default:
|
||||
op = _p_equal; /* just to make some compilers happy */
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "internal assembler error for built-in (%d)", (Flags & 0x7f));
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "internal assembler error for built-in (%d)", (Flags & 0x7f));
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
}
|
||||
@ -920,7 +923,7 @@ a_p(op_numbers opcode, clause_info *clinfo, yamop *code_p, int pass_no, struct i
|
||||
if (clinfo->commit_lab && (Flags & TestPredFlag)) {
|
||||
if (pass_no) {
|
||||
if (Flags & UserCPredFlag) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil,
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil,
|
||||
"user defined predicate cannot be a test predicate");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
@ -1082,7 +1085,7 @@ compile_cmp_flags(char *s)
|
||||
return(EQ_OK_IN_CMP);
|
||||
if (strcmp(s,"=\\=") == 0)
|
||||
return(GT_OK_IN_CMP|LT_OK_IN_CMP);
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "internal assembler error in flags for %s", s);
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "internal assembler error in flags for %s", s);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -2035,7 +2038,7 @@ a_f2(int var, cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermed
|
||||
if (pass_no) {
|
||||
switch (opc) {
|
||||
case _plus:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x1_arg, "internal assembler error CX for +/2");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for +/2 (should be XC)");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
@ -2043,7 +2046,7 @@ a_f2(int var, cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermed
|
||||
code_p->opc = emit_op(_p_minus_y_cv);
|
||||
break;
|
||||
case _times:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x1_arg, "internal assembler error CX for */2");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for */2 (should be XC)");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
@ -2051,24 +2054,20 @@ a_f2(int var, cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermed
|
||||
code_p->opc = emit_op(_p_div_y_cv);
|
||||
break;
|
||||
case _and:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x1_arg, "internal assembler error CX for /\\/2");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for /\\/2 (should be XC)");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _or:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x1_arg, "internal assembler error CX for \\//2");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for \\//2 (should be XC)");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _sll:
|
||||
code_p->opc = emit_op(_p_sll_y_cv);
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _slr:
|
||||
code_p->opc = emit_op(_p_slr_y_cv);
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _arg:
|
||||
code_p->opc = emit_op(_p_arg_y_cv);
|
||||
@ -2090,7 +2089,7 @@ a_f2(int var, cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermed
|
||||
code_p->opc = emit_op(_p_plus_y_vc);
|
||||
break;
|
||||
case _minus:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x2_arg, "internal assembler error XC for -/2");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error XC for -/2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
@ -2113,7 +2112,7 @@ a_f2(int var, cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermed
|
||||
code_p->opc = emit_op(_p_slr_y_vc);
|
||||
break;
|
||||
case _arg:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x2_arg, "internal assembler error for arg/3");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error for arg/3");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
@ -2174,7 +2173,7 @@ a_f2(int var, cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermed
|
||||
if (pass_no) {
|
||||
switch (opc) {
|
||||
case _plus:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x1_arg, "internal assembler error CX for +/2");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for +/2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
@ -2182,7 +2181,7 @@ a_f2(int var, cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermed
|
||||
code_p->opc = emit_op(_p_minus_cv);
|
||||
break;
|
||||
case _times:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x1_arg, "internal assembler error CX for */2");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for */2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
@ -2190,12 +2189,12 @@ a_f2(int var, cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermed
|
||||
code_p->opc = emit_op(_p_div_cv);
|
||||
break;
|
||||
case _and:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x1_arg, "internal assembler error CX for /\\/2");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for /\\/2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
case _or:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x1_arg, "internal assembler error CX for \\//2");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x1_arg, "internal assembler error CX for \\//2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
@ -2225,7 +2224,7 @@ a_f2(int var, cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermed
|
||||
code_p->opc = emit_op(_p_plus_vc);
|
||||
break;
|
||||
case _minus:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x2_arg, "internal assembler error XC for -/2");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error XC for -/2");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
@ -2248,7 +2247,7 @@ a_f2(int var, cmp_op_info *cmp_info, yamop *code_p, int pass_no, struct intermed
|
||||
code_p->opc = emit_op(_p_slr_vc);
|
||||
break;
|
||||
case _arg:
|
||||
Yap_Error(SYSTEM_ERROR, cmp_info->x2_arg, "internal assembler error for arg/3");
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, cmp_info->x2_arg, "internal assembler error for arg/3");
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
break;
|
||||
@ -2922,7 +2921,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
break;
|
||||
case fetch_args_for_bccall:
|
||||
if (cip->cpc->nextInst->op != bccall_op) {
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "compiling binary test", (int) cip->cpc->op);
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "compiling binary test", (int) cip->cpc->op);
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
}
|
||||
@ -2954,7 +2953,7 @@ do_pass(int pass_no, yamop **entry_codep, int assembling, int *clause_has_blobsp
|
||||
case name_op:
|
||||
break;
|
||||
default:
|
||||
Yap_Error(SYSTEM_ERROR, TermNil, "instruction %d found while assembling", (int) cip->cpc->op);
|
||||
Yap_Error(INTERNAL_COMPILER_ERROR, TermNil, "instruction %d found while assembling", (int) cip->cpc->op);
|
||||
save_machine_regs();
|
||||
longjmp(cip->CompilerBotch, 1);
|
||||
}
|
||||
|
26
C/compiler.c
26
C/compiler.c
@ -11,8 +11,12 @@
|
||||
* File: compiler.c *
|
||||
* comments: Clause compiler *
|
||||
* *
|
||||
* Last rev: $Date: 2005-05-12 03:36:32 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2005-05-25 21:43:32 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.66 2005/05/12 03:36:32 vsc
|
||||
* debugger was making predicates meta instead of testing
|
||||
* fix handling of dbrefs in facts and in subarguments.
|
||||
*
|
||||
* Revision 1.65 2005/04/10 04:01:10 vsc
|
||||
* bug fixes, I hope!
|
||||
*
|
||||
@ -458,7 +462,7 @@ compile_sf_term(Term t, int argno, int level)
|
||||
if (IsAtomicTerm(t))
|
||||
Yap_emit((cglobs->onhead ? unify_s_a_op : write_s_a_op), t, (CELL) argno, &cglobs->cint);
|
||||
else if (!IsVarTerm(t)) {
|
||||
Yap_Error_TYPE = SYSTEM_ERROR;
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "illegal argument of soft functor";
|
||||
save_machine_regs();
|
||||
@ -485,7 +489,7 @@ c_args(Term app, unsigned int level, compiler_struct *cglobs)
|
||||
|
||||
if (level == 0) {
|
||||
if (Arity >= MaxTemps) {
|
||||
Yap_Error_TYPE = SYSTEM_ERROR;
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "exceed maximum arity of compiled goal";
|
||||
save_machine_regs();
|
||||
@ -1961,7 +1965,7 @@ clear_bvarray(int var, CELL *bvarray
|
||||
#ifdef DEBUG
|
||||
if (*bvarray & nbit) {
|
||||
/* someone had already marked this variable: complain */
|
||||
Yap_Error_TYPE = SYSTEM_ERROR;
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "compiler internal error: variable initialised twice";
|
||||
save_machine_regs();
|
||||
@ -2002,7 +2006,7 @@ static void
|
||||
push_bvmap(int label, PInstr *pcpc, compiler_struct *cglobs)
|
||||
{
|
||||
if (bvindex == MAX_DISJUNCTIONS) {
|
||||
Yap_Error_TYPE = SYSTEM_ERROR;
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "Too many embedded disjunctions";
|
||||
save_machine_regs();
|
||||
@ -2025,7 +2029,7 @@ reset_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
||||
if (bvarray == NULL)
|
||||
|
||||
if (bvindex == 0) {
|
||||
Yap_Error_TYPE = SYSTEM_ERROR;
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "No embedding in disjunctions";
|
||||
save_machine_regs();
|
||||
@ -2045,7 +2049,7 @@ static void
|
||||
pop_bvmap(CELL *bvarray, int nperm, compiler_struct *cglobs)
|
||||
{
|
||||
if (bvindex == 0) {
|
||||
Yap_Error_TYPE = SYSTEM_ERROR;
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "Too few embedded disjunctions";
|
||||
/* save_machine_regs();
|
||||
@ -2312,7 +2316,7 @@ checktemp(Int arg, Int rn, compiler_vm_op ic, compiler_struct *cglobs)
|
||||
++target1;
|
||||
}
|
||||
if (target1 == cglobs->MaxCTemps) {
|
||||
Yap_Error_TYPE = SYSTEM_ERROR;
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "too many temporaries";
|
||||
save_machine_regs();
|
||||
@ -2432,7 +2436,7 @@ c_layout(compiler_struct *cglobs)
|
||||
CheckUnsafe(cglobs->cint.CodeStart, cglobs);
|
||||
#ifdef DEBUG
|
||||
if (cglobs->pbvars != nperm) {
|
||||
Yap_Error_TYPE = SYSTEM_ERROR;
|
||||
Yap_Error_TYPE = INTERNAL_COMPILER_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
Yap_ErrorMessage = "wrong number of variables found in bitmap";
|
||||
save_machine_regs();
|
||||
@ -2866,10 +2870,10 @@ Yap_cclause(volatile Term inp_clause, int NOfArgs, int mod, volatile Term src)
|
||||
reset_vars(cglobs.vtable);
|
||||
Yap_Error_TYPE = OUT_OF_HEAP_ERROR;
|
||||
Yap_Error_Term = TermNil;
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
my_clause = inp_clause;
|
||||
if (Yap_ErrorMessage != NULL) {
|
||||
if (Yap_ErrorMessage) {
|
||||
reset_vars(cglobs.vtable);
|
||||
return (0);
|
||||
}
|
||||
|
12
C/errors.c
12
C/errors.c
@ -1327,6 +1327,18 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
serious = TRUE;
|
||||
}
|
||||
break;
|
||||
case INTERNAL_COMPILER_ERROR:
|
||||
{
|
||||
int i;
|
||||
|
||||
i = strlen(tmpbuf);
|
||||
nt[0] = MkAtomTerm(Yap_LookupAtom("internal_compiler_error"));
|
||||
tp = tmpbuf+i;
|
||||
psize -= i;
|
||||
fun = Yap_MkFunctor(Yap_LookupAtom("error"),2);
|
||||
serious = TRUE;
|
||||
}
|
||||
break;
|
||||
case TYPE_ERROR_ARRAY:
|
||||
{
|
||||
int i;
|
||||
|
@ -10,7 +10,7 @@
|
||||
* File: Yap.h.m4 *
|
||||
* mods: *
|
||||
* comments: main header file for YAP *
|
||||
* version: $Id: Yap.h.m4,v 1.82 2005-04-07 17:56:00 ricroc Exp $ *
|
||||
* version: $Id: Yap.h.m4,v 1.83 2005-05-25 21:43:33 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
@ -417,6 +417,7 @@ typedef enum {
|
||||
YAP_NO_ERROR,
|
||||
FATAL_ERROR,
|
||||
INTERNAL_ERROR,
|
||||
INTERNAL_COMPILER_ERROR,
|
||||
PURE_ABORT,
|
||||
CALL_COUNTER_UNDERFLOW,
|
||||
/* ISO_ERRORS */
|
||||
|
@ -11,8 +11,13 @@
|
||||
* File: errors.yap *
|
||||
* comments: error messages for YAP *
|
||||
* *
|
||||
* Last rev: $Date: 2005-05-25 18:18:02 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2005-05-25 21:43:33 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.64 2005/05/25 18:18:02 vsc
|
||||
* fix error handling
|
||||
* configure should not allow max-memory and use-malloc at same time
|
||||
* some extensions for jpl
|
||||
*
|
||||
* Revision 1.63 2005/04/20 20:06:26 vsc
|
||||
* try to improve error handling and warnings from within consults.
|
||||
*
|
||||
@ -669,6 +674,9 @@ print_message(Level, Mss) :-
|
||||
'$output_error_message'(system_error, Where) :-
|
||||
format(user_error,'% SYSTEM ERROR- ~w~n',
|
||||
[Where]).
|
||||
'$output_error_message'(internal_compiler_error, Where) :-
|
||||
format(user_error,'% INTERNAL COMPILER ERROR- ~w~n',
|
||||
[Where]).
|
||||
'$output_error_message'(system_error(Message), Where) :-
|
||||
format(user_error,'% SYSTEM ERROR- ~w at ~w]~n',
|
||||
[Message,Where]).
|
||||
|
Reference in New Issue
Block a user