Mercurial > repos > rhope
changeset 72:f7bcf3db1342
Add =@String, fix bool bug
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 18 Jun 2010 17:00:50 -0400 |
parents | c40c3d399133 |
children | 6a1a7d5cc2d9 |
files | cbackend.rhope runtime/builtin.c string.rhope |
diffstat | 3 files changed, 39 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/cbackend.rhope Fri Jun 18 15:07:09 2010 -0400 +++ b/cbackend.rhope Fri Jun 18 17:00:50 2010 -0400 @@ -1090,9 +1090,9 @@ { If[value] { - out <- [text]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = (object *)val_yes;\n"]] + out <- [text]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = make_Bool(1);\n"]] }{ - out <- [text]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = (object *)val_no;\n"]] + out <- [text]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = make_Bool(0);\n"]] } }{ If[[valtype] = ["Machine Integer"]]
--- a/runtime/builtin.c Fri Jun 18 15:07:09 2010 -0400 +++ b/runtime/builtin.c Fri Jun 18 17:00:50 2010 -0400 @@ -110,4 +110,10 @@ return params[0]; } +object * make_Bool(int32_t val) +{ + t_Boolean * b = (t_Boolean *)new_object(TYPE_BOOLEAN); + b->Val = val != 0; + return (object*)b; +}
--- a/string.rhope Fri Jun 18 15:07:09 2010 -0400 +++ b/string.rhope Fri Jun 18 17:00:50 2010 -0400 @@ -153,6 +153,37 @@ right <- String Slice[string, slicepoint, [[string]Length >>]-[slicepoint]] } +Byte@String[string,index:out,invalid] +{ + out,invalid <- [[string]Buffer >>]Index[index] +} + +Length@String[string:out] +{ + out <- [string]Length >> +} + +_=String[left,right,index:out] +{ + [left]Byte[index] + { + ,out <- If[[~]=[[right]Byte[index]]] + { + out <- _=String[left,right,[index]+[1]] + } + }{ + out <- Yes + } +} + +=@String[left,right:out] +{ + ,out <- If[[[left]Length] = [[right]Length]] + { + out <- _=String[left,right,0] + } +} + Blueprint String Slice { Source