ncgcnv.pas 24 KB

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