pmodules.pas 72 KB

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