diff --git a/factor/VocabularyLookup.java b/factor/VocabularyLookup.java index 5bf3fd1b59..27a8a962cb 100644 --- a/factor/VocabularyLookup.java +++ b/factor/VocabularyLookup.java @@ -82,6 +82,12 @@ public class VocabularyLookup FactorWord ket = define("syntax","]"); ket.parsing = new Ket(bra,ket); + /* tuples */ + FactorWord beginTuple = define("syntax","<<"); + beginTuple.parsing = new Bra(beginTuple); + FactorWord endTuple = define("syntax",">>"); + endTuple.parsing = new Ket(beginTuple,endTuple); + /* conses */ FactorWord beginCons = define("syntax","[["); beginCons.parsing = new BeginCons(beginCons); diff --git a/library/bootstrap/image.factor b/library/bootstrap/image.factor index 9c499e432c..414f6b36f5 100644 --- a/library/bootstrap/image.factor +++ b/library/bootstrap/image.factor @@ -15,9 +15,9 @@ ! run platform/native/boot-stage2.factor. IN: image -USING: errors generic hashtables kernel lists math namespaces -parser prettyprint sequences sequences stdio streams strings -vectors words ; +USING: errors generic hashtables kernel lists +math namespaces parser prettyprint sequences sequences stdio +streams strings vectors words ; ! The image being constructed; a vector of word-size integers SYMBOL: image @@ -37,17 +37,9 @@ SYMBOL: boot-quot : cell "64-bits" get 8 4 ? ; : char "64-bits" get 4 2 ? ; -: tag-mask BIN: 111 ; inline -: tag-bits 3 ; inline - : untag ( cell tag -- ) tag-mask bitnot bitand ; : tag ( cell -- tag ) tag-mask bitand ; -: fixnum-tag BIN: 000 ; inline -: bignum-tag BIN: 001 ; inline -: cons-tag BIN: 010 ; inline -: object-tag BIN: 011 ; inline - : t-type 7 ; inline : array-type 8 ; inline : hashtable-type 10 ; inline diff --git a/library/compiler/intrinsics.factor b/library/compiler/intrinsics.factor index ac4ddc8d56..4d3063124c 100644 --- a/library/compiler/intrinsics.factor +++ b/library/compiler/intrinsics.factor @@ -53,7 +53,6 @@ words ; out-1 ] "linearizer" set-word-prop - \ >r [ drop in-1 @@ -78,9 +77,10 @@ words ; : self ( word -- ) f swap dup "infer-effect" word-prop (consume/produce) ; -\ slot [ - \ slot self -] "infer" set-word-prop +: intrinsic ( word -- ) + dup [ literal, \ self , ] make-list "infer" set-word-prop ; + +\ slot intrinsic : slot@ ( seq -- n ) #! Compute slot offset. @@ -102,9 +102,7 @@ words ; ] ifte out-1 ] "linearizer" set-word-prop -\ set-slot [ - \ set-slot self -] "infer" set-word-prop +\ set-slot intrinsic \ set-slot [ node-consume-d swap hash @@ -122,37 +120,49 @@ words ; ] ifte ] "linearizer" set-word-prop -! : binary-op-reg ( op -- ) -! in-2 -! [[ << vreg f 1 >> << vreg f 0 >> ]] cons , -! 1 %dec-d , out-1 ; -! -! -! : binary-op ( node op -- ) -! top-literal? [ -! 1 %dec-d , -! in-1 -! literal-value << vreg f 0 >> swons cons , -! out-1 -! ] [ -! drop -! binary-op-reg -! ] ifte ; -! -! [ -! fixnum+ -! fixnum- -! fixnum* -! fixnum-mod -! fixnum-bitand -! fixnum-bitor -! fixnum-bitxor -! fixnum/i -! fixnum<= -! fixnum< -! fixnum>= -! fixnum> -! ] [ -! dup [ literal, \ binary-op , ] make-list -! "linearizer" set-word-prop -! ] each +\ type intrinsic + +\ type [ + drop + in-1 + 0 %type , + out-1 +] "linearizer" set-word-prop + +: binary-op-reg ( op -- ) + in-2 + << vreg f 1 >> << vreg f 0 >> rot execute , + 1 %dec-d , + out-1 ; + + +: binary-op ( node op -- ) + node-consume-d rot hash + dup top-literal? [ + 1 %dec-d , + in-1 + peek literal-value << vreg f 0 >> rot execute , + out-1 + ] [ + drop + binary-op-reg + ] ifte ; + +[ + [[ fixnum+ %fixnum+ ]] + [[ fixnum- %fixnum- ]] + [[ fixnum* %fixnum* ]] + [[ fixnum-mod %fixnum-mod ]] + [[ fixnum-bitand %fixnum-bitand ]] + [[ fixnum-bitor %fixnum-bitor ]] + [[ fixnum-bitxor %fixnum-bitxor ]] + [[ fixnum/i %fixnum/i ]] + [[ fixnum<= %fixnum<= ]] + [[ fixnum< %fixnum< ]] + [[ fixnum>= %fixnum>= ]] + [[ fixnum> %fixnum> ]] +] [ + uncons over intrinsic + [ literal, \ binary-op , ] make-list + "linearizer" set-word-prop +] each diff --git a/library/compiler/linearizer.factor b/library/compiler/linearizer.factor index 73abc7b475..29ac02de4a 100644 --- a/library/compiler/linearizer.factor +++ b/library/compiler/linearizer.factor @@ -78,7 +78,9 @@ errors prettyprint kernel-internals ; : dispatch-head ( vtable -- end label/code ) #! Output the jump table insn and return a list of #! label/branch pairs. - %dispatch , + in-1 + 1 %dec-d , + 0 %dispatch ,