parser.pas 31 KB

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