pmodules.pas 58 KB

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