From 1972351d7f3f9e946832a352f7fa81b649dce1c3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 21 Jun 2010 22:26:01 -0400 Subject: [PATCH] Move hashtables.identity to basis and update serialize vocab to use them --- .../hashtables/identity/authors.txt | 0 .../hashtables/identity/identity-tests.factor | 0 .../hashtables/identity/identity.factor | 0 .../identity/mirrors/mirrors.factor | 0 .../identity/prettyprint/prettyprint.factor | 0 .../hashtables/identity/summary.txt | 0 basis/serialize/serialize.factor | 24 +++++++------------ 7 files changed, 8 insertions(+), 16 deletions(-) rename {extra => basis}/hashtables/identity/authors.txt (100%) rename {extra => basis}/hashtables/identity/identity-tests.factor (100%) rename {extra => basis}/hashtables/identity/identity.factor (100%) rename {extra => basis}/hashtables/identity/mirrors/mirrors.factor (100%) rename {extra => basis}/hashtables/identity/prettyprint/prettyprint.factor (100%) rename {extra => basis}/hashtables/identity/summary.txt (100%) diff --git a/extra/hashtables/identity/authors.txt b/basis/hashtables/identity/authors.txt similarity index 100% rename from extra/hashtables/identity/authors.txt rename to basis/hashtables/identity/authors.txt diff --git a/extra/hashtables/identity/identity-tests.factor b/basis/hashtables/identity/identity-tests.factor similarity index 100% rename from extra/hashtables/identity/identity-tests.factor rename to basis/hashtables/identity/identity-tests.factor diff --git a/extra/hashtables/identity/identity.factor b/basis/hashtables/identity/identity.factor similarity index 100% rename from extra/hashtables/identity/identity.factor rename to basis/hashtables/identity/identity.factor diff --git a/extra/hashtables/identity/mirrors/mirrors.factor b/basis/hashtables/identity/mirrors/mirrors.factor similarity index 100% rename from extra/hashtables/identity/mirrors/mirrors.factor rename to basis/hashtables/identity/mirrors/mirrors.factor diff --git a/extra/hashtables/identity/prettyprint/prettyprint.factor b/basis/hashtables/identity/prettyprint/prettyprint.factor similarity index 100% rename from extra/hashtables/identity/prettyprint/prettyprint.factor rename to basis/hashtables/identity/prettyprint/prettyprint.factor diff --git a/extra/hashtables/identity/summary.txt b/basis/hashtables/identity/summary.txt similarity index 100% rename from extra/hashtables/identity/summary.txt rename to basis/hashtables/identity/summary.txt diff --git a/basis/serialize/serialize.factor b/basis/serialize/serialize.factor index 10d68fee59..7debb1ae61 100644 --- a/basis/serialize/serialize.factor +++ b/basis/serialize/serialize.factor @@ -8,11 +8,11 @@ ! USING: namespaces sequences kernel math io math.functions io.binary strings classes words sbufs classes.tuple arrays -vectors byte-arrays quotations hashtables assocs help.syntax -help.markup splitting io.streams.byte-array io.encodings.string -io.encodings.utf8 io.encodings.binary combinators accessors -locals prettyprint compiler.units sequences.private -classes.tuple.private vocabs.loader ; +vectors byte-arrays quotations hashtables hashtables.identity +assocs help.syntax help.markup splitting io.streams.byte-array +io.encodings.string io.encodings.utf8 io.encodings.binary +combinators accessors locals prettyprint compiler.units +sequences.private classes.tuple.private vocabs.loader ; IN: serialize GENERIC: (serialize) ( obj -- ) @@ -22,22 +22,14 @@ GENERIC: (serialize) ( obj -- ) ! Variable holding a assoc of objects already serialized SYMBOL: serialized -TUPLE: id obj ; - -C: id - -M: id hashcode* nip obj>> identity-hashcode ; - -M: id equal? over id? [ [ obj>> ] bi@ eq? ] [ 2drop f ] if ; - : add-object ( obj -- ) #! Add an object to the sequence of already serialized #! objects. - serialized get [ assoc-size swap ] keep set-at ; + serialized get [ assoc-size swap ] keep set-at ; : object-id ( obj -- id ) #! Return the id of an already serialized object - serialized get at ; + serialized get at ; ! Numbers are serialized as follows: ! 0 => B{ 0 } @@ -289,7 +281,7 @@ PRIVATE> [ (deserialize) ] with-variable ; : serialize ( obj -- ) - H{ } clone serialized [ (serialize) ] with-variable ; + IH{ } clone serialized [ (serialize) ] with-variable ; : bytes>object ( bytes -- obj ) binary [ deserialize ] with-byte-reader ;