pmodules.pas 57 KB

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