# HG changeset patch # User Mike Pavone # Date 1276894850 14400 # Node ID f7bcf3db1342bc340095ea71bf9b8e81ef409cf4 # Parent c40c3d399133ecd659241d4b9b095713cfbd6474 Add =@String, fix bool bug diff -r c40c3d399133 -r f7bcf3db1342 cbackend.rhope --- 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"]] diff -r c40c3d399133 -r f7bcf3db1342 runtime/builtin.c --- 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; +} diff -r c40c3d399133 -r f7bcf3db1342 string.rhope --- 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