about summary refs log tree commit diff stats
path: root/101run_sandboxed.cc
Commit message (Expand)AuthorAgeFilesLines
* 5001 - drop the :(scenario) DSLKartik Agaram2019-03-121-177/+246
* 4995Kartik Agaram2019-03-061-1/+2
* 4994Kartik Agaram2019-03-031-1/+1
* 4993Kartik Agaram2019-03-031-3/+2
* 4987 - support `browse_trace` tool in SubXKartik Agaram2019-02-251-3/+9
* 4421Kartik Agaram2018-07-261-1/+1
* 4266 - space for alloc-id in heap allocationsKartik Agaram2018-06-241-51/+86
* 4258 - undo 4257Kartik Agaram2018-06-151-67/+44
* 4257 - abortive attempt at safe fat pointersKartik Agaram2018-06-151-44/+67
* 4088Kartik K. Agaram2017-10-211-1/+1
* 3966Kartik K. Agaram2017-07-091-1/+1
* 3907 - standardize test failure messagesKartik K. Agaram2017-06-151-2/+2
* 3888 - beginnings of a profilerKartik K. Agaram2017-05-281-0/+5
* 3805Kartik K. Agaram2017-03-201-3/+45
* 3803Kartik K. Agaram2017-03-201-1/+0
* 3802 - more accurate sandbox resultsKartik K. Agaram2017-03-201-1/+21
* 3801Kartik K. Agaram2017-03-201-5/+5
* 3730Kartik K. Agaram2017-01-061-0/+8
* 3705 - switch to tested file-system primitivesKartik K. Agaram2016-12-111-1/+1
* 3561Kartik K. Agaram2016-10-221-2/+2
* 3409Kartik K. Agaram2016-09-221-0/+4
* 3408Kartik K. Agaram2016-09-221-11/+1
* 3390Kartik K. Agaram2016-09-171-5/+5
* 3389Kartik K. Agaram2016-09-171-3/+3
* 3388Kartik K. Agaram2016-09-171-1/+1
* 3385Kartik K. Agaram2016-09-171-16/+16
* 3379Kartik K. Agaram2016-09-171-4/+4
* 3377Kartik K. Agaram2016-09-171-25/+25
* 3374Kartik K. Agaram2016-09-161-10/+10
* 3367Kartik K. Agaram2016-09-151-8/+24
* 3269Kartik K. Agaram2016-08-281-1/+0
* 3230Kartik K. Agaram2016-08-201-0/+518
s="w"> use an exclusive-container. container list:_elem [ value:_elem next:address:shared:list:_elem ] recipe push x:_elem, in:address:shared:list:_elem -> in:address:shared:list:_elem [ local-scope load-ingredients result:address:shared:list:_elem <- new {(list _elem): type} val:address:_elem <- get-address *result, value:offset *val <- copy x next:address:address:shared:list:_elem <- get-address *result, next:offset *next <- copy in reply result # needed explicitly because we need to replace 'in' with 'result' ] recipe first in:address:shared:list:_elem -> result:_elem [ local-scope load-ingredients result <- get *in, value:offset ] recipe rest in:address:shared:list:_elem -> result:address:shared:list:_elem/contained-in:in [ local-scope load-ingredients result <- get *in, next:offset ] scenario list-handling [ run [ 1:address:shared:list:number <- push 3, 0 1:address:shared:list:number <- push 4, 1:address:shared:list:number 1:address:shared:list:number <- push 5, 1:address:shared:list:number 2:number <- first 1:address:shared:list:number 1:address:shared:list:number <- rest 1:address:shared:list:number 3:number <- first 1:address:shared:list:number 1:address:shared:list:number <- rest 1:address:shared:list:number 4:number <- first 1:address:shared:list:number 1:address:shared:list:number <- rest 1:address:shared:list:number ] memory-should-contain [ 1 <- 0 # empty to empty, dust to dust.. 2 <- 5 3 <- 4 4 <- 3 ] ] recipe to-text in:address:shared:list:_elem -> result:address:shared:array:character [ local-scope #? $print [to text: list], 10/newline load-ingredients buf:address:shared:buffer <- new-buffer 80 buf <- to-buffer in, buf result <- buffer-to-array buf ] # variant of 'to-text' which stops printing after a few elements (and so is robust to cycles) recipe to-text-line in:address:shared:list:_elem -> result:address:shared:array:character [ local-scope #? $print [to text line: list], 10/newline load-ingredients buf:address:shared:buffer <- new-buffer 80 buf <- to-buffer in, buf, 6 # max elements to display result <- buffer-to-array buf ] recipe to-buffer in:address:shared:list:_elem, buf:address:shared:buffer -> buf:address:shared:buffer [ local-scope #? $print [to buffer: list], 10/newline load-ingredients { break-if in buf <- append buf, 48/0 reply } # append in.value to buf val:_elem <- get *in, value:offset buf <- append buf, val # now prepare next next:address:shared:list:_elem <- rest in nextn:number <- copy next #? buf <- append buf, nextn reply-unless next space:character <- copy 32/space buf <- append buf, space:character s:address:shared:array:character <- new [-> ] n:number <- length *s buf <- append buf, s # and recurse remaining:number, optional-ingredient-found?:boolean <- next-ingredient { break-if optional-ingredient-found? # unlimited recursion buf <- to-buffer next, buf reply } { break-unless remaining # limited recursion remaining <- subtract remaining, 1 buf <- to-buffer next, buf, remaining reply } # past recursion depth; insert ellipses and stop s:address:shared:array:character <- new [...] append buf, s ] scenario stash-on-list-converts-to-text [ run [ x:address:shared:list:number <- push 4, 0 x <- push 5, x x <- push 6, x stash [foo foo], x ] trace-should-contain [ app: foo foo 6 -> 5 -> 4 ] ] scenario stash-handles-list-with-cycle [ run [ x:address:shared:list:number <- push 4, 0 y:address:address:shared:list:number <- get-address *x, next:offset *y <- copy x stash [foo foo], x ] trace-should-contain [ app: foo foo 4 -> 4 -> 4 -> 4 -> 4 -> 4 -> 4 -> ... ] ]