2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								:- use_module(library(lineutils),
							 | 
						
					
						
							
								
									
										
										
										
											2014-10-02 14:19:53 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									[file_filter_with_initialization/5,
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									 split/3,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									 glue/3]).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								:- use_module(library(lists),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									[append/2,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									 append/3]).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								:- initialization(main).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								:- dynamic globals/1.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								:- yap_flag(write_strings,on).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								:- style_check(all).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								main :-
							 | 
						
					
						
							
								
									
										
										
										
											2010-04-18 21:48:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									warning(Warning),
							 | 
						
					
						
							
								
									
										
										
										
											2014-10-02 14:19:53 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									file_filter_with_initialization('misc/HEAPFIELDS','H/hstruct.h',gen_struct,Warning,['hstruct.h','HEAPFIELDS']),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									file_filter_with_initialization('misc/HEAPFIELDS','H/dhstruct.h',gen_dstruct,Warning,['dhstruct.h','HEAPFIELDS']),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									file_filter_with_initialization('misc/HEAPFIELDS','H/rhstruct.h',gen_hstruct,Warning,['rhstruct.h','HEAPFIELDS']),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									file_filter_with_initialization('misc/HEAPFIELDS','H/ihstruct.h',gen_init,Warning,['ihstruct.h','HEAPFIELDS']).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									%file_filter_with_initialization('misc/GLOBALS','H/hglobals.h',gen_struct,Warning,['hglobals.h','GLOBALS']),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									%file_filter_with_initialization('misc/GLOBALS','H/dglobals.h',gen_dstruct,Warning,['dglobals.h','GLOBALS']),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									%file_filter_with_initialization('misc/GLOBALS','H/rglobals.h',gen_hstruct,Warning,['rglobals.h','GLOBALS']),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									%file_filter_with_initialization('misc/GLOBALS','H/iglobals.h',gen_init,Warning,['iglobals.h','GLOBALS']),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									%file_filter_with_initialization('misc/LOCALS','H/hlocals.h',gen_struct,Warning,['hlocals.h','LOCALS']),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									%file_filter_with_initialization('misc/LOCALS','H/dlocals.h',gen_dstruct,Warning,['dlocals.h','LOCALS']),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									%file_filter_with_initialization('misc/LOCALS','H/rlocals.h',gen_hstruct,Warning,['rlocals.h','LOCALS']),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									%file_filter_with_initialization('misc/LOCALS','H/ilocals.h',gen_init,Warning,['ilocals.h','LOCALS']).
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									
							 | 
						
					
						
							
								
									
										
										
										
											2010-04-18 21:48:20 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								warning('~n  /* This file, ~a, was generated automatically by \"yap -L misc/buildheap\"~n     please do not update, update misc/~a instead */~n~n').
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								/* define the field */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'/,0'/|_], !.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'/,0'*|_], !.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp, Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'#|_], !, Out = Inp. % '
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'.|_], !. %'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "START_WORKER_LOCAL", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Out = "typedef struct worker_local {".
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "END_WORKER_LOCAL", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Out = "} w_local;".
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-03-25 18:01:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Inp = "START_GLOBAL_DATA", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Out = "typedef struct global_data {".
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-03-25 18:01:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Inp = "END_GLOBAL_DATA", !,
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Out = "} w_shared;".
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-30 23:59:00 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "ATOMS", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Out = "#include \"tatoms.h\"".
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",["struct",Type, Field|_]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  struct ",Type,"  ",Field,";"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",["union",Type, Field|_]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  union ",Type,"  ",Field,";"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-14 12:05:43 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        split(Inp," 	",["const",Type, Field|_]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        append(["  const ",Type,"  ",Field,";"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",["void","void"|_]), !.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[Type, Field|_]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Type,"  ",Field,";"], Out).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_struct(Inp,_) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, _, _| _]),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									format(user_error,"OOPS: could not gen_struct for ~s~n",[Inp]).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'/,0'/|_], !.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'/,0'*|_], !.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp, Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'#|_], !, Out = Inp. % '
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "START_WORKER_LOCAL", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									assert(globals(worker)).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "END_WORKER_LOCAL", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									retract(globals(worker)).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,"") :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-03-25 18:01:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Inp = "START_GLOBAL_DATA", !,
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									assert(globals(all)).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,"") :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-03-25 18:01:17 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Inp = "END_GLOBAL_DATA", !,
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									retract(globals(all)).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-30 23:59:00 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "ATOMS", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Out = "".
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",["void","void"|_]), !.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",["struct"|Inp2]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									glue(Inp2, " ", Inp3),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									gen_dstruct(Inp3, Out).
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",["union"|Inp2]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									glue(Inp2, " ", Inp3),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									gen_dstruct(Inp3, Out).
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-14 12:05:43 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        split(Inp," 	",["const"|Inp2]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        glue(Inp2, " ", Inp3),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        gen_dstruct(Inp3, Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, Name|_]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_c_stuff(Field, RField),
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["#define ",Name," ",Global,RField], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_dstruct(Inp,_) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, _, _| _]),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									format(user_error,"OOPS: could not gen_dstruct for ~s~n",[Inp]).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fetch_name(Global) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									globals(all), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Global = "Yap_global->".
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								fetch_name(Global) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									globals(worker), !,
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-09 19:36:51 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Global = "LOCAL->".
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fetch_name(Global) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									globals(worker_init), !,
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-09 19:55:06 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Global = "REMOTE(wid)->".
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fetch_name(Global) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Global = "Yap_heap_regs->".
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fetch_name(Global,RField,_) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									globals(worker_init), !,
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-09 19:55:06 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									append("REMOTE(wid)->",RField,Global).
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								fetch_name(Global,_,Global).
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								% handle *field[4]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								cut_c_stuff([0'*|Name], RName) :- !, % 'cut *
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_c_stuff(Name, RName).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								cut_c_stuff(Name, RName) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_mat(Name, RName).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								cut_mat([], []).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								cut_mat([0'[|_], []) :- !. %' 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								cut_mat(H.Name, H.RName) :- 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_mat(Name, RName).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'/,0'/|_], !.
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'.|_], !. %'
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'/,0'*|_], !.
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-30 23:59:00 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "ATOMS", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Out = "#include \"ratoms.h\"".
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "START_WORKER_LOCAL", !,
							 | 
						
					
						
							
								
									
										
										
										
											2011-03-07 16:02:55 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Out = "static void RestoreWorker(int wid USES_REGS) {",
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									assert(globals(worker_init)).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "END_WORKER_LOCAL", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Out = "}",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									retract(globals(worker_init)).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-03-29 18:19:18 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Inp = "START_GLOBAL_DATA", !,
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Out = "static void RestoreGlobal(void) {",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									assert(globals(all)).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-03-29 18:19:18 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Inp = "END_GLOBAL_DATA", !,
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Out = "}",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									retract(globals(all)).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp, Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'#|_], !, Out = Inp. % '
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",["struct"|Inp2]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									glue(Inp2, " ", Inp3),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									gen_hstruct(Inp3,Out).
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",["union"|Inp2]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									glue(Inp2, " ", Inp3),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									gen_hstruct(Inp3,Out).
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-14 12:05:43 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        split(Inp," 	",["const"|Inp2]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        glue(Inp2, " ", Inp3),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        gen_hstruct(Inp3,Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkAT", _]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,Field,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global," = AtomTermAdjust(",Global,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkPred"| _]), !,
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_c_stuff(Field, RField),
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,RField,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global," = PtoPredAdjust(",Global,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkOp", Name]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,Field,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global," = Yap_opcode(",Name,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkLock"]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,Field,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  REINIT_LOCK(",Global,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkRWLock"]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,Field,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  REINIT_RWLOCK(",Global,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkInstE",OP]), !,
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_c_stuff(Field, RField),
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,RField,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global,"->opc = Yap_opcode(",OP,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,"") :-
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, _, _, _]), !.
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, _, _, _, "void"]), !.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Restore) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, _, _, _, Restore0]),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append("Restore",_,Restore0), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Restore0,";"],Restore). %'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, _, Adjust]),
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(Adjust,"Adjust",_), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_c_stuff(Field, RField),
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,RField,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global," = ",Adjust,"(",Global,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_hstruct(Inp,_) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, _, _| _]),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									format(user_error,"OOPS: could not gen_hstruct for ~s~n",[Inp]).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'/,0'*|_], !.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'/,0'/|_], !.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp, Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = [0'#|_], !, Out = Inp. % '
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-30 23:59:00 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "ATOMS", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Out = "#include \"iatoms.h\"".
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "START_WORKER_LOCAL", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Out = "static void InitWorker(int wid) {",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									assert(globals(worker_init)).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Inp = "END_WORKER_LOCAL", !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									Out = "}",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									retract(globals(worker_init)).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-03-29 18:19:18 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Inp = "START_GLOBAL_DATA", !,
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Out = "static void InitGlobal(void) {",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									assert(globals(all)).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-03-29 18:19:18 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Inp = "END_GLOBAL_DATA", !,
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									Out = "}",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									retract(globals(all)).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",["struct"|Inp2]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									glue(Inp2, " ", Inp3),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									gen_init(Inp3, Out).
							 | 
						
					
						
							
								
									
										
										
										
											2010-03-21 22:12:42 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",["union"|Inp2]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									glue(Inp2, " ", Inp3),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									gen_init(Inp3, Out).
							 | 
						
					
						
							
								
									
										
										
										
											2014-12-14 12:05:43 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        split(Inp,"	 ",["const"|Inp2]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        glue(Inp2, " ", Inp3),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        gen_init(Inp3, Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,"") :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, _, _, "void"|_]), !.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Init) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, _, _, Init0| _]),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append("Init",_,Init0), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Init0,";"],Init).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Init) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, _, _, Init0| _]),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append("Yap_Init",_,Init0), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Init0,";"],Init).
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-09 19:36:51 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Init) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, _, _, Init0| _]),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append("Yap_init",_,Init0), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Init0,";"],Init).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkAT", AtomName]), !,
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_c_stuff(Field, RField),
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,RField,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global," = MkAtomTerm(",AtomName,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkOp", Name]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,Field,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global," = Yap_opcode(",Name,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkLock"]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,Field,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  INIT_LOCK(",Global,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkRWLock"]), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,Field,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  INIT_RWLOCK(",Global,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkInstE",OP]), !,
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_c_stuff(Field, RField),
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,RField,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global,"->opc = Yap_opcode(",OP,");"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkPred", Atom, "0", Module]), !,
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_c_stuff(Field, RField),
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,RField,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global," = RepPredProp(PredPropByAtom(",Atom,",",Module,"));"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkPred", Atom, Arity, Module]), !,
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_c_stuff(Field, RField),
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,RField,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global," = RepPredProp(PredPropByFunc(Yap_MkFunctor(",Atom,",",Arity,"),",Module,"));"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, "MkPred", Fun, Module]), !,
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_c_stuff(Field, RField),
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,RField,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global," = RepPredProp(PredPropByFunc(",Fun,",",Module,"));"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,Out) :-
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, Field, MacroName, F0|_]),
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append("=",F,F0), !,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									cut_c_stuff(Field, RField),
							 | 
						
					
						
							
								
									
										
										
										
											2011-05-04 19:34:22 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
									fetch_name(Global,RField,MacroName),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									append(["  ",Global," = ",F,";"], Out).
							 | 
						
					
						
							
								
									
										
										
										
											2009-10-28 13:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								gen_init(Inp,_) :-
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									split(Inp,"	 ",[_, _, _| _]),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									format(user_error,"OOPS: could not gen_init for ~s~n",[Inp]).
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 |