pmodules.pas 58 KB

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