pdecl.pas 83 KB

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