diff --git a/os2.rkt b/os2.rkt index e19f54a..da9876c 100644 --- a/os2.rkt +++ b/os2.rkt @@ -402,9 +402,31 @@ (struct-copy process old-process [state new-state]))])) +(define (preaction? a) + (or (add-role? a) + (delete-role? a) + (send-message? a) + (spawn? a) + (kill? a))) + +(define (action? a) + (or (preaction? a) + (and (at-meta-level? a) + (preaction? (at-meta-level-preaction a))))) + +(define (valid-action? pid a) + (cond + [(action? a)] + [(eq? a #f) #f] ;; skip falses in action ConsTrees + [(void? a) #f] ;; skip voids in action ConsTrees + [else (log-warning (format "Illegal action ~v from pid ~v" a pid)) + #f])) + (define (enqueue-actions state pid actions) (struct-copy vm state - [pending-actions (append (reverse (for/list ([a (flatten actions)]) (cons pid a))) + [pending-actions (append (reverse (for/list ([a (flatten actions)] + #:when (valid-action? pid a)) + (cons pid a))) (vm-pending-actions state))])) (define (((wrap-trapk pid trapk) . args) state)