pdecvar.pas 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Parses variable declarations. Used for var statement and record
  5. definitions
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit pdecvar;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. symsym,symdef;
  24. function read_property_dec(aclass:tobjectdef):tpropertysym;
  25. procedure read_var_decs(is_record,is_object,is_threadvar:boolean);
  26. implementation
  27. uses
  28. { common }
  29. cutils,cclasses,
  30. { global }
  31. globtype,globals,tokens,verbose,
  32. systems,
  33. { symtable }
  34. symconst,symbase,symtype,symtable,defutil,defcmp,
  35. fmodule,
  36. { pass 1 }
  37. node,pass_1,
  38. nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,nmem,
  39. { codegen }
  40. ncgutil,
  41. { parser }
  42. scanner,
  43. pbase,pexpr,ptype,ptconst,pdecsub,
  44. { link }
  45. import
  46. ;
  47. function read_property_dec(aclass:tobjectdef):tpropertysym;
  48. { convert a node tree to symlist and return the last
  49. symbol }
  50. function parse_symlist(pl:tsymlist;var def:tdef):boolean;
  51. var
  52. idx : longint;
  53. sym : tsym;
  54. srsymtable : tsymtable;
  55. st : tsymtable;
  56. p : tnode;
  57. begin
  58. result:=true;
  59. def:=nil;
  60. if token=_ID then
  61. begin
  62. if assigned(aclass) then
  63. sym:=search_class_member(aclass,pattern)
  64. else
  65. searchsym(pattern,sym,srsymtable);
  66. if assigned(sym) then
  67. begin
  68. case sym.typ of
  69. varsym :
  70. begin
  71. pl.addsym(sl_load,sym);
  72. def:=tvarsym(sym).vartype.def;
  73. end;
  74. procsym :
  75. begin
  76. pl.addsym(sl_call,sym);
  77. end;
  78. end;
  79. end
  80. else
  81. begin
  82. Message1(parser_e_illegal_field_or_method,pattern);
  83. result:=false;
  84. end;
  85. consume(_ID);
  86. repeat
  87. case token of
  88. _ID,
  89. _SEMICOLON :
  90. begin
  91. break;
  92. end;
  93. _POINT :
  94. begin
  95. consume(_POINT);
  96. if assigned(def) then
  97. begin
  98. st:=def.getsymtable(gs_record);
  99. if assigned(st) then
  100. begin
  101. sym:=searchsymonlyin(st,pattern);
  102. if assigned(sym) then
  103. begin
  104. pl.addsym(sl_subscript,sym);
  105. case sym.typ of
  106. varsym :
  107. def:=tvarsym(sym).vartype.def;
  108. else
  109. begin
  110. Message1(sym_e_illegal_field,pattern);
  111. result:=false;
  112. end;
  113. end;
  114. end
  115. else
  116. begin
  117. Message1(sym_e_illegal_field,pattern);
  118. result:=false;
  119. end;
  120. end
  121. else
  122. begin
  123. Message(parser_e_invalid_qualifier);
  124. result:=false;
  125. end;
  126. end
  127. else
  128. begin
  129. Message(parser_e_invalid_qualifier);
  130. result:=false;
  131. end;
  132. consume(_ID);
  133. end;
  134. _LECKKLAMMER :
  135. begin
  136. consume(_LECKKLAMMER);
  137. repeat
  138. if def.deftype=arraydef then
  139. begin
  140. idx:=0;
  141. p:=comp_expr(true);
  142. if (not codegenerror) then
  143. begin
  144. if (p.nodetype=ordconstn) then
  145. begin
  146. if compare_defs(p.resulttype.def,tarraydef(def).rangetype.def,nothingn)>=te_equal then
  147. idx:=tordconstnode(p).value
  148. else
  149. IncompatibleTypes(p.resulttype.def,tarraydef(def).rangetype.def);
  150. end
  151. else
  152. Message(type_e_ordinal_expr_expected)
  153. end;
  154. p.free;
  155. pl.addconst(sl_vec,idx);
  156. def:=tarraydef(def).elementtype.def;
  157. end
  158. else
  159. begin
  160. Message(parser_e_invalid_qualifier);
  161. result:=false;
  162. end;
  163. until not try_to_consume(_COMMA);
  164. consume(_RECKKLAMMER);
  165. end;
  166. else
  167. begin
  168. Message(parser_e_ill_property_access_sym);
  169. result:=false;
  170. break;
  171. end;
  172. end;
  173. until false;
  174. end
  175. else
  176. begin
  177. Message(parser_e_ill_property_access_sym);
  178. result:=false;
  179. end;
  180. end;
  181. var
  182. sym : tsym;
  183. p : tpropertysym;
  184. overriden : tsym;
  185. hs : string;
  186. varspez : tvarspez;
  187. s : string;
  188. tt : ttype;
  189. arraytype : ttype;
  190. def : tdef;
  191. pt : tnode;
  192. propname : stringid;
  193. sc : tsinglelist;
  194. oldregisterdef : boolean;
  195. readvs,
  196. hvs : tvarsym;
  197. readprocdef,
  198. writeprocdef : tprocvardef;
  199. oldsymtablestack : tsymtable;
  200. begin
  201. { Generate temp procvardefs to search for matching read/write
  202. procedures. the readprocdef will store all definitions }
  203. oldregisterdef:=registerdef;
  204. registerdef:=false;
  205. readprocdef:=tprocvardef.create(normal_function_level);
  206. writeprocdef:=tprocvardef.create(normal_function_level);
  207. registerdef:=oldregisterdef;
  208. { make it method pointers }
  209. if assigned(aclass) then
  210. begin
  211. include(readprocdef.procoptions,po_methodpointer);
  212. include(writeprocdef.procoptions,po_methodpointer);
  213. end;
  214. if token<>_ID then
  215. begin
  216. consume(_ID);
  217. consume(_SEMICOLON);
  218. exit;
  219. end;
  220. { Generate propertysym and insert in symtablestack }
  221. p:=tpropertysym.create(orgpattern);
  222. symtablestack.insert(p);
  223. propname:=pattern;
  224. consume(_ID);
  225. { Set the symtablestack to the parast of readprop so
  226. temp defs will be destroyed after declaration }
  227. readprocdef.parast.next:=symtablestack;
  228. symtablestack:=readprocdef.parast;
  229. { property parameters ? }
  230. if token=_LECKKLAMMER then
  231. begin
  232. if (sp_published in current_object_option) then
  233. Message(parser_e_cant_publish_that_property);
  234. { create a list of the parameters }
  235. sc:=tsinglelist.create;
  236. consume(_LECKKLAMMER);
  237. inc(testcurobject);
  238. repeat
  239. if token=_VAR then
  240. begin
  241. consume(_VAR);
  242. varspez:=vs_var;
  243. end
  244. else if token=_CONST then
  245. begin
  246. consume(_CONST);
  247. varspez:=vs_const;
  248. end
  249. else if (idtoken=_OUT) and (m_out in aktmodeswitches) then
  250. begin
  251. consume(_OUT);
  252. varspez:=vs_out;
  253. end
  254. else
  255. varspez:=vs_value;
  256. sc.reset;
  257. repeat
  258. readvs:=tvarsym.create(orgpattern,varspez,generrortype);
  259. readprocdef.parast.insert(readvs);
  260. sc.insert(readvs);
  261. consume(_ID);
  262. until not try_to_consume(_COMMA);
  263. if try_to_consume(_COLON) then
  264. begin
  265. { for records, don't search the recordsymtable for
  266. the symbols of the types }
  267. oldsymtablestack:=symtablestack;
  268. symtablestack:=symtablestack.next;
  269. if try_to_consume(_ARRAY) then
  270. begin
  271. consume(_OF);
  272. { define range and type of range }
  273. tt.setdef(tarraydef.create(0,-1,s32inttype));
  274. { define field type }
  275. single_type(arraytype,s,false);
  276. tarraydef(tt.def).setelementtype(arraytype);
  277. end
  278. else
  279. single_type(tt,s,false);
  280. symtablestack:=oldsymtablestack;
  281. end
  282. else
  283. tt:=cformaltype;
  284. readvs:=tvarsym(sc.first);
  285. while assigned(readvs) do
  286. begin
  287. readprocdef.concatpara(nil,tt,readvs,nil,false);
  288. { also update the writeprocdef }
  289. hvs:=tvarsym.create(readvs.realname,vs_value,generrortype);
  290. writeprocdef.parast.insert(hvs);
  291. writeprocdef.concatpara(nil,tt,hvs,nil,false);
  292. readvs:=tvarsym(readvs.listnext);
  293. end;
  294. until not try_to_consume(_SEMICOLON);
  295. sc.free;
  296. dec(testcurobject);
  297. consume(_RECKKLAMMER);
  298. { the parser need to know if a property has parameters, the
  299. index parameter doesn't count (PFV) }
  300. if readprocdef.minparacount>0 then
  301. include(p.propoptions,ppo_hasparameters);
  302. end;
  303. { overriden property ? }
  304. { force property interface
  305. there is a property parameter
  306. a global property }
  307. if (token=_COLON) or (readprocdef.minparacount>0) or (aclass=nil) then
  308. begin
  309. consume(_COLON);
  310. { insert types in global symtable }
  311. oldsymtablestack:=symtablestack;
  312. while not(symtablestack.symtabletype in [globalsymtable,staticsymtable]) do
  313. symtablestack:=symtablestack.next;
  314. single_type(p.proptype,hs,false);
  315. symtablestack:=oldsymtablestack;
  316. if (idtoken=_INDEX) then
  317. begin
  318. consume(_INDEX);
  319. pt:=comp_expr(true);
  320. if is_constnode(pt) and
  321. is_ordinal(pt.resulttype.def)
  322. {$ifndef cpu64bit}
  323. and (not is_64bitint(pt.resulttype.def))
  324. {$endif}
  325. then
  326. p.index:=tordconstnode(pt).value
  327. else
  328. begin
  329. Message(parser_e_invalid_property_index_value);
  330. p.index:=0;
  331. end;
  332. inserttypeconv(pt,sinttype);
  333. p.indextype.setdef(pt.resulttype.def);
  334. include(p.propoptions,ppo_indexed);
  335. { concat a longint to the para templates }
  336. hvs:=tvarsym.create('$index',vs_value,p.indextype);
  337. readprocdef.parast.insert(hvs);
  338. readprocdef.concatpara(nil,p.indextype,hvs,nil,false);
  339. hvs:=tvarsym.create('$index',vs_value,p.indextype);
  340. writeprocdef.parast.insert(hvs);
  341. writeprocdef.concatpara(nil,p.indextype,hvs,nil,false);
  342. pt.free;
  343. end;
  344. end
  345. else
  346. begin
  347. { do an property override }
  348. overriden:=search_class_member(aclass.childof,propname);
  349. if assigned(overriden) and (overriden.typ=propertysym) then
  350. begin
  351. p.dooverride(tpropertysym(overriden));
  352. end
  353. else
  354. begin
  355. p.proptype:=generrortype;
  356. message(parser_e_no_property_found_to_override);
  357. end;
  358. end;
  359. if (sp_published in current_object_option) and
  360. not(p.proptype.def.is_publishable) then
  361. Message(parser_e_cant_publish_that_property);
  362. if try_to_consume(_READ) then
  363. begin
  364. p.readaccess.clear;
  365. if parse_symlist(p.readaccess,def) then
  366. begin
  367. sym:=p.readaccess.firstsym^.sym;
  368. case sym.typ of
  369. procsym :
  370. begin
  371. { read is function returning the type of the property }
  372. readprocdef.rettype:=p.proptype;
  373. { Insert hidden parameters }
  374. handle_calling_convention(readprocdef);
  375. calc_parast(readprocdef);
  376. { search procdefs matching readprocdef }
  377. { we ignore hidden stuff here because the property access symbol might have
  378. non default calling conventions which might change the hidden stuff;
  379. see tw3216.pp (FK) }
  380. p.readaccess.procdef:=Tprocsym(sym).search_procdef_bypara(readprocdef.para,p.proptype.def,[cpo_allowdefaults,cpo_ignorehidden,cpo_allowconvert]);
  381. if not assigned(p.readaccess.procdef) then
  382. Message(parser_e_ill_property_access_sym);
  383. end;
  384. varsym :
  385. begin
  386. if not assigned(def) then
  387. internalerror(200310071);
  388. if compare_defs(def,p.proptype.def,nothingn)>=te_equal then
  389. begin
  390. { property parameters are allowed if this is
  391. an indexed property, because the index is then
  392. the parameter.
  393. Note: In the help of Kylix it is written
  394. that it isn't allowed, but the compiler accepts it (PFV) }
  395. if (ppo_hasparameters in p.propoptions) then
  396. Message(parser_e_ill_property_access_sym);
  397. end
  398. else
  399. IncompatibleTypes(def,p.proptype.def);
  400. end;
  401. else
  402. Message(parser_e_ill_property_access_sym);
  403. end;
  404. end;
  405. end;
  406. if try_to_consume(_WRITE) then
  407. begin
  408. p.writeaccess.clear;
  409. if parse_symlist(p.writeaccess,def) then
  410. begin
  411. sym:=p.writeaccess.firstsym^.sym;
  412. case sym.typ of
  413. procsym :
  414. begin
  415. { write is a procedure with an extra value parameter
  416. of the of the property }
  417. writeprocdef.rettype:=voidtype;
  418. hvs:=tvarsym.create('$value',vs_value,p.proptype);
  419. writeprocdef.parast.insert(hvs);
  420. writeprocdef.concatpara(nil,p.proptype,hvs,nil,false);
  421. { Insert hidden parameters }
  422. handle_calling_convention(writeprocdef);
  423. calc_parast(writeprocdef);
  424. { search procdefs matching writeprocdef }
  425. p.writeaccess.procdef:=Tprocsym(sym).search_procdef_bypara(writeprocdef.para,writeprocdef.rettype.def,[cpo_allowdefaults,cpo_allowconvert]);
  426. if not assigned(p.writeaccess.procdef) then
  427. Message(parser_e_ill_property_access_sym);
  428. end;
  429. varsym :
  430. begin
  431. if not assigned(def) then
  432. internalerror(200310072);
  433. if compare_defs(def,p.proptype.def,nothingn)>=te_equal then
  434. begin
  435. { property parameters are allowed if this is
  436. an indexed property, because the index is then
  437. the parameter.
  438. Note: In the help of Kylix it is written
  439. that it isn't allowed, but the compiler accepts it (PFV) }
  440. if (ppo_hasparameters in p.propoptions) then
  441. Message(parser_e_ill_property_access_sym);
  442. end
  443. else
  444. IncompatibleTypes(def,p.proptype.def);
  445. end;
  446. else
  447. Message(parser_e_ill_property_access_sym);
  448. end;
  449. end;
  450. end;
  451. if assigned(aclass) then
  452. begin
  453. include(p.propoptions,ppo_stored);
  454. if try_to_consume(_STORED) then
  455. begin
  456. p.storedaccess.clear;
  457. case token of
  458. _ID:
  459. begin
  460. { in the case that idtoken=_DEFAULT }
  461. { we have to do nothing except }
  462. { setting ppo_stored, it's the same }
  463. { as stored true }
  464. if idtoken<>_DEFAULT then
  465. begin
  466. if parse_symlist(p.storedaccess,def) then
  467. begin
  468. sym:=p.storedaccess.firstsym^.sym;
  469. case sym.typ of
  470. procsym :
  471. begin
  472. p.storedaccess.procdef:=Tprocsym(sym).search_procdef_nopara_boolret;
  473. if not assigned(p.storedaccess.procdef) then
  474. message(parser_e_ill_property_storage_sym);
  475. end;
  476. varsym :
  477. begin
  478. if not assigned(def) then
  479. internalerror(200310073);
  480. if (ppo_hasparameters in p.propoptions) or
  481. not(is_boolean(def)) then
  482. Message(parser_e_stored_property_must_be_boolean);
  483. end;
  484. else
  485. Message(parser_e_ill_property_access_sym);
  486. end;
  487. end;
  488. end;
  489. end;
  490. _FALSE:
  491. begin
  492. consume(_FALSE);
  493. exclude(p.propoptions,ppo_stored);
  494. end;
  495. _TRUE:
  496. consume(_TRUE);
  497. end;
  498. end;
  499. end;
  500. if try_to_consume(_DEFAULT) then
  501. begin
  502. if not(is_ordinal(p.proptype.def) or
  503. {$ifndef cpu64bit}
  504. is_64bitint(p.proptype.def) or
  505. {$endif cpu64bit}
  506. is_class(p.proptype.def) or
  507. is_single(p.proptype.def) or
  508. (p.proptype.def.deftype in [classrefdef,pointerdef]) or
  509. ((p.proptype.def.deftype=setdef) and
  510. (tsetdef(p.proptype.def).settype=smallset))) or
  511. ((p.proptype.def.deftype=arraydef) and
  512. (ppo_indexed in p.propoptions)) or
  513. (ppo_hasparameters in p.propoptions) then
  514. begin
  515. Message(parser_e_property_cant_have_a_default_value);
  516. { Error recovery }
  517. pt:=comp_expr(true);
  518. pt.free;
  519. end
  520. else
  521. begin
  522. { Get the result of the default, the firstpass is
  523. needed to support values like -1 }
  524. pt:=comp_expr(true);
  525. if (p.proptype.def.deftype=setdef) and
  526. (pt.nodetype=arrayconstructorn) then
  527. begin
  528. arrayconstructor_to_set(pt);
  529. do_resulttypepass(pt);
  530. end;
  531. inserttypeconv(pt,p.proptype);
  532. if not(is_constnode(pt)) then
  533. Message(parser_e_property_default_value_must_const);
  534. { Set default value }
  535. case pt.nodetype of
  536. setconstn :
  537. p.default:=plongint(tsetconstnode(pt).value_set)^;
  538. ordconstn :
  539. p.default:=tordconstnode(pt).value;
  540. niln :
  541. p.default:=0;
  542. realconstn:
  543. p.default:=longint(single(trealconstnode(pt).value_real));
  544. end;
  545. pt.free;
  546. end;
  547. end
  548. else if try_to_consume(_NODEFAULT) then
  549. begin
  550. p.default:=0;
  551. end;
  552. { remove temporary procvardefs }
  553. symtablestack:=symtablestack.next;
  554. readprocdef.free;
  555. writeprocdef.free;
  556. result:=p;
  557. end;
  558. const
  559. variantrecordlevel : longint = 0;
  560. procedure read_var_decs(is_record,is_object,is_threadvar:boolean);
  561. { reads the filed of a record into a }
  562. { symtablestack, if record=false }
  563. { variants are forbidden, so this procedure }
  564. { can be used to read object fields }
  565. { if absolute is true, ABSOLUTE and file }
  566. { types are allowed }
  567. { => the procedure is also used to read }
  568. { a sequence of variable declaration }
  569. procedure insert_syms(sc : tsinglelist;tt : ttype;is_threadvar : boolean; addsymopts : tsymoptions);
  570. { inserts the symbols of sc in st with def as definition or sym as ttypesym, sc is disposed }
  571. var
  572. vs,vs2 : tvarsym;
  573. begin
  574. vs:=tvarsym(sc.first);
  575. while assigned(vs) do
  576. begin
  577. vs.vartype:=tt;
  578. { insert any additional hint directives }
  579. vs.symoptions := vs.symoptions + addsymopts;
  580. if (sp_static in current_object_option) then
  581. include(vs.symoptions,sp_static);
  582. if is_threadvar then
  583. include(vs.varoptions,vo_is_thread_var);
  584. { static data fields are inserted in the globalsymtable }
  585. if (symtablestack.symtabletype=objectsymtable) and
  586. (sp_static in current_object_option) then
  587. begin
  588. vs2:=tvarsym.create('$'+lower(symtablestack.name^)+'_'+vs.name,vs_value,tt);
  589. symtablestack.defowner.owner.insert(vs2);
  590. insertbssdata(vs2);
  591. end
  592. else
  593. begin
  594. { external data is not possible here }
  595. case symtablestack.symtabletype of
  596. globalsymtable,
  597. staticsymtable :
  598. insertbssdata(vs);
  599. recordsymtable,
  600. objectsymtable :
  601. tabstractrecordsymtable(symtablestack).insertfield(vs,false);
  602. end;
  603. end;
  604. vs:=tvarsym(vs.listnext);
  605. end;
  606. end;
  607. procedure read_default_value(sc : tsinglelist;tt : ttype;is_threadvar : boolean);
  608. var
  609. vs : tvarsym;
  610. tcsym : ttypedconstsym;
  611. begin
  612. vs:=tvarsym(sc.first);
  613. if assigned(vs.listnext) then
  614. Message(parser_e_initialized_only_one_var);
  615. if is_threadvar then
  616. Message(parser_e_initialized_not_for_threadvar);
  617. if symtablestack.symtabletype=localsymtable then
  618. begin
  619. consume(_EQUAL);
  620. tcsym:=ttypedconstsym.createtype('default'+vs.realname,tt,false);
  621. vs.defaultconstsym:=tcsym;
  622. symtablestack.insert(tcsym);
  623. insertconstdata(tcsym);
  624. readtypedconst(tt,tcsym,false);
  625. end
  626. else
  627. begin
  628. tcsym:=ttypedconstsym.createtype(vs.realname,tt,true);
  629. tcsym.fileinfo:=vs.fileinfo;
  630. symtablestack.replace(vs,tcsym);
  631. vs.free;
  632. insertconstdata(tcsym);
  633. consume(_EQUAL);
  634. readtypedconst(tt,tcsym,true);
  635. end;
  636. end;
  637. var
  638. sc : tsinglelist;
  639. old_block_type : tblock_type;
  640. symdone : boolean;
  641. { to handle absolute }
  642. abssym : tabsolutesym;
  643. { c var }
  644. newtype : ttypesym;
  645. is_dll,
  646. hasdefaultvalue,
  647. is_gpc_name,is_cdecl,
  648. extern_var,export_var : boolean;
  649. old_current_object_option : tsymoptions;
  650. hs,sorg,C_name,dll_name : string;
  651. tt,casetype : ttype;
  652. { maxsize contains the max. size of a variant }
  653. { startvarrec contains the start of the variant part of a record }
  654. maxsize, startvarrecsize : longint;
  655. usedalign,
  656. maxalignment,startvarrecalign,
  657. maxpadalign, startpadalign: shortint;
  658. hp,pt : tnode;
  659. vs,vs2 : tvarsym;
  660. srsym : tsym;
  661. oldsymtablestack,
  662. srsymtable : tsymtable;
  663. unionsymtable : trecordsymtable;
  664. offset : longint;
  665. uniondef : trecorddef;
  666. unionsym : tvarsym;
  667. uniontype : ttype;
  668. dummysymoptions : tsymoptions;
  669. semicolonatend: boolean;
  670. {$ifdef powerpc}
  671. tempdef: tdef;
  672. is_first_field: boolean;
  673. {$endif powerpc}
  674. begin
  675. {$ifdef powerpc}
  676. is_first_field := true;
  677. {$endif powerpc}
  678. old_current_object_option:=current_object_option;
  679. { all variables are public if not in a object declaration }
  680. if not is_object then
  681. current_object_option:=[sp_public];
  682. old_block_type:=block_type;
  683. block_type:=bt_type;
  684. is_gpc_name:=false;
  685. { Force an expected ID error message }
  686. if not (token in [_ID,_CASE,_END]) then
  687. consume(_ID);
  688. { read vars }
  689. sc:=tsinglelist.create;
  690. while (token=_ID) and
  691. not(is_object and (idtoken in [_PUBLIC,_PRIVATE,_PUBLISHED,_PROTECTED])) do
  692. begin
  693. sorg:=orgpattern;
  694. sc.reset;
  695. repeat
  696. vs:=tvarsym.create(orgpattern,vs_value,generrortype);
  697. symtablestack.insert(vs);
  698. if assigned(vs.owner) then
  699. sc.insert(vs)
  700. else
  701. vs.free;
  702. consume(_ID);
  703. until not try_to_consume(_COMMA);
  704. consume(_COLON);
  705. if (m_gpc in aktmodeswitches) and
  706. not(is_record or is_object or is_threadvar) and
  707. (token=_ID) and (orgpattern='__asmname__') then
  708. begin
  709. consume(_ID);
  710. C_name:=get_stringconst;
  711. Is_gpc_name:=true;
  712. end;
  713. { this is needed for Delphi mode at least
  714. but should be OK for all modes !! (PM) }
  715. ignore_equal:=true;
  716. if is_record or is_object then
  717. begin
  718. { for records, don't search the recordsymtable for
  719. the symbols of the types }
  720. oldsymtablestack:=symtablestack;
  721. symtablestack:=symtablestack.next;
  722. read_type(tt,'',false);
  723. symtablestack:=oldsymtablestack;
  724. end
  725. else
  726. read_type(tt,'',false);
  727. { Process procvar directives }
  728. if (tt.def.deftype=procvardef) and
  729. (tt.def.typesym=nil) and
  730. is_proc_directive(token,true) then
  731. begin
  732. newtype:=ttypesym.create('unnamed',tt);
  733. parse_var_proc_directives(tsym(newtype));
  734. newtype.restype.def:=nil;
  735. tt.def.typesym:=nil;
  736. newtype.free;
  737. end;
  738. {$ifdef powerpc}
  739. { from gcc/gcc/config/rs6000/rs6000.h:
  740. /* APPLE LOCAL begin Macintosh alignment 2002-1-22 ff */
  741. /* Return the alignment of a struct based on the Macintosh PowerPC
  742. alignment rules. In general the alignment of a struct is
  743. determined by the greatest alignment of its elements. However, the
  744. PowerPC rules cause the alignment of a struct to peg at word
  745. alignment except when the first field has greater than word
  746. (32-bit) alignment, in which case the alignment is determined by
  747. the alignment of the first field. */
  748. }
  749. if (target_info.system in [system_powerpc_darwin, system_powerpc_macos]) and
  750. is_record and
  751. is_first_field and
  752. (trecordsymtable(symtablestack).usefieldalignment = -1) then
  753. begin
  754. tempdef := tt.def;
  755. while tempdef.deftype = arraydef do
  756. tempdef := tarraydef(tempdef).elementtype.def;
  757. if tempdef.deftype <> recorddef then
  758. maxpadalign := tempdef.alignment
  759. else
  760. maxpadalign := trecorddef(tempdef).padalignment;
  761. if (maxpadalign > 4) and
  762. (maxpadalign > trecordsymtable(symtablestack).padalignment) then
  763. trecordsymtable(symtablestack).padalignment := maxpadalign;
  764. is_first_field := false;
  765. end;
  766. {$endif powerpc}
  767. { types that use init/final are not allowed in variant parts, but
  768. classes are allowed }
  769. if (variantrecordlevel>0) and
  770. (tt.def.needs_inittable and not is_class(tt.def)) then
  771. Message(parser_e_cant_use_inittable_here);
  772. ignore_equal:=false;
  773. hasdefaultvalue:=false;
  774. symdone:=false;
  775. if is_gpc_name then
  776. begin
  777. vs:=tvarsym(sc.first);
  778. if assigned(vs.listnext) then
  779. Message(parser_e_absolute_only_one_var);
  780. vs.vartype:=tt;
  781. include(vs.varoptions,vo_is_C_var);
  782. vs.set_mangledname(target_info.Cprefix+sorg);
  783. include(vs.varoptions,vo_is_external);
  784. symdone:=true;
  785. end;
  786. { check for absolute }
  787. if not symdone and
  788. (idtoken=_ABSOLUTE) and not(is_record or is_object or is_threadvar) then
  789. begin
  790. consume(_ABSOLUTE);
  791. abssym:=nil;
  792. { only allowed for one var }
  793. vs:=tvarsym(sc.first);
  794. if assigned(vs.listnext) then
  795. Message(parser_e_absolute_only_one_var);
  796. { parse the rest }
  797. pt:=expr;
  798. { check allowed absolute types }
  799. if (pt.nodetype=stringconstn) or
  800. (is_constcharnode(pt)) then
  801. begin
  802. abssym:=tabsolutesym.create(vs.realname,tt);
  803. abssym.fileinfo:=vs.fileinfo;
  804. if pt.nodetype=stringconstn then
  805. hs:=strpas(tstringconstnode(pt).value_str)
  806. else
  807. hs:=chr(tordconstnode(pt).value);
  808. consume(token);
  809. abssym.abstyp:=toasm;
  810. abssym.asmname:=stringdup(hs);
  811. { replace the varsym }
  812. symtablestack.replace(vs,abssym);
  813. vs.free;
  814. end
  815. { address }
  816. else if is_constintnode(pt) and
  817. ((target_info.system in [system_i386_go32v2,system_i386_watcom,
  818. system_i386_wdosx,system_i386_win32]) or
  819. (m_objfpc in aktmodeswitches) or
  820. (m_delphi in aktmodeswitches)) then
  821. begin
  822. abssym:=tabsolutesym.create(vs.realname,tt);
  823. abssym.fileinfo:=vs.fileinfo;
  824. abssym.abstyp:=toaddr;
  825. abssym.fieldoffset:=tordconstnode(pt).value;
  826. {$ifdef i386}
  827. abssym.absseg:=false;
  828. if (target_info.system in [system_i386_go32v2,system_i386_watcom]) and
  829. try_to_consume(_COLON) then
  830. begin
  831. pt.free;
  832. pt:=expr;
  833. if is_constintnode(pt) then
  834. begin
  835. abssym.fieldoffset:=abssym.fieldoffset shl 4+tordconstnode(pt).value;
  836. abssym.absseg:=true;
  837. end
  838. else
  839. Message(type_e_ordinal_expr_expected);
  840. end;
  841. {$endif i386}
  842. symtablestack.replace(vs,abssym);
  843. vs.free;
  844. end
  845. { variable }
  846. else
  847. begin
  848. { remove subscriptn before checking for loadn }
  849. hp:=pt;
  850. while (hp.nodetype in [subscriptn,typeconvn,vecn]) do
  851. hp:=tunarynode(hp).left;
  852. if (hp.nodetype=loadn) then
  853. begin
  854. { we should check the result type of loadn }
  855. if not (tloadnode(hp).symtableentry.typ in [varsym,typedconstsym]) then
  856. Message(parser_e_absolute_only_to_var_or_const);
  857. abssym:=tabsolutesym.create(vs.realname,tt);
  858. abssym.fileinfo:=vs.fileinfo;
  859. abssym.abstyp:=tovar;
  860. abssym.ref:=node_to_symlist(pt);
  861. symtablestack.replace(vs,abssym);
  862. vs.free;
  863. end
  864. else
  865. Message(parser_e_absolute_only_to_var_or_const);
  866. end;
  867. if assigned(abssym) then
  868. begin
  869. { try to consume the hint directives with absolute symbols }
  870. dummysymoptions:=[];
  871. try_consume_hintdirective(dummysymoptions);
  872. abssym.symoptions := abssym.symoptions + dummysymoptions;
  873. end;
  874. pt.free;
  875. symdone:=true;
  876. end;
  877. { Process procvar directives before = and ; }
  878. if (tt.def.deftype=procvardef) and
  879. (tt.def.typesym=nil) and
  880. is_proc_directive(token,true) then
  881. begin
  882. newtype:=ttypesym.create('unnamed',tt);
  883. parse_var_proc_directives(tsym(newtype));
  884. newtype.restype.def:=nil;
  885. tt.def.typesym:=nil;
  886. newtype.free;
  887. end;
  888. { try to parse the hint directives }
  889. dummysymoptions:=[];
  890. try_consume_hintdirective(dummysymoptions);
  891. { Records and objects can't have default values }
  892. if is_record or is_object then
  893. begin
  894. { for a record there doesn't need to be a ; before the END or ) }
  895. if not(token in [_END,_RKLAMMER]) then
  896. consume(_SEMICOLON);
  897. end
  898. else
  899. begin
  900. { Handling of Delphi typed const = initialized vars }
  901. if (token=_EQUAL) and
  902. not(m_tp7 in aktmodeswitches) and
  903. (symtablestack.symtabletype<>parasymtable) then
  904. begin
  905. if (tt.def.deftype=procvardef) and
  906. (tt.def.typesym=nil) then
  907. begin
  908. { Add calling convention for procvar }
  909. handle_calling_convention(tprocvardef(tt.def));
  910. calc_parast(tprocvardef(tt.def));
  911. end;
  912. read_default_value(sc,tt,is_threadvar);
  913. { for locals we've created typedconstsym with a different name }
  914. if symtablestack.symtabletype<>localsymtable then
  915. symdone:=true;
  916. hasdefaultvalue:=true;
  917. end;
  918. consume(_SEMICOLON);
  919. end;
  920. { Support calling convention for procvars after semicolon }
  921. if not(hasdefaultvalue) and
  922. (tt.def.deftype=procvardef) and
  923. (tt.def.typesym=nil) then
  924. begin
  925. { Parse procvar directives after ; }
  926. if is_proc_directive(token,true) then
  927. begin
  928. newtype:=ttypesym.create('unnamed',tt);
  929. parse_var_proc_directives(tsym(newtype));
  930. newtype.restype.def:=nil;
  931. tt.def.typesym:=nil;
  932. newtype.free;
  933. end;
  934. { Add calling convention for procvar }
  935. handle_calling_convention(tprocvardef(tt.def));
  936. calc_parast(tprocvardef(tt.def));
  937. { Handling of Delphi typed const = initialized vars }
  938. if (token=_EQUAL) and
  939. not(is_record or is_object) and
  940. not(m_tp7 in aktmodeswitches) and
  941. (symtablestack.symtabletype<>parasymtable) then
  942. begin
  943. read_default_value(sc,tt,is_threadvar);
  944. consume(_SEMICOLON);
  945. symdone:=true;
  946. hasdefaultvalue:=true;
  947. end;
  948. end;
  949. { Check for EXTERNAL etc directives or, in macpas, if cs_external_var is set}
  950. if not symdone and not(is_record or is_object or is_threadvar) then
  951. begin
  952. if (
  953. (token=_ID) and
  954. (m_cvar_support in aktmodeswitches) and
  955. (idtoken in [_EXPORT,_EXTERNAL,_PUBLIC,_CVAR])
  956. ) or
  957. (
  958. (m_mac in aktmodeswitches) and
  959. ((cs_external_var in aktlocalswitches) or (cs_externally_visible in aktlocalswitches))
  960. ) then
  961. begin
  962. { only allowed for one var }
  963. vs:=tvarsym(sc.first);
  964. if assigned(vs.listnext) then
  965. Message(parser_e_absolute_only_one_var);
  966. { set type of the var }
  967. vs.vartype:=tt;
  968. vs.symoptions := vs.symoptions + dummysymoptions;
  969. { defaults }
  970. is_dll:=false;
  971. is_cdecl:=false;
  972. extern_var:=false;
  973. export_var:=false;
  974. C_name:=sorg;
  975. semicolonatend:= false;
  976. { cdecl }
  977. if idtoken=_CVAR then
  978. begin
  979. consume(_CVAR);
  980. consume(_SEMICOLON);
  981. is_cdecl:=true;
  982. C_name:=target_info.Cprefix+sorg;
  983. end;
  984. { external }
  985. if idtoken=_EXTERNAL then
  986. begin
  987. consume(_EXTERNAL);
  988. extern_var:=true;
  989. semicolonatend:= true;
  990. end;
  991. { macpas specific handling due to some switches}
  992. if (m_mac in aktmodeswitches) then
  993. begin
  994. if (cs_external_var in aktlocalswitches) then
  995. begin {The effect of this is the same as if cvar; external; has been given as directives.}
  996. is_cdecl:=true;
  997. C_name:=target_info.Cprefix+sorg;
  998. extern_var:=true;
  999. end
  1000. else if (cs_externally_visible in aktlocalswitches) then
  1001. begin {The effect of this is the same as if cvar has been given as directives.}
  1002. is_cdecl:=true;
  1003. C_name:=target_info.Cprefix+sorg;
  1004. end;
  1005. end;
  1006. { export }
  1007. if idtoken in [_EXPORT,_PUBLIC] then
  1008. begin
  1009. consume(_ID);
  1010. if extern_var or
  1011. (symtablestack.symtabletype in [parasymtable,localsymtable]) then
  1012. Message(parser_e_not_external_and_export)
  1013. else
  1014. begin
  1015. export_var:=true;
  1016. semicolonatend:= true;
  1017. end;
  1018. end;
  1019. { external and export need a name after when no cdecl is used }
  1020. if not is_cdecl then
  1021. begin
  1022. { dll name ? }
  1023. if (extern_var) and (idtoken<>_NAME) then
  1024. begin
  1025. is_dll:=true;
  1026. dll_name:=get_stringconst;
  1027. end;
  1028. consume(_NAME);
  1029. C_name:=get_stringconst;
  1030. end;
  1031. { consume the ; when export or external is used }
  1032. if semicolonatend then
  1033. consume(_SEMICOLON);
  1034. { set some vars options }
  1035. if is_dll then
  1036. include(vs.varoptions,vo_is_dll_var)
  1037. else
  1038. include(vs.varoptions,vo_is_C_var);
  1039. if (is_dll) and
  1040. (target_info.system = system_powerpc_darwin) then
  1041. C_Name := target_info.Cprefix+C_Name;
  1042. vs.set_mangledname(C_Name);
  1043. if export_var then
  1044. begin
  1045. inc(vs.refs);
  1046. include(vs.varoptions,vo_is_exported);
  1047. end;
  1048. if extern_var then
  1049. include(vs.varoptions,vo_is_external);
  1050. { insert in the datasegment when it is not external }
  1051. if (not extern_var) then
  1052. insertbssdata(vs);
  1053. { now we can insert it in the import lib if its a dll, or
  1054. add it to the externals }
  1055. if extern_var then
  1056. begin
  1057. if is_dll then
  1058. begin
  1059. if not(current_module.uses_imports) then
  1060. begin
  1061. current_module.uses_imports:=true;
  1062. importlib.preparelib(current_module.modulename^);
  1063. end;
  1064. importlib.importvariable(vs,C_name,dll_name);
  1065. end
  1066. else
  1067. if target_info.DllScanSupported then
  1068. current_module.Externals.insert(tExternalsItem.create(vs.mangledname));
  1069. end;
  1070. symdone:=true;
  1071. end;
  1072. end;
  1073. { Check for STATIC directive }
  1074. if not symdone and (is_object) and
  1075. (cs_static_keyword in aktmoduleswitches) and (idtoken=_STATIC) then
  1076. begin
  1077. include(current_object_option,sp_static);
  1078. insert_syms(sc,tt,false,dummysymoptions);
  1079. exclude(current_object_option,sp_static);
  1080. consume(_STATIC);
  1081. consume(_SEMICOLON);
  1082. symdone:=true;
  1083. end;
  1084. { insert it in the symtable, if not done yet }
  1085. if not symdone then
  1086. begin
  1087. { save object option, because we can turn of the sp_published }
  1088. if (sp_published in current_object_option) and
  1089. not(is_class(tt.def)) then
  1090. begin
  1091. Message(parser_e_cant_publish_that);
  1092. exclude(current_object_option,sp_published);
  1093. { recover by changing access type to public }
  1094. vs2:=tvarsym(sc.first);
  1095. while assigned (vs2) do
  1096. begin
  1097. exclude(vs2.symoptions,sp_published);
  1098. include(vs2.symoptions,sp_public);
  1099. vs2:=tvarsym(vs2.listnext);
  1100. end;
  1101. end
  1102. else
  1103. if (sp_published in current_object_option) and
  1104. not(oo_can_have_published in tobjectdef(tt.def).objectoptions) then
  1105. begin
  1106. Message(parser_e_only_publishable_classes_can__be_published);
  1107. exclude(current_object_option,sp_published);
  1108. end;
  1109. insert_syms(sc,tt,is_threadvar,dummysymoptions);
  1110. current_object_option:=old_current_object_option;
  1111. end;
  1112. end;
  1113. { Check for Case }
  1114. if is_record and (token=_CASE) then
  1115. begin
  1116. maxsize:=0;
  1117. maxalignment:=0;
  1118. maxpadalign:=0;
  1119. consume(_CASE);
  1120. sorg:=orgpattern;
  1121. hs:=pattern;
  1122. searchsym(hs,srsym,srsymtable);
  1123. { may be only a type: }
  1124. if assigned(srsym) and (srsym.typ in [typesym,unitsym]) then
  1125. begin
  1126. { for records, don't search the recordsymtable for
  1127. the symbols of the types }
  1128. oldsymtablestack:=symtablestack;
  1129. symtablestack:=symtablestack.next;
  1130. read_type(casetype,'',true);
  1131. symtablestack:=oldsymtablestack;
  1132. end
  1133. else
  1134. begin
  1135. consume(_ID);
  1136. consume(_COLON);
  1137. { for records, don't search the recordsymtable for
  1138. the symbols of the types }
  1139. oldsymtablestack:=symtablestack;
  1140. symtablestack:=symtablestack.next;
  1141. read_type(casetype,'',true);
  1142. symtablestack:=oldsymtablestack;
  1143. vs:=tvarsym.create(sorg,vs_value,casetype);
  1144. tabstractrecordsymtable(symtablestack).insertfield(vs,true);
  1145. end;
  1146. if not(is_ordinal(casetype.def))
  1147. {$ifndef cpu64bit}
  1148. or is_64bitint(casetype.def)
  1149. {$endif cpu64bit}
  1150. then
  1151. Message(type_e_ordinal_expr_expected);
  1152. consume(_OF);
  1153. UnionSymtable:=trecordsymtable.create(aktpackrecords);
  1154. Unionsymtable.next:=symtablestack;
  1155. registerdef:=false;
  1156. UnionDef:=trecorddef.create(unionsymtable);
  1157. uniondef.isunion:=true;
  1158. if assigned(symtablestack.defowner) then
  1159. Uniondef.owner:=symtablestack.defowner.owner;
  1160. registerdef:=true;
  1161. startvarrecsize:=UnionSymtable.datasize;
  1162. startvarrecalign:=UnionSymtable.fieldalignment;
  1163. startpadalign:=Unionsymtable.padalignment;
  1164. symtablestack:=UnionSymtable;
  1165. repeat
  1166. repeat
  1167. pt:=comp_expr(true);
  1168. if not(pt.nodetype=ordconstn) then
  1169. Message(parser_e_illegal_expression);
  1170. pt.free;
  1171. if token=_COMMA then
  1172. consume(_COMMA)
  1173. else
  1174. break;
  1175. until false;
  1176. consume(_COLON);
  1177. { read the vars }
  1178. consume(_LKLAMMER);
  1179. inc(variantrecordlevel);
  1180. if token<>_RKLAMMER then
  1181. read_var_decs(true,false,false);
  1182. dec(variantrecordlevel);
  1183. consume(_RKLAMMER);
  1184. { calculates maximal variant size }
  1185. maxsize:=max(maxsize,unionsymtable.datasize);
  1186. maxalignment:=max(maxalignment,unionsymtable.fieldalignment);
  1187. maxpadalign:=max(maxpadalign,unionsymtable.padalignment);
  1188. { the items of the next variant are overlayed }
  1189. unionsymtable.datasize:=startvarrecsize;
  1190. unionsymtable.fieldalignment:=startvarrecalign;
  1191. unionsymtable.padalignment:=startpadalign;
  1192. if (token<>_END) and (token<>_RKLAMMER) then
  1193. consume(_SEMICOLON)
  1194. else
  1195. break;
  1196. until (token=_END) or (token=_RKLAMMER);
  1197. { at last set the record size to that of the biggest variant }
  1198. unionsymtable.datasize:=maxsize;
  1199. unionsymtable.fieldalignment:=maxalignment;
  1200. uniontype.def:=uniondef;
  1201. uniontype.sym:=nil;
  1202. UnionSym:=tvarsym.create('$case',vs_value,uniontype);
  1203. symtablestack:=symtablestack.next;
  1204. unionsymtable.addalignmentpadding;
  1205. {$ifdef powerpc}
  1206. { parent inherits the alignment padding if the variant is the first "field" of the parent record/variant }
  1207. if (target_info.system in [system_powerpc_darwin, system_powerpc_macos]) and
  1208. is_first_field and
  1209. (trecordsymtable(symtablestack).usefieldalignment = -1) and
  1210. (maxpadalign > trecordsymtable(symtablestack).padalignment) then
  1211. trecordsymtable(symtablestack).padalignment:=maxpadalign;
  1212. {$endif powerpc}
  1213. { Align the offset where the union symtable is added }
  1214. if (trecordsymtable(symtablestack).usefieldalignment=-1) then
  1215. usedalign:=used_align(unionsymtable.recordalignment,aktalignment.recordalignmin,aktalignment.maxCrecordalign)
  1216. else
  1217. usedalign:=used_align(unionsymtable.recordalignment,aktalignment.recordalignmin,aktalignment.recordalignmax);
  1218. offset:=align(trecordsymtable(symtablestack).datasize,usedalign);
  1219. trecordsymtable(symtablestack).datasize:=offset+unionsymtable.datasize;
  1220. if unionsymtable.recordalignment>trecordsymtable(symtablestack).fieldalignment then
  1221. trecordsymtable(symtablestack).fieldalignment:=unionsymtable.recordalignment;
  1222. trecordsymtable(symtablestack).insertunionst(Unionsymtable,offset);
  1223. Unionsym.owner:=nil;
  1224. unionsym.free;
  1225. uniondef.owner:=nil;
  1226. uniondef.free;
  1227. end;
  1228. block_type:=old_block_type;
  1229. current_object_option:=old_current_object_option;
  1230. { free the list }
  1231. sc.free;
  1232. {$ifdef powerpc}
  1233. is_first_field := false;
  1234. {$endif powerpc}
  1235. end;
  1236. end.
  1237. {
  1238. $Log$
  1239. Revision 1.81 2004-10-15 09:14:17 mazen
  1240. - remove $IFDEF DELPHI and related code
  1241. - remove $IFDEF FPCPROCVAR and related code
  1242. Revision 1.80 2004/10/12 14:36:38 peter
  1243. * gen high tree makes copy in temp when there is a calln
  1244. Revision 1.79 2004/08/17 16:29:21 jonas
  1245. + padalgingment field for recordsymtables (saved by recorddefs)
  1246. + support for Macintosh PowerPC alignment (if the first field of a record
  1247. or union has an alignment > 4, then the record or union size must be
  1248. padded to a multiple of this size)
  1249. Revision 1.78 2004/08/15 13:30:18 florian
  1250. * fixed alignment of variant records
  1251. * more alignment problems fixed
  1252. Revision 1.77 2004/08/07 19:14:50 florian
  1253. * fixed problem with explicit specified calling conventions for property symbols
  1254. Revision 1.76 2004/07/14 23:19:22 olle
  1255. + added external facilities for macpas
  1256. Revision 1.75 2004/06/20 08:55:30 florian
  1257. * logs truncated
  1258. Revision 1.74 2004/06/16 20:07:09 florian
  1259. * dwarf branch merged
  1260. Revision 1.73 2004/04/11 12:38:16 peter
  1261. * fix calling convention problem when parsing default value before
  1262. the semicolon
  1263. Revision 1.72.2.5 2004/05/02 20:54:04 peter
  1264. * allow convert when choosing property function with index
  1265. Revision 1.72.2.4 2004/05/01 20:51:20 peter
  1266. * fix val code parameter
  1267. Revision 1.72.2.3 2004/04/28 19:55:52 peter
  1268. * new warning for ordinal-pointer when size is different
  1269. * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
  1270. }