From 78e3c197977b2cada35c4ac90fc0f96bc74b3e97 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 18 May 2009 10:31:05 -0500 Subject: [PATCH 01/38] factor out grid mesh generation in terrain to its own vocab --- extra/grid-meshes/grid-meshes.factor | 48 ++++++++++++++++++++++++++++ extra/terrain/authors.txt | 2 ++ extra/terrain/summary.txt | 1 + extra/terrain/terrain.factor | 44 ++++--------------------- 4 files changed, 58 insertions(+), 37 deletions(-) create mode 100644 extra/grid-meshes/grid-meshes.factor create mode 100644 extra/terrain/authors.txt create mode 100644 extra/terrain/summary.txt diff --git a/extra/grid-meshes/grid-meshes.factor b/extra/grid-meshes/grid-meshes.factor new file mode 100644 index 0000000000..19c4568b7c --- /dev/null +++ b/extra/grid-meshes/grid-meshes.factor @@ -0,0 +1,48 @@ +! (c)2009 Joe Groff bsd license +USING: accessors arrays destructors kernel math opengl +opengl.gl sequences sequences.product specialized-arrays.float ; +IN: grid-meshes + +TUPLE: grid-mesh dim buffer row-length ; + +vertex-buffer ( bytes -- buffer ) + [ GL_ARRAY_BUFFER ] dip GL_STATIC_DRAW ; + +: draw-vertex-buffer-row ( grid-mesh i -- ) + swap [ GL_TRIANGLE_STRIP ] 2dip + row-length>> [ * ] keep + glDrawArrays ; + +PRIVATE> + +: draw-grid-mesh ( grid-mesh -- ) + GL_ARRAY_BUFFER over buffer>> [ + [ 3 GL_FLOAT 0 f glVertexPointer ] dip + dup dim>> second iota [ draw-vertex-buffer-row ] with each + ] with-gl-buffer ; + +: ( dim -- grid-mesh ) + [ ] [ vertex-array >vertex-buffer ] [ first 1 + 2 * ] tri + grid-mesh boa ; + +M: grid-mesh dispose + [ [ delete-gl-buffer ] when* f ] change-buffer + drop ; + diff --git a/extra/terrain/authors.txt b/extra/terrain/authors.txt new file mode 100644 index 0000000000..0bc3c5ad4d --- /dev/null +++ b/extra/terrain/authors.txt @@ -0,0 +1,2 @@ +Joe Groff +Doug Coleman diff --git a/extra/terrain/summary.txt b/extra/terrain/summary.txt new file mode 100644 index 0000000000..3244803592 --- /dev/null +++ b/extra/terrain/summary.txt @@ -0,0 +1 @@ +Walk around on procedurally generated terrain diff --git a/extra/terrain/terrain.factor b/extra/terrain/terrain.factor index cfacfeb700..5847426fae 100644 --- a/extra/terrain/terrain.factor +++ b/extra/terrain/terrain.factor @@ -1,3 +1,4 @@ +! (c)2009 Joe Groff, Doug Coleman. bsd license USING: accessors arrays combinators game-input game-loop game-input.scancodes grouping kernel literals locals math math.constants math.functions math.matrices math.order @@ -6,7 +7,8 @@ opengl.shaders opengl.textures opengl.textures.private sequences sequences.product specialized-arrays.float terrain.generation terrain.shaders ui ui.gadgets ui.gadgets.worlds ui.pixel-formats game-worlds method-chains -math.affine-transforms noise ui.gestures combinators.short-circuit ; +math.affine-transforms noise ui.gestures combinators.short-circuit +destructors grid-meshes ; IN: terrain CONSTANT: FOV $[ 2.0 sqrt 1+ ] @@ -26,8 +28,6 @@ CONSTANT: SKY-PERIOD 1200 CONSTANT: SKY-SPEED 0.0005 CONSTANT: terrain-vertex-size { 512 512 } -CONSTANT: terrain-vertex-distance { $[ 1.0 512.0 / ] $[ 1.0 512.0 / ] } -CONSTANT: terrain-vertex-row-length $[ 512 1 + 2 * ] TUPLE: player location yaw pitch velocity velocity-modifier @@ -37,7 +37,7 @@ TUPLE: terrain-world < game-world player sky-image sky-texture sky-program terrain terrain-segment terrain-texture terrain-program - terrain-vertex-buffer + terrain-mesh history ; : ( -- player ) @@ -65,35 +65,6 @@ M: terrain-world tick-length [ yaw>> 0.0 1.0 0.0 glRotatef ] [ location>> vneg first3 glTranslatef ] tri ; -: vertex-array-vertex ( x z -- vertex ) - [ terrain-vertex-distance first * ] - [ terrain-vertex-distance second * ] bi* - [ 0 ] dip float-array{ } 3sequence ; - -: vertex-array-row ( z -- vertices ) - dup 1 + 2array - terrain-vertex-size first 1 + iota - 2array [ first2 swap vertex-array-vertex ] product-map - concat ; - -: vertex-array ( -- vertices ) - terrain-vertex-size second iota - [ vertex-array-row ] map concat ; - -: >vertex-buffer ( bytes -- buffer ) - [ GL_ARRAY_BUFFER ] dip GL_STATIC_DRAW ; - -: draw-vertex-buffer-row ( i -- ) - [ GL_TRIANGLE_STRIP ] dip - terrain-vertex-row-length * terrain-vertex-row-length - glDrawArrays ; - -: draw-vertex-buffer ( buffer -- ) - [ GL_ARRAY_BUFFER ] dip [ - 3 GL_FLOAT 0 f glVertexPointer - terrain-vertex-size second iota [ draw-vertex-buffer-row ] each - ] with-gl-buffer ; - : degrees ( deg -- rad ) pi 180.0 / * ; @@ -119,7 +90,6 @@ M: terrain-world tick-length : clamp-pitch ( pitch -- pitch' ) 90.0 min -90.0 max ; - : walk-forward ( player -- ) dup forward-vector [ v+ ] curry change-velocity drop ; : walk-backward ( player -- ) @@ -274,12 +244,12 @@ BEFORE: terrain-world begin-world >>sky-program terrain-vertex-shader terrain-pixel-shader >>terrain-program - vertex-array >vertex-buffer >>terrain-vertex-buffer + terrain-vertex-size >>terrain-mesh drop ; AFTER: terrain-world end-world { - [ terrain-vertex-buffer>> delete-gl-buffer ] + [ terrain-mesh>> dispose ] [ terrain-program>> delete-gl-program ] [ terrain-texture>> delete-texture ] [ sky-program>> delete-gl-program ] @@ -306,7 +276,7 @@ M: terrain-world draw-world* [ GL_DEPTH_TEST glEnable dup terrain-program>> [ [ "heightmap" glGetUniformLocation 0 glUniform1i ] [ "component_scale" glGetUniformLocation COMPONENT-SCALE first4 glUniform4f ] bi - terrain-vertex-buffer>> draw-vertex-buffer + terrain-mesh>> draw-grid-mesh ] with-gl-program ] } cleave gl-error ; From 74107f2acd9f466f629abd7f93f703bcd1e2318b Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 18 May 2009 23:45:52 -0500 Subject: [PATCH 02/38] fix some duplicate using lines --- basis/furnace/actions/actions.factor | 1 - extra/galois-talk/galois-talk.factor | 2 +- extra/minneapolis-talk/minneapolis-talk.factor | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/basis/furnace/actions/actions.factor b/basis/furnace/actions/actions.factor index c7893117d1..06e743e967 100644 --- a/basis/furnace/actions/actions.factor +++ b/basis/furnace/actions/actions.factor @@ -12,7 +12,6 @@ furnace.conversations furnace.chloe-tags html.forms html.components -html.components html.templates.chloe html.templates.chloe.syntax html.templates.chloe.compiler ; diff --git a/extra/galois-talk/galois-talk.factor b/extra/galois-talk/galois-talk.factor index ba929867e9..0d2a5a73d8 100644 --- a/extra/galois-talk/galois-talk.factor +++ b/extra/galois-talk/galois-talk.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: slides help.markup math arrays hashtables namespaces -sequences kernel sequences parser memoize io.encodings.binary +sequences kernel parser memoize io.encodings.binary locals kernel.private help.vocabs assocs quotations urls peg.ebnf tools.annotations tools.crossref help.topics math.functions compiler.tree.optimizer diff --git a/extra/minneapolis-talk/minneapolis-talk.factor b/extra/minneapolis-talk/minneapolis-talk.factor index 6f1df44bfb..a96bb2ce20 100755 --- a/extra/minneapolis-talk/minneapolis-talk.factor +++ b/extra/minneapolis-talk/minneapolis-talk.factor @@ -1,5 +1,5 @@ USING: slides help.markup math arrays hashtables namespaces -sequences kernel sequences parser memoize ; +sequences kernel parser memoize ; IN: minneapolis-talk CONSTANT: minneapolis-slides From a8c9dab9e2b7a6a27486f0d812f527662ee37b8e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 19 May 2009 01:40:04 -0500 Subject: [PATCH 03/38] make: minor doc fix --- core/make/make-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/make/make-docs.factor b/core/make/make-docs.factor index 7808872588..6a77ef65fc 100644 --- a/core/make/make-docs.factor +++ b/core/make/make-docs.factor @@ -27,7 +27,7 @@ $nl { $heading "Utilities for simple make patterns" } "Sometimes, an existing word already implements a specific " { $link make } " usage. For example, " { $link suffix } " is equivalent to the following, with the added caveat that the below example always outputs an array:" { $code "[ , % ] { } make" } -"The existing utility words can in some cases express intent better than an arbitrary-looking string or " { $link , } " and " { $link % } "." +"The existing utility words can in some cases express intent better than a bunch of " { $link , } " and " { $link % } "." { $heading "Constructing quotations" } "Simple quotation construction can often be accomplished using " { $link "fry" } " and " { $link "compositional-combinators" } "." $nl From 39e0d402238614b224282d7cfd3a199334bd4d04 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 19 May 2009 17:46:05 -0500 Subject: [PATCH 04/38] webapps.mason: minor improvements --- extra/webapps/mason/mason.factor | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extra/webapps/mason/mason.factor b/extra/webapps/mason/mason.factor index ea7040ac6e..359b277677 100644 --- a/extra/webapps/mason/mason.factor +++ b/extra/webapps/mason/mason.factor @@ -9,7 +9,7 @@ IN: webapps.mason : log-file ( -- path ) home "mason.log" append-path ; : recent-events ( -- xml ) - log-file utf8 file-lines 10 short tail* "\n" join [XML
<->
XML] ; + log-file utf8 10 file-tail [XML
<->
XML] ; : git-link ( id -- link ) [ "http://github.com/slavapestov/factor/commit/" prepend ] keep @@ -21,8 +21,9 @@ IN: webapps.mason : current-status ( builder -- xml ) dup status>> { - { "dirty" [ drop "Dirty" ] } - { "clean" [ drop "Clean" ] } + { "status-dirty" [ drop "Dirty" ] } + { "status-clean" [ drop "Clean" ] } + { "status-error" [ drop "Error" ] } { "starting" [ "Starting" building ] } { "make-vm" [ "Compiling VM" building ] } { "boot" [ "Bootstrapping" building ] } From 2d81d082c68dd59d8212cc5f2902d60f3cb50ab8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 19 May 2009 17:56:34 -0500 Subject: [PATCH 05/38] webapps.mason: fix using --- extra/webapps/mason/mason.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/webapps/mason/mason.factor b/extra/webapps/mason/mason.factor index 359b277677..74c459e38e 100644 --- a/extra/webapps/mason/mason.factor +++ b/extra/webapps/mason/mason.factor @@ -2,8 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays combinators db db.tuples furnace.actions http.server.responses kernel mason.platform mason.notify.server -math.order sequences sorting splitting xml.syntax xml.writer -io.pathnames io.encodings.utf8 io.files ; +mason.report math.order sequences sorting splitting xml.syntax +xml.writer io.pathnames io.encodings.utf8 io.files ; IN: webapps.mason : log-file ( -- path ) home "mason.log" append-path ; From 4489346f695b66044318a752499f2f4a8ad8f1cc Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 19 May 2009 18:05:04 -0500 Subject: [PATCH 06/38] speed up md5 compilation time by not inlining everything --- basis/checksums/md5/md5.factor | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/basis/checksums/md5/md5.factor b/basis/checksums/md5/md5.factor index 89ff5d46a2..c74aa550d2 100644 --- a/basis/checksums/md5/md5.factor +++ b/basis/checksums/md5/md5.factor @@ -5,7 +5,7 @@ math.functions math.parser namespaces splitting grouping strings sequences byte-arrays locals sequences.private macros fry io.encodings.binary math.bitwise checksums accessors checksums.common checksums.stream combinators combinators.smart -specialized-arrays.uint literals ; +specialized-arrays.uint literals hints ; IN: checksums.md5 SINGLETON: md5 @@ -28,7 +28,7 @@ M: md5 initialize-checksum-state drop ; : update-md5 ( md5 -- ) [ state>> ] [ old-state>> v-w+ dup clone ] [ ] tri - [ (>>old-state) ] [ (>>state) ] bi ; inline + [ (>>old-state) ] [ (>>state) ] bi ; CONSTANT: T $[ @@ -106,7 +106,7 @@ MACRO: with-md5-round ( ops quot -- ) [ d a b c 13 S12 14 ] [ c d a b 14 S13 15 ] [ b c d a 15 S14 16 ] - } [ F ] with-md5-round ; inline + } [ F ] with-md5-round ; : (process-md5-block-G) ( block state -- ) { @@ -126,7 +126,7 @@ MACRO: with-md5-round ( ops quot -- ) [ d a b c 2 S22 30 ] [ c d a b 7 S23 31 ] [ b c d a 12 S24 32 ] - } [ G ] with-md5-round ; inline + } [ G ] with-md5-round ; : (process-md5-block-H) ( block state -- ) { @@ -146,7 +146,7 @@ MACRO: with-md5-round ( ops quot -- ) [ d a b c 12 S32 46 ] [ c d a b 15 S33 47 ] [ b c d a 2 S34 48 ] - } [ H ] with-md5-round ; inline + } [ H ] with-md5-round ; : (process-md5-block-I) ( block state -- ) { @@ -166,7 +166,12 @@ MACRO: with-md5-round ( ops quot -- ) [ d a b c 11 S42 62 ] [ c d a b 2 S43 63 ] [ b c d a 9 S44 64 ] - } [ I ] with-md5-round ; inline + } [ I ] with-md5-round ; + +HINTS: (process-md5-block-F) { uint-array md5-state } ; +HINTS: (process-md5-block-G) { uint-array md5-state } ; +HINTS: (process-md5-block-H) { uint-array md5-state } ; +HINTS: (process-md5-block-I) { uint-array md5-state } ; M: md5-state checksum-block ( block state -- ) [ From 5fd50a4592856bc5b865913be648a997fc9f1b6f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 19 May 2009 18:53:12 -0500 Subject: [PATCH 07/38] make sure you can define words in fhtml templates --- basis/html/templates/fhtml/fhtml-tests.factor | 13 ++++++++++++- basis/html/templates/fhtml/fhtml.factor | 6 ++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/basis/html/templates/fhtml/fhtml-tests.factor b/basis/html/templates/fhtml/fhtml-tests.factor index 55cf90c2dd..427b3215c1 100644 --- a/basis/html/templates/fhtml/fhtml-tests.factor +++ b/basis/html/templates/fhtml/fhtml-tests.factor @@ -1,5 +1,5 @@ USING: io io.files io.streams.string io.encodings.utf8 -html.templates html.templates.fhtml kernel +html.templates html.templates.fhtml kernel multiline tools.test sequences parser splitting prettyprint ; IN: html.templates.fhtml.tests @@ -17,3 +17,14 @@ IN: html.templates.fhtml.tests [ [ ] [ "<%\n%>" parse-template drop ] unit-test ] with-file-vocabs + +[ + [ ] [ + <" + <% + IN: html.templates.fhtml.tests + : test-word ( -- ) ; + %> + "> parse-template drop + ] unit-test +] with-file-vocabs diff --git a/basis/html/templates/fhtml/fhtml.factor b/basis/html/templates/fhtml/fhtml.factor index 6c5e78e917..ceb2e72478 100644 --- a/basis/html/templates/fhtml/fhtml.factor +++ b/basis/html/templates/fhtml/fhtml.factor @@ -4,7 +4,7 @@ USING: continuations sequences kernel namespaces debugger combinators math quotations generic strings splitting accessors assocs fry vocabs.parser parser parser.notes lexer io io.files -io.streams.string io.encodings.utf8 html.templates ; +io.streams.string io.encodings.utf8 html.templates compiler.units ; IN: html.templates.fhtml ! We use a custom lexer so that %> ends a token even if not @@ -58,11 +58,13 @@ SYNTAX: %> lexer get parse-%> ; : parse-template ( string -- quot ) [ + [ "quiet" on parser-notes off "html.templates.fhtml" use-vocab string-lines parse-template-lines - ] with-file-vocabs ; + ] with-file-vocabs + ] with-compilation-unit ; : eval-template ( string -- ) parse-template call( -- ) ; From e18aa54eeb6f7a629de5f46954b68ac054a01111 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 19 May 2009 18:54:56 -0500 Subject: [PATCH 08/38] clean up vim syntax highlighting file, add a few more syntax words --- misc/factor.vim.fgen | 256 +++++++++++++++++++--------------- misc/vim/syntax/factor.vim | 276 +++++++++++++++++++------------------ 2 files changed, 286 insertions(+), 246 deletions(-) diff --git a/misc/factor.vim.fgen b/misc/factor.vim.fgen index b0d61b8dd0..af1e9e600a 100644 --- a/misc/factor.vim.fgen +++ b/misc/factor.vim.fgen @@ -1,15 +1,26 @@ -<% USING: kernel io prettyprint vocabs sequences ; -%>" Vim syntax file -" Language: factor -" Maintainer: Alex Chapman -" Last Change: 2008 Apr 28 +<% +USING: kernel io prettyprint vocabs sequences multiline ; +IN: factor.vim.fgen + +: print-keywords ( vocab -- ) + words [ + "syn keyword factorKeyword " write + [ bl ] [ pprint ] interleave nl + ] when* ; + +%> +" Vim syntax file +" Language: factor +" Maintainer: Alex Chapman +" Last Change: 2009 May 19 +" To run: USE: html.templates.fhtml "resource:misc/factor.vim.fgen" call-template " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded if version < 600 - syntax clear + syntax clear elseif exists("b:current_syntax") - finish + finish endif " factor is case sensitive. @@ -47,25 +58,27 @@ syn keyword factorBoolean boolean f general-t t syn keyword factorCompileDirective inline foldable parsing <% + ! uncomment this if you want all words from all vocabularies highlighted. Note ! that this changes factor.vim from around 8k to around 100k (and is a bit ! broken) -! vocabs [ words [ "syn keyword factorKeyword " write [ pprint " " write ] each "\n" write ] when* ] each +! vocabs [ print-keywords ] each + + { + "kernel" "assocs" "combinators" "math" "sequences" + "namespaces" "arrays" "io" "strings" "vectors" + "continuations" + } [ print-keywords ] each %> -" kernel vocab keywords -<% { "kernel" "assocs" "combinators" "math" "sequences" "namespaces" "arrays" "io" "strings" "vectors" "continuations" } [ - words "syn keyword factorKeyword " write [ pprint " " write ] each "\n" write - ] each %> - -syn cluster factorReal contains=factorInt,factorFloat,factorRatio,factorBinary,factorHex,factorOctal -syn cluster factorNumber contains=@factorReal,factorComplex -syn cluster factorNumErr contains=factorBinErr,factorHexErr,factorOctErr -syn match factorInt /\<-\=\d\+\>/ -syn match factorFloat /\<-\=\d*\.\d\+\>/ -syn match factorRatio /\<-\=\d*\.*\d\+\/-\=\d*\.*\d\+\>/ -syn region factorComplex start=/\/ end=/\<}\>/ contains=@factorReal +syn cluster factorReal contains=factorInt,factorFloat,factorRatio,factorBinary,factorHex,factorOctal +syn cluster factorNumber contains=@factorReal,factorComplex +syn cluster factorNumErr contains=factorBinErr,factorHexErr,factorOctErr +syn match factorInt /\<-\=\d\+\>/ +syn match factorFloat /\<-\=\d*\.\d\+\>/ +syn match factorRatio /\<-\=\d*\.*\d\+\/-\=\d*\.*\d\+\>/ +syn region factorComplex start=/\/ end=/\<}\>/ contains=@factorReal syn match factorBinErr /\/ syn match factorBinary /\/ syn match factorHexErr /\/ @@ -73,31 +86,36 @@ syn match factorHex /\/ syn match factorOctErr /\/ syn match factorOctal /\/ -syn match factorIn /\/ -syn match factorUse /\/ +syn match factorIn /\/ +syn match factorUse /\/ +syn match factorUnuse /\/ -syn match factorCharErr /\/ +syn match factorCharErr /\/ -syn match factorBackslash /\<\\\>\s\+\S\+\>/ +syn match factorBackslash /\<\\\>\s\+\S\+\>/ -syn region factorUsing start=/\/ end=/;/ -syn region factorRequires start=/\/ end=/;/ +syn region factorUsing start=/\/ end=/;/ +syn region factorSingletons start=/\/ end=/;/ +syn match factorSymbol /\/ +syn region factorSymbols start=/\/ end=/;/ +syn region factorConstructor2 start=/\/ end=/\<;\>/ -syn cluster factorWordOps contains=factorSymbol,factorPostpone,factorDefer,factorForget,factorMixin,factorInstance,factorHook,factorMain,factorConstructor -syn match factorSymbol /\/ -syn match factorPostpone /\/ -syn match factorDefer /\/ -syn match factorForget /\/ -syn match factorMixin /\/ -syn match factorInstance /\/ -syn match factorHook /\/ -syn match factorMain /\/ -syn match factorConstructor /\/ +syn match factorConstant /\/ +syn match factorSingleton /\/ +syn match factorPostpone /\/ +syn match factorDefer /\/ +syn match factorForget /\/ +syn match factorMixin /\/ +syn match factorInstance /\/ +syn match factorHook /\/ +syn match factorMain /\/ +syn match factorConstructor /\/ +syn match factorAlien /\/ -syn match factorAlien /\/ +syn cluster factorWordOps contains=factorSymbol,factorPostpone,factorDefer,factorForget,factorMixin,factorInstance,factorHook,factorMain,factorConstructor -syn region factorTuple start=/\/ end=/\<;\>/ "TODO: "misc: @@ -116,6 +134,12 @@ syn region factorTuple start=/\/ end=/\<;\>/ " TYPEDEF: " LIBRARY: " C-UNION: +"QUALIFIED: +"QUALIFIED-WITH: +"FROM: +"ALIAS: +"! POSTPONE: " +"#\ " syn region factorString start=/"/ skip=/\\"/ end=/"/ oneline syn region factorSbuf start=/SBUF" / skip=/\\"/ end=/"/ oneline @@ -165,88 +189,92 @@ syn sync lines=100 if version >= 508 || !exists("did_factor_syn_inits") if version <= 508 - let did_factor_syn_inits = 1 - command -nargs=+ HiLink hi link + let did_factor_syn_inits = 1 + command -nargs=+ HiLink hi link else - command -nargs=+ HiLink hi def link + command -nargs=+ HiLink hi def link endif - HiLink factorComment Comment - HiLink factorStackEffect Typedef - HiLink factorTodo Todo - HiLink factorInclude Include - HiLink factorRepeat Repeat - HiLink factorConditional Conditional - HiLink factorKeyword Keyword - HiLink factorOperator Operator - HiLink factorBoolean Boolean - HiLink factorDefnDelims Typedef - HiLink factorMethodDelims Typedef - HiLink factorGenericDelims Typedef - HiLink factorGenericNDelims Typedef - HiLink factorConstructor Typedef - HiLink factorPrivate Special - HiLink factorPrivateDefnDelims Special - HiLink factorPrivateMethodDelims Special - HiLink factorPGenericDelims Special + HiLink factorComment Comment + HiLink factorStackEffect Typedef + HiLink factorTodo Todo + HiLink factorInclude Include + HiLink factorRepeat Repeat + HiLink factorConditional Conditional + HiLink factorKeyword Keyword + HiLink factorOperator Operator + HiLink factorBoolean Boolean + HiLink factorDefnDelims Typedef + HiLink factorMethodDelims Typedef + HiLink factorGenericDelims Typedef + HiLink factorGenericNDelims Typedef + HiLink factorConstructor Typedef + HiLink factorConstructor2 Typedef + HiLink factorPrivate Special + HiLink factorPrivateDefnDelims Special + HiLink factorPrivateMethodDelims Special + HiLink factorPGenericDelims Special HiLink factorPGenericNDelims Special - HiLink factorString String - HiLink factorSbuf String - HiLink factorMultiStringContents String - HiLink factorMultiStringDelims Typedef - HiLink factorBracketErr Error - HiLink factorComplex Number - HiLink factorRatio Number - HiLink factorBinary Number - HiLink factorBinErr Error - HiLink factorHex Number - HiLink factorHexErr Error - HiLink factorOctal Number - HiLink factorOctErr Error - HiLink factorFloat Float - HiLink factorInt Number - HiLink factorUsing Include - HiLink factorUse Include - HiLink factorRequires Include - HiLink factorIn Define - HiLink factorChar Character - HiLink factorCharErr Error - HiLink factorDelimiter Delimiter - HiLink factorBackslash Special - HiLink factorCompileDirective Typedef - HiLink factorSymbol Define - HiLink factorMixin Typedef - HiLink factorInstance Typedef - HiLink factorHook Typedef - HiLink factorMain Define - HiLink factorPostpone Define - HiLink factorDefer Define - HiLink factorForget Define - HiLink factorAlien Define - HiLink factorTuple Typedef + HiLink factorString String + HiLink factorSbuf String + HiLink factorMultiStringContents String + HiLink factorMultiStringDelims Typedef + HiLink factorBracketErr Error + HiLink factorComplex Number + HiLink factorRatio Number + HiLink factorBinary Number + HiLink factorBinErr Error + HiLink factorHex Number + HiLink factorHexErr Error + HiLink factorOctal Number + HiLink factorOctErr Error + HiLink factorFloat Float + HiLink factorInt Number + HiLink factorUsing Include + HiLink factorUse Include + HiLink factorUnuse Include + HiLink factorIn Define + HiLink factorChar Character + HiLink factorCharErr Error + HiLink factorDelimiter Delimiter + HiLink factorBackslash Special + HiLink factorCompileDirective Typedef + HiLink factorSymbol Define + HiLink factorConstant Define + HiLink factorSingleton Define + HiLink factorSingletons Define + HiLink factorMixin Typedef + HiLink factorInstance Typedef + HiLink factorHook Typedef + HiLink factorMain Define + HiLink factorPostpone Define + HiLink factorDefer Define + HiLink factorForget Define + HiLink factorAlien Define + HiLink factorTuple Typedef if &bg == "dark" - hi hlLevel0 ctermfg=red guifg=red1 - hi hlLevel1 ctermfg=yellow guifg=orange1 - hi hlLevel2 ctermfg=green guifg=yellow1 - hi hlLevel3 ctermfg=cyan guifg=greenyellow - hi hlLevel4 ctermfg=magenta guifg=green1 - hi hlLevel5 ctermfg=red guifg=springgreen1 - hi hlLevel6 ctermfg=yellow guifg=cyan1 - hi hlLevel7 ctermfg=green guifg=slateblue1 - hi hlLevel8 ctermfg=cyan guifg=magenta1 - hi hlLevel9 ctermfg=magenta guifg=purple1 + hi hlLevel0 ctermfg=red guifg=red1 + hi hlLevel1 ctermfg=yellow guifg=orange1 + hi hlLevel2 ctermfg=green guifg=yellow1 + hi hlLevel3 ctermfg=cyan guifg=greenyellow + hi hlLevel4 ctermfg=magenta guifg=green1 + hi hlLevel5 ctermfg=red guifg=springgreen1 + hi hlLevel6 ctermfg=yellow guifg=cyan1 + hi hlLevel7 ctermfg=green guifg=slateblue1 + hi hlLevel8 ctermfg=cyan guifg=magenta1 + hi hlLevel9 ctermfg=magenta guifg=purple1 else - hi hlLevel0 ctermfg=red guifg=red3 - hi hlLevel1 ctermfg=darkyellow guifg=orangered3 - hi hlLevel2 ctermfg=darkgreen guifg=orange2 - hi hlLevel3 ctermfg=blue guifg=yellow3 - hi hlLevel4 ctermfg=darkmagenta guifg=olivedrab4 - hi hlLevel5 ctermfg=red guifg=green4 - hi hlLevel6 ctermfg=darkyellow guifg=paleturquoise3 - hi hlLevel7 ctermfg=darkgreen guifg=deepskyblue4 - hi hlLevel8 ctermfg=blue guifg=darkslateblue - hi hlLevel9 ctermfg=darkmagenta guifg=darkviolet + hi hlLevel0 ctermfg=red guifg=red3 + hi hlLevel1 ctermfg=darkyellow guifg=orangered3 + hi hlLevel2 ctermfg=darkgreen guifg=orange2 + hi hlLevel3 ctermfg=blue guifg=yellow3 + hi hlLevel4 ctermfg=darkmagenta guifg=olivedrab4 + hi hlLevel5 ctermfg=red guifg=green4 + hi hlLevel6 ctermfg=darkyellow guifg=paleturquoise3 + hi hlLevel7 ctermfg=darkgreen guifg=deepskyblue4 + hi hlLevel8 ctermfg=blue guifg=darkslateblue + hi hlLevel9 ctermfg=darkmagenta guifg=darkviolet endif delcommand HiLink diff --git a/misc/vim/syntax/factor.vim b/misc/vim/syntax/factor.vim index 7d847c7238..86f4f19147 100755 --- a/misc/vim/syntax/factor.vim +++ b/misc/vim/syntax/factor.vim @@ -1,14 +1,15 @@ " Vim syntax file -" Language: factor -" Maintainer: Alex Chapman -" Last Change: 2008 Apr 28 +" Language: factor +" Maintainer: Alex Chapman +" Last Change: 2009 May 19 +" To run: USE: html.templates.fhtml "resource:misc/factor.vim.fgen" call-template " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded if version < 600 - syntax clear + syntax clear elseif exists("b:current_syntax") - finish + finish endif " factor is case sensitive. @@ -45,29 +46,26 @@ syn region None matchgroup=factorPrivate start=/\</ end=/\\>/ syn keyword factorBoolean boolean f general-t t syn keyword factorCompileDirective inline foldable parsing +syn keyword factorKeyword or tuck 2bi 2tri while wrapper nip 4dip wrapper? bi* callstack>array both? hashcode die dupd callstack callstack? 3dup tri@ pick curry build ?execute 3bi prepose >boolean ?if clone eq? tri* ? = swapd call-clear 2over 2keep 3keep clear 2dup when not tuple? dup 2bi* 2tri* call tri-curry object bi@ do unless* if* loop bi-curry* drop when* assert= retainstack assert? -rot execute 2bi@ 2tri@ boa with either? 3drop bi curry? datastack until 3dip over 3curry roll tri-curry* swap tri-curry@ 2nip and throw set-retainstack bi-curry (clone) hashcode* compose spin 2dip if 3tri unless compose? tuple keep 2curry equal? set-datastack assert tri 2drop most boolean? identity-tuple? null new set-callstack dip bi-curry@ rot -roll xor identity-tuple boolean +syn keyword factorKeyword ?at assoc? assoc-clone-like assoc= delete-at* assoc-partition extract-keys new-assoc value? assoc-size map>assoc push-at assoc-like key? assoc-intersect update assoc-union assoc-combine at* assoc-empty? at+ set-at assoc-all? assoc-subset? assoc-hashcode change-at assoc-each assoc-diff zip values value-at rename-at inc-at enum? at cache assoc>map assoc assoc-map enum value-at* remove-all assoc-map-as >alist assoc-filter-as substitute-here clear-assoc assoc-stack substitute assoc-filter 2cache delete-at assoc-find keys assoc-any? at-default unzip +syn keyword factorKeyword case execute-effect dispatch-case-quot no-cond no-case? 3cleave>quot contiguous-range? 2cleave cond>quot wrong-values? no-cond? cleave>quot no-case hash-dispatch-quot case>quot 3cleave wrong-values alist>quot hash-case-table hash-case-quot case-find (distribute-buckets) cond cleave distribute-buckets call-effect 2cleave>quot recursive-hashcode linear-case-quot spread spread>quot +syn keyword factorKeyword byte-array>bignum sgn >bignum next-float number= each-integer next-power-of-2 ?1+ fp-special? imaginary-part mod recip float>bits rational >float number? 2^ bignum? integer fixnum? neg fixnum sq bignum fp-snan? fp-infinity? denominator (all-integers?) times find-last-integer (each-integer) bit? * + fp-bitwise= - fp-qnan? / power-of-2? >= bitand find-integer complex < log2 > integer? real number bits>double double>bits bitor 2/ zero? rem fp-nan-payload all-integers? (find-integer) real-part prev-float align bits>float float? shift float 1+ 1- fp-nan? abs bitxor ratio? even? <= /mod odd? >integer ratio rational? bitnot real? >fixnum complex? /i numerator /f +syn keyword factorKeyword append assert-sequence= find-last-from trim-head-slice clone-like 3sequence assert-sequence? map-as filter-here last-index-from prepare-index reversed index-from cut* pad-tail (indices) concat-as remq but-last snip trim-tail nths nth 2pusher sequence slice? partition remove-nth tail-slice empty? tail* if-empty find-from virtual-sequence? member? set-length delq drop-prefix unclip iota unclip-last-slice bounds-error? sequence-hashcode-step map start midpoint@ rest-slice prepend fourth sift delete sigma new-sequence follow like delete-nth first4 1sequence reverse slice unless-empty padding virtual@ repetition? index 4sequence max-length set-second immutable-sequence first2 first3 replicate-as reduce-index unclip-slice supremum insert-nth trim-tail-slice tail 3append short count suffix concat flip filter sum immutable? 2sequence delete-all start* indices snip-slice check-slice sequence? head map-find reduce append-as reverse-here sequence= halves collapse-slice interleave 2map binary-reduce virtual-seq slice-error? product bounds-check? bounds-check harvest immutable find produce remove pad-head replicate set-fourth peek shorten reversed? map-find-last 3map-as 2unclip-slice shorter? 3map find-last head-slice pop* 2map-as tail-slice* but-last-slice 2map-reduce iota? accumulate each pusher cut-slice new-resizable each-index head-slice* 2reverse-each sequence-hashcode memq? pop set-nth ?nth second change-each join when-empty accumulator immutable-sequence? all? 3append-as virtual-sequence subseq? push-either new-like length last-index push-if 2all? lengthen assert-sequence copy map-reduce move third first 3each tail? set-first prefix bounds-error any? trim-slice exchange surround 2reduce cut change-nth min-length set-third produce-as push-all head? delete-slice rest sum-lengths 2each head* infimum glue slice-error subseq replace-slice push repetition map-index trim-head unclip-last mismatch trim +syn keyword factorKeyword global +@ change set-namestack change-global init-namespaces on off set-global namespace set with-scope bind with-variable inc dec counter initialize namestack get get-global make-assoc +syn keyword factorKeyword 2array 3array pair >array 1array 4array pair? array resize-array array? +syn keyword factorKeyword +character+ bad-seek-type? readln stream-seek read print with-output-stream contents write1 stream-write1 stream-copy stream-element-type with-input-stream stream-print stream-read stream-contents bl seek-output bad-seek-type nl stream-nl write flush stream-lines +byte+ stream-flush read1 seek-absolute? stream-read1 lines stream-readln stream-read-until each-line seek-end with-output-stream* seek-absolute with-streams seek-input seek-relative? input-stream stream-write read-partial seek-end? seek-relative error-stream read-until with-input-stream* with-streams* each-block output-stream stream-read-partial +syn keyword factorKeyword resize-string >string 1string string string? +syn keyword factorKeyword vector? ?push vector >vector 1vector +syn keyword factorKeyword with-return restarts return-continuation with-datastack recover rethrow-restarts ifcc set-catchstack >continuation< cleanup ignore-errors restart? compute-restarts attempt-all-error error-thread continue attempt-all-error? condition? throw-restarts error catchstack continue-with thread-error-hook continuation rethrow callcc1 error-continuation callcc0 attempt-all condition continuation? restart return -" kernel vocab keywords -syn keyword factorKeyword or construct-delegate set-slots tuck 2bi 2tri while wrapper nip bi* wrapper? hashcode callstack>array both? die set-delegate dupd callstack callstack? 3dup tri@ pick curry build prepose 3bi >boolean ?if clone eq? tri* ? = swapd call-clear 2over 2keep 3keep construct clear 2dup when not tuple? 3compose dup 2bi* call object bi@ wrapped unless* if* >r curry-quot drop when* retainstack -rot 2bi@ delegate boa with 3slip slip compose-first compose-second 3drop either? bi curry? datastack curry-obj over 3curry roll throw swap and 2nip set-retainstack (clone) hashcode* get-slots compose spin if 3tri unless compose? tuple keep 2curry equal? set-datastack 2slip tri 2drop most identity-tuple? null r> new set-callstack dip xor rot -roll identity-tuple -syn keyword factorKeyword assoc? assoc-clone-like delete-any assoc= delete-at* new-assoc subassoc? assoc-size map>assoc search-alist assoc-like key? assoc-intersect update assoc-union at* assoc-empty? at+ set-enum-seq set-at assoc-all? assoc-hashcode change-at assoc-each assoc-diff zip values value-at rename-at (assoc-stack) enum? at cache assoc>map assoc-any? assoc assoc-map assoc-pusher (assoc>map) enum assoc-push-if remove-all >alist (substitute) substitute-here clear-assoc assoc-stack substitute assoc-filter delete-at assoc-find enum-seq keys -syn keyword factorKeyword case dispatch-case-quot with-datastack no-cond no-case? 3cleave>quot (distribute-buckets) contiguous-range? 2cleave cond>quot no-cond? cleave>quot no-case recursive-hashcode case>quot 3cleave alist>quot dispatch-case hash-case-table hash-case-quot case-find cond cleave distribute-buckets 2cleave>quot linear-case-quot spread spread>quot hash-dispatch-quot -syn keyword factorKeyword byte-array>bignum sgn >bignum number= each-integer next-power-of-2 ?1+ imaginary-part mod recip float>bits rational >float number? 2^ bignum? integer fixnum? neg fixnum sq bignum (all-integers?) times denominator find-last-integer (each-integer) bit? * + power-of-2? - / >= bitand find-integer complex < real > log2 integer? number bits>double double>bits bitor 2/ zero? rem all-integers? (find-integer) real-part align bits>float float? shift float 1+ 1- fp-nan? ratio? bitxor even? ratio <= /mod >integer odd? rational? bitnot real? >fixnum complex? (next-power-of-2) /i numerator /f -syn keyword factorKeyword slice-to append left-trim find-last-from clone-like 3sequence map-as last-index-from reversed index-from pad-left cut* nth sequence slice? tail-slice empty? tail* find-from member? virtual-sequence? unclip set-length drop-prefix bounds-error? set-slice-seq map start open-slice midpoint@ set-immutable-seq move-forward rest-slice prepend fourth delete set-slice-to new-sequence follow all-eq? monotonic? set-reversed-seq like delete-nth first4 repetition-len (open-slice) reverse slice padding virtual@ repetition? index 4sequence max-length set-second first2 first3 (3append) supremum unclip-slice move-backward tail 3append sequence-hashcode-step right-trim reversed-seq pad-right suffix concat set-slice-from flip filter sum immutable? 2sequence delete-all start* immutable-sequence? (append) check-slice sequence? head set-slice-error-reason reduce set-bounds-error-index reverse-here sequence= halves collapse-slice interleave 2map binary-reduce virtual-seq slice-error? product bounds-check? bounds-check immutable find remove ((append)) set-fourth peek any? reversed? shorter? push-new find-last head-slice pop* immutable-seq tail-slice* accumulate each pusher all-equal? new-resizable cut-slice head-slice* 2reverse-each pop memq? set-nth ?nth second change-each join set-repetition-len all? virtual-sequence set-repetition-elt subseq? immutable-sequence slice-error-reason new-like length last-index push-if 2all? lengthen joined-length copy set-bounds-error-seq cache-nth move third first slice-from repetition-elt tail? set-first prefix bounds-error bounds-error-seq bounds-error-index unfold exchange slice-seq cut 2reduce change-nth min-length set-third (delete) push-all head? delete-slice rest sum-lengths 2each head* infimum sequence-hashcode slice-error subseq replace-slice repetition push trim mismatch -syn keyword factorKeyword global +@ set-namestack with-variable on set bind dec namestack get get-global change init-namespaces with-scope off set-global namespace % make , inc counter building make-assoc -syn keyword factorKeyword 3array >array 4array pair? array pair 2array 1array resize-array array? -syn keyword factorKeyword readln stream-read-until stream-read-partial stderr with-stream read with-stream* print contents make-span-stream write1 stream-write1 stream-format make-block-stream stream-copy with-cell stream-write format with-row stream-print stream-read with-nesting (stream-copy) bl write-object nl stream-nl write stdio flush read-until tabular-output make-cell-stream write-cell stream-flush read1 lines stream-read1 stream-write-table with-style stream-readln -syn keyword factorKeyword resize-string >string 1string string string? -syn keyword factorKeyword vector? ?push vector >vector 1vector -syn keyword factorKeyword rethrow-restarts restarts recover set-restart-name set-continuation-name condition-continuation ifcc continuation-name condition-error set-restart-continuation ignore-errors continuation-retain continue restart-continuation with-disposal set-continuation-catch set-condition-error restart-obj error thread-error-hook set-continuation-retain continuation rethrow callcc1 callcc0 condition continuation? continuation-call continuation-data set-condition-restarts set-catchstack >continuation< error-continuation cleanup restart? compute-restarts condition? error-thread set-continuation-call set-condition-continuation set-restart-obj dispose set-continuation-data throw-restarts catchstack continue-with attempt-all restart restart-name continuation-catch condition-restarts - - -syn cluster factorReal contains=factorInt,factorFloat,factorRatio,factorBinary,factorHex,factorOctal -syn cluster factorNumber contains=@factorReal,factorComplex -syn cluster factorNumErr contains=factorBinErr,factorHexErr,factorOctErr -syn match factorInt /\<-\=\d\+\>/ -syn match factorFloat /\<-\=\d*\.\d\+\>/ -syn match factorRatio /\<-\=\d*\.*\d\+\/-\=\d*\.*\d\+\>/ -syn region factorComplex start=/\/ end=/\<}\>/ contains=@factorReal +syn cluster factorReal contains=factorInt,factorFloat,factorRatio,factorBinary,factorHex,factorOctal +syn cluster factorNumber contains=@factorReal,factorComplex +syn cluster factorNumErr contains=factorBinErr,factorHexErr,factorOctErr +syn match factorInt /\<-\=\d\+\>/ +syn match factorFloat /\<-\=\d*\.\d\+\>/ +syn match factorRatio /\<-\=\d*\.*\d\+\/-\=\d*\.*\d\+\>/ +syn region factorComplex start=/\/ end=/\<}\>/ contains=@factorReal syn match factorBinErr /\/ syn match factorBinary /\/ syn match factorHexErr /\/ @@ -75,31 +73,36 @@ syn match factorHex /\/ syn match factorOctErr /\/ syn match factorOctal /\/ -syn match factorIn /\/ -syn match factorUse /\/ +syn match factorIn /\/ +syn match factorUse /\/ +syn match factorUnuse /\/ -syn match factorCharErr /\/ +syn match factorCharErr /\/ -syn match factorBackslash /\<\\\>\s\+\S\+\>/ +syn match factorBackslash /\<\\\>\s\+\S\+\>/ -syn region factorUsing start=/\/ end=/;/ -syn region factorRequires start=/\/ end=/;/ +syn region factorUsing start=/\/ end=/;/ +syn region factorSingletons start=/\/ end=/;/ +syn match factorSymbol /\/ +syn region factorSymbols start=/\/ end=/;/ +syn region factorConstructor2 start=/\/ end=/\<;\>/ -syn cluster factorWordOps contains=factorSymbol,factorPostpone,factorDefer,factorForget,factorMixin,factorInstance,factorHook,factorMain,factorConstructor -syn match factorSymbol /\/ -syn match factorPostpone /\/ -syn match factorDefer /\/ -syn match factorForget /\/ -syn match factorMixin /\/ -syn match factorInstance /\/ -syn match factorHook /\/ -syn match factorMain /\/ -syn match factorConstructor /\/ +syn match factorConstant /\/ +syn match factorSingleton /\/ +syn match factorPostpone /\/ +syn match factorDefer /\/ +syn match factorForget /\/ +syn match factorMixin /\/ +syn match factorInstance /\/ +syn match factorHook /\/ +syn match factorMain /\/ +syn match factorConstructor /\/ +syn match factorAlien /\/ -syn match factorAlien /\/ +syn cluster factorWordOps contains=factorSymbol,factorPostpone,factorDefer,factorForget,factorMixin,factorInstance,factorHook,factorMain,factorConstructor -syn region factorTuple start=/\/ end=/\<;\>/ "TODO: "misc: @@ -118,6 +121,12 @@ syn region factorTuple start=/\/ end=/\<;\>/ " TYPEDEF: " LIBRARY: " C-UNION: +"QUALIFIED: +"QUALIFIED-WITH: +"FROM: +"ALIAS: +"! POSTPONE: " +"#\ " syn region factorString start=/"/ skip=/\\"/ end=/"/ oneline syn region factorSbuf start=/SBUF" / skip=/\\"/ end=/"/ oneline @@ -131,18 +140,18 @@ syn region factorStackEffect start=/\<(\>/ end=/\<)\>/ contained "adapted from lisp.vim if exists("g:factor_norainbow") - syn region factorQuotation0 matchgroup=factorDelimiter start=/\<\'\?\[\>/ matchgroup=factorDelimiter end=/\<\]\>/ contains=ALL + syn region factorQuotation matchgroup=factorDelimiter start=/\<\[\>/ matchgroup=factorDelimiter end=/\<\]\>/ contains=ALL else - syn region factorQuotation0 matchgroup=hlLevel0 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1 - syn region factorQuotation1 contained matchgroup=hlLevel1 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation2,factorArray2 - syn region factorQuotation2 contained matchgroup=hlLevel2 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation3,factorArray3 - syn region factorQuotation3 contained matchgroup=hlLevel3 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation4,factorArray4 - syn region factorQuotation4 contained matchgroup=hlLevel4 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation5,factorArray5 - syn region factorQuotation5 contained matchgroup=hlLevel5 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation6,factorArray6 - syn region factorQuotation6 contained matchgroup=hlLevel6 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation7,factorArray7 - syn region factorQuotation7 contained matchgroup=hlLevel7 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation8,factorArray8 - syn region factorQuotation8 contained matchgroup=hlLevel8 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation9,factorArray9 - syn region factorQuotation9 contained matchgroup=hlLevel9 start=/\<\'\?\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation0,factorArray0 + syn region factorQuotation0 matchgroup=hlLevel0 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation1,factorArray1 + syn region factorQuotation1 contained matchgroup=hlLevel1 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation2,factorArray2 + syn region factorQuotation2 contained matchgroup=hlLevel2 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation3,factorArray3 + syn region factorQuotation3 contained matchgroup=hlLevel3 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation4,factorArray4 + syn region factorQuotation4 contained matchgroup=hlLevel4 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation5,factorArray5 + syn region factorQuotation5 contained matchgroup=hlLevel5 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation6,factorArray6 + syn region factorQuotation6 contained matchgroup=hlLevel6 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation7,factorArray7 + syn region factorQuotation7 contained matchgroup=hlLevel7 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation8,factorArray8 + syn region factorQuotation8 contained matchgroup=hlLevel8 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation9,factorArray9 + syn region factorQuotation9 contained matchgroup=hlLevel9 start=/\<\[\>/ end=/\<\]\>/ contains=@factorCluster,factorQuotation0,factorArray0 endif if exists("g:factor_norainbow") @@ -167,88 +176,92 @@ syn sync lines=100 if version >= 508 || !exists("did_factor_syn_inits") if version <= 508 - let did_factor_syn_inits = 1 - command -nargs=+ HiLink hi link + let did_factor_syn_inits = 1 + command -nargs=+ HiLink hi link else - command -nargs=+ HiLink hi def link + command -nargs=+ HiLink hi def link endif - HiLink factorComment Comment - HiLink factorStackEffect Typedef - HiLink factorTodo Todo - HiLink factorInclude Include - HiLink factorRepeat Repeat - HiLink factorConditional Conditional - HiLink factorKeyword Keyword - HiLink factorOperator Operator - HiLink factorBoolean Boolean - HiLink factorDefnDelims Typedef - HiLink factorMethodDelims Typedef - HiLink factorGenericDelims Typedef - HiLink factorGenericNDelims Typedef - HiLink factorConstructor Typedef - HiLink factorPrivate Special - HiLink factorPrivateDefnDelims Special - HiLink factorPrivateMethodDelims Special - HiLink factorPGenericDelims Special + HiLink factorComment Comment + HiLink factorStackEffect Typedef + HiLink factorTodo Todo + HiLink factorInclude Include + HiLink factorRepeat Repeat + HiLink factorConditional Conditional + HiLink factorKeyword Keyword + HiLink factorOperator Operator + HiLink factorBoolean Boolean + HiLink factorDefnDelims Typedef + HiLink factorMethodDelims Typedef + HiLink factorGenericDelims Typedef + HiLink factorGenericNDelims Typedef + HiLink factorConstructor Typedef + HiLink factorConstructor2 Typedef + HiLink factorPrivate Special + HiLink factorPrivateDefnDelims Special + HiLink factorPrivateMethodDelims Special + HiLink factorPGenericDelims Special HiLink factorPGenericNDelims Special - HiLink factorString String - HiLink factorSbuf String - HiLink factorMultiStringContents String - HiLink factorMultiStringDelims Typedef - HiLink factorBracketErr Error - HiLink factorComplex Number - HiLink factorRatio Number - HiLink factorBinary Number - HiLink factorBinErr Error - HiLink factorHex Number - HiLink factorHexErr Error - HiLink factorOctal Number - HiLink factorOctErr Error - HiLink factorFloat Float - HiLink factorInt Number - HiLink factorUsing Include - HiLink factorUse Include - HiLink factorRequires Include - HiLink factorIn Define - HiLink factorChar Character - HiLink factorCharErr Error - HiLink factorDelimiter Delimiter - HiLink factorBackslash Special - HiLink factorCompileDirective Typedef - HiLink factorSymbol Define - HiLink factorMixin Typedef - HiLink factorInstance Typedef - HiLink factorHook Typedef - HiLink factorMain Define - HiLink factorPostpone Define - HiLink factorDefer Define - HiLink factorForget Define - HiLink factorAlien Define - HiLink factorTuple Typedef + HiLink factorString String + HiLink factorSbuf String + HiLink factorMultiStringContents String + HiLink factorMultiStringDelims Typedef + HiLink factorBracketErr Error + HiLink factorComplex Number + HiLink factorRatio Number + HiLink factorBinary Number + HiLink factorBinErr Error + HiLink factorHex Number + HiLink factorHexErr Error + HiLink factorOctal Number + HiLink factorOctErr Error + HiLink factorFloat Float + HiLink factorInt Number + HiLink factorUsing Include + HiLink factorUse Include + HiLink factorUnuse Include + HiLink factorIn Define + HiLink factorChar Character + HiLink factorCharErr Error + HiLink factorDelimiter Delimiter + HiLink factorBackslash Special + HiLink factorCompileDirective Typedef + HiLink factorSymbol Define + HiLink factorConstant Define + HiLink factorSingleton Define + HiLink factorSingletons Define + HiLink factorMixin Typedef + HiLink factorInstance Typedef + HiLink factorHook Typedef + HiLink factorMain Define + HiLink factorPostpone Define + HiLink factorDefer Define + HiLink factorForget Define + HiLink factorAlien Define + HiLink factorTuple Typedef if &bg == "dark" - hi hlLevel0 ctermfg=red guifg=red1 - hi hlLevel1 ctermfg=yellow guifg=orange1 - hi hlLevel2 ctermfg=green guifg=yellow1 - hi hlLevel3 ctermfg=cyan guifg=greenyellow - hi hlLevel4 ctermfg=magenta guifg=green1 - hi hlLevel5 ctermfg=red guifg=springgreen1 - hi hlLevel6 ctermfg=yellow guifg=cyan1 - hi hlLevel7 ctermfg=green guifg=slateblue1 - hi hlLevel8 ctermfg=cyan guifg=magenta1 - hi hlLevel9 ctermfg=magenta guifg=purple1 + hi hlLevel0 ctermfg=red guifg=red1 + hi hlLevel1 ctermfg=yellow guifg=orange1 + hi hlLevel2 ctermfg=green guifg=yellow1 + hi hlLevel3 ctermfg=cyan guifg=greenyellow + hi hlLevel4 ctermfg=magenta guifg=green1 + hi hlLevel5 ctermfg=red guifg=springgreen1 + hi hlLevel6 ctermfg=yellow guifg=cyan1 + hi hlLevel7 ctermfg=green guifg=slateblue1 + hi hlLevel8 ctermfg=cyan guifg=magenta1 + hi hlLevel9 ctermfg=magenta guifg=purple1 else - hi hlLevel0 ctermfg=red guifg=red3 - hi hlLevel1 ctermfg=darkyellow guifg=orangered3 - hi hlLevel2 ctermfg=darkgreen guifg=orange2 - hi hlLevel3 ctermfg=blue guifg=yellow3 - hi hlLevel4 ctermfg=darkmagenta guifg=olivedrab4 - hi hlLevel5 ctermfg=red guifg=green4 - hi hlLevel6 ctermfg=darkyellow guifg=paleturquoise3 - hi hlLevel7 ctermfg=darkgreen guifg=deepskyblue4 - hi hlLevel8 ctermfg=blue guifg=darkslateblue - hi hlLevel9 ctermfg=darkmagenta guifg=darkviolet + hi hlLevel0 ctermfg=red guifg=red3 + hi hlLevel1 ctermfg=darkyellow guifg=orangered3 + hi hlLevel2 ctermfg=darkgreen guifg=orange2 + hi hlLevel3 ctermfg=blue guifg=yellow3 + hi hlLevel4 ctermfg=darkmagenta guifg=olivedrab4 + hi hlLevel5 ctermfg=red guifg=green4 + hi hlLevel6 ctermfg=darkyellow guifg=paleturquoise3 + hi hlLevel7 ctermfg=darkgreen guifg=deepskyblue4 + hi hlLevel8 ctermfg=blue guifg=darkslateblue + hi hlLevel9 ctermfg=darkmagenta guifg=darkviolet endif delcommand HiLink @@ -262,4 +275,3 @@ set expandtab set autoindent " annoying? " vim: syntax=vim - From c505c6f261183ba56a366a7782190373ef412062 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 20 May 2009 10:26:24 -0500 Subject: [PATCH 09/38] clean up some GL state mgmt in spheres --- extra/spheres/spheres.factor | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/extra/spheres/spheres.factor b/extra/spheres/spheres.factor index 1a8f41b4a2..b07b7a5ad1 100755 --- a/extra/spheres/spheres.factor +++ b/extra/spheres/spheres.factor @@ -3,7 +3,6 @@ opengl.shaders opengl.framebuffers opengl.capabilities multiline ui.gadgets accessors sequences ui.render ui math locals arrays generalizations combinators ui.gadgets.worlds literals ui.pixel-formats ; -FROM: opengl.demo-support => rect-vertices ; IN: spheres STRING: plane-vertex-shader @@ -117,11 +116,11 @@ TUPLE: spheres-world < demo-world reflection-framebuffer reflection-depthbuffer reflection-texture ; -M: spheres-world near-plane ( gadget -- z ) +M: spheres-world near-plane drop 1.0 ; -M: spheres-world far-plane ( gadget -- z ) +M: spheres-world far-plane drop 512.0 ; -M: spheres-world distance-step ( gadget -- dz ) +M: spheres-world distance-step drop 0.5 ; : (reflection-dim) ( -- w h ) @@ -175,6 +174,9 @@ M: spheres-world distance-step ( gadget -- dz ) M: spheres-world begin-world "2.0" { "GL_ARB_shader_objects" } require-gl-version-or-extensions { "GL_EXT_framebuffer_object" } require-gl-extensions + GL_DEPTH_TEST glEnable + GL_VERTEX_ARRAY glEnableClientState + 0.15 0.15 1.0 1.0 glClearColor 20.0 10.0 20.0 set-demo-orientation (plane-program) >>plane-program (solid-sphere-program) >>solid-sphere-program @@ -194,13 +196,13 @@ M: spheres-world end-world [ plane-program>> [ delete-gl-program ] when* ] } cleave ; -M: spheres-world pref-dim* ( gadget -- dim ) +M: spheres-world pref-dim* drop { 640 480 } ; :: (draw-sphere) ( program center radius -- ) program "center" glGetAttribLocation center first3 glVertexAttrib3f program "radius" glGetAttribLocation radius glVertexAttrib1f - { -1.0 -1.0 } { 1.0 1.0 } rect-vertices ; + { -1.0 -1.0 } { 2.0 2.0 } gl-fill-rect ; :: (draw-colored-sphere) ( program center radius surfacecolor -- ) program "surface_color" glGetAttribLocation surfacecolor first4 glVertexAttrib4f @@ -283,9 +285,7 @@ M: spheres-world pref-dim* ( gadget -- dim ) } cleave ] with-framebuffer ; M: spheres-world draw-world* - GL_DEPTH_TEST glEnable - GL_SCISSOR_TEST glDisable - 0.15 0.15 1.0 1.0 glClearColor { + { [ (draw-reflection-texture) ] [ demo-world-set-matrix ] [ sphere-scene ] From b73c8a06197a8881ca17264885fd1568cf2a4c03 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 20 May 2009 10:26:55 -0500 Subject: [PATCH 10/38] vector bilerp word --- basis/math/vectors/vectors.factor | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/basis/math/vectors/vectors.factor b/basis/math/vectors/vectors.factor index bad2733bbf..0fe1404516 100644 --- a/basis/math/vectors/vectors.factor +++ b/basis/math/vectors/vectors.factor @@ -58,6 +58,10 @@ IN: math.vectors : vnlerp ( a b t -- a_t ) [ lerp ] curry 2map ; +: vbilerp ( aa ba ab bb {t,u} -- a_tu ) + [ first vnlerp ] [ second vnlerp ] bi-curry + [ 2bi@ ] [ call ] bi* ; + HINTS: vneg { array } ; HINTS: norm-sq { array } ; HINTS: norm { array } ; From 8f688eb742a12522e9ed94f038fca89cae13fc7f Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 20 May 2009 15:50:01 -0500 Subject: [PATCH 11/38] fix comments and dtds in html parser --- extra/html/parser/parser-tests.factor | 23 +++++++++++++++++++++++ extra/html/parser/parser.factor | 8 +++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/extra/html/parser/parser-tests.factor b/extra/html/parser/parser-tests.factor index ca276fc54e..2876d03b16 100644 --- a/extra/html/parser/parser-tests.factor +++ b/extra/html/parser/parser-tests.factor @@ -73,3 +73,26 @@ V{ T{ tag f "head" H{ } f t } } ] [ "Spagna" + parse-html +] unit-test + +[ +V{ + T{ tag { name comment } { text "comment" } } +} +] [ + "" parse-html +] unit-test diff --git a/extra/html/parser/parser.factor b/extra/html/parser/parser.factor index d95c79dd88..948bd0c954 100644 --- a/extra/html/parser/parser.factor +++ b/extra/html/parser/parser.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays hashtables sequence-parser -html.parser.utils kernel namespaces sequences +html.parser.utils kernel namespaces sequences math unicode.case unicode.categories combinators.short-circuit quoting fry ; IN: html.parser @@ -63,10 +63,12 @@ SYMBOL: tagstack [ blank? ] trim ; : read-comment ( sequence-parser -- ) - "-->" take-until-sequence comment new-tag push-tag ; + [ "-->" take-until-sequence comment new-tag push-tag ] + [ '[ _ advance drop ] 3 swap times ] bi ; : read-dtd ( sequence-parser -- ) - ">" take-until-sequence dtd new-tag push-tag ; + [ ">" take-until-sequence dtd new-tag push-tag ] + [ advance drop ] bi ; : read-bang ( sequence-parser -- ) advance dup { [ current CHAR: - = ] [ peek-next CHAR: - = ] } 1&& From 0c05f5f3292f461c21ac239deeed9d4c5de1b797 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 20 May 2009 18:51:01 -0500 Subject: [PATCH 12/38] windows.advapi32: add windows.kernel32 dependency --- basis/windows/advapi32/advapi32.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 basis/windows/advapi32/advapi32.factor diff --git a/basis/windows/advapi32/advapi32.factor b/basis/windows/advapi32/advapi32.factor old mode 100644 new mode 100755 index fd037cb2a0..1ba08e657b --- a/basis/windows/advapi32/advapi32.factor +++ b/basis/windows/advapi32/advapi32.factor @@ -1,4 +1,5 @@ -USING: alien.syntax kernel math windows.types math.bitwise ; +USING: alien.syntax kernel math windows.types windows.kernel32 +math.bitwise ; IN: windows.advapi32 LIBRARY: advapi32 From 610b276c861cd67522becc2484e18d7863dd84ce Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 20 May 2009 18:52:21 -0500 Subject: [PATCH 13/38] callstack>array primitive was not GC safe --- vm/callstack.cpp | 36 +++++++++++++++++------------------- vm/callstack.hpp | 14 ++++++++++++-- vm/layouts.hpp | 5 +++++ 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/vm/callstack.cpp b/vm/callstack.cpp index 608a5c39e5..38fb1e2b33 100755 --- a/vm/callstack.cpp +++ b/vm/callstack.cpp @@ -107,8 +107,9 @@ stack_frame *frame_successor(stack_frame *frame) /* Allocates memory */ cell frame_scan(stack_frame *frame) { - if(frame_type(frame) == QUOTATION_TYPE) + switch(frame_type(frame)) { + case QUOTATION_TYPE: cell quot = frame_executing(frame); if(quot == F) return F; @@ -120,28 +121,27 @@ cell frame_scan(stack_frame *frame) return tag_fixnum(quot_code_offset_to_scan( quot,(cell)(return_addr - quot_xt))); } - } - else + case WORD_TYPE: return F; + default: + critical_error("Bad frame type",frame_type(frame)); + return F; + } } namespace { -struct stack_frame_counter { - cell count; - stack_frame_counter() : count(0) {} - void operator()(stack_frame *frame) { count += 2; } -}; - struct stack_frame_accumulator { - cell index; - gc_root frames; - stack_frame_accumulator(cell count) : index(0), frames(allot_array(count,F)) {} + growable_array frames; + void operator()(stack_frame *frame) { - set_array_nth(frames.untagged(),index++,frame_executing(frame)); - set_array_nth(frames.untagged(),index++,frame_scan(frame)); + gc_root executing(frame_executing(frame)); + gc_root scan(frame_scan(frame)); + + frames.add(executing.value()); + frames.add(scan.value()); } }; @@ -151,13 +151,11 @@ PRIMITIVE(callstack_to_array) { gc_root callstack(dpop()); - stack_frame_counter counter; - iterate_callstack_object(callstack.untagged(),counter); - - stack_frame_accumulator accum(counter.count); + stack_frame_accumulator accum; iterate_callstack_object(callstack.untagged(),accum); + accum.frames.trim(); - dpush(accum.frames.value()); + dpush(accum.frames.elements.value()); } stack_frame *innermost_stack_frame(callstack *stack) diff --git a/vm/callstack.hpp b/vm/callstack.hpp index d92e5f69e0..a3cc058e2b 100755 --- a/vm/callstack.hpp +++ b/vm/callstack.hpp @@ -33,9 +33,19 @@ template void iterate_callstack(cell top, cell bottom, T &iterator) } } -template void iterate_callstack_object(callstack *stack, T &iterator) +/* This is a little tricky. The iterator may allocate memory, so we +keep the callstack in a GC root and use relative offsets */ +template void iterate_callstack_object(callstack *stack_, T &iterator) { - iterate_callstack((cell)stack->top(),(cell)stack->bottom(),iterator); + gc_root stack(stack_); + fixnum frame_offset = untag_fixnum(stack->length) - sizeof(stack_frame); + + while(frame_offset >= 0) + { + stack_frame *frame = stack->frame_at(frame_offset); + frame_offset -= frame->size; + iterator(frame); + } } } diff --git a/vm/layouts.hpp b/vm/layouts.hpp index 3fe89cb558..7736143c50 100755 --- a/vm/layouts.hpp +++ b/vm/layouts.hpp @@ -309,6 +309,11 @@ struct callstack : public object { /* tagged */ cell length; + stack_frame *frame_at(cell offset) + { + return (stack_frame *)((char *)(this + 1) + offset); + } + stack_frame *top() { return (stack_frame *)(this + 1); } stack_frame *bottom() { return (stack_frame *)((cell)(this + 1) + untag_fixnum(length)); } }; From 6b2192bde0dfc9ee36ebe432793e707164638537 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 20 May 2009 20:01:21 -0400 Subject: [PATCH 14/38] Fix compile error on GCC 4.x --- vm/callstack.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/vm/callstack.cpp b/vm/callstack.cpp index 38fb1e2b33..39988ae976 100755 --- a/vm/callstack.cpp +++ b/vm/callstack.cpp @@ -110,16 +110,18 @@ cell frame_scan(stack_frame *frame) switch(frame_type(frame)) { case QUOTATION_TYPE: - cell quot = frame_executing(frame); - if(quot == F) - return F; - else { - char *return_addr = (char *)FRAME_RETURN_ADDRESS(frame); - char *quot_xt = (char *)(frame_code(frame) + 1); + cell quot = frame_executing(frame); + if(quot == F) + return F; + else + { + char *return_addr = (char *)FRAME_RETURN_ADDRESS(frame); + char *quot_xt = (char *)(frame_code(frame) + 1); - return tag_fixnum(quot_code_offset_to_scan( - quot,(cell)(return_addr - quot_xt))); + return tag_fixnum(quot_code_offset_to_scan( + quot,(cell)(return_addr - quot_xt))); + } } case WORD_TYPE: return F; From 91834fb3360445c4574552bb1fd0eb5b43caa747 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 20 May 2009 19:30:35 -0500 Subject: [PATCH 15/38] fix error handling in random.windows if acquiring the crypto context fails --- basis/random/windows/windows.factor | 46 +++++++++++++++++--------- basis/windows/advapi32/advapi32.factor | 34 +++++++++++++++++++ 2 files changed, 65 insertions(+), 15 deletions(-) diff --git a/basis/random/windows/windows.factor b/basis/random/windows/windows.factor index 488deef41f..981b8ec14e 100644 --- a/basis/random/windows/windows.factor +++ b/basis/random/windows/windows.factor @@ -1,6 +1,7 @@ -USING: accessors alien.c-types byte-arrays continuations -kernel windows.advapi32 init namespaces random destructors -locals windows.errors ; +USING: accessors alien.c-types byte-arrays +combinators.short-circuit continuations destructors init kernel +locals namespaces random windows.advapi32 windows.errors +windows.kernel32 ; IN: random.windows TUPLE: windows-rng provider type ; @@ -12,22 +13,37 @@ C: windows-crypto-context M: windows-crypto-context dispose ( tuple -- ) handle>> 0 CryptReleaseContext win32-error=0/f ; -: factor-crypto-container ( -- string ) "FactorCryptoContainer" ; inline +CONSTANT: factor-crypto-container "FactorCryptoContainer" -:: (acquire-crypto-context) ( provider type flags -- handle ) - [let | handle [ "HCRYPTPROV" ] | - handle - factor-crypto-container - provider - type - flags - CryptAcquireContextW win32-error=0/f - handle *void* ] ; +:: (acquire-crypto-context) ( provider type flags -- handle ret ) + "HCRYPTPROV" :> handle + handle + factor-crypto-container + provider + type + flags + CryptAcquireContextW handle swap ; : acquire-crypto-context ( provider type -- handle ) - [ 0 (acquire-crypto-context) ] - [ drop CRYPT_NEWKEYSET (acquire-crypto-context) ] recover ; + 0 (acquire-crypto-context) + 0 = [ + GetLastError NTE_BAD_KEYSET = + [ drop f ] [ win32-error-string throw ] if + ] [ + *void* + ] if ; +: create-crypto-context ( provider type -- handle ) + CRYPT_NEWKEYSET (acquire-crypto-context) win32-error=0/f *void* ; + +ERROR: acquire-crypto-context-failed provider type ; + +: attempt-crypto-context ( provider type -- handle ) + { + [ acquire-crypto-context ] + [ create-crypto-context ] + [ acquire-crypto-context-failed ] + } 2|| ; : windows-crypto-context ( provider type -- context ) acquire-crypto-context ; diff --git a/basis/windows/advapi32/advapi32.factor b/basis/windows/advapi32/advapi32.factor index fd037cb2a0..6e040871f8 100644 --- a/basis/windows/advapi32/advapi32.factor +++ b/basis/windows/advapi32/advapi32.factor @@ -291,6 +291,40 @@ CONSTANT: SE_GROUP_ENABLED 4 CONSTANT: SE_GROUP_OWNER 8 CONSTANT: SE_GROUP_LOGON_ID -1073741824 +CONSTANT: NTE_BAD_UID HEX: 80090001 +CONSTANT: NTE_BAD_HASH HEX: 80090002 +CONSTANT: NTE_BAD_KEY HEX: 80090003 +CONSTANT: NTE_BAD_LEN HEX: 80090004 +CONSTANT: NTE_BAD_DATA HEX: 80090005 +CONSTANT: NTE_BAD_SIGNATURE HEX: 80090006 +CONSTANT: NTE_BAD_VER HEX: 80090007 +CONSTANT: NTE_BAD_ALGID HEX: 80090008 +CONSTANT: NTE_BAD_FLAGS HEX: 80090009 +CONSTANT: NTE_BAD_TYPE HEX: 8009000A +CONSTANT: NTE_BAD_KEY_STATE HEX: 8009000B +CONSTANT: NTE_BAD_HASH_STATE HEX: 8009000C +CONSTANT: NTE_NO_KEY HEX: 8009000D +CONSTANT: NTE_NO_MEMORY HEX: 8009000E +CONSTANT: NTE_EXISTS HEX: 8009000F +CONSTANT: NTE_PERM HEX: 80090010 +CONSTANT: NTE_NOT_FOUND HEX: 80090011 +CONSTANT: NTE_DOUBLE_ENCRYPT HEX: 80090012 +CONSTANT: NTE_BAD_PROVIDER HEX: 80090013 +CONSTANT: NTE_BAD_PROV_TYPE HEX: 80090014 +CONSTANT: NTE_BAD_PUBLIC_KEY HEX: 80090015 +CONSTANT: NTE_BAD_KEYSET HEX: 80090016 +CONSTANT: NTE_PROV_TYPE_NOT_DEF HEX: 80090017 +CONSTANT: NTE_PROV_TYPE_ENTRY_BAD HEX: 80090018 +CONSTANT: NTE_KEYSET_NOT_DEF HEX: 80090019 +CONSTANT: NTE_KEYSET_ENTRY_BAD HEX: 8009001A +CONSTANT: NTE_PROV_TYPE_NO_MATCH HEX: 8009001B +CONSTANT: NTE_SIGNATURE_FILE_BAD HEX: 8009001C +CONSTANT: NTE_PROVIDER_DLL_FAIL HEX: 8009001D +CONSTANT: NTE_PROV_DLL_NOT_FOUND HEX: 8009001E +CONSTANT: NTE_BAD_KEYSET_PARAM HEX: 8009001F +CONSTANT: NTE_FAIL HEX: 80090020 +CONSTANT: NTE_SYS_ERR HEX: 80090021 + ! SID is a variable length structure TYPEDEF: void* PSID From 52e959e6a1920ea5df3a40f2da8e632d187b74d7 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 20 May 2009 19:40:52 -0500 Subject: [PATCH 16/38] call the word that attempts both crypto contexts --- basis/random/windows/windows.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basis/random/windows/windows.factor b/basis/random/windows/windows.factor index 981b8ec14e..c8e08c9abe 100644 --- a/basis/random/windows/windows.factor +++ b/basis/random/windows/windows.factor @@ -46,7 +46,7 @@ ERROR: acquire-crypto-context-failed provider type ; } 2|| ; : windows-crypto-context ( provider type -- context ) - acquire-crypto-context ; + attempt-crypto-context ; M: windows-rng random-bytes* ( n tuple -- bytes ) [ From ef3656aea866e1983ebdd9786fe0eb7b038459cf Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 20 May 2009 20:06:05 -0500 Subject: [PATCH 17/38] try to fall back on AES if RSA isn't found --- basis/random/windows/windows.factor | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/basis/random/windows/windows.factor b/basis/random/windows/windows.factor index c8e08c9abe..aa9404fbb2 100644 --- a/basis/random/windows/windows.factor +++ b/basis/random/windows/windows.factor @@ -60,9 +60,13 @@ M: windows-rng random-bytes* ( n tuple -- bytes ) MS_DEF_PROV PROV_RSA_FULL system-random-generator set-global - MS_STRONG_PROV - PROV_RSA_FULL secure-random-generator set-global + [ + MS_STRONG_PROV + PROV_RSA_FULL secure-random-generator set-global + ] [ + drop + MS_ENH_RSA_AES_PROV + PROV_RSA_AES secure-random-generator set-global + ] recover - ! MS_ENH_RSA_AES_PROV - ! PROV_RSA_AES secure-random-generator set-global ] "random.windows" add-init-hook From 57d38b1dd0dcf04edc562307440f9e5cce14f764 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 20 May 2009 20:08:26 -0500 Subject: [PATCH 18/38] better factoring --- basis/random/windows/windows.factor | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/basis/random/windows/windows.factor b/basis/random/windows/windows.factor index aa9404fbb2..6dce078d67 100644 --- a/basis/random/windows/windows.factor +++ b/basis/random/windows/windows.factor @@ -60,13 +60,8 @@ M: windows-rng random-bytes* ( n tuple -- bytes ) MS_DEF_PROV PROV_RSA_FULL system-random-generator set-global - [ - MS_STRONG_PROV - PROV_RSA_FULL secure-random-generator set-global - ] [ - drop - MS_ENH_RSA_AES_PROV - PROV_RSA_AES secure-random-generator set-global - ] recover + [ MS_STRONG_PROV PROV_RSA_FULL ] + [ drop MS_ENH_RSA_AES_PROV PROV_RSA_AES ] recover + secure-random-generator set-global ] "random.windows" add-init-hook From 7d328011e8c3c9c23fa8ec9d4f8c036384171261 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 21 May 2009 00:08:43 -0500 Subject: [PATCH 19/38] Working on webapps.mason --- basis/io/launcher/launcher.factor | 2 +- extra/mason/common/common.factor | 11 +- extra/mason/notify/notify.factor | 6 +- extra/mason/notify/server/server.factor | 55 ++++++++-- extra/mason/report/report.factor | 28 ++--- extra/webapps/mason/download.xml | 23 ++++ extra/webapps/mason/mason.factor | 138 +++++++++++++++++++----- 7 files changed, 202 insertions(+), 61 deletions(-) create mode 100644 extra/webapps/mason/download.xml diff --git a/basis/io/launcher/launcher.factor b/basis/io/launcher/launcher.factor index 7451499978..f4978672d9 100755 --- a/basis/io/launcher/launcher.factor +++ b/basis/io/launcher/launcher.factor @@ -264,7 +264,7 @@ M: output-process-error error. : try-output-process ( command -- ) >process +stdout+ >>stderr - +closed+ >>stdin + [ +closed+ or ] change-stdin utf8 [ stream-contents ] [ dup wait-for-process ] bi* 0 = [ 2drop ] [ output-process-error ] if ; diff --git a/extra/mason/common/common.factor b/extra/mason/common/common.factor index 4ac5767009..d54a17ff91 100755 --- a/extra/mason/common/common.factor +++ b/extra/mason/common/common.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2008 Eduardo Cavazos, Slava Pestov. +! Copyright (C) 2008, 2009 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel namespaces sequences splitting system accessors math.functions make io io.files io.pathnames io.directories @@ -13,10 +13,7 @@ SYMBOL: current-git-id : short-running-process ( command -- ) #! Give network operations and shell commands at most #! 15 minutes to complete, to catch hangs. - >process - 15 minutes >>timeout - +closed+ >>stdin - try-output-process ; + >process 15 minutes >>timeout try-output-process ; HOOK: really-delete-tree os ( path -- ) @@ -45,10 +42,6 @@ M: unix really-delete-tree delete-tree ; dup utf8 file-lines parse-fresh [ "Empty file: " swap append throw ] [ nip first ] if-empty ; -: cat ( file -- ) utf8 file-contents print ; - -: cat-n ( file n -- ) [ utf8 file-lines ] dip short tail* [ print ] each ; - : to-file ( object file -- ) utf8 [ . ] with-file-writer ; : datestamp ( timestamp -- string ) diff --git a/extra/mason/notify/notify.factor b/extra/mason/notify/notify.factor index ccabccdf8b..87447e48cc 100644 --- a/extra/mason/notify/notify.factor +++ b/extra/mason/notify/notify.factor @@ -16,7 +16,7 @@ IN: mason.notify ] { } make prepend [ 5 ] 2dip '[ - _ [ +closed+ ] unless* >>stdin + _ >>stdin _ >>command short-running-process ] retry @@ -49,4 +49,6 @@ IN: mason.notify ] bi ; : notify-release ( archive-name -- ) - "Uploaded " prepend [ print flush ] [ mason-tweet ] bi ; + [ "Uploaded " prepend [ print flush ] [ mason-tweet ] bi ] + [ f swap "release" swap 2array status-notify ] + bi ; diff --git a/extra/mason/notify/server/server.factor b/extra/mason/notify/server/server.factor index cc055e38d8..9ed29aef45 100644 --- a/extra/mason/notify/server/server.factor +++ b/extra/mason/notify/server/server.factor @@ -1,26 +1,44 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors combinators combinators.smart command-line db -db.sqlite db.tuples db.types io kernel namespaces sequences ; +db.sqlite db.tuples db.types io io.encodings.utf8 io.files +present kernel namespaces sequences calendar ; IN: mason.notify.server CONSTANT: +starting+ "starting" CONSTANT: +make-vm+ "make-vm" CONSTANT: +boot+ "boot" CONSTANT: +test+ "test" -CONSTANT: +clean+ "clean" -CONSTANT: +dirty+ "dirty" +CONSTANT: +clean+ "status-clean" +CONSTANT: +dirty+ "status-dirty" +CONSTANT: +error+ "status-error" -TUPLE: builder host-name os cpu clean-git-id last-git-id last-report current-git-id status ; +TUPLE: builder +host-name os cpu +clean-git-id clean-timestamp +last-release release-git-id +last-git-id last-timestamp last-report +current-git-id current-timestamp +status ; builder "BUILDERS" { { "host-name" "HOST_NAME" TEXT +user-assigned-id+ } { "os" "OS" TEXT +user-assigned-id+ } { "cpu" "CPU" TEXT +user-assigned-id+ } + { "clean-git-id" "CLEAN_GIT_ID" TEXT } + { "clean-timestamp" "CLEAN_TIMESTAMP" TIMESTAMP } + + { "last-release" "LAST_RELEASE" TEXT } + { "release-git-id" "RELEASE_GIT_ID" TEXT } + { "last-git-id" "LAST_GIT_ID" TEXT } + { "last-timestamp" "LAST_TIMESTAMP" TIMESTAMP } { "last-report" "LAST_REPORT" TEXT } + { "current-git-id" "CURRENT_GIT_ID" TEXT } + ! Can't name it CURRENT_TIMESTAMP because of bug in db library + { "current-timestamp" "CURR_TIMESTAMP" TIMESTAMP } { "status" "STATUS" TEXT } } define-persistent @@ -49,14 +67,23 @@ SYMBOLS: host-name target-os target-cpu message message-arg ; : make-vm ( builder -- ) +make-vm+ >>status drop ; -: boot ( report -- ) +boot+ >>status drop ; +: boot ( builder -- ) +boot+ >>status drop ; -: test ( report -- ) +test+ >>status drop ; +: test ( builder -- ) +test+ >>status drop ; : report ( builder status content -- ) [ >>status ] [ >>last-report ] bi* - dup status>> +clean+ = [ dup current-git-id>> >>clean-git-id ] when + dup status>> +clean+ = [ + dup current-git-id>> >>clean-git-id + dup current-timestamp>> >>clean-timestamp + ] when dup current-git-id>> >>last-git-id + dup current-timestamp>> >>last-timestamp + drop ; + +: release ( builder name -- ) + >>last-release + dup clean-git-id>> >>release-git-id drop ; : update-builder ( builder -- ) @@ -66,17 +93,25 @@ SYMBOLS: host-name target-os target-cpu message message-arg ; { "boot" [ boot ] } { "test" [ test ] } { "report" [ message-arg get contents report ] } + { "release" [ message-arg get release ] } } case ; : mason-db ( -- db ) "resource:mason.db" ; -: handle-update ( command-line -- ) +: handle-update ( command-line timestamp -- ) mason-db [ - parse-args find-builder + [ parse-args find-builder ] dip >>current-timestamp [ update-builder ] [ update-tuple ] bi ] with-db ; +CONSTANT: log-file "resource:mason.log" + +: log-update ( command-line timestamp -- ) + log-file utf8 [ + present write ": " write " " join print + ] with-file-appender ; + : main ( -- ) - command-line get handle-update ; + command-line get now [ log-update ] [ handle-update ] 2bi ; MAIN: main diff --git a/extra/mason/report/report.factor b/extra/mason/report/report.factor index e74db9a1ae..52237171cf 100644 --- a/extra/mason/report/report.factor +++ b/extra/mason/report/report.factor @@ -59,13 +59,13 @@ IN: mason.report "test-log" "Tests failed" failed-report ; : timings-table ( -- xml ) - { - $ boot-time-file - $ load-time-file - $ test-time-file - $ help-lint-time-file - $ benchmark-time-file - $ html-help-time-file + ${ + boot-time-file + load-time-file + test-time-file + help-lint-time-file + benchmark-time-file + html-help-time-file } [ dup eval-file milli-seconds>time [XML <-><-> XML] @@ -121,13 +121,13 @@ IN: mason.report ] with-report ; : build-clean? ( -- ? ) - { - [ load-all-vocabs-file eval-file empty? ] - [ test-all-vocabs-file eval-file empty? ] - [ help-lint-vocabs-file eval-file empty? ] - [ compiler-errors-file eval-file empty? ] - [ benchmark-error-vocabs-file eval-file empty? ] - } 0&& ; + ${ + load-all-vocabs-file + test-all-vocabs-file + help-lint-vocabs-file + compiler-errors-file + benchmark-error-vocabs-file + } [ eval-file empty? ] all? ; : success ( -- status ) successful-report build-clean? status-clean status-dirty ? ; \ No newline at end of file diff --git a/extra/webapps/mason/download.xml b/extra/webapps/mason/download.xml new file mode 100644 index 0000000000..2b1bb76f64 --- /dev/null +++ b/extra/webapps/mason/download.xml @@ -0,0 +1,23 @@ + + + + + + + Factor binary package for <t:label t:name="platform" /> + + +

Factor binary package for

+ +

Requirements:

+ + +

Download

+ +

This package was built from GIT ID .

+ +

Once you download Factor, you can get started with the language.

+ + + +
diff --git a/extra/webapps/mason/mason.factor b/extra/webapps/mason/mason.factor index 74c459e38e..7e76de736d 100644 --- a/extra/webapps/mason/mason.factor +++ b/extra/webapps/mason/mason.factor @@ -1,11 +1,28 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays combinators db db.tuples furnace.actions -http.server.responses kernel mason.platform mason.notify.server -mason.report math.order sequences sorting splitting xml.syntax -xml.writer io.pathnames io.encodings.utf8 io.files ; +http.server.responses http.server.dispatchers kernel mason.platform +mason.notify.server mason.report math.order sequences sorting +splitting xml.syntax xml.writer io.pathnames io.encodings.utf8 +io.files present validators html.forms furnace.db assocs urls ; IN: webapps.mason +TUPLE: mason-app < dispatcher ; + +: validate-os/cpu ( -- ) + { + { "os" [ v-one-line ] } + { "cpu" [ v-one-line ] } + } validate-params ; + +: current-builder ( -- builder ) + builder new "os" value >>os "cpu" value >>cpu select-tuple ; + +: ( -- action ) + + [ validate-os/cpu ] >>init + [ current-builder last-report>> "text/html" ] >>display ; + : log-file ( -- path ) home "mason.log" append-path ; : recent-events ( -- xml ) @@ -20,24 +37,48 @@ IN: webapps.mason [XML <-> for <-> XML] ; : current-status ( builder -- xml ) - dup status>> { - { "status-dirty" [ drop "Dirty" ] } - { "status-clean" [ drop "Clean" ] } - { "status-error" [ drop "Error" ] } - { "starting" [ "Starting" building ] } - { "make-vm" [ "Compiling VM" building ] } - { "boot" [ "Bootstrapping" building ] } - { "test" [ "Testing" building ] } - [ 2drop "Unknown" ] - } case ; + [ + dup status>> { + { +dirty+ [ drop "Dirty" ] } + { +clean+ [ drop "Clean" ] } + { +error+ [ drop "Error" ] } + { +starting+ [ "Starting build" building ] } + { +make-vm+ [ "Compiling VM" building ] } + { +boot+ [ "Bootstrapping" building ] } + { +test+ [ "Testing" building ] } + [ 2drop "Unknown" ] + } case + ] [ current-timestamp>> present " (as of " ")" surround ] bi 2array ; + +: build-status ( git-id timestamp -- xml ) + over [ [ git-link ] [ present ] bi* " (built on " ")" surround 2array ] [ 2drop f ] if ; + +: binaries-url ( builder -- url ) + [ os>> ] [ cpu>> ] bi (platform) "http://downloads.factorcode.org/" prepend ; + +: url-link ( url -- xml ) + dup [XML ><-> XML] ; + +: latest-binary-link ( builder -- xml ) + [ URL" download" ] dip + [ os>> "os" set-query-param ] + [ cpu>> "cpu" set-query-param ] bi + [XML >Latest download XML] ; : binaries-link ( builder -- link ) - [ os>> ] [ cpu>> ] bi (platform) "http://downloads.factorcode.org/" prepend - dup [XML ><-> XML] ; + binaries-url url-link ; + +: clean-image-url ( builder -- url ) + [ os>> ] [ cpu>> ] bi (platform) "http://factorcode.org/images/clean/" prepend ; : clean-image-link ( builder -- link ) - [ os>> ] [ cpu>> ] bi (platform) "http://factorcode.org/images/clean/" prepend - dup [XML ><-> XML] ; + clean-image-url url-link ; + +: report-link ( builder -- xml ) + [ URL" report" ] dip + [ os>> "os" set-query-param ] + [ cpu>> "cpu" set-query-param ] bi + [XML >Latest build report XML] ; : machine-table ( builder -- xml ) { @@ -45,10 +86,12 @@ IN: webapps.mason [ cpu>> ] [ host-name>> "." split1 drop ] [ current-status ] - [ last-git-id>> dup [ git-link ] when ] - [ clean-git-id>> dup [ git-link ] when ] + [ [ last-git-id>> ] [ last-timestamp>> ] bi build-status ] + [ [ clean-git-id>> ] [ clean-timestamp>> ] bi build-status ] [ binaries-link ] [ clean-image-link ] + [ report-link ] + [ latest-binary-link ] } cleave [XML

<-> / <->

@@ -60,6 +103,8 @@ IN: webapps.mason Binaries:<-> Clean images:<-> + + <-> | <-> XML] ; : machine-report ( -- xml ) @@ -67,7 +112,7 @@ IN: webapps.mason [ [ [ os>> ] [ cpu>> ] bi 2array ] compare ] sort [ machine-table ] map ; -: build-farm-report ( -- xml ) +: build-farm-summary ( -- xml ) recent-events machine-report [XML @@ -77,9 +122,52 @@ IN: webapps.mason XML] ; -: ( -- action ) +: ( -- action ) - [ - mason-db [ build-farm-report xml>string ] with-db - "text/html" - ] >>display ; \ No newline at end of file + [ build-farm-summary xml>string "text/html" ] >>display ; + +TUPLE: builder-link href title ; + +C: builder-link + +: requirements ( builder -- xml ) + [ + os>> { + { "winnt" "Windows XP (also tested on Vista)" } + { "macosx" "Mac OS X 10.5 Leopard" } + { "linux" "Linux 2.6.16 with GLIBC 2.4" } + { "freebsd" "FreeBSD 7.0" } + { "netbsd" "NetBSD 4.0" } + { "openbsd" "OpenBSD 4.2" } + } at + ] [ + dup cpu>> "x86-32" = [ + os>> { + { [ dup { "winnt" "linux" } member? ] [ drop "Intel Pentium 4, Core Duo, or other x86 chip with SSE2 support. Note that 32-bit Athlon XP processors do not support SSE2." ] } + { [ dup { "freebsd" "netbsd" "openbsd" } member? ] [ drop "Intel Pentium Pro or better" ] } + { [ t ] [ drop f ] } + } cond + ] [ drop f ] if + ] bi + 2array sift [ [XML
  • <->
  • XML] ] map [XML
      <->
    XML] ; + +: ( -- action ) + + [ + validate-os/cpu + "os" value "cpu" value (platform) "platform" set-value + current-builder + [ latest-binary-link "package" set-value ] + [ release-git-id>> git-link "git-id" set-value ] + [ requirements "requirements" set-value ] + tri + ] >>init + { mason-app "download" } >>template ; + +: ( -- dispatcher ) + mason-app new-dispatcher + "" add-responder + "report" add-responder + "download" add-responder + mason-db ; + From c5d440700d6395f2c8dfc33817f8a0f7da451619 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 21 May 2009 18:49:22 -0500 Subject: [PATCH 20/38] 0.0 neg ought to be -0.0 --- core/math/math-tests.factor | 3 +++ core/math/math.factor | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/math/math-tests.factor b/core/math/math-tests.factor index b7cc51e669..831430cf24 100644 --- a/core/math/math-tests.factor +++ b/core/math/math-tests.factor @@ -26,6 +26,9 @@ IN: math.tests [ f ] [ 0 fp-nan? ] unit-test [ t ] [ 0 fp-infinity? ] unit-test +[ t ] [ 0.0 neg -0.0 fp-bitwise= ] unit-test +[ t ] [ -0.0 neg 0.0 fp-bitwise= ] unit-test + [ 0.0 ] [ -0.0 next-float ] unit-test [ t ] [ 1.0 dup next-float < ] unit-test [ t ] [ -1.0 dup next-float < ] unit-test diff --git a/core/math/math.factor b/core/math/math.factor index da9bc4d1b5..28efbaa26e 100755 --- a/core/math/math.factor +++ b/core/math/math.factor @@ -60,7 +60,7 @@ PRIVATE> : 1- ( x -- y ) 1 - ; inline : 2/ ( x -- y ) -1 shift ; inline : sq ( x -- y ) dup * ; inline -: neg ( x -- -x ) 0 swap - ; inline +: neg ( x -- -x ) -1 * ; inline : recip ( x -- y ) 1 swap / ; inline : sgn ( x -- n ) dup 0 < [ drop -1 ] [ 0 > 1 0 ? ] if ; inline : ?1+ ( x -- y ) [ 1 + ] [ 0 ] if* ; inline From a150fc9a7f5c63c7880738963a228d77c0f2b4cd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 21 May 2009 19:15:04 -0500 Subject: [PATCH 21/38] webapps.mason: Now renders a download grid with links to build machine status and download pages --- extra/mason/build/build.factor | 20 ++-- extra/mason/child/child.factor | 5 +- extra/mason/report/report.factor | 7 +- extra/webapps/mason/download.xml | 13 +++ extra/webapps/mason/mason.factor | 178 ++++++++++++++++--------------- 5 files changed, 126 insertions(+), 97 deletions(-) diff --git a/extra/mason/build/build.factor b/extra/mason/build/build.factor index a9e32e5315..f2018449fc 100644 --- a/extra/mason/build/build.factor +++ b/extra/mason/build/build.factor @@ -1,12 +1,11 @@ ! Copyright (C) 2008, 2009 Eduardo Cavazos, Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel calendar io.directories io.encodings.utf8 -io.files io.launcher namespaces prettyprint mason.child mason.cleanup -mason.common mason.help mason.release mason.report mason.email -mason.notify ; -IN: mason.build - +io.files io.launcher namespaces prettyprint combinators mason.child +mason.cleanup mason.common mason.help mason.release mason.report +mason.email mason.notify ; QUALIFIED: continuations +IN: mason.build : create-build-dir ( -- ) now datestamp stamp set @@ -18,11 +17,12 @@ QUALIFIED: continuations "git" "clone" builds/factor 3array short-running-process ; : begin-build ( -- ) - "factor" [ git-id ] with-directory - [ "git-id" to-file ] - [ current-git-id set ] - [ notify-begin-build ] - tri ; + "factor" [ git-id ] with-directory { + [ "git-id" to-file ] + [ "factor/git-id" to-file ] + [ current-git-id set ] + [ notify-begin-build ] + } cleave ; : build ( -- ) create-build-dir diff --git a/extra/mason/child/child.factor b/extra/mason/child/child.factor index 8132e62078..4a9a864c40 100755 --- a/extra/mason/child/child.factor +++ b/extra/mason/child/child.factor @@ -64,7 +64,10 @@ IN: mason.child MACRO: recover-cond ( alist -- ) dup { [ length 1 = ] [ first callable? ] } 1&& - [ first ] [ [ first first2 ] [ rest ] bi '[ _ _ [ _ recover-cond ] recover-else ] ] if ; + [ first ] [ + [ first first2 ] [ rest ] bi + '[ _ _ [ _ recover-cond ] recover-else ] + ] if ; : build-child ( -- status ) copy-image diff --git a/extra/mason/report/report.factor b/extra/mason/report/report.factor index 52237171cf..3ed332abf2 100644 --- a/extra/mason/report/report.factor +++ b/extra/mason/report/report.factor @@ -4,13 +4,16 @@ USING: benchmark combinators.smart debugger fry io assocs io.encodings.utf8 io.files io.sockets io.streams.string kernel locals mason.common mason.config mason.platform math namespaces prettyprint sequences xml.syntax xml.writer combinators.short-circuit -literals ; +literals splitting ; IN: mason.report +: short-host-name ( -- string ) + host-name "." split1 drop ; + : common-report ( -- xml ) target-os get target-cpu get - host-name + short-host-name build-dir current-git-id get [XML diff --git a/extra/webapps/mason/download.xml b/extra/webapps/mason/download.xml index 2b1bb76f64..af4ac0214d 100644 --- a/extra/webapps/mason/download.xml +++ b/extra/webapps/mason/download.xml @@ -17,6 +17,19 @@

    This package was built from GIT ID .

    Once you download Factor, you can get started with the language.

    + +

    Build machine information

    + + + + + + + + +
    Host name:
    Current status:
    Last build:
    Last clean build:
    Binaries:
    Clean images:
    + +

    diff --git a/extra/webapps/mason/mason.factor b/extra/webapps/mason/mason.factor index 7e76de736d..4d42617520 100644 --- a/extra/webapps/mason/mason.factor +++ b/extra/webapps/mason/mason.factor @@ -4,11 +4,66 @@ USING: accessors arrays combinators db db.tuples furnace.actions http.server.responses http.server.dispatchers kernel mason.platform mason.notify.server mason.report math.order sequences sorting splitting xml.syntax xml.writer io.pathnames io.encodings.utf8 -io.files present validators html.forms furnace.db assocs urls ; +io.files present validators html.forms furnace.db urls ; +FROM: assocs => at keys values ; IN: webapps.mason TUPLE: mason-app < dispatcher ; +: link ( url label -- xml ) + [XML ><-> XML] ; + +: download-link ( builder label -- xml ) + [ + [ URL" download" ] dip + [ os>> "os" set-query-param ] + [ cpu>> "cpu" set-query-param ] bi + ] dip link ; + +: download-grid-cell ( cpu os -- xml ) + builder new swap >>os swap >>cpu select-tuple dup + [ + dup last-release>> dup + [ "." split1 drop 16 tail* 6 head* download-link ] [ 2drop f ] if + ] when + [XML <-> XML] ; + +CONSTANT: oses +{ + { "winnt" "Windows" } + { "macosx" "Mac OS X" } + { "linux" "Linux" } + { "freebsd" "FreeBSD" } + { "netbsd" "NetBSD" } + { "openbsd" "OpenBSD" } +} + +CONSTANT: cpus +{ + { "x86.32" "x86" } + { "x86.64" "x86-64" } + { "ppc" "PowerPC" } +} + +: download-grid ( -- xml ) + oses + [ values [ [XML <-> XML] ] map ] + [ + keys + cpus [ + [ nip second ] [ first ] 2bi [ + swap download-grid-cell + ] curry map [XML <-><-> XML] + ] with map + ] bi [XML <->
    <->
    XML] ; + +: ( -- action ) + + [ + download-grid + xml>string "text/html" + ] >>display ; + : validate-os/cpu ( -- ) { { "os" [ v-one-line ] } @@ -23,11 +78,6 @@ TUPLE: mason-app < dispatcher ; [ validate-os/cpu ] >>init [ current-builder last-report>> "text/html" ] >>display ; -: log-file ( -- path ) home "mason.log" append-path ; - -: recent-events ( -- xml ) - log-file utf8 10 file-tail [XML
    <->
    XML] ; - : git-link ( id -- link ) [ "http://github.com/slavapestov/factor/commit/" prepend ] keep [XML ><-> XML] ; @@ -36,19 +86,22 @@ TUPLE: mason-app < dispatcher ; swap current-git-id>> git-link [XML <-> for <-> XML] ; +: status-string ( builder -- string ) + dup status>> { + { +dirty+ [ drop "Dirty" ] } + { +clean+ [ drop "Clean" ] } + { +error+ [ drop "Error" ] } + { +starting+ [ "Starting build" building ] } + { +make-vm+ [ "Compiling VM" building ] } + { +boot+ [ "Bootstrapping" building ] } + { +test+ [ "Testing" building ] } + [ 2drop "Unknown" ] + } case ; + : current-status ( builder -- xml ) - [ - dup status>> { - { +dirty+ [ drop "Dirty" ] } - { +clean+ [ drop "Clean" ] } - { +error+ [ drop "Error" ] } - { +starting+ [ "Starting build" building ] } - { +make-vm+ [ "Compiling VM" building ] } - { +boot+ [ "Bootstrapping" building ] } - { +test+ [ "Testing" building ] } - [ 2drop "Unknown" ] - } case - ] [ current-timestamp>> present " (as of " ")" surround ] bi 2array ; + [ status-string ] + [ current-timestamp>> present " (as of " ")" surround ] bi + 2array ; : build-status ( git-id timestamp -- xml ) over [ [ git-link ] [ present ] bi* " (built on " ")" surround 2array ] [ 2drop f ] if ; @@ -56,23 +109,17 @@ TUPLE: mason-app < dispatcher ; : binaries-url ( builder -- url ) [ os>> ] [ cpu>> ] bi (platform) "http://downloads.factorcode.org/" prepend ; -: url-link ( url -- xml ) - dup [XML ><-> XML] ; - : latest-binary-link ( builder -- xml ) - [ URL" download" ] dip - [ os>> "os" set-query-param ] - [ cpu>> "cpu" set-query-param ] bi - [XML >Latest download XML] ; + [ binaries-url ] [ last-release>> ] bi [ "/" glue ] keep link ; : binaries-link ( builder -- link ) - binaries-url url-link ; + binaries-url dup link ; : clean-image-url ( builder -- url ) [ os>> ] [ cpu>> ] bi (platform) "http://factorcode.org/images/clean/" prepend ; : clean-image-link ( builder -- link ) - clean-image-url url-link ; + clean-image-url dup link ; : report-link ( builder -- xml ) [ URL" report" ] dip @@ -80,56 +127,6 @@ TUPLE: mason-app < dispatcher ; [ cpu>> "cpu" set-query-param ] bi [XML >Latest build report XML] ; -: machine-table ( builder -- xml ) - { - [ os>> ] - [ cpu>> ] - [ host-name>> "." split1 drop ] - [ current-status ] - [ [ last-git-id>> ] [ last-timestamp>> ] bi build-status ] - [ [ clean-git-id>> ] [ clean-timestamp>> ] bi build-status ] - [ binaries-link ] - [ clean-image-link ] - [ report-link ] - [ latest-binary-link ] - } cleave - [XML -

    <-> / <->

    - - - - - - - -
    Host name:<->
    Current status:<->
    Last build:<->
    Last clean build:<->
    Binaries:<->
    Clean images:<->
    - - <-> | <-> - XML] ; - -: machine-report ( -- xml ) - builder new select-tuples - [ [ [ os>> ] [ cpu>> ] bi 2array ] compare ] sort - [ machine-table ] map ; - -: build-farm-summary ( -- xml ) - recent-events - machine-report - [XML - - Factor build farm -

    Recent events

    <->

    Machine status

    <-> - - XML] ; - -: ( -- action ) - - [ build-farm-summary xml>string "text/html" ] >>display ; - -TUPLE: builder-link href title ; - -C: builder-link - : requirements ( builder -- xml ) [ os>> { @@ -141,7 +138,7 @@ C: builder-link { "openbsd" "OpenBSD 4.2" } } at ] [ - dup cpu>> "x86-32" = [ + dup cpu>> "x86.32" = [ os>> { { [ dup { "winnt" "linux" } member? ] [ drop "Intel Pentium 4, Core Duo, or other x86 chip with SSE2 support. Note that 32-bit Athlon XP processors do not support SSE2." ] } { [ dup { "freebsd" "netbsd" "openbsd" } member? ] [ drop "Intel Pentium Pro or better" ] } @@ -151,23 +148,36 @@ C: builder-link ] bi 2array sift [ [XML
  • <->
  • XML] ] map [XML
      <->
    XML] ; +: last-build-status ( builder -- xml ) + [ last-git-id>> ] [ last-timestamp>> ] bi build-status ; + +: clean-build-status ( builder -- xml ) + [ clean-git-id>> ] [ clean-timestamp>> ] bi build-status ; + : ( -- action ) [ validate-os/cpu "os" value "cpu" value (platform) "platform" set-value - current-builder - [ latest-binary-link "package" set-value ] - [ release-git-id>> git-link "git-id" set-value ] - [ requirements "requirements" set-value ] - tri + current-builder { + [ latest-binary-link "package" set-value ] + [ release-git-id>> git-link "git-id" set-value ] + [ requirements "requirements" set-value ] + [ host-name>> "host-name" set-value ] + [ current-status "status" set-value ] + [ last-build-status "last-build" set-value ] + [ clean-build-status "last-clean-build" set-value ] + [ binaries-link "binaries" set-value ] + [ clean-image-link "clean-images" set-value ] + [ report-link "last-report" set-value ] + } cleave ] >>init { mason-app "download" } >>template ; : ( -- dispatcher ) mason-app new-dispatcher - "" add-responder "report" add-responder "download" add-responder + "grid" add-responder mason-db ; From 16b39e2d6c438b173a17c27e580247475c651c47 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 21 May 2009 19:19:12 -0500 Subject: [PATCH 22/38] mason: use short host name not fully qualified host name --- extra/mason/common/common.factor | 5 ++++- extra/mason/notify/notify.factor | 2 +- extra/mason/report/report.factor | 3 --- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extra/mason/common/common.factor b/extra/mason/common/common.factor index d54a17ff91..22e37f8a8c 100755 --- a/extra/mason/common/common.factor +++ b/extra/mason/common/common.factor @@ -5,9 +5,12 @@ math.functions make io io.files io.pathnames io.directories io.directories.hierarchy io.launcher io.encodings.utf8 prettyprint combinators.short-circuit parser combinators calendar calendar.format arrays mason.config locals debugger fry -continuations strings ; +continuations strings io.sockets ; IN: mason.common +: short-host-name ( -- string ) + host-name "." split1 drop ; + SYMBOL: current-git-id : short-running-process ( command -- ) diff --git a/extra/mason/notify/notify.factor b/extra/mason/notify/notify.factor index 87447e48cc..122c8a47cd 100644 --- a/extra/mason/notify/notify.factor +++ b/extra/mason/notify/notify.factor @@ -10,7 +10,7 @@ IN: mason.notify [ "ssh" , status-host get , "-l" , status-username get , "./mason-notify" , - host-name , + short-host-name , target-cpu get , target-os get , ] { } make prepend diff --git a/extra/mason/report/report.factor b/extra/mason/report/report.factor index 3ed332abf2..4a2138323c 100644 --- a/extra/mason/report/report.factor +++ b/extra/mason/report/report.factor @@ -7,9 +7,6 @@ prettyprint sequences xml.syntax xml.writer combinators.short-circuit literals splitting ; IN: mason.report -: short-host-name ( -- string ) - host-name "." split1 drop ; - : common-report ( -- xml ) target-os get target-cpu get From 9685aea6fecbd3ff295e048f61a98df81f162e61 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 21 May 2009 20:55:44 -0500 Subject: [PATCH 23/38] homogeneous coordinates coated in nurbsauce --- basis/math/vectors/vectors.factor | 3 + .../affine-transforms.factor | 3 - extra/math/vectors/homogeneous/authors.txt | 1 + .../homogeneous/homogeneous-tests.factor | 15 ++++ .../vectors/homogeneous/homogeneous.factor | 36 +++++++++ extra/math/vectors/homogeneous/summary.txt | 1 + extra/nurbs/authors.txt | 1 + extra/nurbs/nurbs-tests.factor | 32 ++++++++ extra/nurbs/nurbs.factor | 73 +++++++++++++++++++ extra/nurbs/summary.txt | 1 + 10 files changed, 163 insertions(+), 3 deletions(-) create mode 100644 extra/math/vectors/homogeneous/authors.txt create mode 100644 extra/math/vectors/homogeneous/homogeneous-tests.factor create mode 100644 extra/math/vectors/homogeneous/homogeneous.factor create mode 100644 extra/math/vectors/homogeneous/summary.txt create mode 100644 extra/nurbs/authors.txt create mode 100644 extra/nurbs/nurbs-tests.factor create mode 100644 extra/nurbs/nurbs.factor create mode 100644 extra/nurbs/summary.txt diff --git a/basis/math/vectors/vectors.factor b/basis/math/vectors/vectors.factor index 0fe1404516..14a66b5c18 100644 --- a/basis/math/vectors/vectors.factor +++ b/basis/math/vectors/vectors.factor @@ -62,6 +62,9 @@ IN: math.vectors [ first vnlerp ] [ second vnlerp ] bi-curry [ 2bi@ ] [ call ] bi* ; +: v~ ( a b epsilon -- ? ) + [ ~ ] curry 2all? ; + HINTS: vneg { array } ; HINTS: norm-sq { array } ; HINTS: norm { array } ; diff --git a/extra/math/affine-transforms/affine-transforms.factor b/extra/math/affine-transforms/affine-transforms.factor index d1fd602f72..7d63bbfac8 100644 --- a/extra/math/affine-transforms/affine-transforms.factor +++ b/extra/math/affine-transforms/affine-transforms.factor @@ -65,9 +65,6 @@ CONSTANT: identity-transform T{ affine-transform f { 1.0 0.0 } { 0.0 1.0 } { 0.0 } 2cleave [ [ 2array ] 2bi@ ] dip ; -: v~ ( a b epsilon -- ? ) - [ ~ ] curry 2all? ; - : a~ ( a b epsilon -- ? ) { [ [ [ x>> ] bi@ ] dip v~ ] diff --git a/extra/math/vectors/homogeneous/authors.txt b/extra/math/vectors/homogeneous/authors.txt new file mode 100644 index 0000000000..f13c9c1e77 --- /dev/null +++ b/extra/math/vectors/homogeneous/authors.txt @@ -0,0 +1 @@ +Joe Groff diff --git a/extra/math/vectors/homogeneous/homogeneous-tests.factor b/extra/math/vectors/homogeneous/homogeneous-tests.factor new file mode 100644 index 0000000000..7e657dbe71 --- /dev/null +++ b/extra/math/vectors/homogeneous/homogeneous-tests.factor @@ -0,0 +1,15 @@ +! (c)2009 Joe Groff bsd license +USING: math.vectors.homogeneous tools.test ; +IN: math.vectors.homogeneous.tests + +[ { 1.0 2.0 1.0 } ] [ { 1.0 0.0 1.0 } { 0.0 2.0 1.0 } h+ ] unit-test +[ { 1.0 -2.0 1.0 } ] [ { 1.0 0.0 1.0 } { 0.0 2.0 1.0 } h- ] unit-test +[ { 2.0 2.0 2.0 } ] [ { 1.0 0.0 1.0 } { 0.0 2.0 2.0 } h+ ] unit-test +[ { 1.0 2.0 2.0 } ] [ { 1.0 0.0 2.0 } { 0.0 2.0 2.0 } h+ ] unit-test + +[ { 2.0 4.0 2.0 } ] [ 2.0 { 1.0 2.0 2.0 } n*h ] unit-test +[ { 2.0 4.0 2.0 } ] [ { 1.0 2.0 2.0 } 2.0 h*n ] unit-test + +[ { 0.5 1.5 } ] [ { 1.0 3.0 2.0 } h>v ] unit-test +[ { 0.5 1.5 1.0 } ] [ { 0.5 1.5 } v>h ] unit-test +[ { 0.5 1.5 1.0 } ] [ { 0.5 1.5 } v>h ] unit-test diff --git a/extra/math/vectors/homogeneous/homogeneous.factor b/extra/math/vectors/homogeneous/homogeneous.factor new file mode 100644 index 0000000000..218e56dfb5 --- /dev/null +++ b/extra/math/vectors/homogeneous/homogeneous.factor @@ -0,0 +1,36 @@ +! (c)2009 Joe Groff bsd license +USING: kernel math math.vectors sequences ; +IN: math.vectors.homogeneous + +: (homogeneous-xyz) ( h -- xyz ) + 1 head* ; inline +: (homogeneous-w) ( h -- w ) + peek ; inline + +: h+ ( a b -- c ) + 2dup [ (homogeneous-w) ] bi@ over = + [ [ [ (homogeneous-xyz) ] bi@ v+ ] dip suffix ] [ + drop + [ [ (homogeneous-xyz) ] [ (homogeneous-w) ] bi* v*n ] + [ [ (homogeneous-w) ] [ (homogeneous-xyz) ] bi* n*v v+ ] + [ [ (homogeneous-w) ] [ (homogeneous-w) ] bi* * suffix ] 2tri + ] if ; + +: n*h ( n h -- nh ) + [ (homogeneous-xyz) n*v ] [ (homogeneous-w) suffix ] bi ; + +: h*n ( h n -- nh ) + swap n*h ; + +: hneg ( h -- -h ) + -1.0 swap n*h ; + +: h- ( a b -- c ) + hneg h+ ; + +: v>h ( v -- h ) + 1.0 suffix ; + +: h>v ( h -- v ) + [ (homogeneous-xyz) ] [ (homogeneous-w) ] bi v/n ; + diff --git a/extra/math/vectors/homogeneous/summary.txt b/extra/math/vectors/homogeneous/summary.txt new file mode 100644 index 0000000000..eb6d457267 --- /dev/null +++ b/extra/math/vectors/homogeneous/summary.txt @@ -0,0 +1 @@ +Homogeneous coordinate math diff --git a/extra/nurbs/authors.txt b/extra/nurbs/authors.txt new file mode 100644 index 0000000000..f13c9c1e77 --- /dev/null +++ b/extra/nurbs/authors.txt @@ -0,0 +1 @@ +Joe Groff diff --git a/extra/nurbs/nurbs-tests.factor b/extra/nurbs/nurbs-tests.factor new file mode 100644 index 0000000000..db606f9c5c --- /dev/null +++ b/extra/nurbs/nurbs-tests.factor @@ -0,0 +1,32 @@ +! (c)2009 Joe Groff bsd license +USING: literals math math.functions math.vectors namespaces +nurbs tools.test ; +IN: nurbs.tests + +SYMBOL: test-nurbs + +CONSTANT: √2/2 $[ 0.5 sqrt ] +CONSTANT: -√2/2 $[ 0.5 sqrt neg ] + +! unit circle as NURBS +3 { + { 1.0 0.0 1.0 } + { $ √2/2 $ √2/2 $ √2/2 } + { 0.0 1.0 1.0 } + { $ -√2/2 $ √2/2 $ √2/2 } + { -1.0 0.0 1.0 } + { $ -√2/2 $ -√2/2 $ √2/2 } + { 0.0 -1.0 1.0 } + { $ √2/2 $ -√2/2 $ √2/2 } + { 1.0 0.0 1.0 } +} { 0.0 0.0 0.0 0.25 0.25 0.5 0.5 0.75 0.75 1.0 1.0 1.0 } test-nurbs set + +[ t ] [ test-nurbs get 0.0 eval-nurbs { 1.0 0.0 } 0.00001 v~ ] unit-test +[ t ] [ test-nurbs get 0.25 eval-nurbs { 0.0 1.0 } 0.00001 v~ ] unit-test +[ t ] [ test-nurbs get 0.5 eval-nurbs { -1.0 0.0 } 0.00001 v~ ] unit-test +[ t ] [ test-nurbs get 0.75 eval-nurbs { 0.0 -1.0 } 0.00001 v~ ] unit-test + +[ t ] [ test-nurbs get 0.125 eval-nurbs { $ √2/2 $ √2/2 } 0.00001 v~ ] unit-test +[ t ] [ test-nurbs get 0.375 eval-nurbs { $ -√2/2 $ √2/2 } 0.00001 v~ ] unit-test +[ t ] [ test-nurbs get 0.625 eval-nurbs { $ -√2/2 $ -√2/2 } 0.00001 v~ ] unit-test +[ t ] [ test-nurbs get 0.875 eval-nurbs { $ √2/2 $ -√2/2 } 0.00001 v~ ] unit-test diff --git a/extra/nurbs/nurbs.factor b/extra/nurbs/nurbs.factor new file mode 100644 index 0000000000..ff77d3e915 --- /dev/null +++ b/extra/nurbs/nurbs.factor @@ -0,0 +1,73 @@ +! (c)2009 Joe Groff bsd license +USING: accessors arrays grouping kernel locals math math.order +math.ranges math.vectors math.vectors.homogeneous sequences +specialized-arrays.float ; +IN: nurbs + +TUPLE: nurbs-curve + { order integer } + control-points + knots + (knot-constants) ; + +: ?recip ( n -- 1/n ) + dup zero? [ recip ] unless ; + +:: order-index-knot-constants ( curve order index -- knot-constants ) + curve knots>> :> knots + index order 1 - + knots nth :> knot_i+k-1 + index knots nth :> knot_i + index order + knots nth :> knot_i+k + index 1 + knots nth :> knot_i+1 + + knot_i+k-1 knot_i - ?recip :> c1 + knot_i+1 knot_i+k - ?recip :> c2 + + knot_i c1 * neg :> c3 + knot_i+k c2 * neg :> c4 + + c1 c2 c3 c4 float-array{ } 4sequence ; + +: order-knot-constants ( curve order -- knot-constants ) + 2dup [ knots>> length ] dip - iota + [ order-index-knot-constants ] with with map ; + +: knot-constants ( curve -- knot-constants ) + 2 over order>> [a,b] + [ order-knot-constants ] with map ; + +: update-knots ( curve -- curve ) + dup knot-constants >>(knot-constants) ; + +: ( order control-points knots -- nurbs-curve ) + f nurbs-curve boa update-knots ; + +: knot-interval ( nurbs-curve t -- index ) + [ knots>> ] dip [ > ] curry find drop 1 - ; + +: clip-range ( from to sequence -- from' to' ) + length min [ 0 max ] dip ; + +:: eval-base ( knot-constants bases t -- base ) + knot-constants first t * knot-constants third + bases first * + knot-constants second t * knot-constants fourth + bases second * + + ; + +: (eval-curve) ( base-values control-points -- value ) + [ n*v ] 2map { 0.0 0.0 0.0 } [ v+ ] binary-reduce h>v ; + +:: (eval-bases) ( curve t interval values order -- values' ) + order 2 - curve (knot-constants)>> nth :> all-knot-constants + interval order interval + all-knot-constants clip-range :> to :> from + from to all-knot-constants subseq :> knot-constants + values { 0.0 } { 0.0 } surround 2 :> bases + + knot-constants bases [ t eval-base ] 2map :> values' + order curve order>> = + [ values' from to curve control-points>> subseq (eval-curve) ] + [ curve t interval 1 - values' order 1 + (eval-bases) ] if ; + +: eval-nurbs ( nurbs-curve t -- value ) + 2dup knot-interval 1 - { 1.0 } 2 (eval-bases) ; + + diff --git a/extra/nurbs/summary.txt b/extra/nurbs/summary.txt new file mode 100644 index 0000000000..46b9bebffb --- /dev/null +++ b/extra/nurbs/summary.txt @@ -0,0 +1 @@ +NURBS curve evaluation From 3276ae3a088bf6e81ef5a37d8e739626482a660c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 21 May 2009 20:56:57 -0500 Subject: [PATCH 24/38] get rid of useless test --- basis/compiler/tree/cleanup/cleanup-tests.factor | 2 -- 1 file changed, 2 deletions(-) diff --git a/basis/compiler/tree/cleanup/cleanup-tests.factor b/basis/compiler/tree/cleanup/cleanup-tests.factor index c596be263a..549d492d20 100755 --- a/basis/compiler/tree/cleanup/cleanup-tests.factor +++ b/basis/compiler/tree/cleanup/cleanup-tests.factor @@ -136,8 +136,6 @@ M: object xyz ; \ +-integer-fixnum inlined? ] unit-test -[ f ] [ [ dup 0 < [ neg ] when ] \ - inlined? ] unit-test - [ t ] [ [ [ no-cond ] 1 From 028c8776019129e143a4bf81b977eb603ead70dd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 21 May 2009 21:23:01 -0500 Subject: [PATCH 25/38] tuple-arrays: clean up a bit and add docs --- basis/tuple-arrays/tuple-arrays-docs.factor | 25 +++++++++++++++++++++ basis/tuple-arrays/tuple-arrays.factor | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 basis/tuple-arrays/tuple-arrays-docs.factor diff --git a/basis/tuple-arrays/tuple-arrays-docs.factor b/basis/tuple-arrays/tuple-arrays-docs.factor new file mode 100644 index 0000000000..cedf900698 --- /dev/null +++ b/basis/tuple-arrays/tuple-arrays-docs.factor @@ -0,0 +1,25 @@ +IN: tuple-arrays +USING: help.markup help.syntax sequences ; + +HELP: TUPLE-ARRAY: +{ $syntax "TUPLE-ARRAY: class" } +{ $description "Generates a new data type in the current vocabulary named " { $snippet { $emphasis "class" } "-array" } " for holding instances of " { $snippet "class" } ", which must be a tuple class word. Together with the class itself, this also generates words named " { $snippet "<" { $emphasis "class" } "-array>" } " and " { $snippet ">" { $emphasis "class" } "-array" } ", for creating new instances of this tuple array type." } ; + +ARTICLE: "tuple-arrays" "Tuple arrays" +"The " { $vocab-link "tuple-arrays" } " vocabulary implements space-efficient unboxed tuple arrays. Whereas an ordinary array of tuples would consist of pointers to heap-allocated objects, a tuple array stores its elements inline. Calling " { $link nth } " copies an element into a new tuple, and calling " { $link set-nth } " copies an existing tuple's slots into an array." +$nl +"Since value semantics differ from reference semantics, it is best to use tuple arrays with tuples where all slots are declared " { $link read-only } "." +$nl +"Tuple arrays should not be used with inheritance; storing an instance of a subclass in a tuple array will slice off the subclass slots, and getting the same value out again will yield an instance of the superclass. Also, tuple arrays do not get updated if tuples are redefined to add or remove slots, so caution should be exercised when doing interactive development on code that uses tuple arrays." +{ $subsection POSTPONE: TUPLE-ARRAY: } +"An example:" +{ $example + "USE: tuple-arrays" + "IN: scratchpad" + "TUPLE: point x y ;" + "TUPLE-ARRAY: point" + "{ T{ point f 1 2 } T{ point f 1 3 } T{ point f 2 3 } } >point-array first short." + "T{ point f 1 2 }" +} ; + +ABOUT: "tuple-arrays" \ No newline at end of file diff --git a/basis/tuple-arrays/tuple-arrays.factor b/basis/tuple-arrays/tuple-arrays.factor index 35d771416c..761dbd816a 100644 --- a/basis/tuple-arrays/tuple-arrays.factor +++ b/basis/tuple-arrays/tuple-arrays.factor @@ -21,7 +21,7 @@ MACRO: infer-in ( class -- quot ) infer in>> '[ _ ] ; [ new ] [ smart-tuple>array ] bi ; inline : tuple-slice ( n seq -- slice ) - [ n>> [ * dup ] keep + ] [ seq>> ] bi { array } declare slice boa ; inline + [ n>> [ * dup ] keep + ] [ seq>> ] bi slice boa ; inline : read-tuple ( slice class -- tuple ) '[ _ boa-unsafe ] input Date: Thu, 21 May 2009 23:27:42 -0500 Subject: [PATCH 26/38] io.monitors: fix example (reported by levy in #concatenative0 --- basis/io/monitors/monitors-docs.factor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basis/io/monitors/monitors-docs.factor b/basis/io/monitors/monitors-docs.factor index f0278e300e..c5f266de56 100644 --- a/basis/io/monitors/monitors-docs.factor +++ b/basis/io/monitors/monitors-docs.factor @@ -112,10 +112,10 @@ $nl { $code "USE: io.monitors" ": watch-loop ( monitor -- )" - " dup next-change . nl nl flush watch-loop ;" + " dup next-change path>> print nl nl flush watch-loop ;" "" ": watch-directory ( path -- )" - " [ t [ watch-loop ] with-monitor ] with-monitors" + " [ t [ watch-loop ] with-monitor ] with-monitors ;" } ; ABOUT: "io.monitors" From 9cc178b738e4cddaed98748f10233757f05c07d8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 22 May 2009 01:59:50 -0500 Subject: [PATCH 27/38] If a vocab fails to load, manifest would be left in a weird state (reported by Joe Groff) --- core/parser/parser-tests.factor | 11 ++++++++++- core/vocabs/loader/test/l/l.factor | 4 ++++ core/vocabs/loader/test/l/tags.txt | 1 + core/vocabs/parser/parser.factor | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 core/vocabs/loader/test/l/l.factor create mode 100644 core/vocabs/loader/test/l/tags.txt diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor index a9e0bd08ab..32f432a6cd 100644 --- a/core/parser/parser-tests.factor +++ b/core/parser/parser-tests.factor @@ -618,4 +618,13 @@ EXCLUDE: qualified.tests.bar => x ; [ "USE: kernel UNUSE: kernel dup" "unuse-test" parse-stream -] [ error>> error>> error>> no-word-error? ] must-fail-with \ No newline at end of file +] [ error>> error>> error>> no-word-error? ] must-fail-with + +[ ] [ [ "vocabs.loader.test.l" forget-vocab ] with-compilation-unit ] unit-test + +[ + [ "vocabs.loader.test.l" use-vocab ] must-fail + [ f ] [ "vocabs.loader.test.l" manifest get search-vocab-names>> key? ] unit-test + [ ] [ "vocabs.loader.test.l" unuse-vocab ] unit-test + [ f ] [ "vocabs.loader.test.l" manifest get search-vocab-names>> key? ] unit-test +] with-file-vocabs diff --git a/core/vocabs/loader/test/l/l.factor b/core/vocabs/loader/test/l/l.factor new file mode 100644 index 0000000000..10cd35dff2 --- /dev/null +++ b/core/vocabs/loader/test/l/l.factor @@ -0,0 +1,4 @@ +IN: vocabs.loader.test.l +USE: kernel + +"Oops" throw \ No newline at end of file diff --git a/core/vocabs/loader/test/l/tags.txt b/core/vocabs/loader/test/l/tags.txt new file mode 100644 index 0000000000..6bf68304bb --- /dev/null +++ b/core/vocabs/loader/test/l/tags.txt @@ -0,0 +1 @@ +unportable diff --git a/core/vocabs/parser/parser.factor b/core/vocabs/parser/parser.factor index 45084ae8ff..ff55f8e68d 100644 --- a/core/vocabs/parser/parser.factor +++ b/core/vocabs/parser/parser.factor @@ -108,8 +108,8 @@ TUPLE: no-current-vocab ; dup using-vocab? [ vocab-name "Already using ``" "'' vocabulary" surround note. ] [ manifest get - [ [ vocab-name ] dip search-vocab-names>> conjoin ] [ [ load-vocab ] dip search-vocabs>> push ] + [ [ vocab-name ] dip search-vocab-names>> conjoin ] 2bi ] if ; @@ -121,8 +121,8 @@ TUPLE: no-current-vocab ; : unuse-vocab ( vocab -- ) dup using-vocab? [ manifest get - [ [ vocab-name ] dip search-vocab-names>> delete-at ] [ [ load-vocab ] dip search-vocabs>> delq ] + [ [ vocab-name ] dip search-vocab-names>> delete-at ] 2bi ] [ drop ] if ; From d7ab0ad7c081c145989422bfa6e80f2a86512df0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 22 May 2009 02:04:36 -0500 Subject: [PATCH 28/38] io.monitors: spawn-monitor was broken and never used, so remove it (reported by levi in #concatenative) --- basis/io/monitors/monitors.factor | 3 --- 1 file changed, 3 deletions(-) diff --git a/basis/io/monitors/monitors.factor b/basis/io/monitors/monitors.factor index 7d40a1563a..cc8cea37d2 100644 --- a/basis/io/monitors/monitors.factor +++ b/basis/io/monitors/monitors.factor @@ -60,9 +60,6 @@ SYMBOL: +rename-file+ : run-monitor ( path recursive? quot -- ) '[ [ @ t ] loop ] with-monitor ; inline -: spawn-monitor ( path recursive? quot -- ) - [ '[ _ _ _ run-monitor ] ] [ 2drop "Monitoring " prepend ] 3bi - spawn drop ; { { [ os macosx? ] [ "io.monitors.macosx" require ] } { [ os linux? ] [ "io.monitors.linux" require ] } From bbad40683b701346a65253d67b66d1f8f3ed4dac Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 22 May 2009 16:21:35 -0500 Subject: [PATCH 29/38] webapps.mason: spiff up download.xml a bit --- extra/webapps/mason/download.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extra/webapps/mason/download.xml b/extra/webapps/mason/download.xml index af4ac0214d..6dca81baf8 100644 --- a/extra/webapps/mason/download.xml +++ b/extra/webapps/mason/download.xml @@ -4,9 +4,12 @@ + Factor binary package for <t:label t:name="platform" /> +
    Logo
    +

    Factor binary package for

    Requirements:

    From 92ecb2f3be0226c6886018cb0821c6956cbfa2e0 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 22 May 2009 17:15:40 -0500 Subject: [PATCH 30/38] fix random.windows -- use CRYPT_MACHINE_KEYSET --- basis/random/windows/windows.factor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/basis/random/windows/windows.factor b/basis/random/windows/windows.factor index 6dce078d67..06a7634a43 100644 --- a/basis/random/windows/windows.factor +++ b/basis/random/windows/windows.factor @@ -25,7 +25,8 @@ CONSTANT: factor-crypto-container "FactorCryptoContainer" CryptAcquireContextW handle swap ; : acquire-crypto-context ( provider type -- handle ) - 0 (acquire-crypto-context) + CRYPT_MACHINE_KEYSET + (acquire-crypto-context) 0 = [ GetLastError NTE_BAD_KEYSET = [ drop f ] [ win32-error-string throw ] if @@ -34,7 +35,7 @@ CONSTANT: factor-crypto-container "FactorCryptoContainer" ] if ; : create-crypto-context ( provider type -- handle ) - CRYPT_NEWKEYSET (acquire-crypto-context) win32-error=0/f *void* ; + { CRYPT_MACHINE_KEYSET CRYPT_NEWKEYSET } (acquire-crypto-context) win32-error=0/f *void* ; ERROR: acquire-crypto-context-failed provider type ; From d660dd4ed6ec4f91d9b9b9a2a5a24802a2cb7dc6 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 22 May 2009 17:18:24 -0500 Subject: [PATCH 31/38] fix typo --- basis/random/windows/windows.factor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/basis/random/windows/windows.factor b/basis/random/windows/windows.factor index 06a7634a43..83b1fab0d0 100644 --- a/basis/random/windows/windows.factor +++ b/basis/random/windows/windows.factor @@ -1,7 +1,7 @@ USING: accessors alien.c-types byte-arrays combinators.short-circuit continuations destructors init kernel locals namespaces random windows.advapi32 windows.errors -windows.kernel32 ; +windows.kernel32 math.bitwise ; IN: random.windows TUPLE: windows-rng provider type ; @@ -35,7 +35,8 @@ CONSTANT: factor-crypto-container "FactorCryptoContainer" ] if ; : create-crypto-context ( provider type -- handle ) - { CRYPT_MACHINE_KEYSET CRYPT_NEWKEYSET } (acquire-crypto-context) win32-error=0/f *void* ; + { CRYPT_MACHINE_KEYSET CRYPT_NEWKEYSET } flags + (acquire-crypto-context) win32-error=0/f *void* ; ERROR: acquire-crypto-context-failed provider type ; From a1436e69cde39d8ef151c5d09075c9e3afafb3ed Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 22 May 2009 17:32:27 -0500 Subject: [PATCH 32/38] webapps.mason: make it look like the factorcode.org site --- extra/webapps/mason/download.xml | 5 ++++- extra/webapps/mason/mason.factor | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/extra/webapps/mason/download.xml b/extra/webapps/mason/download.xml index 6dca81baf8..7e50f958cd 100644 --- a/extra/webapps/mason/download.xml +++ b/extra/webapps/mason/download.xml @@ -1,8 +1,11 @@ + + - + Factor binary package for <t:label t:name="platform" /> diff --git a/extra/webapps/mason/mason.factor b/extra/webapps/mason/mason.factor index 4d42617520..690c4c9660 100644 --- a/extra/webapps/mason/mason.factor +++ b/extra/webapps/mason/mason.factor @@ -21,12 +21,13 @@ TUPLE: mason-app < dispatcher ; ] dip link ; : download-grid-cell ( cpu os -- xml ) - builder new swap >>os swap >>cpu select-tuple dup - [ + builder new swap >>os swap >>cpu select-tuple [ dup last-release>> dup [ "." split1 drop 16 tail* 6 head* download-link ] [ 2drop f ] if - ] when - [XML <-> XML] ; + [XML
    <->
    XML] + ] [ + [XML XML] + ] if* ; CONSTANT: oses { @@ -47,22 +48,21 @@ CONSTANT: cpus : download-grid ( -- xml ) oses - [ values [ [XML <-> XML] ] map ] + [ values [ [XML <-> XML] ] map ] [ keys cpus [ [ nip second ] [ first ] 2bi [ swap download-grid-cell - ] curry map [XML <-><-> XML] + ] curry map + [XML <-><-> XML] ] with map - ] bi [XML <->
    <->
    XML] ; + ] bi + [XML <->
    <->
    XML] ; : ( -- action ) - [ - download-grid - xml>string "text/html" - ] >>display ; + [ download-grid xml>string "text/html" ] >>display ; : validate-os/cpu ( -- ) { From 760445c8e4347389645e7bf4eafaf2832f694766 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 22 May 2009 17:42:05 -0500 Subject: [PATCH 33/38] More cosmetic tweaks --- extra/webapps/mason/mason.factor | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extra/webapps/mason/mason.factor b/extra/webapps/mason/mason.factor index 690c4c9660..fad77286b2 100644 --- a/extra/webapps/mason/mason.factor +++ b/extra/webapps/mason/mason.factor @@ -26,7 +26,7 @@ TUPLE: mason-app < dispatcher ; [ "." split1 drop 16 tail* 6 head* download-link ] [ 2drop f ] if [XML
    <->
    XML] ] [ - [XML XML] + [XML XML] ] if* ; CONSTANT: oses @@ -58,7 +58,12 @@ CONSTANT: cpus [XML <-><-> XML] ] with map ] bi - [XML <->
    <->
    XML] ; + [XML + + <-> + <-> +
    OS/CPU
    + XML] ; : ( -- action ) From b58c1780c6fd9dde4d15b082f1e18c418dd89c71 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 22 May 2009 17:48:05 -0500 Subject: [PATCH 34/38] One last tweak --- extra/webapps/mason/mason.factor | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extra/webapps/mason/mason.factor b/extra/webapps/mason/mason.factor index fad77286b2..f7aadb9a54 100644 --- a/extra/webapps/mason/mason.factor +++ b/extra/webapps/mason/mason.factor @@ -15,7 +15,7 @@ TUPLE: mason-app < dispatcher ; : download-link ( builder label -- xml ) [ - [ URL" download" ] dip + [ URL" http://builds.factorcode.org/download" ] dip [ os>> "os" set-query-param ] [ cpu>> "cpu" set-query-param ] bi ] dip link ; @@ -137,16 +137,16 @@ CONSTANT: cpus os>> { { "winnt" "Windows XP (also tested on Vista)" } { "macosx" "Mac OS X 10.5 Leopard" } - { "linux" "Linux 2.6.16 with GLIBC 2.4" } + { "linux" "Ubuntu Linux 9.04 (other distributions may also work)" } { "freebsd" "FreeBSD 7.0" } { "netbsd" "NetBSD 4.0" } - { "openbsd" "OpenBSD 4.2" } + { "openbsd" "OpenBSD 4.4" } } at ] [ dup cpu>> "x86.32" = [ os>> { - { [ dup { "winnt" "linux" } member? ] [ drop "Intel Pentium 4, Core Duo, or other x86 chip with SSE2 support. Note that 32-bit Athlon XP processors do not support SSE2." ] } - { [ dup { "freebsd" "netbsd" "openbsd" } member? ] [ drop "Intel Pentium Pro or better" ] } + { [ dup { "winnt" "linux" "freebsd" } member? ] [ drop "Intel Pentium 4, Core Duo, or other x86 chip with SSE2 support. Note that 32-bit Athlon XP processors do not support SSE2." ] } + { [ dup { "netbsd" "openbsd" } member? ] [ drop "Intel Pentium Pro or better" ] } { [ t ] [ drop f ] } } cond ] [ drop f ] if From 5fa0507b97f0acd9721ca8d9bf807a729b55df95 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 22 May 2009 17:52:31 -0500 Subject: [PATCH 35/38] websites.concatenatieve: add builds.factorcode.org --- extra/websites/concatenative/concatenative.factor | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extra/websites/concatenative/concatenative.factor b/extra/websites/concatenative/concatenative.factor index d7b132d4f2..207ae9ab34 100644 --- a/extra/websites/concatenative/concatenative.factor +++ b/extra/websites/concatenative/concatenative.factor @@ -23,7 +23,8 @@ webapps.pastebin webapps.planet webapps.wiki webapps.user-admin -webapps.help ; +webapps.help +webapps.mason ; IN: websites.concatenative : test-db ( -- db ) "resource:test.db" ; @@ -95,6 +96,7 @@ SYMBOL: dh-file test-db "planet.factorcode.org" add-responder home "docs" append-path test-db "docs.factorcode.org" add-responder home "cgi" append-path "gitweb.factorcode.org" add-responder + "builds.factorcode.org" add-responder main-responder set-global ; : ( -- config ) From 6061b68b0daa243b3a224194d65478d3849e984b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 23 May 2009 00:31:52 -0500 Subject: [PATCH 36/38] checksums.md5: make the new optimized code work with big endian CPUs --- basis/checksums/md5/md5.factor | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/basis/checksums/md5/md5.factor b/basis/checksums/md5/md5.factor index c74aa550d2..d59976fb7e 100644 --- a/basis/checksums/md5/md5.factor +++ b/basis/checksums/md5/md5.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2006, 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel io io.binary io.files io.streams.byte-array math +USING: alien.c-types kernel io io.binary io.files io.streams.byte-array math math.functions math.parser namespaces splitting grouping strings sequences byte-arrays locals sequences.private macros fry io.encodings.binary math.bitwise checksums accessors @@ -173,9 +173,27 @@ HINTS: (process-md5-block-G) { uint-array md5-state } ; HINTS: (process-md5-block-H) { uint-array md5-state } ; HINTS: (process-md5-block-I) { uint-array md5-state } ; +: byte-array>le ( byte-array -- byte-array ) + little-endian? [ + dup 4 [ + [ [ 1 2 ] dip exchange-unsafe ] + [ [ 0 3 ] dip exchange-unsafe ] bi + ] each + ] unless ; + +: byte-array>uint-array-le ( byte-array -- uint-array ) + byte-array>le byte-array>uint-array ; + +HINTS: byte-array>uint-array-le byte-array ; + +: uint-array>byte-array-le ( uint-array -- byte-array ) + underlying>> byte-array>le ; + +HINTS: uint-array>byte-array-le uint-array ; + M: md5-state checksum-block ( block state -- ) [ - [ byte-array>uint-array ] [ state>> ] bi* { + [ byte-array>uint-array-le ] [ state>> ] bi* { [ (process-md5-block-F) ] [ (process-md5-block-G) ] [ (process-md5-block-H) ] @@ -185,7 +203,7 @@ M: md5-state checksum-block ( block state -- ) nip update-md5 ] 2bi ; -: md5>checksum ( md5 -- bytes ) state>> underlying>> ; +: md5>checksum ( md5 -- bytes ) state>> uint-array>byte-array-le ; M: md5-state clone ( md5 -- new-md5 ) call-next-method From 3061cea61f90394bfe2d537046a0d2740d06da7c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Sat, 23 May 2009 08:39:01 -0500 Subject: [PATCH 37/38] disable WGL_ARB_pixel_format code path in windows UI backend 'cause ATI drivers are shit --- basis/ui/backend/windows/windows.factor | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index e28776a51c..551d89b66c 100755 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -51,10 +51,8 @@ PIXEL-FORMAT-ATTRIBUTE-TABLE: WGL_ARB { $ WGL_SUPPORT_OPENGL_ARB 1 } H{ { samples { $ WGL_SAMPLES_ARB } } } -MEMO: (has-wglChoosePixelFormatARB?) ( dc -- ? ) - { "WGL_ARB_pixel_format" } has-wgl-extensions? ; : has-wglChoosePixelFormatARB? ( world -- ? ) - handle>> hDC>> (has-wglChoosePixelFormatARB?) ; + drop f ; : arb-make-pixel-format ( world attributes -- pf ) [ handle>> hDC>> ] dip >WGL_ARB-int-array f 1 0 0 From 43a1834e0b348ffff82cfe66102c29b79ed37a71 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 23 May 2009 15:50:35 -0500 Subject: [PATCH 38/38] stack-checker: fix case where invalid code could infer --- basis/compiler/tree/normalization/normalization.factor | 2 +- basis/compiler/tree/tuple-unboxing/tuple-unboxing.factor | 2 ++ basis/stack-checker/branches/branches.factor | 8 ++++++-- basis/stack-checker/known-words/known-words.factor | 2 -- basis/stack-checker/stack-checker-tests.factor | 6 +++++- basis/stack-checker/transforms/transforms-tests.factor | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/basis/compiler/tree/normalization/normalization.factor b/basis/compiler/tree/normalization/normalization.factor index 7494ed064e..fcfa42c70b 100644 --- a/basis/compiler/tree/normalization/normalization.factor +++ b/basis/compiler/tree/normalization/normalization.factor @@ -60,7 +60,7 @@ M: #branch normalize* : eliminate-phi-introductions ( introductions seq terminated -- seq' ) [ [ nip ] [ - dup [ +bottom+ eq? ] trim-head + dup [ +top+ eq? ] trim-head [ [ length ] bi@ - tail* ] keep append ] if ] 3map ; diff --git a/basis/compiler/tree/tuple-unboxing/tuple-unboxing.factor b/basis/compiler/tree/tuple-unboxing/tuple-unboxing.factor index 107ea59902..6bed4407b8 100755 --- a/basis/compiler/tree/tuple-unboxing/tuple-unboxing.factor +++ b/basis/compiler/tree/tuple-unboxing/tuple-unboxing.factor @@ -91,6 +91,8 @@ M: #terminate unbox-tuples* [ flatten-values ] change-in-r ; M: #phi unbox-tuples* + ! pad-with-bottom is only needed if some branches are terminated, + ! which means all output values are bottom [ [ flatten-values ] map pad-with-bottom ] change-phi-in-d [ flatten-values ] change-out-d ; diff --git a/basis/stack-checker/branches/branches.factor b/basis/stack-checker/branches/branches.factor index 690af39c28..8b0665aa49 100755 --- a/basis/stack-checker/branches/branches.factor +++ b/basis/stack-checker/branches/branches.factor @@ -9,12 +9,16 @@ IN: stack-checker.branches : balanced? ( pairs -- ? ) [ second ] filter [ first2 length - ] map all-equal? ; -SYMBOL: +bottom+ +SYMBOLS: +bottom+ +top+ ; : unify-inputs ( max-d-in d-in meta-d -- new-meta-d ) - dup [ [ - +bottom+ ] dip append ] [ 3drop f ] if ; + ! Introduced values can be anything, and don't unify with + ! literals. + dup [ [ - +top+ ] dip append ] [ 3drop f ] if ; : pad-with-bottom ( seq -- newseq ) + ! Terminated branches are padded with bottom values which + ! unify with literals. dup empty? [ dup [ length ] [ max ] map-reduce '[ _ +bottom+ pad-head ] map diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 70382c0829..cf2d08b84f 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -219,8 +219,6 @@ M: object infer-call* \ compose f "no-compile" set-word-prop ! More words not to compile -\ call t "no-compile" set-word-prop -\ execute t "no-compile" set-word-prop \ clear t "no-compile" set-word-prop : non-inline-word ( word -- ) diff --git a/basis/stack-checker/stack-checker-tests.factor b/basis/stack-checker/stack-checker-tests.factor index 201f3ce30b..b84f561861 100644 --- a/basis/stack-checker/stack-checker-tests.factor +++ b/basis/stack-checker/stack-checker-tests.factor @@ -371,4 +371,8 @@ DEFER: eee' [ [ bi ] infer ] must-fail [ at ] must-infer -[ [ [ "OOPS" throw ] dip ] [ drop ] if ] must-infer \ No newline at end of file +[ [ [ "OOPS" throw ] dip ] [ drop ] if ] must-infer + +! Found during code review +[ [ [ drop [ ] ] when call ] infer ] must-fail +[ swap [ [ drop [ ] ] when call ] infer ] must-fail \ No newline at end of file diff --git a/basis/stack-checker/transforms/transforms-tests.factor b/basis/stack-checker/transforms/transforms-tests.factor index fe0fa08356..843083bd52 100644 --- a/basis/stack-checker/transforms/transforms-tests.factor +++ b/basis/stack-checker/transforms/transforms-tests.factor @@ -6,7 +6,7 @@ classes classes.tuple ; : compose-n ( quot n -- ) "OOPS" throw ; << -: compose-n-quot ( word n -- quot' ) >quotation ; +: compose-n-quot ( n word -- quot' ) >quotation ; \ compose-n [ compose-n-quot ] 2 define-transform \ compose-n t "no-compile" set-word-prop >>