pdecl.pas 81 KB

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