pp.pas 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Commandline compiler for Free Pascal
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************}
  17. {
  18. possible compiler switches (* marks a currently required switch):
  19. -----------------------------------------------------------------
  20. USE_RHIDE generates errors and warning in an format recognized
  21. by rhide
  22. TP to compile the compiler with Turbo or Borland Pascal
  23. GDB* support of the GNU Debugger
  24. I386 generate a compiler for the Intel i386+
  25. M68K generate a compiler for the M68000
  26. USEOVERLAY compiles a TP version which uses overlays
  27. EXTDEBUG some extra debug code is executed
  28. SUPPORT_MMX only i386: releases the compiler switch
  29. MMX which allows the compiler to generate
  30. MMX instructions
  31. EXTERN_MSG Don't compile the msgfiles in the compiler, always
  32. use external messagefiles, default for TP
  33. NOAG386INT no Intel Assembler output
  34. NOAG386NSM no NASM output
  35. NOAG386BIN leaves out the binary writer, default for TP
  36. LOGMEMBLOCKS adds memory manager which logs the size of
  37. each allocated memory block, the information
  38. is written to memuse.log after compiling
  39. -----------------------------------------------------------------
  40. Required switches for a i386 compiler be compiled by Free Pascal Compiler:
  41. GDB;I386
  42. Required switches for a i386 compiler be compiled by Turbo Pascal:
  43. GDB;I386;TP
  44. Required switches for a 68000 compiler be compiled by Turbo Pascal:
  45. GDB;M68k;TP
  46. }
  47. {$ifdef FPC}
  48. {$ifndef GDB}
  49. { people can try to compile without GDB }
  50. { $error The compiler switch GDB must be defined}
  51. {$endif GDB}
  52. { but I386 or M68K must be defined }
  53. { and only one of the two }
  54. {$ifndef I386}
  55. {$ifndef M68K}
  56. {$fatal One of the switches I386 or M68K must be defined}
  57. {$endif M68K}
  58. {$endif I386}
  59. {$ifdef I386}
  60. {$ifdef M68K}
  61. {$fatal ONLY one of the switches I386 or M68K must be defined}
  62. {$endif M68K}
  63. {$endif I386}
  64. {$ifdef support_mmx}
  65. {$ifndef i386}
  66. {$fatal I386 switch must be on for MMX support}
  67. {$endif i386}
  68. {$endif support_mmx}
  69. {$endif}
  70. {$ifdef TP}
  71. {$IFNDEF DPMI}
  72. {$M 24000,0,655360}
  73. {$ELSE}
  74. {$M 65000}
  75. {$ENDIF DPMI}
  76. {$E+,N+,F+,S-,R-}
  77. {$endif TP}
  78. program pp;
  79. {$IFDEF TP}
  80. {$UNDEF PROFILE}
  81. {$IFDEF DPMI}
  82. {$UNDEF USEOVERLAY}
  83. {$ENDIF}
  84. {$DEFINE NOAG386BIN}
  85. {$ENDIF}
  86. {$ifdef FPC}
  87. {$UNDEF USEOVERLAY}
  88. {$ENDIF}
  89. uses
  90. {$ifdef useoverlay}
  91. {$ifopt o+}
  92. Overlay,ppovin,
  93. {$else}
  94. {$error You must compile with the $O+ switch}
  95. {$endif}
  96. {$endif useoverlay}
  97. {$ifdef profile}
  98. profile,
  99. {$endif profile}
  100. {$ifdef FPC}
  101. {$ifdef heaptrc}
  102. ppheap,
  103. {$endif heaptrc}
  104. {$ifdef linux}
  105. catch,
  106. {$endif}
  107. {$ifdef go32v2}
  108. {$ifdef DEBUG}
  109. {$define NOCATCH}
  110. {$endif DEBUG}
  111. catch,
  112. {$ifdef nocatch}
  113. lineinfo,
  114. {$endif nocatch}
  115. {$endif}
  116. {$endif FPC}
  117. globals,compiler
  118. {$ifdef logmemblocks}
  119. {$ifdef fpc}
  120. ,memlog
  121. {$endif fpc}
  122. {$endif logmemblocks}
  123. ;
  124. {$ifdef useoverlay}
  125. {$O files}
  126. {$O globals}
  127. {$O hcodegen}
  128. {$O pass_1}
  129. {$O pass_2}
  130. {$O tree}
  131. {$O types}
  132. {$O objects}
  133. {$O options}
  134. {$O cobjects}
  135. {$O globals}
  136. {$O systems}
  137. {$O parser}
  138. {$O pbase}
  139. {$O pdecl}
  140. {$O pexports}
  141. {$O pexpr}
  142. {$O pmodules}
  143. {$O pstatmnt}
  144. {$O psub}
  145. {$O psystem}
  146. {$O ptconst}
  147. {$O script}
  148. {$O switches}
  149. {$O temp_gen}
  150. {$O comphook}
  151. {$O dos}
  152. {$O scanner}
  153. {$O symtable}
  154. {$O objects}
  155. {$O aasm}
  156. {$O link}
  157. {$O assemble}
  158. {$O messages}
  159. {$O gendef}
  160. {$O import}
  161. {$ifdef gdb}
  162. {$O gdb}
  163. {$endif gdb}
  164. {$ifdef i386}
  165. {$O cpubase}
  166. {$O cgai386}
  167. {$O tgeni386}
  168. {$O cg386add}
  169. {$O cg386cal}
  170. {$O cg386cnv}
  171. {$O cg386con}
  172. {$O cg386flw}
  173. {$O cg386ld}
  174. {$O cg386inl}
  175. {$O cg386mat}
  176. {$O cg386set}
  177. {$ifndef NOOPT}
  178. {$O aopt386}
  179. {$O opts386}
  180. {$endif}
  181. {$IfNDef Nora386dir}
  182. {$O ra386dir}
  183. {$endif}
  184. {$IfNDef Nora386int}
  185. {$O ra386int}
  186. {$endif}
  187. {$IfNDef Nora386att}
  188. {$O ra386att}
  189. {$endif}
  190. {$ifndef NoAg386Int}
  191. {$O ag386int}
  192. {$endif}
  193. {$ifndef NoAg386Att}
  194. {$O ag386att}
  195. {$endif}
  196. {$ifndef NoAg386Nsm}
  197. {$O ag386nsm}
  198. {$endif}
  199. {$endif}
  200. {$ifdef m68k}
  201. {$O opts68k}
  202. {$O cpubase}
  203. {$O cga68k}
  204. {$O tgen68k}
  205. {$O cg68kadd}
  206. {$O cg68kcal}
  207. {$O cg68kcnv}
  208. {$O cg68kcon}
  209. {$O cg68kflw}
  210. {$O cg68kld}
  211. {$O cg68kinl}
  212. {$O cg68kmat}
  213. {$O cg68kset}
  214. {$IfNDef Nora68kMot}
  215. {$O ra68kmot}
  216. {$endif}
  217. {$IfNDef Noag68kGas}
  218. {$O ag68kgas}
  219. {$endif}
  220. {$IfNDef Noag68kMot}
  221. {$O ag68kmot}
  222. {$endif}
  223. {$IfNDef Noag68kMit}
  224. {$O ag68kmit}
  225. {$endif}
  226. {$endif}
  227. {$endif useoverlay}
  228. var
  229. oldexit : pointer;
  230. procedure myexit;{$ifndef FPC}far;{$endif}
  231. begin
  232. exitproc:=oldexit;
  233. { Show Runtime error if there was an error }
  234. if (erroraddr<>nil) then
  235. begin
  236. case exitcode of
  237. 202 : begin
  238. erroraddr:=nil;
  239. Writeln('Error: Stack Overflow');
  240. end;
  241. 203 : begin
  242. erroraddr:=nil;
  243. Writeln('Error: Out of memory');
  244. end;
  245. end;
  246. { we cannot use aktfilepos.file because all memory might have been
  247. freed already !
  248. But we can use global parser_current_file var }
  249. Writeln('Compilation aborted ',parser_current_file,':',aktfilepos.line);
  250. end;
  251. end;
  252. begin
  253. oldexit:=exitproc;
  254. exitproc:=@myexit;
  255. {$ifdef UseOverlay}
  256. InitOverlay;
  257. {$endif}
  258. { Call the compiler with empty command, so it will take the parameters }
  259. Halt(compiler.Compile(''));
  260. end.
  261. {
  262. $Log$
  263. Revision 1.56 2000-02-18 12:34:43 pierre
  264. DEBUG implies NOCATCH for go32v2
  265. Revision 1.55 2000/02/10 23:44:43 florian
  266. * big update for exception handling code generation: possible mem holes
  267. fixed, break/continue/exit should work always now as expected
  268. Revision 1.54 2000/02/09 13:22:59 peter
  269. * log truncated
  270. Revision 1.53 2000/01/07 01:14:30 peter
  271. * updated copyright to 2000
  272. Revision 1.52 1999/11/06 14:34:23 peter
  273. * truncated log to 20 revs
  274. Revision 1.51 1999/11/05 13:15:00 florian
  275. * some fixes to get the new cg compiling again
  276. Revision 1.50 1999/09/17 17:14:10 peter
  277. * @procvar fixes for tp mode
  278. * @<id>:= gives now an error
  279. Revision 1.49 1999/09/16 23:05:54 florian
  280. * m68k compiler is again compilable (only gas writer, no assembler reader)
  281. Revision 1.48 1999/09/10 18:48:08 florian
  282. * some bug fixes (e.g. must_be_valid and procinfo.funcret_is_valid)
  283. * most things for stored properties fixed
  284. Revision 1.47 1999/09/02 18:47:45 daniel
  285. * Could not compile with TP, some arrays moved to heap
  286. * NOAG386BIN default for TP
  287. * AG386* files were not compatible with TP, fixed.
  288. Revision 1.46 1999/08/28 15:34:20 florian
  289. * bug 519 fixed
  290. Revision 1.45 1999/08/04 00:23:18 florian
  291. * renamed i386asm and i386base to cpuasm and cpubase
  292. }