diff --git a/basis/fry/fry.factor b/basis/fry/fry.factor index 395d5c3caf..87c59e18a0 100644 --- a/basis/fry/fry.factor +++ b/basis/fry/fry.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov, Eduardo Cavazos. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences combinators parser splitting math -quotations arrays make qualified words ; +quotations arrays make words ; IN: fry : _ ( -- * ) "Only valid inside a fry" throw ; diff --git a/basis/qualified/qualified-docs.factor b/basis/qualified/qualified-docs.factor index d62f696a74..067d221d2f 100644 --- a/basis/qualified/qualified-docs.factor +++ b/basis/qualified/qualified-docs.factor @@ -32,3 +32,14 @@ HELP: RENAME: "RENAME: + math => -" "2 3 - ! => 5" } } ; +ARTICLE: "qualified" "Qualified word lookup" +"The " { $vocab-link "qualified" } " vocabulary provides a handful of parsing words which give more control over word lookup than is offered by " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } "." +$nl +"These words are useful when there is no way to avoid using two vocabularies with identical word names in the same source file." +{ $subsection POSTPONE: QUALIFIED: } +{ $subsection POSTPONE: QUALIFIED-WITH: } +{ $subsection POSTPONE: FROM: } +{ $subsection POSTPONE: EXCLUDE: } +{ $subsection POSTPONE: RENAME: } ; + +ABOUT: "qualified" diff --git a/basis/qualified/qualified-tests.factor b/basis/qualified/qualified-tests.factor index 8f67ddf730..78efec4861 100644 --- a/basis/qualified/qualified-tests.factor +++ b/basis/qualified/qualified-tests.factor @@ -1,24 +1,33 @@ -USING: tools.test qualified ; -IN: foo +USING: tools.test qualified eval accessors parser ; +IN: qualified.tests.foo : x 1 ; -IN: bar +: y 5 ; +IN: qualified.tests.bar : x 2 ; -IN: baz +: y 4 ; +IN: qualified.tests.baz : x 3 ; -QUALIFIED: foo -QUALIFIED: bar -[ 1 2 3 ] [ foo:x bar:x x ] unit-test +QUALIFIED: qualified.tests.foo +QUALIFIED: qualified.tests.bar +[ 1 2 3 ] [ qualified.tests.foo:x qualified.tests.bar:x x ] unit-test -QUALIFIED-WITH: bar p +QUALIFIED-WITH: qualified.tests.bar p [ 2 ] [ p:x ] unit-test -RENAME: x baz => y +RENAME: x qualified.tests.baz => y [ 3 ] [ y ] unit-test -FROM: baz => x ; +FROM: qualified.tests.baz => x ; [ 3 ] [ x ] unit-test +[ 3 ] [ y ] unit-test -EXCLUDE: bar => x ; +EXCLUDE: qualified.tests.bar => x ; [ 3 ] [ x ] unit-test +[ 4 ] [ y ] unit-test +[ "USE: qualified IN: qualified.tests FROM: qualified.tests => doesnotexist ;" eval ] +[ error>> no-word-error? ] must-fail-with + +[ "USE: qualified IN: qualified.tests RENAME: doesnotexist qualified.tests => blah" eval ] +[ error>> no-word-error? ] must-fail-with diff --git a/basis/qualified/qualified.factor b/basis/qualified/qualified.factor index d636cc0152..d387ef4b0e 100644 --- a/basis/qualified/qualified.factor +++ b/basis/qualified/qualified.factor @@ -1,12 +1,12 @@ ! Copyright (C) 2007, 2008 Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences assocs hashtables parser lexer -vocabs words namespaces vocabs.loader debugger sets ; +vocabs words namespaces vocabs.loader debugger sets fry ; IN: qualified : define-qualified ( vocab-name prefix-name -- ) [ load-vocab vocab-words ] [ CHAR: : suffix ] bi* - [ -rot >r append r> ] curry assoc-map + '[ [ [ _ ] dip append ] dip ] assoc-map use get push ; : QUALIFIED: @@ -19,27 +19,27 @@ IN: qualified : expect=> ( -- ) scan "=>" assert= ; -: partial-vocab ( words name -- assoc ) - dupd [ - lookup [ "No such word: " swap append throw ] unless* - ] curry map zip ; - -: partial-vocab-ignoring ( words name -- assoc ) - [ load-vocab vocab-words keys swap diff ] keep partial-vocab ; - -: EXCLUDE: - #! Syntax: EXCLUDE: vocab => words ... ; - scan expect=> - ";" parse-tokens swap partial-vocab-ignoring use get push ; parsing +: partial-vocab ( words vocab -- assoc ) + '[ dup _ lookup [ no-word-error ] unless* ] + { } map>assoc ; : FROM: #! Syntax: FROM: vocab => words... ; scan dup load-vocab drop expect=> ";" parse-tokens swap partial-vocab use get push ; parsing +: partial-vocab-excluding ( words vocab -- assoc ) + [ load-vocab vocab-words keys swap diff ] keep partial-vocab ; + +: EXCLUDE: + #! Syntax: EXCLUDE: vocab => words ... ; + scan expect=> + ";" parse-tokens swap partial-vocab-excluding use get push ; parsing + : RENAME: #! Syntax: RENAME: word vocab => newname - scan scan dup load-vocab drop lookup [ "No such word" throw ] unless* + scan scan dup load-vocab drop + dupd lookup [ ] [ no-word-error ] ?if expect=> scan associate use get push ; parsing diff --git a/basis/ui/gadgets/lists/lists.factor b/basis/ui/gadgets/lists/lists.factor index 62e5b7d780..17fe68721d 100644 --- a/basis/ui/gadgets/lists/lists.factor +++ b/basis/ui/gadgets/lists/lists.factor @@ -97,7 +97,7 @@ M: list focusable-child* drop t ; ] if ; : select-gadget ( gadget list -- ) - swap over children>> index + tuck children>> index [ swap select-index ] [ drop ] if* ; : clamp-loc ( point max -- point ) diff --git a/basis/ui/gadgets/scrollers/scrollers.factor b/basis/ui/gadgets/scrollers/scrollers.factor index fefce8a040..633e3ad4a8 100644 --- a/basis/ui/gadgets/scrollers/scrollers.factor +++ b/basis/ui/gadgets/scrollers/scrollers.factor @@ -41,7 +41,7 @@ scroller H{ dup model>> dependencies>> first >>x dup x>> @bottom grid-add dup model>> dependencies>> second >>y dup y>> @right grid-add - swap over model>> >>viewport + tuck model>> >>viewport dup viewport>> @center grid-add ; : ( gadget -- scroller ) scroller new-scroller ; diff --git a/core/parser/parser-docs.factor b/core/parser/parser-docs.factor index 1d8d1f0714..d33f5cd6d9 100644 --- a/core/parser/parser-docs.factor +++ b/core/parser/parser-docs.factor @@ -69,7 +69,7 @@ $nl { $subsection POSTPONE: PRIVATE> } { $subsection "vocabulary-search-errors" } { $subsection "vocabulary-search-shadow" } -{ $see-also "words" } ; +{ $see-also "words" "qualified" } ; ARTICLE: "reading-ahead" "Reading ahead" "Parsing words can consume input:" diff --git a/core/parser/parser.factor b/core/parser/parser.factor index a86715b073..ed8fc4510b 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -71,10 +71,10 @@ ERROR: no-current-vocab ; ] keep ] { } map>assoc ; -TUPLE: no-word-error name ; +ERROR: no-word-error name ; : no-word ( name -- newword ) - dup no-word-error boa + dup \ no-word-error boa swap words-named [ forward-reference? not ] filter word-restarts throw-restarts dup vocabulary>> (use+) ; diff --git a/extra/mason/release/tidy/tidy.factor b/extra/mason/release/tidy/tidy.factor index a456e6ff23..fb931650d4 100644 --- a/extra/mason/release/tidy/tidy.factor +++ b/extra/mason/release/tidy/tidy.factor @@ -1,16 +1,14 @@ ! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel namespaces continuations debugger sequences fry -io.files io.launcher mason.common mason.platform +io.files io.launcher bootstrap.image qualified mason.common mason.config ; +FROM: mason.config => target-os ; IN: mason.release.tidy : common-files ( -- seq ) + images [ boot-image-name ] map { - "boot.x86.32.image" - "boot.x86.64.image" - "boot.macosx-ppc.image" - "boot.linux-ppc.image" "vm" "temp" "logs" @@ -20,7 +18,8 @@ IN: mason.release.tidy "unmaintained" "unfinished" "build-support" - } ; + } + append ; : remove-common-files ( -- ) common-files [ delete-tree ] each ; diff --git a/vm/cpu-x86.32.S b/vm/cpu-x86.32.S index e0e674a7e2..eec850dc9e 100755 --- a/vm/cpu-x86.32.S +++ b/vm/cpu-x86.32.S @@ -10,14 +10,18 @@ and the callstack top is passed in EDX */ #define DS_REG %esi #define RETURN_REG %eax +#define NV_TEMP_REG %rbx + #define CELL_SIZE 4 #define STACK_PADDING 12 #define PUSH_NONVOLATILE \ push %ebx ; \ + push %ebp ; \ push %ebp #define POP_NONVOLATILE \ + pop %ebp ; \ pop %ebp ; \ pop %ebx diff --git a/vm/cpu-x86.64.S b/vm/cpu-x86.64.S index 15a4eb8da3..c981095d62 100644 --- a/vm/cpu-x86.64.S +++ b/vm/cpu-x86.64.S @@ -7,6 +7,8 @@ #define CELL_SIZE 8 #define STACK_PADDING 56 +#define NV_TEMP_REG %rbp + #ifdef WINDOWS #define ARG0 %rcx @@ -20,9 +22,11 @@ push %rdi ; \ push %rsi ; \ push %rbx ; \ + push %rbp ; \ push %rbp #define POP_NONVOLATILE \ + pop %rbp ; \ pop %rbp ; \ pop %rbx ; \ pop %rsi ; \ @@ -41,9 +45,11 @@ push %rbx ; \ push %rbp ; \ push %r12 ; \ + push %r13 ; \ push %r13 #define POP_NONVOLATILE \ + pop %r13 ; \ pop %r13 ; \ pop %r12 ; \ pop %rbp ; \ diff --git a/vm/cpu-x86.S b/vm/cpu-x86.S index 3d6cacdebd..1857fb0ed8 100755 --- a/vm/cpu-x86.S +++ b/vm/cpu-x86.S @@ -1,20 +1,21 @@ DEF(F_FASTCALL void,c_to_factor,(CELL quot)): PUSH_NONVOLATILE - push ARG0 - - /* Save stack pointer */ - lea -CELL_SIZE(STACK_REG),ARG0 + mov ARG0,NV_TEMP_REG /* Create register shadow area for Win64 */ - sub $32,STACK_REG + sub $32,STACK_REG + + /* Save stack pointer */ + lea -CELL_SIZE(STACK_REG),ARG0 call MANGLE(save_callstack_bottom) - add $32,STACK_REG /* Call quot-xt */ - mov (STACK_REG),ARG0 + mov NV_TEMP_REG,ARG0 call *QUOT_XT_OFFSET(ARG0) - pop ARG0 + /* Tear down register shadow area */ + add $32,STACK_REG + POP_NONVOLATILE ret