pmodules.pas 58 KB

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