pmodules.pas 55 KB

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