pdecvar.pas 52 KB

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