pmodules.pas 72 KB

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