From 6e516789d5c8f9072347c846fd1e8ea8cbd75924 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Feb 2010 13:41:33 +1300 Subject: [PATCH] continuations: add a throw-continue word for resumable errors, and change vocabs.metadata to throw a resumable error if the current platform is not supported --- basis/vocabs/metadata/metadata.factor | 17 +++++++++++------ core/compiler/units/units.factor | 3 +-- core/continuations/continuations-docs.factor | 12 ++++++++++-- core/continuations/continuations.factor | 3 +++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/basis/vocabs/metadata/metadata.factor b/basis/vocabs/metadata/metadata.factor index 10e4eac2a2..09ca012fcc 100644 --- a/basis/vocabs/metadata/metadata.factor +++ b/basis/vocabs/metadata/metadata.factor @@ -100,19 +100,24 @@ ERROR: bad-platform name ; [ [ name>> ] map ] dip dup vocab-platforms-path set-vocab-file-contents ; -: supported-platform? ( vocab -- ? ) - vocab-platforms [ t ] [ [ os swap class<= ] any? ] if-empty ; +: supported-platform? ( platforms -- ? ) + [ t ] [ [ os swap class<= ] any? ] if-empty ; : unportable? ( vocab -- ? ) { [ vocab-tags "untested" swap member? ] - [ supported-platform? not ] + [ vocab-platforms supported-platform? not ] } 1|| ; -ERROR: unsupported-platform vocab ; +TUPLE: unsupported-platform vocab requires ; + +: unsupported-platform ( vocab requires -- ) + \ unsupported-platform boa throw-continue ; M: unsupported-platform summary drop "Current operating system not supported by this vocabulary" ; -[ dup supported-platform? [ drop ] [ vocab-name unsupported-platform ] if ] -check-vocab-hook set-global +[ + dup vocab-platforms dup supported-platform? + [ 2drop ] [ [ vocab-name ] dip unsupported-platform ] if +] check-vocab-hook set-global diff --git a/core/compiler/units/units.factor b/core/compiler/units/units.factor index 9582ebadb6..b024ed2c65 100644 --- a/core/compiler/units/units.factor +++ b/core/compiler/units/units.factor @@ -12,8 +12,7 @@ SYMBOL: new-definitions TUPLE: redefine-error def ; : redefine-error ( definition -- ) - \ redefine-error boa - { { "Continue" t } } throw-restarts drop ; + \ redefine-error boa throw-continue ; condition ( error restarts cc -- condition ) : rethrow-restarts ( error restarts -- restart ) [ rethrow ] callcc1 2nip ; +: throw-continue ( error -- ) + { { "Continue" t } } throw-restarts drop ; + TUPLE: restart name obj continuation ; C: restart