pmodules.pas 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876
  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. else
  696. if (m_mac in aktmodeswitches) then
  697. current_scanner.def_macro('FPC_MAC');
  698. end;
  699. function create_main_proc(const name:string;potype:tproctypeoption;st:tsymtable):tprocdef;
  700. var
  701. stt : tsymtable;
  702. ps : tprocsym;
  703. pd : tprocdef;
  704. begin
  705. { there should be no current_procinfo available }
  706. if assigned(current_procinfo) then
  707. internalerror(200304275);
  708. {Generate a procsym for main}
  709. make_ref:=false;
  710. { try to insert in in static symtable ! }
  711. stt:=symtablestack;
  712. symtablestack:=st;
  713. { generate procsym }
  714. ps:=tprocsym.create('$'+name);
  715. { main are allways used }
  716. inc(ps.refs);
  717. symtablestack.insert(ps);
  718. pd:=tprocdef.create(main_program_level);
  719. include(pd.procoptions,po_public);
  720. pd.procsym:=ps;
  721. ps.addprocdef(pd);
  722. { restore symtable }
  723. make_ref:=true;
  724. symtablestack:=stt;
  725. { set procdef options }
  726. pd.proctypeoption:=potype;
  727. pd.proccalloption:=pocall_default;
  728. pd.forwarddef:=false;
  729. pd.setmangledname(target_info.cprefix+name);
  730. pd.aliasnames.insert(pd.mangledname);
  731. { We don't need is a local symtable. Change it into the static
  732. symtable }
  733. pd.localst.free;
  734. pd.localst:=st;
  735. { set procinfo and current_procinfo.procdef }
  736. current_procinfo:=cprocinfo.create(nil);
  737. current_module.procinfo:=current_procinfo;
  738. current_procinfo.procdef:=pd;
  739. { return procdef }
  740. create_main_proc:=pd;
  741. { main proc does always a call e.g. to init system unit }
  742. include(current_procinfo.flags,pi_do_call);
  743. end;
  744. procedure release_main_proc(pd:tprocdef);
  745. begin
  746. { this is a main proc, so there should be no parent }
  747. if not(assigned(current_procinfo)) or
  748. assigned(current_procinfo.parent) or
  749. not(current_procinfo.procdef=pd) then
  750. internalerror(200304276);
  751. { remove procinfo }
  752. current_module.procinfo:=nil;
  753. current_procinfo.free;
  754. current_procinfo:=nil;
  755. { remove localst as it was replaced by staticsymtable }
  756. pd.localst:=nil;
  757. end;
  758. procedure gen_implicit_initfinal(flag:word;st:tsymtable);
  759. var
  760. pd : tprocdef;
  761. begin
  762. { update module flags }
  763. current_module.flags:=current_module.flags or flag;
  764. { create procdef }
  765. case flag of
  766. uf_init :
  767. begin
  768. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'init_implicit'),potype_unitinit,st);
  769. pd.aliasnames.insert(make_mangledname('INIT$',current_module.localsymtable,''));
  770. end;
  771. uf_finalize :
  772. begin
  773. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize_implicit'),potype_unitfinalize,st);
  774. pd.aliasnames.insert(make_mangledname('FINALIZE$',current_module.localsymtable,''));
  775. end;
  776. else
  777. internalerror(200304253);
  778. end;
  779. tcgprocinfo(current_procinfo).code:=cnothingnode.create;
  780. tcgprocinfo(current_procinfo).add_entry_exit_code;
  781. tcgprocinfo(current_procinfo).generate_code;
  782. release_main_proc(pd);
  783. end;
  784. procedure proc_unit;
  785. function is_assembler_generated:boolean;
  786. begin
  787. is_assembler_generated:=(Errorcount=0) and
  788. not(
  789. codeSegment.empty and
  790. dataSegment.empty and
  791. bssSegment.empty and
  792. ((importssection=nil) or importsSection.empty) and
  793. ((resourcesection=nil) or resourceSection.empty) and
  794. ((resourcestringlist=nil) or resourcestringList.empty)
  795. );
  796. end;
  797. var
  798. main_file: tinputfile;
  799. st : tsymtable;
  800. unitst : tglobalsymtable;
  801. store_crc,store_interface_crc : cardinal;
  802. s1,s2 : ^string; {Saves stack space}
  803. force_init_final : boolean;
  804. pd : tprocdef;
  805. unitname8 : string[8];
  806. has_impl: boolean;
  807. begin
  808. consume(_UNIT);
  809. if compile_level=1 then
  810. Status.IsExe:=false;
  811. if token=_ID then
  812. begin
  813. { create filenames and unit name }
  814. main_file := current_scanner.inputfile;
  815. while assigned(main_file.next) do
  816. main_file := main_file.next;
  817. new(s1);
  818. s1^:=current_module.modulename^;
  819. current_module.SetFileName(main_file.path^+main_file.name^,true);
  820. current_module.SetModuleName(orgpattern);
  821. { check for system unit }
  822. new(s2);
  823. s2^:=upper(SplitName(main_file.name^));
  824. unitname8:=copy(current_module.modulename^,1,8);
  825. if (cs_check_unit_name in aktglobalswitches) and
  826. (
  827. not(
  828. (current_module.modulename^=s2^) or
  829. (
  830. (length(current_module.modulename^)>8) and
  831. (unitname8=s2^)
  832. )
  833. )
  834. or
  835. (
  836. (length(s1^)>8) and
  837. (s1^<>current_module.modulename^)
  838. )
  839. ) then
  840. Message1(unit_e_illegal_unit_name,current_module.realmodulename^);
  841. if (current_module.modulename^='SYSTEM') then
  842. include(aktmoduleswitches,cs_compilesystem);
  843. dispose(s2);
  844. dispose(s1);
  845. end;
  846. consume(_ID);
  847. consume(_SEMICOLON);
  848. consume(_INTERFACE);
  849. { global switches are read, so further changes aren't allowed }
  850. current_module.in_global:=false;
  851. { handle the global switches }
  852. setupglobalswitches;
  853. message1(unit_u_loading_interface_units,current_module.modulename^);
  854. { update status }
  855. status.currentmodule:=current_module.realmodulename^;
  856. { maybe turn off m_objpas if we are compiling objpas }
  857. if (current_module.modulename^='OBJPAS') then
  858. exclude(aktmodeswitches,m_objpas);
  859. parse_only:=true;
  860. { generate now the global symboltable }
  861. st:=tglobalsymtable.create(current_module.modulename^);
  862. refsymtable:=st;
  863. unitst:=tglobalsymtable(st);
  864. { define first as local to overcome dependency conflicts }
  865. current_module.localsymtable:=st;
  866. { the unit name must be usable as a unit specifier }
  867. { inside the unit itself (PM) }
  868. { this also forbids to have another symbol }
  869. { with the same name as the unit }
  870. refsymtable.insert(tunitsym.create(current_module.realmodulename^,unitst));
  871. { load default units, like the system unit }
  872. loaddefaultunits;
  873. { reset }
  874. make_ref:=true;
  875. { insert qualifier for the system unit (allows system.writeln) }
  876. if not(cs_compilesystem in aktmoduleswitches) then
  877. begin
  878. if token=_USES then
  879. begin
  880. loadunits;
  881. { has it been compiled at a higher level ?}
  882. if current_module.state=ms_compiled then
  883. exit;
  884. end;
  885. { ... but insert the symbol table later }
  886. st.next:=symtablestack;
  887. symtablestack:=st;
  888. end
  889. else
  890. { while compiling a system unit, some types are directly inserted }
  891. begin
  892. st.next:=symtablestack;
  893. symtablestack:=st;
  894. insert_intern_types(st);
  895. end;
  896. { now we know the place to insert the constants }
  897. constsymtable:=symtablestack;
  898. { move the global symtab from the temporary local to global }
  899. current_module.globalsymtable:=current_module.localsymtable;
  900. current_module.localsymtable:=nil;
  901. reset_all_defs;
  902. { number all units, so we know if a unit is used by this unit or
  903. needs to be added implicitly }
  904. current_module.numberunits;
  905. { ... parse the declarations }
  906. Message1(parser_u_parsing_interface,current_module.realmodulename^);
  907. read_interface_declarations;
  908. { leave when we got an error }
  909. if (Errorcount>0) and not status.skip_error then
  910. begin
  911. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  912. status.skip_error:=true;
  913. exit;
  914. end;
  915. { Our interface is compiled, generate CRC and switch to implementation }
  916. if not(cs_compilesystem in aktmoduleswitches) and
  917. (Errorcount=0) then
  918. tppumodule(current_module).getppucrc;
  919. current_module.in_interface:=false;
  920. current_module.interface_compiled:=true;
  921. { First reload all units depending on our interface, we need to do this
  922. in the implementation part to prevent errorneous circular references }
  923. reload_flagged_units;
  924. { Parse the implementation section }
  925. if (m_mac in aktmodeswitches) and try_to_consume(_END) then
  926. has_impl:= false
  927. else
  928. begin
  929. consume(_IMPLEMENTATION);
  930. has_impl:= true;
  931. end;
  932. if has_impl then
  933. Message1(unit_u_loading_implementation_units,current_module.modulename^);
  934. parse_only:=false;
  935. { generates static symbol table }
  936. st:=tstaticsymtable.create(current_module.modulename^);
  937. current_module.localsymtable:=st;
  938. { remove the globalsymtable from the symtable stack }
  939. { to reinsert it after loading the implementation units }
  940. symtablestack:=unitst.next;
  941. { we don't want implementation units symbols in unitsymtable !! PM }
  942. refsymtable:=st;
  943. { Read the implementation units }
  944. if has_impl then
  945. parse_implementation_uses;
  946. if current_module.state=ms_compiled then
  947. exit;
  948. { reset ranges/stabs in exported definitions }
  949. reset_all_defs;
  950. { All units are read, now give them a number }
  951. current_module.numberunits;
  952. { now we can change refsymtable }
  953. refsymtable:=st;
  954. { but reinsert the global symtable as lasts }
  955. unitst.next:=symtablestack;
  956. symtablestack:=unitst;
  957. {$ifdef DEBUG}
  958. test_symtablestack;
  959. {$endif DEBUG}
  960. constsymtable:=symtablestack;
  961. {$ifdef Splitheap}
  962. if testsplit then
  963. begin
  964. Split_Heap;
  965. allow_special:=true;
  966. Switch_to_temp_heap;
  967. end;
  968. { it will report all crossings }
  969. allow_special:=false;
  970. {$endif Splitheap}
  971. if has_impl then
  972. begin
  973. Message1(parser_u_parsing_implementation,current_module.modulename^);
  974. if current_module.in_interface then
  975. internalerror(200212285);
  976. { Compile the unit }
  977. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'init'),potype_unitinit,st);
  978. pd.aliasnames.insert(make_mangledname('INIT$',current_module.localsymtable,''));
  979. tcgprocinfo(current_procinfo).parse_body;
  980. tcgprocinfo(current_procinfo).generate_code;
  981. tcgprocinfo(current_procinfo).resetprocdef;
  982. release_main_proc(pd);
  983. end;
  984. { if the unit contains ansi/widestrings, initialization and
  985. finalization code must be forced }
  986. force_init_final:=tglobalsymtable(current_module.globalsymtable).needs_init_final or
  987. tstaticsymtable(current_module.localsymtable).needs_init_final;
  988. { should we force unit initialization? }
  989. { this is a hack, but how can it be done better ? }
  990. if force_init_final and ((current_module.flags and uf_init)=0) then
  991. gen_implicit_initfinal(uf_init,st);
  992. { finalize? }
  993. if has_impl and (token=_FINALIZATION) then
  994. begin
  995. { set module options }
  996. current_module.flags:=current_module.flags or uf_finalize;
  997. { Compile the finalize }
  998. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize'),potype_unitfinalize,st);
  999. pd.aliasnames.insert(make_mangledname('FINALIZE$',current_module.localsymtable,''));
  1000. tcgprocinfo(current_procinfo).parse_body;
  1001. tcgprocinfo(current_procinfo).generate_code;
  1002. tcgprocinfo(current_procinfo).resetprocdef;
  1003. release_main_proc(pd);
  1004. end
  1005. else if force_init_final then
  1006. gen_implicit_initfinal(uf_finalize,st);
  1007. { the last char should always be a point }
  1008. consume(_POINT);
  1009. { generate a list of threadvars }
  1010. InsertThreadvars;
  1011. { Generate resoucestrings }
  1012. If ResourceStrings.ResStrCount>0 then
  1013. begin
  1014. ResourceStrings.CreateResourceStringList;
  1015. current_module.flags:=current_module.flags or uf_has_resources;
  1016. { only write if no errors found }
  1017. if (Errorcount=0) then
  1018. ResourceStrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
  1019. end;
  1020. if (Errorcount=0) then
  1021. begin
  1022. { test static symtable }
  1023. tstoredsymtable(st).allsymbolsused;
  1024. tstoredsymtable(st).allprivatesused;
  1025. current_module.allunitsused;
  1026. end;
  1027. {$ifdef GDB}
  1028. write_gdb_info;
  1029. {$endif GDB}
  1030. if (Errorcount=0) then
  1031. begin
  1032. { tests, if all (interface) forwards are resolved }
  1033. tstoredsymtable(symtablestack).check_forwards;
  1034. { check if all private fields are used }
  1035. tstoredsymtable(symtablestack).allprivatesused;
  1036. { remove cross unit overloads }
  1037. tstoredsymtable(symtablestack).unchain_overloaded;
  1038. end;
  1039. { leave when we got an error }
  1040. if (Errorcount>0) and not status.skip_error then
  1041. begin
  1042. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1043. status.skip_error:=true;
  1044. exit;
  1045. end;
  1046. { generate imports }
  1047. if current_module.uses_imports then
  1048. importlib.generatelib;
  1049. { insert own objectfile, or say that it's in a library
  1050. (no check for an .o when loading) }
  1051. if is_assembler_generated then
  1052. insertobjectfile
  1053. else
  1054. current_module.flags:=current_module.flags or uf_no_link;
  1055. if cs_local_browser in aktmoduleswitches then
  1056. current_module.localsymtable:=refsymtable;
  1057. if is_assembler_generated then
  1058. begin
  1059. { finish asmlist by adding segment starts }
  1060. insertsegment;
  1061. { assemble }
  1062. create_objectfile;
  1063. end;
  1064. { Write out the ppufile after the object file has been created }
  1065. store_interface_crc:=current_module.interface_crc;
  1066. store_crc:=current_module.crc;
  1067. if (Errorcount=0) then
  1068. tppumodule(current_module).writeppu;
  1069. if not(cs_compilesystem in aktmoduleswitches) then
  1070. if store_interface_crc<>current_module.interface_crc then
  1071. Message1(unit_u_interface_crc_changed,current_module.ppufilename^);
  1072. {$ifdef EXTDEBUG}
  1073. if not(cs_compilesystem in aktmoduleswitches) then
  1074. if (store_crc<>current_module.crc) and simplify_ppu then
  1075. Message1(unit_u_implementation_crc_changed,current_module.ppufilename^);
  1076. {$endif EXTDEBUG}
  1077. { remove static symtable (=refsymtable) here to save some mem }
  1078. if not (cs_local_browser in aktmoduleswitches) then
  1079. begin
  1080. st.free;
  1081. current_module.localsymtable:=nil;
  1082. end;
  1083. { leave when we got an error }
  1084. if (Errorcount>0) and not status.skip_error then
  1085. begin
  1086. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1087. status.skip_error:=true;
  1088. exit;
  1089. end;
  1090. Message1(unit_u_finished_compiling,current_module.modulename^);
  1091. end;
  1092. procedure proc_program(islibrary : boolean);
  1093. var
  1094. main_file: tinputfile;
  1095. st : tsymtable;
  1096. hp : tmodule;
  1097. pd : tprocdef;
  1098. begin
  1099. DLLsource:=islibrary;
  1100. Status.IsLibrary:=IsLibrary;
  1101. Status.IsExe:=true;
  1102. parse_only:=false;
  1103. { relocation works only without stabs under win32 !! PM }
  1104. { internal assembler uses rva for stabs info
  1105. so it should work with relocated DLLs }
  1106. if RelocSection and
  1107. (target_info.system in [system_i386_win32,system_i386_wdosx]) and
  1108. (target_info.assem<>as_i386_pecoff) then
  1109. begin
  1110. include(aktglobalswitches,cs_link_strip);
  1111. { Warning stabs info does not work with reloc section !! }
  1112. if cs_debuginfo in aktmoduleswitches then
  1113. begin
  1114. Message1(parser_w_parser_reloc_no_debug,current_module.mainsource^);
  1115. Message(parser_w_parser_win32_debug_needs_WN);
  1116. exclude(aktmoduleswitches,cs_debuginfo);
  1117. end;
  1118. end;
  1119. { get correct output names }
  1120. main_file := current_scanner.inputfile;
  1121. while assigned(main_file.next) do
  1122. main_file := main_file.next;
  1123. current_module.SetFileName(main_file.path^+main_file.name^,true);
  1124. if islibrary then
  1125. begin
  1126. consume(_LIBRARY);
  1127. stringdispose(current_module.modulename);
  1128. current_module.modulename:=stringdup(pattern);
  1129. current_module.islibrary:=true;
  1130. exportlib.preparelib(pattern);
  1131. consume(_ID);
  1132. consume(_SEMICOLON);
  1133. end
  1134. else
  1135. { is there an program head ? }
  1136. if token=_PROGRAM then
  1137. begin
  1138. consume(_PROGRAM);
  1139. stringdispose(current_module.modulename);
  1140. stringdispose(current_module.realmodulename);
  1141. current_module.modulename:=stringdup(pattern);
  1142. current_module.realmodulename:=stringdup(orgpattern);
  1143. if (target_info.system in [system_i386_WIN32,system_i386_wdosx]) then
  1144. exportlib.preparelib(pattern);
  1145. consume(_ID);
  1146. if token=_LKLAMMER then
  1147. begin
  1148. consume(_LKLAMMER);
  1149. repeat
  1150. consume(_ID);
  1151. until not try_to_consume(_COMMA);
  1152. consume(_RKLAMMER);
  1153. end;
  1154. consume(_SEMICOLON);
  1155. end
  1156. else if (target_info.system in [system_i386_WIN32,system_i386_wdosx]) then
  1157. exportlib.preparelib(current_module.modulename^);
  1158. { global switches are read, so further changes aren't allowed }
  1159. current_module.in_global:=false;
  1160. { setup things using the global switches }
  1161. setupglobalswitches;
  1162. { set implementation flag }
  1163. current_module.in_interface:=false;
  1164. current_module.interface_compiled:=true;
  1165. { insert after the unit symbol tables the static symbol table }
  1166. { of the program }
  1167. st:=tstaticsymtable.create(current_module.modulename^);;
  1168. current_module.localsymtable:=st;
  1169. refsymtable:=st;
  1170. { load standard units (system,objpas,profile unit) }
  1171. loaddefaultunits;
  1172. {Load the units used by the program we compile.}
  1173. if token=_USES then
  1174. loadunits;
  1175. { reset ranges/stabs in exported definitions }
  1176. reset_all_defs;
  1177. { All units are read, now give them a number }
  1178. current_module.numberunits;
  1179. {Insert the name of the main program into the symbol table.}
  1180. if current_module.realmodulename^<>'' then
  1181. st.insert(tunitsym.create(current_module.realmodulename^,st));
  1182. { ...is also constsymtable, this is the symtable where }
  1183. { the elements of enumeration types are inserted }
  1184. constsymtable:=st;
  1185. Message1(parser_u_parsing_implementation,current_module.mainsource^);
  1186. { The program intialization needs an alias, so it can be called
  1187. from the bootstrap code.}
  1188. if islibrary or
  1189. (target_info.system in [system_powerpc_macos,system_powerpc_darwin]) then
  1190. begin
  1191. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'main'),potype_proginit,st);
  1192. { Win32 startup code needs a single name }
  1193. // if (target_info.system in [system_i386_win32,system_i386_wdosx]) then
  1194. pd.aliasnames.insert('PASCALMAIN');
  1195. end
  1196. else
  1197. begin
  1198. pd:=create_main_proc('main',potype_proginit,st);
  1199. pd.aliasnames.insert('PASCALMAIN');
  1200. end;
  1201. tcgprocinfo(current_procinfo).parse_body;
  1202. tcgprocinfo(current_procinfo).generate_code;
  1203. tcgprocinfo(current_procinfo).resetprocdef;
  1204. release_main_proc(pd);
  1205. { should we force unit initialization? }
  1206. if tstaticsymtable(current_module.localsymtable).needs_init_final then
  1207. begin
  1208. { initialize section }
  1209. gen_implicit_initfinal(uf_init,st);
  1210. { finalize section }
  1211. gen_implicit_initfinal(uf_finalize,st);
  1212. end;
  1213. { Add symbol to the exports section for win32 so smartlinking a
  1214. DLL will include the edata section }
  1215. if assigned(exportlib) and
  1216. (target_info.system in [system_i386_win32,system_i386_wdosx]) and
  1217. assigned(current_module._exports.first) then
  1218. codesegment.concat(tai_const_symbol.create(exportlib.edatalabel));
  1219. If ResourceStrings.ResStrCount>0 then
  1220. begin
  1221. ResourceStrings.CreateResourceStringList;
  1222. { only write if no errors found }
  1223. if (Errorcount=0) then
  1224. ResourceStrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
  1225. end;
  1226. { finalize? }
  1227. if token=_FINALIZATION then
  1228. begin
  1229. { set module options }
  1230. current_module.flags:=current_module.flags or uf_finalize;
  1231. { Compile the finalize }
  1232. pd:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize'),potype_unitfinalize,st);
  1233. pd.aliasnames.insert(make_mangledname('FINALIZE$',current_module.localsymtable,''));
  1234. tcgprocinfo(current_procinfo).parse_body;
  1235. tcgprocinfo(current_procinfo).generate_code;
  1236. tcgprocinfo(current_procinfo).resetprocdef;
  1237. release_main_proc(pd);
  1238. end;
  1239. { consume the last point }
  1240. consume(_POINT);
  1241. {$ifdef GDB}
  1242. write_gdb_info;
  1243. {$endif GDB}
  1244. { leave when we got an error }
  1245. if (Errorcount>0) and not status.skip_error then
  1246. begin
  1247. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1248. status.skip_error:=true;
  1249. exit;
  1250. end;
  1251. if (Errorcount=0) then
  1252. begin
  1253. { test static symtable }
  1254. tstoredsymtable(st).allsymbolsused;
  1255. tstoredsymtable(st).allprivatesused;
  1256. current_module.allunitsused;
  1257. end;
  1258. { generate a list of threadvars }
  1259. InsertThreadvars;
  1260. { generate imports }
  1261. if current_module.uses_imports then
  1262. importlib.generatelib;
  1263. if islibrary or
  1264. (target_info.system in [system_i386_WIN32,system_i386_wdosx]) or
  1265. (target_info.system=system_i386_NETWARE) then
  1266. exportlib.generatelib;
  1267. { insert Tables and Heap }
  1268. insertThreadVarTablesTable;
  1269. insertResourceTablesTable;
  1270. insertinitfinaltable;
  1271. insertheap;
  1272. insertstacklength;
  1273. // datasize:=symtablestack.datasize;
  1274. { finish asmlist by adding segment starts }
  1275. insertsegment;
  1276. { insert own objectfile }
  1277. insertobjectfile;
  1278. { assemble and link }
  1279. create_objectfile;
  1280. { leave when we got an error }
  1281. if (Errorcount>0) and not status.skip_error then
  1282. begin
  1283. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1284. status.skip_error:=true;
  1285. exit;
  1286. end;
  1287. { create the executable when we are at level 1 }
  1288. if (compile_level=1) then
  1289. begin
  1290. { insert all .o files from all loaded units }
  1291. hp:=tmodule(loaded_units.first);
  1292. while assigned(hp) do
  1293. begin
  1294. linker.AddModuleFiles(hp);
  1295. hp:=tmodule(hp.next);
  1296. end;
  1297. { write .def file }
  1298. if (cs_link_deffile in aktglobalswitches) then
  1299. deffile.writefile;
  1300. { finally we can create a executable }
  1301. if (not current_module.is_unit) then
  1302. begin
  1303. if DLLSource then
  1304. linker.MakeSharedLibrary
  1305. else
  1306. linker.MakeExecutable;
  1307. end;
  1308. end;
  1309. end;
  1310. end.
  1311. {
  1312. $Log$
  1313. Revision 1.150 2004-05-03 09:55:27 olle
  1314. + enable omitting of IMPLEMENTATION for mode mac
  1315. + added macro FPC_MAC for mode mac
  1316. Revision 1.149 2004/05/02 17:26:19 peter
  1317. * fix stabs for globals
  1318. Revision 1.148 2004/03/24 20:24:25 hajny
  1319. * OS/2 heap management modified to be able to grow heap as needed
  1320. Revision 1.147 2004/03/18 11:43:57 olle
  1321. * change AT_FUNCTION to AT_DATA where appropriate
  1322. Revision 1.146 2004/03/14 20:10:14 peter
  1323. * fix stabs lineno for fpc_compiled
  1324. Revision 1.145 2004/03/10 22:52:57 peter
  1325. * more stabs fixes
  1326. * special mode -gv for valgrind compatible stabs
  1327. Revision 1.144 2004/03/09 20:45:04 peter
  1328. * more stabs updates
  1329. Revision 1.143 2004/03/08 22:07:47 peter
  1330. * stabs updates to write stabs for def for all implictly used
  1331. units
  1332. Revision 1.142 2004/03/02 17:32:12 florian
  1333. * make cycle fixed
  1334. + pic support for darwin
  1335. + support of importing vars from shared libs on darwin implemented
  1336. Revision 1.141 2004/03/02 00:36:33 olle
  1337. * big transformation of Tai_[const_]Symbol.Create[data]name*
  1338. Revision 1.140 2004/02/26 16:16:38 peter
  1339. * tai_const.create_ptr added
  1340. Revision 1.139 2004/02/06 22:37:00 daniel
  1341. * Removed not very usefull nextglobal & previousglobal fields from
  1342. Tstoreddef, saving 78 kb of memory
  1343. Revision 1.138 2004/02/04 22:15:15 daniel
  1344. * Rtti generation moved to ncgutil
  1345. * Assmtai usage of symsym removed
  1346. * operator overloading cleanup up
  1347. Revision 1.137 2004/01/28 16:48:24 peter
  1348. use local string of 8 chars
  1349. Revision 1.136 2004/01/04 21:08:09 jonas
  1350. * Never generate a "main" symbol for PASCALMAIN for Darwin and classic
  1351. Mac OS, they use a C-main in their system unit
  1352. Revision 1.135 2003/12/12 19:42:21 peter
  1353. * check unit name when expected unitname > 8 chars
  1354. Revision 1.134 2003/12/08 22:33:43 peter
  1355. * don't allow duplicate uses
  1356. * fix wrong circular dependency
  1357. Revision 1.133 2003/11/29 20:13:25 florian
  1358. * fixed several pi_do_call problems
  1359. Revision 1.132 2003/10/29 19:48:51 peter
  1360. * renamed mangeldname_prefix to make_mangledname and made it more
  1361. generic
  1362. * make_mangledname is now also used for internal threadvar/resstring
  1363. lists
  1364. * Add P$ in front of program modulename to prevent duplicated symbols
  1365. at assembler level, because the main program can have the same name
  1366. as a unit, see webtbs/tw1251b
  1367. Revision 1.131 2003/10/24 17:40:23 peter
  1368. * cleanup of the entry and exit code insertion
  1369. Revision 1.130 2003/10/22 15:22:33 peter
  1370. * fixed unitsym-globalsymtable relation so the uses of a unit
  1371. is counted correctly
  1372. Revision 1.129 2003/10/21 15:14:33 peter
  1373. * fixed memleak for initfinalcode
  1374. * exit from generatecode when there are already errors
  1375. Revision 1.128 2003/10/01 20:34:49 peter
  1376. * procinfo unit contains tprocinfo
  1377. * cginfo renamed to cgbase
  1378. * moved cgmessage to verbose
  1379. * fixed ppc and sparc compiles
  1380. Revision 1.127 2003/09/30 08:39:50 michael
  1381. + Patch from Wiktor Sywula for watcom support
  1382. Revision 1.126 2003/09/23 18:03:08 peter
  1383. * add missing release of main_proc
  1384. Revision 1.125 2003/09/23 17:56:05 peter
  1385. * locals and paras are allocated in the code generation
  1386. * tvarsym.localloc contains the location of para/local when
  1387. generating code for the current procedure
  1388. Revision 1.124 2003/09/09 20:59:27 daniel
  1389. * Adding register allocation order
  1390. Revision 1.123 2003/09/09 15:55:44 peter
  1391. * use register with least interferences in spillregister
  1392. Revision 1.122 2003/09/07 22:09:35 peter
  1393. * preparations for different default calling conventions
  1394. * various RA fixes
  1395. Revision 1.121 2003/09/05 17:41:12 florian
  1396. * merged Wiktor's Watcom patches in 1.1
  1397. Revision 1.120 2003/08/23 22:29:24 peter
  1398. * reload flagged units when interface is loaded
  1399. Revision 1.119 2003/08/21 14:47:41 peter
  1400. * remove convert_registers
  1401. Revision 1.118 2003/08/20 17:48:49 peter
  1402. * fixed stackalloc to not allocate localst.datasize twice
  1403. * order of stackalloc code fixed for implicit init/final
  1404. Revision 1.117 2003/08/20 09:07:00 daniel
  1405. * New register coding now mandatory, some more convert_registers calls
  1406. removed.
  1407. Revision 1.116 2003/07/23 11:04:15 jonas
  1408. * split en_exit_code into a part that may allocate a register and a part
  1409. that doesn't, so the former can be done before the register colouring
  1410. has been performed
  1411. Revision 1.115 2003/07/06 17:58:22 peter
  1412. * framepointer fixes for sparc
  1413. * parent framepointer code more generic
  1414. Revision 1.114 2003/06/13 21:19:31 peter
  1415. * current_procdef removed, use current_procinfo.procdef instead
  1416. Revision 1.113 2003/06/09 12:23:30 peter
  1417. * init/final of procedure data splitted from genentrycode
  1418. * use asmnode getposition to insert final at the correct position
  1419. als for the implicit try...finally
  1420. Revision 1.112 2003/06/07 20:26:32 peter
  1421. * re-resolving added instead of reloading from ppu
  1422. * tderef object added to store deref info for resolving
  1423. Revision 1.111 2003/06/03 20:21:45 mazen
  1424. - removed unneeded ifdefs
  1425. - removed unneeded cases for sparc and x86_64
  1426. Revision 1.110 2003/06/03 13:01:59 daniel
  1427. * Register allocator finished
  1428. Revision 1.109 2003/05/26 21:17:17 peter
  1429. * procinlinenode removed
  1430. * aktexit2label removed, fast exit removed
  1431. + tcallnode.inlined_pass_2 added
  1432. Revision 1.108 2003/05/25 10:27:12 peter
  1433. * moved Comment calls to messge file
  1434. Revision 1.107 2003/05/22 21:31:35 peter
  1435. * defer codegeneration for nested procedures
  1436. Revision 1.106 2003/05/15 18:58:53 peter
  1437. * removed selfpointer_offset, vmtpointer_offset
  1438. * tvarsym.adjusted_address
  1439. * address in localsymtable is now in the real direction
  1440. * removed some obsolete globals
  1441. Revision 1.105 2003/05/11 19:31:28 florian
  1442. * fixed implicit init/final code for units, stack frame was wrong for ppc
  1443. Revision 1.104 2003/04/28 21:19:02 peter
  1444. * fix stabs generation for implicit initfinal
  1445. Revision 1.103 2003/04/27 11:21:34 peter
  1446. * aktprocdef renamed to current_procinfo.procdef
  1447. * procinfo renamed to current_procinfo
  1448. * procinfo will now be stored in current_module so it can be
  1449. cleaned up properly
  1450. * gen_main_procsym changed to create_main_proc and release_main_proc
  1451. to also generate a tprocinfo structure
  1452. * fixed unit implicit initfinal
  1453. Revision 1.102 2003/04/27 07:29:50 peter
  1454. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  1455. a new procdef declaration
  1456. * aktprocsym removed
  1457. * lexlevel removed, use symtable.symtablelevel instead
  1458. * implicit init/final code uses the normal genentry/genexit
  1459. * funcret state checking updated for new funcret handling
  1460. Revision 1.101 2003/04/23 12:35:34 florian
  1461. * fixed several issues with powerpc
  1462. + applied a patch from Jonas for nested function calls (PowerPC only)
  1463. * ...
  1464. Revision 1.100 2003/04/12 15:13:03 peter
  1465. * Use the original unitname when defining a unitsym
  1466. Revision 1.99 2003/03/23 23:21:42 hajny
  1467. + emx target added
  1468. Revision 1.98 2003/03/17 22:20:08 peter
  1469. *** empty log message ***
  1470. Revision 1.97 2003/03/17 13:36:39 peter
  1471. * fix import linking under linux
  1472. Revision 1.96 2003/02/19 22:00:14 daniel
  1473. * Code generator converted to new register notation
  1474. - Horribily outdated todo.txt removed
  1475. Revision 1.95 2003/02/06 22:36:55 mazen
  1476. * fixing bug related to errornous program main entry stack frame
  1477. Revision 1.94 2003/01/30 21:46:20 peter
  1478. * tai_const_symbol.createdataname added
  1479. Revision 1.93 2003/01/11 11:19:54 hajny
  1480. * correction from rev. 1.88 put back
  1481. Revision 1.92 2003/01/08 18:43:56 daniel
  1482. * Tregister changed into a record
  1483. Revision 1.91 2003/01/05 13:36:53 florian
  1484. * x86-64 compiles
  1485. + very basic support for float128 type (x86-64 only)
  1486. Revision 1.90 2002/12/29 18:17:23 peter
  1487. * insert unitsym with the name as specified in the uses list
  1488. Revision 1.89 2002/12/29 14:57:50 peter
  1489. * unit loading changed to first register units and load them
  1490. afterwards. This is needed to support uses xxx in yyy correctly
  1491. * unit dependency check fixed
  1492. Revision 1.88 2002/12/27 19:09:33 hajny
  1493. * another (hopefully final ;-) ) fix for not linked import libraries for units with no code
  1494. Revision 1.87 2002/12/24 23:32:56 peter
  1495. * Use FixFilename for specified unit sourcefile in uses
  1496. Revision 1.86 2002/12/06 16:56:58 peter
  1497. * only compile cs_fp_emulation support when cpufpuemu is defined
  1498. * define cpufpuemu for m68k only
  1499. Revision 1.85 2002/11/30 21:32:24 carl
  1500. + Add loading of softfpu in emulation mode
  1501. + Correct routine call for softfpu
  1502. * Extended type must also be defined even with softfpu
  1503. Revision 1.84 2002/11/15 01:58:53 peter
  1504. * merged changes from 1.0.7 up to 04-11
  1505. - -V option for generating bug report tracing
  1506. - more tracing for option parsing
  1507. - errors for cdecl and high()
  1508. - win32 import stabs
  1509. - win32 records<=8 are returned in eax:edx (turned off by default)
  1510. - heaptrc update
  1511. - more info for temp management in .s file with EXTDEBUG
  1512. Revision 1.83 2002/11/09 15:33:26 carl
  1513. * major alignment updates
  1514. Revision 1.82 2002/10/16 06:32:52 michael
  1515. + Renamed thread unit to systhrds
  1516. Revision 1.81 2002/10/14 19:42:34 peter
  1517. * only use init tables for threadvars
  1518. Revision 1.80 2002/10/06 19:41:30 peter
  1519. * Add finalization of typed consts
  1520. * Finalization of globals in the main program
  1521. Revision 1.79 2002/09/09 17:34:15 peter
  1522. * tdicationary.replace added to replace and item in a dictionary. This
  1523. is only allowed for the same name
  1524. * varsyms are inserted in symtable before the types are parsed. This
  1525. fixes the long standing "var longint : longint" bug
  1526. - consume_idlist and idstringlist removed. The loops are inserted
  1527. at the callers place and uses the symtable for duplicate id checking
  1528. Revision 1.78 2002/09/07 15:25:07 peter
  1529. * old logs removed and tabs fixed
  1530. Revision 1.77 2002/09/03 16:26:27 daniel
  1531. * Make Tprocdef.defs protected
  1532. Revision 1.76 2002/09/02 18:46:26 peter
  1533. * insert PASCALMAIN in library for Win32 only
  1534. Revision 1.75 2002/08/31 15:59:30 florian
  1535. + HEAP* stuff must be generated for Linux/PPC as well
  1536. + direct assembler reader searches now global and static symtables as well
  1537. Revision 1.74 2002/08/25 19:25:20 peter
  1538. * sym.insert_in_data removed
  1539. * symtable.insertvardata/insertconstdata added
  1540. * removed insert_in_data call from symtable.insert, it needs to be
  1541. called separatly. This allows to deref the address calculation
  1542. * procedures now calculate the parast addresses after the procedure
  1543. directives are parsed. This fixes the cdecl parast problem
  1544. * push_addr_param has an extra argument that specifies if cdecl is used
  1545. or not
  1546. Revision 1.73 2002/08/18 20:06:25 peter
  1547. * inlining is now also allowed in interface
  1548. * renamed write/load to ppuwrite/ppuload
  1549. * tnode storing in ppu
  1550. * nld,ncon,nbas are already updated for storing in ppu
  1551. Revision 1.72 2002/08/17 09:23:39 florian
  1552. * first part of procinfo rewrite
  1553. Revision 1.71 2002/08/11 13:24:12 peter
  1554. * saving of asmsymbols in ppu supported
  1555. * asmsymbollist global is removed and moved into a new class
  1556. tasmlibrarydata that will hold the info of a .a file which
  1557. corresponds with a single module. Added librarydata to tmodule
  1558. to keep the library info stored for the module. In the future the
  1559. objectfiles will also be stored to the tasmlibrarydata class
  1560. * all getlabel/newasmsymbol and friends are moved to the new class
  1561. Revision 1.70 2002/08/10 14:46:29 carl
  1562. + moved target_cpu_string to cpuinfo
  1563. * renamed asmmode enum.
  1564. * assembler reader has now less ifdef's
  1565. * move from nppcmem.pas -> ncgmem.pas vec. node.
  1566. Revision 1.69 2002/07/26 21:15:41 florian
  1567. * rewrote the system handling
  1568. Revision 1.68 2002/07/04 20:43:01 florian
  1569. * first x86-64 patches
  1570. Revision 1.67 2002/07/01 18:46:25 peter
  1571. * internal linker
  1572. * reorganized aasm layer
  1573. Revision 1.66 2002/05/16 19:46:43 carl
  1574. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1575. + try to fix temp allocation (still in ifdef)
  1576. + generic constructor calls
  1577. + start of tassembler / tmodulebase class cleanup
  1578. Revision 1.65 2002/05/14 19:34:49 peter
  1579. * removed old logs and updated copyright year
  1580. Revision 1.64 2002/05/12 16:53:09 peter
  1581. * moved entry and exitcode to ncgutil and cgobj
  1582. * foreach gets extra argument for passing local data to the
  1583. iterator function
  1584. * -CR checks also class typecasts at runtime by changing them
  1585. into as
  1586. * fixed compiler to cycle with the -CR option
  1587. * fixed stabs with elf writer, finally the global variables can
  1588. be watched
  1589. * removed a lot of routines from cga unit and replaced them by
  1590. calls to cgobj
  1591. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1592. u32bit then the other is typecasted also to u32bit without giving
  1593. a rangecheck warning/error.
  1594. * fixed pascal calling method with reversing also the high tree in
  1595. the parast, detected by tcalcst3 test
  1596. Revision 1.63 2002/05/06 19:54:50 carl
  1597. + added more patches from Mazen for SPARC port
  1598. Revision 1.62 2002/04/20 21:32:24 carl
  1599. + generic FPC_CHECKPOINTER
  1600. + first parameter offset in stack now portable
  1601. * rename some constants
  1602. + move some cpu stuff to other units
  1603. - remove unused constents
  1604. * fix stacksize for some targets
  1605. * fix generic size problems which depend now on EXTEND_SIZE constant
  1606. Revision 1.61 2002/04/19 15:46:02 peter
  1607. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  1608. in most cases and not written to the ppu
  1609. * add mangeledname_prefix() routine to generate the prefix of
  1610. manglednames depending on the current procedure, object and module
  1611. * removed static procprefix since the mangledname is now build only
  1612. on demand from tprocdef.mangledname
  1613. Revision 1.60 2002/04/14 16:53:10 carl
  1614. + align code section and data section according to alignment rules
  1615. Revision 1.59 2002/04/07 17:58:38 carl
  1616. + generic stack checking
  1617. Revision 1.58 2002/04/04 19:06:03 peter
  1618. * removed unused units
  1619. * use tlocation.size in cg.a_*loc*() routines
  1620. }