parser.pas 29 KB

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