ncgcnv.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. {
  2. Copyright (c) 2000-2002 by Florian Klaempfl
  3. Generate assembler for nodes that handle type conversions which are
  4. the same for all (most) processors
  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 ncgcnv;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,ncnv,defutil,defcmp;
  23. type
  24. tcgtypeconvnode = class(ttypeconvnode)
  25. procedure second_int_to_int;override;
  26. procedure second_cstring_to_pchar;override;
  27. procedure second_cstring_to_int;override;
  28. procedure second_string_to_chararray;override;
  29. procedure second_array_to_pointer;override;
  30. procedure second_pointer_to_array;override;
  31. procedure second_char_to_string;override;
  32. procedure second_real_to_real;override;
  33. procedure second_cord_to_pointer;override;
  34. procedure second_proc_to_procvar;override;
  35. procedure second_nil_to_methodprocvar;override;
  36. procedure second_bool_to_int;override;
  37. procedure second_bool_to_bool;override;
  38. procedure second_ansistring_to_pchar;override;
  39. procedure second_class_to_intf;override;
  40. procedure second_char_to_char;override;
  41. procedure second_nothing;override;
  42. procedure pass_generate_code;override;
  43. end;
  44. tcgasnode = class(tasnode)
  45. procedure pass_generate_code;override;
  46. end;
  47. implementation
  48. uses
  49. cutils,verbose,globtype,globals,
  50. aasmbase,aasmtai,aasmdata,aasmcpu,symconst,symdef,paramgr,
  51. ncon,ncal,
  52. cpubase,systems,
  53. procinfo,pass_2,
  54. cgbase,
  55. cgutils,cgobj,
  56. ncgutil,
  57. tgobj
  58. ;
  59. procedure tcgtypeconvnode.second_int_to_int;
  60. var
  61. orgsize,
  62. newsize : tcgsize;
  63. ressize,
  64. leftsize : longint;
  65. begin
  66. newsize:=def_cgsize(resultdef);
  67. { insert range check if not explicit conversion }
  68. if not(nf_explicit in flags) then
  69. cg.g_rangecheck(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef);
  70. { is the result size smaller? when typecasting from void
  71. we always reuse the current location, because there is
  72. nothing that we can load in a register }
  73. ressize := resultdef.size;
  74. leftsize := left.resultdef.size;
  75. if (ressize<>leftsize) and
  76. not is_void(left.resultdef) then
  77. begin
  78. location_copy(location,left.location);
  79. { reuse a loc_reference when the newsize is smaller than
  80. than the original, else load it to a register }
  81. if (location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) and
  82. (ressize<leftsize) then
  83. begin
  84. location.size:=newsize;
  85. if (target_info.endian = ENDIAN_BIG) then
  86. inc(location.reference.offset,leftsize-ressize);
  87. end
  88. else
  89. location_force_reg(current_asmdata.CurrAsmList,location,newsize,false);
  90. end
  91. else
  92. begin
  93. { no special loading is required, reuse current location }
  94. { that's not true, if you go from signed to unsiged or }
  95. { vice versa, you need sign extension/removal if the }
  96. { value is already in a register (at least for archs }
  97. { which don't have 8bit register components etc) (JM) }
  98. location_copy(location,left.location);
  99. location.size:=newsize;
  100. orgsize := def_cgsize(left.resultdef);
  101. if (ressize < sizeof(aint)) and
  102. (location.loc in [LOC_REGISTER,LOC_CREGISTER]) and
  103. (orgsize <> newsize) then
  104. begin
  105. location.register := cg.getintregister(current_asmdata.CurrAsmList,newsize);
  106. location.loc := LOC_REGISTER;
  107. cg.a_load_reg_reg(current_asmdata.CurrAsmList,orgsize,newsize,left.location.register,location.register);
  108. end;
  109. end;
  110. end;
  111. procedure tcgtypeconvnode.second_cstring_to_pchar;
  112. var
  113. hr : treference;
  114. begin
  115. if left.nodetype<>stringconstn then
  116. internalerror(200601131);
  117. location_reset(location,LOC_REGISTER,OS_ADDR);
  118. case tstringconstnode(left).cst_type of
  119. cst_conststring :
  120. begin
  121. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  122. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.location.reference,location.register);
  123. end;
  124. cst_shortstring :
  125. begin
  126. inc(left.location.reference.offset);
  127. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  128. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.location.reference,location.register);
  129. end;
  130. cst_ansistring :
  131. begin
  132. if tstringconstnode(left).len=0 then
  133. begin
  134. reference_reset(hr);
  135. hr.symbol:=current_asmdata.RefAsmSymbol('FPC_EMPTYCHAR');
  136. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  137. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,hr,location.register);
  138. end
  139. else
  140. begin
  141. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  142. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.reference,location.register);
  143. end;
  144. end;
  145. cst_longstring:
  146. begin
  147. {!!!!!!!}
  148. internalerror(8888);
  149. end;
  150. cst_widestring:
  151. begin
  152. if tstringconstnode(left).len=0 then
  153. begin
  154. reference_reset(hr);
  155. hr.symbol:=current_asmdata.RefAsmSymbol('FPC_EMPTYCHAR');
  156. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  157. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,hr,location.register);
  158. end
  159. else
  160. begin
  161. location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
  162. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_INT,left.location.reference,
  163. location.register);
  164. end;
  165. end;
  166. end;
  167. end;
  168. procedure tcgtypeconvnode.second_cstring_to_int;
  169. begin
  170. { this can't happen because constants are already processed in
  171. pass 1 }
  172. internalerror(200510013);
  173. end;
  174. procedure tcgtypeconvnode.second_string_to_chararray;
  175. begin
  176. if is_chararray(left.resultdef) then
  177. begin
  178. location_copy(location,left.location);
  179. exit;
  180. end;
  181. { should be handled already in resultdef pass (JM) }
  182. internalerror(200108292);
  183. end;
  184. procedure tcgtypeconvnode.second_array_to_pointer;
  185. begin
  186. location_reset(location,LOC_REGISTER,OS_ADDR);
  187. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  188. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.location.reference,location.register);
  189. end;
  190. procedure tcgtypeconvnode.second_pointer_to_array;
  191. begin
  192. location_reset(location,LOC_REFERENCE,OS_NO);
  193. case left.location.loc of
  194. LOC_CREGISTER,
  195. LOC_REGISTER :
  196. begin
  197. {$ifdef cpu_uses_separate_address_registers}
  198. if getregtype(left.location.register)<>R_ADDRESSREGISTER then
  199. begin
  200. location.reference.base:=rg.getaddressregister(current_asmdata.CurrAsmList);
  201. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,
  202. left.location.register,location.reference.base);
  203. end
  204. else
  205. {$endif}
  206. location.reference.base := left.location.register;
  207. end;
  208. LOC_REFERENCE,
  209. LOC_CREFERENCE :
  210. begin
  211. location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList);
  212. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.reference,
  213. location.reference.base);
  214. location_freetemp(current_asmdata.CurrAsmList,left.location);
  215. end;
  216. else
  217. internalerror(2002032216);
  218. end;
  219. end;
  220. procedure tcgtypeconvnode.second_char_to_string;
  221. begin
  222. location_reset(location,LOC_REFERENCE,OS_NO);
  223. case tstringdef(resultdef).stringtype of
  224. st_shortstring :
  225. begin
  226. tg.GetTemp(current_asmdata.CurrAsmList,256,tt_normal,location.reference);
  227. cg.a_load_loc_ref(current_asmdata.CurrAsmList,left.location.size,left.location,
  228. location.reference);
  229. location_freetemp(current_asmdata.CurrAsmList,left.location);
  230. end;
  231. { the rest is removed in the resultdef pass and converted to compilerprocs }
  232. else
  233. internalerror(4179);
  234. end;
  235. end;
  236. procedure tcgtypeconvnode.second_real_to_real;
  237. {$ifdef x86}
  238. var
  239. tr: treference;
  240. {$endif x86}
  241. begin
  242. location_reset(location,expectloc,def_cgsize(resultdef));
  243. {$ifdef x86}
  244. { extended types in memory which should be loaded into the sse unit
  245. must be converted by the fpu first, so force them to be loaded into
  246. the fpu }
  247. if (expectloc=LOC_MMREGISTER) and
  248. (left.location.size in [OS_F80,OS_C64]) then
  249. begin
  250. if (left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  251. location_force_fpureg(current_asmdata.CurrAsmList,left.location,false);
  252. { round them down to the proper precision }
  253. tg.gettemp(current_asmdata.currasmlist,resultdef.size,tt_normal,tr);
  254. cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,tr);
  255. location_reset(left.location,LOC_REFERENCE,location.size);
  256. left.location.reference:=tr;
  257. end;
  258. {$endif x86}
  259. case left.location.loc of
  260. LOC_FPUREGISTER,
  261. LOC_CFPUREGISTER:
  262. begin
  263. case expectloc of
  264. LOC_FPUREGISTER:
  265. begin
  266. { on sparc a move from double -> single means from two to one register. }
  267. { On all other platforms it also needs rounding to avoid that }
  268. { single(double_regvar) = double_regvar is true in all cases }
  269. location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
  270. cg.a_loadfpu_reg_reg(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,location.register);
  271. end;
  272. LOC_MMREGISTER:
  273. begin
  274. location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,false);
  275. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  276. cg.a_loadmm_reg_reg(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,location.register,mms_movescalar);
  277. end
  278. else
  279. internalerror(2003012262);
  280. end;
  281. exit
  282. end;
  283. LOC_CREFERENCE,
  284. LOC_REFERENCE:
  285. begin
  286. if expectloc=LOC_MMREGISTER then
  287. begin
  288. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  289. cg.a_loadmm_loc_reg(current_asmdata.CurrAsmList,location.size,left.location,location.register,mms_movescalar)
  290. end
  291. else
  292. begin
  293. location_force_fpureg(current_asmdata.CurrAsmList,left.location,false);
  294. location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
  295. cg.a_loadfpu_reg_reg(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,location.register);
  296. end;
  297. location_freetemp(current_asmdata.CurrAsmList,left.location);
  298. end;
  299. LOC_MMREGISTER,
  300. LOC_CMMREGISTER:
  301. begin
  302. case expectloc of
  303. LOC_FPUREGISTER:
  304. begin
  305. location_force_fpureg(current_asmdata.CurrAsmList,left.location,false);
  306. location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
  307. cg.a_loadfpu_reg_reg(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,location.register);
  308. end;
  309. LOC_MMREGISTER:
  310. begin
  311. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  312. cg.a_loadmm_reg_reg(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,location.register,mms_movescalar);
  313. end;
  314. else
  315. internalerror(2003012261);
  316. end;
  317. end;
  318. else
  319. internalerror(2002032215);
  320. end;
  321. end;
  322. procedure tcgtypeconvnode.second_cord_to_pointer;
  323. begin
  324. { this can't happen because constants are already processed in
  325. pass 1 }
  326. internalerror(47423985);
  327. end;
  328. procedure tcgtypeconvnode.second_proc_to_procvar;
  329. begin
  330. if tabstractprocdef(resultdef).is_addressonly then
  331. begin
  332. location_reset(location,LOC_REGISTER,OS_ADDR);
  333. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  334. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.location.reference,location.register);
  335. end
  336. else
  337. location_copy(location,left.location);
  338. end;
  339. procedure Tcgtypeconvnode.second_nil_to_methodprocvar;
  340. var r:Treference;
  341. begin
  342. tg.gettemp(current_asmdata.currasmlist,2*sizeof(puint),tt_normal,r);
  343. location_reset(location,LOC_REFERENCE,OS_NO);
  344. location.reference:=r;
  345. cg.a_load_const_ref(current_asmdata.currasmlist,OS_ADDR,0,r);
  346. inc(r.offset,sizeof(puint));
  347. cg.a_load_const_ref(current_asmdata.currasmlist,OS_ADDR,0,r);
  348. end;
  349. procedure tcgtypeconvnode.second_bool_to_int;
  350. var
  351. newsize: tcgsize;
  352. oldTrueLabel,oldFalseLabel : tasmlabel;
  353. begin
  354. oldTrueLabel:=current_procinfo.CurrTrueLabel;
  355. oldFalseLabel:=current_procinfo.CurrFalseLabel;
  356. current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
  357. current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
  358. secondpass(left);
  359. location_copy(location,left.location);
  360. newsize:=def_cgsize(resultdef);
  361. { byte(bytebool) or word(wordbool) or longint(longbool) must be }
  362. { accepted for var parameters and assignments, and must not }
  363. { change the ordinal value or value location. }
  364. { htypechk.valid_for_assign ensures that such locations with a }
  365. { size<sizeof(register) cannot be LOC_CREGISTER (they otherwise }
  366. { could be in case of a plain assignment), and LOC_REGISTER can }
  367. { never be an assignment target. The remaining LOC_REGISTER/ }
  368. { LOC_CREGISTER locations do have to be sign/zero-extended. }
  369. if not(nf_explicit in flags) or
  370. (location.loc in [LOC_FLAGS,LOC_JUMP]) or
  371. { change of size/signedness? Then we have to sign/ }
  372. { zero-extend in case of a loc_(c)register }
  373. ((newsize<>left.location.size) and
  374. ((left.resultdef.size<>resultdef.size) or
  375. not(location.loc in [LOC_REFERENCE,LOC_CREFERENCE]))) then
  376. location_force_reg(current_asmdata.CurrAsmList,location,newsize,true)
  377. else
  378. { may differ in sign, e.g. bytebool -> byte }
  379. location.size:=newsize;
  380. current_procinfo.CurrTrueLabel:=oldTrueLabel;
  381. current_procinfo.CurrFalseLabel:=oldFalseLabel;
  382. end;
  383. procedure tcgtypeconvnode.second_bool_to_bool;
  384. begin
  385. { we can reuse the conversion already available
  386. in bool_to_int to resize the value. But when the
  387. size of the new boolean is smaller we need to calculate
  388. the value as is done in int_to_bool. This is needed because
  389. the bits that define the true status can be outside the limits
  390. of the new size and truncating the register can result in a 0
  391. value }
  392. if (left.expectloc in [LOC_FLAGS,LOC_JUMP]) then
  393. begin
  394. secondpass(left);
  395. if (left.location.loc <> left.expectloc) then
  396. internalerror(20060409);
  397. location_copy(location,left.location);
  398. end
  399. else if (resultdef.size=left.resultdef.size) and
  400. not(is_cbool(resultdef) xor
  401. is_cbool(left.resultdef)) then
  402. second_bool_to_int
  403. else
  404. begin
  405. if (resultdef.size<>left.resultdef.size) then
  406. { remove nf_explicit to perform full conversion if boolean sizes are different }
  407. exclude(flags, nf_explicit);
  408. second_int_to_bool;
  409. end;
  410. end;
  411. procedure tcgtypeconvnode.second_ansistring_to_pchar;
  412. var
  413. l1 : tasmlabel;
  414. hr : treference;
  415. begin
  416. location_reset(location,LOC_REGISTER,OS_ADDR);
  417. current_asmdata.getjumplabel(l1);
  418. case left.location.loc of
  419. LOC_CREGISTER,LOC_REGISTER:
  420. begin
  421. {$ifdef cpu_uses_separate_address_registers}
  422. if getregtype(left.location.register)<>R_ADDRESSREGISTER then
  423. begin
  424. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  425. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,
  426. left.location.register,location.register);
  427. end
  428. else
  429. {$endif}
  430. location.register := left.location.register;
  431. end;
  432. LOC_CREFERENCE,LOC_REFERENCE:
  433. begin
  434. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  435. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.reference,location.register);
  436. end;
  437. else
  438. internalerror(2002032214);
  439. end;
  440. cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_ADDR,OC_NE,0,location.register,l1);
  441. reference_reset(hr);
  442. hr.symbol:=current_asmdata.RefAsmSymbol('FPC_EMPTYCHAR');
  443. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,hr,location.register);
  444. cg.a_label(current_asmdata.CurrAsmList,l1);
  445. end;
  446. procedure tcgtypeconvnode.second_class_to_intf;
  447. var
  448. l1 : tasmlabel;
  449. hd : tobjectdef;
  450. ImplIntf : TImplementedInterface;
  451. begin
  452. location_reset(location,LOC_REGISTER,OS_ADDR);
  453. case left.location.loc of
  454. LOC_CREFERENCE,
  455. LOC_REFERENCE:
  456. begin
  457. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  458. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.reference,location.register);
  459. location_freetemp(current_asmdata.CurrAsmList,left.location);
  460. end;
  461. LOC_CREGISTER:
  462. begin
  463. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  464. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.register,location.register);
  465. end;
  466. LOC_REGISTER:
  467. location.register:=left.location.register;
  468. else
  469. internalerror(121120001);
  470. end;
  471. hd:=tobjectdef(left.resultdef);
  472. while assigned(hd) do
  473. begin
  474. ImplIntf:=hd.find_implemented_interface(tobjectdef(resultdef));
  475. if assigned(ImplIntf) then
  476. begin
  477. case ImplIntf.IType of
  478. etStandard:
  479. begin
  480. current_asmdata.getjumplabel(l1);
  481. cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_ADDR,OC_EQ,0,location.register,l1);
  482. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_ADD,OS_ADDR,ImplIntf.ioffset,location.register);
  483. break;
  484. end;
  485. else
  486. internalerror(200802163);
  487. end;
  488. end;
  489. hd:=hd.childof;
  490. end;
  491. if hd=nil then
  492. internalerror(2002081301);
  493. cg.a_label(current_asmdata.CurrAsmList,l1);
  494. end;
  495. procedure tcgtypeconvnode.second_char_to_char;
  496. begin
  497. internalerror(2007081202);
  498. end;
  499. procedure tcgtypeconvnode.second_nothing;
  500. var
  501. newsize : tcgsize;
  502. begin
  503. { we reuse the old value }
  504. location_copy(location,left.location);
  505. { Floats should never be returned as LOC_CONSTANT, do the
  506. moving to memory before the new size is set.
  507. Also when converting from a float to a non-float
  508. or the other way round, move to memory first to prevent
  509. invalid LOC_FPUREGISTER locations }
  510. if (
  511. (resultdef.typ=floatdef) and
  512. (location.loc=LOC_CONSTANT)
  513. ) or
  514. (
  515. (left.resultdef.typ=floatdef) xor
  516. (resultdef.typ=floatdef)
  517. ) then
  518. location_force_mem(current_asmdata.CurrAsmList,location);
  519. { but use the new size, but we don't know the size of all arrays }
  520. newsize:=def_cgsize(resultdef);
  521. location.size:=newsize;
  522. end;
  523. {$ifdef TESTOBJEXT2}
  524. procedure tcgtypeconvnode.checkobject;
  525. begin
  526. { no checking by default }
  527. end;
  528. {$endif TESTOBJEXT2}
  529. procedure tcgtypeconvnode.pass_generate_code;
  530. begin
  531. { the boolean routines can be called with LOC_JUMP and
  532. call secondpass themselves in the helper }
  533. if not(convtype in [tc_bool_2_int,tc_bool_2_bool,tc_int_2_bool]) then
  534. begin
  535. secondpass(left);
  536. if codegenerror then
  537. exit;
  538. end;
  539. second_call_helper(convtype);
  540. {$ifdef TESTOBJEXT2}
  541. { Check explicit conversions to objects pointers !! }
  542. if p^.explizit and
  543. (p^.resultdef.typ=pointerdef) and
  544. (tpointerdef(p^.resultdef).definition.typ=objectdef) and not
  545. (tobjectdef(tpointerdef(p^.resultdef).definition).isclass) and
  546. ((tobjectdef(tpointerdef(p^.resultdef).definition).options and oo_hasvmt)<>0) and
  547. (cs_check_range in current_settings.localswitches) then
  548. checkobject;
  549. {$endif TESTOBJEXT2}
  550. end;
  551. procedure tcgasnode.pass_generate_code;
  552. begin
  553. secondpass(call);
  554. location_copy(location,call.location);
  555. end;
  556. begin
  557. ctypeconvnode := tcgtypeconvnode;
  558. casnode := tcgasnode;
  559. end.