pinline.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generates nodes for routines that need compiler support
  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 pinline;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. symtype,
  22. node,
  23. globals;
  24. function new_dispose_statement(is_new:boolean) : tnode;
  25. function new_function : tnode;
  26. function inline_setlength : tnode;
  27. function inline_setstring : tnode;
  28. function inline_initialize : tnode;
  29. function inline_finalize : tnode;
  30. function inline_copy : tnode;
  31. function inline_insert : tnode;
  32. function inline_delete : tnode;
  33. function inline_concat : tnode;
  34. implementation
  35. uses
  36. { global }
  37. globtype,tokens,verbose,constexp,
  38. systems,compinnr,
  39. { symtable }
  40. symbase,symconst,symdef,symsym,symtable,defutil,
  41. { pass 1 }
  42. pass_1,htypechk,
  43. ncal,nmem,ncnv,ninl,ncon,nld,nbas,ngenutil,nutils,
  44. { parser }
  45. scanner,
  46. pbase,pexpr;
  47. function new_dispose_statement(is_new:boolean) : tnode;
  48. var
  49. newstatement : tstatementnode;
  50. temp : ttempcreatenode;
  51. para : tcallparanode;
  52. p,p2 : tnode;
  53. again : boolean; { dummy for do_proc_call }
  54. destructorname : TIDString;
  55. sym : tsym;
  56. classh : tobjectdef;
  57. callflag : tcallnodeflag;
  58. destructorpos,
  59. storepos : tfileposinfo;
  60. variantdesc : pvariantrecdesc;
  61. found : boolean;
  62. j,i : longint;
  63. variantselectsymbol : tfieldvarsym;
  64. begin
  65. if target_info.system in systems_managed_vm then
  66. message(parser_e_feature_unsupported_for_vm);
  67. consume(_LKLAMMER);
  68. p:=comp_expr([ef_accept_equal]);
  69. { calc return type }
  70. if is_new then
  71. begin
  72. set_varstate(p,vs_written,[]);
  73. valid_for_var(p,true);
  74. end
  75. else
  76. set_varstate(p,vs_readwritten,[vsf_must_be_valid]);
  77. if (m_mac in current_settings.modeswitches) and
  78. is_class(p.resultdef) then
  79. begin
  80. classh:=tobjectdef(p.resultdef);
  81. { make sure we call ObjPas.TObject.Create/Free and not a random }
  82. { create/free method in a macpas descendent object (since those }
  83. { are not supposed to be called automatically when you call }
  84. { new/dispose) }
  85. while assigned(classh.childof) do
  86. classh := classh.childof;
  87. if is_new then
  88. begin
  89. sym:=search_struct_member(classh,'CREATE');
  90. p2 := cloadvmtaddrnode.create(ctypenode.create(p.resultdef));
  91. end
  92. else
  93. begin
  94. sym:=search_struct_member(classh,'FREE');
  95. p2 := p;
  96. end;
  97. if not(assigned(sym)) then
  98. begin
  99. p.free;
  100. if is_new then
  101. p2.free;
  102. new_dispose_statement := cerrornode.create;
  103. consume_all_until(_RKLAMMER);
  104. consume(_RKLAMMER);
  105. exit;
  106. end;
  107. do_member_read(classh,false,sym,p2,again,[],nil);
  108. { we need the real called method }
  109. do_typecheckpass(p2);
  110. if (p2.nodetype=calln) and
  111. assigned(tcallnode(p2).procdefinition) then
  112. begin
  113. if is_new then
  114. begin
  115. if (tcallnode(p2).procdefinition.proctypeoption<>potype_constructor) then
  116. Message(parser_e_expr_have_to_be_constructor_call);
  117. p2.resultdef:=p.resultdef;
  118. p2:=cassignmentnode.create(p,p2);
  119. typecheckpass(p2);
  120. end
  121. else
  122. begin
  123. { Free is not a destructor
  124. if (tcallnode(p2).procdefinition.proctypeoption<>potype_destructor) then
  125. Message(parser_e_expr_have_to_be_destructor_call);
  126. }
  127. end
  128. end
  129. else
  130. internalerror(2005061202);
  131. new_dispose_statement := p2;
  132. end
  133. { constructor,destructor specified }
  134. else if (([m_mac,m_iso,m_extpas]*current_settings.modeswitches)=[]) and
  135. try_to_consume(_COMMA) then
  136. begin
  137. { extended syntax of new and dispose }
  138. { function styled new is handled in factor }
  139. { destructors have no parameters }
  140. destructorname:=pattern;
  141. destructorpos:=current_tokenpos;
  142. consume(_ID);
  143. if is_typeparam(p.resultdef) then
  144. begin
  145. p.free;
  146. p:=factor(false,[]);
  147. p.free;
  148. consume(_RKLAMMER);
  149. new_dispose_statement:=cnothingnode.create;
  150. exit;
  151. end;
  152. if (p.resultdef.typ<>pointerdef) then
  153. begin
  154. Message1(type_e_pointer_type_expected,p.resultdef.typename);
  155. p.free;
  156. p:=factor(false,[]);
  157. p.free;
  158. consume(_RKLAMMER);
  159. new_dispose_statement:=cerrornode.create;
  160. exit;
  161. end;
  162. { first parameter must be an object or class }
  163. if tpointerdef(p.resultdef).pointeddef.typ<>objectdef then
  164. begin
  165. Message(parser_e_pointer_to_class_expected);
  166. p.free;
  167. new_dispose_statement:=factor(false,[]);
  168. consume_all_until(_RKLAMMER);
  169. consume(_RKLAMMER);
  170. exit;
  171. end;
  172. { check, if the first parameter is a pointer to a _class_ }
  173. classh:=tobjectdef(tpointerdef(p.resultdef).pointeddef);
  174. if is_class(classh) then
  175. begin
  176. Message(parser_e_no_new_or_dispose_for_classes);
  177. new_dispose_statement:=factor(false,[]);
  178. consume_all_until(_RKLAMMER);
  179. consume(_RKLAMMER);
  180. exit;
  181. end;
  182. { search cons-/destructor, also in parent classes }
  183. storepos:=current_tokenpos;
  184. current_tokenpos:=destructorpos;
  185. sym:=search_struct_member(classh,destructorname);
  186. current_tokenpos:=storepos;
  187. { the second parameter of new/dispose must be a call }
  188. { to a cons-/destructor }
  189. if (not assigned(sym)) or (sym.typ<>procsym) then
  190. begin
  191. if is_new then
  192. Message(parser_e_expr_have_to_be_constructor_call)
  193. else
  194. Message(parser_e_expr_have_to_be_destructor_call);
  195. p.free;
  196. new_dispose_statement:=cerrornode.create;
  197. end
  198. else
  199. begin
  200. { For new(var,constructor) we need to take a copy because
  201. p is also used in the assignmentn below }
  202. if is_new then
  203. begin
  204. p2:=cderefnode.create(p.getcopy);
  205. include(p2.flags,nf_no_checkpointer);
  206. end
  207. else
  208. p2:=cderefnode.create(p);
  209. do_typecheckpass(p2);
  210. if is_new then
  211. callflag:=cnf_new_call
  212. else
  213. callflag:=cnf_dispose_call;
  214. if is_new then
  215. do_member_read(classh,false,sym,p2,again,[callflag],nil)
  216. else
  217. begin
  218. if not(m_fpc in current_settings.modeswitches) then
  219. do_member_read(classh,false,sym,p2,again,[callflag],nil)
  220. else
  221. begin
  222. p2:=ccallnode.create(nil,tprocsym(sym),sym.owner,p2,[callflag],nil);
  223. { support dispose(p,done()); }
  224. if try_to_consume(_LKLAMMER) then
  225. begin
  226. if not try_to_consume(_RKLAMMER) then
  227. begin
  228. Message(parser_e_no_paras_for_destructor);
  229. consume_all_until(_RKLAMMER);
  230. consume(_RKLAMMER);
  231. end;
  232. end;
  233. end;
  234. end;
  235. { we need the real called method }
  236. do_typecheckpass(p2);
  237. if (p2.nodetype=calln) and
  238. assigned(tcallnode(p2).procdefinition) then
  239. begin
  240. if is_new then
  241. begin
  242. if (tcallnode(p2).procdefinition.proctypeoption<>potype_constructor) then
  243. Message(parser_e_expr_have_to_be_constructor_call);
  244. p2.resultdef:=p.resultdef;
  245. p2:=cassignmentnode.create(p,p2);
  246. end
  247. else
  248. begin
  249. if (tcallnode(p2).procdefinition.proctypeoption<>potype_destructor) then
  250. Message(parser_e_expr_have_to_be_destructor_call);
  251. end;
  252. end
  253. else
  254. begin
  255. if is_new then
  256. CGMessage(parser_e_expr_have_to_be_constructor_call)
  257. else
  258. CGMessage(parser_e_expr_have_to_be_destructor_call);
  259. end;
  260. result:=p2;
  261. end;
  262. end
  263. else
  264. begin
  265. if (p.resultdef.typ<>pointerdef) then
  266. Begin
  267. if is_typeparam(p.resultdef) then
  268. begin
  269. p.free;
  270. consume(_RKLAMMER);
  271. new_dispose_statement:=cnothingnode.create;
  272. exit;
  273. end
  274. else
  275. begin
  276. Message1(type_e_pointer_type_expected,p.resultdef.typename);
  277. new_dispose_statement:=cerrornode.create;
  278. end;
  279. end
  280. else
  281. begin
  282. if (tpointerdef(p.resultdef).pointeddef.typ=objectdef) and
  283. (oo_has_vmt in tobjectdef(tpointerdef(p.resultdef).pointeddef).objectoptions) then
  284. Message(parser_w_use_extended_syntax_for_objects);
  285. if (tpointerdef(p.resultdef).pointeddef.typ=orddef) and
  286. (torddef(tpointerdef(p.resultdef).pointeddef).ordtype=uvoid) then
  287. begin
  288. if (m_tp7 in current_settings.modeswitches) or
  289. (m_delphi in current_settings.modeswitches) then
  290. Message(parser_w_no_new_dispose_on_void_pointers)
  291. else
  292. Message(parser_e_no_new_dispose_on_void_pointers);
  293. end;
  294. { create statements with call to getmem+initialize or
  295. finalize+freemem }
  296. new_dispose_statement:=internalstatements(newstatement);
  297. if is_new then
  298. begin
  299. { create temp for result }
  300. temp := ctempcreatenode.create(p.resultdef,p.resultdef.size,tt_persistent,true);
  301. addstatement(newstatement,temp);
  302. { create call to fpc_getmem }
  303. para := ccallparanode.create(cordconstnode.create
  304. (tpointerdef(p.resultdef).pointeddef.size,s32inttype,true),nil);
  305. addstatement(newstatement,cassignmentnode.create(
  306. ctemprefnode.create(temp),
  307. ccallnode.createintern('fpc_getmem',para)));
  308. { create call to fpc_initialize }
  309. if is_managed_type(tpointerdef(p.resultdef).pointeddef) or
  310. ((m_isolike_io in current_settings.modeswitches) and (tpointerdef(p.resultdef).pointeddef.typ=filedef)) then
  311. addstatement(newstatement,cnodeutils.initialize_data_node(cderefnode.create(ctemprefnode.create(temp)),false));
  312. { copy the temp to the destination }
  313. addstatement(newstatement,cassignmentnode.create(
  314. p,
  315. ctemprefnode.create(temp)));
  316. if (([m_iso,m_extpas]*current_settings.modeswitches)<>[]) and (is_record(tpointerdef(p.resultdef).pointeddef)) then
  317. begin
  318. variantdesc:=trecorddef(tpointerdef(p.resultdef).pointeddef).variantrecdesc;
  319. while (token=_COMMA) and assigned(variantdesc) do
  320. begin
  321. consume(_COMMA);
  322. p2:=factor(false,[]);
  323. do_typecheckpass(p2);
  324. if p2.nodetype=ordconstn then
  325. begin
  326. found:=false;
  327. { we do not have dynamic dfa, so avoid warning on variantselectsymbol below }
  328. variantselectsymbol:=nil;
  329. for i:=0 to high(variantdesc^.branches) do
  330. begin
  331. for j:=0 to high(variantdesc^.branches[i].values) do
  332. if variantdesc^.branches[i].values[j]=tordconstnode(p2).value then
  333. begin
  334. found:=true;
  335. variantselectsymbol:=tfieldvarsym(variantdesc^.variantselector);
  336. variantdesc:=variantdesc^.branches[i].nestedvariant;
  337. break;
  338. end;
  339. if found then
  340. break;
  341. end;
  342. if found then
  343. begin
  344. { if no tag-field is given, do not create an assignment statement for it }
  345. if assigned(variantselectsymbol) then
  346. { setup variant selector }
  347. addstatement(newstatement,cassignmentnode.create(
  348. csubscriptnode.create(variantselectsymbol,
  349. cderefnode.create(ctemprefnode.create(temp))),
  350. p2));
  351. end
  352. else
  353. Message(parser_e_illegal_expression);
  354. end
  355. else
  356. Message(parser_e_illegal_expression);
  357. end;
  358. end;
  359. { release temp }
  360. addstatement(newstatement,ctempdeletenode.create(temp));
  361. end
  362. else
  363. begin
  364. temp:=nil;
  365. { create call to fpc_finalize }
  366. if is_managed_type(tpointerdef(p.resultdef).pointeddef) then
  367. if might_have_sideeffects(p) then
  368. begin
  369. { ensure that p gets evaluated only once, in case it is e.g. a call }
  370. temp:=ctempcreatenode.create_value(p.resultdef,p.resultdef.size,tt_persistent,true,p);
  371. addstatement(newstatement,temp);
  372. addstatement(newstatement,cnodeutils.finalize_data_node(cderefnode.create(ctemprefnode.create(temp))));
  373. end
  374. else
  375. addstatement(newstatement,cnodeutils.finalize_data_node(cderefnode.create(p.getcopy)));
  376. { create call to fpc_freemem }
  377. if not assigned(temp) then
  378. para := ccallparanode.create(p,nil)
  379. else
  380. para := ccallparanode.create(ctemprefnode.create(temp),nil);
  381. addstatement(newstatement,ccallnode.createintern('fpc_freemem',para));
  382. if assigned(temp) then
  383. addstatement(newstatement,ctempdeletenode.create(temp));
  384. end;
  385. end;
  386. end;
  387. consume(_RKLAMMER);
  388. end;
  389. function new_function : tnode;
  390. var
  391. p1,p2 : tnode;
  392. classh : tobjectdef;
  393. srsym : tsym;
  394. srsymtable : TSymtable;
  395. again : boolean; { dummy for do_proc_call }
  396. begin
  397. if target_info.system in systems_managed_vm then
  398. message(parser_e_feature_unsupported_for_vm);
  399. consume(_LKLAMMER);
  400. p1:=factor(false,[]);
  401. if p1.nodetype<>typen then
  402. begin
  403. Message(type_e_type_id_expected);
  404. consume_all_until(_RKLAMMER);
  405. consume(_RKLAMMER);
  406. p1.destroy;
  407. new_function:=cerrornode.create;
  408. exit;
  409. end;
  410. if (p1.resultdef.typ<>pointerdef) then
  411. begin
  412. Message1(type_e_pointer_type_expected,p1.resultdef.typename);
  413. consume_all_until(_RKLAMMER);
  414. consume(_RKLAMMER);
  415. p1.destroy;
  416. new_function:=cerrornode.create;
  417. exit;
  418. end;
  419. if try_to_consume(_RKLAMMER) then
  420. begin
  421. if (tpointerdef(p1.resultdef).pointeddef.typ=objectdef) and
  422. (oo_has_vmt in tobjectdef(tpointerdef(p1.resultdef).pointeddef).objectoptions) then
  423. Message(parser_w_use_extended_syntax_for_objects);
  424. if p1.nodetype=typen then
  425. ttypenode(p1).allowed:=true;
  426. p1:=cinlinenode.create(in_new_x,false,p1);
  427. end
  428. else
  429. begin
  430. consume(_COMMA);
  431. if tpointerdef(p1.resultdef).pointeddef.typ<>objectdef then
  432. begin
  433. Message(parser_e_pointer_to_class_expected);
  434. consume_all_until(_RKLAMMER);
  435. consume(_RKLAMMER);
  436. p1.destroy;
  437. new_function:=cerrornode.create;
  438. exit;
  439. end;
  440. classh:=tobjectdef(tpointerdef(p1.resultdef).pointeddef);
  441. { use the objectdef for loading the VMT }
  442. p2:=p1;
  443. p1:=ctypenode.create(tpointerdef(p1.resultdef).pointeddef);
  444. do_typecheckpass(p1);
  445. { search the constructor also in the symbol tables of
  446. the parents }
  447. afterassignment:=false;
  448. searchsym_in_class(classh,classh,pattern,srsym,srsymtable,[ssf_search_helper]);
  449. consume(_ID);
  450. do_member_read(classh,false,srsym,p1,again,[cnf_new_call],nil);
  451. { we need to know which procedure is called }
  452. do_typecheckpass(p1);
  453. if not(
  454. (p1.nodetype=calln) and
  455. assigned(tcallnode(p1).procdefinition) and
  456. (tcallnode(p1).procdefinition.proctypeoption=potype_constructor)
  457. ) then
  458. Message(parser_e_expr_have_to_be_constructor_call);
  459. { constructors return boolean, update resultdef to return
  460. the pointer to the object }
  461. p1.resultdef:=p2.resultdef;
  462. p2.free;
  463. consume(_RKLAMMER);
  464. end;
  465. new_function:=p1;
  466. end;
  467. function inline_setlength : tnode;
  468. var
  469. paras: tnode;
  470. begin
  471. consume(_LKLAMMER);
  472. paras:=parse_paras(false,false,_RKLAMMER);
  473. consume(_RKLAMMER);
  474. if not assigned(paras) then
  475. begin
  476. result:=cerrornode.create;
  477. CGMessage1(parser_e_wrong_parameter_size,'SetLength');
  478. exit;
  479. end;
  480. result:=cinlinenode.create(in_setlength_x,false,paras);
  481. end;
  482. function inline_setstring : tnode;
  483. var
  484. paras, strpara, pcharpara: tnode;
  485. procname: string;
  486. cp: tstringencoding;
  487. begin
  488. consume(_LKLAMMER);
  489. paras:=parse_paras(false,false,_RKLAMMER);
  490. consume(_RKLAMMER);
  491. procname:='';
  492. if assigned(paras) and
  493. assigned(tcallparanode(paras).right) and
  494. assigned(tcallparanode(tcallparanode(paras).right).right) then
  495. begin
  496. do_typecheckpass(tcallparanode(tcallparanode(paras).right).left);
  497. do_typecheckpass(tcallparanode(tcallparanode(tcallparanode(paras).right).right).left);
  498. pcharpara:=tcallparanode(tcallparanode(paras).right).left;
  499. strpara:=tcallparanode(tcallparanode(tcallparanode(paras).right).right).left;
  500. if strpara.resultdef.typ=stringdef then
  501. begin
  502. { if there are three parameters and the first parameter
  503. ( = paras.right.right) is an ansistring, add a codepage
  504. parameter }
  505. if is_ansistring(strpara.resultdef) then
  506. begin
  507. cp:=tstringdef(strpara.resultdef).encoding;
  508. if (cp=globals.CP_NONE) then
  509. cp:=0;
  510. paras:=ccallparanode.create(genintconstnode(cp),paras);
  511. end;
  512. procname:='fpc_setstring_'+tstringdef(strpara.resultdef).stringtypname;
  513. { decide which version to call based on the second parameter }
  514. if not is_shortstring(strpara.resultdef) then
  515. if is_pwidechar(pcharpara.resultdef) or
  516. is_widechar(pcharpara.resultdef) or
  517. ((pcharpara.resultdef.typ=arraydef) and
  518. is_widechar(tarraydef(pcharpara.resultdef).elementdef)) then
  519. procname:=procname+'_pwidechar'
  520. else
  521. procname:=procname+'_pansichar';
  522. end;
  523. end;
  524. { default version (for error message) in case of missing or wrong
  525. parameters }
  526. if procname='' then
  527. if m_default_unicodestring in current_settings.modeswitches then
  528. procname:='fpc_setstring_unicodestr_pwidechar'
  529. else if m_default_ansistring in current_settings.modeswitches then
  530. procname:='fpc_setstring_ansistr_pansichar'
  531. else
  532. procname:='fpc_setstring_shortstr';
  533. result:=ccallnode.createintern(procname,paras)
  534. end;
  535. function inline_initfinal(isinit: boolean): tnode;
  536. var
  537. newblock,
  538. paras : tnode;
  539. npara,
  540. destppn,
  541. ppn : tcallparanode;
  542. begin
  543. { for easy exiting if something goes wrong }
  544. result := cerrornode.create;
  545. consume(_LKLAMMER);
  546. paras:=parse_paras(false,false,_RKLAMMER);
  547. consume(_RKLAMMER);
  548. ppn:=tcallparanode(paras);
  549. if not assigned(paras) or
  550. (assigned(ppn.right) and
  551. assigned(tcallparanode(ppn.right).right)) then
  552. begin
  553. if isinit then
  554. CGMessage1(parser_e_wrong_parameter_size,'Initialize')
  555. else
  556. CGMessage1(parser_e_wrong_parameter_size,'Finalize');
  557. exit;
  558. end;
  559. { 2 arguments? }
  560. if assigned(ppn.right) then
  561. begin
  562. destppn:=tcallparanode(ppn.right);
  563. { create call to fpc_initialize/finalize_array }
  564. npara:=ccallparanode.create(ctypeconvnode.create
  565. (ppn.left,s32inttype),
  566. ccallparanode.create(caddrnode.create_internal
  567. (crttinode.create(tstoreddef(destppn.left.resultdef),initrtti,rdt_normal)),
  568. ccallparanode.create(caddrnode.create_internal
  569. (destppn.left),nil)));
  570. if isinit then
  571. newblock:=ccallnode.createintern('fpc_initialize_array',npara)
  572. else
  573. newblock:=ccallnode.createintern('fpc_finalize_array',npara);
  574. destppn.left:=nil;
  575. end
  576. else
  577. begin
  578. if isinit then
  579. newblock:=cnodeutils.initialize_data_node(ppn.left,true)
  580. else
  581. newblock:=cnodeutils.finalize_data_node(ppn.left);
  582. end;
  583. ppn.left:=nil;
  584. paras.free;
  585. result.free;
  586. result:=newblock;
  587. end;
  588. function inline_initialize : tnode;
  589. begin
  590. result:=inline_initfinal(true);
  591. end;
  592. function inline_finalize : tnode;
  593. begin
  594. result:=inline_initfinal(false);
  595. end;
  596. function inline_copy_insert_delete(nr:tinlinenumber;name:string;checkempty:boolean) : tnode;
  597. var
  598. paras : tnode;
  599. { for easy exiting if something goes wrong }
  600. begin
  601. result := cerrornode.create;
  602. consume(_LKLAMMER);
  603. paras:=parse_paras(false,false,_RKLAMMER);
  604. consume(_RKLAMMER);
  605. if not assigned(paras) and checkempty then
  606. begin
  607. CGMessage1(parser_e_wrong_parameter_size,name);
  608. exit;
  609. end;
  610. result.free;
  611. result:=cinlinenode.create(nr,false,paras);
  612. end;
  613. function inline_copy: tnode;
  614. begin
  615. result:=inline_copy_insert_delete(in_copy_x,'Copy',true);
  616. end;
  617. function inline_insert: tnode;
  618. begin
  619. result:=inline_copy_insert_delete(in_insert_x_y_z,'Insert',false);
  620. end;
  621. function inline_delete: tnode;
  622. begin
  623. result:=inline_copy_insert_delete(in_delete_x_y_z,'Delete',false);
  624. end;
  625. function inline_concat: tnode;
  626. begin
  627. result:=inline_copy_insert_delete(in_concat_x,'Concat',false);
  628. end;
  629. end.