removed experimental code on error exceptionization.

made the sp method of the Process class a primitive method for accuracy
fixed omission of some fields when initializing a nil_process.
wrote a macro to inspect a receiver and changed the receiver inspect code to use the macro
corrected the order between return value setting and process suspension/temrination/activation in some primitive functions
This commit is contained in:
hyunghwan.chung
2017-09-25 15:16:19 +00:00
parent ce72ffa193
commit 7ee4453bf3
6 changed files with 202 additions and 270 deletions

View File

@ -289,15 +289,6 @@ extend Apex
self primitiveFailed
}
## -------------------------------------------------------
## -------------------------------------------------------
method exceptionizeError: trueOrFalse
{
<primitive: #_exceptionize_error>
self class cannotExceptionizeError
}
(* ------------------------------------------------------------------
* COMMON ERROR/EXCEPTION HANDLERS
* ------------------------------------------------------------------ *)

View File

@ -507,10 +507,4 @@ extend Apex
class_name := if (self class == Class) { self name } else { self class name }.
ProhibitedMessageException signal: (method_name & ' not allowed for ' & class_name).
}
method(#dual) cannotExceptionizeError
{
## todo: accept the object
ErrorExceptionizationFailureException signal: 'Cannot exceptionize an error'
}
}

View File

@ -2,16 +2,19 @@
class(#pointer,#final,#limited) Process(Object)
{
var(#get) initialContext, currentContext, id, state.
var(#get) sp, ps_prev, ps_next, sem_wait_prev, sem_wait_next.
var sp.
var(#get) ps_prev, ps_next, sem_wait_prev, sem_wait_next.
var sem, perr, perrmsg.
method primError { ^self.perr }
method primErrorMessage { ^self.perrmsg }
method(#primitive) sp.
method(#primitive) resume.
method(#primitive) yield.
method(#primitive) suspend.
method(#primitive) _terminate.
method(#primitive) _suspend.
method terminate
{
@ -38,8 +41,8 @@ class(#pointer,#final,#limited) Process(Object)
## the process must not be scheduled.
## ----------------------------------------------------------------------------------------------------------
##if (Processor activeProcess ~~ self) { self _suspend }.
if (thisProcess ~~ self) { self _suspend }.
##if (Processor activeProcess ~~ self) { self suspend }.
if (thisProcess ~~ self) { self suspend }.
self.currentContext unwindTo: self.initialContext return: nil.
^self _terminate
}
@ -191,6 +194,7 @@ class SemaphoreGroup(Object)
size := 0,
pos := 0,
semarr := nil.
var(#get,#set) signaledSemaphore := nil.
(* TODO: good idea to a shortcut way to prohibit a certain method in the heirarchy chain?
@ -204,7 +208,7 @@ method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibilit
method(#class,#variadic) with()
{
| i x arr |
| i x arr sem |
i := 0.
x := thisContext vargCount.
@ -212,7 +216,13 @@ method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibilit
arr := Array new: x.
while (i < x)
{
arr at: i put: (thisContext vargAt: i).
sem := thisContext vargAt: i.
if (sem _group notNil)
{
System.Exception signal: 'Cannot add a semaphore in a group to another group'
}.
arr at: i put: sem.
i := i + 1.
}.
@ -514,7 +524,7 @@ class(#final,#limited) ProcessScheduler(Object)
## -----------------------------------------------------
| s |
s := Semaphore new.
self signal: s after: secs and: nanosecs
self signal: s after: secs and: nanosecs.
s wait.
}
}