From 6c0986f8b29ffd14e3a8cd15684fc5a3b2e87baf Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 26 Mar 2009 21:27:45 -0500 Subject: [PATCH] Add definition mixin in definitions vocab to replace hard-coded union in ui.tools.operations; add ?execute to kernel to replace dup word? [ execute ] when calls in unicode.breaks and opengl --- basis/help/topics/topics.factor | 4 ++++ basis/math/bitwise/bitwise.factor | 2 +- basis/opengl/opengl.factor | 2 +- basis/ui/tools/operations/operations.factor | 2 -- basis/unicode/breaks/breaks.factor | 2 +- core/definitions/definitions.factor | 2 ++ core/generic/generic.factor | 4 +++- core/kernel/kernel.factor | 4 ++++ core/vocabs/vocabs.factor | 4 +++- core/words/words.factor | 4 ++++ 10 files changed, 23 insertions(+), 7 deletions(-) diff --git a/basis/help/topics/topics.factor b/basis/help/topics/topics.factor index 864b030126..a251849e8f 100644 --- a/basis/help/topics/topics.factor +++ b/basis/help/topics/topics.factor @@ -7,8 +7,12 @@ IN: help.topics TUPLE: link name ; +INSTANCE: link definition + MIXIN: topic + INSTANCE: link topic + INSTANCE: word topic GENERIC: >link ( obj -- obj ) diff --git a/basis/math/bitwise/bitwise.factor b/basis/math/bitwise/bitwise.factor index 4f639c02a7..3148567bc0 100755 --- a/basis/math/bitwise/bitwise.factor +++ b/basis/math/bitwise/bitwise.factor @@ -37,7 +37,7 @@ IN: math.bitwise ! flags MACRO: flags ( values -- ) - [ 0 ] [ [ dup word? [ execute ] when bitor ] curry compose ] reduce ; + [ 0 ] [ [ ?execute bitor ] curry compose ] reduce ; ! bitfield values ( word/value-seq -- value-seq ) - [ dup word? [ execute ] when ] map ; + [ ?execute ] map ; : (all-enabled) ( seq quot -- ) over [ glEnable ] each dip [ glDisable ] each ; inline diff --git a/basis/ui/tools/operations/operations.factor b/basis/ui/tools/operations/operations.factor index 28781e24bb..c6371ac8aa 100644 --- a/basis/ui/tools/operations/operations.factor +++ b/basis/ui/tools/operations/operations.factor @@ -81,8 +81,6 @@ IN: ui.tools.operations { +listener+ t } } define-operation -UNION: definition word method-spec link vocab vocab-link ; - [ definition? ] \ edit H{ { +keyboard+ T{ key-down f { C+ } "e" } } { +listener+ t } diff --git a/basis/unicode/breaks/breaks.factor b/basis/unicode/breaks/breaks.factor index 22d6cddfb9..12314505d9 100644 --- a/basis/unicode/breaks/breaks.factor +++ b/basis/unicode/breaks/breaks.factor @@ -60,7 +60,7 @@ SYMBOL: table : finish-table ( -- table ) table get [ [ 1 = ] map ] map ; -: eval-seq ( seq -- seq ) [ dup word? [ execute ] when ] map ; +: eval-seq ( seq -- seq ) [ ?execute ] map ; : (set-table) ( class1 class2 val -- ) [ table get nth ] dip '[ _ or ] change-nth ; diff --git a/core/definitions/definitions.factor b/core/definitions/definitions.factor index 434b133b3f..c95c5816ac 100644 --- a/core/definitions/definitions.factor +++ b/core/definitions/definitions.factor @@ -3,6 +3,8 @@ USING: kernel sequences namespaces assocs graphs math math.order ; IN: definitions +MIXIN: definition + ERROR: no-compilation-unit definition ; SYMBOLS: inlined-dependency flushed-dependency called-dependency ; diff --git a/core/generic/generic.factor b/core/generic/generic.factor index 8380a41207..c22641d439 100644 --- a/core/generic/generic.factor +++ b/core/generic/generic.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2006, 2008 Slava Pestov. +! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors words kernel sequences namespaces make assocs hashtables definitions kernel.private classes classes.private @@ -27,6 +27,8 @@ M: generic definition drop f ; PREDICATE: method-spec < pair first2 generic? swap class? and ; +INSTANCE: method-spec definition + : order ( generic -- seq ) "methods" word-prop keys sort-classes ; diff --git a/core/kernel/kernel.factor b/core/kernel/kernel.factor index 56f19595cb..baccf56059 100644 --- a/core/kernel/kernel.factor +++ b/core/kernel/kernel.factor @@ -23,6 +23,10 @@ GENERIC: call ( callable -- ) GENERIC: execute ( word -- ) +GENERIC: ?execute ( word -- value ) + +M: object ?execute ; + DEFER: if : ? ( ? true false -- true/false ) diff --git a/core/vocabs/vocabs.factor b/core/vocabs/vocabs.factor index edac418285..2b978e8666 100644 --- a/core/vocabs/vocabs.factor +++ b/core/vocabs/vocabs.factor @@ -108,4 +108,6 @@ SYMBOL: load-vocab-hook ! ( name -- vocab ) : load-vocab ( name -- vocab ) load-vocab-hook get call( name -- vocab ) ; PREDICATE: runnable-vocab < vocab - vocab-main >boolean ; \ No newline at end of file + vocab-main >boolean ; + +INSTANCE: vocab-spec definition \ No newline at end of file diff --git a/core/words/words.factor b/core/words/words.factor index cfdcd4517f..5b230c1b00 100755 --- a/core/words/words.factor +++ b/core/words/words.factor @@ -12,6 +12,8 @@ IN: words M: word execute (execute) ; +M: word ?execute execute( -- value ) ; + M: word <=> [ [ name>> ] [ vocabulary>> ] bi 2array ] compare ; @@ -260,3 +262,5 @@ M: word hashcode* M: word literalize ; : xref-words ( -- ) all-words [ xref ] each ; + +INSTANCE: word definition \ No newline at end of file