Mercurial > repos > rhope
view arrayjs.rhope @ 184:c6ba9fe45910
Strip _c from filenames of current compiler
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 27 Jul 2011 21:28:43 -0700 |
parents | fc3815b7462f |
children |
line wrap: on
line source
Blueprint Array { } Foreign Javascript:runtime { _internal_js_length[array:out(Int32,Naked)] _internal_array_set[array(Array,Boxed,Mutable),index(Int32,Naked),val:array] _internal_array_get[array(Array),index(Int32,Naked):out] } Array[:out(Empty Array)] { out <- Build[Array()] } First@Array[array:out(Int32),empty] { ,empty <- If[[array]Length] { out <- 0 } } Next@Array[array,current:out(Int32),empty] { next <- [current]+[1] ,empty <- If[[next] < [[array]Length]] { out <- Val[next] } } Last@Array[array:out(Int32),empty] { ,empty <- If[[array]Length] { out <- [[array]Length] - [1] } } Append@Array[array,newval:out] { out <- [array]Set[[array]Length, newval] } Index@Array[array,index(Int32):out,notfound] { ,notfound <- If[[index] >= [0]] { ,notfound <- If[[index] < [[array]Length]] { out <- _internal_array_get[array, index] } } } Set@Array[array,index(Int32),val:out,invalid] { invalid <- If[[index]<[0]] {} { len <- [array]Length If[[index]>[len]] { out <- [[array]Set[[index]-[1],val]]Set[index, val] }{ out <- _internal_array_set[array,index,val] } } } Length@Array[arr:out] { out <- _internal_js_length[arr] } Call@Array[arr,index(Int32):out,not found] { out,not found <- [arr]Index[index] }