# HG changeset patch # User Mike Pavone # Date 1271397424 14400 # Node ID 689fb73e761283ac973c6179e17e240649e9f6e8 # Parent 3e20ed8959c4096c1cea262d4823e5a5d48f2d7c Add support for various integer literals and add support for raw pointers to objects and raw pointers to arrays in the FFI diff -r 3e20ed8959c4 -r 689fb73e7612 cbackend.rhope --- a/cbackend.rhope Thu Apr 08 01:02:18 2010 -0400 +++ b/cbackend.rhope Fri Apr 16 01:57:04 2010 -0400 @@ -1075,6 +1075,16 @@ out <- [text]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = (object *)val_no;\n"]] { Print["_Set Consts got output no"] } } + }{ + If[[valtype] = ["Machine Integer"]] + { + If[[value]Signed? >>] + { s <- "I" } + { s <- "UI" } + + make <- [[[" = make_"]Append[s]]Append["nt"]]Append[[value]Size >>] + out <- [text]Append[ [[[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[make]]Append["("]]Append[[value]Value >>]]Append[");\n"] ] + } } } } diff -r 3e20ed8959c4 -r 689fb73e7612 kernel.rhope --- a/kernel.rhope Thu Apr 08 01:02:18 2010 -0400 +++ b/kernel.rhope Fri Apr 16 01:57:04 2010 -0400 @@ -22,7 +22,7 @@ If@Int64[num:yes,no] { - yes,no <- If[[num]!=[0]] + yes,no <- If[[num]!=[0i64]] } Blueprint Int32 @@ -32,7 +32,7 @@ If@Int32[num:yes,no] { - yes,no <- If[[num]!=[0]] + yes,no <- If[[num]!=[0i32]] } Blueprint Int16 @@ -42,7 +42,7 @@ If@Int16[num:yes,no] { - yes,no <- If[[num]!=[0]] + yes,no <- If[[num]!=[0i16]] } Blueprint Int8 @@ -52,7 +52,7 @@ If@Int8[num:yes,no] { - yes,no <- If[[num]!=[0]] + yes,no <- If[[num]!=[0i8]] } Blueprint UInt64 @@ -62,7 +62,7 @@ If@UInt64[num:yes,no] { - yes,no <- If[[num]!=[0]] + yes,no <- If[[num]!=[0u64]] } Blueprint UInt32 @@ -72,7 +72,7 @@ If@UInt32[num:yes,no] { - yes,no <- If[[num]!=[0]] + yes,no <- If[[num]!=[0u32]] } Blueprint UInt16 @@ -82,7 +82,7 @@ If@UInt16[num:yes,no] { - yes,no <- If[[num]!=[0]] + yes,no <- If[[num]!=[0u16]] } Blueprint UInt8 @@ -92,7 +92,7 @@ If@UInt8[num:yes,no] { - yes,no <- If[[num]!=[0]] + yes,no <- If[[num]!=[0u8]] } diff -r 3e20ed8959c4 -r 689fb73e7612 nworker.rhope --- a/nworker.rhope Thu Apr 08 01:02:18 2010 -0400 +++ b/nworker.rhope Fri Apr 16 01:57:04 2010 -0400 @@ -369,8 +369,17 @@ If[[Type Of[[node]Data >>]] = ["Type Instance"]] { outtype <- Type Instance["Blueprint"] - }{ - outtype <- Type Instance[Type Of[[node]Data >>]] + }{ + If[[Type Of[[node]Data >>]] = ["Machine Integer"]] + { + If[[[node]Data >>]Signed? >>] + { base <- "Int" } + { base <- "UInt" } + + outtype <- Type Instance[[base]Append[ [[node]Data >>]Size >> ]] + }{ + outtype <- Type Instance[Type Of[[node]Data >>]] + } } } nextnode <- [node]Output Types <<[ [()]Append[outtype] ] @@ -645,8 +654,16 @@ { //TODO: Support parametric types datstring <- [[node]Data >>]Name >> - }{ - datstring <- [node]Data >> + }{ + If[[Type Of[[node]Data >>]] = ["Machine Integer"]] + { + If[[[node]Data >>]Signed? >>] + { s <- "i" } + { s <- "u" } + datstring <- [[[[node]Data >>]Value >>]Append[s]]Append[[[node]Data >>]Size >>] + }{ + datstring <- [node]Data >> + } } out <- Constant[[[Type Of[[node]Data >>]]Append["_"]]Append[datstring]] @@ -790,7 +807,15 @@ //TODO: Support parametric types datstring <- [[node]Data >>]Name >> }{ - datstring <- [node]Data >> + If[[Type Of[[node]Data >>]] = ["Machine Integer"]] + { + If[[[node]Data >>]Signed? >>] + { s <- "i" } + { s <- "u" } + datstring <- [[[[node]Data >>]Value >>]Append[s]]Append[[[node]Data >>]Size >>] + }{ + datstring <- [node]Data >> + } } nfunc <- [func]Register Constant[[[Type Of[[node]Data >>]]Append["_"]]Append[datstring], [node]Data >>] }{ @@ -945,7 +970,7 @@ { ,none <- [outputs]Next[index] { - out,none <- _Return Param[outputs, index, input types, ~] + out,none <- _Return Param[outputs, inputs, input types, ~] } } { out <- index diff -r 3e20ed8959c4 -r 689fb73e7612 parser_old.rhope --- a/parser_old.rhope Thu Apr 08 01:02:18 2010 -0400 +++ b/parser_old.rhope Fri Apr 16 01:57:04 2010 -0400 @@ -927,6 +927,18 @@ out <- node } +Blueprint Machine Integer +{ + Value + Size + Signed? +} + +Machine Integer[value,size,signed?:out] +{ + out <- [[[Build["Machine Integer"]]Value <<[value]]Size <<[size]]Signed? <<[signed?] +} + Parse Number[string,params:value,after] { delims <- [[[[(" ","\t","\n","\r")]Append[[params]List Delim >>]]Append[[params]Block Begin >>]]Append[[params]Arg End >>]]Append[[params]List End >>] @@ -945,7 +957,12 @@ { value <- params[0]); Ret(0, make_Int32(0)) -EndFunc +EndFunc + +object * make_Int64(int64_t val) +{ + t_Int64 * obj; + object * ret = new_object(TYPE_INT64); + obj = (t_Int64 *)ret; + obj->Num = val; + return ret; +} + + object * make_Int32(int32_t val) { t_Int32 * obj; @@ -46,6 +57,60 @@ return ret; } +object * make_Int16(int16_t val) +{ + t_Int16 * obj; + object * ret = new_object(TYPE_INT16); + obj = (t_Int16 *)ret; + obj->Num = val; + return ret; +} + +object * make_Int8(int8_t val) +{ + t_Int8 * obj; + object * ret = new_object(TYPE_INT8); + obj = (t_Int8 *)ret; + obj->Num = val; + return ret; +} + +object * make_UInt64(uint64_t val) +{ + t_UInt64 * obj; + object * ret = new_object(TYPE_UINT64); + obj = (t_UInt64 *)ret; + obj->Num = val; + return ret; +} + +object * make_UInt32(uint32_t val) +{ + t_UInt32 * obj; + object * ret = new_object(TYPE_UINT32); + obj = (t_UInt32 *)ret; + obj->Num = val; + return ret; +} + +object * make_UInt16(uint16_t val) +{ + t_UInt16 * obj; + object * ret = new_object(TYPE_UINT16); + obj = (t_UInt16 *)ret; + obj->Num = val; + return ret; +} + +object * make_UInt8(uint8_t val) +{ + t_UInt8 * obj; + object * ret = new_object(TYPE_UINT8); + obj = (t_UInt8 *)ret; + obj->Num = val; + return ret; +} + #define lval ((t_Boolean *)(cdata->params[0]))->Val MethodNoLocals(If,Boolean,