parser.pas 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit does the parsing process
  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 parser;
  19. {$i fpcdefs.inc}
  20. interface
  21. {$ifdef PREPROCWRITE}
  22. procedure preprocess(const filename:string);
  23. {$endif PREPROCWRITE}
  24. procedure compile(const filename:string);
  25. procedure initparser;
  26. procedure doneparser;
  27. implementation
  28. uses
  29. cutils,cclasses,
  30. globtype,version,tokens,systems,globals,verbose,
  31. symbase,symtable,symsym,
  32. finput,fmodule,fppu,
  33. aasmbase,aasmtai,
  34. cgbase,
  35. script,gendef,
  36. {$ifdef BrowserLog}
  37. browlog,
  38. {$endif BrowserLog}
  39. {$ifdef UseExcept}
  40. tpexcept,
  41. {$endif UseExcept}
  42. {$ifdef GDB}
  43. gdb,
  44. {$endif GDB}
  45. comphook,
  46. scanner,scandir,
  47. pbase,ptype,psystem,pmodules,psub,
  48. cresstr,cpuinfo,procinfo;
  49. procedure initparser;
  50. begin
  51. { ^M means a string or a char, because we don't parse a }
  52. { type declaration }
  53. ignore_equal:=false;
  54. { we didn't parse a object or class declaration }
  55. { and no function header }
  56. testcurobject:=0;
  57. { Current compiled module/proc }
  58. objectlibrary:=nil;
  59. current_module:=nil;
  60. compiled_module:=nil;
  61. current_procinfo:=nil;
  62. loaded_units:=TLinkedList.Create;
  63. usedunits:=TLinkedList.Create;
  64. { global switches }
  65. aktglobalswitches:=initglobalswitches;
  66. aktsourcecodepage:=initsourcecodepage;
  67. { initialize scanner }
  68. InitScanner;
  69. InitScannerDirectives;
  70. { scanner }
  71. c:=#0;
  72. pattern:='';
  73. orgpattern:='';
  74. current_scanner:=nil;
  75. { register all nodes and tais }
  76. registernodes;
  77. registertais;
  78. { memory sizes }
  79. if heapsize=0 then
  80. heapsize:=target_info.heapsize;
  81. if stacksize=0 then
  82. stacksize:=target_info.stacksize;
  83. { open assembler response }
  84. if cs_link_on_target in aktglobalswitches then
  85. GenerateAsmRes(outputexedir+inputfile+'_ppas')
  86. else
  87. GenerateAsmRes(outputexedir+'ppas');
  88. { open deffile }
  89. DefFile:=TDefFile.Create(outputexedir+inputfile+target_info.defext);
  90. { list of generated .o files, so the linker can remove them }
  91. SmartLinkOFiles:=TStringList.Create;
  92. { codegen }
  93. if paraprintnodetree<>0 then
  94. printnode_reset;
  95. { target specific stuff }
  96. case target_info.system of
  97. system_powerpc_morphos:
  98. include(supported_calling_conventions,pocall_syscall);
  99. system_m68k_amiga:
  100. include(supported_calling_conventions,pocall_syscall);
  101. end;
  102. end;
  103. procedure doneparser;
  104. begin
  105. { Reset current compiling info, so destroy routines can't
  106. reference the data that might already be destroyed }
  107. objectlibrary:=nil;
  108. current_module:=nil;
  109. compiled_module:=nil;
  110. current_procinfo:=nil;
  111. { unload units }
  112. loaded_units.free;
  113. usedunits.free;
  114. { if there was an error in the scanner, the scanner is
  115. still assinged }
  116. if assigned(current_scanner) then
  117. begin
  118. current_scanner.free;
  119. current_scanner:=nil;
  120. end;
  121. { close scanner }
  122. DoneScanner;
  123. { close ppas,deffile }
  124. asmres.free;
  125. deffile.free;
  126. { free list of .o files }
  127. SmartLinkOFiles.Free;
  128. end;
  129. procedure default_macros;
  130. var
  131. hp : tstringlistitem;
  132. begin
  133. { commandline }
  134. hp:=tstringlistitem(initdefines.first);
  135. while assigned(hp) do
  136. begin
  137. current_scanner.def_macro(hp.str);
  138. hp:=tstringlistitem(hp.next);
  139. end;
  140. { set macros for version checking }
  141. current_scanner.set_macro('FPC_VERSION',version_nr);
  142. current_scanner.set_macro('FPC_RELEASE',release_nr);
  143. current_scanner.set_macro('FPC_PATCH',patch_nr);
  144. end;
  145. {$ifdef PREPROCWRITE}
  146. procedure preprocess(const filename:string);
  147. var
  148. i : longint;
  149. begin
  150. new(preprocfile,init('pre'));
  151. { default macros }
  152. current_scanner^.macros:=new(pdictionary,init);
  153. default_macros;
  154. { initialize a module }
  155. current_module:=new(pmodule,init(filename,false));
  156. main_module:=current_module;
  157. { startup scanner, and save in current_module }
  158. current_scanner:=new(pscannerfile,Init(filename));
  159. current_module.scanner:=current_scanner;
  160. { loop until EOF is found }
  161. repeat
  162. current_scanner^.readtoken;
  163. preprocfile^.AddSpace;
  164. case token of
  165. _ID :
  166. begin
  167. preprocfile^.Add(orgpattern);
  168. end;
  169. _REALNUMBER,
  170. _INTCONST :
  171. preprocfile^.Add(pattern);
  172. _CSTRING :
  173. begin
  174. i:=0;
  175. while (i<length(pattern)) do
  176. begin
  177. inc(i);
  178. if pattern[i]='''' then
  179. begin
  180. insert('''',pattern,i);
  181. inc(i);
  182. end;
  183. end;
  184. preprocfile^.Add(''''+pattern+'''');
  185. end;
  186. _CCHAR :
  187. begin
  188. case pattern[1] of
  189. #39 :
  190. pattern:='''''''';
  191. #0..#31,
  192. #128..#255 :
  193. begin
  194. str(ord(pattern[1]),pattern);
  195. pattern:='#'+pattern;
  196. end;
  197. else
  198. pattern:=''''+pattern[1]+'''';
  199. end;
  200. preprocfile^.Add(pattern);
  201. end;
  202. _EOF :
  203. break;
  204. else
  205. preprocfile^.Add(tokeninfo^[token].str)
  206. end;
  207. until false;
  208. { free scanner }
  209. dispose(current_scanner,done);
  210. current_scanner:=nil;
  211. { close }
  212. dispose(preprocfile,done);
  213. end;
  214. {$endif PREPROCWRITE}
  215. {*****************************************************************************
  216. Create information for a new module
  217. *****************************************************************************}
  218. procedure init_module;
  219. begin
  220. { Create assembler output lists for CG }
  221. exprasmlist:=taasmoutput.create;
  222. datasegment:=taasmoutput.create;
  223. codesegment:=taasmoutput.create;
  224. bsssegment:=taasmoutput.create;
  225. debuglist:=taasmoutput.create;
  226. withdebuglist:=taasmoutput.create;
  227. consts:=taasmoutput.create;
  228. rttilist:=taasmoutput.create;
  229. picdata:=taasmoutput.create;
  230. if target_info.system=system_powerpc_darwin then
  231. picdata.concat(tai_simple.create(ait_non_lazy_symbol_pointer));
  232. ResourceStringList:=Nil;
  233. importssection:=nil;
  234. exportssection:=nil;
  235. resourcesection:=nil;
  236. { Resource strings }
  237. ResourceStrings:=TResourceStrings.Create;
  238. { use the librarydata from current_module }
  239. objectlibrary:=current_module.librarydata;
  240. end;
  241. procedure done_module;
  242. {$ifdef MEMDEBUG}
  243. var
  244. d : tmemdebug;
  245. {$endif}
  246. begin
  247. {$ifdef MEMDEBUG}
  248. d:=tmemdebug.create(current_module.modulename^+' - asmlists');
  249. {$endif}
  250. exprasmlist.free;
  251. codesegment.free;
  252. bsssegment.free;
  253. datasegment.free;
  254. debuglist.free;
  255. withdebuglist.free;
  256. consts.free;
  257. rttilist.free;
  258. picdata.free;
  259. if assigned(ResourceStringList) then
  260. ResourceStringList.free;
  261. if assigned(importssection) then
  262. importssection.free;
  263. if assigned(exportssection) then
  264. exportssection.free;
  265. if assigned(resourcesection) then
  266. resourcesection.free;
  267. {$ifdef MEMDEBUG}
  268. d.free;
  269. {$endif}
  270. { resource strings }
  271. ResourceStrings.free;
  272. objectlibrary:=nil;
  273. end;
  274. {*****************************************************************************
  275. Compile a source file
  276. *****************************************************************************}
  277. procedure compile(const filename:string);
  278. type
  279. polddata=^tolddata;
  280. tolddata=record
  281. { scanner }
  282. oldidtoken,
  283. oldtoken : ttoken;
  284. oldtokenpos : tfileposinfo;
  285. oldc : char;
  286. oldpattern,
  287. oldorgpattern : string;
  288. old_block_type : tblock_type;
  289. { symtable }
  290. oldrefsymtable,
  291. olddefaultsymtablestack,
  292. oldsymtablestack : tsymtable;
  293. oldaktprocsym : tprocsym;
  294. { cg }
  295. oldparse_only : boolean;
  296. { asmlists }
  297. oldimports,
  298. oldexports,
  299. oldresource,
  300. oldrttilist,
  301. oldpicdata,
  302. oldresourcestringlist,
  303. oldbsssegment,
  304. olddatasegment,
  305. oldcodesegment,
  306. oldexprasmlist,
  307. olddebuglist,
  308. oldwithdebuglist,
  309. oldconsts : taasmoutput;
  310. oldobjectlibrary : tasmlibrarydata;
  311. { resourcestrings }
  312. OldResourceStrings : tResourceStrings;
  313. { akt.. things }
  314. oldaktlocalswitches : tlocalswitches;
  315. oldaktmoduleswitches : tmoduleswitches;
  316. oldaktfilepos : tfileposinfo;
  317. oldaktpackrecords,
  318. oldaktpackenum,oldaktmaxfpuregisters : longint;
  319. oldaktalignment : talignmentinfo;
  320. oldaktoutputformat : tasm;
  321. oldaktspecificoptprocessor,
  322. oldaktoptprocessor : tprocessors;
  323. oldaktfputype : tfputype;
  324. oldaktasmmode : tasmmode;
  325. oldaktinterfacetype: tinterfacetypes;
  326. oldaktmodeswitches : tmodeswitches;
  327. old_compiled_module : tmodule;
  328. oldcurrent_procinfo : tprocinfo;
  329. oldaktdefproccall : tproccalloption;
  330. oldsourcecodepage : tcodepagestring;
  331. {$ifdef GDB}
  332. store_dbx : plongint;
  333. {$endif GDB}
  334. end;
  335. var
  336. olddata : polddata;
  337. {$ifdef USEEXCEPT}
  338. {$ifndef Delphi}
  339. recoverpos : jmp_buf;
  340. oldrecoverpos : pjmp_buf;
  341. {$endif Delphi}
  342. {$endif useexcept}
  343. begin
  344. inc(compile_level);
  345. parser_current_file:=filename;
  346. { Uses heap memory instead of placing everything on the
  347. stack. This is needed because compile() can be called
  348. recursively }
  349. new(olddata);
  350. with olddata^ do
  351. begin
  352. old_compiled_module:=compiled_module;
  353. { save symtable state }
  354. oldsymtablestack:=symtablestack;
  355. olddefaultsymtablestack:=defaultsymtablestack;
  356. oldrefsymtable:=refsymtable;
  357. oldcurrent_procinfo:=current_procinfo;
  358. oldaktdefproccall:=aktdefproccall;
  359. { save scanner state }
  360. oldc:=c;
  361. oldpattern:=pattern;
  362. oldorgpattern:=orgpattern;
  363. oldtoken:=token;
  364. oldidtoken:=idtoken;
  365. old_block_type:=block_type;
  366. oldtokenpos:=akttokenpos;
  367. oldsourcecodepage:=aktsourcecodepage;
  368. { save cg }
  369. oldparse_only:=parse_only;
  370. { save assembler lists }
  371. olddatasegment:=datasegment;
  372. oldbsssegment:=bsssegment;
  373. oldcodesegment:=codesegment;
  374. olddebuglist:=debuglist;
  375. oldwithdebuglist:=withdebuglist;
  376. oldconsts:=consts;
  377. oldrttilist:=rttilist;
  378. oldpicdata:=picdata;
  379. oldexprasmlist:=exprasmlist;
  380. oldimports:=importssection;
  381. oldexports:=exportssection;
  382. oldresource:=resourcesection;
  383. oldresourcestringlist:=resourcestringlist;
  384. oldobjectlibrary:=objectlibrary;
  385. OldResourceStrings:=ResourceStrings;
  386. { save akt... state }
  387. { handle the postponed case first }
  388. if localswitcheschanged then
  389. begin
  390. aktlocalswitches:=nextaktlocalswitches;
  391. localswitcheschanged:=false;
  392. end;
  393. oldaktlocalswitches:=aktlocalswitches;
  394. oldaktmoduleswitches:=aktmoduleswitches;
  395. oldaktalignment:=aktalignment;
  396. oldaktpackenum:=aktpackenum;
  397. oldaktpackrecords:=aktpackrecords;
  398. oldaktfputype:=aktfputype;
  399. oldaktmaxfpuregisters:=aktmaxfpuregisters;
  400. oldaktoutputformat:=aktoutputformat;
  401. oldaktoptprocessor:=aktoptprocessor;
  402. oldaktspecificoptprocessor:=aktspecificoptprocessor;
  403. oldaktasmmode:=aktasmmode;
  404. oldaktinterfacetype:=aktinterfacetype;
  405. oldaktfilepos:=aktfilepos;
  406. oldaktmodeswitches:=aktmodeswitches;
  407. {$ifdef GDB}
  408. store_dbx:=dbx_counter;
  409. dbx_counter:=nil;
  410. {$endif GDB}
  411. end;
  412. { show info }
  413. Message1(parser_i_compiling,filename);
  414. { reset symtable }
  415. symtablestack:=nil;
  416. defaultsymtablestack:=nil;
  417. systemunit:=nil;
  418. refsymtable:=nil;
  419. aktdefproccall:=initdefproccall;
  420. registerdef:=true;
  421. aktexceptblock:=0;
  422. exceptblockcounter:=0;
  423. aktmaxfpuregisters:=-1;
  424. { reset the unit or create a new program }
  425. if not assigned(current_module) then
  426. begin
  427. current_module:=tppumodule.create(nil,filename,'',false);
  428. main_module:=current_module;
  429. current_module.state:=ms_compile;
  430. end;
  431. if not(current_module.state in [ms_compile,ms_second_compile]) then
  432. internalerror(200212281);
  433. { a unit compiled at command line must be inside the loaded_unit list }
  434. if (compile_level=1) then
  435. loaded_units.insert(current_module);
  436. { Set the module to use for verbose }
  437. compiled_module:=current_module;
  438. SetCompileModule(current_module);
  439. Fillchar(aktfilepos,0,sizeof(aktfilepos));
  440. { Load current state from the init values }
  441. aktlocalswitches:=initlocalswitches;
  442. aktmoduleswitches:=initmoduleswitches;
  443. aktmodeswitches:=initmodeswitches;
  444. {$IFDEF Testvarsets}
  445. aktsetalloc:=initsetalloc;
  446. {$ENDIF}
  447. aktalignment:=initalignment;
  448. aktfputype:=initfputype;
  449. aktpackenum:=initpackenum;
  450. aktpackrecords:=0;
  451. aktoutputformat:=initoutputformat;
  452. set_target_asm(aktoutputformat);
  453. aktoptprocessor:=initoptprocessor;
  454. aktspecificoptprocessor:=initspecificoptprocessor;
  455. aktasmmode:=initasmmode;
  456. aktinterfacetype:=initinterfacetype;
  457. { startup scanner and load the first file }
  458. current_scanner:=tscannerfile.Create(filename);
  459. current_scanner.firstfile;
  460. current_module.scanner:=current_scanner;
  461. { macros }
  462. default_macros;
  463. { read the first token }
  464. current_scanner.readtoken;
  465. { init code generator for a new module }
  466. init_module;
  467. { If the compile level > 1 we get a nice "unit expected" error
  468. message if we are trying to use a program as unit.}
  469. {$ifdef USEEXCEPT}
  470. if setjmp(recoverpos)=0 then
  471. begin
  472. oldrecoverpos:=recoverpospointer;
  473. recoverpospointer:=@recoverpos;
  474. {$endif USEEXCEPT}
  475. if (token=_UNIT) or (compile_level>1) then
  476. begin
  477. current_module.is_unit:=true;
  478. proc_unit;
  479. end
  480. else
  481. proc_program(token=_LIBRARY);
  482. {$ifdef USEEXCEPT}
  483. recoverpospointer:=oldrecoverpos;
  484. end
  485. else
  486. begin
  487. recoverpospointer:=oldrecoverpos;
  488. longjump_used:=true;
  489. end;
  490. {$endif USEEXCEPT}
  491. { clear memory }
  492. {$ifdef Splitheap}
  493. if testsplit then
  494. begin
  495. { temp heap should be empty after that !!!}
  496. codegen_donemodule;
  497. Releasetempheap;
  498. end;
  499. {$endif Splitheap}
  500. { restore old state, close trees, > 0.99.5 has heapblocks, so
  501. it's the default to release the trees }
  502. done_module;
  503. if assigned(current_module) then
  504. begin
  505. { module is now compiled }
  506. tppumodule(current_module).state:=ms_compiled;
  507. { free ppu }
  508. if assigned(tppumodule(current_module).ppufile) then
  509. begin
  510. tppumodule(current_module).ppufile.free;
  511. tppumodule(current_module).ppufile:=nil;
  512. end;
  513. { free scanner }
  514. if assigned(current_module.scanner) then
  515. begin
  516. if current_scanner=tscannerfile(current_module.scanner) then
  517. current_scanner:=nil;
  518. tscannerfile(current_module.scanner).free;
  519. current_module.scanner:=nil;
  520. end;
  521. end;
  522. if (compile_level>1) then
  523. begin
  524. with olddata^ do
  525. begin
  526. { restore scanner }
  527. c:=oldc;
  528. pattern:=oldpattern;
  529. orgpattern:=oldorgpattern;
  530. token:=oldtoken;
  531. idtoken:=oldidtoken;
  532. akttokenpos:=oldtokenpos;
  533. block_type:=old_block_type;
  534. { restore cg }
  535. parse_only:=oldparse_only;
  536. { restore asmlists }
  537. exprasmlist:=oldexprasmlist;
  538. datasegment:=olddatasegment;
  539. bsssegment:=oldbsssegment;
  540. codesegment:=oldcodesegment;
  541. consts:=oldconsts;
  542. debuglist:=olddebuglist;
  543. withdebuglist:=oldwithdebuglist;
  544. importssection:=oldimports;
  545. exportssection:=oldexports;
  546. resourcesection:=oldresource;
  547. rttilist:=oldrttilist;
  548. picdata:=oldpicdata;
  549. resourcestringlist:=oldresourcestringlist;
  550. { object data }
  551. ResourceStrings:=OldResourceStrings;
  552. objectlibrary:=oldobjectlibrary;
  553. { restore previous scanner }
  554. if assigned(old_compiled_module) then
  555. current_scanner:=tscannerfile(old_compiled_module.scanner)
  556. else
  557. current_scanner:=nil;
  558. if assigned(current_scanner) then
  559. parser_current_file:=current_scanner.inputfile.name^;
  560. { restore symtable state }
  561. refsymtable:=oldrefsymtable;
  562. symtablestack:=oldsymtablestack;
  563. defaultsymtablestack:=olddefaultsymtablestack;
  564. aktdefproccall:=oldaktdefproccall;
  565. current_procinfo:=oldcurrent_procinfo;
  566. aktsourcecodepage:=oldsourcecodepage;
  567. aktlocalswitches:=oldaktlocalswitches;
  568. aktmoduleswitches:=oldaktmoduleswitches;
  569. aktalignment:=oldaktalignment;
  570. aktpackenum:=oldaktpackenum;
  571. aktpackrecords:=oldaktpackrecords;
  572. aktmaxfpuregisters:=oldaktmaxfpuregisters;
  573. aktoutputformat:=oldaktoutputformat;
  574. set_target_asm(aktoutputformat);
  575. aktoptprocessor:=oldaktoptprocessor;
  576. aktspecificoptprocessor:=oldaktspecificoptprocessor;
  577. aktfputype:=oldaktfputype;
  578. aktasmmode:=oldaktasmmode;
  579. aktinterfacetype:=oldaktinterfacetype;
  580. aktfilepos:=oldaktfilepos;
  581. aktmodeswitches:=oldaktmodeswitches;
  582. aktexceptblock:=0;
  583. exceptblockcounter:=0;
  584. {$ifdef GDB}
  585. dbx_counter:=store_dbx;
  586. {$endif GDB}
  587. end;
  588. end
  589. else
  590. begin
  591. parser_current_file:='';
  592. { Shut down things when the last file is compiled }
  593. if (compile_level=1) then
  594. begin
  595. { Close script }
  596. if (not AsmRes.Empty) then
  597. begin
  598. Message1(exec_i_closing_script,AsmRes.Fn);
  599. AsmRes.WriteToDisk;
  600. end;
  601. {$ifdef USEEXCEPT}
  602. if not longjump_used then
  603. {$endif USEEXCEPT}
  604. begin
  605. { do not create browsers on errors !! }
  606. if status.errorcount=0 then
  607. begin
  608. {$ifdef BrowserLog}
  609. { Write Browser Log }
  610. if (cs_browser_log in aktglobalswitches) and
  611. (cs_browser in aktmoduleswitches) then
  612. begin
  613. if browserlog.elements_to_list.empty then
  614. begin
  615. Message1(parser_i_writing_browser_log,browserlog.Fname);
  616. WriteBrowserLog;
  617. end
  618. else
  619. browserlog.list_elements;
  620. end;
  621. {$endif BrowserLog}
  622. { Write Browser Collections }
  623. do_extractsymbolinfo{$ifdef FPC}(){$endif};
  624. end;
  625. end;
  626. {$ifdef dummy}
  627. if current_module.in_second_compile then
  628. begin
  629. current_module.in_second_compile:=false;
  630. current_module.in_compile:=true;
  631. end
  632. else
  633. current_module.in_compile:=false;
  634. {$endif dummy}
  635. end;
  636. end;
  637. dec(compile_level);
  638. compiled_module:=olddata^.old_compiled_module;
  639. dispose(olddata);
  640. {$ifdef USEEXCEPT}
  641. if longjump_used then
  642. longjmp(recoverpospointer^,1);
  643. {$endif USEEXCEPT}
  644. end;
  645. end.
  646. {
  647. $Log$
  648. Revision 1.65 2004-05-12 13:21:09 karoly
  649. * few small changes to add syscall support to M68k/Amiga target
  650. Revision 1.64 2004/04/28 15:19:03 florian
  651. + syscall directive support for MorphOS added
  652. Revision 1.63 2004/03/16 16:20:49 peter
  653. * reset current_module,current_procinfo so the destroy routines
  654. can't access their info anymore, because that can be already
  655. destroyed
  656. Revision 1.62 2004/03/14 20:08:37 peter
  657. * packrecords fixed for settings from $PACKRECORDS
  658. * default packrecords now uses value 0 and uses info from aligment
  659. structure only, initpackrecords removed
  660. Revision 1.61 2004/03/02 17:32:12 florian
  661. * make cycle fixed
  662. + pic support for darwin
  663. + support of importing vars from shared libs on darwin implemented
  664. Revision 1.60 2004/02/04 22:15:15 daniel
  665. * Rtti generation moved to ncgutil
  666. * Assmtai usage of symsym removed
  667. * operator overloading cleanup up
  668. Revision 1.59 2004/01/28 22:16:31 peter
  669. * more record alignment fixes
  670. Revision 1.58 2003/10/29 21:02:51 peter
  671. * set ms_compiled after the program/unit is parsed
  672. * check for ms_compiled before checking preproc matches
  673. Revision 1.57 2003/10/01 20:34:49 peter
  674. * procinfo unit contains tprocinfo
  675. * cginfo renamed to cgbase
  676. * moved cgmessage to verbose
  677. * fixed ppc and sparc compiles
  678. Revision 1.56 2003/09/03 11:18:37 florian
  679. * fixed arm concatcopy
  680. + arm support in the common compiler sources added
  681. * moved some generic cg code around
  682. + tfputype added
  683. * ...
  684. Revision 1.55 2003/06/13 21:19:30 peter
  685. * current_procdef removed, use current_procinfo.procdef instead
  686. Revision 1.54 2003/06/12 16:41:51 peter
  687. * add inputfile prefix to ppas/link.res
  688. Revision 1.53 2003/05/15 18:58:53 peter
  689. * removed selfpointer_offset, vmtpointer_offset
  690. * tvarsym.adjusted_address
  691. * address in localsymtable is now in the real direction
  692. * removed some obsolete globals
  693. Revision 1.52 2003/04/27 11:21:33 peter
  694. * aktprocdef renamed to current_procinfo.procdef
  695. * procinfo renamed to current_procinfo
  696. * procinfo will now be stored in current_module so it can be
  697. cleaned up properly
  698. * gen_main_procsym changed to create_main_proc and release_main_proc
  699. to also generate a tprocinfo structure
  700. * fixed unit implicit initfinal
  701. Revision 1.51 2003/04/27 07:29:50 peter
  702. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  703. a new procdef declaration
  704. * aktprocsym removed
  705. * lexlevel removed, use symtable.symtablelevel instead
  706. * implicit init/final code uses the normal genentry/genexit
  707. * funcret state checking updated for new funcret handling
  708. Revision 1.50 2003/04/26 00:30:52 peter
  709. * reset aktfilepos when setting new module for compile
  710. Revision 1.49 2003/04/25 20:59:33 peter
  711. * removed funcretn,funcretsym, function result is now in varsym
  712. and aliases for result and function name are added using absolutesym
  713. * vs_hidden parameter for funcret passed in parameter
  714. * vs_hidden fixes
  715. * writenode changed to printnode and released from extdebug
  716. * -vp option added to generate a tree.log with the nodetree
  717. * nicer printnode for statements, callnode
  718. Revision 1.48 2002/12/29 14:57:50 peter
  719. * unit loading changed to first register units and load them
  720. afterwards. This is needed to support uses xxx in yyy correctly
  721. * unit dependency check fixed
  722. Revision 1.47 2002/12/24 23:32:19 peter
  723. * fixed crash when old_compiled_module was nil
  724. Revision 1.46 2002/11/20 12:36:24 mazen
  725. * $UNITPATH directive is now working
  726. Revision 1.45 2002/10/07 19:29:52 peter
  727. * Place old data in compile() in the heap to save stack
  728. Revision 1.44 2002/09/05 19:27:06 peter
  729. * fixed crash when current_module becomes nil
  730. Revision 1.43 2002/08/18 19:58:28 peter
  731. * more current_scanner fixes
  732. Revision 1.42 2002/08/16 15:31:08 peter
  733. * fixed possible crashes with current_scanner
  734. Revision 1.41 2002/08/15 19:10:35 peter
  735. * first things tai,tnode storing in ppu
  736. Revision 1.40 2002/08/12 16:46:04 peter
  737. * tscannerfile is now destroyed in tmodule.reset and current_scanner
  738. is updated accordingly. This removes all the loading and saving of
  739. the old scanner and the invalid flag marking
  740. Revision 1.39 2002/08/12 15:08:40 carl
  741. + stab register indexes for powerpc (moved from gdb to cpubase)
  742. + tprocessor enumeration moved to cpuinfo
  743. + linker in target_info is now a class
  744. * many many updates for m68k (will soon start to compile)
  745. - removed some ifdef or correct them for correct cpu
  746. Revision 1.38 2002/08/11 14:28:19 peter
  747. * TScannerFile.SetInvalid added that will also reset inputfile
  748. Revision 1.37 2002/08/11 13:24:12 peter
  749. * saving of asmsymbols in ppu supported
  750. * asmsymbollist global is removed and moved into a new class
  751. tasmlibrarydata that will hold the info of a .a file which
  752. corresponds with a single module. Added librarydata to tmodule
  753. to keep the library info stored for the module. In the future the
  754. objectfiles will also be stored to the tasmlibrarydata class
  755. * all getlabel/newasmsymbol and friends are moved to the new class
  756. Revision 1.36 2002/08/09 19:15:41 carl
  757. - removed newcg define
  758. Revision 1.35 2002/07/20 17:16:03 florian
  759. + source code page support
  760. Revision 1.34 2002/07/01 18:46:24 peter
  761. * internal linker
  762. * reorganized aasm layer
  763. Revision 1.33 2002/05/18 13:34:11 peter
  764. * readded missing revisions
  765. Revision 1.32 2002/05/16 19:46:42 carl
  766. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  767. + try to fix temp allocation (still in ifdef)
  768. + generic constructor calls
  769. + start of tassembler / tmodulebase class cleanup
  770. Revision 1.30 2002/04/21 18:57:23 peter
  771. * fixed memleaks when file can't be opened
  772. Revision 1.29 2002/04/20 21:32:24 carl
  773. + generic FPC_CHECKPOINTER
  774. + first parameter offset in stack now portable
  775. * rename some constants
  776. + move some cpu stuff to other units
  777. - remove unused constents
  778. * fix stacksize for some targets
  779. * fix generic size problems which depend now on EXTEND_SIZE constant
  780. Revision 1.28 2002/04/19 15:46:02 peter
  781. * mangledname rewrite, tprocdef.mangledname is now created dynamicly
  782. in most cases and not written to the ppu
  783. * add mangeledname_prefix() routine to generate the prefix of
  784. manglednames depending on the current procedure, object and module
  785. * removed static procprefix since the mangledname is now build only
  786. on demand from tprocdef.mangledname
  787. Revision 1.27 2002/01/29 19:43:11 peter
  788. * update target_asm according to outputformat
  789. }