From 6d3aa439c22331ead38841eb027ffa3c658a3ca2 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 9 Oct 2007 17:35:09 -0400 Subject: [PATCH] forget-all word --- core/definitions/definitions-tests.factor | 39 +++++++++++++++++++++++ core/definitions/definitions.factor | 2 ++ core/generic/generic.factor | 2 +- core/parser/parser.factor | 2 +- core/prettyprint/prettyprint.factor | 3 -- core/source-files/source-files.factor | 2 +- core/words/words.factor | 9 +++--- 7 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 core/definitions/definitions-tests.factor diff --git a/core/definitions/definitions-tests.factor b/core/definitions/definitions-tests.factor new file mode 100644 index 0000000000..14d1c03be3 --- /dev/null +++ b/core/definitions/definitions-tests.factor @@ -0,0 +1,39 @@ +IN: temporary +USING: tools.test generic kernel definitions sequences ; + +TUPLE: combination-1 ; + +M: combination-1 perform-combination 2drop { } [ ] each [ ] ; + +SYMBOL: generic-1 + +generic-1 T{ combination-1 } define-generic + +[ ] object \ generic-1 define-method + +[ ] [ { combination-1 { object generic-1 } } forget-all ] unit-test + +GENERIC: some-generic + +USE: arrays + +M: array some-generic ; + +USE: bit-arrays + +M: bit-array some-generic ; + +USE: byte-arrays + +M: byte-array some-generic ; + +TUPLE: some-class ; + +M: some-class some-generic ; + +TUPLE: another-class some-generic ; + +[ ] [ + { some-generic some-class { another-class some-generic } } + forget-all +] unit-test diff --git a/core/definitions/definitions.factor b/core/definitions/definitions.factor index 9d31c8d87d..c9213c137b 100644 --- a/core/definitions/definitions.factor +++ b/core/definitions/definitions.factor @@ -13,6 +13,8 @@ GENERIC: forget ( defspec -- ) M: object forget drop ; +: forget-all ( definitions -- ) [ forget ] each ; + GENERIC: synopsis* ( defspec -- ) GENERIC: definer ( defspec -- start end ) diff --git a/core/generic/generic.factor b/core/generic/generic.factor index 0de8bd42d2..018e8afd35 100644 --- a/core/generic/generic.factor +++ b/core/generic/generic.factor @@ -94,7 +94,7 @@ M: method-spec forget first2 [ delete-at ] with-methods ; dup associate implementors* ; : forget-methods ( class -- ) - [ implementors ] keep [ swap 2array forget ] curry each ; + [ implementors ] keep [ swap 2array ] curry map forget-all ; M: class forget ( class -- ) dup forget-methods diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 0eb4d3162c..235d0e935a 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -416,7 +416,7 @@ SYMBOL: parse-hook ] keep ; : forget-smudged ( -- ) - smudged-usage [ forget ] each + smudged-usage forget-all over empty? [ 2dup smudged-usage-warning ] unless 2drop ; : record-definitions ( file -- ) diff --git a/core/prettyprint/prettyprint.factor b/core/prettyprint/prettyprint.factor index 01cff3b7b3..b763c06a9a 100644 --- a/core/prettyprint/prettyprint.factor +++ b/core/prettyprint/prettyprint.factor @@ -159,9 +159,6 @@ GENERIC: see ( defspec -- ) M: word synopsis* dup word-synopsis ; -M: simple-generic synopsis* - dup word-synopsis ; - M: standard-generic synopsis* dup seeing-word \ GENERIC# pprint-word diff --git a/core/source-files/source-files.factor b/core/source-files/source-files.factor index f544a41dcf..57ae7d7a53 100644 --- a/core/source-files/source-files.factor +++ b/core/source-files/source-files.factor @@ -71,7 +71,7 @@ M: pathname where pathname-string 1 2array ; : forget-source ( path -- ) dup source-file dup unxref-source - source-file-definitions [ drop forget ] assoc-each + source-file-definitions keys forget-all source-files get delete-at ; M: pathname forget pathname-string forget-source ; diff --git a/core/words/words.factor b/core/words/words.factor index 342b20508c..93c08ff435 100644 --- a/core/words/words.factor +++ b/core/words/words.factor @@ -6,14 +6,14 @@ slots.private math namespaces sequences strings vectors sbufs quotations assocs hashtables sorting math.parser words.private vocabs ; -GENERIC: execute ( word -- ) - -M: word execute (execute) ; - : word ( -- word ) \ word get-global ; : set-word ( word -- ) \ word set-global ; +GENERIC: execute ( word -- ) + +M: word execute (execute) ; + ! Used by the compiler SYMBOL: changed-words @@ -201,7 +201,6 @@ M: word (forget-word) reveal ; : forget-word ( word -- ) - dup f "methods" set-word-prop dup delete-xref dup unchanged-word (forget-word) ;