CLtomCompiler.tex 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. \begin{figure}[h!]
  2. % Define the layers to draw the diagram
  3. \pgfdeclarelayer{tomgombackground}
  4. \pgfdeclarelayer{tombackground}
  5. \pgfsetlayers{tomgombackground,tombackground,main}
  6. % Define a new shape: page with a folded corner
  7. \makeatletter
  8. \pgfdeclareshape{flippedpage}{
  9. \inheritsavedanchors[from=rectangle] % this is nearly a rectangle
  10. \inheritanchorborder[from=rectangle]
  11. \inheritanchor[from=rectangle]{center}
  12. \inheritanchor[from=rectangle]{north}
  13. \inheritanchor[from=rectangle]{south}
  14. \inheritanchor[from=rectangle]{west}
  15. \inheritanchor[from=rectangle]{east}
  16. % ... and possibly more
  17. \backgroundpath{% this is new
  18. % store lower left in xa/ya and upper right in xb/yb
  19. \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
  20. \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
  21. % compute corner of ``flipped page''
  22. \pgf@xc=\pgf@xb \advance\pgf@xc by-5pt % this should be a parameter
  23. \pgf@yc=\pgf@yb \advance\pgf@yc by-5pt
  24. % diagonal path of the corner
  25. \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
  26. \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}}
  27. \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yb}}
  28. \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yc}}
  29. \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
  30. \pgfpathclose
  31. % add little corner
  32. \pgfpathmoveto{\pgfpoint{\pgf@xc}{\pgf@yb}}
  33. \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}}
  34. \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yc}}
  35. \pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}}
  36. }
  37. }
  38. % Define block styles
  39. \tikzstyle{compiler}=[draw, fill=blue!20, text width=6em, text centered, minimum height=2.5em, rounded corners]
  40. \tikzstyle{code}=[draw,shape=flippedpage,text width=2.7em, text centered, minimum height=3.7em,fill=white]
  41. \tikzstyle{texttitle}=[fill=white, rounded corners, draw=black!50, dashed]
  42. \tikzstyle{background}=[fill=yellow!20, rounded corners, draw=black!50, dashed]
  43. \begin{center}
  44. \begin{tikzpicture}
  45. % Draw diagram elements
  46. % Draw an invisible paper and back papers
  47. \node (invisiblemapping) [text width=2.7em, minimum height=3.7em] {};
  48. \path (invisiblemapping)+(0.0,0.16) node (mappingzero) [code] {};
  49. \path (mappingzero)+(-0.08,-0.08) node (mappingone) [code] {};
  50. \path (mappingone)+(-0.08,-0.08) node (mapping) [code] {\figcode{mapping}};
  51. \path (mapping)+(0.0,-3.6) node (datastruct)[code]
  52. {\figcode{java data}\\ \figcode{structures}};
  53. \path (mapping.east)+(2.5,0.0) node (tomcomp)[compiler]
  54. {\figcode{tom compiler}};
  55. \path (mapping.east)+(2.5,1.8) node (tomcode)[code]
  56. {\figcode{tom program}};
  57. \path (mapping.east)+(2.5,-1.8) node (javacode)[code]
  58. {\figcode{java program}};
  59. \path (mapping.east)+(2.5,-3.6) node (javacomp)[compiler]
  60. {\figcode{java compiler}};
  61. \path (mapping.east)+(2.5,-5.4) node (bytecode)[code]
  62. {\figcode{110010}\\\figcode{101110}\\\figcode{010100}};
  63. % Draw gom side
  64. \path (mapping.west)+(-3.0,0.0) node (gomcomp)[compiler]
  65. {\figcode{gom compiler}};
  66. \path (mapping.west)+(-3.0,1.8) node[code] (gomsig) {\figcode{gom} \\ \figcode{signature}};
  67. % Draw arrows between elements
  68. \path [draw, ->] (gomsig.south) -- node [left] {} (gomcomp);
  69. \path [draw, ->] (gomcomp.east) -- node [above] {} (mapping);
  70. % Use invisible mapping to avoid arrow cover back papers
  71. \path [draw, ->] (invisiblemapping.east) -- node [above] {} (tomcomp);
  72. \path [draw, ->] (gomcomp.east) -- node [above] {} (datastruct);
  73. \path [draw, ->] (datastruct.east) -- node [above] {} (javacomp);
  74. \path [draw, ->] (tomcode.south) -- node [left] {} (tomcomp);
  75. \path [draw, ->] (tomcomp.south) -- node [left] {} (javacode);
  76. \path [draw, ->] (javacode.south) -- node [left] {} (javacomp);
  77. \path [draw, ->] (javacomp.south) -- node [left] {} (bytecode);
  78. % Draw layer titles
  79. \path (gomsig)+(-0.5,1.7) node (tomgomtitle) [texttitle]
  80. {\code{tom + gom}};
  81. \path (mapping)+(0.0,3.0) node (tomtitle) [texttitle]
  82. {\code{tom}};
  83. % Draw tomgombackground
  84. \begin{pgfonlayer}{tomgombackground}
  85. % Left-top corner of the background rectangle
  86. \path (gomsig.west |- gomsig.north)+(-1.0,1.0) node (a) {};
  87. % Right-bottom corner of the background rectangle
  88. \path (bytecode.east|- bytecode.south)+(1.5,-1.0) node (b) {};
  89. % Draw the background
  90. \path[background]
  91. (a) rectangle (b);
  92. \end{pgfonlayer}
  93. % Draw tombackground
  94. \begin{pgfonlayer}{tombackground}
  95. % Left-top corner of the background rectangle
  96. \path (mapping.west |- mapping.north)+(-0.5,2.3) node (a) {};
  97. % Right-bottom corner of the background rectangle
  98. \path (bytecode.east|- bytecode.south)+(1.0,-0.5) node (b) {};
  99. % Draw the background
  100. \path[background]
  101. (a) rectangle (b);
  102. \end{pgfonlayer}
  103. \end{tikzpicture}
  104. \end{center}
  105. \caption{Processus de compilation d'un programme {\tom}}
  106. \label{fig:compilation}
  107. \end{figure}