pmodules.pas 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639
  1. {
  2. $Id$
  3. Copyright (c) 1998 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. {.$define TEST_IMPL does not work well }
  20. { other way to get correct type info, in test (PM) }
  21. {$define New_GDB}
  22. interface
  23. procedure proc_unit;
  24. procedure proc_program(islibrary : boolean);
  25. implementation
  26. uses
  27. globtype,version,systems,tokens,
  28. cobjects,comphook,globals,verbose,files,
  29. symtable,aasm,hcodegen,
  30. link,assemble,import,export,gendef,ppu,comprsrc
  31. {$ifdef i386}
  32. ,i386
  33. {$endif}
  34. {$ifdef m68k}
  35. ,m68k
  36. {$endif}
  37. ,scanner,pbase,psystem,pdecl,psub,parser;
  38. procedure create_objectfile;
  39. begin
  40. { create the .s file and assemble it }
  41. GenerateAsm;
  42. { resource files }
  43. CompileResourceFiles;
  44. { When creating a library call the linker. And insert the output
  45. of the linker files }
  46. if (cs_create_sharedlib in aktmoduleswitches) then
  47. Linker.MakeSharedLibrary
  48. else
  49. if (cs_create_staticlib in aktmoduleswitches) or
  50. (cs_smartlink in aktmoduleswitches) then
  51. Linker.MakeStaticLibrary(SmartLinkFilesCnt);
  52. end;
  53. procedure insertobjectfile;
  54. { Insert the used object file for this unit in the used list for this unit }
  55. begin
  56. if (cs_create_sharedlib in aktmoduleswitches) then
  57. current_module^.linksharedlibs.insert(current_module^.sharedlibfilename^)
  58. else
  59. begin
  60. if (cs_create_staticlib in aktmoduleswitches) or
  61. (cs_smartlink in aktmoduleswitches) then
  62. current_module^.linkstaticlibs.insert(current_module^.staticlibfilename^)
  63. else
  64. current_module^.linkunitfiles.insert(current_module^.objfilename^);
  65. end;
  66. end;
  67. procedure insertsegment;
  68. procedure fixseg(p:paasmoutput;sec:tsection);
  69. begin
  70. p^.insert(new(pai_section,init(sec)));
  71. if (cs_smartlink in aktmoduleswitches) then
  72. p^.insert(new(pai_cut,init));
  73. p^.concat(new(pai_section,init(sec_none)));
  74. end;
  75. begin
  76. {Insert Ident of the compiler}
  77. if (not (cs_smartlink in aktmoduleswitches))
  78. {$ifndef EXTDEBUG}
  79. and (not current_module^.is_unit)
  80. {$endif}
  81. then
  82. begin
  83. datasegment^.insert(new(pai_align,init(4)));
  84. datasegment^.insert(new(pai_string,init('FPC '+version_string+
  85. ' for '+target_cpu_string+' - '+target_info.short_name)));
  86. end;
  87. { Insert start and end of sections }
  88. fixseg(codesegment,sec_code);
  89. fixseg(datasegment,sec_data);
  90. fixseg(bsssegment,sec_bss);
  91. fixseg(consts,sec_data);
  92. end;
  93. procedure insertheap;
  94. begin
  95. if (cs_smartlink in aktmoduleswitches) then
  96. begin
  97. bsssegment^.concat(new(pai_cut,init));
  98. datasegment^.concat(new(pai_cut,init));
  99. end;
  100. { On the Macintosh Classic M68k Architecture
  101. The Heap variable is simply a POINTER to the
  102. real HEAP. The HEAP must be set up by the RTL
  103. and must store the pointer in this value.
  104. On OS/2 the heap is also intialized by the RTL. We do
  105. not output a pointer }
  106. case target_info.target of
  107. {$ifdef i386}
  108. target_i386_OS2:
  109. ;
  110. {$endif i386}
  111. {$ifdef m68k}
  112. target_m68k_Mac:
  113. bsssegment^.concat(new(pai_datablock,init_global('HEAP',4)));
  114. target_m68k_PalmOS:
  115. ;
  116. {$endif m68k}
  117. else
  118. bsssegment^.concat(new(pai_datablock,init_global('HEAP',heapsize)));
  119. end;
  120. {$ifdef i386}
  121. datasegment^.concat(new(pai_symbol,init_global('HEAPSIZE')));
  122. datasegment^.concat(new(pai_const,init_32bit(heapsize)));
  123. {$endif i386}
  124. {$ifdef m68k}
  125. if target_info.target<>target_m68k_PalmOS then
  126. begin
  127. datasegment^.concat(new(pai_symbol,init_global('HEAP_SIZE')));
  128. datasegment^.concat(new(pai_const,init_32bit(heapsize)));
  129. end;
  130. {$endif m68k}
  131. end;
  132. procedure inserttargetspecific;
  133. begin
  134. case target_info.target of
  135. {$ifdef i386}
  136. target_i386_GO32V2 :
  137. begin
  138. { stacksize can be specified }
  139. datasegment^.concat(new(pai_symbol,init_global('__stklen')));
  140. datasegment^.concat(new(pai_const,init_32bit(stacksize)));
  141. end;
  142. target_i386_WIN32 :
  143. begin
  144. { Generate an external entry to be sure that _mainCRTStarup will be
  145. linked, can't use concat_external because those aren't written for
  146. asw (PFV) }
  147. if deffile.fname='DEF.$$$'then
  148. target_link.bindcmd[1]:=target_link.bindcmd[1]+' -d DEF.$$$';
  149. if DLLsource then
  150. target_link.binders:=2;
  151. if RelocSection then
  152. begin
  153. target_link.linkcmd:=target_link.linkcmd+' --base-file base.$$$';
  154. target_link.bindcmd[1]:=target_link.bindcmd[1]+' --base-file base.$$$';
  155. target_link.binders:=2;
  156. end;
  157. if apptype=at_cui then
  158. datasegment^.concat(new(pai_const,init_symbol('_mainCRTStartup')))
  159. else
  160. begin
  161. datasegment^.concat(new(pai_const,init_symbol('_WinMainCRTStartup')));
  162. target_link.linkcmd:='--subsystem windows '+target_link.linkcmd;
  163. target_link.bindcmd[2]:='--subsystem windows '+target_link.bindcmd[2];
  164. end;
  165. if DLLsource then
  166. begin
  167. target_link.linkcmd:='--dll '+target_link.linkcmd;
  168. target_link.bindcmd[2]:='--dll '+target_link.bindcmd[2];
  169. end;
  170. end;
  171. {$endif i386}
  172. {$ifdef m68k}
  173. target_m68k_Atari :
  174. begin
  175. { stacksize can be specified }
  176. datasegment^.concat(new(pai_symbol,init_global('__stklen')));
  177. datasegment^.concat(new(pai_const,init_32bit(stacksize)));
  178. end;
  179. {$endif m68k}
  180. end;
  181. end;
  182. function loadunit(const s : string;compile_system:boolean) : pmodule;forward;
  183. procedure load_usedunits(compile_system:boolean);
  184. var
  185. pu : pused_unit;
  186. loaded_unit : pmodule;
  187. nextmapentry : longint;
  188. begin
  189. { init the map }
  190. new(current_module^.map);
  191. fillchar(current_module^.map^,sizeof(tunitmap),#0);
  192. {$ifdef NEWMAP}
  193. current_module^.map^[0]:=current_module;
  194. {$endif NEWMAP}
  195. nextmapentry:=1;
  196. { load the used units from interface }
  197. current_module^.in_implementation:=false;
  198. pu:=pused_unit(current_module^.used_units.first);
  199. while assigned(pu) do
  200. begin
  201. if (not pu^.loaded) and (pu^.in_interface) then
  202. begin
  203. loaded_unit:=loadunit(pu^.name^,false);
  204. if current_module^.compiled then
  205. exit;
  206. { register unit in used units }
  207. pu^.u:=loaded_unit;
  208. pu^.loaded:=true;
  209. { need to recompile the current unit ? }
  210. if loaded_unit^.crc<>pu^.checksum then
  211. begin
  212. Message2(unit_u_recompile_crc_change,current_module^.modulename^,pu^.name^);
  213. current_module^.do_compile:=true;
  214. dispose(current_module^.map);
  215. current_module^.map:=nil;
  216. exit;
  217. end;
  218. { setup the map entry for deref }
  219. {$ifndef NEWMAP}
  220. current_module^.map^[nextmapentry]:=loaded_unit^.globalsymtable;
  221. {$else NEWMAP}
  222. current_module^.map^[nextmapentry]:=loaded_unit;
  223. {$endif NEWMAP}
  224. inc(nextmapentry);
  225. if nextmapentry>maxunits then
  226. Message(unit_f_too_much_units);
  227. end;
  228. pu:=pused_unit(pu^.next);
  229. end;
  230. { ok, now load the unit }
  231. current_module^.globalsymtable:=new(punitsymtable,loadasunit);
  232. { if this is the system unit insert the intern symbols }
  233. if compile_system then
  234. begin
  235. make_ref:=false;
  236. insertinternsyms(psymtable(current_module^.globalsymtable));
  237. make_ref:=true;
  238. end;
  239. { now only read the implementation part }
  240. current_module^.in_implementation:=true;
  241. { load the used units from implementation }
  242. pu:=pused_unit(current_module^.used_units.first);
  243. while assigned(pu) do
  244. begin
  245. if (not pu^.loaded) and (not pu^.in_interface) then
  246. begin
  247. loaded_unit:=loadunit(pu^.name^,false);
  248. if current_module^.compiled then
  249. exit;
  250. { register unit in used units }
  251. pu^.u:=loaded_unit;
  252. pu^.loaded:=true;
  253. {$ifdef TEST_IMPL}
  254. { need to recompile the current unit ? }
  255. if loaded_unit^.crc<>pu^.checksum then
  256. begin
  257. Message2(unit_u_recompile_crc_change,current_module^.modulename^,pu^.name^);
  258. current_module^.do_compile:=true;
  259. dispose(current_module^.map);
  260. current_module^.map:=nil;
  261. exit;
  262. end;
  263. {$endif TEST_IMPL}
  264. { setup the map entry for deref }
  265. {$ifndef NEWMAP}
  266. current_module^.map^[nextmapentry]:=loaded_unit^.globalsymtable;
  267. {$else NEWMAP}
  268. current_module^.map^[nextmapentry]:=loaded_unit;
  269. {$endif NEWMAP}
  270. inc(nextmapentry);
  271. if nextmapentry>maxunits then
  272. Message(unit_f_too_much_units);
  273. end;
  274. pu:=pused_unit(pu^.next);
  275. end;
  276. { load browser info if turned on }
  277. if cs_browser in aktmoduleswitches then
  278. punitsymtable(current_module^.globalsymtable)^.load_symtable_refs;
  279. if ((current_module^.flags and uf_has_browser)<>0) and
  280. (cs_local_browser in aktmoduleswitches) then
  281. begin
  282. current_module^.localsymtable:=new(psymtable,load);
  283. psymtable(current_module^.localsymtable)^.name:=
  284. stringdup('implementation of '+psymtable(current_module^.globalsymtable)^.name^);
  285. psymtable(current_module^.localsymtable)^.load_browser;
  286. end;
  287. { remove the map, it's not needed anymore }
  288. dispose(current_module^.map);
  289. current_module^.map:=nil;
  290. end;
  291. function loadunit(const s : string;compile_system:boolean) : pmodule;
  292. const
  293. ImplIntf : array[boolean] of string[15]=('interface','implementation');
  294. var
  295. st : punitsymtable;
  296. second_time : boolean;
  297. old_current_ppu : pppufile;
  298. old_current_module,hp,hp2 : pmodule;
  299. name : string;{ necessary because
  300. current_module^.mainsource^ is reset in compile !! }
  301. scanner : pscannerfile;
  302. procedure loadppufile;
  303. begin
  304. { load interface section }
  305. if not current_module^.do_compile then
  306. load_interface;
  307. { only load units when we don't recompile }
  308. if not current_module^.do_compile then
  309. load_usedunits(compile_system);
  310. { recompile if set }
  311. if current_module^.do_compile then
  312. begin
  313. { we don't need the ppufile anymore }
  314. if assigned(current_module^.ppufile) then
  315. begin
  316. dispose(current_module^.ppufile,done);
  317. current_module^.ppufile:=nil;
  318. end;
  319. { recompile the unit or give a fatal error if sources not available }
  320. if not(current_module^.sources_avail) then
  321. if (not current_module^.search_unit(current_module^.modulename^,true))
  322. and (length(current_module^.modulename^)>8) then
  323. current_module^.search_unit(copy(current_module^.modulename^,1,8),true);
  324. if not(current_module^.sources_avail) then
  325. Message1(unit_f_cant_compile_unit,current_module^.modulename^)
  326. else
  327. begin
  328. if current_module^.in_second_compile then
  329. Message1(parser_d_compiling_second_time,current_module^.modulename^);
  330. current_scanner^.tempcloseinputfile;
  331. name:=current_module^.mainsource^;
  332. if assigned(scanner) then
  333. scanner^.invalid:=true;
  334. compile(name,compile_system);
  335. if (not current_scanner^.invalid) then
  336. current_scanner^.tempopeninputfile;
  337. end;
  338. end
  339. else
  340. begin
  341. { only reassemble ? }
  342. if (current_module^.do_assemble) then
  343. OnlyAsm;
  344. { add the files for the linker }
  345. Linker.AddModuleFiles(current_module);
  346. end;
  347. if assigned(current_module^.ppufile) then
  348. begin
  349. dispose(current_module^.ppufile,done);
  350. current_module^.ppufile:=nil;
  351. end;
  352. end;
  353. begin
  354. old_current_module:=current_module;
  355. old_current_ppu:=current_ppu;
  356. { Info }
  357. Message3(unit_u_load_unit,current_module^.modulename^,ImplIntf[current_module^.in_implementation],s);
  358. { unit not found }
  359. st:=nil;
  360. { search all loaded units }
  361. hp:=pmodule(loaded_units.first);
  362. while assigned(hp) do
  363. begin
  364. if hp^.modulename^=s then
  365. begin
  366. { the unit is already registered }
  367. { and this means that the unit }
  368. { is already compiled }
  369. { else there is a cyclic unit use }
  370. if assigned(hp^.globalsymtable) then
  371. st:=punitsymtable(hp^.globalsymtable)
  372. else
  373. begin
  374. { both units in interface ? }
  375. if (not current_module^.in_implementation) and (not hp^.in_implementation) then
  376. begin
  377. { check for a cycle }
  378. hp2:=current_module^.loaded_from;
  379. while assigned(hp2) and (hp2<>hp) do
  380. begin
  381. if hp2^.in_implementation then
  382. hp2:=nil
  383. else
  384. hp2:=hp2^.loaded_from;
  385. end;
  386. if assigned(hp2) then
  387. Message2(unit_f_circular_unit_reference,current_module^.modulename^,hp^.modulename^);
  388. end;
  389. end;
  390. break;
  391. end;
  392. { the next unit }
  393. hp:=pmodule(hp^.next);
  394. end;
  395. { the unit is not in the symtable stack }
  396. if (not assigned(st)) then
  397. begin
  398. if assigned(hp) then
  399. begin
  400. { remove the old unit }
  401. loaded_units.remove(hp);
  402. scanner:=hp^.scanner;
  403. hp^.reset;
  404. hp^.scanner:=scanner;
  405. { try to reopen ppu }
  406. hp^.search_unit(s,false);
  407. { try to load the unit a second time first }
  408. current_module:=hp;
  409. current_module^.in_second_compile:=true;
  410. Message1(unit_u_second_load_unit,current_module^.modulename^);
  411. second_time:=true;
  412. end
  413. else
  414. { generates a new unit info record }
  415. begin
  416. current_module:=new(pmodule,init(s,true));
  417. scanner:=nil;
  418. second_time:=false;
  419. end;
  420. current_ppu:=current_module^.ppufile;
  421. { now we can register the unit }
  422. current_module^.loaded_from:=old_current_module;
  423. loaded_units.insert(current_module);
  424. { now realy load the ppu }
  425. loadppufile;
  426. { set compiled flag }
  427. current_module^.compiled:=true;
  428. { register the unit _once_ }
  429. { this is buggy PM }
  430. if not second_time then
  431. usedunits.concat(new(pused_unit,init(current_module,true)));
  432. { load return pointer }
  433. hp:=current_module;
  434. end;
  435. { set the old module }
  436. current_ppu:=old_current_ppu;
  437. current_module:=old_current_module;
  438. loadunit:=hp;
  439. end;
  440. procedure loaddefaultunits;
  441. var
  442. hp : pmodule;
  443. begin
  444. { are we compiling the system unit? }
  445. if (cs_compilesystem in aktmoduleswitches) then
  446. begin
  447. { create system defines }
  448. createconstdefs;
  449. { we don't need to reset anything, it's already done in parser.pas }
  450. exit;
  451. end;
  452. { insert the system unit, it is allways the first }
  453. hp:=loadunit(upper(target_info.system_unit),true);
  454. systemunit:=hp^.globalsymtable;
  455. { it's always the first unit }
  456. systemunit^.next:=nil;
  457. symtablestack:=systemunit;
  458. { add to the used units }
  459. current_module^.used_units.concat(new(pused_unit,init(hp,true)));
  460. refsymtable^.insert(new(punitsym,init('SYSTEM',systemunit)));
  461. { read default constant definitions }
  462. make_ref:=false;
  463. readconstdefs;
  464. make_ref:=true;
  465. { if POWER is defined in the RTL then use it for starstar overloading }
  466. getsym('POWER',false);
  467. if assigned(srsym) and (srsym^.typ=procsym) and (overloaded_operators[STARSTAR]=nil) then
  468. overloaded_operators[STARSTAR]:=pprocsym(srsym);
  469. { Objpas unit? }
  470. if m_objpas in aktmodeswitches then
  471. begin
  472. hp:=loadunit('OBJPAS',false);
  473. objpasunit:=hp^.globalsymtable;
  474. { insert in stack }
  475. objpasunit^.next:=symtablestack;
  476. symtablestack:=objpasunit;
  477. { add to the used units }
  478. current_module^.used_units.concat(new(pused_unit,init(hp,true)));
  479. refsymtable^.insert(new(punitsym,init('OBJPAS',objpasunit)));
  480. end
  481. else
  482. objpasunit:=nil;
  483. { Profile unit? Needed for go32v2 only }
  484. if (cs_profile in aktmoduleswitches) and (target_info.target=target_i386_go32v2) then
  485. begin
  486. hp:=loadunit('PROFILE',false);
  487. psymtable(hp^.globalsymtable)^.next:=symtablestack;
  488. symtablestack:=hp^.globalsymtable;
  489. { add to the used units }
  490. current_module^.used_units.concat(new(pused_unit,init(hp,true)));
  491. refsymtable^.insert(new(punitsym,init('PROFILE',hp^.globalsymtable)));
  492. end;
  493. { Heaptrc unit? (not needed for units), this is here to be sure that it is really
  494. loaded as first unit }
  495. if (cs_gdb_heaptrc in aktglobalswitches) and not(current_module^.is_unit)then
  496. begin
  497. hp:=loadunit('HEAPTRC',false);
  498. psymtable(hp^.globalsymtable)^.next:=symtablestack;
  499. symtablestack:=hp^.globalsymtable;
  500. { add to the used units }
  501. current_module^.used_units.concat(new(pused_unit,init(hp,true)));
  502. refsymtable^.insert(new(punitsym,init('HEAPTRC',hp^.globalsymtable)));
  503. end;
  504. { save default symtablestack }
  505. defaultsymtablestack:=symtablestack;
  506. end;
  507. procedure loadunits;
  508. var
  509. s : stringid;
  510. hp : pused_unit;
  511. hp2 : pmodule;
  512. hp3 : psymtable;
  513. oldprocsym:Pprocsym;
  514. begin
  515. oldprocsym:=aktprocsym;
  516. consume(_USES);
  517. {$ifdef DEBUG}
  518. test_symtablestack;
  519. {$endif DEBUG}
  520. repeat
  521. s:=pattern;
  522. consume(ID);
  523. { avoid uses of itself }
  524. if s<>current_module^.modulename^ then
  525. begin
  526. { load the unit }
  527. hp2:=loadunit(s,false);
  528. { the current module uses the unit hp2 }
  529. current_module^.used_units.concat(new(pused_unit,init(hp2,not current_module^.in_implementation)));
  530. pused_unit(current_module^.used_units.last)^.in_uses:=true;
  531. if current_module^.compiled then
  532. exit;
  533. refsymtable^.insert(new(punitsym,init(s,hp2^.globalsymtable)));
  534. end
  535. else
  536. Message1(sym_e_duplicate_id,s);
  537. if token=COMMA then
  538. begin
  539. pattern:='';
  540. consume(COMMA);
  541. end
  542. else
  543. break;
  544. until false;
  545. consume(SEMICOLON);
  546. { set the symtable to systemunit so it gets reorderd correctly }
  547. symtablestack:=defaultsymtablestack;
  548. { now insert the units in the symtablestack }
  549. hp:=pused_unit(current_module^.used_units.first);
  550. while assigned(hp) do
  551. begin
  552. {$IfDef GDB}
  553. {$IfnDef New_GDB}
  554. if (cs_debuginfo in aktmoduleswitches) and
  555. not hp^.is_stab_written then
  556. begin
  557. punitsymtable(hp^.u^.globalsymtable)^.concattypestabto(debuglist);
  558. hp^.is_stab_written:=true;
  559. hp^.unitid:=psymtable(hp^.u^.globalsymtable)^.unitid;
  560. end;
  561. {$endIf nDef New_GDB}
  562. {$EndIf GDB}
  563. if hp^.in_uses then
  564. begin
  565. hp3:=symtablestack;
  566. while assigned(hp3) do
  567. begin
  568. { insert units only once ! }
  569. if hp^.u^.globalsymtable=hp3 then
  570. break;
  571. hp3:=hp3^.next;
  572. { unit isn't inserted }
  573. if hp3=nil then
  574. begin
  575. psymtable(hp^.u^.globalsymtable)^.next:=symtablestack;
  576. symtablestack:=psymtable(hp^.u^.globalsymtable);
  577. {$ifdef CHAINPROCSYMS}
  578. symtablestack^.chainprocsyms;
  579. {$endif CHAINPROCSYMS}
  580. {$ifdef DEBUG}
  581. test_symtablestack;
  582. {$endif DEBUG}
  583. end;
  584. end;
  585. end;
  586. hp:=pused_unit(hp^.next);
  587. end;
  588. aktprocsym:=oldprocsym;
  589. end;
  590. procedure write_gdb_info;
  591. {$IfDef GDB}
  592. var
  593. hp : pused_unit;
  594. begin
  595. if not (cs_debuginfo in aktmoduleswitches) then
  596. exit;
  597. { now insert the units in the symtablestack }
  598. hp:=pused_unit(current_module^.used_units.first);
  599. while assigned(hp) do
  600. begin
  601. if (cs_debuginfo in aktmoduleswitches) and
  602. not hp^.is_stab_written then
  603. begin
  604. punitsymtable(hp^.u^.globalsymtable)^.concattypestabto(debuglist);
  605. hp^.is_stab_written:=true;
  606. hp^.unitid:=psymtable(hp^.u^.globalsymtable)^.unitid;
  607. end;
  608. hp:=pused_unit(hp^.next);
  609. end;
  610. if current_module^.in_implementation then
  611. begin
  612. if assigned(current_module^.localsymtable) then
  613. begin
  614. { all types }
  615. punitsymtable(current_module^.localsymtable)^.concattypestabto(debuglist);
  616. { and all local symbols}
  617. punitsymtable(current_module^.localsymtable)^.concatstabto(debuglist);
  618. end;
  619. end
  620. else
  621. begin
  622. if assigned(current_module^.globalsymtable) then
  623. begin
  624. { all types }
  625. punitsymtable(current_module^.globalsymtable)^.concattypestabto(debuglist);
  626. { and all local symbols}
  627. punitsymtable(current_module^.globalsymtable)^.concatstabto(debuglist);
  628. end;
  629. end;
  630. end;
  631. {$Else GDB}
  632. begin
  633. end;
  634. {$EndIf GDB}
  635. procedure parse_implementation_uses(symt:Psymtable);
  636. begin
  637. if token=_USES then
  638. begin
  639. symt^.symtabletype:=unitsymtable;
  640. loadunits;
  641. symt^.symtabletype:=globalsymtable;
  642. {$ifdef DEBUG}
  643. test_symtablestack;
  644. {$endif DEBUG}
  645. end;
  646. end;
  647. procedure gen_main_procsym(const name:string;options:longint;st:psymtable);
  648. begin
  649. {Generate a procsym for main}
  650. make_ref:=false;
  651. aktprocsym:=new(Pprocsym,init(name));
  652. aktprocsym^.definition:=new(Pprocdef,init);
  653. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or options;
  654. aktprocsym^.definition^.setmangledname(target_os.cprefix+name);
  655. aktprocsym^.definition^.forwarddef:=false;
  656. make_ref:=true;
  657. { The localst is a local symtable. Change it into the static
  658. symtable }
  659. dispose(aktprocsym^.definition^.localst,done);
  660. aktprocsym^.definition^.localst:=st;
  661. { and insert the procsym in symtable }
  662. st^.insert(aktprocsym);
  663. { set some informations about the main program }
  664. with procinfo do
  665. begin
  666. retdef:=voiddef;
  667. _class:=nil;
  668. call_offset:=8;
  669. framepointer:=frame_pointer;
  670. flags:=0;
  671. end;
  672. end;
  673. procedure proc_unit;
  674. function is_assembler_generated:boolean;
  675. begin
  676. is_assembler_generated:=(status.errorcount=0) and
  677. not(
  678. codesegment^.empty and
  679. datasegment^.empty and
  680. bsssegment^.empty and
  681. ((importssection=nil) or importssection^.empty) and
  682. ((resourcesection=nil) or resourcesection^.empty)
  683. );
  684. end;
  685. var
  686. names : Tstringcontainer;
  687. st : psymtable;
  688. unitst : punitsymtable;
  689. {$ifdef GDB}
  690. pu : pused_unit;
  691. {$endif GDB}
  692. s1,s2 : ^string; {Saves stack space}
  693. begin
  694. consume(_UNIT);
  695. if token=ID then
  696. begin
  697. { create filenames and unit name }
  698. current_module^.SetFileName(current_scanner^.inputfile^.path^+current_scanner^.inputfile^.name^,true);
  699. stringdispose(current_module^.modulename);
  700. current_module^.modulename:=stringdup(upper(pattern));
  701. { check for system unit }
  702. new(s1);
  703. new(s2);
  704. s1^:=upper(target_info.system_unit);
  705. s2^:=upper(SplitName(current_scanner^.inputfile^.name^));
  706. if (cs_compilesystem in aktmoduleswitches) then
  707. begin
  708. if ((length(current_module^.modulename^)>8) or
  709. (current_module^.modulename^<>s1^) or
  710. (current_module^.modulename^<>s2^)) then
  711. Message1(unit_e_illegal_unit_name,current_module^.modulename^);
  712. end
  713. else
  714. begin
  715. if (cs_check_unit_name in aktglobalswitches) and
  716. not((current_module^.modulename^=s2^) or
  717. ((length(current_module^.modulename^)>8) and
  718. (copy(current_module^.modulename^,1,8)=s2^))) then
  719. Message1(unit_e_illegal_unit_name,current_module^.modulename^);
  720. if (current_module^.modulename^=s1^) then
  721. Message(unit_w_switch_us_missed);
  722. end;
  723. dispose(s2);
  724. dispose(s1);
  725. end;
  726. consume(ID);
  727. consume(SEMICOLON);
  728. consume(_INTERFACE);
  729. { global switches are read, so further changes aren't allowed }
  730. current_module^.in_global:=false;
  731. Message1(unit_u_start_parse_interface,current_module^.modulename^);
  732. { update status }
  733. status.currentmodule:=current_module^.modulename^;
  734. { maybe turn off m_objpas if we are compiling objpas }
  735. if (current_module^.modulename^='OBJPAS') then
  736. aktmodeswitches:=aktmodeswitches-[m_objpas];
  737. { this should be placed after uses !!}
  738. {$ifndef UseNiceNames}
  739. procprefix:='_'+current_module^.modulename^+'$$';
  740. {$else UseNiceNames}
  741. procprefix:='_'+tostr(length(current_module^.modulename^))+lowercase(current_module^.modulename^)+'_';
  742. {$endif UseNiceNames}
  743. parse_only:=true;
  744. { generate now the global symboltable }
  745. st:=new(punitsymtable,init(globalsymtable,current_module^.modulename^));
  746. refsymtable:=st;
  747. unitst:=punitsymtable(st);
  748. { define first as local to overcome dependency conflicts }
  749. current_module^.localsymtable:=st;
  750. { the unit name must be usable as a unit specifier }
  751. { inside the unit itself (PM) }
  752. { this also forbids to have another symbol }
  753. { with the same name as the unit }
  754. refsymtable^.insert(new(punitsym,init(current_module^.modulename^,unitst)));
  755. { a unit compiled at command line must be inside the loaded_unit list }
  756. if (compile_level=1) then
  757. loaded_units.insert(current_module);
  758. { load default units, like the system unit }
  759. loaddefaultunits;
  760. { reset }
  761. make_ref:=true;
  762. lexlevel:=0;
  763. { insert qualifier for the system unit (allows system.writeln) }
  764. if not(cs_compilesystem in aktmoduleswitches) then
  765. begin
  766. if token=_USES then
  767. begin
  768. unitst^.symtabletype:=unitsymtable;
  769. loadunits;
  770. { has it been compiled at a higher level ?}
  771. if current_module^.compiled then
  772. begin
  773. { this unit symtable is obsolete }
  774. { dispose(unitst,done);
  775. disposed as localsymtable !! }
  776. exit;
  777. end;
  778. unitst^.symtabletype:=globalsymtable;
  779. end;
  780. { ... but insert the symbol table later }
  781. st^.next:=symtablestack;
  782. symtablestack:=st;
  783. end
  784. else
  785. { while compiling a system unit, some types are directly inserted }
  786. begin
  787. st^.next:=symtablestack;
  788. symtablestack:=st;
  789. insert_intern_types(st);
  790. end;
  791. { now we know the place to insert the constants }
  792. constsymtable:=symtablestack;
  793. { move the global symtab from the temporary local to global }
  794. current_module^.globalsymtable:=current_module^.localsymtable;
  795. current_module^.localsymtable:=nil;
  796. reset_global_defs;
  797. { ... parse the declarations }
  798. read_interface_declarations;
  799. { leave when we got an error }
  800. if (status.errorcount>0) and not status.skip_error then
  801. begin
  802. Message1(unit_f_errors_in_unit,tostr(status.errorcount));
  803. status.skip_error:=true;
  804. exit;
  805. end;
  806. {$ifdef New_GDB}
  807. write_gdb_info;
  808. {$endIf Def New_GDB}
  809. { Parse the implementation section }
  810. consume(_IMPLEMENTATION);
  811. current_module^.in_implementation:=true;
  812. Message1(unit_u_start_parse_implementation,current_module^.modulename^);
  813. parse_only:=false;
  814. { generates static symbol table }
  815. st:=new(punitsymtable,init(staticsymtable,current_module^.modulename^));
  816. current_module^.localsymtable:=st;
  817. { remove the globalsymtable from the symtable stack }
  818. { to reinsert it after loading the implementation units }
  819. symtablestack:=unitst^.next;
  820. { number the definitions, so a deref from other units works }
  821. refsymtable^.number_defs;
  822. refsymtable^.number_symbols;
  823. { we don't want implementation units symbols in unitsymtable !! PM }
  824. refsymtable:=st;
  825. { Read the implementation units }
  826. parse_implementation_uses(unitst);
  827. if current_module^.compiled then
  828. begin
  829. exit;
  830. end;
  831. { reset ranges/stabs in exported definitions }
  832. { If I find who removed this line !!!!!!!
  833. I AM TIRED OF THIS !!!!!!!!!!!
  834. DONT TOUCH WITHOUT ASKING ME Pierre Muller }
  835. reset_global_defs;
  836. { All units are read, now give them a number }
  837. numberunits;
  838. { now we can change refsymtable }
  839. refsymtable:=st;
  840. { but reinsert the global symtable as lasts }
  841. unitst^.next:=symtablestack;
  842. symtablestack:=unitst;
  843. {$ifdef DEBUG}
  844. test_symtablestack;
  845. {$endif DEBUG}
  846. constsymtable:=symtablestack;
  847. {$ifdef Splitheap}
  848. if testsplit then
  849. begin
  850. Split_Heap;
  851. allow_special:=true;
  852. Switch_to_temp_heap;
  853. end;
  854. { it will report all crossings }
  855. allow_special:=false;
  856. {$endif Splitheap}
  857. { Generate a procsym }
  858. gen_main_procsym(current_module^.modulename^+'_init',pounitinit,st);
  859. { Compile the unit }
  860. codegen_newprocedure;
  861. names.init;
  862. names.insert('INIT$$'+current_module^.modulename^);
  863. names.insert(target_os.cprefix+current_module^.modulename^+'_init');
  864. compile_proc_body(names,true,false);
  865. names.done;
  866. codegen_doneprocedure;
  867. { avoid self recursive destructor call !! PM }
  868. aktprocsym^.definition^.localst:=nil;
  869. { finalize? }
  870. if token=_FINALIZATION then
  871. begin
  872. { set module options }
  873. current_module^.flags:=current_module^.flags or uf_finalize;
  874. { Generate a procsym }
  875. gen_main_procsym(current_module^.modulename^+'_finalize',pounitfinalize,st);
  876. { Compile the finalize }
  877. codegen_newprocedure;
  878. names.init;
  879. names.insert('FINALIZE$$'+current_module^.modulename^);
  880. names.insert(target_os.cprefix+current_module^.modulename^+'_finalize');
  881. compile_proc_body(names,true,false);
  882. names.done;
  883. codegen_doneprocedure;
  884. { avoid self recursive destructor call !! PM }
  885. aktprocsym^.definition^.localst:=nil;
  886. end;
  887. { the last char should always be a point }
  888. consume(POINT);
  889. { avoid self recursive destructor call !! PM }
  890. aktprocsym^.definition^.localst:=nil;
  891. { absence does not matter here !! }
  892. aktprocsym^.definition^.forwarddef:=false;
  893. { test static symtable }
  894. if (status.errorcount=0) then
  895. st^.allsymbolsused;
  896. { size of the static data }
  897. datasize:=st^.datasize;
  898. {$ifdef GDB}
  899. { add all used definitions even for implementation}
  900. if (cs_debuginfo in aktmoduleswitches) then
  901. begin
  902. {$IfnDef New_GDB}
  903. if assigned(current_module^.globalsymtable) then
  904. begin
  905. { all types }
  906. punitsymtable(current_module^.globalsymtable)^.concattypestabto(debuglist);
  907. { and all local symbols}
  908. punitsymtable(current_module^.globalsymtable)^.concatstabto(debuglist);
  909. end;
  910. { all local types }
  911. punitsymtable(st)^.concattypestabto(debuglist);
  912. { and all local symbols}
  913. st^.concatstabto(debuglist);
  914. {$else New_GDB}
  915. write_gdb_info;
  916. {$endIf Def New_GDB}
  917. end;
  918. {$endif GDB}
  919. reset_global_defs;
  920. { tests, if all (interface) forwards are resolved }
  921. if (status.errorcount=0) then
  922. symtablestack^.check_forwards;
  923. { now we have a correct unit, change the symtable type }
  924. current_module^.in_implementation:=false;
  925. symtablestack^.symtabletype:=unitsymtable;
  926. {$ifdef GDB}
  927. punitsymtable(symtablestack)^.is_stab_written:=false;
  928. {$endif GDB}
  929. { leave when we got an error }
  930. if (status.errorcount>0) and not status.skip_error then
  931. begin
  932. Message1(unit_f_errors_in_unit,tostr(status.errorcount));
  933. status.skip_error:=true;
  934. exit;
  935. end;
  936. { generate imports }
  937. if current_module^.uses_imports then
  938. importlib^.generatelib;
  939. { insert own objectfile, or say that it's in a library
  940. (no check for an .o when loading) }
  941. if is_assembler_generated then
  942. insertobjectfile
  943. else
  944. current_module^.flags:=current_module^.flags or uf_in_library;
  945. { Write out the ppufile }
  946. if (status.errorcount=0) then
  947. writeunitas(current_module^.ppufilename^,punitsymtable(symtablestack));
  948. { write local browser }
  949. if cs_local_browser in aktmoduleswitches then
  950. begin
  951. current_module^.localsymtable:=refsymtable;
  952. refsymtable^.write;
  953. refsymtable^.write_browser;
  954. end;
  955. {$ifdef GDB}
  956. pu:=pused_unit(usedunits.first);
  957. while assigned(pu) do
  958. begin
  959. punitsymtable(pu^.u^.globalsymtable)^.is_stab_written:=false;
  960. pu:=pused_unit(pu^.next);
  961. end;
  962. {$endif GDB}
  963. { remove static symtable (=refsymtable) here to save some mem }
  964. dispose(st,done);
  965. current_module^.localsymtable:=nil;
  966. if is_assembler_generated then
  967. begin
  968. { finish asmlist by adding segment starts }
  969. insertsegment;
  970. { assemble }
  971. create_objectfile;
  972. end;
  973. { add the files for the linker from current_module }
  974. Linker.AddModuleFiles(current_module);
  975. end;
  976. procedure proc_program(islibrary : boolean);
  977. var
  978. st : psymtable;
  979. names : Tstringcontainer;
  980. begin
  981. {* Changes made by Ozerski 23.10.1998}
  982. DLLsource:=islibrary;
  983. {* End changes}
  984. parse_only:=false;
  985. if islibrary then
  986. begin
  987. consume(_LIBRARY);
  988. stringdispose(current_module^.modulename);
  989. current_module^.modulename:=stringdup(pattern);
  990. current_module^.islibrary:=true;
  991. exportlib^.preparelib(pattern);
  992. consume(ID);
  993. consume(SEMICOLON);
  994. end
  995. else
  996. { is there an program head ? }
  997. if token=_PROGRAM then
  998. begin
  999. consume(_PROGRAM);
  1000. stringdispose(current_module^.modulename);
  1001. current_module^.modulename:=stringdup(pattern);
  1002. consume(ID);
  1003. if token=LKLAMMER then
  1004. begin
  1005. consume(LKLAMMER);
  1006. idlist;
  1007. consume(RKLAMMER);
  1008. end;
  1009. consume(SEMICOLON);
  1010. end;
  1011. { global switches are read, so further changes aren't allowed }
  1012. current_module^.in_global:=false;
  1013. { set implementation flag }
  1014. current_module^.in_implementation:=true;
  1015. { insert after the unit symbol tables the static symbol table }
  1016. { of the program }
  1017. st:=new(punitsymtable,init(staticsymtable,current_module^.modulename^));
  1018. current_module^.localsymtable:=st;
  1019. symtablestack:=st;
  1020. refsymtable:=st;
  1021. { necessary for browser }
  1022. loaded_units.insert(current_module);
  1023. { load standard units (system,objpas,profile unit) }
  1024. loaddefaultunits;
  1025. { reset }
  1026. lexlevel:=0;
  1027. {Load the units used by the program we compile.}
  1028. if token=_USES then
  1029. loadunits;
  1030. reset_global_defs;
  1031. {Insert the name of the main program into the symbol table.}
  1032. if current_module^.modulename^<>'' then
  1033. {st^.insert(new(pprogramsym,init(current_module^.modulename^)));}
  1034. st^.insert(new(punitsym,init(current_module^.modulename^,punitsymtable(st))));
  1035. { ...is also constsymtable, this is the symtable where }
  1036. { the elements of enumeration types are inserted }
  1037. constsymtable:=st;
  1038. { Generate a procsym for main }
  1039. gen_main_procsym('main',poproginit,st);
  1040. { reset }
  1041. procprefix:='';
  1042. in_except_block:=false;
  1043. {The program intialization needs an alias, so it can be called
  1044. from the bootstrap code.}
  1045. codegen_newprocedure;
  1046. names.init;
  1047. names.insert('program_init');
  1048. names.insert('PASCALMAIN');
  1049. names.insert(target_os.cprefix+'main');
  1050. {$ifdef m68k}
  1051. if target_info.target=target_m68k_PalmOS then
  1052. names.insert('PilotMain');
  1053. {$endif}
  1054. compile_proc_body(names,true,false);
  1055. names.done;
  1056. { avoid self recursive destructor call !! PM }
  1057. aktprocsym^.definition^.localst:=nil;
  1058. { consider these symbols as global ones }
  1059. { for browser }
  1060. current_module^.globalsymtable:=current_module^.localsymtable;
  1061. current_module^.localsymtable:=nil;
  1062. codegen_doneprocedure;
  1063. { consume the last point }
  1064. consume(POINT);
  1065. {$ifdef New_GDB}
  1066. write_gdb_info;
  1067. {$endIf Def New_GDB}
  1068. { leave when we got an error }
  1069. if (status.errorcount>0) and not status.skip_error then
  1070. begin
  1071. Message1(unit_f_errors_in_unit,tostr(status.errorcount));
  1072. status.skip_error:=true;
  1073. exit;
  1074. end;
  1075. { generate imports }
  1076. if current_module^.uses_imports then
  1077. importlib^.generatelib;
  1078. if islibrary then
  1079. exportlib^.generatelib;
  1080. { insert heap }
  1081. insertheap;
  1082. inserttargetspecific;
  1083. datasize:=symtablestack^.datasize;
  1084. { finish asmlist by adding segment starts }
  1085. insertsegment;
  1086. { insert own objectfile }
  1087. insertobjectfile;
  1088. { assemble and link }
  1089. create_objectfile;
  1090. { add the files for the linker from current_module }
  1091. Linker.AddModuleFiles(current_module);
  1092. { create the executable when we are at level 1 }
  1093. if (compile_level=1) then
  1094. begin
  1095. if (cs_link_deffile in aktglobalswitches) then
  1096. deffile.writefile;
  1097. if (not current_module^.is_unit) then
  1098. Linker.MakeExecutable;
  1099. end;
  1100. end;
  1101. end.
  1102. {
  1103. $Log$
  1104. Revision 1.96 1999-02-05 08:54:27 pierre
  1105. + linkofiles splitted inot linkofiles and linkunitfiles
  1106. because linkofiles must be stored with directory
  1107. to enabled linking of different objects with same name
  1108. in a different directory
  1109. Revision 1.95 1999/02/03 09:44:36 pierre
  1110. * symbol nubering begins with 1 in number_symbols
  1111. * program tmodule has globalsymtable for its staticsymtable
  1112. (to get it displayed in IDE globals list)
  1113. + list of symbol (browcol) greatly improved for IDE
  1114. Revision 1.94 1999/01/12 14:25:31 peter
  1115. + BrowserLog for browser.log generation
  1116. + BrowserCol for browser info in TCollections
  1117. * released all other UseBrowser
  1118. Revision 1.93 1999/01/06 12:39:46 peter
  1119. * renamed resource -> comprsrc (conflicted with FV)
  1120. Revision 1.92 1998/12/28 23:26:23 peter
  1121. + resource file handling ($R directive) for Win32
  1122. Revision 1.91 1998/12/15 17:14:17 peter
  1123. * fix for tp7
  1124. Revision 1.90 1998/12/15 10:23:26 peter
  1125. + -iSO, -iSP, -iTO, -iTP
  1126. Revision 1.89 1998/12/11 00:03:34 peter
  1127. + globtype,tokens,version unit splitted from globals
  1128. Revision 1.88 1998/12/08 10:18:11 peter
  1129. + -gh for heaptrc unit
  1130. Revision 1.87 1998/12/01 23:40:53 pierre
  1131. * new try for correct debug info generation
  1132. Revision 1.86 1998/11/30 09:43:22 pierre
  1133. * some range check bugs fixed (still not working !)
  1134. + added DLL writing support for win32 (also accepts variables)
  1135. + TempAnsi for code that could be used for Temporary ansi strings
  1136. handling
  1137. Revision 1.85 1998/11/28 16:20:54 peter
  1138. + support for dll variables
  1139. Revision 1.84 1998/11/18 09:18:03 pierre
  1140. + automatic loading of profile unit with -pg option
  1141. in go32v2 mode (also defines FPC_PROFILE)
  1142. * some memory leaks removed
  1143. * unreleased temp problem with sets solved
  1144. Revision 1.83 1998/11/16 11:29:00 pierre
  1145. * stackcheck removed for i386_win32
  1146. * exportlist does not crash at least !!
  1147. (was need for tests dir !)z
  1148. Revision 1.82 1998/11/12 12:55:16 pierre
  1149. * fix for bug0176 and bug0177
  1150. Revision 1.81 1998/11/12 11:34:58 peter
  1151. * fix for empty .o files and linking of libs
  1152. Revision 1.80 1998/11/06 09:48:14 pierre
  1153. * double initialization code calling bug fixed
  1154. Revision 1.79 1998/11/03 11:33:11 peter
  1155. + search_unit arg to only search for sources
  1156. Revision 1.78 1998/10/30 12:23:41 peter
  1157. * fix for lognunitname and longunit.pas
  1158. Revision 1.77 1998/10/29 11:35:52 florian
  1159. * some dll support for win32
  1160. * fixed assembler writing for PalmOS
  1161. Revision 1.76 1998/10/28 18:26:15 pierre
  1162. * removed some erros after other errors (introduced by useexcept)
  1163. * stabs works again correctly (for how long !)
  1164. Revision 1.75 1998/10/27 13:45:35 pierre
  1165. * classes get a vmt allways
  1166. * better error info (tried to remove
  1167. several error strings introduced by the tpexcept handling)
  1168. Revision 1.74 1998/10/26 09:34:50 peter
  1169. * unit check name works now for all units, not only systemunit
  1170. Revision 1.73 1998/10/22 23:53:27 peter
  1171. * leave when an error has been in the interface (else other units could
  1172. be compiled with the implementation uses!)
  1173. * don't always compile when not in implementation with a second_load
  1174. Revision 1.72 1998/10/22 11:36:34 peter
  1175. * fixed imports generation at the wrong place
  1176. Revision 1.71 1998/10/21 20:13:10 peter
  1177. * check for importsection for empty asm file
  1178. Revision 1.70 1998/10/20 09:30:05 peter
  1179. * set also in_library flag when no .o is generated
  1180. Revision 1.68 1998/10/19 08:54:59 pierre
  1181. * wrong stabs info corrected once again !!
  1182. + variable vmt offset with vmt field only if required
  1183. implemented now !!!
  1184. Revision 1.67 1998/10/13 13:10:25 peter
  1185. * new style for m68k/i386 infos and enums
  1186. Revision 1.66 1998/10/09 16:36:05 pierre
  1187. * some memory leaks specific to usebrowser define fixed
  1188. * removed tmodule.implsymtable (was like tmodule.localsymtable)
  1189. Revision 1.65 1998/10/09 14:38:55 pierre
  1190. * add a second load for PPU file
  1191. Revision 1.64 1998/10/09 08:56:28 pierre
  1192. * several memory leaks fixed
  1193. Revision 1.63 1998/10/08 23:29:01 peter
  1194. * -vu shows unit info, -vt shows tried/used files
  1195. Revision 1.62 1998/10/08 17:17:25 pierre
  1196. * current_module old scanner tagged as invalid if unit is recompiled
  1197. + added ppheap for better info on tracegetmem of heaptrc
  1198. (adds line column and file index)
  1199. * several memory leaks removed ith help of heaptrc !!
  1200. Revision 1.61 1998/10/08 13:48:47 peter
  1201. * fixed memory leaks for do nothing source
  1202. * fixed unit interdependency
  1203. Revision 1.60 1998/10/06 17:16:54 pierre
  1204. * some memory leaks fixed (thanks to Peter for heaptrc !)
  1205. Revision 1.59 1998/10/05 21:33:26 peter
  1206. * fixed 161,165,166,167,168
  1207. Revision 1.58 1998/09/30 16:43:37 peter
  1208. * fixed unit interdependency with circular uses
  1209. Revision 1.57 1998/09/30 12:11:52 peter
  1210. * fixed circular uses which looped forever
  1211. Revision 1.56 1998/09/28 11:22:15 pierre
  1212. * did not compile for browser
  1213. * merge from fixes
  1214. Revision 1.48.2.1 1998/09/28 10:55:16 pierre
  1215. fix for current_module dispose bug
  1216. Revision 1.55 1998/09/28 11:04:03 peter
  1217. * fixed loaddefaultunits which was at the wrong place for programs, so
  1218. the default defs were not loaded when main was initialized
  1219. Revision 1.54 1998/09/24 23:49:12 peter
  1220. + aktmodeswitches
  1221. Revision 1.53 1998/09/23 12:20:50 pierre
  1222. * main program tmodule had no symtable (crashed browser)
  1223. * unit symbols problem fixed !!
  1224. Revision 1.52 1998/09/22 17:13:49 pierre
  1225. + browsing updated and developed
  1226. records and objects fields are also stored
  1227. Revision 1.51 1998/09/22 15:40:55 peter
  1228. * some extra ifdef GDB
  1229. Revision 1.50 1998/09/21 08:45:17 pierre
  1230. + added vmt_offset in tobjectdef.write for fututre use
  1231. (first steps to have objects without vmt if no virtual !!)
  1232. + added fpu_used field for tabstractprocdef :
  1233. sets this level to 2 if the functions return with value in FPU
  1234. (is then set to correct value at parsing of implementation)
  1235. THIS MIGHT refuse some code with FPU expression too complex
  1236. that were accepted before and even in some cases
  1237. that don't overflow in fact
  1238. ( like if f : float; is a forward that finally in implementation
  1239. only uses one fpu register !!)
  1240. Nevertheless I think that it will improve security on
  1241. FPU operations !!
  1242. * most other changes only for UseBrowser code
  1243. (added symtable references for record and objects)
  1244. local switch for refs to args and local of each function
  1245. (static symtable still missing)
  1246. UseBrowser still not stable and probably broken by
  1247. the definition hash array !!
  1248. Revision 1.49 1998/09/18 08:01:36 pierre
  1249. + improvement on the usebrowser part
  1250. (does not work correctly for now)
  1251. Revision 1.48 1998/09/09 15:33:07 peter
  1252. * fixed in_global to allow directives also after interface token
  1253. Revision 1.47 1998/09/09 11:50:55 pierre
  1254. * forward def are not put in record or objects
  1255. + added check for forwards also in record and objects
  1256. * dummy parasymtable for unit initialization removed from
  1257. symtable stack
  1258. Revision 1.46 1998/09/03 11:24:01 peter
  1259. * moved more inputfile things from tscannerfile to tinputfile
  1260. * changed ifdef Sourceline to cs_asm_source
  1261. Revision 1.45 1998/08/31 12:26:28 peter
  1262. * m68k and palmos updates from surebugfixes
  1263. Revision 1.44 1998/08/26 15:35:33 peter
  1264. * fixed scannerfiles for macros
  1265. + $I %<environment>%
  1266. Revision 1.43 1998/08/26 10:08:47 peter
  1267. * fixed problem with libprefix at the wrong place
  1268. * fixed lib generation with smartlinking and no -CS used
  1269. Revision 1.42 1998/08/19 18:04:54 peter
  1270. * fixed current_module^.in_implementation flag
  1271. Revision 1.41 1998/08/17 10:10:08 peter
  1272. - removed OLDPPU
  1273. Revision 1.40 1998/08/17 09:17:50 peter
  1274. * static/shared linking updates
  1275. Revision 1.39 1998/08/14 21:56:37 peter
  1276. * setting the outputfile using -o works now to create static libs
  1277. Revision 1.38 1998/08/10 14:50:13 peter
  1278. + localswitches, moduleswitches, globalswitches splitting
  1279. Revision 1.37 1998/08/10 10:18:31 peter
  1280. + Compiler,Comphook unit which are the new interface units to the
  1281. compiler
  1282. Revision 1.36 1998/07/14 14:46:54 peter
  1283. * released NEWINPUT
  1284. Revision 1.35 1998/07/08 12:39:38 peter
  1285. * heap_size for m68k
  1286. Revision 1.34 1998/07/07 11:20:03 peter
  1287. + NEWINPUT for a better inputfile and scanner object
  1288. Revision 1.33 1998/06/25 11:15:34 pierre
  1289. * ppu files where not closed in newppu !!
  1290. second compilation was impossible due to too many opened files
  1291. (not visible in 'make cycle' as we remove all the ppu files)
  1292. Revision 1.32 1998/06/25 08:48:16 florian
  1293. * first version of rtti support
  1294. Revision 1.31 1998/06/24 14:48:35 peter
  1295. * ifdef newppu -> ifndef oldppu
  1296. Revision 1.30 1998/06/17 14:10:16 peter
  1297. * small os2 fixes
  1298. * fixed interdependent units with newppu (remake3 under linux works now)
  1299. Revision 1.29 1998/06/16 08:56:25 peter
  1300. + targetcpu
  1301. * cleaner pmodules for newppu
  1302. Revision 1.28 1998/06/13 00:10:10 peter
  1303. * working browser and newppu
  1304. * some small fixes against crashes which occured in bp7 (but not in
  1305. fpc?!)
  1306. Revision 1.27 1998/06/11 13:58:08 peter
  1307. * small fix to let newppu compile
  1308. Revision 1.26 1998/06/09 16:01:47 pierre
  1309. + added procedure directive parsing for procvars
  1310. (accepted are popstack cdecl and pascal)
  1311. + added C vars with the following syntax
  1312. var C calias 'true_c_name';(can be followed by external)
  1313. reason is that you must add the Cprefix
  1314. which is target dependent
  1315. Revision 1.25 1998/06/08 22:59:49 peter
  1316. * smartlinking works for win32
  1317. * some defines to exclude some compiler parts
  1318. Revision 1.24 1998/06/08 13:13:44 pierre
  1319. + temporary variables now in temp_gen.pas unit
  1320. because it is processor independent
  1321. * mppc68k.bat modified to undefine i386 and support_mmx
  1322. (which are defaults for i386)
  1323. Revision 1.23 1998/06/05 17:47:29 peter
  1324. * some better uses clauses
  1325. Revision 1.22 1998/06/05 14:37:34 pierre
  1326. * fixes for inline for operators
  1327. * inline procedure more correctly restricted
  1328. Revision 1.21 1998/06/04 23:51:53 peter
  1329. * m68k compiles
  1330. + .def file creation moved to gendef.pas so it could also be used
  1331. for win32
  1332. Revision 1.20 1998/06/04 09:55:42 pierre
  1333. * demangled name of procsym reworked to become independant of the mangling scheme
  1334. Revision 1.19 1998/06/03 23:40:38 peter
  1335. + unlimited file support, release tempclose
  1336. Revision 1.18 1998/06/03 22:49:00 peter
  1337. + wordbool,longbool
  1338. * rename bis,von -> high,low
  1339. * moved some systemunit loading/creating to psystem.pas
  1340. Revision 1.17 1998/05/28 14:40:25 peter
  1341. * fixes for newppu, remake3 works now with it
  1342. Revision 1.16 1998/05/27 19:45:06 peter
  1343. * symtable.pas splitted into includefiles
  1344. * symtable adapted for $ifdef NEWPPU
  1345. Revision 1.15 1998/05/23 01:21:22 peter
  1346. + aktasmmode, aktoptprocessor, aktoutputformat
  1347. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1348. + $LIBNAME to set the library name where the unit will be put in
  1349. * splitted cgi386 a bit (codeseg to large for bp7)
  1350. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1351. Revision 1.14 1998/05/20 09:42:35 pierre
  1352. + UseTokenInfo now default
  1353. * unit in interface uses and implementation uses gives error now
  1354. * only one error for unknown symbol (uses lastsymknown boolean)
  1355. the problem came from the label code !
  1356. + first inlined procedures and function work
  1357. (warning there might be allowed cases were the result is still wrong !!)
  1358. * UseBrower updated gives a global list of all position of all used symbols
  1359. with switch -gb
  1360. Revision 1.13 1998/05/12 10:47:00 peter
  1361. * moved printstatus to verb_def
  1362. + V_Normal which is between V_Error and V_Warning and doesn't have a
  1363. prefix like error: warning: and is included in V_Default
  1364. * fixed some messages
  1365. * first time parameter scan is only for -v and -T
  1366. - removed old style messages
  1367. Revision 1.12 1998/05/11 13:07:56 peter
  1368. + $ifdef NEWPPU for the new ppuformat
  1369. + $define GDB not longer required
  1370. * removed all warnings and stripped some log comments
  1371. * no findfirst/findnext anymore to remove smartlink *.o files
  1372. Revision 1.11 1998/05/06 18:36:53 peter
  1373. * tai_section extended with code,data,bss sections and enumerated type
  1374. * ident 'compiled by FPC' moved to pmodules
  1375. * small fix for smartlink
  1376. Revision 1.10 1998/05/04 17:54:28 peter
  1377. + smartlinking works (only case jumptable left todo)
  1378. * redesign of systems.pas to support assemblers and linkers
  1379. + Unitname is now also in the PPU-file, increased version to 14
  1380. Revision 1.9 1998/05/01 16:38:45 florian
  1381. * handling of private and protected fixed
  1382. + change_keywords_to_tp implemented to remove
  1383. keywords which aren't supported by tp
  1384. * break and continue are now symbols of the system unit
  1385. + widestring, longstring and ansistring type released
  1386. Revision 1.8 1998/04/30 15:59:41 pierre
  1387. * GDB works again better :
  1388. correct type info in one pass
  1389. + UseTokenInfo for better source position
  1390. * fixed one remaining bug in scanner for line counts
  1391. * several little fixes
  1392. Revision 1.7 1998/04/29 10:33:59 pierre
  1393. + added some code for ansistring (not complete nor working yet)
  1394. * corrected operator overloading
  1395. * corrected nasm output
  1396. + started inline procedures
  1397. + added starstarn : use ** for exponentiation (^ gave problems)
  1398. + started UseTokenInfo cond to get accurate positions
  1399. Revision 1.6 1998/04/27 23:10:28 peter
  1400. + new scanner
  1401. * $makelib -> if smartlink
  1402. * small filename fixes pmodule.setfilename
  1403. * moved import from files.pas -> import.pas
  1404. Revision 1.5 1998/04/14 23:27:03 florian
  1405. + exclude/include with constant second parameter added
  1406. Revision 1.4 1998/04/10 14:41:43 peter
  1407. * removed some Hints
  1408. * small speed optimization for AsmLn
  1409. Revision 1.3 1998/04/03 09:51:00 daniel
  1410. * Fixed heap allocation for OS/2.
  1411. }