Mercurial > repos > rhope
view backendutils.rhope @ 36:495dddadd058
User defined types work in the compiler now
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 03 Oct 2009 03:18:15 -0400 |
parents | 3498713c3dc9 |
children | 640f541e9116 |
line wrap: on
line source
Escape Rhope Name NU[name:escaped] { escaped <- [[[[[[[[[[name]Replace["@","_AT_"] ]Replace[" ","_SP_"] ]Replace[":","_CN_"] ]Replace["?","_QN_"] ]Replace["+","_PL_"] ]Replace["-","_MN_"] ]Replace["*","_TM_"] ]Replace["/","_DV_"] ]Replace["<","_LT_"] ]Replace[">","_GT_"] } Escape Rhope Name[name:escaped] { escaped <- Escape Rhope Name NU[[name]Replace["_","__"]] } Blueprint AddRef { Value } AddRef[value:out] { out <- [Build["AddRef"]]Value <<[value] } Make Op@AddRef[addref,func:out] { //TODO: Make me work with other backends out <- [["add_ref("]Append[ [[addref]Value >>]Make Op[func] ]]Append[")"] } Make Op@String[string,func:out] { out <- [func]Resolve[string] } Make Op@Whole Number[num,func:out] { out <- num } Make Op@Real Number[num,func:out] { out <- num } Blueprint Constant { Value } Constant[var:out] { out <- [Build["Constant"]]Value <<[var] } Make Op@Constant[const,func:out] { out <- [func]Lookup Constant[[const]Value >>] } Blueprint Result { Output Num } Result[num:out] { out <- [Build["Result"]]Output Num <<[num] } Make Op@Result[result,func:out] { out <- [func]Result Reference[[result]Output Num>>] } Blueprint OrValue { Left Right } OrValue[left,right:out] { out <- [[Build["OrValue"]]Left <<[left]]Right <<[right] } Make Op@OrValue[orval,func:out] { out <- [func]If Null Else[[[func]Left >>]Make Op[func], [[func]Right >>]Make Op[func]] } Blueprint NotCond { Condition } NotCond[cond:out] { out <- [Build["NotCond"]]Condition <<[cond] } Make Op@NotCond[cond,func:out] { out <- ["!"]Append[[[cond]Condition >>]Make Op[func]] } Blueprint OrCond { Condition1 Condition2 } OrCond[cond1,cond2:out] { out <- [[Build["OrCond"]]Condition1 <<[cond1]]Condition2 <<[cond2] } Make Op@OrCond[cond,func:out] { out <- ["("]Append[[[[cond]Condition1 >>]Append[" || "]]Append[[[cond]Condition2 >>]Append[")"]]] } Blueprint AndCond { Condition1 Condition2 } AndCond[cond1,cond2:out] { out <- [[Build["AndCond"]]Condition1 <<[cond1]]Condition2 <<[cond2] } Make Op@AndCond[cond,func:out] { out <- ["("]Append[[[[cond]Condition1 >>]Append[" && "]]Append[[[cond]Condition2 >>]Append[")"]]] } Blueprint Field Ref { Variable Field } Field Ref[var,field:out] { out <- [[Build["Field Ref"]]Variable <<[var]]Field <<[field] } Make Op@Field Ref[ref,func:out] { out <- [func]Field Result[[ref]Variable >>,[ref]Field >>] }