Mercurial > repos > rhope
diff runtime/builtin.c @ 66:d4b44ae2e34a
New variant of C backend works now
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 06 Jun 2010 20:29:10 -0400 |
parents | 04baa003de5a |
children | f7bcf3db1342 |
line wrap: on
line diff
--- a/runtime/builtin.c Tue Jun 01 01:13:54 2010 -0400 +++ b/runtime/builtin.c Sun Jun 06 20:29:10 2010 -0400 @@ -3,8 +3,8 @@ #include "integer.h" #include "bool.h" #include <stddef.h> -#include <stdio.h> -#include <stdlib.h> +#include <stdio.h> +#include <stdlib.h> #include <string.h> void register_builtin_type(uint32_t type) @@ -23,7 +23,7 @@ uint32_t i; for(i = 0; i < TYPE_FIRST_USER; ++i) register_builtin_type(i); -} +} object * make_Int64(int64_t val) { t_Int64 * obj; @@ -31,8 +31,8 @@ obj = (t_Int64 *)ret; obj->Num = val; return ret; -} - +} + object * make_Int32(int32_t val) { @@ -41,8 +41,8 @@ obj = (t_Int32 *)ret; obj->Num = val; return ret; -} - +} + object * make_Int16(int16_t val) { t_Int16 * obj; @@ -50,8 +50,8 @@ obj = (t_Int16 *)ret; obj->Num = val; return ret; -} - +} + object * make_Int8(int8_t val) { t_Int8 * obj; @@ -59,8 +59,8 @@ obj = (t_Int8 *)ret; obj->Num = val; return ret; -} - +} + object * make_UInt64(uint64_t val) { t_UInt64 * obj; @@ -68,8 +68,8 @@ obj = (t_UInt64 *)ret; obj->Num = val; return ret; -} - +} + object * make_UInt32(uint32_t val) { t_UInt32 * obj; @@ -77,8 +77,8 @@ obj = (t_UInt32 *)ret; obj->Num = val; return ret; -} - +} + object * make_UInt16(uint16_t val) { t_UInt16 * obj; @@ -86,8 +86,8 @@ obj = (t_UInt16 *)ret; obj->Num = val; return ret; -} - +} + object * make_UInt8(uint8_t val) { t_UInt8 * obj; @@ -95,35 +95,19 @@ obj = (t_UInt8 *)ret; obj->Num = val; return ret; -} - -object * make_String(char * text) -{ - returntype ret; - context * ct; - calldata * cdata; - object * retobj; - t_Array * arr = (t_Array *)_internal_array_allocnaked(strlen(text), make_Blueprint(TYPE_UINT8)); - arr->payload.Length = arr->payload.Storage; - memcpy(((char *)arr) + sizeof(t_Array), text, arr->payload.Length); - - //This is really ugly, but I don't see a good way around it at the moment - ct = new_context(); - cdata = alloc_cdata(ct, 1); - cdata->params[0] = (object *)arr; - cdata->num_params = 1; - cdata->resume = 0; - ret = f_String(cdata); - while(ret == TAIL_RETURN) - ret = cdata->tail_func(cdata); - if(ret == EXCEPTION_RETURN) - { - puts("Exception while building string literal!"); - exit(-1); - } - retobj = cdata->params[0]; - free_context(ct); - return retobj; -} - - +} + +object * make_String(char * text) +{ + object * params[1]; + t_Array * arr = (t_Array *)_internal_array_allocnaked(strlen(text), make_Blueprint(TYPE_UINT8)); + arr->payload.Length = arr->payload.Storage; + memcpy(((char *)arr) + sizeof(t_Array), text, arr->payload.Length); + + params[0] = (object *)arr; + rhope(FUNC_String, params, 1, 1); + + return params[0]; +} + +