pmodules.pas 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Handles the parsing and loading of the modules (ppufiles)
  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. unit pmodules;
  19. {$i fpcdefs.inc}
  20. interface
  21. procedure proc_unit;
  22. procedure proc_program(islibrary : boolean);
  23. implementation
  24. uses
  25. globtype,version,systems,tokens,
  26. cutils,cclasses,comphook,
  27. globals,verbose,fmodule,finput,fppu,
  28. symconst,symbase,symtype,symdef,symsym,symtable,
  29. aasmtai,aasmcpu,aasmbase,
  30. cgbase,cpuinfo,cgobj,
  31. nbas,
  32. link,assemble,import,export,gendef,ppu,comprsrc,
  33. cresstr,procinfo,
  34. {$ifdef GDB}
  35. gdb,
  36. {$endif GDB}
  37. scanner,pbase,pexpr,psystem,psub;
  38. procedure fixseg(p:TAAsmoutput;sec:TSection);
  39. begin
  40. p.insert(Tai_section.Create(sec));
  41. if (cs_create_smart in aktmoduleswitches) then
  42. p.insert(Tai_cut.Create);
  43. p.concat(Tai_section.Create(sec_none));
  44. end;
  45. procedure create_objectfile;
  46. var
  47. DLLScanner : TDLLScanner;
  48. s : string;
  49. KeepShared : TStringList;
  50. begin
  51. { try to create import entries from system dlls }
  52. if target_info.DllScanSupported and
  53. (not current_module.linkOtherSharedLibs.Empty) then
  54. begin
  55. { Init DLLScanner }
  56. if assigned(CDLLScanner[target_info.system]) then
  57. DLLScanner:=CDLLScanner[target_info.system].Create
  58. else
  59. internalerror(200104121);
  60. KeepShared:=TStringList.Create;
  61. { Walk all shared libs }
  62. While not current_module.linkOtherSharedLibs.Empty do
  63. begin
  64. S:=current_module.linkOtherSharedLibs.Getusemask(link_allways);
  65. if not DLLScanner.scan(s) then
  66. KeepShared.Concat(s);
  67. end;
  68. DLLscanner.Free;
  69. { Recreate import section }
  70. if (target_info.system in [system_i386_win32,system_i386_wdosx]) then
  71. begin
  72. if assigned(importssection)then
  73. importssection.clear
  74. else
  75. importssection:=taasmoutput.Create;
  76. importlib.generatelib;
  77. end;
  78. { Readd the not processed files }
  79. while not KeepShared.Empty do
  80. begin
  81. s:=KeepShared.GetFirst;
  82. current_module.linkOtherSharedLibs.add(s,link_allways);
  83. end;
  84. KeepShared.Free;
  85. end;
  86. { create the .s file and assemble it }
  87. GenerateAsm(false);
  88. { Also create a smartlinked version ? }
  89. if (cs_create_smart in aktmoduleswitches) then
  90. begin
  91. { regenerate the importssection for win32 }
  92. if assigned(importssection) and
  93. (target_info.system in [system_i386_win32,system_i386_wdosx]) then
  94. begin
  95. importsSection.clear;
  96. importlib.generatesmartlib;
  97. end;
  98. GenerateAsm(true);
  99. if target_asm.needar then
  100. Linker.MakeStaticLibrary;
  101. end;
  102. { resource files }
  103. CompileResourceFiles;
  104. end;
  105. procedure insertobjectfile;
  106. { Insert the used object file for this unit in the used list for this unit }
  107. begin
  108. current_module.linkunitofiles.add(current_module.objfilename^,link_static);
  109. current_module.flags:=current_module.flags or uf_static_linked;
  110. if (cs_create_smart in aktmoduleswitches) then
  111. begin
  112. current_module.linkunitstaticlibs.add(current_module.staticlibfilename^,link_smart);
  113. current_module.flags:=current_module.flags or uf_smart_linked;
  114. end;
  115. end;
  116. procedure insertsegment;
  117. var
  118. oldaktfilepos : tfileposinfo;
  119. begin
  120. { Insert Ident of the compiler }
  121. if (not (cs_create_smart in aktmoduleswitches))
  122. {$ifndef EXTDEBUG}
  123. and (not current_module.is_unit)
  124. {$endif}
  125. then
  126. begin
  127. { align the first data }
  128. dataSegment.insert(Tai_align.Create(const_align(32)));
  129. dataSegment.insert(Tai_string.Create('FPC '+full_version_string+
  130. ' ['+date_string+'] for '+target_cpu_string+' - '+target_info.shortname));
  131. end;
  132. { align code segment }
  133. codeSegment.concat(Tai_align.Create(aktalignment.procalign));
  134. { Insert start and end of sections }
  135. fixseg(codesegment,sec_code);
  136. fixseg(datasegment,sec_data);
  137. fixseg(bsssegment,sec_bss);
  138. { we should use .rdata section for these two no ?
  139. .rdata is a read only data section (PM) }
  140. fixseg(rttilist,sec_data);
  141. fixseg(consts,sec_data);
  142. fixseg(picdata,sec_data);
  143. if assigned(resourcestringlist) then
  144. fixseg(resourcestringlist,sec_data);
  145. {$ifdef GDB}
  146. if assigned(debuglist) then
  147. begin
  148. oldaktfilepos:=aktfilepos;
  149. aktfilepos.line:=0;
  150. debugList.insert(Tai_symbol.Createname('gcc2_compiled',AT_DATA,0));
  151. debugList.insert(Tai_symbol.Createname('fpc_compiled',AT_DATA,0));
  152. fixseg(debuglist,sec_code);
  153. aktfilepos:=oldaktfilepos;
  154. end;
  155. {$endif GDB}
  156. end;
  157. procedure InsertThreadvarTablesTable;
  158. var
  159. hp : tused_unit;
  160. ltvTables : taasmoutput;
  161. count : longint;
  162. begin
  163. ltvTables:=TAAsmOutput.Create;
  164. count:=0;
  165. hp:=tused_unit(usedunits.first);
  166. while assigned(hp) do
  167. begin
  168. If (hp.u.flags and uf_threadvars)=uf_threadvars then
  169. begin
  170. ltvTables.concat(Tai_const_symbol.Createname(make_mangledname('THREADVARLIST',hp.u.globalsymtable,''),AT_DATA,0));
  171. inc(count);
  172. end;
  173. hp:=tused_unit(hp.next);
  174. end;
  175. { Add program threadvars, if any }
  176. If (current_module.flags and uf_threadvars)=uf_threadvars then
  177. begin
  178. ltvTables.concat(Tai_const_symbol.Createname(make_mangledname('THREADVARLIST',current_module.localsymtable,''),AT_DATA,0));
  179. inc(count);
  180. end;
  181. { TableCount }
  182. ltvTables.insert(Tai_const.Create_32bit(count));
  183. ltvTables.insert(Tai_symbol.Createname_global('FPC_THREADVARTABLES',AT_DATA,0));
  184. ltvTables.insert(Tai_align.Create(const_align(pointer_size)));
  185. ltvTables.concat(Tai_symbol_end.Createname('FPC_THREADVARTABLES'));
  186. { insert in data segment }
  187. if (cs_create_smart in aktmoduleswitches) then
  188. dataSegment.concat(Tai_cut.Create);
  189. dataSegment.concatlist(ltvTables);
  190. ltvTables.free;
  191. end;
  192. procedure AddToThreadvarList(p:tnamedindexitem;arg:pointer);
  193. var
  194. ltvTable : taasmoutput;
  195. begin
  196. ltvTable:=taasmoutput(arg);
  197. if (tsym(p).typ=varsym) and
  198. (vo_is_thread_var in tvarsym(p).varoptions) then
  199. begin
  200. { address of threadvar }
  201. ltvTable.concat(tai_const_symbol.Createname(tvarsym(p).mangledname,AT_DATA,0));
  202. { size of threadvar }
  203. ltvTable.concat(tai_const.create_32bit(tvarsym(p).getsize));
  204. end;
  205. end;
  206. procedure InsertThreadvars;
  207. var
  208. s : string;
  209. ltvTable : TAAsmoutput;
  210. begin
  211. ltvTable:=TAAsmoutput.create;
  212. if assigned(current_module.globalsymtable) then
  213. current_module.globalsymtable.foreach_static({$ifdef FPCPROCVAR}@{$endif}AddToThreadvarList,ltvTable);
  214. current_module.localsymtable.foreach_static({$ifdef FPCPROCVAR}@{$endif}AddToThreadvarList,ltvTable);
  215. if ltvTable.first<>nil then
  216. begin
  217. s:=make_mangledname('THREADVARLIST',current_module.localsymtable,'');
  218. { add begin and end of the list }
  219. ltvTable.insert(tai_symbol.Createname_global(s,AT_DATA,0));
  220. ltvTable.concat(tai_const.create_ptr(0)); { end of list marker }
  221. ltvTable.concat(tai_symbol_end.createname(s));
  222. if (cs_create_smart in aktmoduleswitches) then
  223. dataSegment.concat(Tai_cut.Create);
  224. dataSegment.concatlist(ltvTable);
  225. current_module.flags:=current_module.flags or uf_threadvars;
  226. end;
  227. ltvTable.Free;
  228. end;
  229. Procedure InsertResourceTablesTable;
  230. var
  231. hp : tused_unit;
  232. ResourceStringTables : taasmoutput;
  233. count : longint;
  234. begin
  235. ResourceStringTables:=TAAsmOutput.Create;
  236. count:=0;
  237. hp:=tused_unit(usedunits.first);
  238. while assigned(hp) do
  239. begin
  240. If (hp.u.flags and uf_has_resources)=uf_has_resources then
  241. begin
  242. ResourceStringTables.concat(Tai_const_symbol.Createname(make_mangledname('RESOURCESTRINGLIST',hp.u.globalsymtable,''),AT_DATA,0));
  243. inc(count);
  244. end;
  245. hp:=tused_unit(hp.next);
  246. end;
  247. { Add program resources, if any }
  248. If ResourceStringList<>Nil then
  249. begin
  250. ResourceStringTables.concat(Tai_const_symbol.Createname(make_mangledname('RESOURCESTRINGLIST',current_module.localsymtable,''),AT_DATA,0));
  251. Inc(Count);
  252. end;
  253. { TableCount }
  254. ResourceStringTables.insert(Tai_const.Create_32bit(count));
  255. ResourceStringTables.insert(Tai_symbol.Createname_global('FPC_RESOURCESTRINGTABLES',AT_DATA,0));
  256. ResourceStringTables.insert(Tai_align.Create(const_align(4)));
  257. ResourceStringTables.concat(Tai_symbol_end.Createname('FPC_RESOURCESTRINGTABLES'));
  258. { insert in data segment }
  259. if (cs_create_smart in aktmoduleswitches) then
  260. dataSegment.concat(Tai_cut.Create);
  261. dataSegment.concatlist(ResourceStringTables);
  262. ResourceStringTables.free;
  263. end;
  264. procedure InsertInitFinalTable;
  265. var
  266. hp : tused_unit;
  267. unitinits : taasmoutput;
  268. count : longint;
  269. begin
  270. unitinits:=TAAsmOutput.Create;
  271. count:=0;
  272. hp:=tused_unit(usedunits.first);
  273. while assigned(hp) do
  274. begin
  275. { call the unit init code and make it external }
  276. if (hp.u.flags and (uf_init or uf_finalize))<>0 then
  277. begin
  278. if (hp.u.flags and uf_init)<>0 then
  279. unitinits.concat(Tai_const_symbol.Createname(make_mangledname('INIT$',hp.u.globalsymtable,''),AT_FUNCTION,0))
  280. else
  281. unitinits.concat(Tai_const.Create_ptr(0));
  282. if (hp.u.flags and uf_finalize)<>0 then
  283. unitinits.concat(Tai_const_symbol.Createname(make_mangledname('FINALIZE$',hp.u.globalsymtable,''),AT_FUNCTION,0))
  284. else
  285. unitinits.concat(Tai_const.Create_ptr(0));
  286. inc(count);
  287. end;
  288. hp:=tused_unit(hp.next);
  289. end;
  290. { Insert initialization/finalization of the program }
  291. if (current_module.flags and (uf_init or uf_finalize))<>0 then
  292. begin
  293. if (current_module.flags and uf_init)<>0 then
  294. unitinits.concat(Tai_const_symbol.Createname(make_mangledname('INIT$',current_module.localsymtable,''),AT_FUNCTION,0))
  295. else
  296. unitinits.concat(Tai_const.Create_ptr(0));
  297. if (current_module.flags and uf_finalize)<>0 then
  298. unitinits.concat(Tai_const_symbol.Createname(make_mangledname('FINALIZE$',current_module.localsymtable,''),AT_FUNCTION,0))
  299. else
  300. unitinits.concat(Tai_const.Create_ptr(0));
  301. inc(count);
  302. end;
  303. { TableCount,InitCount }
  304. unitinits.insert(Tai_const.Create_32bit(0));
  305. unitinits.insert(Tai_const.Create_32bit(count));
  306. unitinits.insert(Tai_symbol.Createname_global('INITFINAL',AT_DATA,0));
  307. unitinits.insert(Tai_align.Create(const_align(4)));
  308. unitinits.concat(Tai_symbol_end.Createname('INITFINAL'));
  309. { insert in data segment }
  310. if (cs_create_smart in aktmoduleswitches) then
  311. dataSegment.concat(Tai_cut.Create);
  312. dataSegment.concatlist(unitinits);
  313. unitinits.free;
  314. end;
  315. procedure insertheap;
  316. begin
  317. if (cs_create_smart in aktmoduleswitches) then
  318. begin
  319. bssSegment.concat(Tai_cut.Create);
  320. dataSegment.concat(Tai_cut.Create);
  321. end;
  322. { On the Macintosh Classic M68k Architecture
  323. The Heap variable is simply a POINTER to the
  324. real HEAP. The HEAP must be set up by the RTL
  325. and must store the pointer in this value.
  326. On OS/2 the heap is also intialized by the RTL. We do
  327. not output a pointer }
  328. case target_info.system of
  329. system_i386_OS2:
  330. bssSegment.concat(Tai_datablock.Create_global('HEAP',4));
  331. system_i386_EMX:
  332. ;
  333. system_powerpc_macos:
  334. ;
  335. system_i386_watcom:
  336. ;
  337. system_alpha_linux:
  338. ;
  339. system_m68k_Mac:
  340. bssSegment.concat(Tai_datablock.Create_global('HEAP',4));
  341. system_m68k_PalmOS:
  342. ;
  343. else
  344. begin
  345. bssSegment.concat(Tai_align.Create(var_align(heapsize)));
  346. bssSegment.concat(Tai_datablock.Create_global('HEAP',heapsize));
  347. end;
  348. end;
  349. {$ifdef m68k}
  350. if target_info.system<>system_m68k_PalmOS then
  351. begin
  352. dataSegment.concat(Tai_align.Create(const_align(4)));
  353. dataSegment.concat(Tai_symbol.Createname_global('HEAPSIZE',AT_DATA,4));
  354. dataSegment.concat(Tai_const.Create_32bit(heapsize));
  355. end;
  356. {$else m68k}
  357. dataSegment.concat(Tai_align.Create(const_align(4)));
  358. dataSegment.concat(Tai_symbol.Createname_global('HEAPSIZE',AT_DATA,4));
  359. dataSegment.concat(Tai_const.Create_32bit(heapsize));
  360. {$endif m68k}
  361. end;
  362. procedure insertstacklength;
  363. begin
  364. { stacksize can be specified and is now simulated }
  365. dataSegment.concat(Tai_align.Create(const_align(4)));
  366. dataSegment.concat(Tai_symbol.Createname_global('__stklen',AT_DATA,4));
  367. dataSegment.concat(Tai_const.Create_32bit(stacksize));
  368. end;
  369. procedure loaddefaultunits;
  370. procedure AddUnit(const s:string);
  371. var
  372. hp : tppumodule;
  373. unitsym : tunitsym;
  374. begin
  375. { load unit }
  376. hp:=registerunit(current_module,s,'');
  377. hp.loadppu;
  378. hp.adddependency(current_module);
  379. { add to symtable stack }
  380. tsymtable(hp.globalsymtable).next:=symtablestack;
  381. symtablestack:=hp.globalsymtable;
  382. { insert unitsym }
  383. unitsym:=tunitsym.create(s,hp.globalsymtable);
  384. inc(unitsym.refs);
  385. refsymtable.insert(unitsym);
  386. { add to used units }
  387. current_module.addusedunit(hp,false,unitsym);
  388. end;
  389. begin
  390. { are we compiling the system unit? }
  391. if (cs_compilesystem in aktmoduleswitches) then
  392. begin
  393. { create system defines }
  394. createconstdefs;
  395. { we don't need to reset anything, it's already done in parser.pas }
  396. exit;
  397. end;
  398. { insert the system unit, it is allways the first }
  399. Symtablestack:=nil;
  400. AddUnit('System');
  401. SystemUnit:=TGlobalSymtable(Symtablestack);
  402. { read default constant definitions }
  403. make_ref:=false;
  404. readconstdefs;
  405. make_ref:=true;
  406. {$ifdef cpufpemu}
  407. { Floating point emulation unit? }
  408. if (cs_fp_emulation in aktmoduleswitches) then
  409. AddUnit('SoftFpu');
  410. {$endif cpufpemu}
  411. { Thread support unit? }
  412. if (cs_threading in aktmoduleswitches) then
  413. AddUnit('SysThrds');
  414. { Objpas unit? }
  415. if m_objpas in aktmodeswitches then
  416. AddUnit('ObjPas');
  417. { Profile unit? Needed for go32v2 only }
  418. if (cs_profile in aktmoduleswitches) and
  419. (target_info.system in [system_i386_go32v2,system_i386_watcom]) then
  420. AddUnit('Profile');
  421. { Units only required for main module }
  422. if not(current_module.is_unit) then
  423. begin
  424. { Heaptrc unit }
  425. if (cs_gdb_heaptrc in aktglobalswitches) then
  426. AddUnit('HeapTrc');
  427. { Lineinfo unit }
  428. if (cs_gdb_lineinfo in aktglobalswitches) then
  429. AddUnit('LineInfo');
  430. { Lineinfo unit }
  431. if (cs_gdb_valgrind in aktglobalswitches) then
  432. AddUnit('CMem');
  433. end;
  434. { save default symtablestack }
  435. defaultsymtablestack:=symtablestack;
  436. end;
  437. procedure loadunits;
  438. var
  439. s,sorg : stringid;
  440. fn : string;
  441. pu : tused_unit;
  442. hp2 : tmodule;
  443. hp3 : tsymtable;
  444. unitsym : tunitsym;
  445. begin
  446. consume(_USES);
  447. {$ifdef DEBUG}
  448. test_symtablestack;
  449. {$endif DEBUG}
  450. repeat
  451. s:=pattern;
  452. sorg:=orgpattern;
  453. consume(_ID);
  454. { support "<unit> in '<file>'" construct, but not for tp7 }
  455. if not(m_tp7 in aktmodeswitches) then
  456. begin
  457. if try_to_consume(_OP_IN) then
  458. fn:=FixFileName(get_stringconst)
  459. else
  460. fn:='';
  461. end;
  462. { Give a warning if objpas is loaded }
  463. if s='OBJPAS' then
  464. Message(parser_w_no_objpas_use_mode);
  465. { Using the unit itself is not possible }
  466. if (s<>current_module.modulename^) then
  467. begin
  468. { check if the unit is already used }
  469. hp2:=nil;
  470. pu:=tused_unit(current_module.used_units.first);
  471. while assigned(pu) do
  472. begin
  473. if (pu.u.modulename^=s) then
  474. begin
  475. hp2:=pu.u;
  476. break;
  477. end;
  478. pu:=tused_unit(pu.next);
  479. end;
  480. if not assigned(hp2) then
  481. hp2:=registerunit(current_module,sorg,fn)
  482. else
  483. Message1(sym_e_duplicate_id,s);
  484. { Create unitsym, we need to use the name as specified, we
  485. can not use the modulename because that can be different
  486. when -Un is used }
  487. unitsym:=tunitsym.create(sorg,nil);
  488. refsymtable.insert(unitsym);
  489. { the current module uses the unit hp2 }
  490. current_module.addusedunit(hp2,true,unitsym);
  491. end
  492. else
  493. Message1(sym_e_duplicate_id,s);
  494. if token=_COMMA then
  495. begin
  496. pattern:='';
  497. consume(_COMMA);
  498. end
  499. else
  500. break;
  501. until false;
  502. consume(_SEMICOLON);
  503. { Load the units }
  504. pu:=tused_unit(current_module.used_units.first);
  505. while assigned(pu) do
  506. begin
  507. { Only load the units that are in the current
  508. (interface/implementation) uses clause }
  509. if pu.in_uses and
  510. (pu.in_interface=current_module.in_interface) then
  511. begin
  512. tppumodule(pu.u).loadppu;
  513. { is our module compiled? then we can stop }
  514. if current_module.state=ms_compiled then
  515. exit;
  516. { add this unit to the dependencies }
  517. pu.u.adddependency(current_module);
  518. { save crc values }
  519. pu.checksum:=pu.u.crc;
  520. pu.interface_checksum:=pu.u.interface_crc;
  521. { connect unitsym to the globalsymtable of the unit }
  522. pu.unitsym.unitsymtable:=pu.u.globalsymtable;
  523. { increase refs of the unitsym when the unit contains
  524. initialization/finalization code so it doesn't trigger
  525. the unit not used hint }
  526. if (pu.u.flags and (uf_init or uf_finalize))<>0 then
  527. inc(pu.unitsym.refs);
  528. end;
  529. pu:=tused_unit(pu.next);
  530. end;
  531. { set the symtable to systemunit so it gets reorderd correctly,
  532. then insert the units in the symtablestack }
  533. pu:=tused_unit(current_module.used_units.first);
  534. symtablestack:=defaultsymtablestack;
  535. while assigned(pu) do
  536. begin
  537. if pu.in_uses then
  538. begin
  539. { Reinsert in symtablestack }
  540. hp3:=symtablestack;
  541. while assigned(hp3) do
  542. begin
  543. { insert units only once ! }
  544. if pu.u.globalsymtable=hp3 then
  545. break;
  546. hp3:=hp3.next;
  547. { unit isn't inserted }
  548. if hp3=nil then
  549. begin
  550. tsymtable(pu.u.globalsymtable).next:=symtablestack;
  551. symtablestack:=tsymtable(pu.u.globalsymtable);
  552. {$ifdef DEBUG}
  553. test_symtablestack;
  554. {$endif DEBUG}
  555. end;
  556. end;
  557. end;
  558. pu:=tused_unit(pu.next);
  559. end;
  560. end;
  561. {$IfDef GDB}
  562. procedure write_gdb_info;
  563. procedure reset_unit_type_info;
  564. var
  565. hp : tmodule;
  566. begin
  567. hp:=tmodule(loaded_units.first);
  568. while assigned(hp) do
  569. begin
  570. hp.is_stab_written:=false;
  571. hp:=tmodule(hp.next);
  572. end;
  573. end;
  574. procedure write_used_unit_type_info(hp:tmodule);
  575. var
  576. pu : tused_unit;
  577. begin
  578. pu:=tused_unit(hp.used_units.first);
  579. while assigned(pu) do
  580. begin
  581. if not pu.u.is_stab_written then
  582. begin
  583. { prevent infinte loop for circular dependencies }
  584. pu.u.is_stab_written:=true;
  585. { write type info from used units, use a depth first
  586. strategy to reduce the recursion in writing all
  587. dependent stabs }
  588. write_used_unit_type_info(pu.u);
  589. if assigned(pu.u.globalsymtable) then
  590. tglobalsymtable(pu.u.globalsymtable).concattypestabto(debuglist);
  591. end;
  592. pu:=tused_unit(pu.next);
  593. end;
  594. end;
  595. var
  596. vardebuglist : taasmoutput;
  597. begin
  598. if not (cs_debuginfo in aktmoduleswitches) then
  599. exit;
  600. { first write all global/local symbols to a temp list. This will flag
  601. all required tdefs. Afterwards this list will be added }
  602. vardebuglist:=taasmoutput.create;
  603. if assigned(current_module.globalsymtable) then
  604. tglobalsymtable(current_module.globalsymtable).concatstabto(vardebuglist);
  605. if assigned(current_module.localsymtable) then
  606. tstaticsymtable(current_module.localsymtable).concatstabto(vardebuglist);
  607. { reset unit type info flag }
  608. reset_unit_type_info;
  609. { write used types from the used units }
  610. write_used_unit_type_info(current_module);
  611. { last write the types from this unit }
  612. if assigned(current_module.globalsymtable) then
  613. tglobalsymtable(current_module.globalsymtable).concattypestabto(debuglist);
  614. if assigned(current_module.localsymtable) then
  615. tstaticsymtable(current_module.localsymtable).concattypestabto(debuglist);
  616. { now all defs have a type in the debuglist, we now can add the vardebuglist since
  617. all references to defs can be solved }
  618. debuglist.concatlist(vardebuglist);
  619. vardebuglist.free;
  620. { include files }
  621. if (cs_gdb_dbx in aktglobalswitches) then
  622. begin
  623. debugList.concat(tai_comment.Create(strpnew('EINCL of global '+
  624. tglobalsymtable(current_module.globalsymtable).name^+' has index '+
  625. tostr(tglobalsymtable(current_module.globalsymtable).unitid))));
  626. debugList.concat(Tai_stabs.Create(strpnew('"'+
  627. tglobalsymtable(current_module.globalsymtable).name^+'",'+
  628. tostr(N_EINCL)+',0,0,0')));
  629. tglobalsymtable(current_module.globalsymtable).dbx_count_ok:={true}false;
  630. dbx_counter:=tglobalsymtable(current_module.globalsymtable).prev_dbx_counter;
  631. do_count_dbx:=false;
  632. end;
  633. end;
  634. {$EndIf GDB}
  635. procedure reset_all_defs;
  636. procedure reset_used_unit_defs(hp:tmodule);
  637. var
  638. pu : tused_unit;
  639. begin
  640. pu:=tused_unit(hp.used_units.first);
  641. while assigned(pu) do
  642. begin
  643. if not pu.u.is_reset then
  644. begin
  645. { prevent infinte loop for circular dependencies }
  646. pu.u.is_reset:=true;
  647. if assigned(pu.u.globalsymtable) then
  648. begin
  649. tglobalsymtable(pu.u.globalsymtable).reset_all_defs;
  650. reset_used_unit_defs(pu.u);
  651. end;
  652. end;
  653. pu:=tused_unit(pu.next);
  654. end;
  655. end;
  656. var
  657. hp2 : tmodule;
  658. begin
  659. hp2:=tmodule(loaded_units.first);
  660. while assigned(hp2) do
  661. begin
  662. hp2.is_reset:=false;
  663. hp2:=tmodule(hp2.next);
  664. end;
  665. reset_used_unit_defs(current_module);
  666. end;
  667. procedure parse_implementation_uses;
  668. begin
  669. if token=_USES then
  670. begin
  671. loadunits;
  672. {$ifdef DEBUG}
  673. test_symtablestack;
  674. {$endif DEBUG}
  675. end;
  676. end;
  677. procedure setupglobalswitches;
  678. begin
  679. { can't have local browser when no global browser }
  680. if (cs_local_browser in aktmoduleswitches) and
  681. not(cs_browser in aktmoduleswitches) then
  682. exclude(aktmoduleswitches,cs_local_browser);
  683. { define a symbol in delphi,objfpc,tp,gpc mode }
  684. if (m_delphi in aktmodeswitches) then
  685. current_scanner.def_macro('FPC_DELPHI')
  686. else
  687. if (m_tp7 in aktmodeswitches) then
  688. current_scanner.def_macro('FPC_TP')
  689. else
  690. if (m_objfpc in aktmodeswitches) then
  691. current_scanner.def_macro('FPC_OBJFPC')
  692. else
  693. if (m_gpc in aktmodeswitches) then
  694. current_scanner.def_macro('FPC_GPC');
  695. end;
  696. function create_main_proc(const name:string;potype:tproctypeoption;st:tsymtable):tprocdef;
  697. var
  698. stt : tsymtable;
  699. ps : tprocsym;
  700. pd : tprocdef;
  701. begin
  702. { there should be no current_procinfo available }
  703. if assigned(current_procinfo) then
  704. internalerror(200304275);
  705. {Generate a procsym for main}
  706. make_ref:=false;
  707. { try to insert in in static symtable ! }
  708. stt:=symtablestack;
  709. symtablestack:=st;
  710. { generate procsym }
  711. ps:=tprocsym.create('$'+name);
  712. { main are allways used }
  713. inc(ps.refs);
  714. symtablestack.insert(ps);
  715. pd:=tprocdef.create(main_program_level);
  716. include(pd.procoptions,po_public);
  717. pd.procsym:=ps;
  718. ps.addprocdef(pd);
  719. { restore symtable }
  720. make_ref:=true;
  721. symtablestack:=stt;
  722. { set procdef options }
  723. pd.proctypeoption:=potype;
  724. pd.proccalloption:=pocall_default;
  725. pd.forwarddef:=false;
  726. pd.setmangledname(target_info.cprefix+name);
  727. pd.aliasnames.insert(pd.mangledname);
  728. { We don't need is a local symtable. Change it into the static
  729. symtable }
  730. pd.localst.free;
  731. pd.localst:=st;
  732. { set procinfo and current_procinfo.procdef }
  733. current_procinfo:=cprocinfo.create(nil);
  734. current_module.procinfo:=current_procinfo;
  735. current_procinfo.procdef:=pd;
  736. { return procdef }
  737. create_main_proc:=pd;
  738. { main proc does always a call e.g. to init system unit }
  739. include(current_procinfo.flags,pi_do_call);
  740. end;
  741. procedure release_main_proc(pd:tprocdef);
  742. begin
  743. { this is a main proc, so there should be no parent }
  744. if not(assigned(current_procinfo)) or
  745. assigned(current_procinfo.parent) or
  746. not(current_procinfo.procdef=pd) then
  747. internalerror(200304276);
  748. { remove procinfo }
  749. current_module.procinfo:=nil;
  750. current_procinfo.free;
  751. current_procinfo:=nil;
  752. { remove localst as it was replaced by staticsymtable }
  753. pd.localst:=nil;
  754. end;
  755. procedure gen_implicit_initfinal(flag:word;st:tsymtable);
  756. var
  757. pd : tprocdef;
  758. begin
  759. { update module flags }
  760. current_module.flags:=current_module.flags or flag;
  761. { create procdef }
  762. case flag of
  763. uf_init :
  764. begin
  765. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'init_implicit'),potype_unitinit,st);
  766. pd.aliasnames.insert(make_mangledname('INIT$',current_module.localsymtable,''));
  767. end;
  768. uf_finalize :
  769. begin
  770. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize_implicit'),potype_unitfinalize,st);
  771. pd.aliasnames.insert(make_mangledname('FINALIZE$',current_module.localsymtable,''));
  772. end;
  773. else
  774. internalerror(200304253);
  775. end;
  776. tcgprocinfo(current_procinfo).code:=cnothingnode.create;
  777. tcgprocinfo(current_procinfo).add_entry_exit_code;
  778. tcgprocinfo(current_procinfo).generate_code;
  779. release_main_proc(pd);
  780. end;
  781. procedure proc_unit;
  782. function is_assembler_generated:boolean;
  783. begin
  784. is_assembler_generated:=(Errorcount=0) and
  785. not(
  786. codeSegment.empty and
  787. dataSegment.empty and
  788. bssSegment.empty and
  789. ((importssection=nil) or importsSection.empty) and
  790. ((resourcesection=nil) or resourceSection.empty) and
  791. ((resourcestringlist=nil) or resourcestringList.empty)
  792. );
  793. end;
  794. var
  795. main_file: tinputfile;
  796. st : tsymtable;
  797. unitst : tglobalsymtable;
  798. store_crc,store_interface_crc : cardinal;
  799. s1,s2 : ^string; {Saves stack space}
  800. force_init_final : boolean;
  801. pd : tprocdef;
  802. unitname8 : string[8];
  803. begin
  804. consume(_UNIT);
  805. if compile_level=1 then
  806. Status.IsExe:=false;
  807. if token=_ID then
  808. begin
  809. { create filenames and unit name }
  810. main_file := current_scanner.inputfile;
  811. while assigned(main_file.next) do
  812. main_file := main_file.next;
  813. new(s1);
  814. s1^:=current_module.modulename^;
  815. current_module.SetFileName(main_file.path^+main_file.name^,true);
  816. current_module.SetModuleName(orgpattern);
  817. { check for system unit }
  818. new(s2);
  819. s2^:=upper(SplitName(main_file.name^));
  820. unitname8:=copy(current_module.modulename^,1,8);
  821. if (cs_check_unit_name in aktglobalswitches) and
  822. (
  823. not(
  824. (current_module.modulename^=s2^) or
  825. (
  826. (length(current_module.modulename^)>8) and
  827. (unitname8=s2^)
  828. )
  829. )
  830. or
  831. (
  832. (length(s1^)>8) and
  833. (s1^<>current_module.modulename^)
  834. )
  835. ) then
  836. Message1(unit_e_illegal_unit_name,current_module.realmodulename^);
  837. if (current_module.modulename^='SYSTEM') then
  838. include(aktmoduleswitches,cs_compilesystem);
  839. dispose(s2);
  840. dispose(s1);
  841. end;
  842. consume(_ID);
  843. consume(_SEMICOLON);
  844. consume(_INTERFACE);
  845. { global switches are read, so further changes aren't allowed }
  846. current_module.in_global:=false;
  847. { handle the global switches }
  848. setupglobalswitches;
  849. message1(unit_u_loading_interface_units,current_module.modulename^);
  850. { update status }
  851. status.currentmodule:=current_module.realmodulename^;
  852. { maybe turn off m_objpas if we are compiling objpas }
  853. if (current_module.modulename^='OBJPAS') then
  854. exclude(aktmodeswitches,m_objpas);
  855. parse_only:=true;
  856. { generate now the global symboltable }
  857. st:=tglobalsymtable.create(current_module.modulename^);
  858. refsymtable:=st;
  859. unitst:=tglobalsymtable(st);
  860. { define first as local to overcome dependency conflicts }
  861. current_module.localsymtable:=st;
  862. { the unit name must be usable as a unit specifier }
  863. { inside the unit itself (PM) }
  864. { this also forbids to have another symbol }
  865. { with the same name as the unit }
  866. refsymtable.insert(tunitsym.create(current_module.realmodulename^,unitst));
  867. { load default units, like the system unit }
  868. loaddefaultunits;
  869. { reset }
  870. make_ref:=true;
  871. { insert qualifier for the system unit (allows system.writeln) }
  872. if not(cs_compilesystem in aktmoduleswitches) then
  873. begin
  874. if token=_USES then
  875. begin
  876. loadunits;
  877. { has it been compiled at a higher level ?}
  878. if current_module.state=ms_compiled then
  879. exit;
  880. end;
  881. { ... but insert the symbol table later }
  882. st.next:=symtablestack;
  883. symtablestack:=st;
  884. end
  885. else
  886. { while compiling a system unit, some types are directly inserted }
  887. begin
  888. st.next:=symtablestack;
  889. symtablestack:=st;
  890. insert_intern_types(st);
  891. end;
  892. { now we know the place to insert the constants }
  893. constsymtable:=symtablestack;
  894. { move the global symtab from the temporary local to global }
  895. current_module.globalsymtable:=current_module.localsymtable;
  896. current_module.localsymtable:=nil;
  897. reset_all_defs;
  898. { number all units, so we know if a unit is used by this unit or
  899. needs to be added implicitly }
  900. current_module.numberunits;
  901. { ... parse the declarations }
  902. Message1(parser_u_parsing_interface,current_module.realmodulename^);
  903. read_interface_declarations;
  904. { leave when we got an error }
  905. if (Errorcount>0) and not status.skip_error then
  906. begin
  907. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  908. status.skip_error:=true;
  909. exit;
  910. end;
  911. { Our interface is compiled, generate CRC and switch to implementation }
  912. if not(cs_compilesystem in aktmoduleswitches) and
  913. (Errorcount=0) then
  914. tppumodule(current_module).getppucrc;
  915. current_module.in_interface:=false;
  916. current_module.interface_compiled:=true;
  917. { First reload all units depending on our interface, we need to do this
  918. in the implementation part to prevent errorneous circular references }
  919. reload_flagged_units;
  920. { Parse the implementation section }
  921. consume(_IMPLEMENTATION);
  922. Message1(unit_u_loading_implementation_units,current_module.modulename^);
  923. parse_only:=false;
  924. { generates static symbol table }
  925. st:=tstaticsymtable.create(current_module.modulename^);
  926. current_module.localsymtable:=st;
  927. { remove the globalsymtable from the symtable stack }
  928. { to reinsert it after loading the implementation units }
  929. symtablestack:=unitst.next;
  930. { we don't want implementation units symbols in unitsymtable !! PM }
  931. refsymtable:=st;
  932. { Read the implementation units }
  933. parse_implementation_uses;
  934. if current_module.state=ms_compiled then
  935. exit;
  936. { reset ranges/stabs in exported definitions }
  937. reset_all_defs;
  938. { All units are read, now give them a number }
  939. current_module.numberunits;
  940. { now we can change refsymtable }
  941. refsymtable:=st;
  942. { but reinsert the global symtable as lasts }
  943. unitst.next:=symtablestack;
  944. symtablestack:=unitst;
  945. {$ifdef DEBUG}
  946. test_symtablestack;
  947. {$endif DEBUG}
  948. constsymtable:=symtablestack;
  949. {$ifdef Splitheap}
  950. if testsplit then
  951. begin
  952. Split_Heap;
  953. allow_special:=true;
  954. Switch_to_temp_heap;
  955. end;
  956. { it will report all crossings }
  957. allow_special:=false;
  958. {$endif Splitheap}
  959. Message1(parser_u_parsing_implementation,current_module.modulename^);
  960. if current_module.in_interface then
  961. internalerror(200212285);
  962. { Compile the unit }
  963. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'init'),potype_unitinit,st);
  964. pd.aliasnames.insert(make_mangledname('INIT$',current_module.localsymtable,''));
  965. tcgprocinfo(current_procinfo).parse_body;
  966. tcgprocinfo(current_procinfo).generate_code;
  967. tcgprocinfo(current_procinfo).resetprocdef;
  968. release_main_proc(pd);
  969. { if the unit contains ansi/widestrings, initialization and
  970. finalization code must be forced }
  971. force_init_final:=tglobalsymtable(current_module.globalsymtable).needs_init_final or
  972. tstaticsymtable(current_module.localsymtable).needs_init_final;
  973. { should we force unit initialization? }
  974. { this is a hack, but how can it be done better ? }
  975. if force_init_final and ((current_module.flags and uf_init)=0) then
  976. gen_implicit_initfinal(uf_init,st);
  977. { finalize? }
  978. if token=_FINALIZATION then
  979. begin
  980. { set module options }
  981. current_module.flags:=current_module.flags or uf_finalize;
  982. { Compile the finalize }
  983. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize'),potype_unitfinalize,st);
  984. pd.aliasnames.insert(make_mangledname('FINALIZE$',current_module.localsymtable,''));
  985. tcgprocinfo(current_procinfo).parse_body;
  986. tcgprocinfo(current_procinfo).generate_code;
  987. tcgprocinfo(current_procinfo).resetprocdef;
  988. release_main_proc(pd);
  989. end
  990. else if force_init_final then
  991. gen_implicit_initfinal(uf_finalize,st);
  992. { the last char should always be a point }
  993. consume(_POINT);
  994. { generate a list of threadvars }
  995. InsertThreadvars;
  996. { Generate resoucestrings }
  997. If ResourceStrings.ResStrCount>0 then
  998. begin
  999. ResourceStrings.CreateResourceStringList;
  1000. current_module.flags:=current_module.flags or uf_has_resources;
  1001. { only write if no errors found }
  1002. if (Errorcount=0) then
  1003. ResourceStrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
  1004. end;
  1005. if (Errorcount=0) then
  1006. begin
  1007. { test static symtable }
  1008. tstoredsymtable(st).allsymbolsused;
  1009. tstoredsymtable(st).allprivatesused;
  1010. current_module.allunitsused;
  1011. end;
  1012. {$ifdef GDB}
  1013. write_gdb_info;
  1014. {$endif GDB}
  1015. if (Errorcount=0) then
  1016. begin
  1017. { tests, if all (interface) forwards are resolved }
  1018. tstoredsymtable(symtablestack).check_forwards;
  1019. { check if all private fields are used }
  1020. tstoredsymtable(symtablestack).allprivatesused;
  1021. { remove cross unit overloads }
  1022. tstoredsymtable(symtablestack).unchain_overloaded;
  1023. end;
  1024. { leave when we got an error }
  1025. if (Errorcount>0) and not status.skip_error then
  1026. begin
  1027. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1028. status.skip_error:=true;
  1029. exit;
  1030. end;
  1031. { generate imports }
  1032. if current_module.uses_imports then
  1033. importlib.generatelib;
  1034. { insert own objectfile, or say that it's in a library
  1035. (no check for an .o when loading) }
  1036. if is_assembler_generated then
  1037. insertobjectfile
  1038. else
  1039. current_module.flags:=current_module.flags or uf_no_link;
  1040. if cs_local_browser in aktmoduleswitches then
  1041. current_module.localsymtable:=refsymtable;
  1042. if is_assembler_generated then
  1043. begin
  1044. { finish asmlist by adding segment starts }
  1045. insertsegment;
  1046. { assemble }
  1047. create_objectfile;
  1048. end;
  1049. { Write out the ppufile after the object file has been created }
  1050. store_interface_crc:=current_module.interface_crc;
  1051. store_crc:=current_module.crc;
  1052. if (Errorcount=0) then
  1053. tppumodule(current_module).writeppu;
  1054. if not(cs_compilesystem in aktmoduleswitches) then
  1055. if store_interface_crc<>current_module.interface_crc then
  1056. Message1(unit_u_interface_crc_changed,current_module.ppufilename^);
  1057. {$ifdef EXTDEBUG}
  1058. if not(cs_compilesystem in aktmoduleswitches) then
  1059. if (store_crc<>current_module.crc) and simplify_ppu then
  1060. Message1(unit_u_implementation_crc_changed,current_module.ppufilename^);
  1061. {$endif EXTDEBUG}
  1062. { remove static symtable (=refsymtable) here to save some mem }
  1063. if not (cs_local_browser in aktmoduleswitches) then
  1064. begin
  1065. st.free;
  1066. current_module.localsymtable:=nil;
  1067. end;
  1068. { leave when we got an error }
  1069. if (Errorcount>0) and not status.skip_error then
  1070. begin
  1071. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1072. status.skip_error:=true;
  1073. exit;
  1074. end;
  1075. Message1(unit_u_finished_compiling,current_module.modulename^);
  1076. end;
  1077. procedure proc_program(islibrary : boolean);
  1078. var
  1079. main_file: tinputfile;
  1080. st : tsymtable;
  1081. hp : tmodule;
  1082. pd : tprocdef;
  1083. begin
  1084. DLLsource:=islibrary;
  1085. Status.IsLibrary:=IsLibrary;
  1086. Status.IsExe:=true;
  1087. parse_only:=false;
  1088. { relocation works only without stabs under win32 !! PM }
  1089. { internal assembler uses rva for stabs info
  1090. so it should work with relocated DLLs }
  1091. if RelocSection and
  1092. (target_info.system in [system_i386_win32,system_i386_wdosx]) and
  1093. (target_info.assem<>as_i386_pecoff) then
  1094. begin
  1095. include(aktglobalswitches,cs_link_strip);
  1096. { Warning stabs info does not work with reloc section !! }
  1097. if cs_debuginfo in aktmoduleswitches then
  1098. begin
  1099. Message1(parser_w_parser_reloc_no_debug,current_module.mainsource^);
  1100. Message(parser_w_parser_win32_debug_needs_WN);
  1101. exclude(aktmoduleswitches,cs_debuginfo);
  1102. end;
  1103. end;
  1104. { get correct output names }
  1105. main_file := current_scanner.inputfile;
  1106. while assigned(main_file.next) do
  1107. main_file := main_file.next;
  1108. current_module.SetFileName(main_file.path^+main_file.name^,true);
  1109. if islibrary then
  1110. begin
  1111. consume(_LIBRARY);
  1112. stringdispose(current_module.modulename);
  1113. current_module.modulename:=stringdup(pattern);
  1114. current_module.islibrary:=true;
  1115. exportlib.preparelib(pattern);
  1116. consume(_ID);
  1117. consume(_SEMICOLON);
  1118. end
  1119. else
  1120. { is there an program head ? }
  1121. if token=_PROGRAM then
  1122. begin
  1123. consume(_PROGRAM);
  1124. stringdispose(current_module.modulename);
  1125. stringdispose(current_module.realmodulename);
  1126. current_module.modulename:=stringdup(pattern);
  1127. current_module.realmodulename:=stringdup(orgpattern);
  1128. if (target_info.system in [system_i386_WIN32,system_i386_wdosx]) then
  1129. exportlib.preparelib(pattern);
  1130. consume(_ID);
  1131. if token=_LKLAMMER then
  1132. begin
  1133. consume(_LKLAMMER);
  1134. repeat
  1135. consume(_ID);
  1136. until not try_to_consume(_COMMA);
  1137. consume(_RKLAMMER);
  1138. end;
  1139. consume(_SEMICOLON);
  1140. end
  1141. else if (target_info.system in [system_i386_WIN32,system_i386_wdosx]) then
  1142. exportlib.preparelib(current_module.modulename^);
  1143. { global switches are read, so further changes aren't allowed }
  1144. current_module.in_global:=false;
  1145. { setup things using the global switches }
  1146. setupglobalswitches;
  1147. { set implementation flag }
  1148. current_module.in_interface:=false;
  1149. current_module.interface_compiled:=true;
  1150. { insert after the unit symbol tables the static symbol table }
  1151. { of the program }
  1152. st:=tstaticsymtable.create(current_module.modulename^);;
  1153. current_module.localsymtable:=st;
  1154. refsymtable:=st;
  1155. { load standard units (system,objpas,profile unit) }
  1156. loaddefaultunits;
  1157. {Load the units used by the program we compile.}
  1158. if token=_USES then
  1159. loadunits;
  1160. { reset ranges/stabs in exported definitions }
  1161. reset_all_defs;
  1162. { All units are read, now give them a number }
  1163. current_module.numberunits;
  1164. {Insert the name of the main program into the symbol table.}
  1165. if current_module.realmodulename^<>'' then
  1166. st.insert(tunitsym.create(current_module.realmodulename^,st));
  1167. { ...is also constsymtable, this is the symtable where }
  1168. { the elements of enumeration types are inserted }
  1169. constsymtable:=st;
  1170. Message1(parser_u_parsing_implementation,current_module.mainsource^);
  1171. { The program intialization needs an alias, so it can be called
  1172. from the bootstrap code.}
  1173. if islibrary or
  1174. (target_info.system in [system_powerpc_macos,system_powerpc_darwin]) then
  1175. begin
  1176. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'main'),potype_proginit,st);
  1177. { Win32 startup code needs a single name }
  1178. // if (target_info.system in [system_i386_win32,system_i386_wdosx]) then
  1179. pd.aliasnames.insert('PASCALMAIN');
  1180. end
  1181. else
  1182. begin
  1183. pd:=create_main_proc('main',potype_proginit,st);
  1184. pd.aliasnames.insert('PASCALMAIN');
  1185. end;
  1186. tcgprocinfo(current_procinfo).parse_body;
  1187. tcgprocinfo(current_procinfo).generate_code;
  1188. tcgprocinfo(current_procinfo).resetprocdef;
  1189. release_main_proc(pd);
  1190. { should we force unit initialization? }
  1191. if tstaticsymtable(current_module.localsymtable).needs_init_final then
  1192. begin
  1193. { initialize section }
  1194. gen_implicit_initfinal(uf_init,st);
  1195. { finalize section }
  1196. gen_implicit_initfinal(uf_finalize,st);
  1197. end;
  1198. { Add symbol to the exports section for win32 so smartlinking a
  1199. DLL will include the edata section }
  1200. if assigned(exportlib) and
  1201. (target_info.system in [system_i386_win32,system_i386_wdosx]) and
  1202. assigned(current_module._exports.first) then
  1203. codesegment.concat(tai_const_symbol.create(exportlib.edatalabel));
  1204. If ResourceStrings.ResStrCount>0 then
  1205. begin
  1206. ResourceStrings.CreateResourceStringList;
  1207. { only write if no errors found }
  1208. if (Errorcount=0) then
  1209. ResourceStrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
  1210. end;
  1211. { finalize? }
  1212. if token=_FINALIZATION then
  1213. begin
  1214. { set module options }
  1215. current_module.flags:=current_module.flags or uf_finalize;
  1216. { Compile the finalize }
  1217. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize'),potype_unitfinalize,st);
  1218. pd.aliasnames.insert(make_mangledname('FINALIZE$',current_module.localsymtable,''));
  1219. tcgprocinfo(current_procinfo).parse_body;
  1220. tcgprocinfo(current_procinfo).generate_code;
  1221. tcgprocinfo(current_procinfo).resetprocdef;
  1222. release_main_proc(pd);
  1223. end;
  1224. { consume the last point }
  1225. consume(_POINT);
  1226. {$ifdef GDB}
  1227. write_gdb_info;
  1228. {$endif GDB}
  1229. { leave when we got an error }
  1230. if (Errorcount>0) and not status.skip_error then
  1231. begin
  1232. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1233. status.skip_error:=true;
  1234. exit;
  1235. end;
  1236. if (Errorcount=0) then
  1237. begin
  1238. { test static symtable }
  1239. tstoredsymtable(st).allsymbolsused;
  1240. tstoredsymtable(st).allprivatesused;
  1241. current_module.allunitsused;
  1242. end;
  1243. { generate a list of threadvars }
  1244. InsertThreadvars;
  1245. { generate imports }
  1246. if current_module.uses_imports then
  1247. importlib.generatelib;
  1248. if islibrary or
  1249. (target_info.system in [system_i386_WIN32,system_i386_wdosx]) or
  1250. (target_info.system=system_i386_NETWARE) then
  1251. exportlib.generatelib;
  1252. { insert Tables and Heap }
  1253. insertThreadVarTablesTable;
  1254. insertResourceTablesTable;
  1255. insertinitfinaltable;
  1256. insertheap;
  1257. insertstacklength;
  1258. // datasize:=symtablestack.datasize;
  1259. { finish asmlist by adding segment starts }
  1260. insertsegment;
  1261. { insert own objectfile }
  1262. insertobjectfile;
  1263. { assemble and link }
  1264. create_objectfile;
  1265. { leave when we got an error }
  1266. if (Errorcount>0) and not status.skip_error then
  1267. begin
  1268. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1269. status.skip_error:=true;
  1270. exit;
  1271. end;
  1272. { create the executable when we are at level 1 }
  1273. if (compile_level=1) then
  1274. begin
  1275. { insert all .o files from all loaded units }
  1276. hp:=tmodule(loaded_units.first);
  1277. while assigned(hp) do
  1278. begin
  1279. linker.AddModuleFiles(hp);
  1280. hp:=tmodule(hp.next);
  1281. end;
  1282. { write .def file }
  1283. if (cs_link_deffile in aktglobalswitches) then
  1284. deffile.writefile;
  1285. { finally we can create a executable }
  1286. if (not current_module.is_unit) then
  1287. begin
  1288. if DLLSource then
  1289. linker.MakeSharedLibrary
  1290. else
  1291. linker.MakeExecutable;
  1292. end;
  1293. end;
  1294. end;
  1295. end.
  1296. {
  1297. $Log$
  1298. Revision 1.149 2004-05-02 17:26:19 peter
  1299. * fix stabs for globals
  1300. Revision 1.148 2004/03/24 20:24:25 hajny
  1301. * OS/2 heap management modified to be able to grow heap as needed
  1302. Revision 1.147 2004/03/18 11:43:57 olle
  1303. * change AT_FUNCTION to AT_DATA where appropriate
  1304. Revision 1.146 2004/03/14 20:10:14 peter
  1305. * fix stabs lineno for fpc_compiled
  1306. Revision 1.145 2004/03/10 22:52:57 peter
  1307. * more stabs fixes
  1308. * special mode -gv for valgrind compatible stabs
  1309. Revision 1.144 2004/03/09 20:45:04 peter
  1310. * more stabs updates
  1311. Revision 1.143 2004/03/08 22:07:47 peter
  1312. * stabs updates to write stabs for def for all implictly used
  1313. units
  1314. Revision 1.142 2004/03/02 17:32:12 florian
  1315. * make cycle fixed
  1316. + pic support for darwin
  1317. + support of importing vars from shared libs on darwin implemented
  1318. Revision 1.141 2004/03/02 00:36:33 olle
  1319. * big transformation of Tai_[const_]Symbol.Create[data]name*
  1320. Revision 1.140 2004/02/26 16:16:38 peter
  1321. * tai_const.create_ptr added
  1322. Revision 1.139 2004/02/06 22:37:00 daniel
  1323. * Removed not very usefull nextglobal & previousglobal fields from
  1324. Tstoreddef, saving 78 kb of memory
  1325. Revision 1.138 2004/02/04 22:15:15 daniel
  1326. * Rtti generation moved to ncgutil
  1327. * Assmtai usage of symsym removed
  1328. * operator overloading cleanup up
  1329. Revision 1.137 2004/01/28 16:48:24 peter
  1330. use local string of 8 chars
  1331. Revision 1.136 2004/01/04 21:08:09 jonas
  1332. * Never generate a "main" symbol for PASCALMAIN for Darwin and classic
  1333. Mac OS, they use a C-main in their system unit
  1334. Revision 1.135 2003/12/12 19:42:21 peter
  1335. * check unit name when expected unitname > 8 chars
  1336. Revision 1.134 2003/12/08 22:33:43 peter
  1337. * don't allow duplicate uses
  1338. * fix wrong circular dependency
  1339. Revision 1.133 2003/11/29 20:13:25 florian
  1340. * fixed several pi_do_call problems
  1341. Revision 1.132 2003/10/29 19:48:51 peter
  1342. * renamed mangeldname_prefix to make_mangledname and made it more
  1343. generic
  1344. * make_mangledname is now also used for internal threadvar/resstring
  1345. lists
  1346. * Add P$ in front of program modulename to prevent duplicated symbols
  1347. at assembler level, because the main program can have the same name
  1348. as a unit, see webtbs/tw1251b
  1349. Revision 1.131 2003/10/24 17:40:23 peter
  1350. * cleanup of the entry and exit code insertion
  1351. Revision 1.130 2003/10/22 15:22:33 peter
  1352. * fixed unitsym-globalsymtable relation so the uses of a unit
  1353. is counted correctly
  1354. Revision 1.129 2003/10/21 15:14:33 peter
  1355. * fixed memleak for initfinalcode
  1356. * exit from generatecode when there are already errors
  1357. Revision 1.128 2003/10/01 20:34:49 peter
  1358. * procinfo unit contains tprocinfo
  1359. * cginfo renamed to cgbase
  1360. * moved cgmessage to verbose
  1361. * fixed ppc and sparc compiles
  1362. Revision 1.127 2003/09/30 08:39:50 michael
  1363. + Patch from Wiktor Sywula for watcom support
  1364. Revision 1.126 2003/09/23 18:03:08 peter
  1365. * add missing release of main_proc
  1366. Revision 1.125 2003/09/23 17:56:05 peter
  1367. * locals and paras are allocated in the code generation
  1368. * tvarsym.localloc contains the location of para/local when
  1369. generating code for the current procedure
  1370. Revision 1.124 2003/09/09 20:59:27 daniel
  1371. * Adding register allocation order
  1372. Revision 1.123 2003/09/09 15:55:44 peter
  1373. * use register with least interferences in spillregister
  1374. Revision 1.122 2003/09/07 22:09:35 peter
  1375. * preparations for different default calling conventions
  1376. * various RA fixes
  1377. Revision 1.121 2003/09/05 17:41:12 florian
  1378. * merged Wiktor's Watcom patches in 1.1
  1379. Revision 1.120 2003/08/23 22:29:24 peter
  1380. * reload flagged units when interface is loaded
  1381. Revision 1.119 2003/08/21 14:47:41 peter
  1382. * remove convert_registers
  1383. Revision 1.118 2003/08/20 17:48:49 peter
  1384. * fixed stackalloc to not allocate localst.datasize twice
  1385. * order of stackalloc code fixed for implicit init/final
  1386. Revision 1.117 2003/08/20 09:07:00 daniel
  1387. * New register coding now mandatory, some more convert_registers calls
  1388. removed.
  1389. Revision 1.116 2003/07/23 11:04:15 jonas
  1390. * split en_exit_code into a part that may allocate a register and a part
  1391. that doesn't, so the former can be done before the register colouring
  1392. has been performed
  1393. Revision 1.115 2003/07/06 17:58:22 peter
  1394. * framepointer fixes for sparc
  1395. * parent framepointer code more generic
  1396. Revision 1.114 2003/06/13 21:19:31 peter
  1397. * current_procdef removed, use current_procinfo.procdef instead
  1398. Revision 1.113 2003/06/09 12:23:30 peter
  1399. * init/final of procedure data splitted from genentrycode
  1400. * use asmnode getposition to insert final at the correct position
  1401. als for the implicit try...finally
  1402. Revision 1.112 2003/06/07 20:26:32 peter
  1403. * re-resolving added instead of reloading from ppu
  1404. * tderef object added to store deref info for resolving
  1405. Revision 1.111 2003/06/03 20:21:45 mazen
  1406. - removed unneeded ifdefs
  1407. - removed unneeded cases for sparc and x86_64
  1408. Revision 1.110 2003/06/03 13:01:59 daniel
  1409. * Register allocator finished
  1410. Revision 1.109 2003/05/26 21:17:17 peter
  1411. * procinlinenode removed
  1412. * aktexit2label removed, fast exit removed
  1413. + tcallnode.inlined_pass_2 added
  1414. Revision 1.108 2003/05/25 10:27:12 peter
  1415. * moved Comment calls to messge file
  1416. Revision 1.107 2003/05/22 21:31:35 peter
  1417. * defer codegeneration for nested procedures
  1418. Revision 1.106 2003/05/15 18:58:53 peter
  1419. * removed selfpointer_offset, vmtpointer_offset
  1420. * tvarsym.adjusted_address
  1421. * address in localsymtable is now in the real direction
  1422. * removed some obsolete globals
  1423. Revision 1.105 2003/05/11 19:31:28 florian
  1424. * fixed implicit init/final code for units, stack frame was wrong for ppc
  1425. Revision 1.104 2003/04/28 21:19:02 peter
  1426. * fix stabs generation for implicit initfinal
  1427. Revision 1.103 2003/04/27 11:21:34 peter
  1428. * aktprocdef renamed to current_procinfo.procdef
  1429. * procinfo renamed to current_procinfo
  1430. * procinfo will now be stored in current_module so it can be
  1431. cleaned up properly
  1432. * gen_main_procsym changed to create_main_proc and release_main_proc
  1433. to also generate a tprocinfo structure
  1434. * fixed unit implicit initfinal
  1435. Revision 1.102 2003/04/27 07:29:50 peter
  1436. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  1437. a new procdef declaration
  1438. * aktprocsym removed
  1439. * lexlevel removed, use symtable.symtablelevel instead
  1440. * implicit init/final code uses the normal genentry/genexit
  1441. * funcret state checking updated for new funcret handling
  1442. Revision 1.101 2003/04/23 12:35:34 florian
  1443. * fixed several issues with powerpc
  1444. + applied a patch from Jonas for nested function calls (PowerPC only)
  1445. * ...
  1446. Revision 1.100 2003/04/12 15:13:03 peter
  1447. * Use the original unitname when defining a unitsym
  1448. Revision 1.99 2003/03/23 23:21:42 hajny
  1449. + emx target added
  1450. Revision 1.98 2003/03/17 22:20:08 peter
  1451. *** empty log message ***
  1452. Revision 1.97 2003/03/17 13:36:39 peter
  1453. * fix import linking under linux
  1454. Revision 1.96 2003/02/19 22:00:14 daniel
  1455. * Code generator converted to new register notation
  1456. - Horribily outdated todo.txt removed
  1457. Revision 1.95 2003/02/06 22:36:55 mazen
  1458. * fixing bug related to errornous program main entry stack frame
  1459. Revision 1.94 2003/01/30 21:46:20 peter
  1460. * tai_const_symbol.createdataname added
  1461. Revision 1.93 2003/01/11 11:19:54 hajny
  1462. * correction from rev. 1.88 put back
  1463. Revision 1.92 2003/01/08 18:43:56 daniel
  1464. * Tregister changed into a record
  1465. Revision 1.91 2003/01/05 13:36:53 florian
  1466. * x86-64 compiles
  1467. + very basic support for float128 type (x86-64 only)
  1468. Revision 1.90 2002/12/29 18:17:23 peter
  1469. * insert unitsym with the name as specified in the uses list
  1470. Revision 1.89 2002/12/29 14:57:50 peter
  1471. * unit loading changed to first register units and load them
  1472. afterwards. This is needed to support uses xxx in yyy correctly
  1473. * unit dependency check fixed
  1474. Revision 1.88 2002/12/27 19:09:33 hajny
  1475. * another (hopefully final ;-) ) fix for not linked import libraries for units with no code
  1476. Revision 1.87 2002/12/24 23:32:56 peter
  1477. * Use FixFilename for specified unit sourcefile in uses
  1478. Revision 1.86 2002/12/06 16:56:58 peter
  1479. * only compile cs_fp_emulation support when cpufpuemu is defined
  1480. * define cpufpuemu for m68k only
  1481. Revision 1.85 2002/11/30 21:32:24 carl
  1482. + Add loading of softfpu in emulation mode
  1483. + Correct routine call for softfpu
  1484. * Extended type must also be defined even with softfpu
  1485. Revision 1.84 2002/11/15 01:58:53 peter
  1486. * merged changes from 1.0.7 up to 04-11
  1487. - -V option for generating bug report tracing
  1488. - more tracing for option parsing
  1489. - errors for cdecl and high()
  1490. - win32 import stabs
  1491. - win32 records<=8 are returned in eax:edx (turned off by default)
  1492. - heaptrc update
  1493. - more info for temp management in .s file with EXTDEBUG
  1494. Revision 1.83 2002/11/09 15:33:26 carl
  1495. * major alignment updates
  1496. Revision 1.82 2002/10/16 06:32:52 michael
  1497. + Renamed thread unit to systhrds
  1498. Revision 1.81 2002/10/14 19:42:34 peter
  1499. * only use init tables for threadvars
  1500. Revision 1.80 2002/10/06 19:41:30 peter
  1501. * Add finalization of typed consts
  1502. * Finalization of globals in the main program
  1503. Revision 1.79 2002/09/09 17:34:15 peter
  1504. * tdicationary.replace added to replace and item in a dictionary. This
  1505. is only allowed for the same name
  1506. * varsyms are inserted in symtable before the types are parsed. This
  1507. fixes the long standing "var longint : longint" bug
  1508. - consume_idlist and idstringlist removed. The loops are inserted
  1509. at the callers place and uses the symtable for duplicate id checking
  1510. Revision 1.78 2002/09/07 15:25:07 peter
  1511. * old logs removed and tabs fixed
  1512. Revision 1.77 2002/09/03 16:26:27 daniel
  1513. * Make Tprocdef.defs protected
  1514. Revision 1.76 2002/09/02 18:46:26 peter
  1515. * insert PASCALMAIN in library for Win32 only
  1516. Revision 1.75 2002/08/31 15:59:30 florian
  1517. + HEAP* stuff must be generated for Linux/PPC as well
  1518. + direct assembler reader searches now global and static symtables as well
  1519. Revision 1.74 2002/08/25 19:25:20 peter
  1520. * sym.insert_in_data removed
  1521. * symtable.insertvardata/insertconstdata added
  1522. * removed insert_in_data call from symtable.insert, it needs to be
  1523. called separatly. This allows to deref the address calculation
  1524. * procedures now calculate the parast addresses after the procedure
  1525. directives are parsed. This fixes the cdecl parast problem
  1526. * push_addr_param has an extra argument that specifies if cdecl is used
  1527. or not
  1528. Revision 1.73 2002/08/18 20:06:25 peter
  1529. * inlining is now also allowed in interface
  1530. * renamed write/load to ppuwrite/ppuload
  1531. * tnode storing in ppu
  1532. * nld,ncon,nbas are already updated for storing in ppu
  1533. Revision 1.72 2002/08/17 09:23:39 florian
  1534. * first part of procinfo rewrite
  1535. Revision 1.71 2002/08/11 13:24:12 peter
  1536. * saving of asmsymbols in ppu supported
  1537. * asmsymbollist global is removed and moved into a new class
  1538. tasmlibrarydata that will hold the info of a .a file which
  1539. corresponds with a single module. Added librarydata to tmodule
  1540. to keep the library info stored for the module. In the future the
  1541. objectfiles will also be stored to the tasmlibrarydata class
  1542. * all getlabel/newasmsymbol and friends are moved to the new class
  1543. Revision 1.70 2002/08/10 14:46:29 carl
  1544. + moved target_cpu_string to cpuinfo
  1545. * renamed asmmode enum.
  1546. * assembler reader has now less ifdef's
  1547. * move from nppcmem.pas -> ncgmem.pas vec. node.
  1548. Revision 1.69 2002/07/26 21:15:41 florian
  1549. * rewrote the system handling
  1550. Revision 1.68 2002/07/04 20:43:01 florian
  1551. * first x86-64 patches
  1552. Revision 1.67 2002/07/01 18:46:25 peter
  1553. * internal linker
  1554. * reorganized aasm layer
  1555. Revision 1.66 2002/05/16 19:46:43 carl
  1556. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1557. + try to fix temp allocation (still in ifdef)
  1558. + generic constructor calls
  1559. + start of tassembler / tmodulebase class cleanup
  1560. Revision 1.65 2002/05/14 19:34:49 peter
  1561. * removed old logs and updated copyright year
  1562. Revision 1.64 2002/05/12 16:53:09 peter
  1563. * moved entry and exitcode to ncgutil and cgobj
  1564. * foreach gets extra argument for passing local data to the
  1565. iterator function
  1566. * -CR checks also class typecasts at runtime by changing them
  1567. into as
  1568. * fixed compiler to cycle with the -CR option
  1569. * fixed stabs with elf writer, finally the global variables can
  1570. be watched
  1571. * removed a lot of routines from cga unit and replaced them by
  1572. calls to cgobj
  1573. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1574. u32bit then the other is typecasted also to u32bit without giving
  1575. a rangecheck warning/error.
  1576. * fixed pascal calling method with reversing also the high tree in
  1577. the parast, detected by tcalcst3 test
  1578. Revision 1.63 2002/05/06 19:54:50 carl
  1579. + added more patches from Mazen for SPARC port
  1580. Revision 1.62 2002/04/20 21:32:24 carl
  1581. + generic FPC_CHECKPOINTER
  1582. + first parameter offset in stack now portable
  1583. * rename some constants
  1584. + move some cpu stuff to other units
  1585. - remove unused constents
  1586. * fix stacksize for some targets
  1587. * fix generic size problems which depend now on EXTEND_SIZE constant
  1588. Revision 1.61 2002/04/19 15:46:02 peter
  1589. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  1590. in most cases and not written to the ppu
  1591. * add mangeledname_prefix() routine to generate the prefix of
  1592. manglednames depending on the current procedure, object and module
  1593. * removed static procprefix since the mangledname is now build only
  1594. on demand from tprocdef.mangledname
  1595. Revision 1.60 2002/04/14 16:53:10 carl
  1596. + align code section and data section according to alignment rules
  1597. Revision 1.59 2002/04/07 17:58:38 carl
  1598. + generic stack checking
  1599. Revision 1.58 2002/04/04 19:06:03 peter
  1600. * removed unused units
  1601. * use tlocation.size in cg.a_*loc*() routines
  1602. }