pdecl.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Does declaration (but not type) parsing for Free Pascal
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit pdecl;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. { global }
  22. globals,
  23. { symtable }
  24. symsym,
  25. { pass_1 }
  26. node;
  27. function readconstant(const orgname:string;const filepos:tfileposinfo):tconstsym;
  28. procedure const_dec;
  29. procedure label_dec;
  30. procedure type_dec;
  31. procedure var_dec;
  32. procedure threadvar_dec;
  33. procedure property_dec;
  34. procedure resourcestring_dec;
  35. implementation
  36. uses
  37. { common }
  38. cutils,cclasses,
  39. { global }
  40. globtype,tokens,verbose,widestr,
  41. systems,
  42. { aasm }
  43. aasmbase,aasmtai,aasmdata,fmodule,
  44. { symtable }
  45. symconst,symbase,symtype,symdef,symtable,paramgr,defutil,
  46. { pass 1 }
  47. nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,nobj,
  48. { codegen }
  49. ncgutil,
  50. { parser }
  51. scanner,
  52. pbase,pexpr,ptype,ptconst,pdecsub,pdecvar,pdecobj,
  53. { cpu-information }
  54. cpuinfo
  55. ;
  56. function readconstant(const orgname:string;const filepos:tfileposinfo):tconstsym;
  57. var
  58. hp : tconstsym;
  59. p : tnode;
  60. ps : pconstset;
  61. pd : pbestreal;
  62. pg : pguid;
  63. sp : pchar;
  64. pw : pcompilerwidestring;
  65. storetokenpos : tfileposinfo;
  66. begin
  67. readconstant:=nil;
  68. if orgname='' then
  69. internalerror(9584582);
  70. hp:=nil;
  71. p:=comp_expr(true);
  72. storetokenpos:=akttokenpos;
  73. akttokenpos:=filepos;
  74. case p.nodetype of
  75. ordconstn:
  76. begin
  77. if p.resulttype.def.deftype=pointerdef then
  78. hp:=tconstsym.create_ordptr(orgname,constpointer,tordconstnode(p).value,p.resulttype)
  79. else
  80. hp:=tconstsym.create_ord(orgname,constord,tordconstnode(p).value,p.resulttype);
  81. end;
  82. stringconstn:
  83. begin
  84. if is_widestring(p.resulttype.def) then
  85. begin
  86. initwidestring(pw);
  87. copywidestring(pcompilerwidestring(tstringconstnode(p).value_str),pw);
  88. hp:=tconstsym.create_wstring(orgname,constwstring,pw);
  89. end
  90. else
  91. begin
  92. getmem(sp,tstringconstnode(p).len+1);
  93. move(tstringconstnode(p).value_str^,sp^,tstringconstnode(p).len+1);
  94. hp:=tconstsym.create_string(orgname,conststring,sp,tstringconstnode(p).len);
  95. end;
  96. end;
  97. realconstn :
  98. begin
  99. new(pd);
  100. pd^:=trealconstnode(p).value_real;
  101. hp:=tconstsym.create_ptr(orgname,constreal,pd,p.resulttype);
  102. end;
  103. setconstn :
  104. begin
  105. new(ps);
  106. ps^:=tsetconstnode(p).value_set^;
  107. hp:=tconstsym.create_ptr(orgname,constset,ps,p.resulttype);
  108. end;
  109. pointerconstn :
  110. begin
  111. hp:=tconstsym.create_ordptr(orgname,constpointer,tpointerconstnode(p).value,p.resulttype);
  112. end;
  113. niln :
  114. begin
  115. hp:=tconstsym.create_ord(orgname,constnil,0,p.resulttype);
  116. end;
  117. typen :
  118. begin
  119. if is_interface(p.resulttype.def) then
  120. begin
  121. if assigned(tobjectdef(p.resulttype.def).iidguid) then
  122. begin
  123. new(pg);
  124. pg^:=tobjectdef(p.resulttype.def).iidguid^;
  125. hp:=tconstsym.create_ptr(orgname,constguid,pg,p.resulttype);
  126. end
  127. else
  128. Message1(parser_e_interface_has_no_guid,tobjectdef(p.resulttype.def).objrealname^);
  129. end
  130. else
  131. Message(parser_e_illegal_expression);
  132. end;
  133. else
  134. Message(parser_e_illegal_expression);
  135. end;
  136. akttokenpos:=storetokenpos;
  137. p.free;
  138. readconstant:=hp;
  139. end;
  140. procedure const_dec;
  141. var
  142. orgname : stringid;
  143. tt : ttype;
  144. sym : tsym;
  145. dummysymoptions : tsymoptions;
  146. storetokenpos,filepos : tfileposinfo;
  147. old_block_type : tblock_type;
  148. skipequal : boolean;
  149. tclist : tasmlist;
  150. begin
  151. consume(_CONST);
  152. old_block_type:=block_type;
  153. block_type:=bt_const;
  154. repeat
  155. orgname:=orgpattern;
  156. filepos:=akttokenpos;
  157. consume(_ID);
  158. case token of
  159. _EQUAL:
  160. begin
  161. consume(_EQUAL);
  162. sym:=readconstant(orgname,filepos);
  163. { Support hint directives }
  164. dummysymoptions:=[];
  165. try_consume_hintdirective(dummysymoptions);
  166. if assigned(sym) then
  167. begin
  168. sym.symoptions:=sym.symoptions+dummysymoptions;
  169. symtablestack.top.insert(sym);
  170. end;
  171. consume(_SEMICOLON);
  172. end;
  173. _COLON:
  174. begin
  175. { set the blocktype first so a consume also supports a
  176. caret, to support const s : ^string = nil }
  177. block_type:=bt_type;
  178. consume(_COLON);
  179. ignore_equal:=true;
  180. read_anon_type(tt,false);
  181. ignore_equal:=false;
  182. block_type:=bt_const;
  183. skipequal:=false;
  184. { create symbol }
  185. storetokenpos:=akttokenpos;
  186. akttokenpos:=filepos;
  187. sym:=ttypedconstsym.createtype(orgname,tt,(cs_typed_const_writable in aktlocalswitches));
  188. akttokenpos:=storetokenpos;
  189. symtablestack.top.insert(sym);
  190. { procvar can have proc directives, but not type references }
  191. if (tt.def.deftype=procvardef) and
  192. (tt.sym=nil) then
  193. begin
  194. { support p : procedure;stdcall=nil; }
  195. if try_to_consume(_SEMICOLON) then
  196. begin
  197. if check_proc_directive(true) then
  198. parse_var_proc_directives(sym)
  199. else
  200. begin
  201. Message(parser_e_proc_directive_expected);
  202. skipequal:=true;
  203. end;
  204. end
  205. else
  206. { support p : procedure stdcall=nil; }
  207. begin
  208. if check_proc_directive(true) then
  209. parse_var_proc_directives(sym);
  210. end;
  211. { add default calling convention }
  212. handle_calling_convention(tabstractprocdef(tt.def));
  213. end;
  214. if not skipequal then
  215. begin
  216. { get init value }
  217. consume(_EQUAL);
  218. if (cs_typed_const_writable in aktlocalswitches) then
  219. tclist:=current_asmdata.asmlists[al_rotypedconsts]
  220. else
  221. tclist:=current_asmdata.asmlists[al_typedconsts];
  222. readtypedconst(tclist,tt,ttypedconstsym(sym),(cs_typed_const_writable in aktlocalswitches));
  223. consume(_SEMICOLON);
  224. end;
  225. end;
  226. else
  227. { generate an error }
  228. consume(_EQUAL);
  229. end;
  230. until token<>_ID;
  231. block_type:=old_block_type;
  232. end;
  233. procedure label_dec;
  234. begin
  235. consume(_LABEL);
  236. if not(cs_support_goto in aktmoduleswitches) then
  237. Message(sym_e_goto_and_label_not_supported);
  238. repeat
  239. if not(token in [_ID,_INTCONST]) then
  240. consume(_ID)
  241. else
  242. begin
  243. if token=_ID then
  244. symtablestack.top.insert(tlabelsym.create(orgpattern))
  245. else
  246. symtablestack.top.insert(tlabelsym.create(pattern));
  247. consume(token);
  248. end;
  249. if token<>_SEMICOLON then consume(_COMMA);
  250. until not(token in [_ID,_INTCONST]);
  251. consume(_SEMICOLON);
  252. end;
  253. { search in symtablestack used, but not defined type }
  254. procedure resolve_type_forward(p : tnamedindexitem;arg:pointer);
  255. var
  256. hpd,pd : tdef;
  257. stpos : tfileposinfo;
  258. again : boolean;
  259. srsym : tsym;
  260. srsymtable : tsymtable;
  261. begin
  262. { Check only typesyms or record/object fields }
  263. case tsym(p).typ of
  264. typesym :
  265. pd:=ttypesym(p).restype.def;
  266. fieldvarsym :
  267. pd:=tfieldvarsym(p).vartype.def
  268. else
  269. exit;
  270. end;
  271. repeat
  272. again:=false;
  273. case pd.deftype of
  274. arraydef :
  275. begin
  276. { elementtype could also be defined using a forwarddef }
  277. pd:=tarraydef(pd).elementtype.def;
  278. again:=true;
  279. end;
  280. pointerdef,
  281. classrefdef :
  282. begin
  283. { classrefdef inherits from pointerdef }
  284. hpd:=tabstractpointerdef(pd).pointertype.def;
  285. { still a forward def ? }
  286. if hpd.deftype=forwarddef then
  287. begin
  288. { try to resolve the forward }
  289. { get the correct position for it }
  290. stpos:=akttokenpos;
  291. akttokenpos:=tforwarddef(hpd).forwardpos;
  292. resolving_forward:=true;
  293. make_ref:=false;
  294. if not assigned(tforwarddef(hpd).tosymname) then
  295. internalerror(20021120);
  296. searchsym(tforwarddef(hpd).tosymname^,srsym,srsymtable);
  297. make_ref:=true;
  298. resolving_forward:=false;
  299. akttokenpos:=stpos;
  300. { we don't need the forwarddef anymore, dispose it }
  301. hpd.free;
  302. tabstractpointerdef(pd).pointertype.def:=nil; { if error occurs }
  303. { was a type sym found ? }
  304. if assigned(srsym) and
  305. (srsym.typ=typesym) then
  306. begin
  307. tabstractpointerdef(pd).pointertype.setsym(srsym);
  308. { avoid wrong unused warnings web bug 801 PM }
  309. inc(ttypesym(srsym).refs);
  310. { we need a class type for classrefdef }
  311. if (pd.deftype=classrefdef) and
  312. not(is_class(ttypesym(srsym).restype.def)) then
  313. Message1(type_e_class_type_expected,ttypesym(srsym).restype.def.typename);
  314. end
  315. else
  316. begin
  317. MessagePos1(tsym(p).fileinfo,sym_e_forward_type_not_resolved,tsym(p).realname);
  318. { try to recover }
  319. tabstractpointerdef(pd).pointertype:=generrortype;
  320. end;
  321. end;
  322. end;
  323. recorddef :
  324. trecorddef(pd).symtable.foreach_static(@resolve_type_forward,nil);
  325. objectdef :
  326. begin
  327. if not(m_fpc in aktmodeswitches) and
  328. (oo_is_forward in tobjectdef(pd).objectoptions) then
  329. begin
  330. { only give an error as the implementation may follow in an
  331. other type block which is allowed by FPC modes }
  332. MessagePos1(tsym(p).fileinfo,sym_e_forward_type_not_resolved,tsym(p).realname);
  333. end
  334. else
  335. begin
  336. { Check all fields of the object declaration, but don't
  337. check objectdefs in objects/records, because these
  338. can't exist (anonymous objects aren't allowed) }
  339. if not(tsym(p).owner.symtabletype in [objectsymtable,recordsymtable]) then
  340. tobjectdef(pd).symtable.foreach_static(@resolve_type_forward,nil);
  341. end;
  342. end;
  343. end;
  344. until not again;
  345. end;
  346. { reads a type declaration to the symbol table }
  347. procedure type_dec;
  348. function parse_generic_parameters:TFPObjectList;
  349. var
  350. generictype : ttypesym;
  351. begin
  352. result:=TFPObjectList.Create(false);
  353. repeat
  354. if token=_ID then
  355. begin
  356. generictype:=ttypesym.create(orgpattern,cundefinedtype);
  357. result.add(generictype);
  358. end;
  359. consume(_ID);
  360. until not try_to_consume(_COMMA) ;
  361. end;
  362. var
  363. typename,orgtypename : stringid;
  364. newtype : ttypesym;
  365. sym : tsym;
  366. srsymtable : tsymtable;
  367. tt : ttype;
  368. oldfilepos,
  369. defpos,storetokenpos : tfileposinfo;
  370. old_block_type : tblock_type;
  371. ch : tclassheader;
  372. isgeneric,
  373. isunique,
  374. istyperenaming : boolean;
  375. generictypelist : TFPObjectList;
  376. generictokenbuf : tdynamicarray;
  377. begin
  378. old_block_type:=block_type;
  379. block_type:=bt_type;
  380. consume(_TYPE);
  381. typecanbeforward:=true;
  382. repeat
  383. defpos:=akttokenpos;
  384. istyperenaming:=false;
  385. generictypelist:=nil;
  386. generictokenbuf:=nil;
  387. { generic declaration? }
  388. isgeneric:=try_to_consume(_GENERIC);
  389. typename:=pattern;
  390. orgtypename:=orgpattern;
  391. consume(_ID);
  392. { Generic type declaration? }
  393. if isgeneric then
  394. begin
  395. consume(_LSHARPBRACKET);
  396. generictypelist:=parse_generic_parameters;
  397. consume(_RSHARPBRACKET);
  398. end;
  399. consume(_EQUAL);
  400. { support 'ttype=type word' syntax }
  401. isunique:=try_to_consume(_TYPE);
  402. { MacPas object model is more like Delphi's than like TP's, but }
  403. { uses the object keyword instead of class }
  404. if (m_mac in aktmodeswitches) and
  405. (token = _OBJECT) then
  406. token := _CLASS;
  407. { Start recording a generic template }
  408. if assigned(generictypelist) then
  409. begin
  410. generictokenbuf:=tdynamicarray.create(256);
  411. current_scanner.startrecordtokens(generictokenbuf);
  412. end;
  413. { is the type already defined? }
  414. searchsym(typename,sym,srsymtable);
  415. newtype:=nil;
  416. { found a symbol with this name? }
  417. if assigned(sym) then
  418. begin
  419. if (sym.typ=typesym) then
  420. begin
  421. if ((token=_CLASS) or
  422. (token=_INTERFACE)) and
  423. (assigned(ttypesym(sym).restype.def)) and
  424. is_class_or_interface(ttypesym(sym).restype.def) and
  425. (oo_is_forward in tobjectdef(ttypesym(sym).restype.def).objectoptions) then
  426. begin
  427. { we can ignore the result }
  428. { the definition is modified }
  429. object_dec(orgtypename,nil,nil,tobjectdef(ttypesym(sym).restype.def));
  430. newtype:=ttypesym(sym);
  431. tt:=newtype.restype;
  432. end
  433. else
  434. message1(parser_h_type_redef,orgtypename);
  435. end;
  436. end;
  437. { no old type reused ? Then insert this new type }
  438. if not assigned(newtype) then
  439. begin
  440. { insert the new type first with an errordef, so that
  441. referencing the type before it's really set it
  442. will give an error (PFV) }
  443. tt:=generrortype;
  444. storetokenpos:=akttokenpos;
  445. newtype:=ttypesym.create(orgtypename,tt);
  446. symtablestack.top.insert(newtype);
  447. akttokenpos:=defpos;
  448. akttokenpos:=storetokenpos;
  449. { read the type definition }
  450. read_named_type(tt,orgtypename,nil,generictypelist,false);
  451. { update the definition of the type }
  452. newtype.restype:=tt;
  453. if assigned(tt.sym) then
  454. istyperenaming:=true
  455. else
  456. tt.sym:=newtype;
  457. if isunique and assigned(tt.def) then
  458. begin
  459. tt.setdef(tstoreddef(tt.def).getcopy);
  460. include(tt.def.defoptions,df_unique);
  461. newtype.restype:=tt;
  462. end;
  463. if assigned(tt.def) and not assigned(tt.def.typesym) then
  464. tt.def.typesym:=newtype;
  465. { KAZ: handle TGUID declaration in system unit }
  466. if (cs_compilesystem in aktmoduleswitches) and not assigned(rec_tguid) and
  467. (typename='TGUID') and { name: TGUID and size=16 bytes that is 128 bits }
  468. assigned(tt.def) and (tt.def.deftype=recorddef) and (tt.def.size=16) then
  469. rec_tguid:=trecorddef(tt.def);
  470. end;
  471. if assigned(tt.def) then
  472. begin
  473. case tt.def.deftype of
  474. pointerdef :
  475. begin
  476. consume(_SEMICOLON);
  477. if try_to_consume(_FAR) then
  478. begin
  479. tpointerdef(tt.def).is_far:=true;
  480. consume(_SEMICOLON);
  481. end;
  482. end;
  483. procvardef :
  484. begin
  485. { in case of type renaming, don't parse proc directives }
  486. if istyperenaming then
  487. consume(_SEMICOLON)
  488. else
  489. begin
  490. if not check_proc_directive(true) then
  491. consume(_SEMICOLON);
  492. parse_var_proc_directives(tsym(newtype));
  493. handle_calling_convention(tprocvardef(tt.def));
  494. end;
  495. end;
  496. objectdef,
  497. recorddef :
  498. begin
  499. try_consume_hintdirective(newtype.symoptions);
  500. consume(_SEMICOLON);
  501. end;
  502. else
  503. consume(_SEMICOLON);
  504. end;
  505. end;
  506. { Stop recording a generic template }
  507. if assigned(generictypelist) then
  508. begin
  509. current_scanner.stoprecordtokens;
  510. tstoreddef(tt.def).generictokenbuf:=generictokenbuf;
  511. { Generic is never a type renaming }
  512. tt.def.typesym:=newtype;
  513. end;
  514. { Write tables if we are the typesym that defines
  515. this type. This will not be done for simple type renamings }
  516. if (tt.def.typesym=newtype) then
  517. begin
  518. { file position }
  519. oldfilepos:=aktfilepos;
  520. aktfilepos:=newtype.fileinfo;
  521. { generate persistent init/final tables when it's declared in the interface so it can
  522. be reused in other used }
  523. if current_module.in_interface and
  524. ((is_class(tt.def) and
  525. tobjectdef(tt.def).members_need_inittable) or
  526. tt.def.needs_inittable) then
  527. generate_inittable(newtype);
  528. { for objects we should write the vmt and interfaces.
  529. This need to be done after the rtti has been written, because
  530. it can contain a reference to that data (PFV)
  531. This is not for forward classes }
  532. if (tt.def.deftype=objectdef) and
  533. (tt.def.owner.symtabletype in [staticsymtable,globalsymtable]) then
  534. with Tobjectdef(tt.def) do
  535. begin
  536. if not(oo_is_forward in objectoptions) then
  537. begin
  538. ch:=tclassheader.create(tobjectdef(tt.def));
  539. { generate and check virtual methods, must be done
  540. before RTTI is written }
  541. ch.genvmt;
  542. { Generate RTTI for class }
  543. generate_rtti(newtype);
  544. if is_interface(tobjectdef(tt.def)) then
  545. ch.writeinterfaceids;
  546. if (oo_has_vmt in objectoptions) then
  547. ch.writevmt;
  548. ch.free;
  549. end;
  550. end
  551. else
  552. begin
  553. { Always generate RTTI info for all types. This is to have typeinfo() return
  554. the same pointer }
  555. generate_rtti(newtype);
  556. end;
  557. aktfilepos:=oldfilepos;
  558. end;
  559. until token<>_ID;
  560. typecanbeforward:=false;
  561. symtablestack.top.foreach_static(@resolve_type_forward,nil);
  562. block_type:=old_block_type;
  563. end;
  564. procedure var_dec;
  565. { parses variable declarations and inserts them in }
  566. { the top symbol table of symtablestack }
  567. begin
  568. consume(_VAR);
  569. read_var_decls([]);
  570. end;
  571. procedure property_dec;
  572. var
  573. old_block_type : tblock_type;
  574. begin
  575. consume(_PROPERTY);
  576. if not(symtablestack.top.symtabletype in [staticsymtable,globalsymtable]) then
  577. message(parser_e_resourcestring_only_sg);
  578. old_block_type:=block_type;
  579. block_type:=bt_const;
  580. repeat
  581. read_property_dec(nil);
  582. consume(_SEMICOLON);
  583. until token<>_ID;
  584. block_type:=old_block_type;
  585. end;
  586. procedure threadvar_dec;
  587. { parses thread variable declarations and inserts them in }
  588. { the top symbol table of symtablestack }
  589. begin
  590. consume(_THREADVAR);
  591. if not(symtablestack.top.symtabletype in [staticsymtable,globalsymtable]) then
  592. message(parser_e_threadvars_only_sg);
  593. read_var_decls([vd_threadvar]);
  594. end;
  595. procedure resourcestring_dec;
  596. var
  597. orgname : stringid;
  598. p : tnode;
  599. dummysymoptions : tsymoptions;
  600. storetokenpos,filepos : tfileposinfo;
  601. old_block_type : tblock_type;
  602. sp : pchar;
  603. sym : tsym;
  604. begin
  605. consume(_RESOURCESTRING);
  606. if not(symtablestack.top.symtabletype in [staticsymtable,globalsymtable]) then
  607. message(parser_e_resourcestring_only_sg);
  608. old_block_type:=block_type;
  609. block_type:=bt_const;
  610. repeat
  611. orgname:=orgpattern;
  612. filepos:=akttokenpos;
  613. consume(_ID);
  614. case token of
  615. _EQUAL:
  616. begin
  617. consume(_EQUAL);
  618. p:=comp_expr(true);
  619. storetokenpos:=akttokenpos;
  620. akttokenpos:=filepos;
  621. sym:=nil;
  622. case p.nodetype of
  623. ordconstn:
  624. begin
  625. if is_constcharnode(p) then
  626. begin
  627. getmem(sp,2);
  628. sp[0]:=chr(tordconstnode(p).value);
  629. sp[1]:=#0;
  630. sym:=tconstsym.create_string(orgname,constresourcestring,sp,1);
  631. end
  632. else
  633. Message(parser_e_illegal_expression);
  634. end;
  635. stringconstn:
  636. with Tstringconstnode(p) do
  637. begin
  638. getmem(sp,len+1);
  639. move(value_str^,sp^,len+1);
  640. sym:=tconstsym.create_string(orgname,constresourcestring,sp,len);
  641. end;
  642. else
  643. Message(parser_e_illegal_expression);
  644. end;
  645. akttokenpos:=storetokenpos;
  646. { Support hint directives }
  647. dummysymoptions:=[];
  648. try_consume_hintdirective(dummysymoptions);
  649. if assigned(sym) then
  650. begin
  651. sym.symoptions:=sym.symoptions+dummysymoptions;
  652. symtablestack.top.insert(sym);
  653. end;
  654. consume(_SEMICOLON);
  655. p.free;
  656. end;
  657. else consume(_EQUAL);
  658. end;
  659. until token<>_ID;
  660. block_type:=old_block_type;
  661. end;
  662. end.