pmodules.pas 69 KB

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