pmodules.pas 65 KB

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