Merge branch 'master' of git://factorcode.org/git/factor

db4
Slava Pestov 2009-06-02 18:30:25 -05:00
commit 9da8cfe942
8 changed files with 72 additions and 46 deletions

View File

@ -8,7 +8,7 @@ IN: compiler.cfg.checker
ERROR: last-insn-not-a-jump insn ; ERROR: last-insn-not-a-jump insn ;
: check-last-instruction ( bb -- ) : check-last-instruction ( bb -- )
peek dup { last dup {
[ ##branch? ] [ ##branch? ]
[ ##dispatch? ] [ ##dispatch? ]
[ ##conditional-branch? ] [ ##conditional-branch? ]

View File

@ -15,18 +15,19 @@ ERROR: cursor-ended cursor ;
dup cursor-done? dup cursor-done?
[ cursor-ended ] [ cursor-get-unsafe ] if ; inline [ cursor-ended ] [ cursor-get-unsafe ] if ; inline
: find-done? ( quot cursor -- ? ) : find-done? ( cursor quot -- ? )
dup cursor-done? [ 2drop t ] [ cursor-get-unsafe swap call ] if ; inline over cursor-done?
[ 2drop t ] [ [ cursor-get-unsafe ] dip call ] if ; inline
: cursor-until ( quot cursor -- ) : cursor-until ( cursor quot -- )
[ find-done? not ] [ find-done? not ]
[ cursor-advance drop ] bi-curry bi-curry while ; inline [ drop cursor-advance ] bi-curry bi-curry while ; inline
: cursor-each ( cursor quot -- ) : cursor-each ( cursor quot -- )
[ f ] compose swap cursor-until ; inline [ f ] compose cursor-until ; inline
: cursor-find ( cursor quot -- obj ? ) : cursor-find ( cursor quot -- obj ? )
swap [ cursor-until ] keep [ cursor-until ] [ drop ] 2bi
dup cursor-done? [ drop f f ] [ cursor-get t ] if ; inline dup cursor-done? [ drop f f ] [ cursor-get t ] if ; inline
: cursor-any? ( cursor quot -- ? ) : cursor-any? ( cursor quot -- ? )
@ -93,7 +94,8 @@ M: to-sequence cursor-write
: transform ( seq quot transformer -- newseq ) : transform ( seq quot transformer -- newseq )
[ [ >input ] [ >output ] bi ] 2dip [ [ >input ] [ >output ] bi ] 2dip
[ call ] [ 2drop freeze ] 3bi ; inline [ call ]
[ 2drop freeze ] 3bi ; inline
: map ( seq quot -- ) [ cursor-map ] transform ; inline : map ( seq quot -- ) [ cursor-map ] transform ; inline
: filter ( seq quot -- newseq ) [ cursor-filter ] transform ; inline : filter ( seq quot -- newseq ) [ cursor-filter ] transform ; inline

View File

@ -134,14 +134,16 @@ PRIVATE>
! Scaffold support ! Scaffold support
: fuel-scaffold-name ( devname -- )
[ developer-name set ] when* ;
: fuel-scaffold-vocab ( root name devname -- ) : fuel-scaffold-vocab ( root name devname -- )
developer-name set dup [ scaffold-vocab ] dip [ fuel-scaffold-name dup [ scaffold-vocab ] dip ] with-scope
dup require vocab-source-path (normalize-path) fuel-eval-set-result ; dup require vocab-source-path (normalize-path) fuel-eval-set-result ;
: fuel-scaffold-help ( name devname -- ) : fuel-scaffold-help ( name devname -- )
developer-name set [ fuel-scaffold-name dup require dup scaffold-help ] with-scope
dup require dup scaffold-help vocab-docs-path vocab-docs-path (normalize-path) fuel-eval-set-result ;
(normalize-path) fuel-eval-set-result ;
: fuel-scaffold-get-root ( name -- ) find-vocab-root fuel-eval-set-result ; : fuel-scaffold-get-root ( name -- ) find-vocab-root fuel-eval-set-result ;

View File

@ -85,6 +85,18 @@ M: mb-writer dispose drop ;
] with-irc ] with-irc
] unit-test ] unit-test
! Test connect with password
{ V{ "PASS password" "NICK factorbot" "USER factorbot hostname servername :irc.factor" } } [
"someserver" irc-port "factorbot" "password" <irc-profile> <irc-client>
[ 2drop <test-stream> ] >>connect
[
(connect-irc)
(do-login)
irc> stream>> out>> lines>>
(terminate-irc)
] with-irc
] unit-test
! Test join ! Test join
[ { "JOIN #factortest" } [ [ { "JOIN #factortest" } [
"#factortest" %join %pop-output-line "#factortest" %join %pop-output-line

View File

@ -16,6 +16,7 @@ IN: irc.client.internals
: /NICK ( nick -- ) "NICK " prepend irc-print ; : /NICK ( nick -- ) "NICK " prepend irc-print ;
: /PONG ( text -- ) "PONG " prepend irc-print ; : /PONG ( text -- ) "PONG " prepend irc-print ;
: /PASS ( password -- ) "PASS " prepend irc-print ;
: /LOGIN ( nick -- ) : /LOGIN ( nick -- )
dup /NICK dup /NICK
@ -44,7 +45,11 @@ IN: irc.client.internals
in-messages>> [ irc-connected ] dip mailbox-put in-messages>> [ irc-connected ] dip mailbox-put
] [ (terminate-irc) ] if* ; ] [ (terminate-irc) ] if* ;
: (do-login) ( -- ) irc> nick>> /LOGIN ; : (do-login) ( -- )
irc>
[ profile>> password>> [ /PASS ] when* ]
[ nick>> /LOGIN ]
bi ;
GENERIC: initialize-chat ( chat -- ) GENERIC: initialize-chat ( chat -- )
M: irc-chat initialize-chat drop ; M: irc-chat initialize-chat drop ;

View File

@ -18,6 +18,9 @@ chat-docs [ H{ } clone ] initialize
CONSTANT: line-beginning "-!- " CONSTANT: line-beginning "-!- "
: send-line ( string -- )
write "\r\n" write flush ;
: handle-me ( string -- ) : handle-me ( string -- )
[ [
[ "* " username " " ] dip [ "* " username " " ] dip
@ -29,15 +32,15 @@ CONSTANT: line-beginning "-!- "
: handle-help ( string -- ) : handle-help ( string -- )
[ [
"Commands: " "Commands: "
commands get keys natural-sort ", " join append print flush commands get keys natural-sort ", " join append send-line
] [ ] [
chat-docs get ?at chat-docs get ?at
[ print flush ] [ send-line ]
[ "Unknown command: " prepend print flush ] if [ "Unknown command: " prepend send-line ] if
] if-empty ; ] if-empty ;
: usage ( string -- ) : usage ( string -- )
chat-docs get at print flush ; chat-docs get at send-line ;
: username-taken-string ( username -- string ) : username-taken-string ( username -- string )
"The username ``" "'' is already in use; try again." surround ; "The username ``" "'' is already in use; try again." surround ;
@ -53,7 +56,7 @@ CONSTANT: line-beginning "-!- "
"nick" usage "nick" usage
] [ ] [
dup clients key? [ dup clients key? [
username-taken-string print flush username-taken-string send-line
] [ ] [
[ username swap warn-name-changed ] [ username swap warn-name-changed ]
[ username clients rename-at ] [ username clients rename-at ]
@ -70,12 +73,12 @@ CONSTANT: line-beginning "-!- "
Displays the documentation for a command."> Displays the documentation for a command.">
"help" add-command "help" add-command
[ drop clients keys [ "``" "''" surround ] map ", " join print flush ] [ drop clients keys [ "``" "''" surround ] map ", " join send-line ]
<" Syntax: /who <" Syntax: /who
Shows the list of connected users."> Shows the list of connected users.">
"who" add-command "who" add-command
[ drop gmt timestamp>rfc822 print flush ] [ drop gmt timestamp>rfc822 send-line ]
<" Syntax: /time <" Syntax: /time
Returns the current GMT time."> "time" add-command Returns the current GMT time."> "time" add-command
@ -96,7 +99,7 @@ Disconnects a user from the chat server."> "quit" add-command
dup " " split1 swap >lower commands get at* [ dup " " split1 swap >lower commands get at* [
call( string -- ) drop call( string -- ) drop
] [ ] [
2drop "Unknown command: " prepend print flush 2drop "Unknown command: " prepend send-line
] if ; ] if ;
: <chat-server> ( port -- managed-server ) : <chat-server> ( port -- managed-server )
@ -123,7 +126,7 @@ M: chat-server handle-client-disconnect
] "" append-outputs-as send-everyone ; ] "" append-outputs-as send-everyone ;
M: chat-server handle-already-logged-in M: chat-server handle-already-logged-in
username username-taken-string print flush ; username username-taken-string send-line ;
M: chat-server handle-managed-client* M: chat-server handle-managed-client*
readln dup f = [ t client (>>quit?) ] when readln dup f = [ t client (>>quit?) ] when

View File

@ -26,9 +26,10 @@
"Options for FUEL's scaffolding." "Options for FUEL's scaffolding."
:group 'fuel) :group 'fuel)
(defcustom fuel-scaffold-developer-name user-full-name (defcustom fuel-scaffold-developer-name nil
"The name to be inserted as yours in scaffold templates." "The name to be inserted as yours in scaffold templates."
:type 'string :type '(choice string
(const :tag "Factor's value for developer-name" nil))
:group 'fuel-scaffold) :group 'fuel-scaffold)

View File

@ -59,7 +59,7 @@
"POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROVIDE:" "POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROVIDE:"
"QUALIFIED-WITH:" "QUALIFIED:" "QUALIFIED-WITH:" "QUALIFIED:"
"read-only" "RENAME:" "REQUIRE:" "REQUIRES:" "read-only" "RENAME:" "REQUIRE:" "REQUIRES:"
"SINGLETON:" "SINGLETONS:" "SLOT:" "SYMBOL:" "SYMBOLS:" "SINGLETON:" "SINGLETONS:" "SLOT:" "SYMBOL:" "SYMBOLS:" "SYNTAX:"
"TUPLE:" "t" "t?" "TYPEDEF:" "TUPLE:" "t" "t?" "TYPEDEF:"
"UNION:" "USE:" "USING:" "UNION:" "USE:" "USING:"
"VARS:")) "VARS:"))
@ -109,7 +109,7 @@
(format "\\_<\\(%s\\)?: +\\_<\\(\\w+\\)\\_>" (format "\\_<\\(%s\\)?: +\\_<\\(\\w+\\)\\_>"
(regexp-opt (regexp-opt
'(":" "GENERIC" "DEFER" "HOOK" "MAIN" "MATH" "POSTPONE" '(":" "GENERIC" "DEFER" "HOOK" "MAIN" "MATH" "POSTPONE"
"SYMBOL" "RENAME")))) "SYMBOL" "SYNTAX" "RENAME"))))
(defconst fuel-syntax--alias-definition-regex (defconst fuel-syntax--alias-definition-regex
"^ALIAS: +\\(\\_<.+?\\_>\\) +\\(\\_<.+?\\_>\\)") "^ALIAS: +\\(\\_<.+?\\_>\\) +\\(\\_<.+?\\_>\\)")
@ -156,6 +156,7 @@
"INTERSECTION:" "INTERSECTION:"
"M" "MACRO" "MACRO:" "M" "MACRO" "MACRO:"
"MEMO" "MEMO:" "METHOD" "MEMO" "MEMO:" "METHOD"
"SYNTAX"
"PREDICATE" "PRIMITIVE" "PREDICATE" "PRIMITIVE"
"UNION")) "UNION"))