pmodules.pas 58 KB

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