pp.pas 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 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. -----------------------------------------------------------------
  36. Required switches for a i386 compiler be compiled by Free Pascal Compiler:
  37. GDB;I386
  38. Required switches for a i386 compiler be compiled by Turbo Pascal:
  39. GDB;I386;TP
  40. Required switches for a 68000 compiler be compiled by Turbo Pascal:
  41. GDB;M68k;TP
  42. }
  43. {$ifdef FPC}
  44. {$ifndef GDB}
  45. { people can try to compile without GDB }
  46. { $error The compiler switch GDB must be defined}
  47. {$endif GDB}
  48. { but I386 or M68K must be defined }
  49. { and only one of the two }
  50. {$ifndef I386}
  51. {$ifndef M68K}
  52. {$fatal One of the switches I386 or M68K must be defined}
  53. {$endif M68K}
  54. {$endif I386}
  55. {$ifdef I386}
  56. {$ifdef M68K}
  57. {$fatal ONLY one of the switches I386 or M68K must be defined}
  58. {$endif M68K}
  59. {$endif I386}
  60. {$ifdef support_mmx}
  61. {$ifndef i386}
  62. {$fatal I386 switch must be on for MMX support}
  63. {$endif i386}
  64. {$endif support_mmx}
  65. {$endif}
  66. {$ifdef TP}
  67. {$IFNDEF DPMI}
  68. {$M 24000,0,655360}
  69. {$ELSE}
  70. {$M 65000}
  71. {$ENDIF DPMI}
  72. {$E+,N+,F+,S-,R-}
  73. {$endif TP}
  74. program pp;
  75. {$IFDEF TP}
  76. {$UNDEF PROFILE}
  77. {$IFDEF DPMI}
  78. {$UNDEF USEOVERLAY}
  79. {$ENDIF}
  80. {$ENDIF}
  81. {$ifdef FPC}
  82. {$UNDEF USEOVERLAY}
  83. {$ENDIF}
  84. uses
  85. {$ifdef useoverlay}
  86. {$ifopt o+}
  87. Overlay,ppovin,
  88. {$else}
  89. {$error You must compile with the $O+ switch}
  90. {$endif}
  91. {$endif useoverlay}
  92. {$ifdef profile}
  93. profile,
  94. {$endif profile}
  95. {$ifdef FPC}
  96. {$ifdef heaptrc}
  97. ppheap,
  98. {$endif heaptrc}
  99. {$endif FPC}
  100. globals,compiler;
  101. {$ifdef useoverlay}
  102. {$O files}
  103. {$O globals}
  104. {$O hcodegen}
  105. {$O pass_1}
  106. {$O pass_2}
  107. {$O tree}
  108. {$O types}
  109. {$O objects}
  110. {$O options}
  111. {$O cobjects}
  112. {$O globals}
  113. {$O systems}
  114. {$O parser}
  115. {$O pbase}
  116. {$O pdecl}
  117. {$O pexports}
  118. {$O pexpr}
  119. {$O pmodules}
  120. {$O pstatmnt}
  121. {$O psub}
  122. {$O psystem}
  123. {$O ptconst}
  124. {$O script}
  125. {$O switches}
  126. {$O temp_gen}
  127. {$O comphook}
  128. {$O dos}
  129. {$O scanner}
  130. {$O symtable}
  131. {$O objects}
  132. {$O aasm}
  133. {$O link}
  134. {$O assemble}
  135. {$O messages}
  136. {$O gendef}
  137. {$O import}
  138. {$ifdef i386}
  139. {$O os2_targ}
  140. {$O win_targ}
  141. {$endif i386}
  142. {$O asmutils}
  143. {$ifdef gdb}
  144. {$O gdb}
  145. {$endif gdb}
  146. {$ifdef i386}
  147. {$O opts386}
  148. {$O i386}
  149. {$O cgai386}
  150. {$O tgeni386}
  151. {$O cg386add}
  152. {$O cg386cal}
  153. {$O cg386cnv}
  154. {$O cg386con}
  155. {$O cg386flw}
  156. {$O cg386ld}
  157. {$O cg386inl}
  158. {$O cg386mat}
  159. {$O cg386set}
  160. {$ifndef NOOPT}
  161. {$O aopt386}
  162. {$endif}
  163. {$IfNDef Nora386dir}
  164. {$O ra386dir}
  165. {$endif}
  166. {$IfNDef Nora386int}
  167. {$O ra386int}
  168. {$endif}
  169. {$IfNDef Nora386att}
  170. {$O ra386att}
  171. {$endif}
  172. {$ifndef NoAg386Int}
  173. {$O ag386int}
  174. {$endif}
  175. {$ifndef NoAg386Att}
  176. {$O ag386att}
  177. {$endif}
  178. {$ifndef NoAg386Nsm}
  179. {$O ag386nsm}
  180. {$endif}
  181. {$endif}
  182. {$ifdef m68k}
  183. {$O opts68k}
  184. {$O m68k}
  185. {$O cga68k}
  186. {$O tgen68k}
  187. {$O cg68kadd}
  188. {$O cg68kcal}
  189. {$O cg68kcnv}
  190. {$O cg68kcon}
  191. {$O cg68kflw}
  192. {$O cg68kld}
  193. {$O cg68kinl}
  194. {$O cg68kmat}
  195. {$O cg68kset}
  196. {$IfNDef Nora68kMot}
  197. {$O ra68kmot}
  198. {$endif}
  199. {$IfNDef Noag68kGas}
  200. {$O ag68kgas}
  201. {$endif}
  202. {$IfNDef Noag68kMot}
  203. {$O ag68kmot}
  204. {$endif}
  205. {$IfNDef Noag68kMit}
  206. {$O ag68kmit}
  207. {$endif}
  208. {$endif}
  209. {$endif useoverlay}
  210. var
  211. oldexit : pointer;
  212. procedure myexit;{$ifndef FPC}far;{$endif}
  213. begin
  214. exitproc:=oldexit;
  215. { Show Runtime error if there was an error }
  216. if (erroraddr<>nil) then
  217. begin
  218. case exitcode of
  219. 202 : begin
  220. erroraddr:=nil;
  221. Writeln('Error: Stack Overflow');
  222. end;
  223. 203 : begin
  224. erroraddr:=nil;
  225. Writeln('Error: Out of memory');
  226. end;
  227. end;
  228. Writeln('Compilation aborted at line ',aktfilepos.line);
  229. end;
  230. end;
  231. begin
  232. oldexit:=exitproc;
  233. exitproc:=@myexit;
  234. {$ifndef TP}
  235. {$ifndef UseAnsiString}
  236. heapblocks:=true;
  237. {$endif not UseAnsiString}
  238. {$endif}
  239. {$ifdef UseOverlay}
  240. InitOverlay;
  241. {$endif}
  242. { Call the compiler with empty command, so it will take the parameters }
  243. Halt(Compile(''));
  244. end.
  245. {
  246. $Log$
  247. Revision 1.34 1998-10-14 11:28:24 florian
  248. * emitpushreferenceaddress gets now the asmlist as parameter
  249. * m68k version compiles with -duseansistrings
  250. Revision 1.33 1998/10/08 17:17:26 pierre
  251. * current_module old scanner tagged as invalid if unit is recompiled
  252. + added ppheap for better info on tracegetmem of heaptrc
  253. (adds line column and file index)
  254. * several memory leaks removed ith help of heaptrc !!
  255. Revision 1.32 1998/10/02 17:03:51 peter
  256. * ifdef heaptrc for heaptrc
  257. Revision 1.31 1998/09/28 16:57:23 pierre
  258. * changed all length(p^.value_str^) into str_length(p)
  259. to get it work with and without ansistrings
  260. * changed sourcefiles field of tmodule to a pointer
  261. Revision 1.30 1998/09/24 23:49:13 peter
  262. + aktmodeswitches
  263. Revision 1.29 1998/09/17 09:42:41 peter
  264. + pass_2 for cg386
  265. * Message() -> CGMessage() for pass_1/pass_2
  266. Revision 1.28 1998/08/26 15:31:17 peter
  267. * heapblocks for >0.99.5
  268. Revision 1.27 1998/08/11 00:00:00 peter
  269. * fixed dup log
  270. Revision 1.26 1998/08/10 15:49:40 peter
  271. * small fixes for 0.99.5
  272. Revision 1.25 1998/08/10 14:50:16 peter
  273. + localswitches, moduleswitches, globalswitches splitting
  274. Revision 1.24 1998/08/10 10:18:32 peter
  275. + Compiler,Comphook unit which are the new interface units to the
  276. compiler
  277. Revision 1.23 1998/08/05 16:00:16 florian
  278. * some fixes for ansi strings
  279. Revision 1.22 1998/08/04 16:28:40 jonas
  280. * added support for NoRa386* in the $O ... section
  281. Revision 1.21 1998/07/18 17:11:12 florian
  282. + ansi string constants fixed
  283. + switch $H partial implemented
  284. Revision 1.20 1998/07/14 14:46:55 peter
  285. * released NEWINPUT
  286. Revision 1.19 1998/07/07 11:20:04 peter
  287. + NEWINPUT for a better inputfile and scanner object
  288. Revision 1.18 1998/06/24 14:06:33 peter
  289. * fixed the name changes
  290. Revision 1.17 1998/06/23 08:59:22 daniel
  291. * Recommitted.
  292. Revision 1.16 1998/06/17 14:10:17 peter
  293. * small os2 fixes
  294. * fixed interdependent units with newppu (remake3 under linux works now)
  295. Revision 1.15 1998/06/16 11:32:18 peter
  296. * small cosmetic fixes
  297. Revision 1.14 1998/06/15 13:43:45 daniel
  298. * Updated overlays.
  299. Revision 1.12 1998/05/23 01:21:23 peter
  300. + aktasmmode, aktoptprocessor, aktoutputformat
  301. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  302. + $LIBNAME to set the library name where the unit will be put in
  303. * splitted cgi386 a bit (codeseg to large for bp7)
  304. * nasm, tasm works again. nasm moved to ag386nsm.pas
  305. Revision 1.11 1998/05/20 09:42:35 pierre
  306. + UseTokenInfo now default
  307. * unit in interface uses and implementation uses gives error now
  308. * only one error for unknown symbol (uses lastsymknown boolean)
  309. the problem came from the label code !
  310. + first inlined procedures and function work
  311. (warning there might be allowed cases were the result is still wrong !!)
  312. * UseBrower updated gives a global list of all position of all used symbols
  313. with switch -gb
  314. Revision 1.10 1998/05/12 10:47:00 peter
  315. * moved printstatus to verb_def
  316. + V_Normal which is between V_Error and V_Warning and doesn't have a
  317. prefix like error: warning: and is included in V_Default
  318. * fixed some messages
  319. * first time parameter scan is only for -v and -T
  320. - removed old style messages
  321. Revision 1.9 1998/05/11 13:07:56 peter
  322. + $ifdef NEWPPU for the new ppuformat
  323. + $define GDB not longer required
  324. * removed all warnings and stripped some log comments
  325. * no findfirst/findnext anymore to remove smartlink *.o files
  326. Revision 1.8 1998/05/08 09:21:57 michael
  327. + Librarysearchpath is now a linker object field;
  328. Revision 1.7 1998/05/04 17:54:28 peter
  329. + smartlinking works (only case jumptable left todo)
  330. * redesign of systems.pas to support assemblers and linkers
  331. + Unitname is now also in the PPU-file, increased version to 14
  332. Revision 1.6 1998/04/29 13:40:23 peter
  333. + heapblocks:=true
  334. Revision 1.5 1998/04/29 10:33:59 pierre
  335. + added some code for ansistring (not complete nor working yet)
  336. * corrected operator overloading
  337. * corrected nasm output
  338. + started inline procedures
  339. + added starstarn : use ** for exponentiation (^ gave problems)
  340. + started UseTokenInfo cond to get accurate positions
  341. Revision 1.3 1998/04/21 10:16:48 peter
  342. * patches from strasbourg
  343. * objects is not used anymore in the fpc compiled version
  344. Revision 1.2 1998/04/07 13:19:47 pierre
  345. * bugfixes for reset_gdb_info
  346. in MEM parsing for go32v2
  347. better external symbol creation
  348. support for rhgdb.exe (lowercase file names)
  349. }