Fix conflict
parent
5c6c3ecd85
commit
1acf243cce
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008, 2009 Slava Pestov, Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: sequences accessors layouts kernel math namespaces
|
USING: sequences accessors layouts kernel math namespaces
|
||||||
combinators fry locals
|
combinators fry locals
|
||||||
|
@ -17,13 +17,14 @@ IN: compiler.cfg.intrinsics.fixnum
|
||||||
0 cc= ^^compare-imm
|
0 cc= ^^compare-imm
|
||||||
ds-push ;
|
ds-push ;
|
||||||
|
|
||||||
: (emit-fixnum-imm-op) ( infos insn -- dst )
|
: tag-literal ( n -- tagged )
|
||||||
ds-drop
|
literal>> [ tag-fixnum ] [ \ f tag-number ] if* ;
|
||||||
[ ds-pop ]
|
|
||||||
[ second literal>> [ tag-fixnum ] [ \ f tag-number ] if* ]
|
: emit-fixnum-imm-op1 ( infos insn -- dst )
|
||||||
[ ]
|
[ ds-pop ds-drop ] [ first tag-literal ] [ ] tri* call ; inline
|
||||||
tri*
|
|
||||||
call ; inline
|
: emit-fixnum-imm-op2 ( infos insn -- dst )
|
||||||
|
[ ds-drop ds-pop ] [ second tag-literal ] [ ] tri* call ; inline
|
||||||
|
|
||||||
: (emit-fixnum-op) ( insn -- dst )
|
: (emit-fixnum-op) ( insn -- dst )
|
||||||
[ 2inputs ] dip call ; inline
|
[ 2inputs ] dip call ; inline
|
||||||
|
@ -31,9 +32,22 @@ IN: compiler.cfg.intrinsics.fixnum
|
||||||
:: emit-fixnum-op ( node insn imm-insn -- )
|
:: emit-fixnum-op ( node insn imm-insn -- )
|
||||||
[let | infos [ node node-input-infos ] |
|
[let | infos [ node node-input-infos ] |
|
||||||
infos second value-info-small-tagged?
|
infos second value-info-small-tagged?
|
||||||
[ infos imm-insn (emit-fixnum-imm-op) ]
|
[ infos imm-insn emit-fixnum-imm-op2 ]
|
||||||
[ insn (emit-fixnum-op) ]
|
[ insn (emit-fixnum-op) ] if
|
||||||
if
|
ds-push
|
||||||
|
] ; inline
|
||||||
|
|
||||||
|
:: emit-commutative-fixnum-op ( node insn imm-insn -- )
|
||||||
|
[let | infos [ node node-input-infos ] |
|
||||||
|
infos first value-info-small-tagged?
|
||||||
|
[ infos imm-insn emit-fixnum-imm-op1 ]
|
||||||
|
[
|
||||||
|
infos second value-info-small-tagged? [
|
||||||
|
infos imm-insn emit-fixnum-imm-op2
|
||||||
|
] [
|
||||||
|
insn (emit-fixnum-op)
|
||||||
|
] if
|
||||||
|
] if
|
||||||
ds-push
|
ds-push
|
||||||
] ; inline
|
] ; inline
|
||||||
|
|
||||||
|
@ -68,9 +82,14 @@ IN: compiler.cfg.intrinsics.fixnum
|
||||||
[ (emit-fixnum*fast-imm) ] [ drop (emit-fixnum*fast) ] if
|
[ (emit-fixnum*fast-imm) ] [ drop (emit-fixnum*fast) ] if
|
||||||
ds-push ;
|
ds-push ;
|
||||||
|
|
||||||
|
: (emit-fixnum-comparison) ( cc -- quot1 quot2 )
|
||||||
|
[ ^^compare ] [ ^^compare-imm ] bi-curry ; inline
|
||||||
|
|
||||||
|
: emit-eq ( node -- )
|
||||||
|
cc= (emit-fixnum-comparison) emit-commutative-fixnum-op ;
|
||||||
|
|
||||||
: emit-fixnum-comparison ( node cc -- )
|
: emit-fixnum-comparison ( node cc -- )
|
||||||
[ ^^compare ] [ ^^compare-imm ] bi-curry
|
(emit-fixnum-comparison) emit-fixnum-op ;
|
||||||
emit-fixnum-op ;
|
|
||||||
|
|
||||||
: emit-bignum>fixnum ( -- )
|
: emit-bignum>fixnum ( -- )
|
||||||
ds-pop ^^bignum>integer ^^tag-fixnum ds-push ;
|
ds-pop ^^bignum>integer ^^tag-fixnum ds-push ;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008, 2009 Slava Pestov, Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: words sequences kernel combinators cpu.architecture
|
USING: words sequences kernel combinators cpu.architecture
|
||||||
compiler.cfg.hats
|
compiler.cfg.hats
|
||||||
|
@ -102,11 +102,11 @@ IN: compiler.cfg.intrinsics
|
||||||
{ \ math.private:fixnum+ [ drop [ ##fixnum-add ] emit-fixnum-overflow-op ] }
|
{ \ math.private:fixnum+ [ drop [ ##fixnum-add ] emit-fixnum-overflow-op ] }
|
||||||
{ \ math.private:fixnum- [ drop [ ##fixnum-sub ] emit-fixnum-overflow-op ] }
|
{ \ math.private:fixnum- [ drop [ ##fixnum-sub ] emit-fixnum-overflow-op ] }
|
||||||
{ \ math.private:fixnum* [ drop [ i i ##fixnum-mul ] emit-fixnum-overflow-op ] }
|
{ \ math.private:fixnum* [ drop [ i i ##fixnum-mul ] emit-fixnum-overflow-op ] }
|
||||||
{ \ math.private:fixnum+fast [ [ ^^add ] [ ^^add-imm ] emit-fixnum-op ] }
|
{ \ math.private:fixnum+fast [ [ ^^add ] [ ^^add-imm ] emit-commutative-fixnum-op ] }
|
||||||
{ \ math.private:fixnum-fast [ [ ^^sub ] [ ^^sub-imm ] emit-fixnum-op ] }
|
{ \ math.private:fixnum-fast [ [ ^^sub ] [ ^^sub-imm ] emit-fixnum-op ] }
|
||||||
{ \ math.private:fixnum-bitand [ [ ^^and ] [ ^^and-imm ] emit-fixnum-op ] }
|
{ \ math.private:fixnum-bitand [ [ ^^and ] [ ^^and-imm ] emit-commutative-fixnum-op ] }
|
||||||
{ \ math.private:fixnum-bitor [ [ ^^or ] [ ^^or-imm ] emit-fixnum-op ] }
|
{ \ math.private:fixnum-bitor [ [ ^^or ] [ ^^or-imm ] emit-commutative-fixnum-op ] }
|
||||||
{ \ math.private:fixnum-bitxor [ [ ^^xor ] [ ^^xor-imm ] emit-fixnum-op ] }
|
{ \ math.private:fixnum-bitxor [ [ ^^xor ] [ ^^xor-imm ] emit-commutative-fixnum-op ] }
|
||||||
{ \ math.private:fixnum-shift-fast [ emit-fixnum-shift-fast ] }
|
{ \ math.private:fixnum-shift-fast [ emit-fixnum-shift-fast ] }
|
||||||
{ \ math.private:fixnum-bitnot [ drop emit-fixnum-bitnot ] }
|
{ \ math.private:fixnum-bitnot [ drop emit-fixnum-bitnot ] }
|
||||||
{ \ math.integers.private:fixnum-log2 [ drop emit-fixnum-log2 ] }
|
{ \ math.integers.private:fixnum-log2 [ drop emit-fixnum-log2 ] }
|
||||||
|
@ -115,7 +115,7 @@ IN: compiler.cfg.intrinsics
|
||||||
{ \ math.private:fixnum<= [ cc<= emit-fixnum-comparison ] }
|
{ \ math.private:fixnum<= [ cc<= emit-fixnum-comparison ] }
|
||||||
{ \ math.private:fixnum>= [ cc>= emit-fixnum-comparison ] }
|
{ \ math.private:fixnum>= [ cc>= emit-fixnum-comparison ] }
|
||||||
{ \ math.private:fixnum> [ cc> emit-fixnum-comparison ] }
|
{ \ math.private:fixnum> [ cc> emit-fixnum-comparison ] }
|
||||||
{ \ kernel:eq? [ cc= emit-fixnum-comparison ] }
|
{ \ kernel:eq? [ emit-eq ] }
|
||||||
{ \ math.private:bignum>fixnum [ drop emit-bignum>fixnum ] }
|
{ \ math.private:bignum>fixnum [ drop emit-bignum>fixnum ] }
|
||||||
{ \ math.private:fixnum>bignum [ drop emit-fixnum>bignum ] }
|
{ \ math.private:fixnum>bignum [ drop emit-fixnum>bignum ] }
|
||||||
{ \ math.private:float+ [ drop [ ^^add-float ] emit-float-op ] }
|
{ \ math.private:float+ [ drop [ ^^add-float ] emit-float-op ] }
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
USING: arrays sequences tools.test compiler.cfg.checker compiler.cfg.debugger
|
USING: arrays sequences tools.test compiler.cfg.checker
|
||||||
compiler.cfg.def-use sets kernel kernel.private fry slots.private vectors
|
compiler.cfg.debugger compiler.cfg.def-use sets kernel
|
||||||
sequences.private math sbufs math.private slots.private strings ;
|
kernel.private fry slots.private vectors sequences.private
|
||||||
|
math sbufs math.private strings ;
|
||||||
IN: compiler.cfg.optimizer.tests
|
IN: compiler.cfg.optimizer.tests
|
||||||
|
|
||||||
! Miscellaneous tests
|
! Miscellaneous tests
|
||||||
|
|
|
@ -1,39 +1,45 @@
|
||||||
! Copyright (C) 2008 Doug Coleman.
|
! Copyright (C) 2008 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors kernel furnace.actions html.forms
|
USING: accessors furnace.actions furnace.redirection
|
||||||
http.server.dispatchers db db.tuples db.types urls
|
html.forms http http.server http.server.dispatchers
|
||||||
furnace.redirection multiline http namespaces ;
|
io.directories io.encodings.utf8 io.files io.pathnames
|
||||||
|
kernel math.parser multiline namespaces sequences urls ;
|
||||||
IN: webapps.imagebin
|
IN: webapps.imagebin
|
||||||
|
|
||||||
TUPLE: imagebin < dispatcher ;
|
TUPLE: imagebin < dispatcher path n ;
|
||||||
|
|
||||||
TUPLE: image id path ;
|
|
||||||
|
|
||||||
image "IMAGE" {
|
|
||||||
{ "id" "ID" INTEGER +db-assigned-id+ }
|
|
||||||
{ "path" "PATH" { VARCHAR 256 } +not-null+ }
|
|
||||||
} define-persistent
|
|
||||||
|
|
||||||
: <uploaded-image-action> ( -- action )
|
: <uploaded-image-action> ( -- action )
|
||||||
<page-action>
|
<page-action>
|
||||||
{ imagebin "uploaded-image" } >>template ;
|
{ imagebin "uploaded-image" } >>template ;
|
||||||
|
|
||||||
SYMBOL: my-post-data
|
: next-image-path ( -- path )
|
||||||
|
imagebin get
|
||||||
|
[ path>> ] [ n>> number>string ] bi append-path ;
|
||||||
|
|
||||||
|
M: imagebin call-responder*
|
||||||
|
[ imagebin set ] [ call-next-method ] bi ;
|
||||||
|
|
||||||
|
: move-image ( mime-file -- )
|
||||||
|
next-image-path
|
||||||
|
[ [ temporary-path>> ] dip move-file ]
|
||||||
|
[ [ filename>> ] dip ".txt" append utf8 set-file-contents ] 2bi ;
|
||||||
|
|
||||||
: <upload-image-action> ( -- action )
|
: <upload-image-action> ( -- action )
|
||||||
<page-action>
|
<page-action>
|
||||||
{ imagebin "upload-image" } >>template
|
{ imagebin "upload-image" } >>template
|
||||||
[
|
[
|
||||||
|
"file1" param [ move-image ] when*
|
||||||
! request get post-data>> my-post-data set-global
|
"file2" param [ move-image ] when*
|
||||||
! image new
|
"file3" param [ move-image ] when*
|
||||||
! "file" value
|
|
||||||
! insert-tuple
|
|
||||||
"uploaded-image" <redirect>
|
"uploaded-image" <redirect>
|
||||||
] >>submit ;
|
] >>submit ;
|
||||||
|
|
||||||
: <imagebin> ( -- responder )
|
: <imagebin> ( image-directory -- responder )
|
||||||
imagebin new-dispatcher
|
imagebin new-dispatcher
|
||||||
|
swap [ make-directories ] [ >>path ] bi
|
||||||
|
0 >>n
|
||||||
<upload-image-action> "" add-responder
|
<upload-image-action> "" add-responder
|
||||||
<upload-image-action> "upload-image" add-responder
|
<upload-image-action> "upload-image" add-responder
|
||||||
<uploaded-image-action> "uploaded-image" add-responder ;
|
<uploaded-image-action> "uploaded-image" add-responder ;
|
||||||
|
|
||||||
|
"resource:images" <imagebin> main-responder set-global
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
<html>
|
<html>
|
||||||
<head><title>Uploaded</title></head>
|
<head><title>Uploaded</title></head>
|
||||||
<body>
|
<body>
|
||||||
hi from uploaded-image
|
You uploaded something!
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue