pmodules.pas 53 KB

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