pmodules.pas 56 KB

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