parser.pas 29 KB

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