pmodules.pas 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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 defines.inc}
  20. {$define New_GDB}
  21. interface
  22. procedure proc_unit;
  23. procedure proc_program(islibrary : boolean);
  24. implementation
  25. uses
  26. globtype,version,systems,tokens,
  27. cutils,comphook,
  28. globals,verbose,fmodule,finput,fppu,
  29. symconst,symbase,symppu,symdef,symsym,symtable,aasm,
  30. {$ifdef newcg}
  31. cgbase,
  32. {$else newcg}
  33. hcodegen,
  34. {$ifdef i386}
  35. cgai386,
  36. {$endif i386}
  37. {$endif newcg}
  38. link,assemble,import,export,gendef,ppu,comprsrc,
  39. cresstr,cpubase,cpuasm,
  40. {$ifdef GDB}
  41. gdb,
  42. {$endif GDB}
  43. scanner,pbase,psystem,psub,parser;
  44. procedure create_objectfile;
  45. var
  46. DLLScanner : TDLLScanner;
  47. s : string;
  48. begin
  49. { try to create import entries from system dlls }
  50. if target_info.DllScanSupported and
  51. (not current_module.linkOtherSharedLibs.Empty) then
  52. begin
  53. { Init DLLScanner }
  54. if assigned(CDLLScanner[target_info.target]) then
  55. DLLScanner:=CDLLScanner[target_info.target].Create
  56. else
  57. internalerror(200104121);
  58. { Walk all shared libs }
  59. While not current_module.linkOtherSharedLibs.Empty do
  60. begin
  61. S:=current_module.linkOtherSharedLibs.Getusemask(link_allways);
  62. DLLScanner.scan(s)
  63. end;
  64. DLLscanner.Free;
  65. { Recreate import section }
  66. if (target_info.target=target_i386_win32) then
  67. begin
  68. if assigned(importssection)then
  69. importssection.clear
  70. else
  71. importssection:=taasmoutput.Create;
  72. importlib.generatelib;
  73. end;
  74. end;
  75. { create the .s file and assemble it }
  76. GenerateAsm(false);
  77. { Also create a smartlinked version ? }
  78. if (cs_create_smart in aktmoduleswitches) then
  79. begin
  80. { regenerate the importssection for win32 }
  81. if assigned(importssection) and
  82. (target_info.target=target_i386_win32) then
  83. begin
  84. importsSection.clear;
  85. importlib.generatesmartlib;
  86. end;
  87. GenerateAsm(true);
  88. if target_asm.needar then
  89. Linker.MakeStaticLibrary;
  90. end;
  91. { resource files }
  92. CompileResourceFiles;
  93. end;
  94. procedure insertobjectfile;
  95. { Insert the used object file for this unit in the used list for this unit }
  96. begin
  97. current_module.linkunitofiles.add(current_module.objfilename^,link_static);
  98. current_module.flags:=current_module.flags or uf_static_linked;
  99. if (cs_create_smart in aktmoduleswitches) then
  100. begin
  101. current_module.linkunitstaticlibs.add(current_module.staticlibfilename^,link_smart);
  102. current_module.flags:=current_module.flags or uf_smart_linked;
  103. end;
  104. end;
  105. procedure insertsegment;
  106. procedure fixseg(p:TAAsmoutput;sec:tsection);
  107. begin
  108. p.insert(Tai_section.Create(sec));
  109. if (cs_create_smart in aktmoduleswitches) then
  110. p.insert(Tai_cut.Create);
  111. p.concat(Tai_section.Create(sec_none));
  112. end;
  113. begin
  114. { Insert Ident of the compiler }
  115. if (not (cs_create_smart in aktmoduleswitches))
  116. {$ifndef EXTDEBUG}
  117. and (not current_module.is_unit)
  118. {$endif}
  119. then
  120. begin
  121. dataSegment.insert(Tai_align.Create(4));
  122. dataSegment.insert(Tai_string.Create('FPC '+full_version_string+
  123. ' ['+date_string+'] for '+target_cpu_string+' - '+target_info.shortname));
  124. end;
  125. { finish codesegment }
  126. {$ifdef i386}
  127. codeSegment.concat(Tai_align.Create(16));
  128. {$else}
  129. if cs_littlesize in aktglobalswitches then
  130. codesegment.concat(tai_align.create(2))
  131. else
  132. codesegment.concat(tai_align.create(4));
  133. {$endif}
  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. if assigned(resourcestringlist) then
  143. fixseg(resourcestringlist,sec_data);
  144. {$ifdef GDB}
  145. if assigned(debuglist) then
  146. begin
  147. debugList.insert(Tai_symbol.Createname('gcc2_compiled',0));
  148. debugList.insert(Tai_symbol.Createname('fpc_compiled',0));
  149. fixseg(debuglist,sec_code);
  150. end;
  151. {$endif GDB}
  152. end;
  153. Procedure InsertResourceTablesTable;
  154. var
  155. hp : tused_unit;
  156. ResourceStringTables : taasmoutput;
  157. count : longint;
  158. begin
  159. ResourceStringTables:=TAAsmOutput.Create;
  160. count:=0;
  161. hp:=tused_unit(usedunits.first);
  162. while assigned(hp) do
  163. begin
  164. If (hp.u.flags and uf_has_resources)=uf_has_resources then
  165. begin
  166. ResourceStringTables.concat(Tai_const_symbol.Createname(hp.u.modulename^+'_RESOURCESTRINGLIST'));
  167. inc(count);
  168. end;
  169. hp:=tused_unit(hp.next);
  170. end;
  171. { Add program resources, if any }
  172. If ResourceStringList<>Nil then
  173. begin
  174. ResourceStringTables.concat(Tai_const_symbol.Createname(current_module.modulename^+'_RESOURCESTRINGLIST'));
  175. Inc(Count);
  176. end;
  177. { TableCount }
  178. ResourceStringTables.insert(Tai_const.Create_32bit(count));
  179. ResourceStringTables.insert(Tai_symbol.Createdataname_global('FPC_RESOURCESTRINGTABLES',0));
  180. ResourceStringTables.concat(Tai_symbol_end.Createname('FPC_RESOURCESTRINGTABLES'));
  181. { insert in data segment }
  182. if (cs_create_smart in aktmoduleswitches) then
  183. dataSegment.concat(Tai_cut.Create);
  184. dataSegment.concatlist(ResourceStringTables);
  185. ResourceStringTables.free;
  186. end;
  187. procedure InsertInitFinalTable;
  188. var
  189. hp : tused_unit;
  190. unitinits : taasmoutput;
  191. count : longint;
  192. begin
  193. unitinits:=TAAsmOutput.Create;
  194. count:=0;
  195. hp:=tused_unit(usedunits.first);
  196. while assigned(hp) do
  197. begin
  198. { call the unit init code and make it external }
  199. if (hp.u.flags and (uf_init or uf_finalize))<>0 then
  200. begin
  201. if (hp.u.flags and uf_init)<>0 then
  202. unitinits.concat(Tai_const_symbol.Createname('INIT$$'+hp.u.modulename^))
  203. else
  204. unitinits.concat(Tai_const.Create_32bit(0));
  205. if (hp.u.flags and uf_finalize)<>0 then
  206. unitinits.concat(Tai_const_symbol.Createname('FINALIZE$$'+hp.u.modulename^))
  207. else
  208. unitinits.concat(Tai_const.Create_32bit(0));
  209. inc(count);
  210. end;
  211. hp:=tused_unit(hp.next);
  212. end;
  213. if current_module.islibrary then
  214. if (current_module.flags and uf_finalize)<>0 then
  215. begin
  216. { INIT code is done by PASCALMAIN calling }
  217. unitinits.concat(Tai_const.Create_32bit(0));
  218. unitinits.concat(Tai_const_symbol.Createname('FINALIZE$$'+current_module.modulename^));
  219. inc(count);
  220. end;
  221. { TableCount,InitCount }
  222. unitinits.insert(Tai_const.Create_32bit(0));
  223. unitinits.insert(Tai_const.Create_32bit(count));
  224. unitinits.insert(Tai_symbol.Createdataname_global('INITFINAL',0));
  225. unitinits.concat(Tai_symbol_end.Createname('INITFINAL'));
  226. { insert in data segment }
  227. if (cs_create_smart in aktmoduleswitches) then
  228. dataSegment.concat(Tai_cut.Create);
  229. dataSegment.concatlist(unitinits);
  230. unitinits.free;
  231. end;
  232. procedure insertheap;
  233. begin
  234. if (cs_create_smart in aktmoduleswitches) then
  235. begin
  236. bssSegment.concat(Tai_cut.Create);
  237. dataSegment.concat(Tai_cut.Create);
  238. end;
  239. { On the Macintosh Classic M68k Architecture
  240. The Heap variable is simply a POINTER to the
  241. real HEAP. The HEAP must be set up by the RTL
  242. and must store the pointer in this value.
  243. On OS/2 the heap is also intialized by the RTL. We do
  244. not output a pointer }
  245. case target_info.target of
  246. {$ifdef i386}
  247. target_i386_OS2:
  248. ;
  249. {$endif i386}
  250. {$ifdef alpha}
  251. target_alpha_linux:
  252. ;
  253. {$endif alpha}
  254. {$ifdef powerpc}
  255. target_powerpc_linux:
  256. ;
  257. {$endif powerpc}
  258. {$ifdef m68k}
  259. target_m68k_Mac:
  260. bssSegment.concat(Tai_datablock.Create_global('HEAP',4));
  261. target_m68k_PalmOS:
  262. ;
  263. {$endif m68k}
  264. else
  265. bssSegment.concat(Tai_datablock.Create_global('HEAP',heapsize));
  266. end;
  267. {$ifdef m68k}
  268. if target_info.target<>target_m68k_PalmOS then
  269. begin
  270. dataSegment.concat(Tai_symbol.Createdataname_global('HEAP_SIZE',0));
  271. dataSegment.concat(Tai_const.Create_32bit(heapsize));
  272. end;
  273. {$else m68k}
  274. dataSegment.concat(Tai_symbol.Createdataname_global('HEAPSIZE',4));
  275. dataSegment.concat(Tai_const.Create_32bit(heapsize));
  276. {$endif m68k}
  277. end;
  278. procedure inserttargetspecific;
  279. begin
  280. case target_info.target of
  281. {$ifdef alpha}
  282. target_alpha_linux:
  283. ;
  284. {$endif alpha}
  285. {$ifdef powerpc}
  286. target_powerpc_linux:
  287. ;
  288. {$endif powerpc}
  289. {$ifdef i386}
  290. target_i386_GO32V2 :
  291. begin
  292. { stacksize can be specified }
  293. dataSegment.concat(Tai_symbol.Createdataname_global('__stklen',4));
  294. dataSegment.concat(Tai_const.Create_32bit(stacksize));
  295. end;
  296. {$endif i386}
  297. {$ifdef m68k}
  298. target_m68k_Atari :
  299. begin
  300. { stacksize can be specified }
  301. dataSegment.concat(Tai_symbol.Createdataname_global('__stklen',4));
  302. dataSegment.concat(Tai_const.Create_32bit(stacksize));
  303. end;
  304. {$endif m68k}
  305. end;
  306. end;
  307. procedure loaddefaultunits;
  308. var
  309. hp : tmodule;
  310. unitsym : tunitsym;
  311. begin
  312. { are we compiling the system unit? }
  313. if (cs_compilesystem in aktmoduleswitches) then
  314. begin
  315. { create system defines }
  316. createconstdefs;
  317. { we don't need to reset anything, it's already done in parser.pas }
  318. exit;
  319. end;
  320. { insert the system unit, it is allways the first }
  321. hp:=loadunit('System');
  322. systemunit:=tglobalsymtable(hp.globalsymtable);
  323. { it's always the first unit }
  324. systemunit.next:=nil;
  325. symtablestack:=systemunit;
  326. { add to the used units }
  327. current_module.used_units.concat(tused_unit.create(hp,true));
  328. unitsym:=tunitsym.create('System',systemunit);
  329. inc(unitsym.refs);
  330. refsymtable.insert(unitsym);
  331. { read default constant definitions }
  332. make_ref:=false;
  333. readconstdefs;
  334. make_ref:=true;
  335. { Objpas unit? }
  336. if m_objpas in aktmodeswitches then
  337. begin
  338. hp:=loadunit('ObjPas');
  339. tsymtable(hp.globalsymtable).next:=symtablestack;
  340. symtablestack:=hp.globalsymtable;
  341. { add to the used units }
  342. current_module.used_units.concat(tused_unit.create(hp,true));
  343. unitsym:=tunitsym.create('ObjPas',hp.globalsymtable);
  344. inc(unitsym.refs);
  345. refsymtable.insert(unitsym);
  346. end;
  347. { Profile unit? Needed for go32v2 only }
  348. if (cs_profile in aktmoduleswitches) and (target_info.target=target_i386_go32v2) then
  349. begin
  350. hp:=loadunit('Profile');
  351. tsymtable(hp.globalsymtable).next:=symtablestack;
  352. symtablestack:=hp.globalsymtable;
  353. { add to the used units }
  354. current_module.used_units.concat(tused_unit.create(hp,true));
  355. unitsym:=tunitsym.create('Profile',hp.globalsymtable);
  356. inc(unitsym.refs);
  357. refsymtable.insert(unitsym);
  358. end;
  359. { Units only required for main module }
  360. if not(current_module.is_unit) then
  361. begin
  362. { Heaptrc unit }
  363. if (cs_gdb_heaptrc in aktglobalswitches) then
  364. begin
  365. hp:=loadunit('HeapTrc');
  366. tsymtable(hp.globalsymtable).next:=symtablestack;
  367. symtablestack:=hp.globalsymtable;
  368. { add to the used units }
  369. current_module.used_units.concat(tused_unit.create(hp,true));
  370. unitsym:=tunitsym.create('HeapTrc',hp.globalsymtable);
  371. inc(unitsym.refs);
  372. refsymtable.insert(unitsym);
  373. end;
  374. { Lineinfo unit }
  375. if (cs_gdb_lineinfo in aktglobalswitches) then
  376. begin
  377. hp:=loadunit('LineInfo');
  378. tsymtable(hp.globalsymtable).next:=symtablestack;
  379. symtablestack:=hp.globalsymtable;
  380. { add to the used units }
  381. current_module.used_units.concat(tused_unit.create(hp,true));
  382. unitsym:=tunitsym.create('LineInfo',hp.globalsymtable);
  383. inc(unitsym.refs);
  384. refsymtable.insert(unitsym);
  385. end;
  386. end;
  387. { save default symtablestack }
  388. defaultsymtablestack:=symtablestack;
  389. end;
  390. procedure loadunits;
  391. var
  392. s,sorg : stringid;
  393. pu,
  394. hp : tused_unit;
  395. hp2 : tmodule;
  396. hp3 : tsymtable;
  397. oldprocsym:tprocsym;
  398. unitsym : tunitsym;
  399. begin
  400. oldprocsym:=aktprocsym;
  401. consume(_USES);
  402. {$ifdef DEBUG}
  403. test_symtablestack;
  404. {$endif DEBUG}
  405. repeat
  406. s:=pattern;
  407. sorg:=orgpattern;
  408. consume(_ID);
  409. { Give a warning if objpas is loaded }
  410. if s='OBJPAS' then
  411. Message(parser_w_no_objpas_use_mode);
  412. { check if the unit is already used }
  413. pu:=tused_unit(current_module.used_units.first);
  414. while assigned(pu) do
  415. begin
  416. if (pu.name^=s) then
  417. break;
  418. pu:=tused_unit(pu.next);
  419. end;
  420. { avoid uses of itself }
  421. if not assigned(pu) and (s<>current_module.modulename^) then
  422. begin
  423. { load the unit }
  424. hp2:=loadunit(sorg);
  425. { the current module uses the unit hp2 }
  426. current_module.used_units.concat(tused_unit.create(hp2,not current_module.in_implementation));
  427. tused_unit(current_module.used_units.last).in_uses:=true;
  428. if current_module.compiled then
  429. exit;
  430. unitsym:=tunitsym.create(sorg,hp2.globalsymtable);
  431. { never claim about unused unit if
  432. there is init or finalize code PM }
  433. if (hp2.flags and (uf_init or uf_finalize))<>0 then
  434. inc(unitsym.refs);
  435. refsymtable.insert(unitsym);
  436. end
  437. else
  438. Message1(sym_e_duplicate_id,s);
  439. if token=_COMMA then
  440. begin
  441. pattern:='';
  442. consume(_COMMA);
  443. end
  444. else
  445. break;
  446. until false;
  447. consume(_SEMICOLON);
  448. { set the symtable to systemunit so it gets reorderd correctly }
  449. symtablestack:=defaultsymtablestack;
  450. { now insert the units in the symtablestack }
  451. hp:=tused_unit(current_module.used_units.first);
  452. while assigned(hp) do
  453. begin
  454. {$IfDef GDB}
  455. if (cs_debuginfo in aktmoduleswitches) and
  456. (cs_gdb_dbx in aktglobalswitches) and
  457. not hp.is_stab_written then
  458. begin
  459. tglobalsymtable(hp.u.globalsymtable).concattypestabto(debuglist);
  460. hp.is_stab_written:=true;
  461. hp.unitid:=tsymtable(hp.u.globalsymtable).unitid;
  462. end;
  463. {$EndIf GDB}
  464. if hp.in_uses then
  465. begin
  466. hp3:=symtablestack;
  467. while assigned(hp3) do
  468. begin
  469. { insert units only once ! }
  470. if hp.u.globalsymtable=hp3 then
  471. break;
  472. hp3:=hp3.next;
  473. { unit isn't inserted }
  474. if hp3=nil then
  475. begin
  476. tsymtable(hp.u.globalsymtable).next:=symtablestack;
  477. symtablestack:=tsymtable(hp.u.globalsymtable);
  478. {$ifdef CHAINPROCSYMS}
  479. symtablestack.chainprocsyms;
  480. {$endif CHAINPROCSYMS}
  481. {$ifdef DEBUG}
  482. test_symtablestack;
  483. {$endif DEBUG}
  484. end;
  485. end;
  486. end;
  487. hp:=tused_unit(hp.next);
  488. end;
  489. aktprocsym:=oldprocsym;
  490. end;
  491. procedure write_gdb_info;
  492. {$IfDef GDB}
  493. var
  494. hp : tused_unit;
  495. begin
  496. if not (cs_debuginfo in aktmoduleswitches) then
  497. exit;
  498. if (cs_gdb_dbx in aktglobalswitches) then
  499. begin
  500. debugList.concat(Tai_asm_comment.Create(strpnew('EINCL of global '+
  501. tglobalsymtable(current_module.globalsymtable).name^+' has index '+
  502. tostr(tglobalsymtable(current_module.globalsymtable).unitid))));
  503. debugList.concat(Tai_stabs.Create(strpnew('"'+
  504. tglobalsymtable(current_module.globalsymtable).name^+'",'+
  505. tostr(N_EINCL)+',0,0,0')));
  506. tglobalsymtable(current_module.globalsymtable).dbx_count_ok:={true}false;
  507. dbx_counter:=tglobalsymtable(current_module.globalsymtable).prev_dbx_counter;
  508. do_count_dbx:=false;
  509. end;
  510. { now insert the units in the symtablestack }
  511. hp:=tused_unit(current_module.used_units.first);
  512. while assigned(hp) do
  513. begin
  514. if (cs_debuginfo in aktmoduleswitches) and
  515. not hp.is_stab_written then
  516. begin
  517. tglobalsymtable(hp.u.globalsymtable).concattypestabto(debuglist);
  518. hp.is_stab_written:=true;
  519. hp.unitid:=tsymtable(hp.u.globalsymtable).unitid;
  520. end;
  521. hp:=tused_unit(hp.next);
  522. end;
  523. if current_module.in_implementation and
  524. assigned(current_module.localsymtable) then
  525. begin
  526. { all types }
  527. tstaticsymtable(current_module.localsymtable).concattypestabto(debuglist);
  528. { and all local symbols}
  529. tstaticsymtable(current_module.localsymtable).concatstabto(debuglist);
  530. end
  531. else if assigned(current_module.globalsymtable) then
  532. begin
  533. { all types }
  534. tglobalsymtable(current_module.globalsymtable).concattypestabto(debuglist);
  535. { and all local symbols}
  536. tglobalsymtable(current_module.globalsymtable).concatstabto(debuglist);
  537. end;
  538. end;
  539. {$Else GDB}
  540. begin
  541. end;
  542. {$EndIf GDB}
  543. procedure parse_implementation_uses(symt:tsymtable);
  544. begin
  545. if token=_USES then
  546. begin
  547. loadunits;
  548. {$ifdef DEBUG}
  549. test_symtablestack;
  550. {$endif DEBUG}
  551. end;
  552. end;
  553. procedure setupglobalswitches;
  554. begin
  555. { can't have local browser when no global browser }
  556. if (cs_local_browser in aktmoduleswitches) and
  557. not(cs_browser in aktmoduleswitches) then
  558. exclude(aktmoduleswitches,cs_local_browser);
  559. { define a symbol in delphi,objfpc,tp,gpc mode }
  560. if (m_delphi in aktmodeswitches) then
  561. current_scanner.def_macro('FPC_DELPHI')
  562. else
  563. if (m_tp in aktmodeswitches) then
  564. current_scanner.def_macro('FPC_TP')
  565. else
  566. if (m_objfpc in aktmodeswitches) then
  567. current_scanner.def_macro('FPC_OBJFPC')
  568. else
  569. if (m_gpc in aktmodeswitches) then
  570. current_scanner.def_macro('FPC_GPC');
  571. end;
  572. procedure gen_main_procsym(const name:string;options:tproctypeoption;st:tsymtable);
  573. var
  574. stt : tsymtable;
  575. begin
  576. {Generate a procsym for main}
  577. make_ref:=false;
  578. aktprocsym:=tprocsym.create('$'+name);
  579. { main are allways used }
  580. inc(aktprocsym.refs);
  581. {Try to insert in in static symtable ! }
  582. stt:=symtablestack;
  583. symtablestack:=st;
  584. aktprocsym.definition:=tprocdef.create;
  585. symtablestack:=stt;
  586. aktprocsym.definition.proctypeoption:=options;
  587. aktprocsym.definition.setmangledname(target_info.cprefix+name);
  588. aktprocsym.definition.forwarddef:=false;
  589. make_ref:=true;
  590. { The localst is a local symtable. Change it into the static
  591. symtable }
  592. aktprocsym.definition.localst.free;
  593. aktprocsym.definition.localst:=st;
  594. { and insert the procsym in symtable }
  595. st.insert(aktprocsym);
  596. { set some informations about the main program }
  597. with procinfo^ do
  598. begin
  599. returntype:=voidtype;
  600. _class:=nil;
  601. para_offset:=8;
  602. framepointer:=frame_pointer;
  603. flags:=0;
  604. end;
  605. end;
  606. procedure proc_unit;
  607. function is_assembler_generated:boolean;
  608. begin
  609. is_assembler_generated:=(Errorcount=0) and
  610. not(
  611. codeSegment.empty and
  612. dataSegment.empty and
  613. bssSegment.empty and
  614. ((importssection=nil) or importsSection.empty) and
  615. ((resourcesection=nil) or resourceSection.empty) and
  616. ((resourcestringlist=nil) or resourcestringList.empty)
  617. );
  618. end;
  619. var
  620. main_file: tinputfile;
  621. st : tsymtable;
  622. unitst : tglobalsymtable;
  623. {$ifdef GDB}
  624. pu : tused_unit;
  625. {$endif GDB}
  626. store_crc,store_interface_crc : cardinal;
  627. s2 : ^string; {Saves stack space}
  628. force_init_final : boolean;
  629. begin
  630. consume(_UNIT);
  631. if token=_ID then
  632. begin
  633. { create filenames and unit name }
  634. main_file := current_scanner.inputfile;
  635. while assigned(main_file.next) do
  636. main_file := main_file.next;
  637. current_module.SetFileName(main_file.path^+main_file.name^,true);
  638. stringdispose(current_module.modulename);
  639. stringdispose(current_module.realmodulename);
  640. current_module.modulename:=stringdup(pattern);
  641. current_module.realmodulename:=stringdup(orgpattern);
  642. { check for system unit }
  643. new(s2);
  644. s2^:=upper(SplitName(main_file.name^));
  645. if (cs_check_unit_name in aktglobalswitches) and
  646. not((current_module.modulename^=s2^) or
  647. ((length(current_module.modulename^)>8) and
  648. (copy(current_module.modulename^,1,8)=s2^))) then
  649. Message1(unit_e_illegal_unit_name,current_module.realmodulename^);
  650. if (current_module.modulename^='SYSTEM') then
  651. include(aktmoduleswitches,cs_compilesystem);
  652. dispose(s2);
  653. end;
  654. consume(_ID);
  655. consume(_SEMICOLON);
  656. consume(_INTERFACE);
  657. { global switches are read, so further changes aren't allowed }
  658. current_module.in_global:=false;
  659. { handle the global switches }
  660. setupglobalswitches;
  661. Message1(unit_u_start_parse_interface,current_module.realmodulename^);
  662. { update status }
  663. status.currentmodule:=current_module.realmodulename^;
  664. { maybe turn off m_objpas if we are compiling objpas }
  665. if (current_module.modulename^='OBJPAS') then
  666. exclude(aktmodeswitches,m_objpas);
  667. { this should be placed after uses !!}
  668. {$ifndef UseNiceNames}
  669. procprefix:='_'+current_module.modulename^+'$$';
  670. {$else UseNiceNames}
  671. procprefix:='_'+tostr(length(current_module.modulename^))+lowercase(current_module.modulename^)+'_';
  672. {$endif UseNiceNames}
  673. parse_only:=true;
  674. { generate now the global symboltable }
  675. st:=tglobalsymtable.create(current_module.modulename^);
  676. refsymtable:=st;
  677. unitst:=tglobalsymtable(st);
  678. { define first as local to overcome dependency conflicts }
  679. current_module.localsymtable:=st;
  680. { the unit name must be usable as a unit specifier }
  681. { inside the unit itself (PM) }
  682. { this also forbids to have another symbol }
  683. { with the same name as the unit }
  684. refsymtable.insert(tunitsym.create(current_module.realmodulename^,unitst));
  685. { load default units, like the system unit }
  686. loaddefaultunits;
  687. { reset }
  688. make_ref:=true;
  689. lexlevel:=0;
  690. { insert qualifier for the system unit (allows system.writeln) }
  691. if not(cs_compilesystem in aktmoduleswitches) then
  692. begin
  693. if token=_USES then
  694. begin
  695. loadunits;
  696. { has it been compiled at a higher level ?}
  697. if current_module.compiled then
  698. begin
  699. { this unit symtable is obsolete }
  700. { dispose(unitst,done);
  701. disposed as localsymtable !! }
  702. RestoreUnitSyms;
  703. exit;
  704. end;
  705. end;
  706. { ... but insert the symbol table later }
  707. st.next:=symtablestack;
  708. symtablestack:=st;
  709. end
  710. else
  711. { while compiling a system unit, some types are directly inserted }
  712. begin
  713. st.next:=symtablestack;
  714. symtablestack:=st;
  715. insert_intern_types(st);
  716. end;
  717. { now we know the place to insert the constants }
  718. constsymtable:=symtablestack;
  719. { move the global symtab from the temporary local to global }
  720. current_module.globalsymtable:=current_module.localsymtable;
  721. current_module.localsymtable:=nil;
  722. reset_global_defs;
  723. { number all units, so we know if a unit is used by this unit or
  724. needs to be added implicitly }
  725. current_module.numberunits;
  726. { ... parse the declarations }
  727. Message1(parser_u_parsing_interface,current_module.realmodulename^);
  728. read_interface_declarations;
  729. { leave when we got an error }
  730. if (Errorcount>0) and not status.skip_error then
  731. begin
  732. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  733. status.skip_error:=true;
  734. exit;
  735. end;
  736. {else in inteface its somatimes necessary even if unused
  737. st^.allunitsused; }
  738. {$ifdef New_GDB}
  739. write_gdb_info;
  740. {$endIf Def New_GDB}
  741. if not(cs_compilesystem in aktmoduleswitches) then
  742. if (Errorcount=0) then
  743. tppumodule(current_module).getppucrc;
  744. { Parse the implementation section }
  745. consume(_IMPLEMENTATION);
  746. current_module.in_implementation:=true;
  747. Message1(unit_u_start_parse_implementation,current_module.modulename^);
  748. parse_only:=false;
  749. { generates static symbol table }
  750. st:=tstaticsymtable.create(current_module.modulename^);
  751. current_module.localsymtable:=st;
  752. { remove the globalsymtable from the symtable stack }
  753. { to reinsert it after loading the implementation units }
  754. symtablestack:=unitst.next;
  755. { we don't want implementation units symbols in unitsymtable !! PM }
  756. refsymtable:=st;
  757. { Read the implementation units }
  758. parse_implementation_uses(unitst);
  759. if current_module.compiled then
  760. begin
  761. RestoreUnitSyms;
  762. exit;
  763. end;
  764. { reset ranges/stabs in exported definitions }
  765. reset_global_defs;
  766. { All units are read, now give them a number }
  767. current_module.numberunits;
  768. { now we can change refsymtable }
  769. refsymtable:=st;
  770. { but reinsert the global symtable as lasts }
  771. unitst.next:=symtablestack;
  772. symtablestack:=unitst;
  773. tstoredsymtable(symtablestack).chainoperators;
  774. {$ifdef DEBUG}
  775. test_symtablestack;
  776. {$endif DEBUG}
  777. constsymtable:=symtablestack;
  778. {$ifdef Splitheap}
  779. if testsplit then
  780. begin
  781. Split_Heap;
  782. allow_special:=true;
  783. Switch_to_temp_heap;
  784. end;
  785. { it will report all crossings }
  786. allow_special:=false;
  787. {$endif Splitheap}
  788. Message1(parser_u_parsing_implementation,current_module.realmodulename^);
  789. { Compile the unit }
  790. codegen_newprocedure;
  791. gen_main_procsym(current_module.modulename^+'_init',potype_unitinit,st);
  792. aktprocsym.definition.aliasnames.insert('INIT$$'+current_module.modulename^);
  793. aktprocsym.definition.aliasnames.insert(target_info.cprefix+current_module.modulename^+'_init');
  794. compile_proc_body(true,false);
  795. codegen_doneprocedure;
  796. { avoid self recursive destructor call !! PM }
  797. aktprocsym.definition.localst:=nil;
  798. { if the unit contains ansi/widestrings, initialization and
  799. finalization code must be forced }
  800. force_init_final:=tglobalsymtable(current_module.globalsymtable).needs_init_final or
  801. tstaticsymtable(current_module.localsymtable).needs_init_final;
  802. { should we force unit initialization? }
  803. { this is a hack, but how can it be done better ? }
  804. if force_init_final and ((current_module.flags and uf_init)=0) then
  805. begin
  806. current_module.flags:=current_module.flags or uf_init;
  807. { now we can insert a cut }
  808. if (cs_create_smart in aktmoduleswitches) then
  809. codeSegment.concat(Tai_cut.Create);
  810. genimplicitunitinit(codesegment);
  811. end;
  812. { finalize? }
  813. if token=_FINALIZATION then
  814. begin
  815. { set module options }
  816. current_module.flags:=current_module.flags or uf_finalize;
  817. { Compile the finalize }
  818. codegen_newprocedure;
  819. gen_main_procsym(current_module.modulename^+'_finalize',potype_unitfinalize,st);
  820. aktprocsym.definition.aliasnames.insert('FINALIZE$$'+current_module.modulename^);
  821. aktprocsym.definition.aliasnames.insert(target_info.cprefix+current_module.modulename^+'_finalize');
  822. compile_proc_body(true,false);
  823. codegen_doneprocedure;
  824. end
  825. else if force_init_final then
  826. begin
  827. current_module.flags:=current_module.flags or uf_finalize;
  828. { now we can insert a cut }
  829. if (cs_create_smart in aktmoduleswitches) then
  830. codeSegment.concat(Tai_cut.Create);
  831. genimplicitunitfinal(codesegment);
  832. end;
  833. { the last char should always be a point }
  834. consume(_POINT);
  835. If ResourceStrings.ResStrCount>0 then
  836. begin
  837. ResourceStrings.CreateResourceStringList;
  838. current_module.flags:=current_module.flags or uf_has_resources;
  839. { only write if no errors found }
  840. if (Errorcount=0) then
  841. ResourceStrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
  842. end;
  843. { avoid self recursive destructor call !! PM }
  844. aktprocsym.definition.localst:=nil;
  845. { absence does not matter here !! }
  846. aktprocsym.definition.forwarddef:=false;
  847. { test static symtable }
  848. if (Errorcount=0) then
  849. begin
  850. tstoredsymtable(st).allsymbolsused;
  851. tstoredsymtable(st).allunitsused;
  852. tstoredsymtable(st).allprivatesused;
  853. end;
  854. { size of the static data }
  855. datasize:=st.datasize;
  856. {$ifdef GDB}
  857. { add all used definitions even for implementation}
  858. if (cs_debuginfo in aktmoduleswitches) then
  859. begin
  860. {$IfnDef New_GDB}
  861. if assigned(current_module.globalsymtable) then
  862. begin
  863. { all types }
  864. tglobalsymtable(current_module.globalsymtable).concattypestabto(debuglist);
  865. { and all local symbols}
  866. tglobalsymtable(current_module.globalsymtable).concatstabto(debuglist);
  867. end;
  868. { all local types }
  869. tglobalsymtable(st)^.concattypestabto(debuglist);
  870. { and all local symbols}
  871. st^.concatstabto(debuglist);
  872. {$else New_GDB}
  873. write_gdb_info;
  874. {$endIf Def New_GDB}
  875. end;
  876. {$endif GDB}
  877. reset_global_defs;
  878. { tests, if all (interface) forwards are resolved }
  879. if (Errorcount=0) then
  880. begin
  881. tstoredsymtable(symtablestack).check_forwards;
  882. tstoredsymtable(symtablestack).allprivatesused;
  883. end;
  884. current_module.in_implementation:=false;
  885. {$ifdef GDB}
  886. tglobalsymtable(symtablestack).is_stab_written:=false;
  887. {$endif GDB}
  888. { leave when we got an error }
  889. if (Errorcount>0) and not status.skip_error then
  890. begin
  891. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  892. status.skip_error:=true;
  893. exit;
  894. end;
  895. { generate imports }
  896. if current_module.uses_imports then
  897. importlib.generatelib;
  898. { insert own objectfile, or say that it's in a library
  899. (no check for an .o when loading) }
  900. if is_assembler_generated then
  901. insertobjectfile
  902. else
  903. current_module.flags:=current_module.flags or uf_no_link;
  904. if cs_local_browser in aktmoduleswitches then
  905. current_module.localsymtable:=refsymtable;
  906. {$ifdef GDB}
  907. pu:=tused_unit(usedunits.first);
  908. while assigned(pu) do
  909. begin
  910. if assigned(pu.u.globalsymtable) then
  911. tglobalsymtable(pu.u.globalsymtable).is_stab_written:=false;
  912. pu:=tused_unit(pu.next);
  913. end;
  914. {$endif GDB}
  915. if is_assembler_generated then
  916. begin
  917. { finish asmlist by adding segment starts }
  918. insertsegment;
  919. { assemble }
  920. create_objectfile;
  921. end;
  922. { Write out the ppufile after the object file has been created }
  923. store_interface_crc:=current_module.interface_crc;
  924. store_crc:=current_module.crc;
  925. if (Errorcount=0) then
  926. tppumodule(current_module).writeppu;
  927. if not(cs_compilesystem in aktmoduleswitches) then
  928. if store_interface_crc<>current_module.interface_crc then
  929. Comment(V_Warning,current_module.ppufilename^+' Interface CRC changed '+
  930. hexstr(store_crc,8)+'<>'+hexstr(current_module.interface_crc,8));
  931. {$ifdef EXTDEBUG}
  932. if not(cs_compilesystem in aktmoduleswitches) then
  933. if (store_crc<>current_module.crc) and simplify_ppu then
  934. Comment(V_Warning,current_module.ppufilename^+' implementation CRC changed '+
  935. hexstr(store_crc,8)+'<>'+hexstr(current_module.interface_crc,8));
  936. {$endif EXTDEBUG}
  937. { remove static symtable (=refsymtable) here to save some mem }
  938. if not (cs_local_browser in aktmoduleswitches) then
  939. begin
  940. st.free;
  941. current_module.localsymtable:=nil;
  942. end;
  943. RestoreUnitSyms;
  944. { leave when we got an error }
  945. if (Errorcount>0) and not status.skip_error then
  946. begin
  947. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  948. status.skip_error:=true;
  949. exit;
  950. end;
  951. end;
  952. procedure proc_program(islibrary : boolean);
  953. var
  954. main_file: tinputfile;
  955. st : tsymtable;
  956. hp : tmodule;
  957. begin
  958. DLLsource:=islibrary;
  959. IsExe:=true;
  960. parse_only:=false;
  961. { relocation works only without stabs under win32 !! PM }
  962. { internal assembler uses rva for stabs info
  963. so it should work with relocated DLLs }
  964. if RelocSection and
  965. (target_info.target=target_i386_win32) and
  966. (target_info.assem<>as_i386_pecoff) then
  967. begin
  968. include(aktglobalswitches,cs_link_strip);
  969. { Warning stabs info does not work with reloc section !! }
  970. if cs_debuginfo in aktmoduleswitches then
  971. begin
  972. Message1(parser_w_parser_reloc_no_debug,current_module.mainsource^);
  973. Message(parser_w_parser_win32_debug_needs_WN);
  974. exclude(aktmoduleswitches,cs_debuginfo);
  975. end;
  976. end;
  977. { get correct output names }
  978. main_file := current_scanner.inputfile;
  979. while assigned(main_file.next) do
  980. main_file := main_file.next;
  981. current_module.SetFileName(main_file.path^+main_file.name^,true);
  982. if islibrary then
  983. begin
  984. consume(_LIBRARY);
  985. stringdispose(current_module.modulename);
  986. current_module.modulename:=stringdup(pattern);
  987. current_module.islibrary:=true;
  988. exportlib.preparelib(pattern);
  989. consume(_ID);
  990. consume(_SEMICOLON);
  991. end
  992. else
  993. { is there an program head ? }
  994. if token=_PROGRAM then
  995. begin
  996. consume(_PROGRAM);
  997. stringdispose(current_module.modulename);
  998. stringdispose(current_module.realmodulename);
  999. current_module.modulename:=stringdup(pattern);
  1000. current_module.realmodulename:=stringdup(orgpattern);
  1001. if (target_info.target=target_i386_WIN32) then
  1002. exportlib.preparelib(pattern);
  1003. consume(_ID);
  1004. if token=_LKLAMMER then
  1005. begin
  1006. consume(_LKLAMMER);
  1007. idlist;
  1008. consume(_RKLAMMER);
  1009. end;
  1010. consume(_SEMICOLON);
  1011. end
  1012. else if (target_info.target=target_i386_WIN32) then
  1013. exportlib.preparelib(current_module.modulename^);
  1014. { global switches are read, so further changes aren't allowed }
  1015. current_module.in_global:=false;
  1016. { setup things using the global switches }
  1017. setupglobalswitches;
  1018. { set implementation flag }
  1019. current_module.in_implementation:=true;
  1020. { insert after the unit symbol tables the static symbol table }
  1021. { of the program }
  1022. st:=tstaticsymtable.create(current_module.modulename^);;
  1023. current_module.localsymtable:=st;
  1024. refsymtable:=st;
  1025. { load standard units (system,objpas,profile unit) }
  1026. loaddefaultunits;
  1027. { reset }
  1028. lexlevel:=0;
  1029. {Load the units used by the program we compile.}
  1030. if token=_USES then
  1031. loadunits;
  1032. tstoredsymtable(symtablestack).chainoperators;
  1033. { reset ranges/stabs in exported definitions }
  1034. reset_global_defs;
  1035. { All units are read, now give them a number }
  1036. current_module.numberunits;
  1037. {Insert the name of the main program into the symbol table.}
  1038. if current_module.realmodulename^<>'' then
  1039. st.insert(tunitsym.create(current_module.realmodulename^,tglobalsymtable(st)));
  1040. { ...is also constsymtable, this is the symtable where }
  1041. { the elements of enumeration types are inserted }
  1042. constsymtable:=st;
  1043. Message1(parser_u_parsing_implementation,current_module.mainsource^);
  1044. { reset }
  1045. procprefix:='';
  1046. {The program intialization needs an alias, so it can be called
  1047. from the bootstrap code.}
  1048. codegen_newprocedure;
  1049. gen_main_procsym('main',potype_proginit,st);
  1050. aktprocsym.definition.aliasnames.insert('program_init');
  1051. aktprocsym.definition.aliasnames.insert('PASCALMAIN');
  1052. aktprocsym.definition.aliasnames.insert(target_info.cprefix+'main');
  1053. {$ifdef m68k}
  1054. if target_info.target=target_m68k_PalmOS then
  1055. aktprocsym.definition.aliasnames.insert('PilotMain');
  1056. {$endif m68k}
  1057. compile_proc_body(true,false);
  1058. { avoid self recursive destructor call !! PM }
  1059. aktprocsym.definition.localst:=nil;
  1060. { consider these symbols as global ones for browser
  1061. but the typecasting of the globalsymtable with tglobalsymtable
  1062. can then lead to problems (PFV)
  1063. current_module.globalsymtable:=current_module.localsymtable;
  1064. current_module.localsymtable:=nil;}
  1065. If ResourceStrings.ResStrCount>0 then
  1066. begin
  1067. ResourceStrings.CreateResourceStringList;
  1068. { only write if no errors found }
  1069. if (Errorcount=0) then
  1070. ResourceStrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
  1071. end;
  1072. codegen_doneprocedure;
  1073. { finalize? }
  1074. if token=_FINALIZATION then
  1075. begin
  1076. { set module options }
  1077. current_module.flags:=current_module.flags or uf_finalize;
  1078. { Compile the finalize }
  1079. codegen_newprocedure;
  1080. gen_main_procsym(current_module.modulename^+'_finalize',potype_unitfinalize,st);
  1081. aktprocsym.definition.aliasnames.insert('FINALIZE$$'+current_module.modulename^);
  1082. aktprocsym.definition.aliasnames.insert(target_info.cprefix+current_module.modulename^+'_finalize');
  1083. compile_proc_body(true,false);
  1084. codegen_doneprocedure;
  1085. end;
  1086. { consume the last point }
  1087. consume(_POINT);
  1088. {$ifdef New_GDB}
  1089. write_gdb_info;
  1090. {$endIf Def New_GDB}
  1091. { leave when we got an error }
  1092. if (Errorcount>0) and not status.skip_error then
  1093. begin
  1094. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1095. status.skip_error:=true;
  1096. exit;
  1097. end;
  1098. { test static symtable }
  1099. if (Errorcount=0) then
  1100. begin
  1101. tstoredsymtable(st).allsymbolsused;
  1102. tstoredsymtable(st).allunitsused;
  1103. tstoredsymtable(st).allprivatesused;
  1104. end;
  1105. { generate imports }
  1106. if current_module.uses_imports then
  1107. importlib.generatelib;
  1108. if islibrary or
  1109. (target_info.target=target_i386_WIN32) then
  1110. exportlib.generatelib;
  1111. { insert heap }
  1112. insertResourceTablesTable;
  1113. insertinitfinaltable;
  1114. insertheap;
  1115. inserttargetspecific;
  1116. datasize:=symtablestack.datasize;
  1117. { finish asmlist by adding segment starts }
  1118. insertsegment;
  1119. { insert own objectfile }
  1120. insertobjectfile;
  1121. { assemble and link }
  1122. create_objectfile;
  1123. { leave when we got an error }
  1124. if (Errorcount>0) and not status.skip_error then
  1125. begin
  1126. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1127. status.skip_error:=true;
  1128. exit;
  1129. end;
  1130. { create the executable when we are at level 1 }
  1131. if (compile_level=1) then
  1132. begin
  1133. { insert all .o files from all loaded units }
  1134. hp:=tmodule(loaded_units.first);
  1135. while assigned(hp) do
  1136. begin
  1137. linker.AddModuleFiles(hp);
  1138. hp:=tmodule(hp.next);
  1139. end;
  1140. { write .def file }
  1141. if (cs_link_deffile in aktglobalswitches) then
  1142. deffile.writefile;
  1143. { finally we can create a executable }
  1144. if (not current_module.is_unit) then
  1145. begin
  1146. if DLLSource then
  1147. linker.MakeSharedLibrary
  1148. else
  1149. linker.MakeExecutable;
  1150. end;
  1151. end;
  1152. end;
  1153. end.
  1154. {
  1155. $Log$
  1156. Revision 1.32 2001-05-18 22:26:36 peter
  1157. * merged alignment for non-i386
  1158. Revision 1.31 2001/05/09 14:11:10 jonas
  1159. * range check error fixes from Peter
  1160. Revision 1.30 2001/05/06 14:49:17 peter
  1161. * ppu object to class rewrite
  1162. * move ppu read and write stuff to fppu
  1163. Revision 1.29 2001/04/18 22:01:57 peter
  1164. * registration of targets and assemblers
  1165. Revision 1.28 2001/04/13 18:08:37 peter
  1166. * scanner object to class
  1167. Revision 1.27 2001/04/13 01:22:12 peter
  1168. * symtable change to classes
  1169. * range check generation and errors fixed, make cycle DEBUG=1 works
  1170. * memory leaks fixed
  1171. Revision 1.26 2001/04/02 21:20:33 peter
  1172. * resulttype rewrite
  1173. Revision 1.25 2001/03/13 18:45:07 peter
  1174. * fixed some memory leaks
  1175. Revision 1.24 2001/03/06 18:28:02 peter
  1176. * patch from Pavel with a new and much faster DLL Scanner for
  1177. automatic importing so $linklib works for DLLs. Thanks Pavel!
  1178. Revision 1.23 2001/02/24 10:44:56 peter
  1179. * generate .rst from ppufilename instead of modulename
  1180. Revision 1.22 2001/02/21 19:37:19 peter
  1181. * moved deref to be done after loading of implementation units. prederef
  1182. is still done directly after loading of symbols and definitions.
  1183. Revision 1.21 2001/01/14 22:13:52 peter
  1184. * fixed crash with program name as a important unit name
  1185. Revision 1.20 2000/12/25 00:07:27 peter
  1186. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1187. tlinkedlist objects)
  1188. Revision 1.19 2000/11/29 00:30:36 florian
  1189. * unused units removed from uses clause
  1190. * some changes for widestrings
  1191. Revision 1.18 2000/11/01 23:04:37 peter
  1192. * tprocdef.fullprocname added for better casesensitve writing of
  1193. procedures
  1194. Revision 1.17 2000/10/31 22:02:50 peter
  1195. * symtable splitted, no real code changes
  1196. Revision 1.16 2000/10/21 14:36:26 peter
  1197. * merged pierres fixes
  1198. Revision 1.15 2000/10/15 09:08:58 peter
  1199. * use System for the systemunit instead of target dependent
  1200. Revision 1.14 2000/10/15 07:47:51 peter
  1201. * unit names and procedure names are stored mixed case
  1202. Revision 1.13 2000/10/04 14:51:08 pierre
  1203. * IsExe restored
  1204. Revision 1.12 2000/09/30 16:07:40 peter
  1205. * filepos when unit not found (merged)
  1206. Revision 1.11 2000/09/24 21:33:47 peter
  1207. * message updates merges
  1208. Revision 1.10 2000/09/24 15:06:22 peter
  1209. * use defines.inc
  1210. Revision 1.9 2000/08/31 07:53:02 michael
  1211. + Applied patch from Peter
  1212. Revision 1.8 2000/08/29 19:00:01 peter
  1213. * _init and _finalize procsyms also need a $ prefix
  1214. Revision 1.7 2000/08/27 20:19:39 peter
  1215. * store strings with case in ppu, when an internal symbol is created
  1216. a '$' is prefixed so it's not automatic uppercased
  1217. Revision 1.6 2000/08/27 16:11:52 peter
  1218. * moved some util functions from globals,cobjects to cutils
  1219. * splitted files into finput,fmodule
  1220. Revision 1.5 2000/08/25 08:48:22 jonas
  1221. * fixed bug with include files at the very beginning of .pp/.pas files
  1222. (wrong name used for generating exe/checking unit name) (merged from
  1223. fixes branch)
  1224. Revision 1.4 2000/08/21 11:27:44 pierre
  1225. * fix the stabs problems
  1226. Revision 1.3 2000/07/13 12:08:26 michael
  1227. + patched to 1.1.0 with former 1.09patch from peter
  1228. Revision 1.2 2000/07/13 11:32:45 michael
  1229. + removed logs
  1230. }