pmodules.pas 58 KB

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