pmodules.pas 72 KB

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