pmodules.pas 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087
  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. { close old_current_ppu on system that are
  20. short on file handles like DOS system PM }
  21. {$ifdef GO32V1}
  22. {$define SHORT_ON_FILE_HANDLES}
  23. {$endif GO32V1}
  24. {$ifdef GO32V2}
  25. {$define SHORT_ON_FILE_HANDLES}
  26. {$endif GO32V2}
  27. {$define New_GDB}
  28. interface
  29. procedure proc_unit;
  30. procedure proc_program(islibrary : boolean);
  31. implementation
  32. uses
  33. globtype,version,systems,tokens,
  34. cobjects,comphook,globals,verbose,files,
  35. symconst,symtable,aasm,
  36. {$ifdef newcg}
  37. cgbase,
  38. {$else newcg}
  39. hcodegen,
  40. {$endif newcg}
  41. link,assemble,import,export,gendef,ppu,comprsrc,
  42. cresstr,cpubase,cpuasm,
  43. scanner,pbase,psystem,pdecl,psub,parser;
  44. procedure create_objectfile;
  45. begin
  46. { create the .s file and assemble it }
  47. GenerateAsm(false);
  48. { Also create a smartlinked version ? }
  49. if (cs_create_smart in aktmoduleswitches) then
  50. begin
  51. GenerateAsm(true);
  52. if target_asm.needar then
  53. Linker^.MakeStaticLibrary(SmartLinkFilesCnt);
  54. end;
  55. { resource files }
  56. CompileResourceFiles;
  57. end;
  58. procedure insertobjectfile;
  59. { Insert the used object file for this unit in the used list for this unit }
  60. begin
  61. current_module^.linkunitofiles.insert(current_module^.objfilename^,link_static);
  62. current_module^.flags:=current_module^.flags or uf_static_linked;
  63. if (cs_create_smart in aktmoduleswitches) then
  64. begin
  65. current_module^.linkunitstaticlibs.insert(current_module^.staticlibfilename^,link_smart);
  66. current_module^.flags:=current_module^.flags or uf_smart_linked;
  67. end;
  68. end;
  69. procedure insertsegment;
  70. procedure fixseg(p:paasmoutput;sec:tsection);
  71. begin
  72. p^.insert(new(pai_section,init(sec)));
  73. if (cs_create_smart in aktmoduleswitches) then
  74. p^.insert(new(pai_cut,init));
  75. p^.concat(new(pai_section,init(sec_none)));
  76. end;
  77. begin
  78. {Insert Ident of the compiler}
  79. if (not (cs_create_smart in aktmoduleswitches))
  80. {$ifndef EXTDEBUG}
  81. and (not current_module^.is_unit)
  82. {$endif}
  83. then
  84. begin
  85. datasegment^.insert(new(pai_align,init(4)));
  86. datasegment^.insert(new(pai_string,init('FPC '+full_version_string+' ['+
  87. date_string+'] for '+target_cpu_string+' - '+target_info.short_name)));
  88. end;
  89. { Insert start and end of sections }
  90. fixseg(codesegment,sec_code);
  91. fixseg(datasegment,sec_data);
  92. fixseg(bsssegment,sec_bss);
  93. { we should use .rdata section for these two no ? }
  94. { .rdata is a read only data section (PM) }
  95. fixseg(rttilist,sec_data);
  96. fixseg(consts,sec_data);
  97. if assigned(resourcestringlist) then
  98. fixseg(resourcestringlist,sec_data);
  99. {$ifdef GDB}
  100. if assigned(debuglist) then
  101. fixseg(debuglist,sec_code);
  102. {$endif GDB}
  103. end;
  104. Procedure InsertResourceTablesTable;
  105. var
  106. hp : pused_unit;
  107. ResourceStringTables : taasmoutput;
  108. count : longint;
  109. begin
  110. ResourceStringTables.init;
  111. count:=0;
  112. hp:=pused_unit(usedunits.first);
  113. while assigned(hp) do
  114. begin
  115. If (hp^.u^.flags and uf_has_resources)=uf_has_resources then
  116. begin
  117. ResourceStringTables.concat(new(pai_const_symbol,initname(hp^.u^.modulename^+'_RESOURCESTRINGLIST')));
  118. inc(count);
  119. end;
  120. hp:=Pused_unit(hp^.next);
  121. end;
  122. { Add program resources, if any }
  123. If ResourceStringList<>Nil then
  124. begin
  125. ResourceStringTables.concat(new(pai_const_symbol,initname(Current_Module^.modulename^+'_RESOURCESTRINGLIST')));
  126. Inc(Count);
  127. end;
  128. { TableCount }
  129. With ResourceStringTables do
  130. begin
  131. insert(new(pai_const,init_32bit(count)));
  132. insert(new(pai_symbol,initname_global('FPC_RESOURCESTRINGTABLES',0)));
  133. concat(new(pai_symbol_end,initname('FPC_RESOURCESTRINGTABLES')));
  134. end;
  135. { insert in data segment }
  136. if (cs_create_smart in aktmoduleswitches) then
  137. datasegment^.concat(new(pai_cut,init));
  138. datasegment^.concatlist(@ResourceStringTables);
  139. ResourceStringTables.done;
  140. end;
  141. procedure InsertInitFinalTable;
  142. var
  143. hp : pused_unit;
  144. unitinits : taasmoutput;
  145. count : longint;
  146. begin
  147. unitinits.init;
  148. count:=0;
  149. hp:=pused_unit(usedunits.first);
  150. while assigned(hp) do
  151. begin
  152. { call the unit init code and make it external }
  153. if (hp^.u^.flags and (uf_init or uf_finalize))<>0 then
  154. begin
  155. if (hp^.u^.flags and uf_init)<>0 then
  156. begin
  157. unitinits.concat(new(pai_const_symbol,initname('INIT$$'+hp^.u^.modulename^)));
  158. end
  159. else
  160. unitinits.concat(new(pai_const,init_32bit(0)));
  161. if (hp^.u^.flags and uf_finalize)<>0 then
  162. begin
  163. unitinits.concat(new(pai_const_symbol,initname('FINALIZE$$'+hp^.u^.modulename^)));
  164. end
  165. else
  166. unitinits.concat(new(pai_const,init_32bit(0)));
  167. inc(count);
  168. end;
  169. hp:=Pused_unit(hp^.next);
  170. end;
  171. { TableCount,InitCount }
  172. unitinits.insert(new(pai_const,init_32bit(0)));
  173. unitinits.insert(new(pai_const,init_32bit(count)));
  174. unitinits.insert(new(pai_symbol,initname_global('INITFINAL',0)));
  175. unitinits.concat(new(pai_symbol_end,initname('INITFINAL')));
  176. { insert in data segment }
  177. if (cs_create_smart in aktmoduleswitches) then
  178. datasegment^.concat(new(pai_cut,init));
  179. datasegment^.concatlist(@unitinits);
  180. unitinits.done;
  181. end;
  182. procedure insertheap;
  183. begin
  184. if (cs_create_smart in aktmoduleswitches) then
  185. begin
  186. bsssegment^.concat(new(pai_cut,init));
  187. datasegment^.concat(new(pai_cut,init));
  188. end;
  189. { On the Macintosh Classic M68k Architecture
  190. The Heap variable is simply a POINTER to the
  191. real HEAP. The HEAP must be set up by the RTL
  192. and must store the pointer in this value.
  193. On OS/2 the heap is also intialized by the RTL. We do
  194. not output a pointer }
  195. case target_info.target of
  196. {$ifdef i386}
  197. target_i386_OS2:
  198. ;
  199. {$endif i386}
  200. {$ifdef alpha}
  201. target_alpha_linux:
  202. ;
  203. {$endif alpha}
  204. {$ifdef powerpc}
  205. target_powerpc_linux:
  206. ;
  207. {$endif powerpc}
  208. {$ifdef m68k}
  209. target_m68k_Mac:
  210. bsssegment^.concat(new(pai_datablock,init_global('HEAP',4)));
  211. target_m68k_PalmOS:
  212. ;
  213. {$endif m68k}
  214. else
  215. bsssegment^.concat(new(pai_datablock,init_global('HEAP',heapsize)));
  216. end;
  217. {$ifdef m68k}
  218. if target_info.target<>target_m68k_PalmOS then
  219. begin
  220. datasegment^.concat(new(pai_symbol,initname_global('HEAP_SIZE',0)));
  221. datasegment^.concat(new(pai_const,init_32bit(heapsize)));
  222. end;
  223. {$else m68k}
  224. datasegment^.concat(new(pai_symbol,initname_global('HEAPSIZE',4)));
  225. datasegment^.concat(new(pai_const,init_32bit(heapsize)));
  226. {$endif m68k}
  227. end;
  228. procedure inserttargetspecific;
  229. begin
  230. case target_info.target of
  231. {$ifdef alpha}
  232. target_alpha_linux:
  233. ;
  234. {$endif alpha}
  235. {$ifdef powerpc}
  236. target_powerpc_linux:
  237. ;
  238. {$endif powerpc}
  239. {$ifdef i386}
  240. target_i386_GO32V2 :
  241. begin
  242. { stacksize can be specified }
  243. datasegment^.concat(new(pai_symbol,initname_global('__stklen',4)));
  244. datasegment^.concat(new(pai_const,init_32bit(stacksize)));
  245. end;
  246. {$endif i386}
  247. {$ifdef m68k}
  248. target_m68k_Atari :
  249. begin
  250. { stacksize can be specified }
  251. datasegment^.concat(new(pai_symbol,initname_global('__stklen',4)));
  252. datasegment^.concat(new(pai_const,init_32bit(stacksize)));
  253. end;
  254. {$endif m68k}
  255. end;
  256. end;
  257. function loadunit(const s : string;compile_system:boolean) : pmodule;forward;
  258. procedure load_usedunits(compile_system:boolean);
  259. var
  260. pu : pused_unit;
  261. loaded_unit : pmodule;
  262. load_refs : boolean;
  263. nextmapentry : longint;
  264. begin
  265. load_refs:=true;
  266. { init the map }
  267. new(current_module^.map);
  268. fillchar(current_module^.map^,sizeof(tunitmap),#0);
  269. {$ifdef NEWMAP}
  270. current_module^.map^[0]:=current_module;
  271. {$endif NEWMAP}
  272. nextmapentry:=1;
  273. { load the used units from interface }
  274. current_module^.in_implementation:=false;
  275. pu:=pused_unit(current_module^.used_units.first);
  276. while assigned(pu) do
  277. begin
  278. if (not pu^.loaded) and (pu^.in_interface) then
  279. begin
  280. loaded_unit:=loadunit(pu^.name^,false);
  281. if current_module^.compiled then
  282. exit;
  283. { register unit in used units }
  284. pu^.u:=loaded_unit;
  285. pu^.loaded:=true;
  286. { doubles are not important for that list PM }
  287. pu^.u^.dependent_units.concat(new(pdependent_unit,init(current_module)));
  288. { need to recompile the current unit ? }
  289. if loaded_unit^.crc<>pu^.checksum then
  290. begin
  291. Message2(unit_u_recompile_crc_change,current_module^.modulename^,pu^.name^);
  292. current_module^.recompile_reason:=rr_crcchanged;
  293. current_module^.do_compile:=true;
  294. dispose(current_module^.map);
  295. current_module^.map:=nil;
  296. exit;
  297. end;
  298. { setup the map entry for deref }
  299. {$ifndef NEWMAP}
  300. current_module^.map^[nextmapentry]:=loaded_unit^.globalsymtable;
  301. {$else NEWMAP}
  302. current_module^.map^[nextmapentry]:=loaded_unit;
  303. {$endif NEWMAP}
  304. inc(nextmapentry);
  305. if nextmapentry>maxunits then
  306. Message(unit_f_too_much_units);
  307. end;
  308. pu:=pused_unit(pu^.next);
  309. end;
  310. { ok, now load the unit }
  311. current_module^.globalsymtable:=new(punitsymtable,loadasunit);
  312. { now only read the implementation part }
  313. current_module^.in_implementation:=true;
  314. { load the used units from implementation }
  315. pu:=pused_unit(current_module^.used_units.first);
  316. while assigned(pu) do
  317. begin
  318. if (not pu^.loaded) and (not pu^.in_interface) then
  319. begin
  320. loaded_unit:=loadunit(pu^.name^,false);
  321. if current_module^.compiled then
  322. exit;
  323. { register unit in used units }
  324. pu^.u:=loaded_unit;
  325. pu^.loaded:=true;
  326. { need to recompile the current unit ? }
  327. if (loaded_unit^.interface_crc<>pu^.interface_checksum) {and
  328. not(current_module^.in_second_compile) } then
  329. begin
  330. Message2(unit_u_recompile_crc_change,current_module^.modulename^,pu^.name^+' {impl}');
  331. current_module^.recompile_reason:=rr_crcchanged;
  332. current_module^.do_compile:=true;
  333. dispose(current_module^.map);
  334. current_module^.map:=nil;
  335. exit;
  336. end;
  337. { setup the map entry for deref }
  338. {$ifndef NEWMAP}
  339. current_module^.map^[nextmapentry]:=loaded_unit^.globalsymtable;
  340. {$else NEWMAP}
  341. current_module^.map^[nextmapentry]:=loaded_unit;
  342. {$endif NEWMAP}
  343. inc(nextmapentry);
  344. if nextmapentry>maxunits then
  345. Message(unit_f_too_much_units);
  346. end;
  347. pu:=pused_unit(pu^.next);
  348. end;
  349. { load browser info if stored }
  350. if ((current_module^.flags and uf_has_browser)<>0) and load_refs then
  351. punitsymtable(current_module^.globalsymtable)^.load_symtable_refs;
  352. { remove the map, it's not needed anymore }
  353. dispose(current_module^.map);
  354. current_module^.map:=nil;
  355. end;
  356. function loadunit(const s : string;compile_system:boolean) : pmodule;
  357. const
  358. ImplIntf : array[boolean] of string[15]=('interface','implementation');
  359. var
  360. st : punitsymtable;
  361. second_time : boolean;
  362. old_current_ppu : pppufile;
  363. old_current_module,hp,hp2 : pmodule;
  364. name : string;{ necessary because current_module^.mainsource^ is reset in compile !! }
  365. scanner : pscannerfile;
  366. procedure loadppufile;
  367. begin
  368. { load interface section }
  369. if not current_module^.do_compile then
  370. load_interface;
  371. { only load units when we don't recompile }
  372. if not current_module^.do_compile then
  373. load_usedunits(compile_system);
  374. { recompile if set }
  375. if current_module^.do_compile then
  376. begin
  377. { we don't need the ppufile anymore }
  378. if assigned(current_module^.ppufile) then
  379. begin
  380. dispose(current_module^.ppufile,done);
  381. current_module^.ppufile:=nil;
  382. current_ppu:=nil;
  383. end;
  384. { recompile the unit or give a fatal error if sources not available }
  385. if not(current_module^.sources_avail) then
  386. if (not current_module^.search_unit(current_module^.modulename^,true))
  387. and (length(current_module^.modulename^)>8) then
  388. current_module^.search_unit(copy(current_module^.modulename^,1,8),true);
  389. if not(current_module^.sources_avail) then
  390. begin
  391. if current_module^.recompile_reason=rr_noppu then
  392. Message1(unit_f_cant_find_ppu,current_module^.modulename^)
  393. else
  394. Message1(unit_f_cant_compile_unit,current_module^.modulename^);
  395. end
  396. else
  397. begin
  398. if current_module^.in_compile then
  399. begin
  400. current_module^.in_second_compile:=true;
  401. Message1(parser_d_compiling_second_time,current_module^.modulename^);
  402. end;
  403. current_scanner^.tempcloseinputfile;
  404. name:=current_module^.mainsource^;
  405. if assigned(scanner) then
  406. scanner^.invalid:=true;
  407. compile(name,compile_system);
  408. current_module^.in_second_compile:=false;
  409. if (not current_scanner^.invalid) then
  410. current_scanner^.tempopeninputfile;
  411. end;
  412. end
  413. else
  414. begin
  415. { only reassemble ? }
  416. if (current_module^.do_assemble) then
  417. OnlyAsm;
  418. end;
  419. if assigned(current_module^.ppufile) then
  420. begin
  421. dispose(current_module^.ppufile,done);
  422. current_module^.ppufile:=nil;
  423. current_ppu:=nil;
  424. end;
  425. end;
  426. var
  427. dummy : pmodule;
  428. begin
  429. old_current_module:=current_module;
  430. old_current_ppu:=current_ppu;
  431. { Info }
  432. Message3(unit_u_load_unit,current_module^.modulename^,ImplIntf[current_module^.in_implementation],s);
  433. { unit not found }
  434. st:=nil;
  435. dummy:=nil;
  436. { search all loaded units }
  437. hp:=pmodule(loaded_units.first);
  438. while assigned(hp) do
  439. begin
  440. if hp^.modulename^=s then
  441. begin
  442. { forced to reload ? }
  443. if hp^.do_reload then
  444. begin
  445. hp^.do_reload:=false;
  446. break;
  447. end;
  448. { the unit is already registered }
  449. { and this means that the unit }
  450. { is already compiled }
  451. { else there is a cyclic unit use }
  452. if assigned(hp^.globalsymtable) then
  453. st:=punitsymtable(hp^.globalsymtable)
  454. else
  455. begin
  456. { both units in interface ? }
  457. if (not current_module^.in_implementation) and (not hp^.in_implementation) then
  458. begin
  459. { check for a cycle }
  460. hp2:=current_module^.loaded_from;
  461. while assigned(hp2) and (hp2<>hp) do
  462. begin
  463. if hp2^.in_implementation then
  464. hp2:=nil
  465. else
  466. hp2:=hp2^.loaded_from;
  467. end;
  468. if assigned(hp2) then
  469. Message2(unit_f_circular_unit_reference,current_module^.modulename^,hp^.modulename^);
  470. end;
  471. end;
  472. break;
  473. end
  474. else if copy(hp^.modulename^,1,8)=s then
  475. dummy:=hp;
  476. { the next unit }
  477. hp:=pmodule(hp^.next);
  478. end;
  479. if assigned(dummy) and not assigned(hp) then
  480. Message2(unit_w_unit_name_error,s,dummy^.modulename^);
  481. { the unit is not in the symtable stack }
  482. if (not assigned(st)) then
  483. begin
  484. if assigned(hp) then
  485. begin
  486. { remove the old unit }
  487. loaded_units.remove(hp);
  488. scanner:=hp^.scanner;
  489. hp^.reset;
  490. hp^.scanner:=scanner;
  491. { try to reopen ppu }
  492. hp^.search_unit(s,false);
  493. { try to load the unit a second time first }
  494. current_module:=hp;
  495. current_module^.in_second_load:=true;
  496. Message1(unit_u_second_load_unit,current_module^.modulename^);
  497. second_time:=true;
  498. end
  499. else
  500. { generates a new unit info record }
  501. begin
  502. current_module:=new(pmodule,init(s,true));
  503. scanner:=nil;
  504. second_time:=false;
  505. end;
  506. current_ppu:=current_module^.ppufile;
  507. { close old_current_ppu on system that are
  508. short on file handles like DOS PM }
  509. {$ifdef SHORT_ON_FILE_HANDLES}
  510. if assigned(old_current_ppu) then
  511. old_current_ppu^.tempclose;
  512. {$endif SHORT_ON_FILE_HANDLES}
  513. { now we can register the unit }
  514. current_module^.loaded_from:=old_current_module;
  515. loaded_units.insert(current_module);
  516. { now realy load the ppu }
  517. loadppufile;
  518. { set compiled flag }
  519. current_module^.compiled:=true;
  520. { load return pointer }
  521. hp:=current_module;
  522. { for a second_time recompile reload all dependent units,
  523. for a first time compile register the unit _once_ }
  524. if second_time then
  525. begin
  526. { now reload all dependent units }
  527. hp2:=pmodule(loaded_units.first);
  528. while assigned(hp2) do
  529. begin
  530. if hp2^.do_reload then
  531. dummy:=loadunit(hp2^.modulename^,false);
  532. hp2:=pmodule(hp2^.next);
  533. end;
  534. end
  535. else
  536. usedunits.concat(new(pused_unit,init(current_module,true)));
  537. end;
  538. { set the old module }
  539. {$ifdef SHORT_ON_FILE_HANDLES}
  540. if assigned(old_current_ppu) then
  541. old_current_ppu^.tempopen;
  542. {$endif SHORT_ON_FILE_HANDLES}
  543. current_ppu:=old_current_ppu;
  544. current_module:=old_current_module;
  545. loadunit:=hp;
  546. end;
  547. procedure loaddefaultunits;
  548. var
  549. hp : pmodule;
  550. begin
  551. { are we compiling the system unit? }
  552. if (cs_compilesystem in aktmoduleswitches) then
  553. begin
  554. { create system defines }
  555. createconstdefs;
  556. { we don't need to reset anything, it's already done in parser.pas }
  557. exit;
  558. end;
  559. { insert the system unit, it is allways the first }
  560. hp:=loadunit(upper(target_info.system_unit),true);
  561. systemunit:=hp^.globalsymtable;
  562. { it's always the first unit }
  563. systemunit^.next:=nil;
  564. symtablestack:=systemunit;
  565. { add to the used units }
  566. current_module^.used_units.concat(new(pused_unit,init(hp,true)));
  567. refsymtable^.insert(new(punitsym,init('SYSTEM',systemunit)));
  568. { read default constant definitions }
  569. make_ref:=false;
  570. readconstdefs;
  571. make_ref:=true;
  572. { if POWER is defined in the RTL then use it for starstar overloading }
  573. getsym('POWER',false);
  574. if assigned(srsym) and (srsym^.typ=procsym) and (overloaded_operators[_STARSTAR]=nil) then
  575. overloaded_operators[_STARSTAR]:=pprocsym(srsym);
  576. { Objpas unit? }
  577. if m_objpas in aktmodeswitches then
  578. begin
  579. hp:=loadunit('OBJPAS',false);
  580. psymtable(hp^.globalsymtable)^.next:=symtablestack;
  581. symtablestack:=hp^.globalsymtable;
  582. { add to the used units }
  583. current_module^.used_units.concat(new(pused_unit,init(hp,true)));
  584. refsymtable^.insert(new(punitsym,init('OBJPAS',hp^.globalsymtable)));
  585. end;
  586. { Profile unit? Needed for go32v2 only }
  587. if (cs_profile in aktmoduleswitches) and (target_info.target=target_i386_go32v2) then
  588. begin
  589. hp:=loadunit('PROFILE',false);
  590. psymtable(hp^.globalsymtable)^.next:=symtablestack;
  591. symtablestack:=hp^.globalsymtable;
  592. { add to the used units }
  593. current_module^.used_units.concat(new(pused_unit,init(hp,true)));
  594. refsymtable^.insert(new(punitsym,init('PROFILE',hp^.globalsymtable)));
  595. end;
  596. { Heaptrc unit? (not needed for units), this is here to be sure that it is really
  597. loaded as first unit }
  598. if (cs_gdb_heaptrc in aktglobalswitches) and not(current_module^.is_unit)then
  599. begin
  600. hp:=loadunit('HEAPTRC',false);
  601. psymtable(hp^.globalsymtable)^.next:=symtablestack;
  602. symtablestack:=hp^.globalsymtable;
  603. { add to the used units }
  604. current_module^.used_units.concat(new(pused_unit,init(hp,true)));
  605. refsymtable^.insert(new(punitsym,init('HEAPTRC',hp^.globalsymtable)));
  606. end;
  607. { save default symtablestack }
  608. defaultsymtablestack:=symtablestack;
  609. end;
  610. procedure loadunits;
  611. var
  612. s : stringid;
  613. pu,
  614. hp : pused_unit;
  615. hp2 : pmodule;
  616. hp3 : psymtable;
  617. oldprocsym:Pprocsym;
  618. begin
  619. oldprocsym:=aktprocsym;
  620. consume(_USES);
  621. {$ifdef DEBUG}
  622. test_symtablestack;
  623. {$endif DEBUG}
  624. repeat
  625. s:=pattern;
  626. consume(_ID);
  627. { Give a warning if objpas is loaded }
  628. if s='OBJPAS' then
  629. Message(parser_w_no_objpas_use_mode);
  630. { check if the unit is already used }
  631. pu:=pused_unit(current_module^.used_units.first);
  632. while assigned(pu) do
  633. begin
  634. if (pu^.name^=s) then
  635. break;
  636. pu:=pused_unit(pu^.next);
  637. end;
  638. { avoid uses of itself }
  639. if not assigned(pu) and (s<>current_module^.modulename^) then
  640. begin
  641. { load the unit }
  642. hp2:=loadunit(s,false);
  643. { the current module uses the unit hp2 }
  644. current_module^.used_units.concat(new(pused_unit,init(hp2,not current_module^.in_implementation)));
  645. pused_unit(current_module^.used_units.last)^.in_uses:=true;
  646. if current_module^.compiled then
  647. exit;
  648. refsymtable^.insert(new(punitsym,init(s,hp2^.globalsymtable)));
  649. end
  650. else
  651. Message1(sym_e_duplicate_id,s);
  652. if token=_COMMA then
  653. begin
  654. pattern:='';
  655. consume(_COMMA);
  656. end
  657. else
  658. break;
  659. until false;
  660. consume(_SEMICOLON);
  661. { set the symtable to systemunit so it gets reorderd correctly }
  662. symtablestack:=defaultsymtablestack;
  663. { now insert the units in the symtablestack }
  664. hp:=pused_unit(current_module^.used_units.first);
  665. while assigned(hp) do
  666. begin
  667. {$IfDef GDB}
  668. {$IfnDef New_GDB}
  669. if (cs_debuginfo in aktmoduleswitches) and
  670. not hp^.is_stab_written then
  671. begin
  672. punitsymtable(hp^.u^.globalsymtable)^.concattypestabto(debuglist);
  673. hp^.is_stab_written:=true;
  674. hp^.unitid:=psymtable(hp^.u^.globalsymtable)^.unitid;
  675. end;
  676. {$endIf nDef New_GDB}
  677. {$EndIf GDB}
  678. if hp^.in_uses then
  679. begin
  680. hp3:=symtablestack;
  681. while assigned(hp3) do
  682. begin
  683. { insert units only once ! }
  684. if hp^.u^.globalsymtable=hp3 then
  685. break;
  686. hp3:=hp3^.next;
  687. { unit isn't inserted }
  688. if hp3=nil then
  689. begin
  690. psymtable(hp^.u^.globalsymtable)^.next:=symtablestack;
  691. symtablestack:=psymtable(hp^.u^.globalsymtable);
  692. {$ifdef CHAINPROCSYMS}
  693. symtablestack^.chainprocsyms;
  694. {$endif CHAINPROCSYMS}
  695. {$ifdef DEBUG}
  696. test_symtablestack;
  697. {$endif DEBUG}
  698. end;
  699. end;
  700. end;
  701. hp:=pused_unit(hp^.next);
  702. end;
  703. aktprocsym:=oldprocsym;
  704. end;
  705. procedure write_gdb_info;
  706. {$IfDef GDB}
  707. var
  708. hp : pused_unit;
  709. begin
  710. if not (cs_debuginfo in aktmoduleswitches) then
  711. exit;
  712. { now insert the units in the symtablestack }
  713. hp:=pused_unit(current_module^.used_units.first);
  714. while assigned(hp) do
  715. begin
  716. if (cs_debuginfo in aktmoduleswitches) and
  717. not hp^.is_stab_written then
  718. begin
  719. punitsymtable(hp^.u^.globalsymtable)^.concattypestabto(debuglist);
  720. hp^.is_stab_written:=true;
  721. hp^.unitid:=psymtable(hp^.u^.globalsymtable)^.unitid;
  722. end;
  723. hp:=pused_unit(hp^.next);
  724. end;
  725. if current_module^.in_implementation then
  726. begin
  727. if assigned(current_module^.localsymtable) then
  728. begin
  729. { all types }
  730. punitsymtable(current_module^.localsymtable)^.concattypestabto(debuglist);
  731. { and all local symbols}
  732. punitsymtable(current_module^.localsymtable)^.concatstabto(debuglist);
  733. end;
  734. end
  735. else
  736. begin
  737. if assigned(current_module^.globalsymtable) then
  738. begin
  739. { all types }
  740. punitsymtable(current_module^.globalsymtable)^.concattypestabto(debuglist);
  741. { and all local symbols}
  742. punitsymtable(current_module^.globalsymtable)^.concatstabto(debuglist);
  743. end;
  744. end;
  745. end;
  746. {$Else GDB}
  747. begin
  748. end;
  749. {$EndIf GDB}
  750. procedure parse_implementation_uses(symt:Psymtable);
  751. begin
  752. if token=_USES then
  753. begin
  754. symt^.symtabletype:=unitsymtable;
  755. loadunits;
  756. symt^.symtabletype:=globalsymtable;
  757. {$ifdef DEBUG}
  758. test_symtablestack;
  759. {$endif DEBUG}
  760. end;
  761. end;
  762. procedure gen_main_procsym(const name:string;options:tproctypeoption;st:psymtable);
  763. var
  764. stt : psymtable;
  765. begin
  766. {Generate a procsym for main}
  767. make_ref:=false;
  768. aktprocsym:=new(Pprocsym,init(name));
  769. {Try to insert in in static symtable ! }
  770. stt:=symtablestack;
  771. symtablestack:=st;
  772. aktprocsym^.definition:=new(Pprocdef,init);
  773. symtablestack:=stt;
  774. aktprocsym^.definition^.proctypeoption:=options;
  775. aktprocsym^.definition^.setmangledname(target_os.cprefix+name);
  776. aktprocsym^.definition^.forwarddef:=false;
  777. make_ref:=true;
  778. { The localst is a local symtable. Change it into the static
  779. symtable }
  780. dispose(aktprocsym^.definition^.localst,done);
  781. aktprocsym^.definition^.localst:=st;
  782. { and insert the procsym in symtable }
  783. st^.insert(aktprocsym);
  784. { set some informations about the main program }
  785. with procinfo^ do
  786. begin
  787. retdef:=voiddef;
  788. _class:=nil;
  789. call_offset:=8;
  790. framepointer:=frame_pointer;
  791. flags:=0;
  792. end;
  793. end;
  794. procedure proc_unit;
  795. function is_assembler_generated:boolean;
  796. begin
  797. is_assembler_generated:=(Errorcount=0) and
  798. not(
  799. codesegment^.empty and
  800. datasegment^.empty and
  801. bsssegment^.empty and
  802. ((importssection=nil) or importssection^.empty) and
  803. ((resourcesection=nil) or resourcesection^.empty) and
  804. ((resourcestringlist=nil) or resourcestringlist^.empty)
  805. );
  806. end;
  807. var
  808. names : Tstringcontainer;
  809. st : psymtable;
  810. unitst : punitsymtable;
  811. {$ifdef GDB}
  812. pu : pused_unit;
  813. {$endif GDB}
  814. {$ifndef Dont_use_double_checksum}
  815. store_crc,store_interface_crc : longint;
  816. {$endif}
  817. s1,s2 : ^string; {Saves stack space}
  818. begin
  819. consume(_UNIT);
  820. if token=_ID then
  821. begin
  822. { create filenames and unit name }
  823. current_module^.SetFileName(current_scanner^.inputfile^.path^+current_scanner^.inputfile^.name^,true);
  824. stringdispose(current_module^.modulename);
  825. current_module^.modulename:=stringdup(upper(pattern));
  826. { check for system unit }
  827. new(s1);
  828. new(s2);
  829. s1^:=upper(target_info.system_unit);
  830. s2^:=upper(SplitName(current_scanner^.inputfile^.name^));
  831. if (cs_compilesystem in aktmoduleswitches) then
  832. begin
  833. if ((length(current_module^.modulename^)>8) or
  834. (current_module^.modulename^<>s1^) or
  835. (current_module^.modulename^<>s2^)) then
  836. Message1(unit_e_illegal_unit_name,current_module^.modulename^);
  837. end
  838. else
  839. begin
  840. if (cs_check_unit_name in aktglobalswitches) and
  841. not((current_module^.modulename^=s2^) or
  842. ((length(current_module^.modulename^)>8) and
  843. (copy(current_module^.modulename^,1,8)=s2^))) then
  844. Message1(unit_e_illegal_unit_name,current_module^.modulename^);
  845. if (current_module^.modulename^=s1^) then
  846. Message(unit_w_switch_us_missed);
  847. end;
  848. dispose(s2);
  849. dispose(s1);
  850. end;
  851. consume(_ID);
  852. consume(_SEMICOLON);
  853. consume(_INTERFACE);
  854. { global switches are read, so further changes aren't allowed }
  855. current_module^.in_global:=false;
  856. { can't have local browser when no global browser }
  857. if (cs_local_browser in aktmoduleswitches) and
  858. not(cs_browser in aktmoduleswitches) then
  859. aktmoduleswitches:=aktmoduleswitches-[cs_local_browser];
  860. Message1(unit_u_start_parse_interface,current_module^.modulename^);
  861. { update status }
  862. status.currentmodule:=current_module^.modulename^;
  863. { maybe turn off m_objpas if we are compiling objpas }
  864. if (current_module^.modulename^='OBJPAS') then
  865. aktmodeswitches:=aktmodeswitches-[m_objpas];
  866. { this should be placed after uses !!}
  867. {$ifndef UseNiceNames}
  868. procprefix:='_'+current_module^.modulename^+'$$';
  869. {$else UseNiceNames}
  870. procprefix:='_'+tostr(length(current_module^.modulename^))+lowercase(current_module^.modulename^)+'_';
  871. {$endif UseNiceNames}
  872. parse_only:=true;
  873. { generate now the global symboltable }
  874. st:=new(punitsymtable,init(globalsymtable,current_module^.modulename^));
  875. refsymtable:=st;
  876. unitst:=punitsymtable(st);
  877. { define first as local to overcome dependency conflicts }
  878. current_module^.localsymtable:=st;
  879. { the unit name must be usable as a unit specifier }
  880. { inside the unit itself (PM) }
  881. { this also forbids to have another symbol }
  882. { with the same name as the unit }
  883. refsymtable^.insert(new(punitsym,init(current_module^.modulename^,unitst)));
  884. { a unit compiled at command line must be inside the loaded_unit list }
  885. if (compile_level=1) then
  886. loaded_units.insert(current_module);
  887. { load default units, like the system unit }
  888. loaddefaultunits;
  889. { reset }
  890. make_ref:=true;
  891. lexlevel:=0;
  892. { insert qualifier for the system unit (allows system.writeln) }
  893. if not(cs_compilesystem in aktmoduleswitches) then
  894. begin
  895. if token=_USES then
  896. begin
  897. unitst^.symtabletype:=unitsymtable;
  898. loadunits;
  899. { has it been compiled at a higher level ?}
  900. if current_module^.compiled then
  901. begin
  902. { this unit symtable is obsolete }
  903. { dispose(unitst,done);
  904. disposed as localsymtable !! }
  905. exit;
  906. end;
  907. unitst^.symtabletype:=globalsymtable;
  908. end;
  909. { ... but insert the symbol table later }
  910. st^.next:=symtablestack;
  911. symtablestack:=st;
  912. end
  913. else
  914. { while compiling a system unit, some types are directly inserted }
  915. begin
  916. st^.next:=symtablestack;
  917. symtablestack:=st;
  918. insert_intern_types(st);
  919. end;
  920. { now we know the place to insert the constants }
  921. constsymtable:=symtablestack;
  922. { move the global symtab from the temporary local to global }
  923. current_module^.globalsymtable:=current_module^.localsymtable;
  924. current_module^.localsymtable:=nil;
  925. reset_global_defs;
  926. { number all units, so we know if a unit is used by this unit or
  927. needs to be added implicitly }
  928. numberunits;
  929. { ... parse the declarations }
  930. Message1(parser_u_parsing_interface,current_module^.modulename^);
  931. read_interface_declarations;
  932. { leave when we got an error }
  933. if (Errorcount>0) and not status.skip_error then
  934. begin
  935. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  936. status.skip_error:=true;
  937. exit;
  938. end;
  939. {$ifdef New_GDB}
  940. write_gdb_info;
  941. {$endIf Def New_GDB}
  942. {$ifndef Dont_use_double_checksum}
  943. if not(cs_compilesystem in aktmoduleswitches) then
  944. if (Errorcount=0) then
  945. writeunitas(current_module^.ppufilename^,punitsymtable(symtablestack),true);
  946. {$endif Test_Double_checksum}
  947. { Parse the implementation section }
  948. consume(_IMPLEMENTATION);
  949. current_module^.in_implementation:=true;
  950. Message1(unit_u_start_parse_implementation,current_module^.modulename^);
  951. parse_only:=false;
  952. { generates static symbol table }
  953. st:=new(punitsymtable,init(staticsymtable,current_module^.modulename^));
  954. current_module^.localsymtable:=st;
  955. { remove the globalsymtable from the symtable stack }
  956. { to reinsert it after loading the implementation units }
  957. symtablestack:=unitst^.next;
  958. { we don't want implementation units symbols in unitsymtable !! PM }
  959. refsymtable:=st;
  960. { Read the implementation units }
  961. parse_implementation_uses(unitst);
  962. if current_module^.compiled then
  963. begin
  964. exit;
  965. end;
  966. { reset ranges/stabs in exported definitions }
  967. reset_global_defs;
  968. { All units are read, now give them a number }
  969. numberunits;
  970. { now we can change refsymtable }
  971. refsymtable:=st;
  972. { but reinsert the global symtable as lasts }
  973. unitst^.next:=symtablestack;
  974. symtablestack:=unitst;
  975. {$ifdef DEBUG}
  976. test_symtablestack;
  977. {$endif DEBUG}
  978. constsymtable:=symtablestack;
  979. {$ifdef Splitheap}
  980. if testsplit then
  981. begin
  982. Split_Heap;
  983. allow_special:=true;
  984. Switch_to_temp_heap;
  985. end;
  986. { it will report all crossings }
  987. allow_special:=false;
  988. {$endif Splitheap}
  989. Message1(parser_u_parsing_implementation,current_module^.modulename^);
  990. { Compile the unit }
  991. codegen_newprocedure;
  992. gen_main_procsym(current_module^.modulename^+'_init',potype_unitinit,st);
  993. names.init;
  994. names.insert('INIT$$'+current_module^.modulename^);
  995. names.insert(target_os.cprefix+current_module^.modulename^+'_init');
  996. compile_proc_body(names,true,false);
  997. names.done;
  998. codegen_doneprocedure;
  999. { avoid self recursive destructor call !! PM }
  1000. aktprocsym^.definition^.localst:=nil;
  1001. { finalize? }
  1002. if token=_FINALIZATION then
  1003. begin
  1004. { set module options }
  1005. current_module^.flags:=current_module^.flags or uf_finalize;
  1006. { Compile the finalize }
  1007. codegen_newprocedure;
  1008. gen_main_procsym(current_module^.modulename^+'_finalize',potype_unitfinalize,st);
  1009. names.init;
  1010. names.insert('FINALIZE$$'+current_module^.modulename^);
  1011. names.insert(target_os.cprefix+current_module^.modulename^+'_finalize');
  1012. compile_proc_body(names,true,false);
  1013. names.done;
  1014. codegen_doneprocedure;
  1015. end;
  1016. { the last char should always be a point }
  1017. consume(_POINT);
  1018. If ResourceStringList<>Nil then
  1019. begin
  1020. insertresourcestrings;
  1021. current_module^.flags:=current_module^.flags or uf_has_resources;
  1022. WriteResourceFile(Current_module^.ModuleName^);
  1023. end;
  1024. { avoid self recursive destructor call !! PM }
  1025. aktprocsym^.definition^.localst:=nil;
  1026. { absence does not matter here !! }
  1027. aktprocsym^.definition^.forwarddef:=false;
  1028. { test static symtable }
  1029. if (Errorcount=0) then
  1030. st^.allsymbolsused;
  1031. { size of the static data }
  1032. datasize:=st^.datasize;
  1033. {$ifdef GDB}
  1034. { add all used definitions even for implementation}
  1035. if (cs_debuginfo in aktmoduleswitches) then
  1036. begin
  1037. {$IfnDef New_GDB}
  1038. if assigned(current_module^.globalsymtable) then
  1039. begin
  1040. { all types }
  1041. punitsymtable(current_module^.globalsymtable)^.concattypestabto(debuglist);
  1042. { and all local symbols}
  1043. punitsymtable(current_module^.globalsymtable)^.concatstabto(debuglist);
  1044. end;
  1045. { all local types }
  1046. punitsymtable(st)^.concattypestabto(debuglist);
  1047. { and all local symbols}
  1048. st^.concatstabto(debuglist);
  1049. {$else New_GDB}
  1050. write_gdb_info;
  1051. {$endIf Def New_GDB}
  1052. end;
  1053. {$endif GDB}
  1054. reset_global_defs;
  1055. { tests, if all (interface) forwards are resolved }
  1056. if (Errorcount=0) then
  1057. symtablestack^.check_forwards;
  1058. { now we have a correct unit, change the symtable type }
  1059. current_module^.in_implementation:=false;
  1060. symtablestack^.symtabletype:=unitsymtable;
  1061. {$ifdef GDB}
  1062. punitsymtable(symtablestack)^.is_stab_written:=false;
  1063. {$endif GDB}
  1064. { leave when we got an error }
  1065. if (Errorcount>0) and not status.skip_error then
  1066. begin
  1067. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1068. status.skip_error:=true;
  1069. exit;
  1070. end;
  1071. { generate imports }
  1072. if current_module^.uses_imports then
  1073. importlib^.generatelib;
  1074. { insert own objectfile, or say that it's in a library
  1075. (no check for an .o when loading) }
  1076. if is_assembler_generated then
  1077. insertobjectfile
  1078. else
  1079. current_module^.flags:=current_module^.flags or uf_no_link;
  1080. if cs_local_browser in aktmoduleswitches then
  1081. current_module^.localsymtable:=refsymtable;
  1082. { Write out the ppufile }
  1083. {$ifndef Dont_use_double_checksum}
  1084. store_interface_crc:=current_module^.interface_crc;
  1085. store_crc:=current_module^.crc;
  1086. {$endif Test_Double_checksum}
  1087. if (Errorcount=0) then
  1088. writeunitas(current_module^.ppufilename^,punitsymtable(symtablestack),false);
  1089. {$ifndef Dont_use_double_checksum}
  1090. if not(cs_compilesystem in aktmoduleswitches) then
  1091. if store_interface_crc<>current_module^.interface_crc then
  1092. Do_comment(V_Warning,current_module^.ppufilename^+' Interface CRC changed '+
  1093. tostr(store_crc)+'<>'+tostr(current_module^.interface_crc));
  1094. {$ifdef EXTDEBUG}
  1095. if not(cs_compilesystem in aktmoduleswitches) then
  1096. if (store_crc<>current_module^.crc) and simplify_ppu then
  1097. Do_comment(V_Warning,current_module^.ppufilename^+' implementation CRC changed '+
  1098. tostr(store_crc)+'<>'+tostr(current_module^.interface_crc));
  1099. {$endif EXTDEBUG}
  1100. {$endif ndef Dont_use_Double_checksum}
  1101. { must be done only after local symtable ref stores !! }
  1102. closecurrentppu;
  1103. {$ifdef GDB}
  1104. pu:=pused_unit(usedunits.first);
  1105. while assigned(pu) do
  1106. begin
  1107. if assigned(pu^.u^.globalsymtable) then
  1108. punitsymtable(pu^.u^.globalsymtable)^.is_stab_written:=false;
  1109. pu:=pused_unit(pu^.next);
  1110. end;
  1111. {$endif GDB}
  1112. { remove static symtable (=refsymtable) here to save some mem }
  1113. if not (cs_local_browser in aktmoduleswitches) then
  1114. begin
  1115. dispose(st,done);
  1116. current_module^.localsymtable:=nil;
  1117. end;
  1118. if is_assembler_generated then
  1119. begin
  1120. { finish asmlist by adding segment starts }
  1121. insertsegment;
  1122. { assemble }
  1123. create_objectfile;
  1124. end;
  1125. { leave when we got an error }
  1126. if (Errorcount>0) and not status.skip_error then
  1127. begin
  1128. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1129. status.skip_error:=true;
  1130. exit;
  1131. end;
  1132. end;
  1133. procedure proc_program(islibrary : boolean);
  1134. var
  1135. st : psymtable;
  1136. hp : pmodule;
  1137. names : Tstringcontainer;
  1138. begin
  1139. DLLsource:=islibrary;
  1140. parse_only:=false;
  1141. if islibrary then
  1142. begin
  1143. consume(_LIBRARY);
  1144. { relocation works only without stabs !! PM }
  1145. if RelocSection then
  1146. begin
  1147. aktglobalswitches:=aktglobalswitches+[cs_link_strip];
  1148. aktmoduleswitches:=aktmoduleswitches-[cs_debuginfo];
  1149. end;
  1150. stringdispose(current_module^.modulename);
  1151. current_module^.modulename:=stringdup(pattern);
  1152. current_module^.islibrary:=true;
  1153. exportlib^.preparelib(pattern);
  1154. consume(_ID);
  1155. consume(_SEMICOLON);
  1156. end
  1157. else
  1158. { is there an program head ? }
  1159. if token=_PROGRAM then
  1160. begin
  1161. consume(_PROGRAM);
  1162. stringdispose(current_module^.modulename);
  1163. current_module^.modulename:=stringdup(pattern);
  1164. consume(_ID);
  1165. if token=_LKLAMMER then
  1166. begin
  1167. consume(_LKLAMMER);
  1168. idlist;
  1169. consume(_RKLAMMER);
  1170. end;
  1171. consume(_SEMICOLON);
  1172. end;
  1173. { global switches are read, so further changes aren't allowed }
  1174. current_module^.in_global:=false;
  1175. { can't have local browser when no global browser }
  1176. if (cs_local_browser in aktmoduleswitches) and
  1177. not(cs_browser in aktmoduleswitches) then
  1178. aktmoduleswitches:=aktmoduleswitches-[cs_local_browser];
  1179. { set implementation flag }
  1180. current_module^.in_implementation:=true;
  1181. { insert after the unit symbol tables the static symbol table }
  1182. { of the program }
  1183. st:=new(punitsymtable,init(staticsymtable,current_module^.modulename^));
  1184. current_module^.localsymtable:=st;
  1185. symtablestack:=st;
  1186. refsymtable:=st;
  1187. { necessary for browser }
  1188. loaded_units.insert(current_module);
  1189. { load standard units (system,objpas,profile unit) }
  1190. loaddefaultunits;
  1191. { reset }
  1192. lexlevel:=0;
  1193. {Load the units used by the program we compile.}
  1194. if token=_USES then
  1195. loadunits;
  1196. { reset ranges/stabs in exported definitions }
  1197. reset_global_defs;
  1198. { All units are read, now give them a number }
  1199. numberunits;
  1200. {Insert the name of the main program into the symbol table.}
  1201. if current_module^.modulename^<>'' then
  1202. {st^.insert(new(pprogramsym,init(current_module^.modulename^)));}
  1203. st^.insert(new(punitsym,init(current_module^.modulename^,punitsymtable(st))));
  1204. { ...is also constsymtable, this is the symtable where }
  1205. { the elements of enumeration types are inserted }
  1206. constsymtable:=st;
  1207. Message1(parser_u_parsing_implementation,current_module^.mainsource^);
  1208. { reset }
  1209. procprefix:='';
  1210. {The program intialization needs an alias, so it can be called
  1211. from the bootstrap code.}
  1212. codegen_newprocedure;
  1213. gen_main_procsym('main',potype_proginit,st);
  1214. names.init;
  1215. names.insert('program_init');
  1216. names.insert('PASCALMAIN');
  1217. names.insert(target_os.cprefix+'main');
  1218. {$ifdef m68k}
  1219. if target_info.target=target_m68k_PalmOS then
  1220. names.insert('PilotMain');
  1221. {$endif}
  1222. compile_proc_body(names,true,false);
  1223. names.done;
  1224. { avoid self recursive destructor call !! PM }
  1225. aktprocsym^.definition^.localst:=nil;
  1226. { consider these symbols as global ones }
  1227. { for browser }
  1228. current_module^.globalsymtable:=current_module^.localsymtable;
  1229. current_module^.localsymtable:=nil;
  1230. If ResourceStringList<>Nil then
  1231. begin
  1232. insertresourcestrings;
  1233. WriteResourceFile(Current_module^.ModuleName^);
  1234. end;
  1235. codegen_doneprocedure;
  1236. { consume the last point }
  1237. consume(_POINT);
  1238. {$ifdef New_GDB}
  1239. write_gdb_info;
  1240. {$endIf Def New_GDB}
  1241. { leave when we got an error }
  1242. if (Errorcount>0) and not status.skip_error then
  1243. begin
  1244. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1245. status.skip_error:=true;
  1246. exit;
  1247. end;
  1248. { generate imports }
  1249. if current_module^.uses_imports then
  1250. importlib^.generatelib;
  1251. if islibrary then
  1252. exportlib^.generatelib;
  1253. { insert heap }
  1254. insertResourceTablesTable;
  1255. insertinitfinaltable;
  1256. insertheap;
  1257. inserttargetspecific;
  1258. datasize:=symtablestack^.datasize;
  1259. { finish asmlist by adding segment starts }
  1260. insertsegment;
  1261. { insert own objectfile }
  1262. insertobjectfile;
  1263. { assemble and link }
  1264. create_objectfile;
  1265. { leave when we got an error }
  1266. if (Errorcount>0) and not status.skip_error then
  1267. begin
  1268. Message1(unit_f_errors_in_unit,tostr(Errorcount));
  1269. status.skip_error:=true;
  1270. exit;
  1271. end;
  1272. { create the executable when we are at level 1 }
  1273. if (compile_level=1) then
  1274. begin
  1275. { insert all .o files from all loaded units }
  1276. hp:=pmodule(loaded_units.first);
  1277. while assigned(hp) do
  1278. begin
  1279. Linker^.AddModuleFiles(hp);
  1280. hp:=pmodule(hp^.next);
  1281. end;
  1282. { write .def file }
  1283. if (cs_link_deffile in aktglobalswitches) then
  1284. deffile.writefile;
  1285. { finally we can create a executable }
  1286. if (not current_module^.is_unit) then
  1287. begin
  1288. if DLLSource then
  1289. Linker^.MakeSharedLibrary
  1290. else
  1291. Linker^.MakeExecutable;
  1292. end;
  1293. end;
  1294. end;
  1295. end.
  1296. {
  1297. $Log$
  1298. Revision 1.160 1999-10-21 14:29:37 peter
  1299. * redesigned linker object
  1300. + library support for linux (only procedures can be exported)
  1301. Revision 1.159 1999/10/12 21:20:45 florian
  1302. * new codegenerator compiles again
  1303. Revision 1.158 1999/10/03 19:44:42 peter
  1304. * removed objpasunit reference, tvarrec is now searched in systemunit
  1305. where it already was located
  1306. Revision 1.157 1999/09/27 23:44:54 peter
  1307. * procinfo is now a pointer
  1308. * support for result setting in sub procedure
  1309. Revision 1.156 1999/09/20 16:39:00 peter
  1310. * cs_create_smart instead of cs_smartlink
  1311. * -CX is create smartlink
  1312. * -CD is create dynamic, but does nothing atm.
  1313. Revision 1.155 1999/09/16 23:05:54 florian
  1314. * m68k compiler is again compilable (only gas writer, no assembler reader)
  1315. Revision 1.154 1999/09/16 14:18:12 pierre
  1316. + warning if truncate unit name found
  1317. Revision 1.153 1999/09/13 22:56:17 peter
  1318. * fixed crashes under plain dos
  1319. Revision 1.152 1999/09/01 22:18:42 peter
  1320. * moved parsing interface/implementation to -vu
  1321. Revision 1.151 1999/08/31 15:51:10 pierre
  1322. * in_second_compile cleaned up, in_compile and in_second_load added
  1323. Revision 1.150 1999/08/30 16:21:40 pierre
  1324. * tempclosing of ppufiles under dos was wrong
  1325. Revision 1.149 1999/08/28 15:34:19 florian
  1326. * bug 519 fixed
  1327. Revision 1.148 1999/08/27 14:53:00 pierre
  1328. * double checksum problem solved
  1329. Revision 1.147 1999/08/27 10:57:56 pierre
  1330. + define SHORT_ON_FILE_HANDLES for DOS targets
  1331. causes tempclose of ppufiles
  1332. + double_checksum code released
  1333. (you can try with -dDONT_USE_DOUBLE_CHECKSUM to see the difference)
  1334. this allow second compilation of compiler without any
  1335. unit recompilation !!!!
  1336. Revision 1.146 1999/08/26 21:16:21 peter
  1337. * write date of the compiler into the executable
  1338. Revision 1.145 1999/08/26 20:24:44 michael
  1339. + Hopefuly last fixes for resourcestrings
  1340. Revision 1.144 1999/08/24 22:38:53 michael
  1341. * more resourcestring changes
  1342. Revision 1.143 1999/08/24 12:01:34 michael
  1343. + changes for resourcestrings
  1344. Revision 1.142 1999/08/16 15:35:27 pierre
  1345. * fix for DLL relocation problems
  1346. * external bss vars had wrong stabs for pecoff
  1347. + -WB11000000 to specify default image base, allows to
  1348. load several DLLs with debugging info included
  1349. (relocatable DLL are stripped because the relocation
  1350. of the .Stab section is misplaced by ldw)
  1351. Revision 1.141 1999/08/11 17:26:36 peter
  1352. * tlinker object is now inherited for win32 and dos
  1353. * postprocessexecutable is now a method of tlinker
  1354. Revision 1.140 1999/08/04 13:02:57 jonas
  1355. * all tokens now start with an underscore
  1356. * PowerPC compiles!!
  1357. Revision 1.139 1999/08/04 00:23:15 florian
  1358. * renamed i386asm and i386base to cpuasm and cpubase
  1359. Revision 1.138 1999/08/03 22:03:02 peter
  1360. * moved bitmask constants to sets
  1361. * some other type/const renamings
  1362. Revision 1.137 1999/08/03 17:09:38 florian
  1363. * the alpha compiler can be compiled now
  1364. Revision 1.136 1999/08/02 17:17:10 florian
  1365. * small changes for the new code generator
  1366. Revision 1.135 1999/07/29 20:54:04 peter
  1367. * write .size also
  1368. Revision 1.134 1999/07/26 09:42:11 florian
  1369. * bugs 494-496 fixed
  1370. Revision 1.133 1999/07/24 00:13:25 peter
  1371. * also number units for program
  1372. Revision 1.132 1999/07/23 11:37:48 peter
  1373. * error for illegal type reference, instead of 10998
  1374. Revision 1.131 1999/07/22 09:37:54 florian
  1375. + resourcestring implemented
  1376. + start of longstring support
  1377. Revision 1.130 1999/07/14 21:19:11 florian
  1378. + implemented a better error message if a PPU file isn't found as suggested
  1379. by Lee John
  1380. Revision 1.129 1999/07/06 21:48:24 florian
  1381. * a lot bug fixes:
  1382. - po_external isn't any longer necessary for procedure compatibility
  1383. - m_tp_procvar is in -Sd now available
  1384. - error messages of procedure variables improved
  1385. - return values with init./finalization fixed
  1386. - data types with init./finalization aren't any longer allowed in variant
  1387. record
  1388. Revision 1.128 1999/07/06 00:53:48 peter
  1389. * merged
  1390. Revision 1.127 1999/07/05 16:21:27 peter
  1391. * fixed linking for units without linking necessary
  1392. Revision 1.126 1999/07/03 00:29:56 peter
  1393. * new link writing to the ppu, one .ppu is needed for all link types,
  1394. static (.o) is now always created also when smartlinking is used
  1395. Revision 1.125 1999/06/15 13:57:32 peter
  1396. * merged
  1397. Revision 1.124.2.2 1999/07/06 00:47:52 peter
  1398. * killed recompile bug
  1399. Revision 1.124.2.1 1999/06/15 13:54:26 peter
  1400. * don't run ar anymore for binary writer, also not with -CS
  1401. Revision 1.124 1999/05/27 19:44:48 peter
  1402. * removed oldasm
  1403. * plabel -> pasmlabel
  1404. * -a switches to source writing automaticly
  1405. * assembler readers OOPed
  1406. * asmsymbol automaticly external
  1407. * jumptables and other label fixes for asm readers
  1408. Revision 1.123 1999/05/21 13:55:06 peter
  1409. * NEWLAB for label as symbol
  1410. Revision 1.122 1999/05/18 22:36:29 pierre
  1411. * little redondant code removed
  1412. Revision 1.121 1999/05/17 14:43:54 pierre
  1413. * reset current_ppu to nil when appropriate
  1414. Revision 1.120 1999/05/13 21:59:35 peter
  1415. * removed oldppu code
  1416. * warning if objpas is loaded from uses
  1417. * first things for new deref writing
  1418. Revision 1.119 1999/05/09 11:38:08 peter
  1419. * don't write .o and link if errors occure during assembling
  1420. Revision 1.118 1999/05/03 18:03:28 peter
  1421. * no ar.exe running field in target_asm
  1422. Revision 1.117 1999/05/01 13:24:32 peter
  1423. * merged nasm compiler
  1424. * old asm moved to oldasm/
  1425. Revision 1.116 1999/04/26 23:22:42 peter
  1426. * fixed double .o file insertion
  1427. Revision 1.115 1999/04/26 18:29:58 peter
  1428. * farpointerdef moved into pointerdef.is_far
  1429. Revision 1.114 1999/04/26 13:31:39 peter
  1430. * release storenumber,double_checksum
  1431. Revision 1.113 1999/04/25 17:32:14 peter
  1432. * fixed double_checksum
  1433. Revision 1.112 1999/04/25 15:08:38 peter
  1434. * small fixes for double_checksum
  1435. Revision 1.111 1999/04/21 09:43:46 peter
  1436. * storenumber works
  1437. * fixed some typos in double_checksum
  1438. + incompatible types type1 and type2 message (with storenumber)
  1439. Revision 1.110 1999/04/17 13:14:52 peter
  1440. * concat_external added for new init/final
  1441. Revision 1.109 1999/04/15 12:19:59 peter
  1442. + finalization support
  1443. Revision 1.108 1999/04/14 09:14:52 peter
  1444. * first things to store the symbol/def number in the ppu
  1445. Revision 1.107 1999/04/08 10:53:54 michael
  1446. * Fixed forgotten ;
  1447. Revision 1.106 1999/04/07 15:39:30 pierre
  1448. + double_checksum code added
  1449. Revision 1.105 1999/03/26 00:05:38 peter
  1450. * released valintern
  1451. + deffile is now removed when compiling is finished
  1452. * ^( compiles now correct
  1453. + static directive
  1454. * shrd fixed
  1455. Revision 1.104 1999/03/24 23:17:17 peter
  1456. * fixed bugs 212,222,225,227,229,231,233
  1457. Revision 1.103 1999/03/18 20:30:46 peter
  1458. + .a writer
  1459. Revision 1.102 1999/03/16 21:07:25 peter
  1460. * check for dup uses
  1461. Revision 1.101 1999/02/25 21:02:43 peter
  1462. * ag386bin updates
  1463. + coff writer
  1464. Revision 1.100 1999/02/23 18:29:20 pierre
  1465. * win32 compilation error fix
  1466. + some work for local browser (not cl=omplete yet)
  1467. Revision 1.99 1999/02/22 13:06:58 pierre
  1468. + -b and -bl options work !
  1469. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  1470. is not enabled when quitting global section
  1471. * local vars and procedures are not yet stored into PPU
  1472. Revision 1.98 1999/02/22 02:15:29 peter
  1473. * updates for ag386bin
  1474. Revision 1.97 1999/02/16 00:45:31 peter
  1475. * fixed crashes by forgotten strpnew() for init_symbol
  1476. Revision 1.96 1999/02/05 08:54:27 pierre
  1477. + linkofiles splitted inot linkofiles and linkunitfiles
  1478. because linkofiles must be stored with directory
  1479. to enabled linking of different objects with same name
  1480. in a different directory
  1481. Revision 1.95 1999/02/03 09:44:36 pierre
  1482. * symbol nubering begins with 1 in number_symbols
  1483. * program tmodule has globalsymtable for its staticsymtable
  1484. (to get it displayed in IDE globals list)
  1485. + list of symbol (browcol) greatly improved for IDE
  1486. Revision 1.94 1999/01/12 14:25:31 peter
  1487. + BrowserLog for browser.log generation
  1488. + BrowserCol for browser info in TCollections
  1489. * released all other UseBrowser
  1490. Revision 1.93 1999/01/06 12:39:46 peter
  1491. * renamed resource -> comprsrc (conflicted with FV)
  1492. Revision 1.92 1998/12/28 23:26:23 peter
  1493. + resource file handling ($R directive) for Win32
  1494. Revision 1.91 1998/12/15 17:14:17 peter
  1495. * fix for tp7
  1496. Revision 1.90 1998/12/15 10:23:26 peter
  1497. + -iSO, -iSP, -iTO, -iTP
  1498. Revision 1.89 1998/12/11 00:03:34 peter
  1499. + globtype,tokens,version unit splitted from globals
  1500. Revision 1.88 1998/12/08 10:18:11 peter
  1501. + -gh for heaptrc unit
  1502. Revision 1.87 1998/12/01 23:40:53 pierre
  1503. * new try for correct debug info generation
  1504. Revision 1.86 1998/11/30 09:43:22 pierre
  1505. * some range check bugs fixed (still not working !)
  1506. + added DLL writing support for win32 (also accepts variables)
  1507. + TempAnsi for code that could be used for Temporary ansi strings
  1508. handling
  1509. Revision 1.85 1998/11/28 16:20:54 peter
  1510. + support for dll variables
  1511. Revision 1.84 1998/11/18 09:18:03 pierre
  1512. + automatic loading of profile unit with -pg option
  1513. in go32v2 mode (also defines FPC_PROFILE)
  1514. * some memory leaks removed
  1515. * unreleased temp problem with sets solved
  1516. Revision 1.83 1998/11/16 11:29:00 pierre
  1517. * stackcheck removed for i386_win32
  1518. * exportlist does not crash at least !!
  1519. (was need for tests dir !)z
  1520. Revision 1.82 1998/11/12 12:55:16 pierre
  1521. * fix for bug0176 and bug0177
  1522. Revision 1.81 1998/11/12 11:34:58 peter
  1523. * fix for empty .o files and linking of libs
  1524. Revision 1.80 1998/11/06 09:48:14 pierre
  1525. * double initialization code calling bug fixed
  1526. Revision 1.79 1998/11/03 11:33:11 peter
  1527. + search_unit arg to only search for sources
  1528. Revision 1.78 1998/10/30 12:23:41 peter
  1529. * fix for lognunitname and longunit.pas
  1530. Revision 1.77 1998/10/29 11:35:52 florian
  1531. * some dll support for win32
  1532. * fixed assembler writing for PalmOS
  1533. Revision 1.76 1998/10/28 18:26:15 pierre
  1534. * removed some erros after other errors (introduced by useexcept)
  1535. * stabs works again correctly (for how long !)
  1536. Revision 1.75 1998/10/27 13:45:35 pierre
  1537. * classes get a vmt allways
  1538. * better error info (tried to remove
  1539. several error strings introduced by the tpexcept handling)
  1540. Revision 1.74 1998/10/26 09:34:50 peter
  1541. * unit check name works now for all units, not only systemunit
  1542. Revision 1.73 1998/10/22 23:53:27 peter
  1543. * leave when an error has been in the interface (else other units could
  1544. be compiled with the implementation uses!)
  1545. * don't always compile when not in implementation with a second_load
  1546. Revision 1.72 1998/10/22 11:36:34 peter
  1547. * fixed imports generation at the wrong place
  1548. Revision 1.71 1998/10/21 20:13:10 peter
  1549. * check for importsection for empty asm file
  1550. Revision 1.70 1998/10/20 09:30:05 peter
  1551. * set also in_library flag when no .o is generated
  1552. Revision 1.68 1998/10/19 08:54:59 pierre
  1553. * wrong stabs info corrected once again !!
  1554. + variable vmt offset with vmt field only if required
  1555. implemented now !!!
  1556. Revision 1.67 1998/10/13 13:10:25 peter
  1557. * new style for m68k/i386 infos and enums
  1558. Revision 1.66 1998/10/09 16:36:05 pierre
  1559. * some memory leaks specific to usebrowser define fixed
  1560. * removed tmodule.implsymtable (was like tmodule.localsymtable)
  1561. Revision 1.65 1998/10/09 14:38:55 pierre
  1562. * add a second load for PPU file
  1563. Revision 1.64 1998/10/09 08:56:28 pierre
  1564. * several memory leaks fixed
  1565. Revision 1.63 1998/10/08 23:29:01 peter
  1566. * -vu shows unit info, -vt shows tried/used files
  1567. Revision 1.62 1998/10/08 17:17:25 pierre
  1568. * current_module old scanner tagged as invalid if unit is recompiled
  1569. + added ppheap for better info on tracegetmem of heaptrc
  1570. (adds line column and file index)
  1571. * several memory leaks removed ith help of heaptrc !!
  1572. Revision 1.61 1998/10/08 13:48:47 peter
  1573. * fixed memory leaks for do nothing source
  1574. * fixed unit interdependency
  1575. Revision 1.60 1998/10/06 17:16:54 pierre
  1576. * some memory leaks fixed (thanks to Peter for heaptrc !)
  1577. Revision 1.59 1998/10/05 21:33:26 peter
  1578. * fixed 161,165,166,167,168
  1579. Revision 1.58 1998/09/30 16:43:37 peter
  1580. * fixed unit interdependency with circular uses
  1581. Revision 1.57 1998/09/30 12:11:52 peter
  1582. * fixed circular uses which looped forever
  1583. Revision 1.56 1998/09/28 11:22:15 pierre
  1584. * did not compile for browser
  1585. * merge from fixes
  1586. Revision 1.48.2.1 1998/09/28 10:55:16 pierre
  1587. fix for current_module dispose bug
  1588. Revision 1.55 1998/09/28 11:04:03 peter
  1589. * fixed loaddefaultunits which was at the wrong place for programs, so
  1590. the default defs were not loaded when main was initialized
  1591. Revision 1.54 1998/09/24 23:49:12 peter
  1592. + aktmodeswitches
  1593. Revision 1.53 1998/09/23 12:20:50 pierre
  1594. * main program tmodule had no symtable (crashed browser)
  1595. * unit symbols problem fixed !!
  1596. Revision 1.52 1998/09/22 17:13:49 pierre
  1597. + browsing updated and developed
  1598. records and objects fields are also stored
  1599. Revision 1.51 1998/09/22 15:40:55 peter
  1600. * some extra ifdef GDB
  1601. Revision 1.50 1998/09/21 08:45:17 pierre
  1602. + added vmt_offset in tobjectdef.write for fututre use
  1603. (first steps to have objects without vmt if no virtual !!)
  1604. + added fpu_used field for tabstractprocdef :
  1605. sets this level to 2 if the functions return with value in FPU
  1606. (is then set to correct value at parsing of implementation)
  1607. THIS MIGHT refuse some code with FPU expression too complex
  1608. that were accepted before and even in some cases
  1609. that don't overflow in fact
  1610. ( like if f : float; is a forward that finally in implementation
  1611. only uses one fpu register !!)
  1612. Nevertheless I think that it will improve security on
  1613. FPU operations !!
  1614. * most other changes only for UseBrowser code
  1615. (added symtable references for record and objects)
  1616. local switch for refs to args and local of each function
  1617. (static symtable still missing)
  1618. UseBrowser still not stable and probably broken by
  1619. the definition hash array !!
  1620. Revision 1.49 1998/09/18 08:01:36 pierre
  1621. + improvement on the usebrowser part
  1622. (does not work correctly for now)
  1623. Revision 1.48 1998/09/09 15:33:07 peter
  1624. * fixed in_global to allow directives also after interface token
  1625. Revision 1.47 1998/09/09 11:50:55 pierre
  1626. * forward def are not put in record or objects
  1627. + added check for forwards also in record and objects
  1628. * dummy parasymtable for unit initialization removed from
  1629. symtable stack
  1630. Revision 1.46 1998/09/03 11:24:01 peter
  1631. * moved more inputfile things from tscannerfile to tinputfile
  1632. * changed ifdef Sourceline to cs_asm_source
  1633. Revision 1.45 1998/08/31 12:26:28 peter
  1634. * m68k and palmos updates from surebugfixes
  1635. Revision 1.44 1998/08/26 15:35:33 peter
  1636. * fixed scannerfiles for macros
  1637. + $I %<environment>%
  1638. Revision 1.43 1998/08/26 10:08:47 peter
  1639. * fixed problem with libprefix at the wrong place
  1640. * fixed lib generation with smartlinking and no -CS used
  1641. Revision 1.42 1998/08/19 18:04:54 peter
  1642. * fixed current_module^.in_implementation flag
  1643. Revision 1.41 1998/08/17 10:10:08 peter
  1644. - removed OLDPPU
  1645. Revision 1.40 1998/08/17 09:17:50 peter
  1646. * static/shared linking updates
  1647. Revision 1.39 1998/08/14 21:56:37 peter
  1648. * setting the outputfile using -o works now to create static libs
  1649. Revision 1.38 1998/08/10 14:50:13 peter
  1650. + localswitches, moduleswitches, globalswitches splitting
  1651. Revision 1.37 1998/08/10 10:18:31 peter
  1652. + Compiler,Comphook unit which are the new interface units to the
  1653. compiler
  1654. Revision 1.36 1998/07/14 14:46:54 peter
  1655. * released NEWINPUT
  1656. Revision 1.35 1998/07/08 12:39:38 peter
  1657. * heap_size for m68k
  1658. Revision 1.34 1998/07/07 11:20:03 peter
  1659. + NEWINPUT for a better inputfile and scanner object
  1660. Revision 1.33 1998/06/25 11:15:34 pierre
  1661. * ppu files where not closed in newppu !!
  1662. second compilation was impossible due to too many opened files
  1663. (not visible in 'make cycle' as we remove all the ppu files)
  1664. Revision 1.32 1998/06/25 08:48:16 florian
  1665. * first version of rtti support
  1666. Revision 1.31 1998/06/24 14:48:35 peter
  1667. * ifdef newppu -> ifndef oldppu
  1668. Revision 1.30 1998/06/17 14:10:16 peter
  1669. * small os2 fixes
  1670. * fixed interdependent units with newppu (remake3 under linux works now)
  1671. Revision 1.29 1998/06/16 08:56:25 peter
  1672. + targetcpu
  1673. * cleaner pmodules for newppu
  1674. Revision 1.28 1998/06/13 00:10:10 peter
  1675. * working browser and newppu
  1676. * some small fixes against crashes which occured in bp7 (but not in
  1677. fpc?!)
  1678. Revision 1.27 1998/06/11 13:58:08 peter
  1679. * small fix to let newppu compile
  1680. Revision 1.26 1998/06/09 16:01:47 pierre
  1681. + added procedure directive parsing for procvars
  1682. (accepted are popstack cdecl and pascal)
  1683. + added C vars with the following syntax
  1684. var C calias 'true_c_name';(can be followed by external)
  1685. reason is that you must add the Cprefix
  1686. which is target dependent
  1687. Revision 1.25 1998/06/08 22:59:49 peter
  1688. * smartlinking works for win32
  1689. * some defines to exclude some compiler parts
  1690. Revision 1.24 1998/06/08 13:13:44 pierre
  1691. + temporary variables now in temp_gen.pas unit
  1692. because it is processor independent
  1693. * mppc68k.bat modified to undefine i386 and support_mmx
  1694. (which are defaults for i386)
  1695. Revision 1.23 1998/06/05 17:47:29 peter
  1696. * some better uses clauses
  1697. Revision 1.22 1998/06/05 14:37:34 pierre
  1698. * fixes for inline for operators
  1699. * inline procedure more correctly restricted
  1700. Revision 1.21 1998/06/04 23:51:53 peter
  1701. * m68k compiles
  1702. + .def file creation moved to gendef.pas so it could also be used
  1703. for win32
  1704. Revision 1.20 1998/06/04 09:55:42 pierre
  1705. * demangled name of procsym reworked to become independant of the mangling scheme
  1706. Revision 1.19 1998/06/03 23:40:38 peter
  1707. + unlimited file support, release tempclose
  1708. Revision 1.18 1998/06/03 22:49:00 peter
  1709. + wordbool,longbool
  1710. * rename bis,von -> high,low
  1711. * moved some systemunit loading/creating to psystem.pas
  1712. Revision 1.17 1998/05/28 14:40:25 peter
  1713. * fixes for newppu, remake3 works now with it
  1714. Revision 1.16 1998/05/27 19:45:06 peter
  1715. * symtable.pas splitted into includefiles
  1716. * symtable adapted for $ifdef NEWPPU
  1717. Revision 1.15 1998/05/23 01:21:22 peter
  1718. + aktasmmode, aktoptprocessor, aktoutputformat
  1719. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1720. + $LIBNAME to set the library name where the unit will be put in
  1721. * splitted cgi386 a bit (codeseg to large for bp7)
  1722. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1723. Revision 1.14 1998/05/20 09:42:35 pierre
  1724. + UseTokenInfo now default
  1725. * unit in interface uses and implementation uses gives error now
  1726. * only one error for unknown symbol (uses lastsymknown boolean)
  1727. the problem came from the label code !
  1728. + first inlined procedures and function work
  1729. (warning there might be allowed cases were the result is still wrong !!)
  1730. * UseBrower updated gives a global list of all position of all used symbols
  1731. with switch -gb
  1732. Revision 1.13 1998/05/12 10:47:00 peter
  1733. * moved printstatus to verb_def
  1734. + V_Normal which is between V_Error and V_Warning and doesn't have a
  1735. prefix like error: warning: and is included in V_Default
  1736. * fixed some messages
  1737. * first time parameter scan is only for -v and -T
  1738. - removed old style messages
  1739. Revision 1.12 1998/05/11 13:07:56 peter
  1740. + $ifdef NEWPPU for the new ppuformat
  1741. + $define GDB not longer required
  1742. * removed all warnings and stripped some log comments
  1743. * no findfirst/findnext anymore to remove smartlink *.o files
  1744. Revision 1.11 1998/05/06 18:36:53 peter
  1745. * tai_section extended with code,data,bss sections and enumerated type
  1746. * ident 'compiled by FPC' moved to pmodules
  1747. * small fix for smartlink
  1748. Revision 1.10 1998/05/04 17:54:28 peter
  1749. + smartlinking works (only case jumptable left todo)
  1750. * redesign of systems.pas to support assemblers and linkers
  1751. + Unitname is now also in the PPU-file, increased version to 14
  1752. Revision 1.9 1998/05/01 16:38:45 florian
  1753. * handling of private and protected fixed
  1754. + change_keywords_to_tp implemented to remove
  1755. keywords which aren't supported by tp
  1756. * break and continue are now symbols of the system unit
  1757. + widestring, longstring and ansistring type released
  1758. Revision 1.8 1998/04/30 15:59:41 pierre
  1759. * GDB works again better :
  1760. correct type info in one pass
  1761. + UseTokenInfo for better source position
  1762. * fixed one remaining bug in scanner for line counts
  1763. * several little fixes
  1764. Revision 1.7 1998/04/29 10:33:59 pierre
  1765. + added some code for ansistring (not complete nor working yet)
  1766. * corrected operator overloading
  1767. * corrected nasm output
  1768. + started inline procedures
  1769. + added starstarn : use ** for exponentiation (^ gave problems)
  1770. + started UseTokenInfo cond to get accurate positions
  1771. Revision 1.6 1998/04/27 23:10:28 peter
  1772. + new scanner
  1773. * $makelib -> if smartlink
  1774. * small filename fixes pmodule.setfilename
  1775. * moved import from files.pas -> import.pas
  1776. Revision 1.5 1998/04/14 23:27:03 florian
  1777. + exclude/include with constant second parameter added
  1778. Revision 1.4 1998/04/10 14:41:43 peter
  1779. * removed some Hints
  1780. * small speed optimization for AsmLn
  1781. Revision 1.3 1998/04/03 09:51:00 daniel
  1782. * Fixed heap allocation for OS/2.
  1783. }