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

db4
Slava Pestov 2009-08-24 20:34:15 -05:00
commit a2529717ba
9 changed files with 63 additions and 7 deletions

View File

@ -106,11 +106,21 @@ HELP: append-outputs-as
{ append-outputs append-outputs-as } related-words
HELP: drop-outputs
{ $values { "quot" quotation } }
{ $description "Calls a quotation and drops any values it leaves on the stack." } ;
HELP: keep-inputs
{ $values { "quot" quotation } }
{ $description "Calls a quotation and preserves any values it takes off the stack." } ;
{ drop-outputs keep-inputs } related-words
ARTICLE: "combinators.smart" "Smart combinators"
"A " { $emphasis "smart combinator" } " is a macro which reflects on the stack effect of an input quotation. The " { $vocab-link "combinators.smart" } " vocabulary implements a few simple smart combinators which look at the static stack effects of input quotations and generate code which produces or consumes the relevant number of stack values." $nl
"Call a quotation and discard all output values:"
"Call a quotation and discard all output values or preserve all input values:"
{ $subsection drop-outputs }
{ $subsection keep-inputs }
"Take all input values from a sequence:"
{ $subsection input<sequence }
"Store all output values to a sequence:"

View File

@ -7,6 +7,9 @@ IN: combinators.smart
MACRO: drop-outputs ( quot -- quot' )
dup infer out>> '[ @ _ ndrop ] ;
MACRO: keep-inputs ( quot -- quot' )
dup infer in>> '[ _ _ nkeep ] ;
MACRO: output>sequence ( quot exemplar -- newquot )
[ dup infer out>> ] dip
'[ @ _ _ nsequence ] ;

View File

@ -137,6 +137,14 @@ ALIAS: $slot $snippet
] with-nesting
] ($heading) ;
: $deprecated ( element -- )
[
deprecated-style get [
last-element off
"This word is deprecated" $heading print-element
] with-nesting
] ($heading) ;
! Images
: $image ( element -- )
[ first write-image ] ($span) ;

View File

@ -85,6 +85,14 @@ H{
{ wrap-margin 500 }
} warning-style set-global
SYMBOL: deprecated-style
H{
{ page-color COLOR: gray90 }
{ border-color COLOR: red }
{ border-width 5 }
{ wrap-margin 500 }
} deprecated-style set-global
SYMBOL: table-content-style
H{
{ wrap-margin 350 }

View File

@ -95,7 +95,11 @@ ERROR: unimplemented-color-type image ;
unimplemented-color-type ;
: decode-truecolor-alpha ( loading-png -- loading-png )
unimplemented-color-type ;
[ <image> ] dip {
[ png-image-bytes >>bitmap ]
[ [ width>> ] [ height>> ] bi 2array >>dim ]
[ drop RGBA >>component-order ubyte-components >>component-type ]
} cleave ;
: decode-png ( loading-png -- loading-png )
dup color-type>> {

View File

@ -193,7 +193,8 @@ HELP: delimiter
HELP: deprecated
{ $syntax ": foo ... ; deprecated" }
{ $description "Declares the most recently defined word as deprecated. If the " { $vocab-link "tools.deprecation" } " vocabulary is loaded, usages of deprecated words will be noted as they are made." } ;
{ $description "Declares the most recently defined word as deprecated. If the " { $vocab-link "tools.deprecation" } " vocabulary is loaded, usages of deprecated words will be noted by the " { $link "tools.errors" } " system." }
{ $notes "Code that uses deprecated words continues to function normally; the errors are purely informational. However, code that uses deprecated words should be updated, for the deprecated words are intended to be removed soon." } ;
HELP: SYNTAX:
{ $syntax "SYNTAX: foo ... ;" }

View File

@ -111,7 +111,7 @@ HELP: output-index
{ $notes "Named fragment shader outputs require OpenGL 3.0 or later and GLSL 1.30 or later, or OpenGL 2.0 or later and GLSL 1.20 or earlier with the " { $snippet "GL_EXT_gpu_shader4" } " extension." } ;
HELP: program
{ $class-description "A " { $snippet "program" } " provides a specification for linking a " { $link program-instance } " in a graphics context. Programs are defined with " { $link POSTPONE: GLSL-PROGRAM: } " and instantiated in a context with " { $link <program-instance> } "." } ;
{ $class-description "A " { $snippet "program" } " provides a specification for linking a " { $link program-instance } " in a graphics context. Programs are defined with " { $link POSTPONE: GLSL-PROGRAM: } " and instantiated for a context with " { $link <program-instance> } "." } ;
HELP: program-instance
{ $class-description "A " { $snippet "program-instance" } " is a shader " { $link program } " that has been compiled and linked for a graphics context using " { $link <program-instance> } "." } ;
@ -120,10 +120,10 @@ HELP: refresh-program
{ $values
{ "program" program }
}
{ $description "Rereads the source code for every " { $link shader } " in " { $link program } " and attempts to refresh all the existing " { $link shader-instance } "s and " { $link program-instance } "s for those programs. If the new source code fails to compile or link, the existing instances are untouched; otherwise, they are updated on the fly to reference the newly compiled code." } ;
{ $description "Rereads the source code for every " { $link shader } " in " { $link program } " and attempts to refresh all the existing " { $link shader-instance } "s and " { $link program-instance } "s for those shaders. If any of the new source code fails to compile or link, the existing valid shader and program instances will remain untouched. However, subsequent attempts to compile new shader or program instances will still attempt to use the new source code. If the compilation and linking succeed, the existing shader and program instances will be updated on the fly to reference the newly compiled code." } ;
HELP: shader
{ $class-description "A " { $snippet "shader" } " provides a block of GLSL source code that can be compiled into a " { $link shader-instance } " in a graphics context. Shaders are defined with " { $link POSTPONE: GLSL-SHADER: } " or " { $link POSTPONE: GLSL-SHADER-FILE: } " and instantiated in a context with " { $link <shader-instance> } "." } ;
{ $class-description "A " { $snippet "shader" } " provides a block of GLSL source code that can be compiled into a " { $link shader-instance } " in a graphics context. Shaders are defined with " { $link POSTPONE: GLSL-SHADER: } " or " { $link POSTPONE: GLSL-SHADER-FILE: } " and instantiated for a context with " { $link <shader-instance> } "." } ;
HELP: shader-instance
{ $class-description "A " { $snippet "shader-instance" } " is a " { $link shader } " that has been compiled for a graphics context using " { $link <shader-instance> } "." } ;

View File

@ -32,6 +32,20 @@ HELP: pile-alloc
}
{ $description "Requests " { $snippet "size" } " bytes from a " { $link pile } ". If the pile does not have enough space to satisfy the request, a " { $link not-enough-pile-space } " error is thrown." } ;
HELP: <pile-c-array>
{ $values
{ "pile" pile } { "n" integer } { "c-type" "a C type" }
{ "alien" alien }
}
{ $description "Requests enough space from a " { $link pile } " to hold " { $snippet "n" } " values of " { $snippet "c-type" } ". If the pile does not have enough space to satisfy the request, a " { $link not-enough-pile-space } " error is thrown." } ;
HELP: <pile-c-object>
{ $values
{ "pile" pile } { "c-type" "a C type" }
{ "alien" alien }
}
{ $description "Requests enough space from a " { $link pile } " to hold a value of " { $snippet "c-type" } ". If the pile does not have enough space to satisfy the request, a " { $link not-enough-pile-space } " error is thrown." } ;
HELP: pile-empty
{ $values
{ "pile" pile }
@ -42,6 +56,8 @@ ARTICLE: "memory.piles" "Piles"
"A " { $link pile } " is a block of raw memory. Portions of its memory can be allocated from the beginning of the pile in constant time, and the pile can be emptied and its pointer reset to the beginning."
{ $subsection <pile> }
{ $subsection pile-alloc }
{ $subsection <pile-c-array> }
{ $subsection <pile-c-object> }
{ $subsection pile-align }
{ $subsection pile-empty }
"An example of the utility of piles is in video games. For example, the game Abuse was scripted with a Lisp dialect. In order to avoid stalls from traditional GC or heap-based allocators, the Abuse Lisp VM would allocate values from a preallocated pile over the course of a frame, and release the entire pile at the end of the frame." ;

View File

@ -1,5 +1,5 @@
! (c)2009 Joe Groff bsd license
USING: accessors alien destructors kernel libc math ;
USING: accessors alien alien.c-types destructors kernel libc math ;
IN: memory.piles
TUPLE: pile
@ -28,6 +28,12 @@ M: pile dispose
[ + ] curry change-offset drop
] 2tri ;
: <pile-c-object> ( pile c-type -- alien )
heap-size pile-alloc ; inline
: <pile-c-array> ( pile n c-type -- alien )
heap-size * pile-alloc ; inline
: pile-align ( pile align -- pile )
[ align ] curry change-offset ;