diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-17 20:36:25 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-17 20:36:25 -0700 |
commit | 0acfaaef6a402d332f2c1e83424e9d4d0ada7455 (patch) | |
tree | 4c2912b33a27bda361d2b4227954e84801eb366b /cpp/060string.mu | |
parent | 7f931ef0f27f2815ca435bd63f3aa77329c2f096 (diff) | |
download | mu-0acfaaef6a402d332f2c1e83424e9d4d0ada7455.tar.gz |
1088 - start porting the 'buffer' type
Diffstat (limited to 'cpp/060string.mu')
-rw-r--r-- | cpp/060string.mu | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cpp/060string.mu b/cpp/060string.mu index a437c24f..85ff65b6 100644 --- a/cpp/060string.mu +++ b/cpp/060string.mu @@ -96,3 +96,20 @@ scenario string-equal-common-lengths-but-distinct [ 3 <- 0 # abc != abd ] ] + +# A new type to help incrementally construct strings. +container buffer [ + length:integer + data:address:array:character +] + +recipe init-buffer [ + default-space:address:space <- new location:type, 30:literal + result:address:buffer <- new buffer:type + len:address:integer <- get-address result:address:buffer/deref, length:offset + len:address:integer/deref <- copy 0:literal + s:address:address:array:character <- get-address result:address:buffer/deref, data:offset + capacity:integer <- next-ingredient + s:address:address:array:character/deref <- new character:type, capacity:integer + reply result:address:buffer +] |