Mercurial > hg > truffle
diff doc/design/graphdrawing.tex @ 2517:8c6e31c62fba
added initial version of design docs, fixed .hgignore (regex, . -> \.)
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 27 Apr 2011 15:59:38 +0200 |
parents | |
children | 550b291f56c4 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/design/graphdrawing.tex Wed Apr 27 15:59:38 2011 +0200 @@ -0,0 +1,84 @@ + +% graph drawing +\newcommand{\digraph}[3][scale=1]{ + \newwrite\dotfile + \immediate\openout\dotfile=dot_temp_#2.dot + \immediate\write\dotfile{digraph dot_temp_#2 {\string#3}} + \immediate\closeout\dotfile + \immediate\write18{bash -c "dot -Tpdf dot_temp_#2.dot > dot_temp_#2.pdf"} + \IfFileExists{dot_temp_#2.pdf} + % the pdf exists: include it + { \includegraphics[#1]{dot_temp_#2} } + % the pdf was not created - show a hint + { \fbox{ \begin{tabular}{l} + The file \texttt{dot_temp_#2.pdf} hasn't been created from + \texttt{dot_temp_#2.dot} yet. \\ + We attempted to create it with:\\ + `\texttt{dot -Tpdf dot_temp_#2.dot > dot_temp_#2.pdf}' \\ + but that seems not to have worked. You need to execute `\texttt{pdflatex}' with \\ + the `\texttt{-shell-escape} option. + \end{tabular}} + } +} + +\NewEnviron{digraphenv}[2]{\digraph[#1]{#2}{ margin=0; pad=0; \BODY }} + +\newcommand{\control}[2]{#1:successors:s -> #2:predecessors:n [color=red];} +\newcommand{\controllabel}[2]{#1 -> #2:predecessors:n [color=red];} +\newcommand{\data}[2]{#2:usages:s -> #1:inputs [color=black,dir=back];} +\newcommand{\datalabel}[2]{#2:usages:s -> #1:n [color=black,dir=back];} + +\newcommand{\genericnodestart}[1]{#1 [shape=plaintext, label=< <TABLE BORDER="0" CELLSPACING="0"><TR><TD CELLPADDING="0"><TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0"><TR><TD WIDTH="15" HEIGHT="5" PORT="predecessors" BGCOLOR="rosybrown1"></TD></TR></TABLE></TD><TD COLSPAN="2" CELLPADDING="0" ALIGN="RIGHT"><TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0"><TR>} +\newcommand{\genericnodeend}[0]{</TR></TABLE></TD><TD CELLPADDING="0"><TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0"><TR><TD WIDTH="15" HEIGHT="5" PORT="usages" BGCOLOR="lightgrey"></TD></TR></TABLE></TD></TR></TABLE>>]} +\newcommand{\portinput}[1]{<TD WIDTH="15" HEIGHT="5" PORT="#1" BGCOLOR="lightgrey"></TD>} +\newcommand{\portsuccessor}[1]{<TD WIDTH="15" HEIGHT="5" PORT="#1" BGCOLOR="rosybrown1"></TD>} +\newcommand{\portempty}[0]{<TD WIDTH="15" HEIGHT="5"></TD>} +\newcommand{\genericnodelabel}[1]{</TR></TABLE></TD></TR><TR><TD BORDER="1" COLSPAN="3">#1</TD></TR><TR><TD COLSPAN="2" CELLPADDING="0" ALIGN="RIGHT"><TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0"><TR>} + +\newcommand{\node}[2]{\genericnodestart{#1} \portempty \portinput{inputs} \genericnodelabel{#2} \portsuccessor{successors} \portempty \genericnodeend } +\newcommand{\nodebi}[2]{\genericnodestart{#1} \portinput{in1} \portinput{in2} \genericnodelabel{#2} \portsuccessor{successors} \portempty \genericnodeend } +\newcommand{\nodetri}[2]{\genericnodestart{#1} \portinput{in1} \portinput{in2} \portinput{in3} \genericnodelabel{#2} \portsuccessor{successors} \portempty \portempty \genericnodeend } +\newcommand{\nodesplit}[2]{\genericnodestart{#1} \portempty \portinput{inputs} \genericnodelabel{#2} \portsuccessor{succ1} \portsuccessor{succ2} \genericnodeend } + +%%%%%%%%%%%%%% example: + +% \begin{digraphenv}{scale=0.5}{MyGraph} +% \node{start}{start} +% \node{end}{end} +% % input projections +% \node{a}{proj:a} +% \node{b}{proj:b} +% \data{a}{start} +% \data{b}{start} +% % if +% \nodebi{cmp1}{<} +% \datalabel{cmp1:in1}{a} +% \datalabel{cmp1:in2}{b} +% \nodesplit{if}{if} +% \data{if}{cmp1} +% \control{start}{if} +% % branches +% \nodebi{add1}{+} +% \datalabel{add1:in1}{a} +% \datalabel{add1:in2}{b} +% \nodebi{sub1}{-} +% \datalabel{sub1:in1}{a} +% \datalabel{sub1:in2}{b} +% \controllabel{if:succ1}{add1} +% \controllabel{if:succ2}{sub1} +% % merge +% \nodebi{merge}{merge} +% \control{add1}{merge} +% \control{sub1}{merge} +% % phi +% \nodebi{phi1}{phi} +% \datalabel{phi1:in1}{add1} +% \datalabel{phi1:in2}{sub1} +% % ret +% \node{ret}{ret} +% \data{ret}{phi1} +% \control{merge}{ret} +% \control{ret}{end} +% \end{digraphenv} + +%%%%%%%%%%%%%%%