From 9c84fe7018e3a119a871ef9a8cc8dfd89f8c5302 Mon Sep 17 00:00:00 2001 From: slava Date: Tue, 1 Aug 2006 01:30:06 +0000 Subject: [PATCH] Split describe.factor up --- library/bootstrap/boot-stage1.factor | 2 ++ library/math/complex.factor | 6 ++-- library/math/complex.facts | 4 --- library/tools/describe.factor | 46 ---------------------------- library/tools/describe.facts | 4 --- library/tools/summary.factor | 29 ++++++++++++++++++ library/tools/summary.facts | 6 ++++ 7 files changed, 39 insertions(+), 58 deletions(-) create mode 100644 library/tools/summary.factor create mode 100644 library/tools/summary.facts diff --git a/library/bootstrap/boot-stage1.factor b/library/bootstrap/boot-stage1.factor index d724952f15..0de09bf355 100644 --- a/library/bootstrap/boot-stage1.factor +++ b/library/bootstrap/boot-stage1.factor @@ -94,6 +94,7 @@ sequences vectors words ; "/library/syntax/see.factor" "/library/syntax/parser.factor" + "/library/tools/summary.factor" "/library/tools/describe.factor" "/library/tools/debugger.factor" @@ -292,6 +293,7 @@ sequences vectors words ; "/library/test/test.facts" "/library/tools/word-tools.facts" "/library/tools/debugger.facts" + "/library/tools/summary.facts" "/library/tools/describe.facts" "/library/tools/inspector.facts" "/library/tools/listener.facts" diff --git a/library/math/complex.factor b/library/math/complex.factor index 0166d64db2..b642d56ddf 100644 --- a/library/math/complex.factor +++ b/library/math/complex.factor @@ -1,5 +1,5 @@ -! Copyright (C) 2004, 2005 Slava Pestov. -! See http://factor.sf.net/license.txt for BSD license. +! Copyright (C) 2006 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. IN: math-internals USING: errors generic kernel kernel-internals math ; @@ -35,8 +35,6 @@ M: number = ( n n -- ? ) number= ; : polar> ( abs arg -- z ) cis * ; inline -: quadrant ( z -- n ) >rect >r 0 >= 0 1 ? r> 0 >= 0 3 ? bitxor ; - M: complex absq >rect [ sq ] 2apply + ; IN: math-internals diff --git a/library/math/complex.facts b/library/math/complex.facts index 60bb7a236f..811120b17e 100644 --- a/library/math/complex.facts +++ b/library/math/complex.facts @@ -49,10 +49,6 @@ HELP: polar> "( abs arg -- z )" { $values { "z" "a complex number" } { "abs" "a non-negative real number" } { "arg" "a real number" } } { $description "Converts an absolute value and argument (polar form) to a complex number." } ; -HELP: quadrant "( z -- n )" -{ $values { "z" "a complex number" } { "n" "0, 1, 2, or 3" } } -{ $description "If the imaginary axis runs from bottom to top and the real axis runs from left to right, the quadrants of the complex plane run anti-clockwise starting from the positive real axis:" { $code "1|0" "---" "2|3" } } ; - HELP: 2>rect "( x y -- xr xi yr yi )" { $values { "x" "a complex number" } { "y" "a complex number" } { "xr" "real part of " { $snippet "x" } } { "xi" "imaginary part of " { $snippet "x" } } { "yr" "real part of " { $snippet "y" } } { "yi" "imaginary part of " { $snippet "y" } } } { $description "Extracts real and imaginary components of two numbers at once." } ; diff --git a/library/tools/describe.factor b/library/tools/describe.factor index ec3c4bef70..5b0520b159 100644 --- a/library/tools/describe.factor +++ b/library/tools/describe.factor @@ -5,31 +5,8 @@ USING: arrays generic hashtables io kernel kernel-internals math namespaces prettyprint sequences strings styles vectors words ; -GENERIC: summary ( object -- string ) - -: sign-string ( n -- string ) - 0 > "a positive " "a negative " ? ; - -M: integer summary - dup zero? [ - "a " "zero " - ] [ - dup sign-string over 2 mod zero? "even " "odd " ? - ] if rot class word-name append3 ; - -M: real summary - dup sign-string swap class word-name append ; - -M: complex summary - "a complex number in the " - swap quadrant { "first" "second" "fourth" "third" } nth - " quadrant" append3 ; - GENERIC: sheet ( obj -- sheet ) -M: object summary - "an instance of the " swap class word-name " class" append3 ; - : slot-sheet ( obj -- sheet ) dup class "slots" word-prop dup [ third ] map -rot @@ -53,29 +30,6 @@ M: hashtable summary M: hashtable sheet hash>alist flip ; -M: word summary ( word -- ) - dup word-vocabulary [ - dup interned? - "a word in the " "a word orphaned from the " ? - swap word-vocabulary " vocabulary" append3 - ] [ - drop "a uniquely generated symbol" - ] if ; - -M: input summary ( input -- ) - "Input: " swap input-string - dup string? [ unparse-short ] unless append ; - -M: vocab-link summary ( vocab-link -- ) - [ - vocab-link-name dup % - " vocabulary (" % - words length # - " words)" % - ] "" make ; - -DEFER: describe - : sheet. ( sheet -- ) flip dup empty? [ drop diff --git a/library/tools/describe.facts b/library/tools/describe.facts index 92b9cf150d..ab28ff4e0f 100644 --- a/library/tools/describe.facts +++ b/library/tools/describe.facts @@ -1,10 +1,6 @@ IN: inspector USING: help io kernel prettyprint words ; -HELP: summary "( object -- string )" -{ $values { "object" "an object" } { "string" "a string" } } -{ $contract "Outputs a brief description of the object." } ; - HELP: sheet "( object -- sheet )" { $values { "object" "an object" } { "sheet" "a sequence of sequences" } } { $contract "Outputs a representation of the object for the " { $link describe } " word, which is a table where each row corresponds to an object slot, and consists of a number of columns, presumably including the slot name and value." } ; diff --git a/library/tools/summary.factor b/library/tools/summary.factor new file mode 100644 index 0000000000..717fd9a429 --- /dev/null +++ b/library/tools/summary.factor @@ -0,0 +1,29 @@ +! Copyright (C) 2005, 2006 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +IN: inspector + +GENERIC: summary ( object -- string ) + +M: object summary + "an instance of the " swap class word-name " class" append3 ; + +M: word summary ( word -- ) + dup word-vocabulary [ + dup interned? + "a word in the " "a word orphaned from the " ? + swap word-vocabulary " vocabulary" append3 + ] [ + drop "a uniquely generated symbol" + ] if ; + +M: input summary ( input -- ) + "Input: " swap input-string + dup string? [ unparse-short ] unless append ; + +M: vocab-link summary ( vocab-link -- ) + [ + vocab-link-name dup % + " vocabulary (" % + words length # + " words)" % + ] "" make ; diff --git a/library/tools/summary.facts b/library/tools/summary.facts new file mode 100644 index 0000000000..eeae5bf4a0 --- /dev/null +++ b/library/tools/summary.facts @@ -0,0 +1,6 @@ +IN: inspector +USING: help ; + +HELP: summary "( object -- string )" +{ $values { "object" "an object" } { "string" "a string" } } +{ $contract "Outputs a brief description of the object." } ;