pinline.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generates nodes for routines that need compiler support
  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 pinline;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. symtype,
  23. node,
  24. globals,
  25. cpuinfo;
  26. function new_dispose_statement(is_new:boolean) : tnode;
  27. function new_function : tnode;
  28. function inline_setlength : tnode;
  29. function inline_finalize : tnode;
  30. function inline_copy : tnode;
  31. implementation
  32. uses
  33. {$ifdef delphi}
  34. SysUtils,
  35. {$endif}
  36. { common }
  37. cutils,
  38. { global }
  39. globtype,tokens,verbose,
  40. systems,
  41. { symtable }
  42. symconst,symdef,symsym,symtable,defutil,
  43. { pass 1 }
  44. pass_1,htypechk,
  45. nmat,nadd,ncal,nmem,nset,ncnv,ninl,ncon,nld,nflw,nbas,nutils,
  46. { parser }
  47. scanner,
  48. pbase,pexpr,
  49. { codegen }
  50. tgobj,cgbase
  51. ;
  52. function new_dispose_statement(is_new:boolean) : tnode;
  53. var
  54. newstatement : tstatementnode;
  55. temp : ttempcreatenode;
  56. para : tcallparanode;
  57. p,p2 : tnode;
  58. again : boolean; { dummy for do_proc_call }
  59. destructorname : stringid;
  60. sym : tsym;
  61. classh : tobjectdef;
  62. callflag : tnodeflag;
  63. destructorpos,
  64. storepos : tfileposinfo;
  65. begin
  66. consume(_LKLAMMER);
  67. p:=comp_expr(true);
  68. { calc return type }
  69. set_varstate(p,(not is_new));
  70. { constructor,destructor specified }
  71. if try_to_consume(_COMMA) then
  72. begin
  73. { extended syntax of new and dispose }
  74. { function styled new is handled in factor }
  75. { destructors have no parameters }
  76. destructorname:=pattern;
  77. destructorpos:=akttokenpos;
  78. consume(_ID);
  79. if (p.resulttype.def.deftype<>pointerdef) then
  80. begin
  81. Message1(type_e_pointer_type_expected,p.resulttype.def.typename);
  82. p.free;
  83. p:=factor(false);
  84. p.free;
  85. consume(_RKLAMMER);
  86. new_dispose_statement:=cerrornode.create;
  87. exit;
  88. end;
  89. { first parameter must be an object or class }
  90. if tpointerdef(p.resulttype.def).pointertype.def.deftype<>objectdef then
  91. begin
  92. Message(parser_e_pointer_to_class_expected);
  93. p.free;
  94. new_dispose_statement:=factor(false);
  95. consume_all_until(_RKLAMMER);
  96. consume(_RKLAMMER);
  97. exit;
  98. end;
  99. { check, if the first parameter is a pointer to a _class_ }
  100. classh:=tobjectdef(tpointerdef(p.resulttype.def).pointertype.def);
  101. if is_class(classh) then
  102. begin
  103. Message(parser_e_no_new_or_dispose_for_classes);
  104. new_dispose_statement:=factor(false);
  105. consume_all_until(_RKLAMMER);
  106. consume(_RKLAMMER);
  107. exit;
  108. end;
  109. { search cons-/destructor, also in parent classes }
  110. storepos:=akttokenpos;
  111. akttokenpos:=destructorpos;
  112. sym:=search_class_member(classh,destructorname);
  113. akttokenpos:=storepos;
  114. { the second parameter of new/dispose must be a call }
  115. { to a cons-/destructor }
  116. if (not assigned(sym)) or (sym.typ<>procsym) then
  117. begin
  118. if is_new then
  119. Message(parser_e_expr_have_to_be_constructor_call)
  120. else
  121. Message(parser_e_expr_have_to_be_destructor_call);
  122. p.free;
  123. new_dispose_statement:=cerrornode.create;
  124. end
  125. else
  126. begin
  127. p2:=cderefnode.create(p.getcopy);
  128. do_resulttypepass(p2);
  129. if is_new then
  130. callflag:=nf_new_call
  131. else
  132. callflag:=nf_dispose_call;
  133. if is_new then
  134. do_member_read(false,sym,p2,again,[callflag])
  135. else
  136. begin
  137. if not(m_fpc in aktmodeswitches) then
  138. do_member_read(false,sym,p2,again,[callflag])
  139. else
  140. begin
  141. p2:=ccallnode.create(nil,tprocsym(sym),sym.owner,p2);
  142. if is_new then
  143. include(p2.flags,nf_new_call)
  144. else
  145. include(p2.flags,nf_dispose_call);
  146. { support dispose(p,done()); }
  147. if try_to_consume(_LKLAMMER) then
  148. begin
  149. if not try_to_consume(_RKLAMMER) then
  150. begin
  151. Message(parser_e_no_paras_for_destructor);
  152. consume_all_until(_RKLAMMER);
  153. consume(_RKLAMMER);
  154. end;
  155. end;
  156. end;
  157. end;
  158. { we need the real called method }
  159. do_resulttypepass(p2);
  160. if p2.nodetype<>calln then
  161. begin
  162. if is_new then
  163. CGMessage(parser_e_expr_have_to_be_constructor_call)
  164. else
  165. CGMessage(parser_e_expr_have_to_be_destructor_call);
  166. end;
  167. if not codegenerror then
  168. begin
  169. if is_new then
  170. begin
  171. if (tcallnode(p2).procdefinition.proctypeoption<>potype_constructor) then
  172. Message(parser_e_expr_have_to_be_constructor_call);
  173. p2.resulttype:=p.resulttype;
  174. p2:=cassignmentnode.create(p,p2);
  175. end
  176. else
  177. begin
  178. if (tcallnode(p2).procdefinition.proctypeoption<>potype_destructor) then
  179. Message(parser_e_expr_have_to_be_destructor_call);
  180. end;
  181. end;
  182. new_dispose_statement:=p2;
  183. end;
  184. end
  185. else
  186. begin
  187. if (p.resulttype.def.deftype<>pointerdef) then
  188. Begin
  189. Message1(type_e_pointer_type_expected,p.resulttype.def.typename);
  190. new_dispose_statement:=cerrornode.create;
  191. end
  192. else
  193. begin
  194. if (tpointerdef(p.resulttype.def).pointertype.def.deftype=objectdef) and
  195. (oo_has_vmt in tobjectdef(tpointerdef(p.resulttype.def).pointertype.def).objectoptions) then
  196. Message(parser_w_use_extended_syntax_for_objects);
  197. if (tpointerdef(p.resulttype.def).pointertype.def.deftype=orddef) and
  198. (torddef(tpointerdef(p.resulttype.def).pointertype.def).typ=uvoid) then
  199. begin
  200. if (m_tp7 in aktmodeswitches) or
  201. (m_delphi in aktmodeswitches) then
  202. Message(parser_w_no_new_dispose_on_void_pointers)
  203. else
  204. Message(parser_e_no_new_dispose_on_void_pointers);
  205. end;
  206. { create statements with call to getmem+initialize or
  207. finalize+freemem }
  208. new_dispose_statement:=internalstatements(newstatement,true);
  209. if is_new then
  210. begin
  211. { create temp for result }
  212. temp := ctempcreatenode.create(p.resulttype,p.resulttype.def.size,tt_persistent);
  213. addstatement(newstatement,temp);
  214. { create call to fpc_getmem }
  215. para := ccallparanode.create(cordconstnode.create
  216. (tpointerdef(p.resulttype.def).pointertype.def.size,s32bittype,true),nil);
  217. addstatement(newstatement,cassignmentnode.create(
  218. ctemprefnode.create(temp),
  219. ccallnode.createintern('fpc_getmem',para)));
  220. { create call to fpc_initialize }
  221. if tpointerdef(p.resulttype.def).pointertype.def.needs_inittable then
  222. addstatement(newstatement,initialize_data_node(ctemprefnode.create(temp)));
  223. { copy the temp to the destination }
  224. addstatement(newstatement,cassignmentnode.create(
  225. p,
  226. ctemprefnode.create(temp)));
  227. { release temp }
  228. addstatement(newstatement,ctempdeletenode.create(temp));
  229. end
  230. else
  231. begin
  232. { create call to fpc_finalize }
  233. if tpointerdef(p.resulttype.def).pointertype.def.needs_inittable then
  234. addstatement(newstatement,finalize_data_node(cderefnode.create(p.getcopy)));
  235. { create call to fpc_freemem }
  236. para := ccallparanode.create(p,nil);
  237. addstatement(newstatement,ccallnode.createintern('fpc_freemem',para));
  238. end;
  239. end;
  240. end;
  241. consume(_RKLAMMER);
  242. end;
  243. function new_function : tnode;
  244. var
  245. newstatement : tstatementnode;
  246. newblock : tblocknode;
  247. temp : ttempcreatenode;
  248. para : tcallparanode;
  249. p1,p2 : tnode;
  250. classh : tobjectdef;
  251. sym : tsym;
  252. again : boolean; { dummy for do_proc_call }
  253. begin
  254. consume(_LKLAMMER);
  255. p1:=factor(false);
  256. if p1.nodetype<>typen then
  257. begin
  258. Message(type_e_type_id_expected);
  259. consume_all_until(_RKLAMMER);
  260. consume(_RKLAMMER);
  261. p1.destroy;
  262. new_function:=cerrornode.create;
  263. exit;
  264. end;
  265. if (p1.resulttype.def.deftype<>pointerdef) then
  266. begin
  267. Message1(type_e_pointer_type_expected,p1.resulttype.def.typename);
  268. consume_all_until(_RKLAMMER);
  269. consume(_RKLAMMER);
  270. p1.destroy;
  271. new_function:=cerrornode.create;
  272. exit;
  273. end;
  274. if try_to_consume(_RKLAMMER) then
  275. begin
  276. if (tpointerdef(p1.resulttype.def).pointertype.def.deftype=objectdef) and
  277. (oo_has_vmt in tobjectdef(tpointerdef(p1.resulttype.def).pointertype.def).objectoptions) then
  278. Message(parser_w_use_extended_syntax_for_objects);
  279. { create statements with call to getmem+initialize }
  280. newblock:=internalstatements(newstatement,true);
  281. { create temp for result }
  282. temp := ctempcreatenode.create(p1.resulttype,p1.resulttype.def.size,tt_persistent);
  283. addstatement(newstatement,temp);
  284. { create call to fpc_getmem }
  285. para := ccallparanode.create(cordconstnode.create
  286. (tpointerdef(p1.resulttype.def).pointertype.def.size,s32bittype,true),nil);
  287. addstatement(newstatement,cassignmentnode.create(
  288. ctemprefnode.create(temp),
  289. ccallnode.createintern('fpc_getmem',para)));
  290. { create call to fpc_initialize }
  291. if tpointerdef(p1.resulttype.def).pointertype.def.needs_inittable then
  292. begin
  293. para := ccallparanode.create(caddrnode.create(crttinode.create
  294. (tstoreddef(tpointerdef(p1.resulttype.def).pointertype.def),initrtti)),
  295. ccallparanode.create(ctemprefnode.create
  296. (temp),nil));
  297. addstatement(newstatement,ccallnode.createintern('fpc_initialize',para));
  298. end;
  299. { the last statement should return the value as
  300. location and type, this is done be referencing the
  301. temp and converting it first from a persistent temp to
  302. normal temp }
  303. addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
  304. addstatement(newstatement,ctemprefnode.create(temp));
  305. p1.destroy;
  306. p1:=newblock;
  307. end
  308. else
  309. begin
  310. consume(_COMMA);
  311. if tpointerdef(p1.resulttype.def).pointertype.def.deftype<>objectdef then
  312. begin
  313. Message(parser_e_pointer_to_class_expected);
  314. consume_all_until(_RKLAMMER);
  315. consume(_RKLAMMER);
  316. p1.destroy;
  317. new_function:=cerrornode.create;
  318. exit;
  319. end;
  320. classh:=tobjectdef(tpointerdef(p1.resulttype.def).pointertype.def);
  321. { check for an abstract class }
  322. if (oo_has_abstract in classh.objectoptions) then
  323. Message(sym_e_no_instance_of_abstract_object);
  324. { use the objectdef for loading the VMT }
  325. p2:=p1;
  326. p1:=ctypenode.create(tpointerdef(p1.resulttype.def).pointertype);
  327. do_resulttypepass(p1);
  328. { search the constructor also in the symbol tables of
  329. the parents }
  330. afterassignment:=false;
  331. sym:=searchsym_in_class(classh,pattern);
  332. consume(_ID);
  333. do_member_read(false,sym,p1,again,[nf_new_call]);
  334. { we need to know which procedure is called }
  335. do_resulttypepass(p1);
  336. if not(
  337. (p1.nodetype=calln) and
  338. assigned(tcallnode(p1).procdefinition) and
  339. (tcallnode(p1).procdefinition.proctypeoption=potype_constructor)
  340. ) then
  341. Message(parser_e_expr_have_to_be_constructor_call);
  342. { constructors return boolean, update resulttype to return
  343. the pointer to the object }
  344. p1.resulttype:=p2.resulttype;
  345. p2.free;
  346. consume(_RKLAMMER);
  347. end;
  348. new_function:=p1;
  349. end;
  350. function inline_setlength : tnode;
  351. var
  352. paras : tnode;
  353. npara,
  354. ppn : tcallparanode;
  355. counter : integer;
  356. isarray : boolean;
  357. def : tdef;
  358. destppn : tnode;
  359. newstatement : tstatementnode;
  360. temp : ttempcreatenode;
  361. newblock : tnode;
  362. begin
  363. { for easy exiting if something goes wrong }
  364. result := cerrornode.create;
  365. consume(_LKLAMMER);
  366. paras:=parse_paras(false,false);
  367. consume(_RKLAMMER);
  368. if not assigned(paras) then
  369. begin
  370. CGMessage(parser_e_wrong_parameter_size);
  371. exit;
  372. end;
  373. counter:=0;
  374. if assigned(paras) then
  375. begin
  376. { check type of lengths }
  377. ppn:=tcallparanode(paras);
  378. while assigned(ppn.right) do
  379. begin
  380. set_varstate(ppn.left,true);
  381. inserttypeconv(ppn.left,s32bittype);
  382. inc(counter);
  383. ppn:=tcallparanode(ppn.right);
  384. end;
  385. end;
  386. if counter=0 then
  387. begin
  388. CGMessage(parser_e_wrong_parameter_size);
  389. paras.free;
  390. exit;
  391. end;
  392. { last param must be var }
  393. destppn:=ppn.left;
  394. inc(parsing_para_level);
  395. valid_for_var(destppn);
  396. set_varstate(destppn,false);
  397. dec(parsing_para_level);
  398. { first param must be a string or dynamic array ...}
  399. isarray:=is_dynamic_array(destppn.resulttype.def);
  400. if not((destppn.resulttype.def.deftype=stringdef) or
  401. isarray) then
  402. begin
  403. CGMessage(type_e_mismatch);
  404. paras.free;
  405. exit;
  406. end;
  407. { only dynamic arrays accept more dimensions }
  408. if (counter>1) then
  409. begin
  410. if (not isarray) then
  411. CGMessage(type_e_mismatch)
  412. else
  413. begin
  414. { check if the amount of dimensions is valid }
  415. def := tarraydef(destppn.resulttype.def).elementtype.def;
  416. while counter > 1 do
  417. begin
  418. if not(is_dynamic_array(def)) then
  419. begin
  420. CGMessage(parser_e_wrong_parameter_size);
  421. break;
  422. end;
  423. dec(counter);
  424. def := tarraydef(def).elementtype.def;
  425. end;
  426. end;
  427. end;
  428. if isarray then
  429. begin
  430. { create statements with call initialize the arguments and
  431. call fpc_dynarr_setlength }
  432. newblock:=internalstatements(newstatement,true);
  433. { get temp for array of lengths }
  434. temp := ctempcreatenode.create(s32bittype,counter*s32bittype.def.size,tt_persistent);
  435. addstatement(newstatement,temp);
  436. { load array of lengths }
  437. ppn:=tcallparanode(paras);
  438. counter:=0;
  439. while assigned(ppn.right) do
  440. begin
  441. addstatement(newstatement,cassignmentnode.create(
  442. ctemprefnode.create_offset(temp,counter*s32bittype.def.size),
  443. ppn.left));
  444. ppn.left:=nil;
  445. inc(counter);
  446. ppn:=tcallparanode(ppn.right);
  447. end;
  448. { destppn is also reused }
  449. ppn.left:=nil;
  450. { create call to fpc_dynarr_setlength }
  451. npara:=ccallparanode.create(caddrnode.create
  452. (ctemprefnode.create(temp)),
  453. ccallparanode.create(cordconstnode.create
  454. (counter,s32bittype,true),
  455. ccallparanode.create(caddrnode.create
  456. (crttinode.create(tstoreddef(destppn.resulttype.def),initrtti)),
  457. ccallparanode.create(ctypeconvnode.create_explicit(destppn,voidpointertype),nil))));
  458. addstatement(newstatement,ccallnode.createintern('fpc_dynarray_setlength',npara));
  459. addstatement(newstatement,ctempdeletenode.create(temp));
  460. { we don't need original the callparanodes tree }
  461. paras.free;
  462. end
  463. else
  464. begin
  465. { we can reuse the supplied parameters }
  466. newblock:=ccallnode.createintern(
  467. 'fpc_'+tstringdef(destppn.resulttype.def).stringtypname+'_setlength',paras);
  468. end;
  469. result.free;
  470. result:=newblock;
  471. end;
  472. function inline_finalize : tnode;
  473. var
  474. newblock,
  475. paras : tnode;
  476. npara,
  477. destppn,
  478. ppn : tcallparanode;
  479. begin
  480. { for easy exiting if something goes wrong }
  481. result := cerrornode.create;
  482. consume(_LKLAMMER);
  483. paras:=parse_paras(false,false);
  484. consume(_RKLAMMER);
  485. if not assigned(paras) then
  486. begin
  487. CGMessage(parser_e_wrong_parameter_size);
  488. exit;
  489. end;
  490. ppn:=tcallparanode(paras);
  491. { 2 arguments? }
  492. if assigned(ppn.right) then
  493. begin
  494. destppn:=tcallparanode(ppn.right);
  495. { 3 arguments is invalid }
  496. if assigned(destppn.right) then
  497. begin
  498. CGMessage(parser_e_wrong_parameter_size);
  499. paras.free;
  500. exit;
  501. end;
  502. { create call to fpc_finalize_array }
  503. npara:=ccallparanode.create(cordconstnode.create
  504. (destppn.left.resulttype.def.size,s32bittype,true),
  505. ccallparanode.create(ctypeconvnode.create
  506. (ppn.left,s32bittype),
  507. ccallparanode.create(caddrnode.create
  508. (crttinode.create(tstoreddef(destppn.left.resulttype.def),initrtti)),
  509. ccallparanode.create(caddrnode.create
  510. (destppn.left),nil))));
  511. newblock:=ccallnode.createintern('fpc_finalize_array',npara);
  512. destppn.left:=nil;
  513. ppn.left:=nil;
  514. end
  515. else
  516. begin
  517. newblock:=finalize_data_node(ppn.left);
  518. ppn.left:=nil;
  519. end;
  520. paras.free;
  521. result.free;
  522. result:=newblock;
  523. end;
  524. function inline_copy : tnode;
  525. var
  526. copynode,
  527. lowppn,
  528. highppn,
  529. npara,
  530. paras : tnode;
  531. temp : ttempcreatenode;
  532. ppn : tcallparanode;
  533. paradef : tdef;
  534. counter : integer;
  535. newstatement : tstatementnode;
  536. begin
  537. { for easy exiting if something goes wrong }
  538. result := cerrornode.create;
  539. consume(_LKLAMMER);
  540. paras:=parse_paras(false,false);
  541. consume(_RKLAMMER);
  542. if not assigned(paras) then
  543. begin
  544. CGMessage(parser_e_wrong_parameter_size);
  545. exit;
  546. end;
  547. { determine copy function to use based on the first argument,
  548. also count the number of arguments in this loop }
  549. counter:=1;
  550. ppn:=tcallparanode(paras);
  551. while assigned(ppn.right) do
  552. begin
  553. inc(counter);
  554. ppn:=tcallparanode(ppn.right);
  555. end;
  556. paradef:=ppn.left.resulttype.def;
  557. if is_ansistring(paradef) then
  558. copynode:=ccallnode.createintern('fpc_ansistr_copy',paras)
  559. else
  560. if is_widestring(paradef) then
  561. copynode:=ccallnode.createintern('fpc_widestr_copy',paras)
  562. else
  563. if is_char(paradef) then
  564. copynode:=ccallnode.createintern('fpc_char_copy',paras)
  565. else
  566. if is_dynamic_array(paradef) then
  567. begin
  568. { Only allow 1 or 3 arguments }
  569. if (counter<>1) and (counter<>3) then
  570. begin
  571. CGMessage(parser_e_wrong_parameter_size);
  572. exit;
  573. end;
  574. { create statements with call }
  575. copynode:=internalstatements(newstatement,true);
  576. if (counter=3) then
  577. begin
  578. highppn:=tcallparanode(paras).left.getcopy;
  579. lowppn:=tcallparanode(tcallparanode(paras).right).left.getcopy;
  580. end
  581. else
  582. begin
  583. { use special -1,-1 argument to copy the whole array }
  584. highppn:=cordconstnode.create(-1,s32bittype,false);
  585. lowppn:=cordconstnode.create(-1,s32bittype,false);
  586. end;
  587. { create temp for result, we've to use a temp because a dynarray
  588. type is handled differently from a pointer so we can't
  589. use createinternres() and a function }
  590. temp := ctempcreatenode.create(voidpointertype,voidpointertype.def.size,tt_persistent);
  591. addstatement(newstatement,temp);
  592. { create call to fpc_dynarray_copy }
  593. npara:=ccallparanode.create(highppn,
  594. ccallparanode.create(lowppn,
  595. ccallparanode.create(caddrnode.create
  596. (crttinode.create(tstoreddef(ppn.left.resulttype.def),initrtti)),
  597. ccallparanode.create
  598. (ctypeconvnode.create_explicit(ppn.left,voidpointertype),
  599. ccallparanode.create
  600. (ctemprefnode.create(temp),nil)))));
  601. addstatement(newstatement,ccallnode.createintern('fpc_dynarray_copy',npara));
  602. { convert the temp to normal and return the reference to the
  603. created temp, and convert the type of the temp to the dynarray type }
  604. addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
  605. addstatement(newstatement,ctypeconvnode.create_explicit(ctemprefnode.create(temp),ppn.left.resulttype));
  606. ppn.left:=nil;
  607. paras.free;
  608. end
  609. else
  610. begin
  611. { generic fallback that will give an error if a wrong
  612. type is passed }
  613. copynode:=ccallnode.createintern('fpc_shortstr_copy',paras)
  614. end;
  615. result.free;
  616. result:=copynode;
  617. end;
  618. end.
  619. {
  620. $Log$
  621. Revision 1.15 2003-05-17 13:30:08 jonas
  622. * changed tt_persistant to tt_persistent :)
  623. * tempcreatenode now doesn't accept a boolean anymore for persistent
  624. temps, but a ttemptype, so you can also create ansistring temps etc
  625. Revision 1.14 2003/05/16 14:33:31 peter
  626. * regvar fixes
  627. Revision 1.13 2003/05/09 17:47:03 peter
  628. * self moved to hidden parameter
  629. * removed hdisposen,hnewn,selfn
  630. Revision 1.12 2002/04/25 20:15:40 florian
  631. * block nodes within expressions shouldn't release the used registers,
  632. fixed using a flag till the new rg is ready
  633. Revision 1.11 2002/11/26 22:59:09 peter
  634. * fix Copy(array,x,y)
  635. Revision 1.10 2002/11/25 17:43:22 peter
  636. * splitted defbase in defutil,symutil,defcmp
  637. * merged isconvertable and is_equal into compare_defs(_ext)
  638. * made operator search faster by walking the list only once
  639. Revision 1.9 2002/10/29 10:01:22 pierre
  640. * fix crash report as webbug 2174
  641. Revision 1.8 2002/10/02 18:20:52 peter
  642. * Copy() is now internal syssym that calls compilerprocs
  643. Revision 1.7 2002/09/07 12:16:03 carl
  644. * second part bug report 1996 fix, testrange in cordconstnode
  645. only called if option is set (also make parsing a tiny faster)
  646. Revision 1.6 2002/07/20 11:57:56 florian
  647. * types.pas renamed to defbase.pas because D6 contains a types
  648. unit so this would conflicts if D6 programms are compiled
  649. + Willamette/SSE2 instructions to assembler added
  650. Revision 1.5 2002/05/18 13:34:12 peter
  651. * readded missing revisions
  652. Revision 1.4 2002/05/16 19:46:43 carl
  653. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  654. + try to fix temp allocation (still in ifdef)
  655. + generic constructor calls
  656. + start of tassembler / tmodulebase class cleanup
  657. Revision 1.2 2002/05/12 16:53:09 peter
  658. * moved entry and exitcode to ncgutil and cgobj
  659. * foreach gets extra argument for passing local data to the
  660. iterator function
  661. * -CR checks also class typecasts at runtime by changing them
  662. into as
  663. * fixed compiler to cycle with the -CR option
  664. * fixed stabs with elf writer, finally the global variables can
  665. be watched
  666. * removed a lot of routines from cga unit and replaced them by
  667. calls to cgobj
  668. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  669. u32bit then the other is typecasted also to u32bit without giving
  670. a rangecheck warning/error.
  671. * fixed pascal calling method with reversing also the high tree in
  672. the parast, detected by tcalcst3 test
  673. Revision 1.1 2002/04/23 19:16:35 peter
  674. * add pinline unit that inserts compiler supported functions using
  675. one or more statements
  676. * moved finalize and setlength from ninl to pinline
  677. }