pmodules.pas 56 KB

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