pdecl.pas 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl
  4. Does declaration parsing for Free Pascal
  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 pdecl;
  19. interface
  20. uses
  21. globals,symtable;
  22. var
  23. { pointer to the last read type symbol, (for "forward" }
  24. { types) }
  25. lasttypesym : ptypesym;
  26. { hack, which allows to use the current parsed }
  27. { object type as function argument type }
  28. testcurobject : byte;
  29. curobjectname : stringid;
  30. { reads a string type with optional length }
  31. { and returns a pointer to the string }
  32. { definition }
  33. function stringtype : pdef;
  34. { reads a string, file type or a type id and returns a name and }
  35. { pdef }
  36. function single_type(var s : string) : pdef;
  37. { reads the declaration blocks }
  38. procedure read_declarations(islibrary : boolean);
  39. { reads declarations in the interface part of a unit }
  40. procedure read_interface_declarations;
  41. implementation
  42. uses
  43. cobjects,scanner,aasm,tree,pass_1,
  44. files,types,hcodegen,verbose,systems
  45. {$ifdef GDB}
  46. ,gdb
  47. {$endif GDB}
  48. { parser specific stuff }
  49. ,pbase,ptconst,pexpr,psub,pexports
  50. { processor specific stuff }
  51. {$ifdef i386}
  52. ,i386
  53. {$endif}
  54. {$ifdef m68k}
  55. ,m68k
  56. {$endif}
  57. ;
  58. function read_type(const name : stringid) : pdef;forward;
  59. procedure const_dec;
  60. var
  61. name : stringid;
  62. p : ptree;
  63. def : pdef;
  64. sym : psym;
  65. ps : pconstset;
  66. pd : pbestreal;
  67. {$ifdef USEANSISTRING}
  68. sp : pstring;
  69. {$endif USEANSISTRING}
  70. begin
  71. consume(_CONST);
  72. repeat
  73. name:=pattern;
  74. consume(ID);
  75. case token of
  76. EQUAL:
  77. begin
  78. consume(EQUAL);
  79. p:=comp_expr(true);
  80. do_firstpass(p);
  81. case p^.treetype of
  82. ordconstn:
  83. begin
  84. if is_constintnode(p) then
  85. symtablestack^.insert(new(pconstsym,init(name,constint,p^.value,nil)))
  86. else if is_constcharnode(p) then
  87. symtablestack^.insert(new(pconstsym,init(name,constchar,p^.value,nil)))
  88. else if is_constboolnode(p) then
  89. symtablestack^.insert(new(pconstsym,init(name,constbool,p^.value,nil)))
  90. else if p^.resulttype^.deftype=enumdef then
  91. symtablestack^.insert(new(pconstsym,init(name,constord,p^.value,p^.resulttype)))
  92. else if p^.resulttype^.deftype=pointerdef then
  93. symtablestack^.insert(new(pconstsym,init(name,constord,p^.value,p^.resulttype)))
  94. else internalerror(111);
  95. end;
  96. stringconstn:
  97. {values is disposed with p so I need a copy !}
  98. {$ifdef USEANSISTRING} begin
  99. getmem(sp,p^.length+1);
  100. move(p^.values^,sp^[1],p^.length);
  101. sp^[0]:=chr(p^.length);
  102. symtablestack^.insert(new(pconstsym,init(name,conststring,longint(sp),nil)));
  103. end;
  104. {$else USEANSISTRING}
  105. symtablestack^.insert(new(pconstsym,init(name,conststring,longint(stringdup(p^.values^)),nil)));
  106. {$endif USEANSISTRING}
  107. realconstn : begin
  108. new(pd);
  109. pd^:=p^.valued;
  110. symtablestack^.insert(new(pconstsym,init(name,constreal,longint(pd),nil)));
  111. end;
  112. setconstrn : begin
  113. new(ps);
  114. ps^:=p^.constset^;
  115. symtablestack^.insert(new(pconstsym,init(name,
  116. constseta,longint(ps),p^.resulttype)));
  117. end;
  118. else Message(cg_e_illegal_expression);
  119. end;
  120. consume(SEMICOLON);
  121. end;
  122. COLON:
  123. begin
  124. { this was missed, so const s : ^string = nil gives an
  125. error (FK)
  126. }
  127. block_type:=bt_type;
  128. consume(COLON);
  129. ignore_equal:=true;
  130. def:=read_type('');
  131. block_type:=bt_general;
  132. ignore_equal:=false;
  133. sym:=new(ptypedconstsym,init(name,def));
  134. symtablestack^.insert(sym);
  135. consume(EQUAL);
  136. readtypedconst(def,ptypedconstsym(sym));
  137. consume(SEMICOLON);
  138. end;
  139. else consume(EQUAL);
  140. end;
  141. until token<>ID;
  142. end;
  143. procedure label_dec;
  144. var
  145. hl : plabel;
  146. begin
  147. consume(_LABEL);
  148. if not(cs_support_goto in aktmoduleswitches) then
  149. Message(sym_e_goto_and_label_not_supported);
  150. repeat
  151. if not(token in [ID,INTCONST]) then
  152. consume(ID)
  153. else
  154. begin
  155. getlabel(hl);
  156. symtablestack^.insert(new(plabelsym,init(pattern,hl)));
  157. consume(token);
  158. end;
  159. if token<>SEMICOLON then consume(COMMA);
  160. until not(token in [ID,INTCONST]);
  161. consume(SEMICOLON);
  162. end;
  163. procedure read_var_decs(is_record,is_object:boolean);
  164. { reads the filed of a record into a }
  165. { symtablestack, if record=false }
  166. { variants are forbidden, so this procedure }
  167. { can be used to read object fields }
  168. { if absolute is true, ABSOLUTE and file }
  169. { types are allowed }
  170. { => the procedure is also used to read }
  171. { a sequence of variable declaration }
  172. var
  173. sc : pstringcontainer;
  174. s : stringid;
  175. old_block_type : tblock_type;
  176. filepos : tfileposinfo;
  177. symdone : boolean;
  178. { to handle absolute }
  179. abssym : pabsolutesym;
  180. {$ifdef i386}
  181. l : longint;
  182. code : word;
  183. {$endif i386}
  184. { c var }
  185. Csym : pvarsym;
  186. newtype : ptypesym;
  187. is_gpc_name,is_cdecl,extern_Csym,export_Csym : boolean;
  188. C_name : string;
  189. { case }
  190. p,casedef : pdef;
  191. { maxsize contains the max. size of a variant }
  192. { startvarrec contains the start of the variant part of a record }
  193. maxsize,startvarrec : longint;
  194. pt : ptree;
  195. begin
  196. old_block_type:=block_type;
  197. block_type:=bt_type;
  198. is_gpc_name:=false;
  199. { Force an expected ID error message }
  200. if not (token in [ID,_CASE,_END]) then
  201. consume(ID);
  202. { read vars }
  203. while (token=ID) and
  204. not(is_object and
  205. ((pattern='PUBLIC') or (pattern='PRIVATE') or
  206. (pattern='PUBLISHED') or (pattern='PROTECTED'))) do
  207. begin
  208. C_name:=orgpattern;
  209. sc:=idlist;
  210. consume(COLON);
  211. if (cs_gpc_compatible in aktmoduleswitches) and
  212. not(is_record or is_object) and
  213. (token=ID) and (orgpattern='__asmname__') then
  214. begin
  215. consume(ID);
  216. C_name:=get_stringconst;
  217. Is_gpc_name:=true;
  218. end;
  219. p:=read_type('');
  220. symdone:=false;
  221. if is_gpc_name then
  222. begin
  223. s:=sc^.get_with_tokeninfo(filepos);
  224. if not sc^.empty then
  225. Message(parser_e_absolute_only_one_var);
  226. dispose(sc,done);
  227. Csym:=new(pvarsym,init_C(s,target_os.Cprefix+C_name,p));
  228. Csym^.fileinfo:=filepos;
  229. Csym^.var_options:=Csym^.var_options or vo_is_external;
  230. externals^.concat(new(pai_external,init(Csym^.mangledname,EXT_NEAR)));
  231. symtablestack^.insert(Csym);
  232. symdone:=true;
  233. end;
  234. { check for absolute }
  235. if not symdone and (token=ID) and
  236. (pattern='ABSOLUTE') and not(is_record or is_object) then
  237. begin
  238. consume(ID);
  239. { only allowed for one var }
  240. s:=sc^.get_with_tokeninfo(filepos);
  241. if not sc^.empty then
  242. Message(parser_e_absolute_only_one_var);
  243. dispose(sc,done);
  244. { parse the rest }
  245. if token=ID then
  246. begin
  247. getsym(pattern,true);
  248. consume(ID);
  249. { we should check the result type of srsym }
  250. if not (srsym^.typ in [varsym,typedconstsym]) then
  251. Message(parser_e_absolute_only_to_var_or_const);
  252. abssym:=new(pabsolutesym,init(s,p));
  253. abssym^.typ:=absolutesym;
  254. abssym^.abstyp:=tovar;
  255. abssym^.ref:=srsym;
  256. abssym^.fileinfo:=filepos;
  257. symtablestack^.insert(abssym);
  258. end
  259. else
  260. if token=CSTRING then
  261. begin
  262. abssym:=new(pabsolutesym,init(s,p));
  263. s:=pattern;
  264. consume(CSTRING);
  265. abssym^.typ:=absolutesym;
  266. abssym^.abstyp:=toasm;
  267. abssym^.asmname:=stringdup(s);
  268. abssym^.fileinfo:=filepos;
  269. symtablestack^.insert(abssym);
  270. end
  271. else
  272. { absolute address ?!? }
  273. if token=INTCONST then
  274. begin
  275. {$ifdef i386}
  276. if (target_info.target=target_GO32V2) then
  277. begin
  278. abssym:=new(pabsolutesym,init(s,p));
  279. abssym^.typ:=absolutesym;
  280. abssym^.abstyp:=toaddr;
  281. abssym^.absseg:=false;
  282. abssym^.fileinfo:=filepos;
  283. s:=pattern;
  284. consume(INTCONST);
  285. val(s,abssym^.address,code);
  286. if token=COLON then
  287. begin
  288. consume(token);
  289. s:=pattern;
  290. consume(INTCONST);
  291. val(s,l,code);
  292. abssym^.address:=abssym^.address shl 4+l;
  293. abssym^.absseg:=true;
  294. end;
  295. symtablestack^.insert(abssym);
  296. end
  297. else
  298. {$endif i386}
  299. Message(parser_e_absolute_only_to_var_or_const);
  300. end
  301. else
  302. Message(parser_e_absolute_only_to_var_or_const);
  303. symdone:=true;
  304. end;
  305. { for a record there doesn't need to be a ; before the END or ) }
  306. if not((is_record or is_object) and (token in [_END,RKLAMMER])) then
  307. consume(SEMICOLON);
  308. if (p^.deftype=procvardef) and (p^.sym=nil) then
  309. begin
  310. newtype:=new(ptypesym,init('unnamed',p));
  311. parse_var_proc_directives(newtype);
  312. newtype^.definition:=nil;
  313. p^.sym:=nil;
  314. dispose(newtype,done);
  315. end;
  316. { Check for variable directives }
  317. if not symdone and (token=ID) then
  318. begin
  319. { Check for C Variable declarations }
  320. if (cs_support_c_var in aktmoduleswitches) and
  321. not(is_record or is_object) and
  322. ((pattern='EXPORT') or
  323. (pattern='EXTERNAL') or
  324. (pattern='PUBLIC') or
  325. (pattern='CVAR')) then
  326. begin
  327. { only allowed for one var }
  328. s:=sc^.get_with_tokeninfo(filepos);
  329. if not sc^.empty then
  330. Message(parser_e_absolute_only_one_var);
  331. dispose(sc,done);
  332. { defaults }
  333. is_cdecl:=false;
  334. extern_csym:=false;
  335. export_Csym:=false;
  336. { cdecl }
  337. if pattern='CVAR' then
  338. begin
  339. consume(ID);
  340. consume(SEMICOLON);
  341. is_cdecl:=true;
  342. C_name:=target_os.Cprefix+C_name;
  343. end;
  344. { external }
  345. if pattern='EXTERNAL' then
  346. begin
  347. consume(ID);
  348. extern_csym:=true;
  349. end;
  350. { export }
  351. if (pattern='EXPORT') or (pattern='PUBLIC') then
  352. begin
  353. consume(ID);
  354. if extern_csym then
  355. Message(parser_e_not_external_and_export)
  356. else
  357. export_Csym:=true;
  358. end;
  359. { external and export need a name after when no cdecl is used }
  360. if not is_cdecl then
  361. begin
  362. if (token=ID) and (pattern='NAME') then
  363. consume(ID)
  364. else
  365. Message(parser_e_name_keyword_expected);
  366. C_name:=pattern;
  367. { allow also char }
  368. if token=CCHAR then
  369. consume(CCHAR)
  370. else
  371. consume(CSTRING);
  372. end;
  373. { consume the ; when export or external is used }
  374. if extern_csym or export_csym then
  375. consume(SEMICOLON);
  376. { insert in the symtable }
  377. Csym:=new(pvarsym,init_C(s,C_name,p));
  378. Csym^.fileinfo:=filepos;
  379. if export_Csym then
  380. inc(Csym^.refs);
  381. if extern_Csym then
  382. begin
  383. Csym^.var_options:=Csym^.var_options or vo_is_external;
  384. { correct type ?? }
  385. externals^.concat(new(pai_external,init(Csym^.mangledname,EXT_NEAR)));
  386. end;
  387. symtablestack^.insert(Csym);
  388. symdone:=true;
  389. end
  390. else
  391. if (is_object) and (cs_static_keyword in aktglobalswitches) and (pattern='STATIC') then
  392. begin
  393. current_object_option:=current_object_option or sp_static;
  394. insert_syms(symtablestack,sc,p);
  395. current_object_option:=current_object_option - sp_static;
  396. consume(ID);
  397. consume(SEMICOLON);
  398. symdone:=true;
  399. end;
  400. end;
  401. { insert it in the symtable, if not done yet }
  402. if not symdone then
  403. insert_syms(symtablestack,sc,p);
  404. end;
  405. { Check for Case }
  406. if is_record and (token=_CASE) then
  407. begin
  408. maxsize:=0;
  409. consume(_CASE);
  410. s:=pattern;
  411. getsym(s,false);
  412. { may be only a type: }
  413. if assigned(srsym) and (srsym^.typ in [typesym,unitsym]) then
  414. casedef:=read_type('')
  415. else
  416. begin
  417. consume(ID);
  418. consume(COLON);
  419. casedef:=read_type('');
  420. symtablestack^.insert(new(pvarsym,init(s,casedef)));
  421. end;
  422. if not is_ordinal(casedef) then
  423. Message(parser_e_ordinal_expected);
  424. consume(_OF);
  425. startvarrec:=symtablestack^.datasize;
  426. repeat
  427. repeat
  428. pt:=comp_expr(true);
  429. do_firstpass(pt);
  430. if not(pt^.treetype=ordconstn) then
  431. Message(cg_e_illegal_expression);
  432. disposetree(pt);
  433. if token=COMMA then
  434. consume(COMMA)
  435. else
  436. break;
  437. until false;
  438. consume(COLON);
  439. { read the vars }
  440. consume(LKLAMMER);
  441. if token<>RKLAMMER then
  442. read_var_decs(true,false);
  443. consume(RKLAMMER);
  444. { calculates maximal variant size }
  445. maxsize:=max(maxsize,symtablestack^.datasize);
  446. { the items of the next variant are overlayed }
  447. symtablestack^.datasize:=startvarrec;
  448. if (token<>_END) and (token<>RKLAMMER) then
  449. consume(SEMICOLON)
  450. else
  451. break;
  452. until (token=_END) or (token=RKLAMMER);
  453. { at last set the record size to that of the biggest variant }
  454. symtablestack^.datasize:=maxsize;
  455. end;
  456. block_type:=old_block_type;
  457. end;
  458. function stringtype : pdef;
  459. { reads a string type with optional length }
  460. { and returns a pointer to the string }
  461. { definition }
  462. var
  463. p : ptree;
  464. d : pdef;
  465. begin
  466. consume(_STRING);
  467. if token=LECKKLAMMER then
  468. begin
  469. consume(LECKKLAMMER);
  470. p:=comp_expr(true);
  471. do_firstpass(p);
  472. if not is_constintnode(p) then
  473. Message(cg_e_illegal_expression);
  474. {$ifndef UseAnsiString}
  475. if (p^.value<1) or (p^.value>255) then
  476. begin
  477. Message(parser_e_string_too_long);
  478. p^.value:=255;
  479. end;
  480. consume(RECKKLAMMER);
  481. if p^.value<>255 then
  482. d:=new(pstringdef,init(p^.value))
  483. {$ifndef GDB}
  484. else d:=new(pstringdef,init(255));
  485. {$else GDB}
  486. else d:=globaldef('STRING');
  487. {$endif GDB}
  488. {$else UseAnsiString}
  489. if p^.value>255 then
  490. d:=new(pstringdef,ansiinit(p^.value))
  491. else if p^.value<>255 then
  492. d:=new(pstringdef,init(p^.value))
  493. {$ifndef GDB}
  494. else d:=new(pstringdef,init(255));
  495. {$else GDB}
  496. else d:=globaldef('STRING');
  497. {$endif GDB}
  498. consume(RECKKLAMMER);
  499. {$endif UseAnsiString}
  500. disposetree(p);
  501. end
  502. { should string without suffix be an ansistring also
  503. in ansistring mode ?? (PM) Yes!!! (FK) }
  504. else
  505. begin
  506. if cs_ansistrings in aktlocalswitches then
  507. d:=new(pstringdef,ansiinit(0))
  508. else
  509. {$ifndef GDB}
  510. d:=new(pstringdef,init(255));
  511. {$else GDB}
  512. d:=globaldef('STRING');
  513. {$endif GDB}
  514. end;
  515. stringtype:=d;
  516. end;
  517. function id_type(var s : string) : pdef;
  518. { reads a type definition and returns a pointer }
  519. { to a appropriating pdef, s gets the name of }
  520. { the type to allow name mangling }
  521. begin
  522. s:=pattern;
  523. consume(ID);
  524. { classes can be used also in classes }
  525. if (curobjectname=pattern) and aktobjectdef^.isclass then
  526. begin
  527. id_type:=aktobjectdef;
  528. exit;
  529. end;
  530. { objects can be parameters }
  531. if (testcurobject=2) and (curobjectname=pattern) then
  532. begin
  533. id_type:=aktobjectdef;
  534. exit;
  535. end;
  536. getsym(s,true);
  537. if assigned(srsym) then
  538. begin
  539. if srsym^.typ=unitsym then
  540. begin
  541. consume(POINT);
  542. getsymonlyin(punitsym(srsym)^.unitsymtable,pattern);
  543. s:=pattern;
  544. consume(ID);
  545. end;
  546. if srsym^.typ<>typesym then
  547. begin
  548. Message(sym_e_type_id_expected);
  549. lasttypesym:=ptypesym(srsym);
  550. id_type:=generrordef;
  551. exit;
  552. end;
  553. end;
  554. lasttypesym:=ptypesym(srsym);
  555. id_type:=ptypesym(srsym)^.definition;
  556. end;
  557. function single_type(var s : string) : pdef;
  558. { reads a string, file type or a type id and returns a name and }
  559. { pdef }
  560. var
  561. hs : string;
  562. begin
  563. case token of
  564. _STRING:
  565. begin
  566. single_type:=stringtype;
  567. s:='STRING';
  568. lasttypesym:=nil;
  569. end;
  570. _FILE:
  571. begin
  572. consume(_FILE);
  573. if token=_OF then
  574. begin
  575. consume(_OF);
  576. single_type:=new(pfiledef,init(ft_typed,single_type(hs)));
  577. s:='FILE$OF$'+hs;
  578. end
  579. else
  580. begin
  581. { single_type:=new(pfiledef,init(ft_untyped,nil));}
  582. single_type:=cfiledef;
  583. s:='FILE';
  584. end;
  585. lasttypesym:=nil;
  586. end;
  587. else single_type:=id_type(s);
  588. end;
  589. end;
  590. function object_dec(const n : stringid;fd : pobjectdef) : pdef;
  591. { this function parses an object or class declaration }
  592. var
  593. actmembertype : symprop;
  594. there_is_a_destructor : boolean;
  595. is_a_class : boolean;
  596. childof : pobjectdef;
  597. aktclass : pobjectdef;
  598. procedure constructor_head;
  599. begin
  600. consume(_CONSTRUCTOR);
  601. { must be at same level as in implementation }
  602. _proc_head(poconstructor);
  603. if (cs_constructor_name in aktglobalswitches) and (aktprocsym^.name<>'INIT') then
  604. Message(parser_e_constructorname_must_be_init);
  605. consume(SEMICOLON);
  606. begin
  607. if (aktclass^.options and oois_class)<>0 then
  608. begin
  609. { CLASS constructors return the created instance }
  610. aktprocsym^.definition^.retdef:=aktclass;
  611. end
  612. else
  613. begin
  614. { OBJECT constructors return a boolean }
  615. {$IfDef GDB}
  616. {GDB doesn't like unnamed types !}
  617. aktprocsym^.definition^.retdef:=
  618. globaldef('boolean');
  619. {$Else GDB}
  620. aktprocsym^.definition^.retdef:=
  621. new(porddef,init(bool8bit,0,1));
  622. {$Endif GDB}
  623. end;
  624. end;
  625. end;
  626. procedure property_dec;
  627. var
  628. sym : psym;
  629. propertyparas : pdefcoll;
  630. { returns the matching procedure to access a property }
  631. function get_procdef : pprocdef;
  632. var
  633. p : pprocdef;
  634. begin
  635. p:=pprocsym(sym)^.definition;
  636. get_procdef:=nil;
  637. while assigned(p) do
  638. begin
  639. if equal_paras(p^.para1,propertyparas,true) then
  640. break;
  641. p:=p^.nextoverloaded;
  642. end;
  643. get_procdef:=p;
  644. end;
  645. var
  646. hp2,datacoll : pdefcoll;
  647. p,p2 : ppropertysym;
  648. overriden : psym;
  649. hs : string;
  650. code : word;
  651. varspez : tvarspez;
  652. sc : pstringcontainer;
  653. hp : pdef;
  654. s : string;
  655. filepos : tfileposinfo;
  656. pp : pprocdef;
  657. begin
  658. { check for a class }
  659. if (aktclass^.options and oois_class=0) then
  660. Message(parser_e_syntax_error);
  661. consume(_PROPERTY);
  662. if token=ID then
  663. begin
  664. p:=new(ppropertysym,init(pattern));
  665. consume(ID);
  666. propertyparas:=nil;
  667. datacoll:=nil;
  668. { property parameters ? }
  669. if token=LECKKLAMMER then
  670. begin
  671. { create a list of the parameters in propertyparas }
  672. consume(LECKKLAMMER);
  673. inc(testcurobject);
  674. repeat
  675. if token=_VAR then
  676. begin
  677. consume(_VAR);
  678. varspez:=vs_var;
  679. end
  680. else if token=_CONST then
  681. begin
  682. consume(_CONST);
  683. varspez:=vs_const;
  684. end
  685. else varspez:=vs_value;
  686. sc:=idlist;
  687. if token=COLON then
  688. begin
  689. consume(COLON);
  690. if token=_ARRAY then
  691. begin
  692. {
  693. if (varspez<>vs_const) and
  694. (varspez<>vs_var) then
  695. begin
  696. varspez:=vs_const;
  697. Message(parser_e_illegal_open_parameter);
  698. end;
  699. }
  700. consume(_ARRAY);
  701. consume(_OF);
  702. { define range and type of range }
  703. hp:=new(parraydef,init(0,-1,s32bitdef));
  704. { define field type }
  705. parraydef(hp)^.definition:=single_type(s);
  706. end
  707. else
  708. hp:=single_type(s);
  709. end
  710. else
  711. hp:=new(pformaldef,init);
  712. s:=sc^.get_with_tokeninfo(filepos);
  713. while s<>'' do
  714. begin
  715. new(hp2);
  716. hp2^.paratyp:=varspez;
  717. hp2^.data:=hp;
  718. hp2^.next:=propertyparas;
  719. propertyparas:=hp2;
  720. s:=sc^.get_with_tokeninfo(filepos);
  721. end;
  722. dispose(sc,done);
  723. if token=SEMICOLON then consume(SEMICOLON)
  724. else break;
  725. until false;
  726. dec(testcurobject);
  727. consume(RECKKLAMMER);
  728. end;
  729. { overriden property ? }
  730. { force property interface, if there is a property parameter }
  731. if (token=COLON) or assigned(propertyparas) then
  732. begin
  733. consume(COLON);
  734. p^.proptype:=single_type(hs);
  735. if (token=ID) and (pattern='INDEX') then
  736. begin
  737. consume(ID);
  738. p^.options:=p^.options or ppo_indexed;
  739. if token=INTCONST then
  740. val(pattern,p^.index,code);
  741. consume(INTCONST);
  742. { concat a longint to the para template }
  743. new(hp2);
  744. hp2^.paratyp:=vs_value;
  745. hp2^.data:=s32bitdef;
  746. hp2^.next:=propertyparas;
  747. propertyparas:=hp2;
  748. end;
  749. end
  750. else
  751. begin
  752. { do an property override }
  753. overriden:=search_class_member(aktclass,pattern);
  754. if assigned(overriden) and (overriden^.typ=propertysym) then
  755. begin
  756. { take the whole info: }
  757. p^.options:=ppropertysym(overriden)^.options;
  758. p^.index:=ppropertysym(overriden)^.index;
  759. p^.proptype:=ppropertysym(overriden)^.proptype;
  760. p^.writeaccesssym:=ppropertysym(overriden)^.writeaccesssym;
  761. p^.readaccesssym:=ppropertysym(overriden)^.readaccesssym;
  762. p^.writeaccessdef:=ppropertysym(overriden)^.writeaccessdef;
  763. p^.readaccessdef:=ppropertysym(overriden)^.readaccessdef;
  764. end
  765. else
  766. begin
  767. p^.proptype:=generrordef;
  768. message(parser_e_no_property_found_to_override);
  769. end;
  770. end;
  771. { create data defcoll to allow correct parameter checks }
  772. new(datacoll);
  773. datacoll^.paratyp:=vs_value;
  774. datacoll^.data:=p^.proptype;
  775. datacoll^.next:=nil;
  776. if (token=ID) and (pattern='READ') then
  777. begin
  778. consume(ID);
  779. sym:=search_class_member(aktclass,pattern);
  780. if not(assigned(sym)) then
  781. Message1(sym_e_unknown_id,pattern)
  782. else
  783. begin
  784. { varsym aren't allowed for an indexed property
  785. or an property with parameters }
  786. if ((sym^.typ=varsym) and
  787. { not necessary, an index forces propertyparas
  788. to be assigned
  789. }
  790. { (((p^.options and ppo_indexed)<>0) or }
  791. assigned(propertyparas)) or
  792. not(sym^.typ in [varsym,procsym]) then
  793. Message(parser_e_ill_property_access_sym);
  794. { search the matching definition }
  795. if sym^.typ=procsym then
  796. begin
  797. pp:=get_procdef;
  798. if not(assigned(pp)) or
  799. not(is_equal(pp^.retdef,p^.proptype)) then
  800. Message(parser_e_ill_property_access_sym);
  801. p^.readaccessdef:=pp;
  802. end
  803. else if sym^.typ=varsym then
  804. begin
  805. if not(is_equal(pvarsym(sym)^.definition,
  806. p^.proptype)) then
  807. Message(parser_e_ill_property_access_sym);
  808. end;
  809. p^.readaccesssym:=sym;
  810. end;
  811. consume(ID);
  812. end;
  813. if (token=ID) and (pattern='WRITE') then
  814. begin
  815. consume(ID);
  816. sym:=search_class_member(aktclass,pattern);
  817. if not(assigned(sym)) then
  818. Message1(sym_e_unknown_id,pattern)
  819. else
  820. begin
  821. if ((sym^.typ=varsym) and
  822. assigned(propertyparas)) or
  823. not(sym^.typ in [varsym,procsym]) then
  824. Message(parser_e_ill_property_access_sym);
  825. { search the matching definition }
  826. if sym^.typ=procsym then
  827. begin
  828. { insert data entry to check access method }
  829. datacoll^.next:=propertyparas;
  830. propertyparas:=datacoll;
  831. pp:=get_procdef;
  832. { ... and remove it }
  833. propertyparas:=propertyparas^.next;
  834. if not(assigned(pp)) then
  835. Message(parser_e_ill_property_access_sym);
  836. p^.writeaccessdef:=pp;
  837. end
  838. else if sym^.typ=varsym then
  839. begin
  840. if not(is_equal(pvarsym(sym)^.definition,
  841. p^.proptype)) then
  842. Message(parser_e_ill_property_access_sym);
  843. end;
  844. p^.writeaccesssym:=sym;
  845. end;
  846. consume(ID);
  847. end;
  848. if (token=ID) and (pattern='STORED') then
  849. begin
  850. consume(ID);
  851. { !!!!!!!! }
  852. end;
  853. if (token=ID) and (pattern='DEFAULT') then
  854. begin
  855. consume(ID);
  856. { !!!!!!! storage }
  857. consume(SEMICOLON);
  858. end
  859. else if (token=ID) and (pattern='NODEFAULT') then
  860. begin
  861. consume(ID);
  862. { !!!!!!!! }
  863. end;
  864. symtablestack^.insert(p);
  865. { default property ? }
  866. consume(SEMICOLON);
  867. if (token=ID) and (pattern='DEFAULT') then
  868. begin
  869. consume(ID);
  870. p2:=search_default_property(aktclass);
  871. if assigned(p2) then
  872. message1(parser_e_only_one_default_property,
  873. pobjectdef(p2^.owner^.defowner)^.name^)
  874. else
  875. begin
  876. p^.options:=p^.options or ppo_defaultproperty;
  877. if not(assigned(propertyparas)) then
  878. message(parser_e_property_need_paras);
  879. end;
  880. consume(SEMICOLON);
  881. end;
  882. { clean up }
  883. if assigned(datacoll) then
  884. dispose(datacoll);
  885. end
  886. else
  887. begin
  888. consume(ID);
  889. consume(SEMICOLON);
  890. end;
  891. end;
  892. procedure destructor_head;
  893. begin
  894. consume(_DESTRUCTOR);
  895. _proc_head(podestructor);
  896. if (cs_constructor_name in aktglobalswitches) and (aktprocsym^.name<>'DONE') then
  897. Message(parser_e_destructorname_must_be_done);
  898. consume(SEMICOLON);
  899. if assigned(aktprocsym^.definition^.para1) then
  900. Message(parser_e_no_paras_for_destructor);
  901. { no return value }
  902. aktprocsym^.definition^.retdef:=voiddef;
  903. end;
  904. var
  905. hs : string;
  906. pcrd : pclassrefdef;
  907. hp1 : pdef;
  908. oldprocsym : Pprocsym;
  909. oldparse_only : boolean;
  910. classnamelabel : plabel;
  911. begin
  912. {Nowadays aktprocsym may already have a value, so we need to save
  913. it.}
  914. oldprocsym:=aktprocsym;
  915. { forward is resolved }
  916. if assigned(fd) then
  917. fd^.options:=fd^.options and not(oo_isforward);
  918. there_is_a_destructor:=false;
  919. actmembertype:=sp_public;
  920. { objects and class types can't be declared local }
  921. if (symtablestack^.symtabletype<>globalsymtable) and
  922. (symtablestack^.symtabletype<>staticsymtable) then
  923. Message(parser_e_no_local_objects);
  924. { distinguish classes and objects }
  925. if token=_OBJECT then
  926. begin
  927. is_a_class:=false;
  928. consume(_OBJECT)
  929. end
  930. else
  931. begin
  932. is_a_class:=true;
  933. consume(_CLASS);
  934. if not(assigned(fd)) and (token=_OF) then
  935. begin
  936. { a hack, but it's easy to handle }
  937. { class reference type }
  938. consume(_OF);
  939. if typecanbeforward then
  940. forwardsallowed:=true;
  941. hp1:=single_type(hs);
  942. { accept hp1, if is a forward def ...}
  943. if ((lasttypesym<>nil)
  944. and ((lasttypesym^.properties and sp_forwarddef)<>0)) or
  945. { or a class
  946. (if the foward defined type is a class is checked, when
  947. the forward is resolved)
  948. }
  949. ((hp1^.deftype=objectdef) and (
  950. (pobjectdef(hp1)^.options and oois_class)<>0)) then
  951. begin
  952. pcrd:=new(pclassrefdef,init(hp1));
  953. object_dec:=pcrd;
  954. {I add big troubles here
  955. with var p : ^byte in graph.putimage
  956. because a save_forward was called and
  957. no resolve forward
  958. => so the definition was rewritten after
  959. having been disposed !!
  960. Strange problems appeared !!!!}
  961. {Anyhow forwards should only be allowed
  962. inside a type statement ??
  963. don't you think so }
  964. if (lasttypesym<>nil)
  965. and ((lasttypesym^.properties and sp_forwarddef)<>0) then
  966. lasttypesym^.forwardpointer:=ppointerdef(pcrd);
  967. forwardsallowed:=false;
  968. end
  969. else
  970. begin
  971. Message(parser_e_class_type_expected);
  972. object_dec:=new(perrordef,init);
  973. end;
  974. exit;
  975. end
  976. { forward class }
  977. else if not(assigned(fd)) and (token=SEMICOLON) then
  978. begin
  979. { also anonym objects aren't allow (o : object a : longint; end;) }
  980. if n='' then
  981. Message(parser_e_no_anonym_objects);
  982. if n='TOBJECT' then
  983. begin
  984. aktclass:=new(pobjectdef,init(n,nil));
  985. class_tobject:=aktclass;
  986. end
  987. else
  988. aktclass:=new(pobjectdef,init(n,class_tobject));
  989. aktclass^.options:=aktclass^.options or oois_class or oo_isforward;
  990. object_dec:=aktclass;
  991. exit;
  992. end;
  993. end;
  994. { also anonym objects aren't allow (o : object a : longint; end;) }
  995. if n='' then
  996. Message(parser_e_no_anonym_objects);
  997. { read the parent class }
  998. if token=LKLAMMER then
  999. begin
  1000. consume(LKLAMMER);
  1001. { does not allow objects.tobject !! }
  1002. {if token<>ID then
  1003. consume(ID);
  1004. getsym(pattern,true);}
  1005. childof:=pobjectdef(id_type(pattern));
  1006. if (childof^.deftype<>objectdef) then
  1007. begin
  1008. Message(parser_e_class_type_expected);
  1009. childof:=nil;
  1010. end;
  1011. { a mix of class and object isn't allowed }
  1012. if (((childof^.options and oois_class)<>0) and not is_a_class) or
  1013. (((childof^.options and oois_class)=0) and is_a_class) then
  1014. Message(parser_e_mix_of_classes_and_objects);
  1015. if assigned(fd) then
  1016. begin
  1017. { the forward of the child must be resolved to get
  1018. correct field addresses
  1019. }
  1020. if (childof^.options and oo_isforward)<>0 then
  1021. Message1(parser_forward_declaration_must_be_resolved,childof^.name^);
  1022. fd^.childof:=childof;
  1023. aktclass:=fd;
  1024. { ajust the size, because the child could be also
  1025. forward defined
  1026. }
  1027. aktclass^.publicsyms^.datasize:=
  1028. aktclass^.publicsyms^.datasize-4+childof^.publicsyms^.datasize;
  1029. end
  1030. else
  1031. aktclass:=new(pobjectdef,init(n,childof));
  1032. consume(RKLAMMER);
  1033. end
  1034. { if no parent class, then a class get tobject as parent }
  1035. else if is_a_class then
  1036. begin
  1037. { is the current class tobject? }
  1038. { so you could define your own tobject }
  1039. if n='TOBJECT' then
  1040. begin
  1041. if assigned(fd) then
  1042. aktclass:=fd
  1043. else
  1044. aktclass:=new(pobjectdef,init(n,nil));
  1045. class_tobject:=aktclass;
  1046. end
  1047. else
  1048. begin
  1049. childof:=class_tobject;
  1050. if assigned(fd) then
  1051. begin
  1052. { the forward of the child must be resolved to get
  1053. correct field addresses
  1054. }
  1055. if (childof^.options and oo_isforward)<>0 then
  1056. Message1(parser_forward_declaration_must_be_resolved,childof^.name^);
  1057. aktclass:=fd;
  1058. aktclass^.childof:=childof;
  1059. { ajust the size, because the child could be also
  1060. forward defined
  1061. }
  1062. aktclass^.publicsyms^.datasize:=
  1063. aktclass^.publicsyms^.datasize-4+childof^.publicsyms^.datasize;
  1064. end
  1065. else
  1066. aktclass:=new(pobjectdef,init(n,childof));
  1067. end;
  1068. end
  1069. else aktclass:=new(pobjectdef,init(n,nil));
  1070. { set the class attribute }
  1071. if is_a_class then
  1072. begin
  1073. aktclass^.options:=aktclass^.options or oois_class;
  1074. if (cs_generate_rtti in aktmoduleswitches) or
  1075. (assigned(aktclass^.childof) and
  1076. ((aktclass^.childof^.options and oo_can_have_published)<>0)
  1077. ) then
  1078. aktclass^.options:=aktclass^.options or oo_can_have_published;
  1079. end;
  1080. aktobjectdef:=aktclass;
  1081. { default access is public }
  1082. actmembertype:=sp_public;
  1083. aktclass^.publicsyms^.next:=symtablestack;
  1084. symtablestack:=aktclass^.publicsyms;
  1085. procinfo._class:=aktclass;
  1086. testcurobject:=1;
  1087. curobjectname:=n;
  1088. { short class declaration ? }
  1089. if (not is_a_class) or (token<>SEMICOLON) then
  1090. begin
  1091. { Parse componenten }
  1092. repeat
  1093. if actmembertype=sp_private then
  1094. aktclass^.options:=aktclass^.options or oo_hasprivate;
  1095. if actmembertype=sp_protected then
  1096. aktclass^.options:=aktclass^.options or oo_hasprotected;
  1097. case token of
  1098. ID : begin
  1099. if (pattern='PRIVATE') then
  1100. begin
  1101. consume(ID);
  1102. actmembertype:=sp_private;
  1103. current_object_option:=sp_private;
  1104. end
  1105. else
  1106. if (pattern='PROTECTED') then
  1107. begin
  1108. consume(ID);
  1109. current_object_option:=sp_protected;
  1110. actmembertype:=sp_protected;
  1111. end
  1112. else
  1113. if (pattern='PUBLIC') then
  1114. begin
  1115. consume(ID);
  1116. current_object_option:=sp_public;
  1117. actmembertype:=sp_public;
  1118. end
  1119. else
  1120. if (pattern='PUBLISHED') then
  1121. begin
  1122. if (aktclass^.options and oo_can_have_published)=0 then
  1123. Message(parser_e_cant_have_published);
  1124. consume(ID);
  1125. current_object_option:=sp_published;
  1126. actmembertype:=sp_published;
  1127. end
  1128. else
  1129. read_var_decs(false,true);
  1130. end;
  1131. _PROPERTY : property_dec;
  1132. _PROCEDURE,
  1133. _FUNCTION,
  1134. _CLASS : begin
  1135. oldparse_only:=parse_only;
  1136. parse_only:=true;
  1137. proc_head;
  1138. parse_only:=oldparse_only;
  1139. if (token=ID) then
  1140. begin
  1141. if (pattern='VIRTUAL') or (pattern='DYNAMIC') then
  1142. begin
  1143. if actmembertype=sp_private then
  1144. Message(parser_w_priv_meth_not_virtual);
  1145. consume(ID);
  1146. consume(SEMICOLON);
  1147. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or povirtualmethod;
  1148. aktclass^.options:=aktclass^.options or oo_hasvirtual;
  1149. end
  1150. else
  1151. if (pattern='OVERRIDE') then
  1152. begin
  1153. consume(ID);
  1154. consume(SEMICOLON);
  1155. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or
  1156. pooverridingmethod or povirtualmethod;
  1157. end;
  1158. { Delphi II extension }
  1159. if (pattern='ABSTRACT') then
  1160. begin
  1161. consume(ID);
  1162. consume(SEMICOLON);
  1163. if (aktprocsym^.definition^.options and povirtualmethod)<>0 then
  1164. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or poabstractmethod
  1165. else
  1166. Message(parser_e_only_virtual_methods_abstract);
  1167. { the method is defined }
  1168. aktprocsym^.definition^.forwarddef:=false;
  1169. end;
  1170. if (cs_static_keyword in aktglobalswitches) and (pattern='STATIC') then
  1171. begin
  1172. consume(ID);
  1173. consume(SEMICOLON);
  1174. aktprocsym^.properties:=aktprocsym^.properties or sp_static;
  1175. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or postaticmethod;
  1176. end;
  1177. end;
  1178. end;
  1179. _CONSTRUCTOR : begin
  1180. if actmembertype<>sp_public then
  1181. Message(parser_w_constructor_should_be_public);
  1182. oldparse_only:=parse_only;
  1183. parse_only:=true;
  1184. constructor_head;
  1185. parse_only:=oldparse_only;
  1186. if (token=ID) then
  1187. begin
  1188. if (pattern='VIRTUAL') or (pattern='DYNAMIC') then
  1189. begin
  1190. consume(ID);
  1191. consume(SEMICOLON);
  1192. if not(aktclass^.isclass) then
  1193. Message(parser_e_constructor_cannot_be_not_virtual)
  1194. else
  1195. begin
  1196. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or povirtualmethod;
  1197. aktclass^.options:=aktclass^.options or oo_hasvirtual;
  1198. end;
  1199. end
  1200. else
  1201. if (pattern='OVERRIDE') then
  1202. begin
  1203. consume(ID);
  1204. consume(SEMICOLON);
  1205. if (aktclass^.options and oois_class=0) then
  1206. Message(parser_e_constructor_cannot_be_not_virtual)
  1207. else
  1208. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or
  1209. pooverridingmethod or povirtualmethod;
  1210. end;
  1211. end;
  1212. end;
  1213. _DESTRUCTOR : begin
  1214. if there_is_a_destructor then
  1215. Message(parser_n_only_one_destructor);
  1216. there_is_a_destructor:=true;
  1217. if actmembertype<>sp_public then
  1218. Message(parser_w_destructor_should_be_public);
  1219. oldparse_only:=parse_only;
  1220. parse_only:=true;
  1221. destructor_head;
  1222. parse_only:=oldparse_only;
  1223. if (token=ID) then
  1224. begin
  1225. if (pattern='VIRTUAL') or (pattern='DYNAMIC') then
  1226. begin
  1227. consume(ID);
  1228. consume(SEMICOLON);
  1229. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or povirtualmethod;
  1230. end
  1231. else
  1232. if (pattern='OVERRIDE') then
  1233. begin
  1234. consume(ID);
  1235. consume(SEMICOLON);
  1236. aktprocsym^.definition^.options:=aktprocsym^.definition^.options or
  1237. pooverridingmethod or povirtualmethod;
  1238. end;
  1239. end;
  1240. end;
  1241. _END : begin
  1242. consume(_END);
  1243. break;
  1244. end;
  1245. else
  1246. consume(ID); { Give a ident expected message, like tp7 }
  1247. end;
  1248. until false;
  1249. current_object_option:=sp_public;
  1250. end;
  1251. testcurobject:=0;
  1252. curobjectname:='';
  1253. if (cs_smartlink in aktmoduleswitches) then
  1254. datasegment^.concat(new(pai_cut,init));
  1255. { write extended info for classes }
  1256. if is_a_class then
  1257. begin
  1258. { write class name }
  1259. getlabel(classnamelabel);
  1260. datasegment^.concat(new(pai_label,init(classnamelabel)));
  1261. datasegment^.concat(new(pai_const,init_8bit(length(aktclass^.name^))));
  1262. datasegment^.concat(new(pai_string,init(aktclass^.name^)));
  1263. { interface table }
  1264. datasegment^.concat(new(pai_const,init_32bit(0)));
  1265. { auto table }
  1266. datasegment^.concat(new(pai_const,init_32bit(0)));
  1267. { inittable for con-/destruction }
  1268. if aktclass^.needs_inittable then
  1269. datasegment^.concat(new(pai_const,init_symbol(strpnew(lab2str(aktclass^.get_inittable_label)))))
  1270. else
  1271. datasegment^.concat(new(pai_const,init_32bit(0)));
  1272. { pointer to type info of published section }
  1273. datasegment^.concat(new(pai_const,init_symbol(strpnew(lab2str(aktclass^.get_rtti_label)))));
  1274. { pointer to field table }
  1275. datasegment^.concat(new(pai_const,init_32bit(0)));
  1276. { pointer to method table }
  1277. datasegment^.concat(new(pai_const,init_32bit(0)));
  1278. { pointer to dynamic table }
  1279. datasegment^.concat(new(pai_const,init_32bit(0)));
  1280. { pointer to class name string }
  1281. datasegment^.concat(new(pai_const,init_symbol(strpnew(lab2str(classnamelabel)))));
  1282. end;
  1283. {$ifdef GDB}
  1284. { generate the VMT }
  1285. if cs_debuginfo in aktmoduleswitches then
  1286. begin
  1287. do_count_dbx:=true;
  1288. if assigned(aktclass^.owner) and assigned(aktclass^.owner^.name) then
  1289. datasegment^.concat(new(pai_stabs,init(strpnew('"vmt_'+aktclass^.owner^.name^+n+':S'+
  1290. typeglobalnumber('__vtbl_ptr_type')+'",'+tostr(N_STSYM)+',0,0,'+aktclass^.vmt_mangledname))));
  1291. end;
  1292. {$endif GDB}
  1293. datasegment^.concat(new(pai_symbol,init_global(aktclass^.vmt_mangledname)));
  1294. { determine the size with publicsyms^.datasize, because }
  1295. { size gives back 4 for CLASSes }
  1296. datasegment^.concat(new(pai_const,init_32bit(aktclass^.publicsyms^.datasize)));
  1297. datasegment^.concat(new(pai_const,init_32bit(-aktclass^.publicsyms^.datasize)));
  1298. { write pointer to parent VMT, this isn't implemented in TP }
  1299. { but this is not used in FPC ? (PM) }
  1300. { it's not used yet, but the delphi-operators as and is need it (FK) }
  1301. if assigned(aktclass^.childof) then
  1302. begin
  1303. datasegment^.concat(new(pai_const,init_symbol(strpnew(aktclass^.childof^.vmt_mangledname))));
  1304. if aktclass^.childof^.owner^.symtabletype=unitsymtable then
  1305. concat_external(aktclass^.childof^.vmt_mangledname,EXT_NEAR);
  1306. end
  1307. else
  1308. datasegment^.concat(new(pai_const,init_32bit(0)));
  1309. { this generates the entries }
  1310. genvmt(aktclass);
  1311. { restore old state }
  1312. symtablestack:=symtablestack^.next;
  1313. procinfo._class:=nil;
  1314. {Restore the aktprocsym.}
  1315. aktprocsym:=oldprocsym;
  1316. object_dec:=aktclass;
  1317. end;
  1318. { reads a record declaration }
  1319. function record_dec : pdef;
  1320. var
  1321. symtable : psymtable;
  1322. begin
  1323. symtable:=new(psymtable,init(recordsymtable));
  1324. symtable^.next:=symtablestack;
  1325. symtablestack:=symtable;
  1326. consume(_RECORD);
  1327. read_var_decs(true,false);
  1328. { may be scale record size to a size of n*4 ? }
  1329. if ((symtablestack^.datasize mod aktpackrecords)<>0) then
  1330. inc(symtablestack^.datasize,aktpackrecords-(symtablestack^.datasize mod aktpackrecords));
  1331. consume(_END);
  1332. symtablestack:=symtable^.next;
  1333. record_dec:=new(precdef,init(symtable));
  1334. end;
  1335. { search in symtablestack used, but not defined type }
  1336. procedure testforward_types(p : psym);{$ifndef FPC}far;{$endif}
  1337. begin
  1338. if (p^.typ=typesym) and ((p^.properties and sp_forwarddef)<>0) then
  1339. Message(sym_e_type_id_not_defined);
  1340. end;
  1341. { reads a type definition and returns a pointer to it }
  1342. function read_type(const name : stringid) : pdef;
  1343. function handle_procvar:Pprocvardef;
  1344. var
  1345. sc : pstringcontainer;
  1346. s : string;
  1347. p : pdef;
  1348. varspez : tvarspez;
  1349. procvardef : pprocvardef;
  1350. begin
  1351. procvardef:=new(pprocvardef,init);
  1352. if token=LKLAMMER then
  1353. begin
  1354. consume(LKLAMMER);
  1355. inc(testcurobject);
  1356. repeat
  1357. if token=_VAR then
  1358. begin
  1359. consume(_VAR);
  1360. varspez:=vs_var;
  1361. end
  1362. else if token=_CONST then
  1363. begin
  1364. consume(_CONST);
  1365. varspez:=vs_const;
  1366. end
  1367. else varspez:=vs_value;
  1368. sc:=idlist;
  1369. if token=COLON then
  1370. begin
  1371. consume(COLON);
  1372. if token=_ARRAY then
  1373. begin
  1374. {
  1375. if (varspez<>vs_const) and
  1376. (varspez<>vs_var) then
  1377. begin
  1378. varspez:=vs_const;
  1379. Message(parser_e_illegal_open_parameter);
  1380. end;
  1381. }
  1382. consume(_ARRAY);
  1383. consume(_OF);
  1384. { define range and type of range }
  1385. p:=new(parraydef,init(0,-1,s32bitdef));
  1386. { define field type }
  1387. parraydef(p)^.definition:=single_type(s);
  1388. end
  1389. else
  1390. p:=single_type(s);
  1391. end
  1392. else
  1393. p:=new(pformaldef,init);
  1394. s:=sc^.get;
  1395. while s<>'' do
  1396. begin
  1397. procvardef^.concatdef(p,varspez);
  1398. s:=sc^.get;
  1399. end;
  1400. dispose(sc,done);
  1401. if token=SEMICOLON then consume(SEMICOLON)
  1402. else break;
  1403. until false;
  1404. dec(testcurobject);
  1405. consume(RKLAMMER);
  1406. end;
  1407. handle_procvar:=procvardef;
  1408. end;
  1409. var
  1410. hp1,p : pdef;
  1411. aufdef : penumdef;
  1412. aufsym : penumsym;
  1413. ap : parraydef;
  1414. s : stringid;
  1415. l,v,oldaktpackrecords : longint;
  1416. hs : string;
  1417. procedure expr_type;
  1418. var
  1419. pt1,pt2 : ptree;
  1420. begin
  1421. p:=nil;
  1422. { use of current parsed object ? }
  1423. if (token=ID) and (testcurobject=2) and (curobjectname=pattern) then
  1424. begin
  1425. consume(ID);
  1426. p:=aktobjectdef;
  1427. exit;
  1428. end;
  1429. { we can't accept a equal in type }
  1430. pt1:=comp_expr(not(ignore_equal));
  1431. if (pt1^.treetype=typen) and (token<>POINTPOINT) then
  1432. begin
  1433. { a simple type renaming }
  1434. p:=pt1^.resulttype;
  1435. end
  1436. else
  1437. begin
  1438. { range type }
  1439. consume(POINTPOINT);
  1440. { range type declaration }
  1441. do_firstpass(pt1);
  1442. pt2:=comp_expr(not(ignore_equal));
  1443. do_firstpass(pt2);
  1444. { valid expression ? }
  1445. if (pt1^.treetype<>ordconstn) or (pt2^.treetype<>ordconstn) then
  1446. Message(sym_e_error_in_type_def)
  1447. else
  1448. begin
  1449. { Check bounds }
  1450. if pt2^.value<pt1^.value then
  1451. Message(cg_e_upper_lower_than_lower)
  1452. else
  1453. begin
  1454. { is one an enum ? }
  1455. if (pt1^.resulttype^.deftype=enumdef) or (pt2^.resulttype^.deftype=enumdef) then
  1456. begin
  1457. { both must be the have the same (enumdef) definition, else its a type mismatch }
  1458. if (pt1^.resulttype=pt2^.resulttype) then
  1459. p:=new(penumdef,init_subrange(penumdef(pt1^.resulttype),pt1^.value,pt2^.value))
  1460. else
  1461. Message(sym_e_type_mismatch);
  1462. end
  1463. else
  1464. begin
  1465. { both must be are orddefs, create an uauto orddef }
  1466. p:=new(porddef,init(uauto,pt1^.value,pt2^.value));
  1467. end;
  1468. end;
  1469. end;
  1470. disposetree(pt2);
  1471. end;
  1472. disposetree(pt1);
  1473. end;
  1474. var
  1475. pt : ptree;
  1476. procedure array_dec;
  1477. var
  1478. lowval,
  1479. highval : longint;
  1480. arraytype : pdef;
  1481. begin
  1482. consume(_ARRAY);
  1483. consume(LECKKLAMMER);
  1484. { defaults }
  1485. arraytype:=generrordef;
  1486. lowval:=$80000000;
  1487. highval:=$7fffffff;
  1488. p:=nil;
  1489. repeat
  1490. { read the expression and check it }
  1491. pt:=expr;
  1492. if pt^.treetype=typen then
  1493. begin
  1494. case pt^.resulttype^.deftype of
  1495. enumdef : begin
  1496. lowval:=penumdef(pt^.resulttype)^.min;
  1497. highval:=penumdef(pt^.resulttype)^.max;
  1498. arraytype:=pt^.resulttype;
  1499. end;
  1500. orddef : begin
  1501. case porddef(pt^.resulttype)^.typ of
  1502. s8bit,u8bit,
  1503. s16bit,u16bit,
  1504. s32bit : begin
  1505. lowval:=porddef(pt^.resulttype)^.low;
  1506. highval:=porddef(pt^.resulttype)^.high;
  1507. arraytype:=pt^.resulttype;
  1508. end;
  1509. bool8bit,
  1510. bool16bit,
  1511. bool32bit : begin
  1512. lowval:=0;
  1513. highval:=1;
  1514. arraytype:=pt^.resulttype;
  1515. end;
  1516. uchar : begin
  1517. lowval:=0;
  1518. highval:=255;
  1519. arraytype:=pt^.resulttype;
  1520. end;
  1521. else
  1522. Message(sym_e_error_in_type_def);
  1523. end;
  1524. end;
  1525. else
  1526. Message(sym_e_error_in_type_def);
  1527. end
  1528. end
  1529. else
  1530. begin
  1531. do_firstpass(pt);
  1532. if (pt^.treetype<>rangen) or
  1533. (pt^.left^.treetype<>ordconstn) then
  1534. Message(sym_e_error_in_type_def)
  1535. else
  1536. begin
  1537. {$ifndef GDB}
  1538. if pt^.right^.resulttype=pdef(s32bitdef) then
  1539. pt^.right^.resulttype:=new(porddef,init(s32bit,$80000000,$7fffffff));
  1540. {$endif GDB}
  1541. lowval:=pt^.left^.value;
  1542. highval:=pt^.right^.value;
  1543. arraytype:=pt^.right^.resulttype;
  1544. end;
  1545. end;
  1546. disposetree(pt);
  1547. { create arraydef }
  1548. if p=nil then
  1549. begin
  1550. ap:=new(parraydef,init(lowval,highval,arraytype));
  1551. p:=ap;
  1552. end
  1553. else
  1554. begin
  1555. ap^.definition:=new(parraydef,init(lowval,highval,arraytype));
  1556. ap:=parraydef(ap^.definition);
  1557. end;
  1558. if token=COMMA then
  1559. consume(COMMA)
  1560. else
  1561. break;
  1562. until false;
  1563. consume(RECKKLAMMER);
  1564. consume(_OF);
  1565. hp1:=read_type('');
  1566. { if no error, set element type }
  1567. if assigned(ap) then
  1568. ap^.definition:=hp1;
  1569. end;
  1570. begin
  1571. case token of
  1572. _STRING,_FILE:
  1573. p:=single_type(hs);
  1574. LKLAMMER:
  1575. begin
  1576. consume(LKLAMMER);
  1577. { allow negativ values }
  1578. l:=-1;
  1579. aufsym := Nil;
  1580. aufdef:=new(penumdef,init);
  1581. repeat
  1582. s:=pattern;
  1583. consume(ID);
  1584. if token=ASSIGNMENT then
  1585. begin
  1586. consume(ASSIGNMENT);
  1587. v:=get_intconst;
  1588. { please leave that a note, allows type save }
  1589. { declarations in the win32 units ! }
  1590. if v<=l then
  1591. Message(parser_n_duplicate_enum);
  1592. l:=v;
  1593. end
  1594. else
  1595. inc(l);
  1596. constsymtable^.insert(new(penumsym,init(s,aufdef,l)));
  1597. if token=COMMA then
  1598. consume(COMMA)
  1599. else
  1600. break;
  1601. until false;
  1602. {aufdef^.max:=l;
  1603. if we allow unordered enums
  1604. this can be wrong
  1605. min and max are now set in tenumsym.init PM }
  1606. p:=aufdef;
  1607. consume(RKLAMMER);
  1608. end;
  1609. _ARRAY:
  1610. array_dec;
  1611. _SET:
  1612. begin
  1613. consume(_SET);
  1614. consume(_OF);
  1615. hp1:=read_type('');
  1616. case hp1^.deftype of
  1617. { don't forget that min can be negativ PM }
  1618. enumdef : if penumdef(hp1)^.min>=0 then
  1619. p:=new(psetdef,init(hp1,penumdef(hp1)^.max))
  1620. else
  1621. Message(sym_e_ill_type_decl_set);
  1622. orddef : begin
  1623. case porddef(hp1)^.typ of
  1624. uchar : p:=new(psetdef,init(hp1,255));
  1625. u8bit,s8bit,u16bit,s16bit,s32bit :
  1626. begin
  1627. if (porddef(hp1)^.low>=0) then
  1628. p:=new(psetdef,init(hp1,porddef(hp1)^.high))
  1629. else Message(sym_e_ill_type_decl_set);
  1630. end;
  1631. else Message(sym_e_ill_type_decl_set);
  1632. end;
  1633. end;
  1634. else Message(sym_e_ill_type_decl_set);
  1635. end;
  1636. end;
  1637. CARET:
  1638. begin
  1639. consume(CARET);
  1640. { forwards allowed only inside TYPE statements }
  1641. if typecanbeforward then
  1642. forwardsallowed:=true;
  1643. hp1:=single_type(hs);
  1644. p:=new(ppointerdef,init(hp1));
  1645. {I add big troubles here
  1646. with var p : ^byte in graph.putimage
  1647. because a save_forward was called and
  1648. no resolve forward
  1649. => so the definition was rewritten after
  1650. having been disposed !!
  1651. Strange problems appeared !!!!}
  1652. {Anyhow forwards should only be allowed
  1653. inside a type statement ??
  1654. don't you think so }
  1655. if (lasttypesym<>nil)
  1656. and ((lasttypesym^.properties and sp_forwarddef)<>0) then
  1657. lasttypesym^.forwardpointer:=ppointerdef(p);
  1658. forwardsallowed:=false;
  1659. end;
  1660. _RECORD:
  1661. p:=record_dec;
  1662. _PACKED:
  1663. begin
  1664. consume(_PACKED);
  1665. if token=_ARRAY then
  1666. array_dec
  1667. else
  1668. begin
  1669. oldaktpackrecords:=aktpackrecords;
  1670. aktpackrecords:=1;
  1671. if token in [_CLASS,_OBJECT] then
  1672. p:=object_dec(name,nil)
  1673. else
  1674. p:=record_dec;
  1675. aktpackrecords:=oldaktpackrecords;
  1676. end;
  1677. end;
  1678. _CLASS,
  1679. _OBJECT:
  1680. p:=object_dec(name,nil);
  1681. _PROCEDURE:
  1682. begin
  1683. consume(_PROCEDURE);
  1684. p:=handle_procvar;
  1685. if token=_OF then
  1686. begin
  1687. consume(_OF);
  1688. consume(_OBJECT);
  1689. pprocvardef(p)^.options:=pprocvardef(p)^.options or pomethodpointer;
  1690. end;
  1691. end;
  1692. _FUNCTION:
  1693. begin
  1694. consume(_FUNCTION);
  1695. p:=handle_procvar;
  1696. consume(COLON);
  1697. pprocvardef(p)^.retdef:=single_type(hs);
  1698. if token=_OF then
  1699. begin
  1700. consume(_OF);
  1701. consume(_OBJECT);
  1702. pprocvardef(p)^.options:=pprocvardef(p)^.options or pomethodpointer;
  1703. end;
  1704. end;
  1705. else
  1706. expr_type;
  1707. end;
  1708. read_type:=p;
  1709. end;
  1710. { reads a type declaration to the symbol table }
  1711. procedure type_dec;
  1712. var
  1713. typename : stringid;
  1714. newtype : ptypesym;
  1715. {$ifdef dummy}
  1716. olddef,newdef : pdef;
  1717. s : string;
  1718. {$endif dummy}
  1719. begin
  1720. block_type:=bt_type;
  1721. consume(_TYPE);
  1722. typecanbeforward:=true;
  1723. repeat
  1724. typename:=pattern;
  1725. consume(ID);
  1726. consume(EQUAL);
  1727. { here you loose the strictness of pascal
  1728. for which a redefinition like
  1729. childtype = parenttype;
  1730. child2type = parenttype;
  1731. does not make the two child types equal !!
  1732. here all vars from childtype and child2type
  1733. get the definition of parenttype !! }
  1734. {$ifdef testequaltype}
  1735. if (token = ID) or (token=_FILE) or (token=_STRING) then
  1736. begin
  1737. olddef := single_type(s);
  1738. { make a clone of olddef }
  1739. { is that ok ??? }
  1740. getmem(newdef,SizeOf(olddef));
  1741. move(olddef^,newdef^,SizeOf(olddef));
  1742. newtype:=new(ptypesym,init(typename,newdef));
  1743. symtablestack^.insert(newtype);
  1744. end
  1745. else
  1746. {$endif testequaltype}
  1747. begin
  1748. getsym(typename,false);
  1749. { check if it is the definition of a forward defined class }
  1750. if assigned(srsym) and (token=_CLASS) and
  1751. (srsym^.typ=typesym) and
  1752. (ptypesym(srsym)^.definition^.deftype=objectdef) and
  1753. ((pobjectdef(ptypesym(srsym)^.definition)^.options and oo_isforward)<>0) and
  1754. ((pobjectdef(ptypesym(srsym)^.definition)^.options and oois_class)<>0) then
  1755. begin
  1756. { we can ignore the result }
  1757. { the definition is modified }
  1758. object_dec(typename,pobjectdef(ptypesym(srsym)^.definition));
  1759. newtype:=ptypesym(srsym);
  1760. end
  1761. else
  1762. begin
  1763. newtype:=new(ptypesym,init(typename,read_type(typename)));
  1764. { load newtype with the new pointer to the inserted type
  1765. because it can be an already defined forwarded type !! }
  1766. newtype:=ptypesym(symtablestack^.insert(newtype));
  1767. end;
  1768. end;
  1769. consume(SEMICOLON);
  1770. if assigned(newtype^.definition) and (newtype^.definition^.deftype=procvardef) then
  1771. parse_var_proc_directives(newtype);
  1772. until token<>ID;
  1773. typecanbeforward:=false;
  1774. {$ifdef tp}
  1775. symtablestack^.foreach(testforward_types);
  1776. {$else}
  1777. symtablestack^.foreach(@testforward_types);
  1778. {$endif}
  1779. resolve_forwards;
  1780. block_type:=bt_general;
  1781. end;
  1782. procedure var_dec;
  1783. { parses varaible declarations and inserts them in }
  1784. { the top symbol table of symtablestack }
  1785. begin
  1786. consume(_VAR);
  1787. read_var_decs(false,false);
  1788. end;
  1789. procedure Not_supported_for_inline(t : ttoken);
  1790. begin
  1791. if assigned(aktprocsym) and
  1792. ((aktprocsym^.definition^.options and poinline)<>0) then
  1793. Begin
  1794. Message1(parser_w_not_supported_for_inline,tokenstring(t));
  1795. Message(parser_w_inlining_disabled);
  1796. aktprocsym^.definition^.options:= aktprocsym^.definition^.options and not poinline;
  1797. End;
  1798. end;
  1799. procedure read_declarations(islibrary : boolean);
  1800. begin
  1801. repeat
  1802. case token of
  1803. _LABEL:
  1804. begin
  1805. Not_supported_for_inline(token);
  1806. label_dec;
  1807. end;
  1808. _CONST:
  1809. begin
  1810. Not_supported_for_inline(token);
  1811. const_dec;
  1812. end;
  1813. _TYPE:
  1814. begin
  1815. Not_supported_for_inline(token);
  1816. type_dec;
  1817. end;
  1818. _VAR:
  1819. var_dec;
  1820. _CONSTRUCTOR,_DESTRUCTOR,
  1821. _FUNCTION,_PROCEDURE,_OPERATOR,_CLASS:
  1822. begin
  1823. Not_supported_for_inline(token);
  1824. unter_dec;
  1825. end;
  1826. _EXPORTS:
  1827. begin
  1828. { here we should be at lexlevel 1, no ? PM }
  1829. Not_supported_for_inline(token);
  1830. if islibrary then
  1831. read_exports
  1832. else
  1833. break;
  1834. end
  1835. else break;
  1836. end;
  1837. until false;
  1838. end;
  1839. procedure read_interface_declarations;
  1840. begin
  1841. {Since the body is now parsed at lexlevel 1, and the declarations
  1842. must be parsed at the same lexlevel we increase the lexlevel.}
  1843. inc(lexlevel);
  1844. repeat
  1845. case token of
  1846. _CONST : const_dec;
  1847. _TYPE : type_dec;
  1848. _VAR : var_dec;
  1849. _FUNCTION,
  1850. _PROCEDURE,
  1851. _OPERATOR : unter_dec;
  1852. else
  1853. break;
  1854. end;
  1855. until false;
  1856. dec(lexlevel);
  1857. end;
  1858. end.
  1859. {
  1860. $Log$
  1861. Revision 1.47 1998-09-03 16:03:18 florian
  1862. + rtti generation
  1863. * init table generation changed
  1864. Revision 1.46 1998/09/01 17:39:48 peter
  1865. + internal constant functions
  1866. Revision 1.45 1998/08/31 12:20:28 peter
  1867. * fixed array_dec when unknown type was used
  1868. Revision 1.44 1998/08/28 10:57:01 peter
  1869. * removed warnings
  1870. Revision 1.43 1998/08/25 13:09:25 pierre
  1871. * corrected mangling sheme :
  1872. cvar add Cprefix to the mixed case name whereas
  1873. export or public use direct name
  1874. Revision 1.42 1998/08/25 12:42:41 pierre
  1875. * CDECL changed to CVAR for variables
  1876. specifications are read in structures also
  1877. + started adding GPC compatibility mode ( option -Sp)
  1878. * names changed to lowercase
  1879. Revision 1.41 1998/08/23 21:04:36 florian
  1880. + rtti generation for classes added
  1881. + new/dispose do now also a call to INITIALIZE/FINALIZE, if necessaray
  1882. Revision 1.40 1998/08/21 15:48:58 pierre
  1883. * more cdecl chagnes
  1884. - better line info
  1885. - changes the definition options of a procvar
  1886. if it is a unnamed type
  1887. Revision 1.39 1998/08/19 00:42:40 peter
  1888. + subrange types for enums
  1889. + checking for bounds type with ranges
  1890. Revision 1.38 1998/08/12 19:20:39 peter
  1891. + public is the same as export for c_vars
  1892. * a exported/public c_var incs now the refcount
  1893. Revision 1.37 1998/08/11 15:31:38 peter
  1894. * write extended to ppu file
  1895. * new version 0.99.7
  1896. Revision 1.36 1998/08/10 14:50:09 peter
  1897. + localswitches, moduleswitches, globalswitches splitting
  1898. Revision 1.35 1998/07/26 21:59:00 florian
  1899. + better support for switch $H
  1900. + index access to ansi strings added
  1901. + assigment of data (records/arrays) containing ansi strings
  1902. Revision 1.34 1998/07/20 22:17:15 florian
  1903. * hex constants in numeric char (#$54#$43 ...) are now allowed
  1904. * there was a bug in record_var_dec which prevents the used
  1905. of nested variant records (for example drivers.tevent of tv)
  1906. Revision 1.33 1998/07/18 17:11:11 florian
  1907. + ansi string constants fixed
  1908. + switch $H partial implemented
  1909. Revision 1.32 1998/07/14 21:46:50 peter
  1910. * updated messages file
  1911. Revision 1.31 1998/07/14 14:46:53 peter
  1912. * released NEWINPUT
  1913. Revision 1.30 1998/07/10 00:00:00 peter
  1914. * fixed ttypesym bug finally
  1915. * fileinfo in the symtable and better using for unused vars
  1916. Revision 1.29 1998/06/25 14:04:21 peter
  1917. + internal inc/dec
  1918. Revision 1.28 1998/06/24 12:26:45 peter
  1919. * stricter var parsing like tp7 and some optimizes with directive
  1920. parsing
  1921. Revision 1.27 1998/06/12 16:15:34 pierre
  1922. * external name 'C_var';
  1923. export name 'intern_C_var';
  1924. cdecl;
  1925. cdecl;external;
  1926. are now supported only with -Sv switch
  1927. Revision 1.25 1998/06/09 16:01:45 pierre
  1928. + added procedure directive parsing for procvars
  1929. (accepted are popstack cdecl and pascal)
  1930. + added C vars with the following syntax
  1931. var C calias 'true_c_name';(can be followed by external)
  1932. reason is that you must add the Cprefix
  1933. which is target dependent
  1934. Revision 1.24 1998/06/05 14:37:32 pierre
  1935. * fixes for inline for operators
  1936. * inline procedure more correctly restricted
  1937. Revision 1.23 1998/06/04 23:51:50 peter
  1938. * m68k compiles
  1939. + .def file creation moved to gendef.pas so it could also be used
  1940. for win32
  1941. Revision 1.22 1998/06/03 22:48:59 peter
  1942. + wordbool,longbool
  1943. * rename bis,von -> high,low
  1944. * moved some systemunit loading/creating to psystem.pas
  1945. Revision 1.21 1998/06/03 22:14:19 florian
  1946. * problem with sizes of classes fixed (if the anchestor was declared
  1947. forward, the compiler doesn't update the child classes size)
  1948. Revision 1.20 1998/05/28 14:35:54 peter
  1949. * nicer error message when no id is used after var
  1950. Revision 1.19 1998/05/23 01:21:19 peter
  1951. + aktasmmode, aktoptprocessor, aktoutputformat
  1952. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1953. + $LIBNAME to set the library name where the unit will be put in
  1954. * splitted cgi386 a bit (codeseg to large for bp7)
  1955. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1956. Revision 1.18 1998/05/20 09:42:35 pierre
  1957. + UseTokenInfo now default
  1958. * unit in interface uses and implementation uses gives error now
  1959. * only one error for unknown symbol (uses lastsymknown boolean)
  1960. the problem came from the label code !
  1961. + first inlined procedures and function work
  1962. (warning there might be allowed cases were the result is still wrong !!)
  1963. * UseBrower updated gives a global list of all position of all used symbols
  1964. with switch -gb
  1965. Revision 1.17 1998/05/11 13:07:55 peter
  1966. + $ifdef NEWPPU for the new ppuformat
  1967. + $define GDB not longer required
  1968. * removed all warnings and stripped some log comments
  1969. * no findfirst/findnext anymore to remove smartlink *.o files
  1970. Revision 1.16 1998/05/05 12:05:42 florian
  1971. * problems with properties fixed
  1972. * crash fixed: i:=l when i and l are undefined, was a problem with
  1973. implementation of private/protected
  1974. Revision 1.15 1998/05/01 09:01:23 florian
  1975. + correct semantics of private and protected
  1976. * small fix in variable scope:
  1977. a id can be used in a parameter list of a method, even it is used in
  1978. an anchestor class as field id
  1979. Revision 1.14 1998/05/01 07:43:56 florian
  1980. + basics for rtti implemented
  1981. + switch $m (generate rtti for published sections)
  1982. Revision 1.13 1998/04/30 15:59:41 pierre
  1983. * GDB works again better :
  1984. correct type info in one pass
  1985. + UseTokenInfo for better source position
  1986. * fixed one remaining bug in scanner for line counts
  1987. * several little fixes
  1988. Revision 1.12 1998/04/29 10:33:57 pierre
  1989. + added some code for ansistring (not complete nor working yet)
  1990. * corrected operator overloading
  1991. * corrected nasm output
  1992. + started inline procedures
  1993. + added starstarn : use ** for exponentiation (^ gave problems)
  1994. + started UseTokenInfo cond to get accurate positions
  1995. Revision 1.11 1998/04/28 11:45:52 florian
  1996. * make it compilable with TP
  1997. + small COM problems solved to compile classes.pp
  1998. Revision 1.10 1998/04/27 23:10:28 peter
  1999. + new scanner
  2000. * $makelib -> if smartlink
  2001. * small filename fixes pmodule.setfilename
  2002. * moved import from files.pas -> import.pas
  2003. Revision 1.9 1998/04/10 21:36:56 florian
  2004. + some stuff to support method pointers (procedure of object) added
  2005. (declaration, parameter handling)
  2006. Revision 1.8 1998/04/10 15:39:48 florian
  2007. * more fixes to get classes.pas compiled
  2008. Revision 1.7 1998/04/09 23:02:15 florian
  2009. * small problems solved to get remake3 work
  2010. Revision 1.6 1998/04/09 22:16:35 florian
  2011. * problem with previous REGALLOC solved
  2012. * improved property support
  2013. Revision 1.5 1998/04/08 14:59:20 florian
  2014. * problem with new expr_type solved
  2015. Revision 1.4 1998/04/08 10:26:09 florian
  2016. * correct error handling of virtual constructors
  2017. * problem with new type declaration handling fixed
  2018. Revision 1.3 1998/04/07 22:45:05 florian
  2019. * bug0092, bug0115 and bug0121 fixed
  2020. + packed object/class/array
  2021. Revision 1.2 1998/04/05 13:58:35 peter
  2022. * fixed the -Ss bug
  2023. + warning for Virtual constructors
  2024. * helppages updated with -TGO32V1
  2025. }