pp.pas 8.5 KB

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