pmodules.pas 57 KB

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