pmodules.pas 55 KB

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