# HG changeset patch # User Leonard Ritter # Date 1684934136 -7200 # Wed May 24 15:15:36 2023 +0200 # Node ID 39915d8c09d5534767694ca22b4ce1186bcc6117 # Parent 2a3a5d27ab7b440045abae21b2b8f9d5b47f2192 * atom: `cell` and `blob` use FatArray by default diff --git a/lib/scopes/compiler/atom.sc b/lib/scopes/compiler/atom.sc --- a/lib/scopes/compiler/atom.sc +++ b/lib/scopes/compiler/atom.sc @@ -155,6 +155,13 @@ super-type.__typecall cls keys = cls.ArrayType ... + @@ memo + inline __rimply (T cls) + static-if (T == cls.ArrayType) + inline (self) + super-type.__typecall cls + keys = (move self) + fn invalidate (self offset count) cls := typeof self x0 := offset // cls.Stride @@ -237,6 +244,9 @@ inline append (self value) 'append self.keys (autocopy value) + fn append-from-arrayptr (self ptr sz) + 'append-from-arrayptr self.keys ptr sz + inline updated? (self) (countof self.past) == (countof self.keys) @@ -261,6 +271,10 @@ self.pastcount = keyscount ; + fn data (self offset) + viewing self + 'data self.keys 0:usize + inline indexof (self value) """"return the absolute last index of `value` copy ('getdefault self.map value NoIndex) @@ -393,9 +407,8 @@ inline wrap (cls arr) count := copy (countof arr) - data := Rc.wrap arr super-type.__typecall cls - data = data + data = arr offset = 0 count = count @@ -440,7 +453,7 @@ inline... join (self, other : this-type) self := 'align self - 'append-from-arrayptr self.data ('data other.data other.offset) other.count + 'append-from-arrayptr self.data ('data other) other.count cls := typeof self super-type.__typecall cls data = copy self.data @@ -678,7 +691,8 @@ ############################### -Cell := Slice (Array Atom) +Cell := Slice (FatArray (Array Atom) 1) +#Cell := Slice (Array Atom) CellView := Cell.SliceViewType type+ Cell @@ -722,7 +736,8 @@ ############################### -Blob := Slice String +Blob := Slice (FatArray String 8) +#Blob := Slice String BlobView := Blob.SliceViewType fn... blob-quotestr (x : String, start : usize, end : usize) @@ -1090,6 +1105,8 @@ ############################### +run-stage; + static-if main-module? using import testing .Printer @@ -1127,27 +1144,7 @@ k += 1 test (k == 4) do - cell := (SliceT) - cell := 'append cell "1" - cell := 'append cell "2" - cell := 'append cell "3" - cell := 'append cell "4" - cell := 'append cell "5" - cell := 'append cell "1" - cell := 'append cell "2" - cell := 'append cell "3" - cell := 'append cell "4" - cell := 'append cell "5" - cell := 'append cell "1" - cell := 'append cell "2" - cell := 'append cell "3" - cell := 'append cell "4" - cell := 'append cell "5" - cell := 'append cell "1" - cell := 'append cell "2" - cell := 'append cell "3" - cell := 'append cell "4" - cell := 'append cell "5" + cell := b"12345123451234512345" s5a := slice (copy cell) 0 5 s5b := slice (copy cell) 5 10 @@ -1170,6 +1167,8 @@ print hash s10a hash s10b + test + (hash (copy cell)) == (hash (s10a .. s10b)) #test == hash (slice (copy cell) 1 3)