pmodules.pas 68 KB

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