diff --git a/basis/compiler/tree/escape-analysis/simple/simple.factor b/basis/compiler/tree/escape-analysis/simple/simple.factor index e143fb75ed..0324b31199 100644 --- a/basis/compiler/tree/escape-analysis/simple/simple.factor +++ b/basis/compiler/tree/escape-analysis/simple/simple.factor @@ -23,9 +23,8 @@ DEFER: record-literal-allocation [ [ swap record-literal-allocation ] keep ] map ; : object-slots ( object -- slots/f ) - #! Delegation { - { [ dup class immutable-tuple-class? ] [ tuple-slots rest-slice ] } + { [ dup class immutable-tuple-class? ] [ tuple-slots ] } { [ dup complex? ] [ [ real-part ] [ imaginary-part ] bi 2array ] } [ drop f ] } cond ; @@ -37,7 +36,6 @@ DEFER: record-literal-allocation if* ; M: #push escape-analysis* - #! Delegation. [ out-d>> first ] [ literal>> ] bi record-literal-allocation ; : record-unknown-allocation ( #call -- ) @@ -59,7 +57,7 @@ M: #push escape-analysis* [ second node-value-info literal>> ] 2bi dup fixnum? [ { - { [ over tuple class<= ] [ 3 - ] } + { [ over tuple class<= ] [ 2 - ] } { [ over complex class<= ] [ 1 - ] } [ drop f ] } cond nip diff --git a/basis/compiler/tree/finalization/finalization.factor b/basis/compiler/tree/finalization/finalization.factor index 4de81306cc..759f92c9be 100644 --- a/basis/compiler/tree/finalization/finalization.factor +++ b/basis/compiler/tree/finalization/finalization.factor @@ -67,15 +67,14 @@ MEMO: builtin-predicate-expansion ( word -- nodes ) MEMO: (tuple-boa-expansion) ( n -- quot ) [ - 1- [ 3 + ] map + [ 2 + ] map [ '[ [ , set-slot ] keep ] % ] each - [ f over 2 set-slot ] % ] [ ] make ; : tuple-boa-expansion ( layout -- quot ) #! No memoization here since otherwise we'd hang on to #! tuple layout objects. - [ \ (tuple) , size>> (tuple-boa-expansion) % ] [ ] make splice-quot ; + size>> (tuple-boa-expansion) \ (tuple) prefix splice-quot ; : expand-tuple-boa ( #call -- node ) last-literal tuple-boa-expansion ; diff --git a/basis/compiler/tree/propagation/info/info.factor b/basis/compiler/tree/propagation/info/info.factor index d0f418f3c9..8f2220aaaf 100644 --- a/basis/compiler/tree/propagation/info/info.factor +++ b/basis/compiler/tree/propagation/info/info.factor @@ -60,15 +60,13 @@ slots ; : ( -- info ) \ value-info new ; : read-only-slots ( values class -- slots ) - #! Delegation. - all-slots rest-slice + all-slots [ read-only>> [ drop f ] unless ] 2map - { f f } prepend ; + f prefix ; DEFER: : init-literal-info ( info -- info ) - #! Delegation. dup literal>> class >>class dup literal>> dup real? [ [a,a] >>interval ] [ [ [-inf,inf] >>interval ] dip @@ -79,10 +77,8 @@ DEFER: 2array >>slots ] } { [ dup tuple? ] [ - [ - tuple-slots rest-slice - [ ] map - ] [ class ] bi read-only-slots >>slots + [ tuple-slots [ ] map ] [ class ] bi + read-only-slots >>slots ] } [ drop ] } cond diff --git a/basis/compiler/tree/propagation/slots/slots.factor b/basis/compiler/tree/propagation/slots/slots.factor index a4bd48ecc0..08a8520d0a 100644 --- a/basis/compiler/tree/propagation/slots/slots.factor +++ b/basis/compiler/tree/propagation/slots/slots.factor @@ -32,19 +32,18 @@ UNION: fixed-length-sequence array byte-array string ; { } memq? ; : fold- ( values class -- info ) - [ , f , [ literal>> ] map % ] { } make >tuple + [ [ literal>> ] map ] dip prefix >tuple ; : (propagate-tuple-constructor) ( values class -- info ) [ [ value-info ] map ] dip [ read-only-slots ] keep - over 2 tail-slice [ dup [ literal?>> ] when ] all? [ - [ 2 tail-slice ] dip fold- + over rest-slice [ dup [ literal?>> ] when ] all? [ + [ rest-slice ] dip fold- ] [ ] if ; : propagate- ( #call -- info ) - #! Delegation in-d>> unclip-last value-info literal>> class>> (propagate-tuple-constructor) ; @@ -69,7 +68,6 @@ UNION: fixed-length-sequence array byte-array string ; [ 1 = ] [ length>> ] bi* and ; : value-info-slot ( slot info -- info' ) - #! Delegation. { { [ over 0 = ] [ 2drop fixnum ] } { [ 2dup length-accessor? ] [ nip length>> ] } diff --git a/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor b/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor index 334fcb11f0..858e40347f 100644 --- a/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor +++ b/basis/compiler/tree/tuple-unboxing/tuple-unboxing-tests.factor @@ -30,7 +30,7 @@ TUPLE: empty-tuple ; [ dup cons boa 10 [ nip dup cons boa ] each-integer car>> ] [ 2 cons boa { [ ] [ ] } dispatch ] [ dup [ drop f ] [ "A" throw ] if ] - [ [ ] [ ] curry curry dup 3 slot swap 4 slot dup 3 slot swap 4 slot drop ] + [ [ ] [ ] curry curry dup 2 slot swap 3 slot dup 2 slot swap 3 slot drop ] [ [ ] [ ] curry curry call ] [ dup 1 slot drop 2 slot drop ] [ 1 cons boa over [ "A" throw ] when car>> ] diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index 8e5e932666..87f6d3122e 100755 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -163,10 +163,12 @@ M: byte-vector >pprint-sequence ; M: curry >pprint-sequence ; M: compose >pprint-sequence ; M: hashtable >pprint-sequence >alist ; -M: tuple >pprint-sequence tuple>array ; M: wrapper >pprint-sequence wrapped>> 1array ; M: callstack >pprint-sequence callstack>array ; +M: tuple >pprint-sequence + [ class f 2array ] [ tuple-slots ] bi append ; + GENERIC: pprint-narrow? ( obj -- ? ) M: object pprint-narrow? drop f ; diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 5cbd5f40af..1c25df4112 100755 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -108,7 +108,7 @@ M: object infer-call* : infer- ( -- ) \ - peek-d literal value>> size>> { tuple } + peek-d literal value>> size>> 1+ { tuple } apply-word/effect ; : infer-(throw) ( -- ) diff --git a/basis/stack-checker/transforms/transforms.factor b/basis/stack-checker/transforms/transforms.factor index 1bdfdb6f42..2773b8b4e4 100755 --- a/basis/stack-checker/transforms/transforms.factor +++ b/basis/stack-checker/transforms/transforms.factor @@ -105,8 +105,11 @@ IN: stack-checker.transforms \ new [ dup tuple-class? [ dup inlined-dependency depends-on - dup all-slots rest-slice ! delegate slot - [ [ initial>> literalize , ] each literalize , \ boa , ] [ ] make + [ + [ all-slots [ initial>> literalize , ] each ] + [ literalize , ] bi + \ boa , + ] [ ] make ] [ drop f ] if ] 1 define-transform diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 8d9f812cee..ad56dbd296 100755 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -281,18 +281,12 @@ bi "tuple" "kernel" create [ { } define-builtin ] [ define-tuple-layout ] -[ - { "delegate" } make-slots - [ drop ] [ finalize-tuple-slots ] 2bi - [ "slots" set-word-prop ] - [ define-accessors ] - 2bi -] tri +bi ! Create special tombstone values "tombstone" "hashtables.private" create tuple -{ } define-tuple-class +{ "state" } define-tuple-class "((empty))" "hashtables.private" create "tombstone" "hashtables.private" lookup f diff --git a/core/bootstrap/stage1.factor b/core/bootstrap/stage1.factor index 92558561d2..56c9382d1a 100755 --- a/core/bootstrap/stage1.factor +++ b/core/bootstrap/stage1.factor @@ -21,7 +21,7 @@ load-help? off ! using the host image's hashing algorithms. We don't ! use each-object here since the catch stack isn't yet ! set up. - begin-scan + begin-scan USE: accessors USE: kernel.private [ hashtable? ] pusher [ (each-object) ] dip end-scan [ rehash ] each diff --git a/core/classes/tuple/parser/parser.factor b/core/classes/tuple/parser/parser.factor index 47363378fa..e85910d18d 100644 --- a/core/classes/tuple/parser/parser.factor +++ b/core/classes/tuple/parser/parser.factor @@ -58,3 +58,10 @@ ERROR: invalid-slot-name name ; } case dup check-duplicate-slots 3dup check-slot-shadowing ; + +: literal>tuple ( seq -- tuple ) + { + { [ dup length 1 = ] [ first new ] } + { [ dup second not ] [ [ 2 tail ] [ first ] bi slots>tuple ] } + [ "Not implemented" throw ] + } cond ; diff --git a/core/classes/tuple/tuple.factor b/core/classes/tuple/tuple.factor index 80ccc8fd9f..b48f04fa5d 100755 --- a/core/classes/tuple/tuple.factor +++ b/core/classes/tuple/tuple.factor @@ -21,8 +21,7 @@ ERROR: not-a-tuple object ; superclasses [ "slots" word-prop ] map concat ; PREDICATE: immutable-tuple-class < tuple-class ( class -- ? ) - #! Delegation - all-slots rest-slice [ read-only>> ] all? ; + all-slots [ read-only>> ] all? ; > instance-check-quot ] map spread>quot ; + all-slots [ class>> instance-check-quot ] map spread>quot ; : define-boa-check ( class -- ) dup boa-check-quot "boa-check" set-word-prop ; diff --git a/core/quotations/quotations.factor b/core/quotations/quotations.factor index 617dac3323..31e5e4753d 100755 --- a/core/quotations/quotations.factor +++ b/core/quotations/quotations.factor @@ -7,9 +7,9 @@ IN: quotations diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index e156832923..1617617b44 100755 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -83,7 +83,7 @@ IN: bootstrap.syntax "B{" [ \ } [ >byte-array ] parse-literal ] define-syntax "BV{" [ \ } [ >byte-vector ] parse-literal ] define-syntax "H{" [ \ } [ >hashtable ] parse-literal ] define-syntax - "T{" [ \ } [ >tuple ] parse-literal ] define-syntax + "T{" [ \ } [ literal>tuple ] parse-literal ] define-syntax "W{" [ \ } [ first ] parse-literal ] define-syntax "POSTPONE:" [ scan-word parsed ] define-syntax diff --git a/vm/types.c b/vm/types.c index 59581ecee5..3097ee73f8 100755 --- a/vm/types.c +++ b/vm/types.c @@ -345,11 +345,8 @@ DEFINE_PRIMITIVE(tuple_boa) F_TUPLE *tuple = allot_tuple(layout); UNREGISTER_UNTAGGED(layout); - /* set delegate slot */ - put(AREF(tuple,0),F); - F_FIXNUM i; - for(i = size - 1; i >= 1; i--) + for(i = size - 1; i >= 0; i--) put(AREF(tuple,i),dpop()); dpush(tag_tuple(tuple));