[Commit]
nickle debug.c,1.31,1.32 error.c,1.18,1.19 execute.c,1.78,1.79
ref.c,1.16,1.17 sched.c,1.48,1.49 value.c,1.41,1.42
value.h,1.84,1.85
Keith Packard
commit at keithp.com
Tue Jun 3 00:03:59 PDT 2003
Committed by: keithp
Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv12660
Modified Files:
debug.c error.c execute.c ref.c sched.c value.c value.h
Log Message:
Eliminate remaining RaiseError calls. Make unhandled exceptions get a continuation to the crash through to the debugger with a magic stack push/pop
Index: debug.c
===================================================================
RCS file: /local/src/CVS/nickle/debug.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- debug.c 4 Nov 2002 09:47:43 -0000 1.31
+++ debug.c 3 Jun 2003 06:03:56 -0000 1.32
@@ -77,7 +77,7 @@
FramePtr frame = continuation->continuation.frame;
ObjPtr obj = continuation->continuation.obj;
InstPtr pc = continuation->continuation.pc;
- ExprPtr stat = ObjStatement (obj, pc);
+ ExprPtr stat = obj ? ObjStatement (obj, pc) : 0;
NamespacePtr namespace;
int n = offset;
Bool ret;
Index: error.c
===================================================================
RCS file: /local/src/CVS/nickle/error.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- error.c 15 Mar 2001 18:22:23 -0000 1.18
+++ error.c 3 Jun 2003 06:03:56 -0000 1.19
@@ -20,15 +20,3 @@
FileVPrintf (FileStderr, s, args);
va_end (args);
}
-
-void
-RaiseError (char *s, ...)
-{
- va_list args;
-
- va_start (args, s);
- FileVPrintf (FileStderr, s, args);
- va_end (args);
- FilePrintf (FileStderr, "\n");
- SetSignalError ();
-}
Index: execute.c
===================================================================
RCS file: /local/src/CVS/nickle/execute.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- execute.c 30 May 2003 06:18:51 -0000 1.78
+++ execute.c 3 Jun 2003 06:03:56 -0000 1.79
@@ -1001,7 +1001,9 @@
case OpReturn:
if (!thread->thread.continuation.frame)
{
- RaiseError ("return outside of function");
+ RaiseStandardException (exception_invalid_argument,
+ "return outside of function",
+ 2, Void, Void);
break;
}
if (!TypeCompatibleAssign (thread->thread.continuation.frame->function->func.code->base.type,
@@ -1177,7 +1179,9 @@
case OpStaticDone:
if (!thread->thread.continuation.frame)
{
- RaiseError ("StaticInitDone outside of function");
+ RaiseStandardException (exception_invalid_argument,
+ "StaticInitDone outside of function",
+ 2, Void, Void);
break;
}
if (aborting)
@@ -1323,8 +1327,6 @@
if (signalError)
{
signalError = False;
- DebugStart (NewContinuation (&thread->thread.continuation,
- inst));
ThreadFinish (thread);
}
if (signalProfile)
Index: ref.c
===================================================================
RCS file: /local/src/CVS/nickle/ref.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- ref.c 17 Mar 2003 20:32:56 -0000 1.16
+++ ref.c 3 Jun 2003 06:03:56 -0000 1.17
@@ -73,7 +73,9 @@
bref = &bv->ref;
if (ref->box != bref->box)
{
- RaiseError ("Attempt to subtract references to different objects %v - %v", av, bv);
+ RaiseStandardException (exception_invalid_binop_values,
+ "References to different objects are unordered",
+ 2, av, bv);
RETURN (Void);
}
RETURN (NewInt (ref->element - bref->element));
@@ -97,8 +99,9 @@
if (aref->box != bref->box ||
(!aref->box->homogeneous && aref->element != bref->element))
{
- RaiseError ("Attempt to order references to different objects %v < %v",
- av, bv);
+ RaiseStandardException (exception_invalid_binop_values,
+ "References to different objects are unordered",
+ 2, av, bv);
return FalseVal;
}
if (aref->element < bref->element)
Index: sched.c
===================================================================
RCS file: /local/src/CVS/nickle/sched.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- sched.c 30 May 2003 06:18:51 -0000 1.48
+++ sched.c 3 Jun 2003 06:03:56 -0000 1.49
@@ -167,7 +167,9 @@
ENTER ();
if (!ValueIsThread(target))
{
- RaiseError ("Join needs thread argument");
+ RaiseStandardException (exception_invalid_argument,
+ "Thread::join needs thread argument",
+ 2, target, Void);
RETURN (Void);
}
if ((target->thread.state & ThreadFinished) == 0)
@@ -257,7 +259,9 @@
int i;
if (!ValueIsThread(thread))
{
- RaiseError ("SetPriority: %v not a thread", thread);
+ RaiseStandardException (exception_invalid_argument,
+ "Thread::set_priority: not a thread",
+ 2, thread, priority);
RETURN (Void);
}
i = IntPart (priority, "Invalid thread priority");
@@ -278,7 +282,9 @@
ENTER ();
if (!ValueIsThread(thread))
{
- RaiseError ("GetPriority: %v not a thread", thread);
+ RaiseStandardException (exception_invalid_argument,
+ "Thread::get_priority: not a thread",
+ 2, thread, Void);
RETURN (Void);
}
RETURN (NewInt (thread->thread.priority));
@@ -300,7 +306,9 @@
if (!ValueIsThread(thread))
{
- RaiseError ("Kill: %v not a thread", thread);
+ RaiseStandardException (exception_invalid_argument,
+ "Thread::kill: not a thread",
+ 2, thread, Void);
return 0;
}
if (thread->thread.state & ThreadFinished)
@@ -322,7 +330,9 @@
{
thread = lookupVar (0, "thread");
if (!ValueIsThread(thread))
- RaiseError ("Kill: no default thread");
+ RaiseStandardException (exception_invalid_argument,
+ "Thread::kill: no default thread",
+ 2, thread, Void);
else
ret = KillThread (thread);
}
@@ -402,9 +412,13 @@
break;
default:
if (n == 0)
- RaiseError ("trace: no default continuation");
+ RaiseStandardException (exception_invalid_argument,
+ "Thread::trace: no default continuation",
+ 1, Zero);
else
- RaiseError ("trace: %v neither continuation nor thread", v);
+ RaiseStandardException (exception_invalid_argument,
+ "Thread::trace: neither continuation nor thread",
+ 1, v);
RETURN (Void);
}
TraceFrame (frame, obj, pc);
@@ -758,6 +772,22 @@
}
/*
+ * An unhandled exception will attempt to jump to NULL,
+ * catch that and invoke the debugger. When the exception
+ * was raised, the code carefully pushed a continuation from
+ * the point of the exception to pass to the debugger
+ */
+
+static void
+JumpUnhandledException (Value thread)
+{
+ Value continuation = STACK_POP (thread->thread.continuation.stack);
+
+ DebugStart (continuation);
+ SetSignalError ();
+}
+
+/*
* Figure out where to go next in a longjmp through twixts
*/
Value
@@ -801,7 +831,7 @@
*next = ContinuationSet (&thread->thread.continuation, jump->continuation);
}
if (!*next)
- SetSignalError ();
+ JumpUnhandledException (thread);
RETURN (jump->ret);
}
@@ -873,7 +903,7 @@
else
*next = ContinuationSet (&thread->thread.continuation, continuation);
if (!*next)
- SetSignalError ();
+ JumpUnhandledException (thread);
RETURN (ret);
}
@@ -891,7 +921,9 @@
if (!ValueIsRef(continuation_ref))
{
- RaiseError ("setjump: not a reference %v", continuation_ref);
+ RaiseStandardException (exception_invalid_argument,
+ "setjump: not a reference",
+ 1, continuation_ref);
RETURN (Void);
}
continuation = NewContinuation (&running->thread.continuation,
@@ -916,7 +948,9 @@
RETURN (Void);
if (!ValueIsContinuation(continuation))
{
- RaiseError ("longjump: not a continuation %v", continuation);
+ RaiseStandardException (exception_invalid_argument,
+ "longjmp: non-continuation argument",
+ 1, continuation);
RETURN (Void);
}
RETURN (ContinuationJump (running, &continuation->continuation, ret, next));
@@ -1028,6 +1062,8 @@
PrintError ("\t%v\n", BoxValueGet (args->array.values, i));
}
continuation = EmptyContinuation();
+ STACK_PUSH (continuation->stack,
+ NewContinuation (&thread->thread.continuation, pc));
}
ContinuationJump (thread, continuation, args, next);
EXIT ();
Index: value.c
===================================================================
RCS file: /local/src/CVS/nickle/value.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- value.c 16 Mar 2003 22:49:26 -0000 1.41
+++ value.c 3 Jun 2003 06:03:56 -0000 1.42
@@ -402,7 +402,9 @@
}
break;
default:
- RaiseError ("pow: non-integer power %v", bv);
+ RaiseStandardException (exception_invalid_binop_values,
+ "non-integer pow right operand",
+ 2, av, bv);
result = Void;
break;
}
@@ -415,7 +417,9 @@
ENTER ();
if (!Integralp (ValueTag(av)) || !Integralp (ValueTag(bv)))
{
- RaiseError ("non-integer %v << %v\n", av, bv);
+ RaiseStandardException (exception_invalid_binop_values,
+ "non-integer << operands",
+ 2, av, bv);
RETURN (Void);
}
if (Negativep (bv))
@@ -444,7 +448,9 @@
ENTER ();
if (!Integralp (ValueTag(av)) || !Integralp (ValueTag(bv)))
{
- RaiseError ("non-integer %v >> %v\n", av, bv);
+ RaiseStandardException (exception_invalid_binop_values,
+ "non-integer >> operands",
+ 2, av, bv);
RETURN (Void);
}
if (Negativep (bv))
Index: value.h
===================================================================
RCS file: /local/src/CVS/nickle/value.h,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- value.h 29 May 2003 18:36:35 -0000 1.84
+++ value.h 3 Jun 2003 06:03:56 -0000 1.85
@@ -948,7 +948,6 @@
Value Lxor(Value, Value), Lnot (Value);
Value Popcount(Value);
Bool Print (Value, Value, char format, int base, int width, int prec, int fill);
-void RaiseError (char *s, ...);
void PrintError (char *s, ...);
Value CopyMutable (Value v);
#ifdef HAVE_C_INLINE
More information about the Commit
mailing list