parser.pas 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 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. {$ifdef tp}
  19. {$E+,N+,D+,F+}
  20. {$endif}
  21. unit parser;
  22. interface
  23. procedure compile(const filename:string;compile_system:boolean);
  24. procedure initparser;
  25. implementation
  26. uses
  27. dos,cobjects,globals,scanner,systems,symtable,tree,aasm,
  28. types,strings,pass_1,hcodegen,files,verbose,script,import
  29. {$ifdef i386}
  30. ,i386
  31. ,cgi386
  32. ,cgai386
  33. ,tgeni386
  34. ,aopt386
  35. {$endif i386}
  36. {$ifdef m68k}
  37. ,m68k
  38. ,cg68k
  39. ,tgen68k
  40. ,cga68k
  41. {$endif m68k}
  42. { parser units }
  43. ,pbase,pmodules,pdecl,
  44. { assembling & linking }
  45. assemble,
  46. link;
  47. { dummy variable for search when calling exec }
  48. var
  49. file_found : boolean;
  50. procedure readconstdefs;
  51. begin
  52. s32bitdef:=porddef(globaldef('longint'));
  53. u32bitdef:=porddef(globaldef('ulong'));
  54. cstringdef:=pstringdef(globaldef('string'));
  55. {$ifdef UseLongString}
  56. clongstringdef:=pstringdef(globaldef('longstring'));
  57. {$endif UseLongString}
  58. {$ifdef UseAnsiString}
  59. cansistringdef:=pstringdef(globaldef('ansistring'));
  60. {$endif UseAnsiString}
  61. cchardef:=porddef(globaldef('char'));
  62. {$ifdef i386}
  63. c64floatdef:=pfloatdef(globaldef('s64real'));
  64. {$endif}
  65. {$ifdef m68k}
  66. c64floatdef:=pfloatdef(globaldef('s32real'));
  67. {$endif m68k}
  68. s80floatdef:=pfloatdef(globaldef('s80real'));
  69. s32fixeddef:=pfloatdef(globaldef('cs32fixed'));
  70. voiddef:=porddef(globaldef('void'));
  71. u8bitdef:=porddef(globaldef('byte'));
  72. u16bitdef:=porddef(globaldef('word'));
  73. booldef:=porddef(globaldef('boolean'));
  74. voidpointerdef:=ppointerdef(globaldef('void_pointer'));
  75. cfiledef:=pfiledef(globaldef('file'));
  76. end;
  77. procedure initparser;
  78. begin
  79. forwardsallowed:=false;
  80. { ^M means a string or a char, because we don't parse a }
  81. { type declaration }
  82. block_type:=bt_general;
  83. ignore_equal:=false;
  84. { we didn't parse a object or class declaration }
  85. { and no function header }
  86. testcurobject:=0;
  87. { create error defintion }
  88. generrordef:=new(perrordef,init);
  89. symtablestack:=nil;
  90. { a long time, this was forgotten }
  91. aktprocsym:=nil;
  92. current_module:=nil;
  93. loaded_units.init;
  94. usedunits.init;
  95. end;
  96. { moved out to save stack }
  97. var
  98. addparam : string;
  99. procedure compile(const filename:string;compile_system:boolean);
  100. var
  101. hp : pmodule;
  102. comp_unit : boolean;
  103. { some variables to save the compiler state }
  104. oldtoken : ttoken;
  105. {$ifdef UseTokenInfo}
  106. oldtokeninfo : ptokeninfo;
  107. {$endif UseTokenInfo}
  108. oldpattern : stringid;
  109. oldpreprocstack : ppreprocstack;
  110. oldorgpattern,oldprocprefix : string;
  111. old_block_type : tblock_type;
  112. oldinputbuffer,
  113. oldinputpointer : pchar;
  114. olds_point,oldparse_only : boolean;
  115. oldc : char;
  116. oldcomment_level : word;
  117. oldimports,oldexports,oldresource,
  118. oldbsssegment,olddatasegment,oldcodesegment,
  119. oldexprasmlist,olddebuglist,
  120. oldinternals,oldexternals,oldconsts : paasmoutput;
  121. oldnextlabelnr : longint;
  122. oldswitches : Tcswitches;
  123. oldmacros,oldrefsymtable,oldsymtablestack : psymtable;
  124. procedure def_macro(const s : string);
  125. var
  126. mac : pmacrosym;
  127. begin
  128. mac:=pmacrosym(macros^.search(s));
  129. if mac=nil then
  130. begin
  131. mac:=new(pmacrosym,init(s));
  132. Message1(parser_m_macro_defined,mac^.name);
  133. macros^.insert(mac);
  134. end;
  135. mac^.defined:=true;
  136. end;
  137. procedure set_macro(const s : string;value : string);
  138. var
  139. mac : pmacrosym;
  140. begin
  141. mac:=pmacrosym(macros^.search(s));
  142. if mac=nil then
  143. begin
  144. mac:=new(pmacrosym,init(s));
  145. macros^.insert(mac);
  146. end
  147. else
  148. begin
  149. if assigned(mac^.buftext) then
  150. freemem(mac^.buftext,mac^.buflen);
  151. end;
  152. Message2(parser_m_macro_set_to,mac^.name,value);
  153. mac^.buflen:=length(value);
  154. getmem(mac^.buftext,mac^.buflen);
  155. move(value[1],mac^.buftext^,mac^.buflen);
  156. mac^.defined:=true;
  157. end;
  158. procedure define_macros;
  159. var
  160. hp : pstring_item;
  161. begin
  162. hp:=pstring_item(commandlinedefines.first);
  163. while assigned(hp) do
  164. begin
  165. def_macro(hp^.str^);
  166. hp:=pstring_item(hp^.next);
  167. end;
  168. { set macros for version checking }
  169. set_macro('FPC_VERSION',version_nr);
  170. set_macro('FPC_RELEASE',release_nr);
  171. set_macro('FPC_PATCH',patch_nr);
  172. end;
  173. label
  174. done;
  175. begin {compile}
  176. inc(compile_level);
  177. { save old state }
  178. { save symtable state }
  179. oldsymtablestack:=symtablestack;
  180. symtablestack:=nil;
  181. oldrefsymtable:=refsymtable;
  182. refsymtable:=nil;
  183. oldprocprefix:=procprefix;
  184. { a long time, this was only in init_parser
  185. but it should be reset to zero for each module }
  186. aktprocsym:=nil;
  187. { first, we assume a program }
  188. if not(assigned(current_module)) then
  189. begin
  190. {!!!}
  191. current_module:=new(pmodule,init(filename,false));
  192. main_module:=current_module;
  193. end;
  194. { reset flags }
  195. current_module^.flags:=0;
  196. { ... and crc }
  197. current_module^.crc:=0;
  198. { save scanner state }
  199. oldmacros:=macros;
  200. oldpattern:=pattern;
  201. oldtoken:=token;
  202. {$ifdef UseTokenInfo}
  203. oldtokeninfo:=tokeninfo;
  204. {$endif UseTokenInfo}
  205. oldorgpattern:=orgpattern;
  206. old_block_type:=block_type;
  207. oldpreprocstack:=preprocstack;
  208. oldinputbuffer:=inputbuffer;
  209. oldinputpointer:=inputpointer;
  210. olds_point:=s_point;
  211. oldc:=c;
  212. oldcomment_level:=comment_level;
  213. oldparse_only:=parse_only;
  214. { save assembler lists }
  215. olddatasegment:=datasegment;
  216. oldbsssegment:=bsssegment;
  217. oldcodesegment:=codesegment;
  218. olddebuglist:=debuglist;
  219. oldexternals:=externals;
  220. oldinternals:=internals;
  221. oldconsts:=consts;
  222. oldexprasmlist:=exprasmlist;
  223. oldimports:=importssection;
  224. oldexports:=exportssection;
  225. oldresource:=resourcesection;
  226. oldswitches:=aktswitches;
  227. oldnextlabelnr:=nextlabelnr;
  228. Message1(parser_i_compiling,filename);
  229. InitScanner(filename);
  230. aktswitches:=initswitches;
  231. { we need this to make the system unit }
  232. if compile_system then
  233. aktswitches:=aktswitches+[cs_compilesystem];
  234. aktpackrecords:=initpackrecords;
  235. { init code generator for a new module }
  236. codegen_newmodule;
  237. macros:=new(psymtable,init(macrosymtable));
  238. define_macros;
  239. { startup scanner }
  240. {$ifndef UseTokenInfo}
  241. token:=yylex;
  242. {$else UseTokenInfo}
  243. tokeninfo:=yylex;
  244. token:=tokeninfo^.token;
  245. {$endif UseTokenInfo}
  246. reset_gdb_info;
  247. { init asm writing }
  248. datasegment:=new(paasmoutput,init);
  249. codesegment:=new(paasmoutput,init);
  250. bsssegment:=new(paasmoutput,init);
  251. debuglist:=new(paasmoutput,init);
  252. externals:=new(paasmoutput,init);
  253. internals:=new(paasmoutput,init);
  254. consts:=new(paasmoutput,init);
  255. importssection:=nil;
  256. exportssection:=nil;
  257. resourcesection:=nil;
  258. { global switches are read, so further changes aren't allowed }
  259. current_module^.in_main:=true;
  260. { open assembler response }
  261. if (compile_level=1) then
  262. AsmRes.Init('ppas');
  263. { if the current file isn't a system unit }
  264. { the the system unit will be loaded }
  265. if not(cs_compilesystem in aktswitches) then
  266. begin
  267. { should be done in unit system (changing the field system_unit)
  268. FK
  269. }
  270. hp:=loadunit(upper(target_info.system_unit),true,true);
  271. systemunit:=hp^.symtable;
  272. readconstdefs;
  273. { we could try to overload caret by default }
  274. symtablestack:=systemunit;
  275. { if POWER is defined in the RTL then use it for starstar overloading }
  276. getsym('POWER',false);
  277. if assigned(srsym) and (srsym^.typ=procsym) and
  278. (overloaded_operators[STARSTAR]=nil) then
  279. overloaded_operators[STARSTAR]:=pprocsym(srsym);
  280. end
  281. else
  282. begin
  283. { create definitions for constants }
  284. registerdef:=false;
  285. s32bitdef:=new(porddef,init(s32bit,$80000000,$7fffffff));
  286. u32bitdef:=new(porddef,init(u32bit,0,$ffffffff));
  287. cstringdef:=new(pstringdef,init(255));
  288. { should we give a length to the default long and ansi string definition ?? }
  289. {$ifdef UseLongString}
  290. clongstringdef:=new(pstringdef,longinit(-1));
  291. {$endif UseLongString}
  292. {$ifdef UseAnsiString}
  293. cansistringdef:=new(pstringdef,ansiinit(-1));
  294. {$endif UseAnsiString}
  295. cchardef:=new(porddef,init(uchar,0,255));
  296. {$ifdef i386}
  297. c64floatdef:=new(pfloatdef,init(s64real));
  298. s80floatdef:=new(pfloatdef,init(s80real));
  299. {$endif}
  300. {$ifdef m68k}
  301. c64floatdef:=new(pfloatdef,init(s32real));
  302. if (cs_fp_emulation in aktswitches) then
  303. s80floatdef:=new(pfloatdef,init(s32real))
  304. else
  305. s80floatdef:=new(pfloatdef,init(s80real));
  306. {$endif}
  307. s32fixeddef:=new(pfloatdef,init(f32bit));
  308. { some other definitions }
  309. voiddef:=new(porddef,init(uvoid,0,0));
  310. u8bitdef:=new(porddef,init(u8bit,0,255));
  311. u16bitdef:=new(porddef,init(u16bit,0,65535));
  312. booldef:=new(porddef,init(bool8bit,0,1));
  313. voidpointerdef:=new(ppointerdef,init(voiddef));
  314. cfiledef:=new(pfiledef,init(ft_untyped,nil));
  315. systemunit:=nil;
  316. end;
  317. registerdef:=true;
  318. { current return type is void }
  319. procinfo.retdef:=voiddef;
  320. { reset lexical level }
  321. lexlevel:=0;
  322. { parse source }
  323. {***BUGFIX}
  324. if (token=_UNIT) or (compile_level>1) then
  325. begin
  326. {If the compile level > 1 we get a nice "unit expected" error
  327. message if we are trying to use a program as unit.}
  328. proc_unit;
  329. if current_module^.compiled then
  330. goto done;
  331. comp_unit:=true;
  332. end
  333. else
  334. begin
  335. proc_program(token=_LIBRARY);
  336. comp_unit:=false;
  337. end;
  338. { Why? The definition of Pascal requires that everything
  339. after 'end.' is ignored!
  340. if not(cs_tp_compatible in aktswitches) then
  341. consume(_EOF); }
  342. if errorcount=0 then
  343. begin
  344. if current_module^.uses_imports then
  345. importlib^.generatelib;
  346. GenerateAsm(filename);
  347. { Check linking => we are at first level in compile }
  348. if (compile_level=1) then
  349. begin
  350. if Linker.ExeName='' then
  351. Linker.SetFileName(FileName);
  352. if (comp_unit) then
  353. begin
  354. Linker.Make_Library;
  355. end
  356. else
  357. begin
  358. if (cs_no_linking in initswitches) then
  359. externlink:=true;
  360. Linker.Link;
  361. end;
  362. end;
  363. end
  364. else
  365. begin
  366. Message1(unit_e_total_errors,tostr(errorcount));
  367. Message(unit_f_errors_in_unit);
  368. end;
  369. { clear memory }
  370. {$ifdef Splitheap}
  371. if testsplit then
  372. begin
  373. { temp heap should be empty after that !!!}
  374. codegen_donemodule;
  375. Releasetempheap;
  376. end;
  377. {else
  378. codegen_donemodule;}
  379. {$endif Splitheap}
  380. { restore old state }
  381. { if already compiled jumps directly here }
  382. done:
  383. { close trees }
  384. if dispose_asm_lists then
  385. begin
  386. dispose(datasegment,Done);
  387. dispose(codesegment,Done);
  388. dispose(bsssegment,Done);
  389. dispose(debuglist,Done);
  390. dispose(externals,Done);
  391. dispose(internals,Done);
  392. dispose(consts,Done);
  393. end;
  394. reset_gdb_info;
  395. { restore symtable state }
  396. {$ifdef UseBrowser}
  397. if (compile_level>1) then
  398. { we want to keep the current symtablestack }
  399. {$endif UseBrowser}
  400. begin
  401. refsymtable:=oldrefsymtable;
  402. symtablestack:=oldsymtablestack;
  403. end;
  404. procprefix:=oldprocprefix;
  405. { close the inputfiles }
  406. {$ifndef UseBrowser}
  407. { but not if we want the names for the browser ! }
  408. current_module^.sourcefiles.done;
  409. {$endif not UseBrowser}
  410. { restore scanner state }
  411. pattern:=oldpattern;
  412. token:=oldtoken;
  413. {$ifdef UseTokenInfo}
  414. tokeninfo:=oldtokeninfo;
  415. {$endif UseTokenInfo}
  416. orgpattern:=oldorgpattern;
  417. block_type:=old_block_type;
  418. { call donescanner before restoring preprocstack, because }
  419. { donescanner tests for a empty preprocstack }
  420. { and can also check for unused macros }
  421. donescanner(current_module^.compiled);
  422. dispose(macros,done);
  423. macros:=oldmacros;
  424. preprocstack:=oldpreprocstack;
  425. aktswitches:=oldswitches;
  426. inputbuffer:=oldinputbuffer;
  427. inputpointer:=oldinputpointer;
  428. s_point:=olds_point;
  429. c:=oldc;
  430. comment_level:=oldcomment_level;
  431. parse_only:=oldparse_only;
  432. { restore asmlists }
  433. datasegment:=olddatasegment;
  434. bsssegment:=oldbsssegment;
  435. codesegment:=oldcodesegment;
  436. debuglist:=olddebuglist;
  437. externals:=oldexternals;
  438. internals:=oldinternals;
  439. importssection:=oldimports;
  440. exportssection:=oldexports;
  441. resourcesection:=oldresource;
  442. nextlabelnr:=oldnextlabelnr;
  443. exprasmlist:=oldexprasmlist;
  444. consts:=oldconsts;
  445. nextlabelnr:=oldnextlabelnr;
  446. if (compile_level=1) then
  447. begin
  448. if (not AsmRes.Empty) then
  449. begin
  450. Message1(exec_i_closing_script,AsmRes.Fn);
  451. AsmRes.WriteToDisk;
  452. end;
  453. end;
  454. dec(compile_level);
  455. end;
  456. end.
  457. {
  458. $Log$
  459. Revision 1.9 1998-04-30 15:59:40 pierre
  460. * GDB works again better :
  461. correct type info in one pass
  462. + UseTokenInfo for better source position
  463. * fixed one remaining bug in scanner for line counts
  464. * several little fixes
  465. Revision 1.8 1998/04/29 10:33:55 pierre
  466. + added some code for ansistring (not complete nor working yet)
  467. * corrected operator overloading
  468. * corrected nasm output
  469. + started inline procedures
  470. + added starstarn : use ** for exponentiation (^ gave problems)
  471. + started UseTokenInfo cond to get accurate positions
  472. Revision 1.7 1998/04/27 23:10:28 peter
  473. + new scanner
  474. * $makelib -> if smartlink
  475. * small filename fixes pmodule.setfilename
  476. * moved import from files.pas -> import.pas
  477. Revision 1.6 1998/04/21 10:16:48 peter
  478. * patches from strasbourg
  479. * objects is not used anymore in the fpc compiled version
  480. Revision 1.5 1998/04/10 14:41:43 peter
  481. * removed some Hints
  482. * small speed optimization for AsmLn
  483. Revision 1.4 1998/04/08 16:58:03 pierre
  484. * several bugfixes
  485. ADD ADC and AND are also sign extended
  486. nasm output OK (program still crashes at end
  487. and creates wrong assembler files !!)
  488. procsym types sym in tdef removed !!
  489. Revision 1.3 1998/04/07 22:45:04 florian
  490. * bug0092, bug0115 and bug0121 fixed
  491. + packed object/class/array
  492. Revision 1.2 1998/03/26 11:18:30 florian
  493. - switch -Sa removed
  494. - support of a:=b:=0 removed
  495. Revision 1.1.1.1 1998/03/25 11:18:12 root
  496. * Restored version
  497. Revision 1.60 1998/03/24 21:48:32 florian
  498. * just a couple of fixes applied:
  499. - problem with fixed16 solved
  500. - internalerror 10005 problem fixed
  501. - patch for assembler reading
  502. - small optimizer fix
  503. - mem is now supported
  504. Revision 1.59 1998/03/20 23:31:33 florian
  505. * bug0113 fixed
  506. * problem with interdepened units fixed ("options.pas problem")
  507. * two small extensions for future AMD 3D support
  508. Revision 1.58 1998/03/13 22:45:58 florian
  509. * small bug fixes applied
  510. Revision 1.57 1998/03/10 17:19:29 peter
  511. * fixed bug0108
  512. * better linebreak scanning (concentrated in nextchar(), it supports
  513. #10, #13, #10#13, #13#10
  514. Revision 1.56 1998/03/10 16:27:40 pierre
  515. * better line info in stabs debug
  516. * symtabletype and lexlevel separated into two fields of tsymtable
  517. + ifdef MAKELIB for direct library output, not complete
  518. + ifdef CHAINPROCSYMS for overloaded seach across units, not fully
  519. working
  520. + ifdef TESTFUNCRET for setting func result in underfunction, not
  521. working
  522. Revision 1.55 1998/03/10 12:54:06 peter
  523. * def_symbol renamed to def_macro and use it in defines_macros
  524. Revision 1.54 1998/03/10 01:17:22 peter
  525. * all files have the same header
  526. * messages are fully implemented, EXTDEBUG uses Comment()
  527. + AG... files for the Assembler generation
  528. Revision 1.53 1998/03/06 00:52:34 peter
  529. * replaced all old messages from errore.msg, only ExtDebug and some
  530. Comment() calls are left
  531. * fixed options.pas
  532. Revision 1.52 1998/03/02 16:00:37 peter
  533. * -Ch works again
  534. Revision 1.51 1998/03/02 13:38:44 peter
  535. + importlib object
  536. * doesn't crash on a systemunit anymore
  537. * updated makefile and depend
  538. Revision 1.49 1998/02/28 00:20:31 florian
  539. * more changes to get import libs for Win32 working
  540. Revision 1.48 1998/02/27 22:27:56 florian
  541. + win_targ unit
  542. + support of sections
  543. + new asmlists: sections, exports and resource
  544. Revision 1.47 1998/02/24 10:29:17 peter
  545. * -a works again
  546. Revision 1.46 1998/02/24 00:19:14 peter
  547. * makefile works again (btw. linux does like any char after a \ )
  548. * removed circular unit with assemble and files
  549. * fixed a sigsegv in pexpr
  550. * pmodule init unit/program is the almost the same, merged them
  551. Revision 1.45 1998/02/22 23:03:25 peter
  552. * renamed msource->mainsource and name->unitname
  553. * optimized filename handling, filename is not seperate anymore with
  554. path+name+ext, this saves stackspace and a lot of fsplit()'s
  555. * recompiling of some units in libraries fixed
  556. * shared libraries are working again
  557. + $LINKLIB <lib> to support automatic linking to libraries
  558. + libraries are saved/read from the ppufile, also allows more libraries
  559. per ppufile
  560. Revision 1.44 1998/02/19 00:11:04 peter
  561. * fixed -g to work again
  562. * fixed some typos with the scriptobject
  563. Revision 1.43 1998/02/18 13:48:12 michael
  564. + Implemented an OS independent AsmRes object.
  565. Revision 1.42 1998/02/17 21:20:54 peter
  566. + Script unit
  567. + __EXIT is called again to exit a program
  568. - target_info.link/assembler calls
  569. * linking works again for dos
  570. * optimized a few filehandling functions
  571. * fixed stabs generation for procedures
  572. Revision 1.41 1998/02/16 12:51:35 michael
  573. + Implemented linker object
  574. Revision 1.40 1998/02/15 21:16:25 peter
  575. * all assembler outputs supported by assemblerobject
  576. * cleanup with assembleroutputs, better .ascii generation
  577. * help_constructor/destructor are now added to the externals
  578. - generation of asmresponse is not outputformat depended
  579. Revision 1.39 1998/02/14 01:45:26 peter
  580. * more fixes
  581. - pmode target is removed
  582. - search_as_ld is removed, this is done in the link.pas/assemble.pas
  583. + findexe() to search for an executable (linker,assembler,binder)
  584. Revision 1.38 1998/02/13 22:26:33 peter
  585. * fixed a few SigSegv's
  586. * INIT$$ was not written for linux!
  587. * assembling and linking works again for linux and dos
  588. + assembler object, only attasmi3 supported yet
  589. * restore pp.pas with AddPath etc.
  590. Revision 1.37 1998/02/13 10:35:17 daniel
  591. * Made Motorola version compilable.
  592. * Fixed optimizer
  593. Revision 1.36 1998/02/12 17:19:12 florian
  594. * fixed to get remake3 work, but needs additional fixes (output, I don't like
  595. also that aktswitches isn't a pointer)
  596. Revision 1.35 1998/02/12 11:50:16 daniel
  597. Yes! Finally! After three retries, my patch!
  598. Changes:
  599. Complete rewrite of psub.pas.
  600. Added support for DLL's.
  601. Compiler requires less memory.
  602. Platform units for each platform.
  603. Revision 1.34 1998/02/02 11:47:36 pierre
  604. + compilation stops at unit with error
  605. Revision 1.33 1998/02/01 22:41:08 florian
  606. * clean up
  607. + system.assigned([class])
  608. + system.assigned([class of xxxx])
  609. * first fixes of as and is-operator
  610. Revision 1.32 1998/01/30 17:31:23 pierre
  611. * bug of cyclic symtablestack fixed
  612. Revision 1.31 1998/01/29 12:13:21 michael
  613. * fixed Typos for library making
  614. Revision 1.30 1998/01/28 13:48:45 michael
  615. + Initial implementation for making libs from within FPC. Not tested, as compiler does not run
  616. Revision 1.29 1998/01/25 18:45:47 peter
  617. + Search for as and ld at startup
  618. + source_info works the same as target_info
  619. + externlink allows only external linking
  620. Revision 1.28 1998/01/23 21:14:59 carl
  621. * RunError 105 (file not open) with -Agas switch fix
  622. Revision 1.27 1998/01/23 17:55:11 michael
  623. + Moved linking stage to it's own unit (link.pas)
  624. Incorporated Pierres changes, but removed -E switch
  625. switch for not linking is now -Cn instead of -E
  626. Revision 1.26 1998/01/23 17:12:15 pierre
  627. * added some improvements for as and ld :
  628. - doserror and dosexitcode treated separately
  629. - PATH searched if doserror=2
  630. + start of long and ansi string (far from complete)
  631. in conditionnal UseLongString and UseAnsiString
  632. * options.pas cleaned (some variables shifted to globals)gl
  633. Revision 1.25 1998/01/22 14:47:16 michael
  634. + Reinstated linker options as -k option. How did they dissapear ?
  635. Revision 1.24 1998/01/17 01:57:36 michael
  636. + Start of shared library support. First working version.
  637. Revision 1.23 1998/01/16 22:34:37 michael
  638. * Changed 'conversation' to 'conversion'. Waayyy too much chatting going on
  639. in this compiler :)
  640. Revision 1.22 1998/01/14 12:52:04 michael
  641. - Removed the 'Assembled' line and replaced 'Calling Linker/assembler...'
  642. with 'Assembling/linking...'. Too much verbosity when V_info is on.
  643. Revision 1.21 1998/01/13 16:15:56 pierre
  644. * bug in interdependent units handling
  645. - primary unit was not in loaded_units list
  646. - current_module^.symtable was assigned too early
  647. - donescanner must not call error if the compilation
  648. of the unit was done at a higher level.
  649. Revision 1.20 1998/01/11 10:54:22 florian
  650. + generic library support
  651. Revision 1.19 1998/01/11 04:17:11 carl
  652. + correct heap and memory variables for m68k targets
  653. Revision 1.18 1998/01/08 23:56:39 florian
  654. * parser unit divided into several smaller units
  655. Revision 1.17 1998/01/08 17:10:12 florian
  656. * the name of the initialization part of a unit was sometimes written
  657. in lower case
  658. Revision 1.16 1998/01/07 00:16:56 michael
  659. Restored released version (plus fixes) as current
  660. Revision 1.13 1997/12/14 22:43:21 florian
  661. + command line switch -Xs for DOS (passes -s to the linker to strip symbols from
  662. executable)
  663. * some changes of Carl-Eric implemented
  664. Revision 1.12 1997/12/12 13:28:31 florian
  665. + version 0.99.0
  666. * all WASM options changed into MASM
  667. + -O2 for Pentium II optimizations
  668. Revision 1.11 1997/12/10 23:07:21 florian
  669. * bugs fixed: 12,38 (also m68k),39,40,41
  670. + warning if a system unit is without -Us compiled
  671. + warning if a method is virtual and private (was an error)
  672. * some indentions changed
  673. + factor does a better error recovering (omit some crashes)
  674. + problem with @type(x) removed (crashed the compiler)
  675. Revision 1.10 1997/12/09 13:50:36 carl
  676. * bugfix of possible alignment problems with m68k
  677. * bugfix of circular unit use -- could still give a stack overflow,
  678. so changed to fatalerror instead.
  679. * bugfix of nil procedural variables, fpc = @nil is illogical!
  680. (if was reversed!)
  681. Revision 1.9 1997/12/08 13:31:31 daniel
  682. * File was in DOS format. Translated to Unix.
  683. Revision 1.8 1997/12/08 10:01:08 pierre
  684. * nil for a procvar const was not allowed (os2_targ.pas not compilable)
  685. * bug in loadunit for units in implementation part already loaded
  686. (crashed on dos_targ.pas, thanks to Daniel who permitted me
  687. to find this bug out)
  688. Revision 1.7 1997/12/04 17:47:50 carl
  689. + renamed m68k units and refs to these units according to cpu rules.
  690. Revision 1.6 1997/12/02 15:56:13 carl
  691. * bugfix of postfixoperator with pd =nil
  692. * bugfix of motorola instructions types for exit code.
  693. Revision 1.5 1997/12/01 18:14:33 pierre
  694. * fixes a bug in nasm output due to my previous changes
  695. Revision 1.3 1997/11/28 18:14:40 pierre
  696. working version with several bug fixes
  697. Revision 1.2 1997/11/27 17:59:46 carl
  698. * made it compile under BP (line too long errors)
  699. Revision 1.1.1.1 1997/11/27 08:32:57 michael
  700. FPC Compiler CVS start
  701. Pre-CVS log:
  702. CEC Carl-Eric Codere
  703. FK Florian Klaempfl
  704. PM Pierre Muller
  705. + feature added
  706. - removed
  707. * bug fixed or changed
  708. History (started with version 0.9.0):
  709. 5th november 1996:
  710. * adapted to 0.9.0
  711. 25th november 1996:
  712. * more stuff adapted
  713. 9th december 1996:
  714. + support for different inline assemblers added (FK)
  715. 22th september:
  716. + support for PACKED RECORD implemented (FK)
  717. 24th september:
  718. + internal support of system.seg added (FK)
  719. * system.ofs bug fixed (FK)
  720. * problem with compiler switches solved (see also pass_1.pas) (FK)
  721. * all aktswitch memory is now recoverd (see also scanner.pas) (FK)
  722. 24th september 1997:
  723. * bug in ESI offset, pushed only if not nested, changed in cgi386.pas in v93 by (FK)
  724. but forgotten here (PM)
  725. 25th september:
  726. + parsing of open arrays implemented (FK)
  727. + parsing of high and low implemented (FK)
  728. + open array support also for proc vars added (FK)
  729. 1th october:
  730. * in typed constants is now the conversion int -> real
  731. automatically done (FK)
  732. 3rd october 1997:
  733. + started conversion to motorola 68000 - ifdef m68k to find
  734. changes (this makes the code look horrible, may later separate
  735. in includes?) - look for all ifdef i386 and ifdef m68k to see
  736. changes. (CEC)
  737. - commented out regnames (was unused) (CEC)
  738. + peepholeopt put in i386 define (not yet available for motorola
  739. 68000) (CEC)
  740. + i386 defines around a_att, in a_o and around a_wasm, a_nasm (CEC).
  741. + code for in_ord_x (PM)
  742. 4th october 1997:
  743. + checking for double definitions of function/procedure
  744. with same parameters in interface (PM)
  745. + enums with jumps set the boolean has_jumps and
  746. disable the succ and pred use (PM)
  747. 9th october 1997:
  748. * Fixed problem with 80float on the 68000 output, caused a GPF (CEC).
  749. 13th october 1997:
  750. + Added support for Motorola Standard assembler. (CEC)
  751. 15th october 1997:
  752. + added code for static modifier for objects variables and methods
  753. controlled by -St switch at command line (PM)
  754. 17th october 1997:
  755. + Added support for Motorola inline assembler (CEC)
  756. * Bugfix with .align 4,0x90, this is NOT allowed in TASM/MASM/WASM (CEC).
  757. + procedure set_macro and setting of fpc_* macros (FK)
  758. 19th october 1997:
  759. * Bugfix of RTS on 68000 target. PC Counter would become corrupt
  760. with paramsize (CEC).
  761. 23th october 1997:
  762. * Small bugfixes concerning SUBI #const,address_reg (CEC).
  763. 24th october 1997:
  764. * array[boolean] works now (FK)
  765. 25th october 1997:
  766. + CDECL and STDCALL (FK)
  767. * ASSEMBLER isn't a keyword anymore (FK)
  768. 3rd november 1997:
  769. + added symdif for sets (PM)
  770. 5th november 1997:
  771. * changed all while token<>ATOKEN do consume(token);
  772. by a procedure call consume_all_untill(ATOKEN)
  773. to test for _EOF (PM)
  774. * aktobjectname was not reset to '' at the end of objectcomponenten (PM)
  775. 14th november 1997:
  776. * removed bug for procvar where the type was not allways set correctly (PM)
  777. + integer const not in longint range converted to real constant (PM)
  778. 25th november 1997:
  779. * removed bugs due to wrong current_module references in compile procedure (PM)
  780. }