pmodules.pas 55 KB

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