module wirespi. import typechecker, popeyesig, wiresig, gatesig, spinach. % Typechecker stuff. %%%%%%%%%%%%%%%%%%%% % Extension % extends wire object. % Generated by: otype wire class. % tcheck Theta wire Cont tmod TC :- popmod wire M, pi C\ tcheck ((tp C (tref wire))::Theta) (M C) Cont tprog TC. tcheck Theta (new wire P) Cont tcmd TC :- pi C\ tcheck ((tp C (tref wire))::Theta) (P C) Cont tcmd TC, print "OK". tcheck Theta (cons W wire) Cont theadin TC :- tcheck Theta W nil (tref wire) nil, tcheck Theta none Cont dot TC. tcheck Theta (cons W wire) Cont theadout TC :- tcheck Theta none Cont dot TC. tcheck Theta (super C wire) Cont tcmd TC :- tcheck Theta none Cont dot TC. % Private data % tcheck Theta (ppriv wire state) Cont popbool TC :- tcheck Theta none Cont dot TC. % Generated by: ptype wire state boolean. tcheck Theta (ppriv wire queue) Cont (tref poplist) TC :- tcheck Theta none Cont dot TC. % Generated by: ptype wire queue ref poplist. % Constants % tcheck Theta (pcst wire on) Cont popbool TC :- tcheck Theta none Cont dot TC. % Generated by: ctype wire on boolean (pbool true). tcheck Theta (pcst wire off) Cont popbool TC :- tcheck Theta none Cont dot TC. % Generated by: ctype wire off (pbool false). % Methods % % Generated by: mtype get_signal out ref wire -> boolean -> cmd. % tcheck Theta (get_signal W S) Cont tcmd TC :- tcheck Theta W nil (tref wire) nil, tcheck Theta S nil dot nil, tcheck ((tp S popbool)::Theta) none Cont dot TC. % read tcheck Theta (get_signal W S) Cont ttest TC :- tcheck Theta W nil (tref wire) nil, tcheck Theta S nil popbool nil, tcheck Theta none Cont dot TC. % test tcheck Theta (get_signal W S) Cont theadin TC :- tcheck Theta W nil (tref wire) nil, tcheck Theta none Cont dot TC. % headin tcheck Theta (get_signal W S) Cont theadout TC :- tcheck Theta S nil popbool nil, tcheck Theta none Cont dot TC. % headout % Generated by: mtype set_signal in ref wire -> boolean -> cmd. % tcheck Theta (set_signal W S) Cont tcmd TC :- tcheck Theta W nil (tref wire) nil, tcheck Theta S nil popbool nil, tcheck Theta none Cont dot TC. % write tcheck Theta (set_signal W S) Cont theadin TC :- tcheck Theta W nil (tref wire) nil, tcheck ((tp S popbool)::Theta) none Cont dot TC. % headin tcheck Theta (set_signal W S) Cont theadout TC :- tcheck Theta none Cont dot TC. % headout % Generated by: mtype add_gate in ref wire -> ref gate -> cmd. % tcheck Theta (add_gate W G) Cont tcmd TC :- tcheck Theta W nil (tref wire) nil, tcheck Theta G nil (tref gate) nil, tcheck Theta none Cont dot TC. % write tcheck Theta (add_gate W G) Cont theadin TC :- tcheck Theta W nil (tref wire) nil, tcheck ((tp G (tref gate))::Theta) none Cont dot TC. % headin tcheck Theta (add_gate W G) Cont theadout TC :- tcheck Theta none Cont dot TC. % headout % Generated by: mtype del_gate in ref wire -> ref gate -> cmd. % tcheck Theta (del_gate W G) Cont tcmd TC :- tcheck Theta W nil (tref wire) nil, tcheck Theta G nil (tref gate) nil, tcheck Theta none Cont dot TC. % write tcheck Theta (del_gate W G) Cont theadin TC :- tcheck Theta W nil (tref wire) nil, tcheck ((tp G (tref gate))::Theta) none Cont dot TC. % headin tcheck Theta (del_gate W G) Cont theadout TC :- tcheck Theta none Cont dot TC. % Generated by: mtype notify in ref wire -> ref poplist -> cmd. % tcheck Theta (notify W O) Cont tcmd TC :- tcheck Theta W nil (tref wire) nil, tcheck Theta O nil (tref poplist) nil, tcheck Theta none Cont dot TC. % write tcheck Theta (notify W O) Cont theadin TC :- tcheck Theta W nil (tref wire) nil, tcheck ((tp O (tref poplist))::Theta) none Cont dot TC. % headin tcheck Theta (notify W O) Cont theadout TC :- print "OUT", tcheck Theta none Cont dot TC. % headout % Spinacher stuff %%%%%%%%%%%%%%%%% % Constants % spinach Theta Mu (pcst wire on) Java :- spinach nil nil (tref wire) SO, Java is SO ^ "." ^ "ON". % Generated by: ctype on boolean true. spinach Theta Mu (pcst wire off) Java :- spinach nil nil (tref wire) SO, Java is SO ^ "." ^ "OFF". % Generated by: ctype off boolean false. % Generated by: otype wire class. % spinach Theta Mu (tref wire) "Wire". spinach Theta Mu wire Java :- popmod wire P, extends wire O, spinach nil nil (tref O) SO, pi C\ spinach ((tp C (tref wire))::Theta) ((np C "this")::Mu) (P C) JP, Java is "public class " ^ "Wire" ^ " extends " ^ SO ^ "{\n" ^ JP ^ "}\n". spihead Theta Mu (cons W (wire)) nil Java "" :- Java is "Wire(" ^ "){\n". spinach Theta Mu (popnew wire S P) Java :- pi O\ spinach ((tp O (tref wire))::Theta) ((np O S)::Mu) (P O) JP, spinach nil nil (tref wire) JS, Java is JS ^ " " ^ S ^ " = new " ^ JS ^ "(" ^ ");\n" ^ JP. spinach Theta Mu (super C (wire)) Java :- Java is "super(" ^ ");\n". % Generated by: mtype get_signal out ref wire -> boolean -> cmd. % spihead Theta Mu (get_signal W S) nil Java Jreturn :- spinach nil nil popbool STS, Java is "public " ^ STS ^ " get_signal(){\n", spinach Theta Mu S SS, Jreturn is "return " ^ SS ^ ";\n". spinach Theta Mu (get_signal W S) Java :- spinach Theta Mu W SW, spinach Theta Mu S SS, Java is SS ^ "=" ^ SW ^ "." ^ "get_signal();\n". % Generated by: mtype set_signal in ref wire -> boolean -> cmd. % spihead Theta Mu (set_signal W S) (S::nil) Java "" :- spinach nil nil popbool STS, spinach Theta Mu S SS, Java is "public void set_signal( " ^ STS ^ " " ^ SS ^ " ){\n". spinach Theta Mu (set_signal W S) Java :- spinach Theta Mu W SW, spinach Theta Mu S SS, Java is SW ^ "." ^ "set_signal(" ^ SS ^ ");\n". % Generated by: mtype add_gate in ref wire -> ref gate -> cmd. % spihead Theta Mu (add_gate W G) (G::nil) Java "" :- spinach nil nil (tref gate) STG, spinach Theta Mu G SG, Java is "public void add_gate( " ^ STG ^ " " ^ SG ^ " ){\n". spinach Theta Mu (add_gate W G) Java :- spinach Theta Mu W SW, spinach Theta Mu G SG, Java is SW ^ "." ^ "add_gate(" ^ SG ^ ");\n". % Generated by: mtype del_gate in ref wire -> ref gate -> cmd. % spihead Theta Mu (del_gate W G) (G::nil) Java "" :- spinach nil nil (tref gate) STG, spinach Theta Mu G SG, Java is "public void del_gate( " ^ STG ^ " " ^ SG ^ " ){\n". spinach Theta Mu (del_gate W G) Java :- spinach Theta Mu W SW, spinach Theta Mu G SG, Java is SW ^ "." ^ "del_gate(" ^ SG ^ ");\n". % Generated by: mtype notify in ref wire -> ref poplist -> cmd. % % HACK: notify is reserved for synchronization in Java. I modified the name to % notify_gates by hand... % spihead Theta Mu (notify W O) (O::nil) Java "" :- spinach nil nil (tref poplist) STO, spinach Theta Mu O SO, Java is "public void notify_gates( " ^ STO ^ " " ^ SO ^ " ){\n". spinach Theta Mu (notify W O) Java :- spinach Theta Mu W SW, spinach Theta Mu O SO, Java is SW ^ "." ^ "notify_gates(" ^ SO ^ ");\n".