pmodules.pas 69 KB

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