Mercurial > repos > rhope
comparison cbackend_c.rhope @ 109:b7df624895b2
Hack to reduce overhead of Escape Rhope Name
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 06 Oct 2010 23:47:26 +0000 |
parents | f4fc0a98088a |
children | b3f56e1d54a0 |
comparison
equal
deleted
inserted
replaced
108:a7add4db4a25 | 109:b7df624895b2 |
---|---|
112 Register Fields@C Type[ctype,field reg:out] | 112 Register Fields@C Type[ctype,field reg:out] |
113 { | 113 { |
114 out <- Fold[_Register Field C[?], field reg, [ctype]Fields >>] | 114 out <- Fold[_Register Field C[?], field reg, [ctype]Fields >>] |
115 } | 115 } |
116 | 116 |
117 Rhope Type to C[type:out,array] | 117 Rhope Type to C[type,p:out,array] |
118 { | 118 { |
119 If[[Blueprint Of[type]]=[Type Instance()]] | 119 If[[Blueprint Of[type]]=[Type Instance()]] |
120 { | 120 { |
121 variant <- [type]Variant >> | 121 variant <- [type]Variant >> |
122 If[[[type]Name >>] = ["Array"]] | 122 If[[[type]Name >>] = ["Array"]] |
203 } | 203 } |
204 If[primitive] | 204 If[primitive] |
205 { | 205 { |
206 escaped <- Val[typename] | 206 escaped <- Val[typename] |
207 }{ | 207 }{ |
208 escaped <- Escape Rhope Name[typename] | 208 escaped <- Escape Rhope Name[typename,p] |
209 } | 209 } |
210 out <- [[prefix]Append[escaped]]Append[postfix] | 210 out <- [[prefix]Append[escaped]]Append[postfix] |
211 } | 211 } |
212 | 212 |
213 _Type Def C Type[text,field:out] | 213 _Type Def C Type[text,field,p:out] |
214 { | 214 { |
215 name <- [field]Index[0] | 215 name <- [field]Index[0] |
216 ,postfix <- Rhope Type to C[[field]Index[1]] | 216 ,postfix <- Rhope Type to C[[field]Index[1],p] |
217 { type <- ["\n\t"]Append[~] } | 217 { type <- ["\n\t"]Append[~] } |
218 | 218 |
219 out <- [[[[text]Append[type]]Append[" "]]Append[[Escape Rhope Name[name]]Append[postfix]]]Append[";"] | 219 out <- [[[[text]Append[type]]Append[" "]]Append[[Escape Rhope Name[name,p]]Append[postfix]]]Append[";"] |
220 } | 220 } |
221 | 221 |
222 Type Def@C Type[ctype:out] | 222 Type Def@C Type[ctype,p:out] |
223 { | 223 { |
224 If[[[[ctype]Fields >>]Length] = [1]] | 224 If[[[[ctype]Fields >>]Length] = [1]] |
225 { | 225 { |
226 out <- [[[[_Type Def C Type["typedef struct {\n\tobject _SP_header;\n\t", [[ctype]Fields >>]Index[0]]]Append["\n} t_"]]Append[Escape Rhope Name[[ctype]Name >>]]]Append[";"] | 226 out <- [[[[_Type Def C Type["typedef struct {\n\tobject _SP_header;\n\t", [[ctype]Fields >>]Index[0], p]]Append["\n} t_"]]Append[Escape Rhope Name[[ctype]Name >>,p]]]Append[";"] |
227 ]Append[ | 227 ]Append[ |
228 [[[["typedef " | 228 [[[["typedef " |
229 ]Append[Rhope Type to C[ [[[ctype]Fields >>]Index[0]]Index[1] ]] | 229 ]Append[Rhope Type to C[ [[[ctype]Fields >>]Index[0]]Index[1],p ]] |
230 ]Append[" nt_"] | 230 ]Append[" nt_"] |
231 ]Append[Escape Rhope Name[[ctype]Name >>]] | 231 ]Append[Escape Rhope Name[[ctype]Name >>,p]] |
232 ]Append[";"] ] | 232 ]Append[";"] ] |
233 }{ | 233 }{ |
234 //HACK!!! | 234 //HACK!!! |
235 If[[[ctype]Name >>]=["Blueprint"]] | 235 If[[[ctype]Name >>]=["Blueprint"]] |
236 { | 236 { |
237 out <- "" | 237 out <- "" |
238 }{ | 238 }{ |
239 [("Array","Boxed Array","Worker")]Find[=[[ctype]Name >>,?]] | 239 [("Array","Boxed Array","Worker")]Find[=[[ctype]Name >>,?]] |
240 { oend <- "\nMObject(" } | 240 { oend <- "\nMObject(" } |
241 { oend <- "\nObject(" } | 241 { oend <- "\nObject(" } |
242 out <- [Fold[_Type Def C Type[?], "OBegin", [ctype]Fields >>]]Append[ [[oend]Append[Escape Rhope Name[[ctype]Name >>]]]Append[")"] ] | 242 out <- [Fold[_Type Def C Type[?,?,p], "OBegin", [ctype]Fields >>]]Append[ [[oend]Append[Escape Rhope Name[[ctype]Name >>,p]]]Append[")"] ] |
243 } | 243 } |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 _Type Init C[type name,method reg,text,method:out] | 247 _Type Init C[type name,method reg,text,method,p:out] |
248 { | 248 { |
249 out <- [[text]Append[[["\n\tadd_method(bp, "]Append[ [method reg]Method ID[method] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[method]]]Append[[","]Append[Escape Rhope Name[type name]]]]]]Append["));"] | 249 out <- [[text]Append[[["\n\tadd_method(bp, "]Append[ [method reg]Method ID[method] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[method,p]]]Append[[","]Append[Escape Rhope Name[type name,p]]]]]]Append["));"] |
250 } | 250 } |
251 | 251 |
252 _Type Init C Field[type name,field reg,text,field:out] | 252 _Type Init C Field[type name,field reg,text,field,p:out] |
253 { | 253 { |
254 fname <- [field]Index[0] | 254 fname <- [field]Index[0] |
255 out <- [[[[text]Append[[["\n\tadd_getter(bp, "]Append[ String[[field reg]Field ID[fname]] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[[fname]Append[" >>"]]]]Append[[","]Append[Escape Rhope Name[type name]]]]]]Append["));"] | 255 out <- [[[[text]Append[[["\n\tadd_getter(bp, "]Append[ String[[field reg]Field ID[fname]] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[[fname]Append[" >>"],p]]]Append[[","]Append[Escape Rhope Name[type name,p]]]]]]Append["));"] |
256 ]Append[[["\n\tadd_setter(bp, "]Append[ String[[field reg]Field ID[fname]] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[[fname]Append[" <<"]]]]Append[[","]Append[Escape Rhope Name[type name]]]]]]Append["));"] | 256 ]Append[[["\n\tadd_setter(bp, "]Append[ String[[field reg]Field ID[fname]] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[[fname]Append[" <<"],p]]]Append[[","]Append[Escape Rhope Name[type name,p]]]]]]Append["));"] |
257 } | 257 } |
258 | 258 |
259 Type Init@C Type[ctype,id,method reg,field reg:out] | 259 Type Init@C Type[ctype,id,method reg,field reg,p:out] |
260 { | 260 { |
261 [("Array","Boxed Array", "Worker")]Find[=[[ctype]Name >>, ?]] | 261 [("Array","Boxed Array", "Worker")]Find[=[[ctype]Name >>, ?]] |
262 { size <- "-1" } | 262 { size <- "-1" } |
263 { | 263 { |
264 [("Int64","Int32","Int16","Int8")]Find[=[[ctype]Name >>, ?]] | 264 [("Int64","Int32","Int16","Int8")]Find[=[[ctype]Name >>, ?]] |
274 If[[[ctype]Name >>]=["Blueprint"]] | 274 If[[[ctype]Name >>]=["Blueprint"]] |
275 { typename <- "blueprint *" } | 275 { typename <- "blueprint *" } |
276 { | 276 { |
277 If[[[ctype]Name >>]=["Boolean"]] | 277 If[[[ctype]Name >>]=["Boolean"]] |
278 { typename <- "int32_t" } | 278 { typename <- "int32_t" } |
279 { typename <- ["nt_"]Append[Escape Rhope Name[[ctype]Name >>]] } | 279 { typename <- ["nt_"]Append[Escape Rhope Name[[ctype]Name >>,p]] } |
280 } | 280 } |
281 } | 281 } |
282 } | 282 } |
283 size <- [["sizeof("]Append[typename]]Append[")"] | 283 size <- [["sizeof("]Append[typename]]Append[")"] |
284 } | 284 } |
287 ]Append[ | 287 ]Append[ |
288 [[", "]Append[size] | 288 [[", "]Append[size] |
289 ]Append[ | 289 ]Append[ |
290 [", (special_func)"]Append[ | 290 [", (special_func)"]Append[ |
291 [ | 291 [ |
292 [[[[Escape Rhope Name[[ctype]Init >>] | 292 [[[[Escape Rhope Name[[ctype]Init >>,p] |
293 ]Append[", (special_func)"] | 293 ]Append[", (special_func)"] |
294 ]Append[Escape Rhope Name[[ctype]Copy >> ]] | 294 ]Append[Escape Rhope Name[[ctype]Copy >> ,p]] |
295 ]Append[", (special_func)"] | 295 ]Append[", (special_func)"] |
296 ]Append[Escape Rhope Name[[ctype]Cleanup >>]] | 296 ]Append[Escape Rhope Name[[ctype]Cleanup >>,p]] |
297 ]Append[");"]]] ] | 297 ]Append[");"]]] ] |
298 out <- Val[start]//Fold[[["_Type Init C Field"]Set Input[0, [ctype]Name >>]]Set Input[1, field reg], Fold[[["_Type Init C"]Set Input[0, [ctype]Name >>]]Set Input[1, method reg], start, [ctype]Methods >>], [ctype]Fields >>] | 298 out <- Val[start]//Fold[[["_Type Init C Field"]Set Input[0, [ctype]Name >>]]Set Input[1, field reg], Fold[[["_Type Init C"]Set Input[0, [ctype]Name >>]]Set Input[1, method reg], start, [ctype]Methods >>], [ctype]Fields >>] |
299 } | 299 } |
300 | 300 |
301 Blueprint C Type Registry | 301 Blueprint C Type Registry |
302 { | 302 { |
303 Lookup | 303 Lookup |
304 Definitions | 304 Definitions |
305 Next ID | 305 Next ID |
306 } | 306 Escape Pattern |
307 | 307 } |
308 C Type Registry[:out] | 308 |
309 { | 309 C Type Registry[p:out] |
310 out <- [[[Build[C Type Registry()]]Lookup << [ | 310 { |
311 out <- [[[[Build[C Type Registry()]]Lookup << [ | |
311 [[[[[[[[[[[[[[[[[[[Dictionary[] | 312 [[[[[[[[[[[[[[[[[[[Dictionary[] |
312 ]Set["UInt8", "TYPE_UINT8"] //1 | 313 ]Set["UInt8", "TYPE_UINT8"] //1 |
313 ]Set["UInt16", "TYPE_UINT16"] //2 | 314 ]Set["UInt16", "TYPE_UINT16"] //2 |
314 ]Set["UInt32", "TYPE_UINT32"] //3 | 315 ]Set["UInt32", "TYPE_UINT32"] //3 |
315 ]Set["UInt64", "TYPE_UINT64"] //4 | 316 ]Set["UInt64", "TYPE_UINT64"] //4 |
328 ]Set["Method Missing Exception", "TYPE_METHODMISSINGEXCEPTION"] //17 | 329 ]Set["Method Missing Exception", "TYPE_METHODMISSINGEXCEPTION"] //17 |
329 ]Set["Field Missing Exception", "TYPE_FIELDMISSINGEXCEPTION"] //18 | 330 ]Set["Field Missing Exception", "TYPE_FIELDMISSINGEXCEPTION"] //18 |
330 ]Set["Wrong Type Exception", "TYPE_WRONGTYPEEXCEPTION"]] //19 | 331 ]Set["Wrong Type Exception", "TYPE_WRONGTYPEEXCEPTION"]] //19 |
331 ]Definitions << [Dictionary[]] | 332 ]Definitions << [Dictionary[]] |
332 ]Next ID <<[0] | 333 ]Next ID <<[0] |
333 } | 334 ]Escape Pattern <<[p] |
334 | 335 } |
335 _Type Defs C[text,def:out] | 336 |
336 { | 337 _Type Defs C[text,def,p:out] |
337 out <- [[text]Append[[def]Type Def]]Append["\n\n"] | 338 { |
339 out <- [[text]Append[[def]Type Def[p]]]Append["\n\n"] | |
338 } | 340 } |
339 | 341 |
340 Type Defs@C Type Registry[reg:out] | 342 Type Defs@C Type Registry[reg:out] |
341 { | 343 { |
342 out <- Fold[_Type Defs C[?], "", [reg]Definitions >>] | 344 out <- Fold[_Type Defs C[?,?,[reg]Escape Pattern >>], "", [reg]Definitions >>] |
343 } | 345 } |
344 | 346 |
345 _Type Inits C[reg,method reg,field reg,text,def,name:out] | 347 _Type Inits C[reg,method reg,field reg,text,def,name:out] |
346 { | 348 { |
347 out <- [[text]Append[ [def]Type Init[[reg]Type ID[name], method reg, field reg] ]]Append["\n\n"] | 349 out <- [[text]Append[ [def]Type Init[[reg]Type ID[name], method reg, field reg,[reg]Escape Pattern >>] ]]Append["\n\n"] |
348 } | 350 } |
349 | 351 |
350 Type Inits@C Type Registry[reg,method reg,field reg:out] | 352 Type Inits@C Type Registry[reg,method reg,field reg:out] |
351 { | 353 { |
352 out <- Fold[_Type Inits C[reg, method reg, field reg, ?], "", [reg]Definitions >>] | 354 out <- Fold[_Type Inits C[reg, method reg, field reg, ?], "", [reg]Definitions >>] |
401 Constants | 403 Constants |
402 Input Types | 404 Input Types |
403 Output Types | 405 Output Types |
404 Resume Index | 406 Resume Index |
405 Last NumParams | 407 Last NumParams |
406 } | 408 Escape Pattern |
407 | 409 } |
408 C Function[name,inputs,outputs,convention:out] | 410 |
409 { | 411 C Function[name,inputs,outputs,convention,p:out] |
410 out <- C Function With Registry[name,inputs,outputs,convention, C Method Registry[], C Field Registry[], C Type Registry[]] | 412 { |
411 } | 413 out <- C Function With Registry[name,inputs,outputs,convention, C Method Registry[], C Field Registry[], C Type Registry[p],p] |
412 | 414 } |
413 C Function With Registry[name,inputs,outputs,convention,registry,field reg,type reg:out] | 415 |
414 { | 416 C Function With Registry[name,inputs,outputs,convention,registry,field reg,type reg,p:out] |
415 out <- [[[[[[[[[[[[[[Build[C Function()] | 417 { |
418 out <- [[[[[[[[[[[[[[[Build[C Function()] | |
416 ]Name <<[name] | 419 ]Name <<[name] |
417 ]Inputs <<[inputs] | 420 ]Inputs <<[inputs] |
418 ]Outputs <<[outputs] | 421 ]Outputs <<[outputs] |
419 ]Convention <<[convention] | 422 ]Convention <<[convention] |
420 ]Variables <<[Dictionary[]] | 423 ]Variables <<[Dictionary[]] |
425 ]Constants <<[Dictionary[]] | 428 ]Constants <<[Dictionary[]] |
426 ]Input Types <<[ Fold[Append[?, "Any Type"], (), inputs] ] | 429 ]Input Types <<[ Fold[Append[?, "Any Type"], (), inputs] ] |
427 ]Output Types <<[ Fold[Append[?, "Any Type"], (), outputs] ] | 430 ]Output Types <<[ Fold[Append[?, "Any Type"], (), outputs] ] |
428 ]Resume Index <<[1] | 431 ]Resume Index <<[1] |
429 ]Last NumParams <<[-1] | 432 ]Last NumParams <<[-1] |
433 ]Escape Pattern <<[p] | |
430 } | 434 } |
431 | 435 |
432 Set Input Type@C Function[func,type,input num:out] | 436 Set Input Type@C Function[func,type,input num:out] |
433 { | 437 { |
434 out <- [func]Input Types <<[ [[func]Input Types >>]Set[input num, type] ] | 438 out <- [func]Input Types <<[ [[func]Input Types >>]Set[input num, type] ] |
559 out <- [func]Add Statement[[dest]Append[" = NULL"]] | 563 out <- [func]Add Statement[[dest]Append[" = NULL"]] |
560 } | 564 } |
561 | 565 |
562 Lookup Constant@C Function[func,const,doaddref:out] | 566 Lookup Constant@C Function[func,const,doaddref:out] |
563 { | 567 { |
564 var <- ["_const_"]Append[Escape Rhope Name[const]] | 568 var <- ["_const_"]Append[Escape Rhope Name[const,[func]Escape Pattern >>]] |
565 If[doaddref] | 569 If[doaddref] |
566 { | 570 { |
567 out <- [["add_ref("]Append[var]]Append[")"] | 571 out <- [["add_ref("]Append[var]]Append[")"] |
568 }{ | 572 }{ |
569 out <- Val[var] | 573 out <- Val[var] |
598 { | 602 { |
599 If[[type] = ["Any Type"]] | 603 If[[type] = ["Any Type"]] |
600 { | 604 { |
601 rvar <- Val[as op] | 605 rvar <- Val[as op] |
602 }{ | 606 }{ |
603 rvar <- [[[["(("]Append[ Rhope Type to C[type] ]]Append[")("]]Append[as op]]Append["))"] | 607 rvar <- [[[["(("]Append[ Rhope Type to C[type,[func]Escape Pattern >>] ]]Append[")("]]Append[as op]]Append["))"] |
604 } | 608 } |
605 }{ | 609 }{ |
606 rvar <- Val[as op] | 610 rvar <- Val[as op] |
607 } | 611 } |
608 | 612 |
611 { access <- "->payload." } | 615 { access <- "->payload." } |
612 { | 616 { |
613 //TODO: Generate some kind of error/exception in this case | 617 //TODO: Generate some kind of error/exception in this case |
614 access <- "->" | 618 access <- "->" |
615 } | 619 } |
616 out <- [[rvar]Append[access]]Append[Escape Rhope Name[field]] | 620 out <- [[rvar]Append[access]]Append[Escape Rhope Name[field,[func]Escape Pattern >>]] |
617 } | 621 } |
618 | 622 |
619 Read Field@C Function[func,var,field:out,result op] | 623 Read Field@C Function[func,var,field:out,result op] |
620 { | 624 { |
621 out <- func | 625 out <- func |
734 ]Append[", "] | 738 ]Append[", "] |
735 ]Append[String[[rargs]Length]] | 739 ]Append[String[[rargs]Length]] |
736 ]Append[", "] | 740 ]Append[", "] |
737 ]Append[String[[func]Resume Index >>]] | 741 ]Append[String[[func]Resume Index >>]] |
738 ]Append[", "] | 742 ]Append[", "] |
739 ]Append[Escape Rhope Name[[func]Name >>]] | 743 ]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] |
740 ]Append[")"]] | 744 ]Append[")"]] |
741 ]Add Raw Line["DISPATCH"] | 745 ]Add Raw Line["DISPATCH"] |
742 ]Add Raw Line[ | 746 ]Add Raw Line[ |
743 [[[["ValCallPostlude(" | 747 [[[["ValCallPostlude(" |
744 ]Append[String[[func]Resume Index >>]] | 748 ]Append[String[[func]Resume Index >>]] |
745 ]Append[", "] | 749 ]Append[", "] |
746 ]Append[Escape Rhope Name[[func]Name >>]] | 750 ]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] |
747 ]Append[")"]] | 751 ]Append[")"]] |
748 ]Resume Index <<[ [[func]Resume Index >>]+[1] ] | 752 ]Resume Index <<[ [[func]Resume Index >>]+[1] ] |
749 } | 753 } |
750 | 754 |
751 Call@C Function[func,name,args:out] | 755 Call@C Function[func,name,args:out] |
764 ]Add Raw Line["} else {"] | 768 ]Add Raw Line["} else {"] |
765 ]Last NumParams <<[last numparams] | 769 ]Last NumParams <<[last numparams] |
766 ]Func Base["Call",args, "Call"] | 770 ]Func Base["Call",args, "Call"] |
767 ]Add Raw Line["}"] | 771 ]Add Raw Line["}"] |
768 }{ | 772 }{ |
769 out <- [func]Func Base[Escape Rhope Name[name],args, "Call"] | 773 out <- [func]Func Base[Escape Rhope Name[name,[func]Escape Pattern >>],args, "Call"] |
770 } | 774 } |
771 } | 775 } |
772 } | 776 } |
773 | 777 |
774 Func Base@C Function[func,tocall,args,type:out] | 778 Func Base@C Function[func,tocall,args,type:out] |
798 ]Append[", "] | 802 ]Append[", "] |
799 ]Append[String[[rargs]Length]] | 803 ]Append[String[[rargs]Length]] |
800 ]Append[", "] | 804 ]Append[", "] |
801 ]Append[String[[func]Resume Index >>]] | 805 ]Append[String[[func]Resume Index >>]] |
802 ]Append[", "] | 806 ]Append[", "] |
803 ]Append[Escape Rhope Name[[func]Name >>]] | 807 ]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] |
804 ]Append[")"]] | 808 ]Append[")"]] |
805 ]Resume Index <<[ [[func]Resume Index >>]+[1] ] | 809 ]Resume Index <<[ [[func]Resume Index >>]+[1] ] |
806 } | 810 } |
807 | 811 |
808 Call Foreign@C Function[func,name,language,args,store result:out] | 812 Call Foreign@C Function[func,name,language,args,store result:out] |
821 out <- [func]Add Statement[stmt] | 825 out <- [func]Add Statement[stmt] |
822 } | 826 } |
823 | 827 |
824 Get Field Call@C Function[func,field,source:out] | 828 Get Field Call@C Function[func,field,source:out] |
825 { | 829 { |
826 out <- [func]Func Base[Escape Rhope Name[[field]Append[" >>"]], [()]Append[source], "Call"] | 830 out <- [func]Func Base[Escape Rhope Name[[field]Append[" >>"],[func]Escape Pattern >>], [()]Append[source], "Call"] |
827 } | 831 } |
828 | 832 |
829 Set Field Call@C Function[func,field,object,value:out] | 833 Set Field Call@C Function[func,field,object,value:out] |
830 { | 834 { |
831 out <- [func]Func Base[Escape Rhope Name[[field]Append[" <<"]], [[()]Append[object]]Append[value], "Call"] | 835 out <- [func]Func Base[Escape Rhope Name[[field]Append[" <<"],[func]Escape Pattern >>], [[()]Append[object]]Append[value], "Call"] |
832 } | 836 } |
833 | 837 |
834 Tail Method Call@C Function[func,method,args:out] | 838 Tail Method Call@C Function[func,method,args:out] |
835 { | 839 { |
836 out <- [func]Func Base[[[func]Method Registry >>]Method ID[method],args, "TMCall"] | 840 out <- [func]Func Base[[[func]Method Registry >>]Method ID[method],args, "TMCall"] |
837 } | 841 } |
838 | 842 |
839 Tail Call@C Function[func,name,args:out] | 843 Tail Call@C Function[func,name,args:out] |
840 { | 844 { |
841 out <- [func]Func Base[Escape Rhope Name[name],args, "TCall"] | 845 out <- [func]Func Base[Escape Rhope Name[name,[func]Escape Pattern >>],args, "TCall"] |
842 } | 846 } |
843 | 847 |
844 Resolve@C Function[func,op:out] | 848 Resolve@C Function[func,op:out] |
845 { | 849 { |
846 If[[[func]Convention >>] = ["rhope"]] | 850 If[[[func]Convention >>] = ["rhope"]] |
847 { | 851 { |
848 [[func]Inputs >>]Find[=[op,?]] | 852 [[func]Inputs >>]Find[=[op,?]] |
849 { | 853 { |
850 out <- [["my_cdata->params["]Append[String[~]]]Append[" ]"] | 854 out <- [["my_cdata->params["]Append[String[~]]]Append[" ]"] |
851 }{ | 855 }{ |
852 out <- [[["lv_"]Append[Escape Rhope Name[[func]Name >>]]]Append["->"]]Append[Escape Rhope Name[op]] | 856 out <- [[["lv_"]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append["->"]]Append[Escape Rhope Name[op,[func]Escape Pattern >>]] |
853 } | 857 } |
854 }{ | 858 }{ |
855 out <- Escape Rhope Name[op] | 859 out <- Escape Rhope Name[op,[func]Escape Pattern >>] |
856 } | 860 } |
857 } | 861 } |
858 | 862 |
859 Resolve Output@C Function[func,name:out] | 863 Resolve Output@C Function[func,name:out] |
860 { | 864 { |
861 If[[[func]Convention >>] = ["rhope"]] | 865 If[[[func]Convention >>] = ["rhope"]] |
862 { | 866 { |
863 out <- [[["lv_"]Append[Escape Rhope Name[[func]Name >>]]]Append["->"]]Append[Escape Rhope Name[name]] | 867 out <- [[["lv_"]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append["->"]]Append[Escape Rhope Name[name,[func]Escape Pattern >>]] |
864 }{ | 868 }{ |
865 out <- Escape Rhope Name[name] | 869 out <- Escape Rhope Name[name,[func]Escape Pattern >>] |
866 } | 870 } |
867 } | 871 } |
868 | 872 |
869 Instruction Stream@C Function[func:out] | 873 Instruction Stream@C Function[func:out] |
870 { | 874 { |
922 ]Append[")"] | 926 ]Append[")"] |
923 } | 927 } |
924 | 928 |
925 _Set Outputs C[string,inputname,inputnum,func:out] | 929 _Set Outputs C[string,inputname,inputnum,func:out] |
926 { | 930 { |
927 out <- [string]Append[[[ [ ["\tRet("]Append[String[inputnum]] ]Append[ [[", lv_"]Append[Escape Rhope Name[[func]Name >>]]]Append["->"]]]Append[Escape Rhope Name[inputname]]]Append[")\n"]] | 931 out <- [string]Append[[[ [ ["\tRet("]Append[String[inputnum]] ]Append[ [[", lv_"]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append["->"]]]Append[Escape Rhope Name[inputname,[func]Escape Pattern >>]]]Append[")\n"]] |
928 } | 932 } |
929 | 933 |
930 Set Outputs@C Function[func:out] | 934 Set Outputs@C Function[func:out] |
931 { | 935 { |
932 If[[[func]Convention >>] = ["rhope"]] | 936 If[[[func]Convention >>] = ["rhope"]] |
933 { | 937 { |
934 out <- [[[Fold[_Set Outputs C[?, ?, ?, func], "", [func]Outputs >>]]Append["\tNumRet("]]Append[String[[[func]Outputs >>]Length]]]Append[")\n"] | 938 out <- [[[Fold[_Set Outputs C[?, ?, ?, func], "", [func]Outputs >>]]Append["\tNumRet("]]Append[String[[[func]Outputs >>]Length]]]Append[")\n"] |
935 }{ | 939 }{ |
936 [[func]Outputs >>]Index[0] | 940 [[func]Outputs >>]Index[0] |
937 { | 941 { |
938 out <- [["\treturn "]Append[Escape Rhope Name[~]]]Append[";\n"] | 942 out <- [["\treturn "]Append[Escape Rhope Name[~,[func]Escape Pattern >>]]]Append[";\n"] |
939 }{ | 943 }{ |
940 out <- "" | 944 out <- "" |
941 } | 945 } |
942 } | 946 } |
943 } | 947 } |
944 _Output Defs C[string,varname,index,func:out] | 948 _Output Defs C[string,varname,index,func:out] |
945 { | 949 { |
946 out <- [[[string]Append[ ["\t"]Append[Rhope Type to C[[[func]Output Types >>]Index[index]]] ]]Append[[" "]Append[Escape Rhope Name[varname]]]]Append[";\n"] | 950 out <- [[[string]Append[ ["\t"]Append[Rhope Type to C[[[func]Output Types >>]Index[index],[func]Escape Pattern >>]] ]]Append[[" "]Append[Escape Rhope Name[varname,[func]Escape Pattern >>]]]]Append[";\n"] |
947 } | 951 } |
948 _Var Defs C[string,type,varname:out] | 952 _Var Defs C[string,type,varname,p:out] |
949 { | 953 { |
950 Print[["Variable: "]Append[varname]] | 954 Print[["Variable: "]Append[varname]] |
951 { | 955 { |
952 out <- [[[string]Append[ ["\t"]Append[Rhope Type to C[type]] ]]Append[[" "]Append[Escape Rhope Name[varname]]]]Append[";\n"] | 956 out <- [[[string]Append[ ["\t"]Append[Rhope Type to C[type,p]] ]]Append[[" "]Append[Escape Rhope Name[varname,p]]]]Append[";\n"] |
953 { Print["Produced Output"]} | 957 { Print["Produced Output"]} |
954 } | 958 } |
955 } | 959 } |
956 | 960 |
957 | 961 |
959 { | 963 { |
960 Print[["Definitions@C Function: "]Append[[func]Name >>]] | 964 Print[["Definitions@C Function: "]Append[[func]Name >>]] |
961 { | 965 { |
962 If[ [[[func]Convention >>] = ["rhope"]] And [[ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] > [0]] ] | 966 If[ [[[func]Convention >>] = ["rhope"]] And [[ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] > [0]] ] |
963 { | 967 { |
964 localtype <- [[[Fold[_Output Defs C[?, ?, ?, func], Fold[_Var Defs C[?],"typedef struct {\n", [func]Variables >>], [func]Outputs >>]]Append["} lt_"]]Append[Escape Rhope Name[[func]Name >>]]]Append[";\n"] | 968 localtype <- [[[Fold[_Output Defs C[?, ?, ?, func], Fold[_Var Defs C[?,?,?,[func]Escape Pattern >>],"typedef struct {\n", [func]Variables >>], [func]Outputs >>]]Append["} lt_"]]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[";\n"] |
965 }{ | 969 }{ |
966 localtype <- "" | 970 localtype <- "" |
967 } | 971 } |
968 | 972 |
969 If[ [[func]Convention >>] = ["rhope"] ] | 973 If[ [[func]Convention >>] = ["rhope"] ] |
970 { | 974 { |
971 /* parts <- [[func]Name >>]Split["@"] | 975 /* parts <- [[func]Name >>]Split["@"] |
972 [parts]Index[1] | 976 [parts]Index[1] |
973 { | 977 { |
974 proto <- [[[["MethodDef(" | 978 proto <- [[[["MethodDef(" |
975 ]Append[Escape Rhope Name[[parts]Index[0]]] | 979 ]Append[Escape Rhope Name[[parts]Index[0],[func]Escape Pattern >>]] |
976 ]Append[", "] | 980 ]Append[", "] |
977 ]Append[Escape Rhope Name[~]] | 981 ]Append[Escape Rhope Name[~,[func]Escape Pattern >>]] |
978 ]Append[")\n"] | 982 ]Append[")\n"] |
979 }{ | 983 }{ |
980 proto <- [["FuncDef("]Append[Escape Rhope Name[[func]Name >>]]]Append[")\n"] | 984 proto <- [["FuncDef("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[")\n"] |
981 } */ | 985 } */ |
982 out <- Val[localtype] | 986 out <- Val[localtype] |
983 }{ | 987 }{ |
984 out <- [[func]Naked Proto]Append[";\n"] | 988 out <- [[func]Naked Proto]Append[";\n"] |
985 } | 989 } |
986 } | 990 } |
987 } | 991 } |
988 | 992 |
989 _Proto Input[list,input,index,types:out] | 993 _Proto Input[list,input,index,types,p:out] |
990 { | 994 { |
991 out <- [list]Append[ [[Rhope Type to C[[types]Index[index]]]Append[" "]]Append[Escape Rhope Name[input]] ] | 995 out <- [list]Append[ [[Rhope Type to C[[types]Index[index],p]]Append[" "]]Append[Escape Rhope Name[input,p]] ] |
992 } | 996 } |
993 | 997 |
994 Naked Proto@C Function[func:out] | 998 Naked Proto@C Function[func:out] |
995 { | 999 { |
996 [[func]Output Types >>]Index[0] | 1000 [[func]Output Types >>]Index[0] |
997 { | 1001 { |
998 outtype <- [Rhope Type to C[~]]Append[" "] | 1002 outtype <- [Rhope Type to C[~,[func]Escape Pattern >>]]Append[" "] |
999 }{ | 1003 }{ |
1000 outtype <- "void " | 1004 outtype <- "void " |
1001 } | 1005 } |
1002 out <- [[[[outtype | 1006 out <- [[[[outtype |
1003 ]Append[ Escape Rhope Name[[func]Name >>]] | 1007 ]Append[ Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] |
1004 ]Append["("] | 1008 ]Append["("] |
1005 ]Append[ [Fold[_Proto Input[?, ?, ?, [func]Input Types >>], (), [func]Inputs >>]]Join[", "] ] | 1009 ]Append[ [Fold[_Proto Input[?, ?, ?, [func]Input Types >>,[func]Escape Pattern >>], (), [func]Inputs >>]]Join[", "] ] |
1006 ]Append[")"] | 1010 ]Append[")"] |
1007 } | 1011 } |
1008 | 1012 |
1009 Type Check@C Function[func,text,type,input num:out] | 1013 Type Check@C Function[func,text,type,input num:out] |
1010 { | 1014 { |
1038 If[ [[func]Convention >>] = ["rhope"] ] | 1042 If[ [[func]Convention >>] = ["rhope"] ] |
1039 { | 1043 { |
1040 before <- [[func]Name >>]Partition["@"] {} {} | 1044 before <- [[func]Name >>]Partition["@"] {} {} |
1041 { | 1045 { |
1042 type <- "MethodImpl" | 1046 type <- "MethodImpl" |
1043 cname <- [[[[Escape Rhope Name[before] | 1047 cname <- [[[[Escape Rhope Name[before,[func]Escape Pattern >>] |
1044 ]Append[", "] | 1048 ]Append[", "] |
1045 ]Append[Escape Rhope Name[~]] | 1049 ]Append[Escape Rhope Name[~,[func]Escape Pattern >>]] |
1046 ]Append[", "] | 1050 ]Append[", "] |
1047 ]Append[ [[func]Type Registry >>]Type ID[~] ] | 1051 ]Append[ [[func]Type Registry >>]Type ID[~] ] |
1048 }{ | 1052 }{ |
1049 type <- "Func" | 1053 type <- "Func" |
1050 cname <- Val[fname] | 1054 cname <- Val[fname] |
1051 } | 1055 } |
1052 fname <- Escape Rhope Name[[func]Name >>] | 1056 fname <- Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>] |
1053 param check <- Fold[Check Param Type C[?, ?, ?, func], "", [func]Input Types >>] | 1057 param check <- Fold[Check Param Type C[?, ?, ?, func], "", [func]Input Types >>] |
1054 If[ [ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] = [0] ] | 1058 If[ [ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] = [0] ] |
1055 { | 1059 { |
1056 out <- [[[[[[[[ [type]Append["NoLocals("] | 1060 out <- [[[[[[[[ [type]Append["NoLocals("] |
1057 ]Append[cname] | 1061 ]Append[cname] |
1097 Functions | 1101 Functions |
1098 Method Registry | 1102 Method Registry |
1099 Field Registry | 1103 Field Registry |
1100 Type Registry | 1104 Type Registry |
1101 Libraries | 1105 Libraries |
1106 Escape Pattern | |
1102 } | 1107 } |
1103 | 1108 |
1104 C Program[:out] | 1109 C Program[:out] |
1105 { | 1110 { |
1106 out <- [[[[[Build[C Program()]]Functions <<[Dictionary[]]]Method Registry <<[C Method Registry[]]]Type Registry <<[C Type Registry[]]]Field Registry <<[C Field Registry[]]]Libraries <<[Dictionary[]] | 1111 p <- Pattern[("_", "@", " ", ":", "?", "+", "-", "*", "/", "<", ">", "(", ")", "!", "=", "'", |
1112 "\"", "\t", ",", ".", "\n", "{", "}", "[", "]", "#", "\\", "\r", ";", "&", "|", "%", "^", "`", "~")] | |
1113 out <- [[[[[[Build[C Program()]]Functions <<[Dictionary[]]]Method Registry <<[C Method Registry[]]]Type Registry <<[C Type Registry[p]]]Field Registry <<[C Field Registry[]]]Libraries <<[Dictionary[]]]Escape Pattern <<[p] | |
1107 } | 1114 } |
1108 | 1115 |
1109 Link@C Program[program,language,library:out] | 1116 Link@C Program[program,language,library:out] |
1110 { | 1117 { |
1111 If[[library] = ["runtime"]] | 1118 If[[library] = ["runtime"]] |
1130 out <- C Type[name] | 1137 out <- C Type[name] |
1131 } | 1138 } |
1132 | 1139 |
1133 Create Function@C Program[program,name,inputs,outputs,convention:out] | 1140 Create Function@C Program[program,name,inputs,outputs,convention:out] |
1134 { | 1141 { |
1135 out <- C Function With Registry[name,inputs,outputs,convention, [program]Method Registry >>, [program]Field Registry >>, [program]Type Registry >>] | 1142 out <- C Function With Registry[name,inputs,outputs,convention, [program]Method Registry >>, [program]Field Registry >>, [program]Type Registry >>, [program]Escape Pattern >>] |
1136 } | 1143 } |
1137 | 1144 |
1138 Store Function@C Program[program,func:out] | 1145 Store Function@C Program[program,func:out] |
1139 { | 1146 { |
1140 out <- [program]Functions <<[ [[program]Functions >>]Set[ [func]Name >>, func] ] | 1147 out <- [program]Functions <<[ [[program]Functions >>]Set[ [func]Name >>, func] ] |
1164 Combine Consts[consts,func:out] | 1171 Combine Consts[consts,func:out] |
1165 { | 1172 { |
1166 out <- Combine[[func]Constants >>, consts] | 1173 out <- Combine[[func]Constants >>, consts] |
1167 } | 1174 } |
1168 | 1175 |
1169 _Consts C Program[text,value,name:out] | 1176 _Consts C Program[text,value,name,p:out] |
1170 { | 1177 { |
1171 out <- [text]Append[ [["object * _const_"]Append[Escape Rhope Name[name]]]Append[";\n"] ] | 1178 out <- [text]Append[ [["object * _const_"]Append[Escape Rhope Name[name,p]]]Append[";\n"] ] |
1172 } | 1179 } |
1173 | 1180 |
1174 Const Construct C[value,type reg:out] | 1181 Const Construct C[value,type reg:out] |
1175 { | 1182 { |
1176 valtype <- Blueprint Of[value] | 1183 valtype <- Blueprint Of[value] |
1215 //or workaround the problem higher up in the food chain | 1222 //or workaround the problem higher up in the food chain |
1216 [[value]Args >>]Last | 1223 [[value]Args >>]Last |
1217 { size <- String[[~]+[1]] } | 1224 { size <- String[[~]+[1]] } |
1218 { size <- "0" } | 1225 { size <- "0" } |
1219 out <- [[[[[["make_Worker(FUNC_" | 1226 out <- [[[[[["make_Worker(FUNC_" |
1220 ]Append[Escape Rhope Name[[value]Name >>]] | 1227 ]Append[Escape Rhope Name[[value]Name >>,[type reg]Escape Pattern >>]] |
1221 ]Append[", "] | 1228 ]Append[", "] |
1222 ]Append[size] | 1229 ]Append[size] |
1223 ]Append[", "] | 1230 ]Append[", "] |
1224 ]Append[String[Fold[+[1,?], 0, [value]Args >>]]] | 1231 ]Append[String[Fold[+[1,?], 0, [value]Args >>]]] |
1225 ]Append[")"] | 1232 ]Append[")"] |
1251 [(String(),String Cat(),String Slice(),Worker Literal(),List(),List Leaf())]Find[=[valtype,?]] | 1258 [(String(),String Cat(),String Slice(),Worker Literal(),List(),List Leaf())]Find[=[valtype,?]] |
1252 { | 1259 { |
1253 out <- text | 1260 out <- text |
1254 }{ | 1261 }{ |
1255 Const Construct C[value,type reg] | 1262 Const Construct C[value,type reg] |
1256 { out <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] } | 1263 { out <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = "]]Append[~]]Append[";\n"] ] } |
1257 } | 1264 } |
1258 } | 1265 } |
1259 | 1266 |
1260 _Set List Els[text,el,index,type reg:out] | 1267 _Set List Els[text,el,index,type reg:out] |
1261 { | 1268 { |
1275 [(String(),String Cat(),String Slice(),Worker Literal(),List(),List Leaf())]Find[=[valtype,?]] | 1282 [(String(),String Cat(),String Slice(),Worker Literal(),List(),List Leaf())]Find[=[valtype,?]] |
1276 { | 1283 { |
1277 If[[~]>[3]] | 1284 If[[~]>[3]] |
1278 { | 1285 { |
1279 out <- [Fold[_Set List Els[?, ?, ?, type reg], "\trhope(FUNC_List, inout, 0, 1);\n", value] | 1286 out <- [Fold[_Set List Els[?, ?, ?, type reg], "\trhope(FUNC_List, inout, 0, 1);\n", value] |
1280 ]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = inout[0];\n"]] | 1287 ]Append[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = inout[0];\n"]] |
1281 }{ | 1288 }{ |
1282 Const Construct C[value,type reg] | 1289 Const Construct C[value,type reg] |
1283 { init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] } | 1290 { init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = "]]Append[~]]Append[";\n"] ] } |
1284 | 1291 |
1285 If[[valtype]=[Worker Literal()]] | 1292 If[[valtype]=[Worker Literal()]] |
1286 { | 1293 { |
1287 out <- Fold[_Set Worker Params C[?, ?, ?, type reg, Escape Rhope Name[name]], init, [value]Args >>] | 1294 out <- Fold[_Set Worker Params C[?, ?, ?, type reg, Escape Rhope Name[name,[type reg]Escape Pattern >>]], init, [value]Args >>] |
1288 }{ | 1295 }{ |
1289 out <- Val[init] | 1296 out <- Val[init] |
1290 } | 1297 } |
1291 } | 1298 } |
1292 }{ | 1299 }{ |
1306 | 1313 |
1307 _Dispatch Switch[text,func,raw name:out] | 1314 _Dispatch Switch[text,func,raw name:out] |
1308 { | 1315 { |
1309 If[[[func]Convention >>] = ["rhope"]] | 1316 If[[[func]Convention >>] = ["rhope"]] |
1310 { | 1317 { |
1311 name <- Escape Rhope Name[raw name] | 1318 name <- Escape Rhope Name[raw name,[func]Escape Pattern >>] |
1312 out <- [[text]Append[ [["\tDispatchEntry("]Append[name]]Append[")\\\n"] ] | 1319 out <- [[text]Append[ [["\tDispatchEntry("]Append[name]]Append[")\\\n"] ] |
1313 ]Append[Fold[_Dispatch Switch Sub[?, ?, name], "", Range[1, [func]Resume Index >>]]] | 1320 ]Append[Fold[_Dispatch Switch Sub[?, ?, name], "", Range[1, [func]Resume Index >>]]] |
1314 }{ | 1321 }{ |
1315 out <- text | 1322 out <- text |
1316 } | 1323 } |
1317 } | 1324 } |
1318 | 1325 |
1319 _Dispatch Switch Methods[text,id,raw name:out] | 1326 _Dispatch Switch Methods[p,text,id,raw name:out] |
1320 { | 1327 { |
1321 name <- Escape Rhope Name[raw name] | 1328 name <- Escape Rhope Name[raw name,p] |
1322 out <- [text]Append[ [["\tDispatchEntry("]Append[name]]Append[")\\\n"] ] | 1329 out <- [text]Append[ [["\tDispatchEntry("]Append[name]]Append[")\\\n"] ] |
1323 } | 1330 } |
1324 | 1331 |
1325 _Dispatch Enum Sub[text, num, name:out] | 1332 _Dispatch Enum Sub[text, num, name:out] |
1326 { | 1333 { |
1334 | 1341 |
1335 _Dispatch Enum[text,func,raw name:out] | 1342 _Dispatch Enum[text,func,raw name:out] |
1336 { | 1343 { |
1337 If[[[func]Convention >>] = ["rhope"]] | 1344 If[[[func]Convention >>] = ["rhope"]] |
1338 { | 1345 { |
1339 name <- Escape Rhope Name[raw name] | 1346 name <- Escape Rhope Name[raw name,[func]Escape Pattern >>] |
1340 out <- [[text]Append[ [["\tFUNC_"]Append[name]]Append[",\n"] ] | 1347 out <- [[text]Append[ [["\tFUNC_"]Append[name]]Append[",\n"] ] |
1341 ]Append[Fold[_Dispatch Enum Sub[?, ?, name], "", Range[1, [func]Resume Index >>]]] | 1348 ]Append[Fold[_Dispatch Enum Sub[?, ?, name], "", Range[1, [func]Resume Index >>]]] |
1342 }{ | 1349 }{ |
1343 out <- text | 1350 out <- text |
1344 } | 1351 } |
1345 } | 1352 } |
1346 | 1353 |
1347 _Dispatch Enum Methods[text,types,name:out] | 1354 _Dispatch Enum Methods[p,text,types,name:out] |
1348 { | 1355 { |
1349 out <- [text]Append[ [["\tFUNC_"]Append[Escape Rhope Name[name]]]Append[",\n"] ] | 1356 out <- [text]Append[ [["\tFUNC_"]Append[Escape Rhope Name[name,p]]]Append[",\n"] ] |
1350 } | 1357 } |
1351 | 1358 |
1352 Dispatch@C Program[program,all methods:out] | 1359 Dispatch@C Program[program,all methods:out] |
1353 { | 1360 { |
1354 out <- [[[[["typedef enum {\n" | 1361 out <- [[[[["typedef enum {\n" |
1355 ]Append[Fold[_Dispatch Enum[?], | 1362 ]Append[Fold[_Dispatch Enum[?], |
1356 [Fold[_Dispatch Enum Methods[?], "", all methods]]Append["\tFUNC_Build,\n\tFUNC_BlueprintSP_Of,\n\tFUNC_ID,\n\tFUNC_BlueprintSP_FromSP_ID,\n"], | 1363 [Fold[_Dispatch Enum Methods[[program]Escape Pattern >>,?], "", all methods]]Append["\tFUNC_Build,\n\tFUNC_BlueprintSP_Of,\n\tFUNC_ID,\n\tFUNC_BlueprintSP_FromSP_ID,\n"], |
1357 [program]Functions >>]] | 1364 [program]Functions >>]] |
1358 ]Append["\tEND\n} funcids;\n\n"] | 1365 ]Append["\tEND\n} funcids;\n\n"] |
1359 ]Append["#define DispatchEntries \\\n"] | 1366 ]Append["#define DispatchEntries \\\n"] |
1360 ]Append[Fold[_Dispatch Switch[?], | 1367 ]Append[Fold[_Dispatch Switch[?], |
1361 [Fold[_Dispatch Switch Methods[?], "", all methods]]Append["\tDispatchEntry(Build)\\\n\tDispatchEntry(BlueprintSP_Of)\\\n\tDispatchEntry(ID)\\\n\tDispatchEntry(BlueprintSP_FromSP_ID)\\\n"], | 1368 [Fold[_Dispatch Switch Methods[[program]Escape Pattern >>,?], "", all methods]]Append["\tDispatchEntry(Build)\\\n\tDispatchEntry(BlueprintSP_Of)\\\n\tDispatchEntry(ID)\\\n\tDispatchEntry(BlueprintSP_FromSP_ID)\\\n"], |
1362 [program]Functions >>]] | 1369 [program]Functions >>]] |
1363 ]Append["\tEndEntry\n\n"] | 1370 ]Append["\tEndEntry\n\n"] |
1364 } | 1371 } |
1365 | 1372 |
1366 Not Native[func:out] | 1373 Not Native[func:out] |
1379 { | 1386 { |
1380 If[ [ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] = [0] ] | 1387 If[ [ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] = [0] ] |
1381 { | 1388 { |
1382 out <- text | 1389 out <- text |
1383 }{ | 1390 }{ |
1384 out <- [text]Append[[["\tFuncDef("]Append[Escape Rhope Name[[func]Name >>]]]Append[")\n"]] | 1391 out <- [text]Append[[["\tFuncDef("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[")\n"]] |
1385 } | 1392 } |
1386 } | 1393 } |
1387 | 1394 |
1388 _Method to Types[dict,name,type:out] | 1395 _Method to Types[dict,name,type:out] |
1389 { | 1396 { |
1411 out <- Fold[_Field to Types[?, ?, type], dict, [type]Fields >>] | 1418 out <- Fold[_Field to Types[?, ?, type], dict, [type]Fields >>] |
1412 } | 1419 } |
1413 | 1420 |
1414 _Method Dispatch[text, type, method, reg: out] | 1421 _Method Dispatch[text, type, method, reg: out] |
1415 { | 1422 { |
1416 out <- [[[[[[[text]Append["\tMethodDispatch("]]Append[ [reg]Type ID[type] ]]Append[","]]Append[Escape Rhope Name[method]]]Append[","]]Append[Escape Rhope Name[type]]]Append[")\n"] | 1423 out <- [[[[[[[text]Append["\tMethodDispatch("]]Append[ [reg]Type ID[type] ]]Append[","]]Append[Escape Rhope Name[method,[reg]Escape Pattern >>]]]Append[","]]Append[Escape Rhope Name[type,[reg]Escape Pattern >>]]]Append[")\n"] |
1417 } | 1424 } |
1418 | 1425 |
1419 Method Dispatch[text, types, method, reg: out] | 1426 Method Dispatch[text, types, method, reg: out] |
1420 { | 1427 { |
1421 out <- [[[Fold[_Method Dispatch[?, ?, method, reg], [[[text]Append["Method("]]Append[ Escape Rhope Name[method] ]]Append[")\n"], types] | 1428 out <- [[[Fold[_Method Dispatch[?, ?, method, reg], [[[text]Append["Method("]]Append[ Escape Rhope Name[method,[reg]Escape Pattern >>] ]]Append[")\n"], types] |
1422 ]Append["EndMethod("] | 1429 ]Append["EndMethod("] |
1423 ]Append[Escape Rhope Name[method]] | 1430 ]Append[Escape Rhope Name[method,[reg]Escape Pattern >>]] |
1424 ]Append[")\n\n"] | 1431 ]Append[")\n\n"] |
1425 } | 1432 } |
1426 | 1433 |
1427 Text@C Program[program:out] | 1434 Text@C Program[program:out] |
1428 { | 1435 { |
1436 p <- [program]Escape Pattern >> | |
1429 type defs <- [[program]Type Registry >>]Definitions >> | 1437 type defs <- [[program]Type Registry >>]Definitions >> |
1430 constants <- Fold[Combine Consts[?], Dictionary[], [program]Functions >>] | 1438 constants <- Fold[Combine Consts[?], Dictionary[], [program]Functions >>] |
1431 all methods <- Fold[Field to Types[?], Fold[Method to Types[?], Dictionary[], type defs], type defs] | 1439 all methods <- Fold[Field to Types[?], Fold[Method to Types[?], Dictionary[], type defs], type defs] |
1432 headers <- "#include <stdio.h> | 1440 headers <- "#include <stdio.h> |
1433 #include <stdlib.h> | 1441 #include <stdlib.h> |
1441 #include \"worker.h\" | 1449 #include \"worker.h\" |
1442 #include \"bool.h\"\n\n" | 1450 #include \"bool.h\"\n\n" |
1443 out <- [[[[[[[[[[[[[[[headers | 1451 out <- [[[[[[[[[[[[[[[headers |
1444 ]Append[[program]Dispatch[all methods]] | 1452 ]Append[[program]Dispatch[all methods]] |
1445 ]Append[[[program]Type Registry >>]Type Defs] | 1453 ]Append[[[program]Type Registry >>]Type Defs] |
1446 ]Append[Fold[_Consts C Program[?], | 1454 ]Append[Fold[_Consts C Program[?,?,?,p], |
1447 Fold[_Defs C Program[?], "", [program]Functions >>], | 1455 Fold[_Defs C Program[?], "", [program]Functions >>], |
1448 constants]] | 1456 constants]] |
1449 ]Append[Fold[_Text C Program[?, ?, [program]Type Registry >>], "", Filter[[program]Functions >>, Not Native[?]]]] | 1457 ]Append[Fold[_Text C Program[?, ?, [program]Type Registry >>], "", Filter[[program]Functions >>, Not Native[?]]]] |
1450 ]Append["\n | 1458 ]Append["\n |
1451 int32_t rhope(uint32_t func, object ** params, uint16_t numparams, uint16_t callspace) | 1459 int32_t rhope(uint32_t func, object ** params, uint16_t numparams, uint16_t callspace) |