Mercurial > repos > rhope
diff backendutils.rhope @ 49:3e20ed8959c4
Added initial FFI implementation, Array type and 64-bit integers
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 08 Apr 2010 01:02:18 -0400 |
parents | a24eb366195c |
children | a844c623c7df |
line wrap: on
line diff
--- a/backendutils.rhope Tue Mar 02 00:18:49 2010 -0500 +++ b/backendutils.rhope Thu Apr 08 01:02:18 2010 -0400 @@ -36,22 +36,62 @@ Make Op@AddRef[addref,func:out] { //TODO: Make me work with other backends - out <- [["add_ref("]Append[ [[addref]Value >>]Make Op[func] ]]Append[")"] + out <- [["add_ref((object *)"]Append[ [[addref]Value >>]Make Op[func] ]]Append[")"] +} + +Strip Addref@AddRef[op:out] +{ + out <- [[op]Value >>]Strip Addref } Make Op@String[string,func:out] { out <- [func]Resolve[string] +} + +Strip Addref@String[op:out] +{ + out <- op } Make Op@Whole Number[num,func:out] { out <- num +} + +Strip Addref@Whole Number[op:out] +{ + out <- op } Make Op@Real Number[num,func:out] { out <- num +} + +Strip Addref@Real Number[op:out] +{ + out <- op +} + +Blueprint Output +{ + Name +} + +Output[name:out] +{ + out <- [Build["Output"]]Name <<[name] +} + +Make Op@Output[op,func:out] +{ + out <- [func]Resolve Output[[op]Name >>] +} + +Strip Addref@Output[op:out] +{ + out <- op } Blueprint Constant @@ -67,6 +107,11 @@ Make Op@Constant[const,func:out] { out <- [func]Lookup Constant[[const]Value >>] +} + +Strip Addref@Constant[op:out] +{ + out <- op } Blueprint Result @@ -82,6 +127,21 @@ Make Op@Result[result,func:out] { out <- [func]Result Reference[[result]Output Num>>] +} + +Strip Addref@Result[op:out] +{ + out <- op +} + +Make Condition[op:out] +{ + If[[Type Of[op]]=["OrValue"]] + { + out <- OrCond[Make Condition[[op]Left >>], Make Condition[[op]Right >>]] + }{ + out <- op + } } Blueprint OrValue @@ -97,7 +157,12 @@ Make Op@OrValue[orval,func:out] { - out <- [func]If Null Else[[[func]Left >>]Make Op[func], [[func]Right >>]Make Op[func]] + out <- [func]If Null Else[[orval]Left >>, [orval]Right >>] +} + +Strip Addref@OrValue[op:out] +{ + out <- [[op]Left <<[ [[op]Left >>]Strip Addref ]]Right <<[ [[op]Right >>]Strip Addref ] } Blueprint NotCond @@ -107,12 +172,17 @@ NotCond[cond:out] { - out <- [Build["NotCond"]]Condition <<[cond] + out <- [Build["NotCond"]]Condition <<[[cond]Strip Addref] } Make Op@NotCond[cond,func:out] { out <- ["!"]Append[[[cond]Condition >>]Make Op[func]] +} + +Strip Addref@NotCond[op:out] +{ + out <- op } Blueprint OrCond @@ -123,12 +193,17 @@ OrCond[cond1,cond2:out] { - out <- [[Build["OrCond"]]Condition1 <<[cond1]]Condition2 <<[cond2] + out <- [[Build["OrCond"]]Condition1 <<[[cond1]Strip Addref]]Condition2 <<[[cond2]Strip Addref] } Make Op@OrCond[cond,func:out] { out <- ["("]Append[[[ [[cond]Condition1 >>]Make Op[func] ]Append[" || "]]Append[[ [[cond]Condition2 >>]Make Op[func] ]Append[")"]]] +} + +Strip Addref@OrCond[op:out] +{ + out <- op } Blueprint AndCond @@ -139,12 +214,17 @@ AndCond[cond1,cond2:out] { - out <- [[Build["AndCond"]]Condition1 <<[cond1]]Condition2 <<[cond2] + out <- [[Build["AndCond"]]Condition1 <<[[cond1]Strip Addref]]Condition2 <<[[cond2]Strip Addref] } Make Op@AndCond[cond,func:out] { out <- ["("]Append[[[ [[cond]Condition1 >>]Make Op[func] ]Append[" && "]]Append[[ [[cond]Condition2 >>]Make Op[func] ]Append[")"]]] +} + +Strip Addref@AndCond[op:out] +{ + out <- op } Blueprint Field Ref @@ -161,13 +241,19 @@ Make Op@Field Ref[ref,func:out] { out <- [func]Field Result[[ref]Variable >>,[ref]Field >>] +} + +Strip Addref@Field Ref[op:out] +{ + out <- op } Blueprint Type Instance { Name Params - Variant + Variant + Mutable? } Type Instance[raw name:out] @@ -178,7 +264,7 @@ }{ name <- raw name } - out <- [[[Build["Type Instance"]]Name <<[name]]Params <<[()]]Variant <<["Boxed"] + out <- [[[[Build["Type Instance"]]Name <<[name]]Params <<[()]]Variant <<["Boxed"]]Mutable? <<[No] } Set Variant@Type Instance[type,variant:out,invalid]