Mercurial > repos > rhope
changeset 163:9fab36cc706b
Add Raw Size method to blueprint to allow code to query the raw size of a type in bytes
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 09 Jan 2011 23:03:30 -0500 |
parents | bac2c74801f0 |
children | 429afd920a23 |
files | kernel.rhope runtime/blueprint.c runtime/blueprint.h runtime/object.h |
diffstat | 4 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/kernel.rhope Sun Jan 09 22:51:10 2011 -0500 +++ b/kernel.rhope Sun Jan 09 23:03:30 2011 -0500 @@ -183,6 +183,7 @@ Foreign C:runtime { _internal_blueprint_eq[left(Blueprint),right(Blueprint):out(Int32,Naked)] + _internal_blueprint_rawsize[bp(Blueprint):out(Int32,Naked)] _internal_worker_alloc[size(Int16,Naked):out(Worker)] _internal_worker_setinput[worker(Worker,Boxed,Mutable),num(Int16,Naked),val:worker] _internal_worker_getinput[worker(Worker),num(Int16,Naked):out] @@ -248,6 +249,11 @@ out <- [_internal_blueprint_eq[left,right]]!=[0] } +Raw Size@Blueprint[bp:out] +{ + out <- _internal_blueprint_rawsize[bp] +} + _Keys[list,val,key:out] { out <- [list]Append[key]
--- a/runtime/blueprint.c Sun Jan 09 22:51:10 2011 -0500 +++ b/runtime/blueprint.c Sun Jan 09 23:03:30 2011 -0500 @@ -26,4 +26,12 @@ return l->bp == r->bp; } +int32_t _internal_blueprint_rawsize(object * bp) +{ + int32_t ret; + t_Blueprint * bprint = (t_Blueprint *)bp; + ret = bprint->bp->size; + release_ref(bp); + return ret; +}
--- a/runtime/blueprint.h Sun Jan 09 22:51:10 2011 -0500 +++ b/runtime/blueprint.h Sun Jan 09 23:03:30 2011 -0500 @@ -9,6 +9,7 @@ object * make_Blueprint(int32_t type_id); int32_t _internal_blueprint_eq(object * left, object * right); +int32_t _internal_blueprint_rawsize(object * bp); typedef struct { blueprint * bp;
--- a/runtime/object.h Sun Jan 09 22:51:10 2011 -0500 +++ b/runtime/object.h Sun Jan 09 23:03:30 2011 -0500 @@ -27,8 +27,8 @@ uint32_t last_convertto; uint32_t first_convertfrom; uint32_t last_convertfrom; - int32_t size; - int32_t boxed_size; + int32_t size; + int32_t boxed_size; } blueprint; struct object {