tcalval4.pp 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159
  1. {****************************************************************}
  2. { CODE GENERATOR TEST PROGRAM }
  3. { By Carl Eric Codere }
  4. {****************************************************************}
  5. { NODE TESTED : secondcallparan() }
  6. {****************************************************************}
  7. { PRE-REQUISITES: secondload() }
  8. { secondassign() }
  9. { secondtypeconv() }
  10. { secondtryexcept() }
  11. { secondcalln() }
  12. { secondadd() }
  13. {****************************************************************}
  14. { DEFINES: }
  15. { FPC = Target is FreePascal compiler }
  16. {****************************************************************}
  17. { REMARKS: This tests a subset of the secondcalln() node }
  18. { (value parameters with cdecl calling convention) }
  19. {****************************************************************}
  20. program tcalval4;
  21. {$ifdef fpc}
  22. {$mode objfpc}
  23. {$INLINE ON}
  24. {$endif}
  25. {$R+}
  26. {$P-}
  27. {$ifdef VER70}
  28. {$define tp}
  29. {$endif}
  30. { REAL should map to single or double }
  31. { so it is not checked, since single }
  32. { double nodes are checked. }
  33. { assumes that enumdef is the same as orddef (same storage format) }
  34. const
  35. { should be defined depending on CPU target }
  36. {$ifdef fpc}
  37. {$ifdef cpu68k}
  38. BIG_INDEX = 8000;
  39. SMALL_INDEX = 13;
  40. {$else}
  41. BIG_INDEX = 33000;
  42. SMALL_INDEX = 13; { value should not be aligned! }
  43. {$endif}
  44. {$else}
  45. BIG_INDEX = 33000;
  46. SMALL_INDEX = 13; { value should not be aligned! }
  47. {$endif}
  48. RESULT_U8BIT = $55;
  49. RESULT_U16BIT = $500F;
  50. RESULT_S32BIT = $500F0000;
  51. RESULT_S64BIT = $500F0000;
  52. RESULT_S32REAL = 1777.12;
  53. RESULT_S64REAL = 3444.24;
  54. RESULT_BOOL8BIT = 1;
  55. RESULT_BOOL16BIT = 1;
  56. RESULT_BOOL32BIT = 1;
  57. RESULT_PCHAR = 'Hello world';
  58. RESULT_BIGSTRING = 'Hello world';
  59. RESULT_SMALLSTRING = 'H';
  60. RESULT_CHAR = 'I';
  61. RESULT_BOOLEAN = TRUE;
  62. type
  63. {$ifndef tp}
  64. tclass1 = class
  65. end;
  66. {$else}
  67. shortstring = string;
  68. {$endif}
  69. tprocedure = procedure;
  70. tsmallrecord = packed record
  71. b: byte;
  72. w: word;
  73. end;
  74. tlargerecord = packed record
  75. b: array[1..BIG_INDEX] of byte;
  76. end;
  77. tsmallarray = packed array[1..SMALL_INDEX] of byte;
  78. tsmallsetenum =
  79. (A_A,A_B,A_C,A_D);
  80. tsmallset = set of tsmallsetenum;
  81. tlargeset = set of char;
  82. tsmallstring = string[2];
  83. var
  84. global_u8bit : byte;
  85. global_u16bit : word;
  86. global_s32bit : longint;
  87. global_s32real : single;
  88. global_s64real : double;
  89. global_ptr : pchar;
  90. global_proc : tprocedure;
  91. global_bigstring : shortstring;
  92. global_boolean : boolean;
  93. global_char : char;
  94. {$ifndef tp}
  95. global_class : tclass1;
  96. global_s64bit : int64;
  97. value_s64bit : int64;
  98. value_class : tclass1;
  99. {$endif}
  100. value_u8bit : byte;
  101. value_u16bit : word;
  102. value_s32bit : longint;
  103. value_s32real : single;
  104. value_s64real : double;
  105. value_proc : tprocedure;
  106. value_ptr : pchar;
  107. value_smallrec : tsmallrecord;
  108. value_largerec : tlargerecord;
  109. value_smallset : tsmallset;
  110. value_smallstring : tsmallstring;
  111. value_bigstring : shortstring;
  112. value_largeset : tlargeset;
  113. value_smallarray : tsmallarray;
  114. value_boolean : boolean;
  115. value_char : char;
  116. procedure fail;
  117. begin
  118. WriteLn('Failure.');
  119. halt(1);
  120. end;
  121. procedure clear_globals;
  122. begin
  123. global_u8bit := 0;
  124. global_u16bit := 0;
  125. global_s32bit := 0;
  126. global_s32real := 0.0;
  127. global_s64real := 0.0;
  128. global_ptr := nil;
  129. global_proc := nil;
  130. global_bigstring := '';
  131. global_boolean := false;
  132. global_char := #0;
  133. {$ifndef tp}
  134. global_s64bit := 0;
  135. global_class := nil;
  136. {$endif}
  137. end;
  138. procedure clear_values;
  139. begin
  140. value_u8bit := 0;
  141. value_u16bit := 0;
  142. value_s32bit := 0;
  143. value_s32real := 0.0;
  144. value_s64real := 0.0;
  145. value_proc := nil;
  146. value_ptr := nil;
  147. fillchar(value_smallrec, sizeof(value_smallrec), #0);
  148. fillchar(value_largerec, sizeof(value_largerec), #0);
  149. value_smallset := [];
  150. value_smallstring := '';
  151. value_bigstring := '';
  152. value_largeset := [];
  153. fillchar(value_smallarray, sizeof(value_smallarray), #0);
  154. value_boolean := false;
  155. value_char:=#0;
  156. {$ifndef tp}
  157. value_s64bit := 0;
  158. value_class := nil;
  159. {$endif}
  160. end;
  161. procedure testprocedure;
  162. begin
  163. end;
  164. function getu8bit : byte;
  165. begin
  166. getu8bit:=RESULT_U8BIT;
  167. end;
  168. function getu16bit: word;
  169. begin
  170. getu16bit:=RESULT_U16BIT;
  171. end;
  172. function gets32bit: longint;
  173. begin
  174. gets32bit:=RESULT_S32BIT;
  175. end;
  176. function gets64bit: int64;
  177. begin
  178. gets64bit:=RESULT_S64BIT;
  179. end;
  180. function gets32real: single;
  181. begin
  182. gets32real:=RESULT_S32REAL;
  183. end;
  184. function gets64real: double;
  185. begin
  186. gets64real:=RESULT_S64REAL;
  187. end;
  188. { ***************************************************************** }
  189. { VALUE PARAMETERS }
  190. { ***************************************************************** }
  191. procedure proc_value_u8bit(v: byte);cdecl;
  192. begin
  193. global_u8bit := v;
  194. end;
  195. procedure proc_value_u16bit(v: word);cdecl;
  196. begin
  197. global_u16bit := v;
  198. end;
  199. procedure proc_value_s32bit(v : longint);cdecl;
  200. begin
  201. global_s32bit := v;
  202. end;
  203. procedure proc_value_bool8bit(v: boolean);cdecl;
  204. begin
  205. { boolean should be 8-bit always! }
  206. if sizeof(boolean) <> 1 then RunError(255);
  207. global_u8bit := byte(v);
  208. end;
  209. procedure proc_value_bool16bit(v: wordbool);cdecl;
  210. begin
  211. global_u16bit := word(v);
  212. end;
  213. procedure proc_value_bool32bit(v : longbool);cdecl;
  214. begin
  215. global_s32bit := longint(v);
  216. end;
  217. procedure proc_value_s32real(v : single);cdecl;
  218. begin
  219. global_s32real := v;
  220. end;
  221. procedure proc_value_s64real(v: double);cdecl;
  222. begin
  223. global_s64real:= v;
  224. end;
  225. procedure proc_value_pointerdef(p : pchar);cdecl;
  226. begin
  227. global_ptr:=p;
  228. end;
  229. procedure proc_value_procvardef(p : tprocedure);cdecl;
  230. begin
  231. global_proc:=p;
  232. end;
  233. procedure proc_value_smallrecord(smallrec : tsmallrecord);cdecl;
  234. begin
  235. if (smallrec.b = RESULT_U8BIT) and (smallrec.w = RESULT_U16BIT) then
  236. global_u8bit := RESULT_U8BIT;
  237. end;
  238. procedure proc_value_largerecord(largerec : tlargerecord);cdecl;
  239. begin
  240. if (largerec.b[1] = RESULT_U8BIT) and (largerec.b[2] = RESULT_U8BIT) then
  241. global_u8bit := RESULT_U8BIT;
  242. end;
  243. procedure proc_value_smallset(smallset : tsmallset);cdecl;
  244. begin
  245. if A_D in smallset then
  246. global_u8bit := RESULT_U8BIT;
  247. end;
  248. procedure proc_value_largeset(largeset : tlargeset);cdecl;
  249. begin
  250. if 'I' in largeset then
  251. global_u8bit := RESULT_U8BIT;
  252. end;
  253. procedure proc_value_smallstring(s:tsmallstring);cdecl;
  254. begin
  255. if s = RESULT_SMALLSTRING then
  256. global_u8bit := RESULT_u8BIT;
  257. end;
  258. procedure proc_value_bigstring(s:shortstring);cdecl;
  259. begin
  260. if s = RESULT_BIGSTRING then
  261. global_u8bit := RESULT_u8BIT;
  262. end;
  263. procedure proc_value_smallarray(arr : tsmallarray);cdecl;
  264. begin
  265. if arr[SMALL_INDEX] = RESULT_U8BIT then
  266. global_u8bit := RESULT_U8BIT;
  267. end;
  268. procedure proc_value_smallarray_open(arr : array of byte);cdecl;
  269. begin
  270. { form 0 to N-1 indexes in open arrays }
  271. if arr[SMALL_INDEX-1] = RESULT_U8BIT then
  272. global_u8bit := RESULT_U8BIT;
  273. end;
  274. {$ifndef tp}
  275. procedure proc_value_classrefdef(obj : tclass1);cdecl;
  276. begin
  277. global_class:=obj;
  278. end;
  279. procedure proc_value_s64bit(v: int64);cdecl;
  280. begin
  281. global_s64bit:= v;
  282. end;
  283. {$endif}
  284. {********************************* MIXED PARAMETERS *************************}
  285. procedure proc_value_u8bit_mixed(b1 : byte; v: byte; b2: byte);cdecl;
  286. begin
  287. global_u8bit := v;
  288. value_u8bit := b2;
  289. end;
  290. procedure proc_value_u16bit_mixed(b1: byte; v: word; b2: byte);cdecl;
  291. begin
  292. global_u16bit := v;
  293. value_u8bit := b2;
  294. end;
  295. procedure proc_value_s32bit_mixed(b1 : byte; v : longint; b2: byte);cdecl;
  296. begin
  297. global_s32bit := v;
  298. value_u8bit := b2;
  299. end;
  300. procedure proc_value_bool8bit_mixed(b1: byte; v: boolean; b2: byte);cdecl;
  301. begin
  302. { boolean should be 8-bit always! }
  303. if sizeof(boolean) <> 1 then RunError(255);
  304. global_u8bit := byte(v);
  305. value_u8bit := b2;
  306. end;
  307. procedure proc_value_bool16bit_mixed(b1 : byte; v: wordbool; b2: byte);cdecl;
  308. begin
  309. global_u16bit := word(v);
  310. value_u8bit := b2;
  311. end;
  312. procedure proc_value_bool32bit_mixed(b1 : byte; v : longbool; b2: byte);cdecl;
  313. begin
  314. global_s32bit := longint(v);
  315. value_u8bit := b2;
  316. end;
  317. procedure proc_value_s32real_mixed(b1: byte; v : single; b2: byte);cdecl;
  318. begin
  319. global_s32real := v;
  320. value_u8bit := b2;
  321. end;
  322. procedure proc_value_s64real_mixed(b1: byte; v: double; b2: byte);cdecl;
  323. begin
  324. global_s64real:= v;
  325. value_u8bit := b2;
  326. end;
  327. procedure proc_value_pointerdef_mixed(b1: byte; p : pchar; b2: byte);cdecl;
  328. begin
  329. global_ptr:=p;
  330. value_u8bit := b2;
  331. end;
  332. procedure proc_value_procvardef_mixed(b1: byte; p : tprocedure; b2: byte);cdecl;
  333. begin
  334. global_proc:=p;
  335. value_u8bit := b2;
  336. end;
  337. procedure proc_value_smallrecord_mixed(b1: byte; smallrec : tsmallrecord; b2: byte);cdecl;
  338. begin
  339. if (smallrec.b = RESULT_U8BIT) and (smallrec.w = RESULT_U16BIT) then
  340. global_u8bit := RESULT_U8BIT;
  341. value_u8bit := b2;
  342. end;
  343. procedure proc_value_largerecord_mixed(b1: byte; largerec : tlargerecord; b2: byte);cdecl;
  344. begin
  345. if (largerec.b[1] = RESULT_U8BIT) and (largerec.b[2] = RESULT_U8BIT) then
  346. global_u8bit := RESULT_U8BIT;
  347. value_u8bit := b2;
  348. end;
  349. procedure proc_value_smallset_mixed(b1: byte; smallset : tsmallset; b2: byte);cdecl;
  350. begin
  351. if A_D in smallset then
  352. global_u8bit := RESULT_U8BIT;
  353. value_u8bit := b2;
  354. end;
  355. procedure proc_value_largeset_mixed(b1: byte; largeset : tlargeset; b2: byte);cdecl;
  356. begin
  357. if 'I' in largeset then
  358. global_u8bit := RESULT_U8BIT;
  359. value_u8bit := b2;
  360. end;
  361. procedure proc_value_smallstring_mixed(b1: byte; s:tsmallstring; b2: byte);cdecl;
  362. begin
  363. if s = RESULT_SMALLSTRING then
  364. global_u8bit := RESULT_u8BIT;
  365. value_u8bit := b2;
  366. end;
  367. procedure proc_value_bigstring_mixed(b1: byte; s:shortstring; b2: byte);cdecl;
  368. begin
  369. if s = RESULT_BIGSTRING then
  370. global_u8bit := RESULT_u8BIT;
  371. value_u8bit := b2;
  372. end;
  373. procedure proc_value_smallarray_mixed(b1: byte; arr : tsmallarray; b2: byte);cdecl;
  374. begin
  375. if arr[SMALL_INDEX] = RESULT_U8BIT then
  376. global_u8bit := RESULT_U8BIT;
  377. value_u8bit := b2;
  378. end;
  379. procedure proc_value_smallarray_open_mixed(b1: byte; arr : array of byte; b2: byte);cdecl;
  380. begin
  381. { form 0 to N-1 indexes in open arrays }
  382. if arr[SMALL_INDEX-1] = RESULT_U8BIT then
  383. global_u8bit := RESULT_U8BIT;
  384. value_u8bit := b2;
  385. end;
  386. {$ifndef tp}
  387. procedure proc_value_classrefdef_mixed(b1: byte; obj : tclass1; b2: byte);cdecl;
  388. begin
  389. global_class:=obj;
  390. value_u8bit := b2;
  391. end;
  392. procedure proc_value_s64bit_mixed(b1 : byte; v: int64; b2: byte);cdecl;
  393. begin
  394. global_s64bit:= v;
  395. value_u8bit := b2;
  396. end;
  397. {$endif}
  398. var
  399. failed: boolean;
  400. Begin
  401. {***************************** NORMAL TESTS *******************************}
  402. clear_globals;
  403. clear_values;
  404. failed:=false;
  405. { LOC_REGISTER }
  406. write('Value parameter test (src : LOC_REGISTER)...');
  407. proc_value_u8bit(getu8bit);
  408. if global_u8bit <> RESULT_U8BIT then
  409. failed:=true;
  410. proc_value_u16bit(getu16bit);
  411. if global_u16bit <> RESULT_U16BIT then
  412. failed:=true;
  413. proc_value_s32bit(gets32bit);
  414. if global_s32bit <> RESULT_S32BIT then
  415. failed:=true;
  416. {$ifndef tp}
  417. proc_value_s64bit(gets64bit);
  418. if global_s64bit <> RESULT_S64BIT then
  419. failed:=true;
  420. {$endif}
  421. if failed then
  422. fail
  423. else
  424. WriteLn('Passed!');
  425. { LOC_FPUREGISTER }
  426. clear_globals;
  427. clear_values;
  428. failed:=false;
  429. write('Value parameter test (src : LOC_FPUREGISTER)...');
  430. proc_value_s32real(gets32real);
  431. if trunc(global_s32real) <> trunc(RESULT_S32REAL) then
  432. failed:=true;
  433. proc_value_s64real(gets64real);
  434. if trunc(global_s64real) <> trunc(RESULT_S64REAL) then
  435. failed:=true;
  436. if failed then
  437. fail
  438. else
  439. WriteLn('Passed!');
  440. { LOC_MEM, LOC_REFERENCE orddef }
  441. clear_globals;
  442. clear_values;
  443. value_u8bit := RESULT_U8BIT;
  444. value_u16bit := RESULT_U16BIT;
  445. value_s32bit := RESULT_S32BIT;
  446. {$ifndef tp}
  447. value_s64bit := RESULT_S64BIT;
  448. {$endif}
  449. value_s32real := RESULT_S32REAL;
  450. value_s64real := RESULT_S64REAL;
  451. failed:=false;
  452. { LOC_REFERENCE }
  453. write('Value parameter test (src : LOC_REFERENCE (orddef/enumdef)))...');
  454. proc_value_u8bit(value_u8bit);
  455. if global_u8bit <> RESULT_U8BIT then
  456. failed:=true;
  457. proc_value_u16bit(value_u16bit);
  458. if global_u16bit <> RESULT_U16BIT then
  459. failed:=true;
  460. proc_value_s32bit(value_s32bit);
  461. if global_s32bit <> RESULT_S32BIT then
  462. failed:=true;
  463. {$ifndef tp}
  464. proc_value_s64bit(value_s64bit);
  465. if global_s64bit <> RESULT_S64BIT then
  466. failed:=true;
  467. {$endif}
  468. if failed then
  469. fail
  470. else
  471. WriteLn('Passed!');
  472. { LOC_REFERENCE }
  473. clear_globals;
  474. failed:=false;
  475. write('Value parameter test (src : LOC_REFERENCE (floatdef))...');
  476. proc_value_s32real(value_s32real);
  477. if trunc(global_s32real) <> trunc(RESULT_S32REAL) then
  478. failed:=true;
  479. proc_value_s64real(value_s64real);
  480. if trunc(global_s64real) <> trunc(RESULT_S64REAL) then
  481. failed:=true;
  482. if failed then
  483. fail
  484. else
  485. WriteLn('Passed!');
  486. write('Value parameter test (src : LOC_REFERENCE (pointer))...');
  487. clear_globals;
  488. clear_values;
  489. failed:=false;
  490. value_ptr := RESULT_PCHAR;
  491. proc_value_pointerdef(value_ptr);
  492. if global_ptr <> value_ptr then
  493. failed := true;
  494. value_proc := {$ifndef tp}@{$endif}testprocedure;
  495. proc_value_procvardef(value_proc);
  496. if {$ifndef fpc}@{$endif}value_proc <> {$ifndef fpc}@{$endif}global_proc then
  497. failed := true;
  498. {$ifndef tp}
  499. value_class := tclass1.create;
  500. proc_value_classrefdef(value_class);
  501. if value_class <> global_class then
  502. failed := true;
  503. value_class.destroy;
  504. {$endif}
  505. if failed then
  506. fail
  507. else
  508. WriteLn('Passed!');
  509. { LOC_REFERENCE }
  510. clear_globals;
  511. clear_values;
  512. failed:=false;
  513. value_u8bit := 0;
  514. write('Value parameter test (src : LOC_FLAGS (orddef)))...');
  515. proc_value_bool8bit(value_u8bit = 0);
  516. if global_u8bit <> RESULT_BOOL8BIT then
  517. failed:=true;
  518. {* IMPOSSIBLE TO GENERATE LOC_FLAGS WITH SIZE <> S_B ON VERSION 1.0.x
  519. proc_value_bool16bit(value_s64bit < 0);
  520. if global_u16bit <> RESULT_BOOL16BIT then
  521. failed:=true;
  522. proc_value_bool32bit(bool1 and bool2);
  523. if global_s32bit <> RESULT_BOOL32BIT then
  524. failed:=true;*}
  525. if failed then
  526. fail
  527. else
  528. WriteLn('Passed!');
  529. {$ifndef tp}
  530. clear_globals;
  531. clear_values;
  532. failed:=false;
  533. write('Value parameter test (src : LOC_JUMP (orddef)))...');
  534. proc_value_bool8bit(value_s64bit = 0);
  535. if global_u8bit <> RESULT_BOOL8BIT then
  536. failed:=true;
  537. {* IMPOSSIBLE TO GENERATE LOC_JUMP WITH SIZE <> S_B ON VERSION 1.0.x
  538. proc_value_bool16bit(value_s64bit < 0);
  539. if global_u16bit <> RESULT_BOOL16BIT then
  540. failed:=true;
  541. proc_value_bool32bit(bool1 and bool2);
  542. if global_s32bit <> RESULT_BOOL32BIT then
  543. failed:=true;*}
  544. if failed then
  545. fail
  546. else
  547. WriteLn('Passed!');
  548. {$endif}
  549. { arraydef,
  550. recorddef,
  551. objectdef,
  552. stringdef,
  553. setdef : all considered the same by code generator.
  554. }
  555. write('Value parameter test (src : LOC_REFERENCE (recorddef)))...');
  556. clear_globals;
  557. clear_values;
  558. failed := false;
  559. value_smallrec.b := RESULT_U8BIT;
  560. value_smallrec.w := RESULT_U16BIT;
  561. proc_value_smallrecord(value_smallrec);
  562. if global_u8bit <> RESULT_U8BIT then
  563. failed := true;
  564. clear_globals;
  565. clear_values;
  566. fillchar(value_largerec,sizeof(value_largerec),RESULT_U8BIT);
  567. proc_value_largerecord(value_largerec);
  568. if global_u8bit <> RESULT_U8BIT then
  569. failed := true;
  570. if failed then
  571. fail
  572. else
  573. WriteLn('Passed!');
  574. write('Value parameter test (src : LOC_REFERENCE (setdef)))...');
  575. clear_globals;
  576. clear_values;
  577. failed := false;
  578. value_smallset := [A_A,A_D];
  579. proc_value_smallset(value_smallset);
  580. if global_u8bit <> RESULT_U8BIT then
  581. failed := true;
  582. clear_globals;
  583. clear_values;
  584. value_largeset := ['I'];
  585. proc_value_largeset(value_largeset);
  586. if global_u8bit <> RESULT_U8BIT then
  587. failed := true;
  588. if failed then
  589. fail
  590. else
  591. WriteLn('Passed!');
  592. write('Value parameter test (src : LOC_REFERENCE (stringdef)))...');
  593. clear_globals;
  594. clear_values;
  595. failed := false;
  596. value_smallstring := RESULT_SMALLSTRING;
  597. proc_value_smallstring(value_smallstring);
  598. if global_u8bit <> RESULT_U8BIT then
  599. failed := true;
  600. clear_globals;
  601. clear_values;
  602. value_bigstring := RESULT_BIGSTRING;
  603. proc_value_bigstring(value_bigstring);
  604. if global_u8bit <> RESULT_U8BIT then
  605. failed := true;
  606. if failed then
  607. fail
  608. else
  609. WriteLn('Passed!');
  610. { open array by value with cdecl modifier!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  611. { DON'T KNOW WHY/HOW TO TEST!!!!! }
  612. write('Value parameter test (src : LOC_REFERENCE (arraydef)))...');
  613. clear_globals;
  614. clear_values;
  615. failed:=false;
  616. fillchar(value_smallarray,sizeof(value_smallarray),#0);
  617. value_smallarray[SMALL_INDEX] := RESULT_U8BIT;
  618. proc_value_smallarray(value_smallarray);
  619. if global_u8bit <> RESULT_U8BIT then
  620. failed := true;
  621. clear_globals;
  622. clear_values;
  623. fillchar(value_smallarray,sizeof(value_smallarray),#0);
  624. value_smallarray[SMALL_INDEX] := RESULT_U8BIT;
  625. proc_value_smallarray_open(value_smallarray);
  626. if global_u8bit <> RESULT_U8BIT then
  627. failed := true;
  628. if failed then
  629. fail
  630. else
  631. WriteLn('Passed!');
  632. {***************************** MIXED TESTS *******************************}
  633. clear_globals;
  634. clear_values;
  635. failed:=false;
  636. { LOC_REGISTER }
  637. write('Mixed value parameter test (src : LOC_REGISTER)...');
  638. proc_value_u8bit_mixed(byte(NOT RESULT_U8BIT),getu8bit,RESULT_U8BIT);
  639. if global_u8bit <> RESULT_U8BIT then
  640. failed:=true;
  641. if value_u8bit <> RESULT_U8BIT then
  642. failed := true;
  643. proc_value_u16bit_mixed(byte(NOT RESULT_U8BIT),getu16bit,RESULT_U8BIT);
  644. if global_u16bit <> RESULT_U16BIT then
  645. failed:=true;
  646. if value_u8bit <> RESULT_U8BIT then
  647. failed := true;
  648. proc_value_s32bit_mixed(byte(NOT RESULT_U8BIT),gets32bit, RESULT_U8BIT);
  649. if global_s32bit <> RESULT_S32BIT then
  650. failed:=true;
  651. if value_u8bit <> RESULT_U8BIT then
  652. failed := true;
  653. {$ifndef tp}
  654. proc_value_s64bit_mixed(byte(NOT RESULT_U8BIT),gets64bit,RESULT_U8BIT);
  655. if global_s64bit <> RESULT_S64BIT then
  656. failed:=true;
  657. {$endif}
  658. if value_u8bit <> RESULT_U8BIT then
  659. failed := true;
  660. if failed then
  661. fail
  662. else
  663. WriteLn('Passed!');
  664. { LOC_FPUREGISTER }
  665. clear_globals;
  666. clear_values;
  667. failed:=false;
  668. write('Mixed value parameter test (src : LOC_FPUREGISTER)...');
  669. proc_value_s32real_mixed(byte(NOT RESULT_U8BIT), gets32real, RESULT_U8BIT);
  670. if value_u8bit <> RESULT_U8BIT then
  671. failed := true;
  672. if trunc(global_s32real) <> trunc(RESULT_S32REAL) then
  673. failed:=true;
  674. proc_value_s64real_mixed(byte(NOT RESULT_U8BIT),gets64real,RESULT_U8BIT);
  675. if value_u8bit <> RESULT_U8BIT then
  676. failed := true;
  677. if trunc(global_s64real) <> trunc(RESULT_S64REAL) then
  678. failed:=true;
  679. if failed then
  680. fail
  681. else
  682. WriteLn('Passed!');
  683. { LOC_MEM, LOC_REFERENCE orddef }
  684. clear_globals;
  685. clear_values;
  686. value_u8bit := RESULT_U8BIT;
  687. value_u16bit := RESULT_U16BIT;
  688. value_s32bit := RESULT_S32BIT;
  689. {$ifndef tp}
  690. value_s64bit := RESULT_S64BIT;
  691. {$endif}
  692. value_s32real := RESULT_S32REAL;
  693. value_s64real := RESULT_S64REAL;
  694. failed:=false;
  695. { LOC_REFERENCE }
  696. write('Mixed value parameter test (src : LOC_REFERENCE (orddef/enumdef)))...');
  697. proc_value_u8bit_mixed(byte(NOT RESULT_U8BIT),value_u8bit, RESULT_U8BIT);
  698. if global_u8bit <> RESULT_U8BIT then
  699. failed:=true;
  700. if value_u8bit <> RESULT_U8BIT then
  701. failed := true;
  702. proc_value_u16bit_mixed(byte(NOT RESULT_U8BIT),value_u16bit, RESULT_U8BIT);
  703. if global_u16bit <> RESULT_U16BIT then
  704. failed:=true;
  705. if value_u8bit <> RESULT_U8BIT then
  706. failed := true;
  707. proc_value_s32bit_mixed(byte(NOT RESULT_U8BIT),value_s32bit, RESULT_U8BIT);
  708. if global_s32bit <> RESULT_S32BIT then
  709. failed:=true;
  710. if value_u8bit <> RESULT_U8BIT then
  711. failed := true;
  712. {$ifndef tp}
  713. proc_value_s64bit_mixed(byte(NOT RESULT_U8BIT), value_s64bit, RESULT_U8BIT);
  714. if global_s64bit <> RESULT_S64BIT then
  715. failed:=true;
  716. {$endif}
  717. if value_u8bit <> RESULT_U8BIT then
  718. failed := true;
  719. if failed then
  720. fail
  721. else
  722. WriteLn('Passed!');
  723. { LOC_REFERENCE }
  724. clear_globals;
  725. failed:=false;
  726. write('Mixed value parameter test (src : LOC_REFERENCE (floatdef))...');
  727. proc_value_s32real_mixed(byte(NOT RESULT_U8BIT), value_s32real, RESULT_U8BIT);
  728. if trunc(global_s32real) <> trunc(RESULT_S32REAL) then
  729. failed:=true;
  730. if value_u8bit <> RESULT_U8BIT then
  731. failed := true;
  732. proc_value_s64real_mixed(byte(NOT RESULT_U8BIT), value_s64real, RESULT_U8BIT);
  733. if trunc(global_s64real) <> trunc(RESULT_S64REAL) then
  734. failed:=true;
  735. if value_u8bit <> RESULT_U8BIT then
  736. failed := true;
  737. if failed then
  738. fail
  739. else
  740. WriteLn('Passed!');
  741. write('Mixed value parameter test (src : LOC_REFERENCE (pointer))...');
  742. clear_globals;
  743. clear_values;
  744. failed:=false;
  745. value_ptr := RESULT_PCHAR;
  746. proc_value_pointerdef_mixed(byte(NOT RESULT_U8BIT), value_ptr, RESULT_U8BIT);
  747. if global_ptr <> value_ptr then
  748. failed := true;
  749. if value_u8bit <> RESULT_U8BIT then
  750. failed := true;
  751. value_proc := {$ifndef tp}@{$endif}testprocedure;
  752. proc_value_procvardef_mixed(byte(NOT RESULT_U8BIT), value_proc, RESULT_U8BIT);
  753. if {$ifndef fpc}@{$endif}value_proc <> {$ifndef fpc}@{$endif}global_proc then
  754. failed := true;
  755. {$ifndef tp}
  756. value_class := tclass1.create;
  757. proc_value_classrefdef_mixed(byte(NOT RESULT_U8BIT), value_class, RESULT_U8BIT);
  758. if value_class <> global_class then
  759. failed := true;
  760. if value_u8bit <> RESULT_U8BIT then
  761. failed := true;
  762. value_class.destroy;
  763. {$endif}
  764. if failed then
  765. fail
  766. else
  767. WriteLn('Passed!');
  768. { LOC_REFERENCE }
  769. clear_globals;
  770. clear_values;
  771. failed:=false;
  772. value_u8bit := 0;
  773. write('Mixed value parameter test (src : LOC_FLAGS (orddef)))...');
  774. proc_value_bool8bit_mixed(byte(NOT RESULT_U8BIT), value_u8bit = 0, RESULT_U8BIT);
  775. if global_u8bit <> RESULT_BOOL8BIT then
  776. failed:=true;
  777. if value_u8bit <> RESULT_U8BIT then
  778. failed := true;
  779. {* IMPOSSIBLE TO GENERATE LOC_FLAGS WITH SIZE <> S_B ON VERSION 1.0.x
  780. proc_value_bool16bit(value_s64bit < 0);
  781. if global_u16bit <> RESULT_BOOL16BIT then
  782. failed:=true;
  783. proc_value_bool32bit(bool1 and bool2);
  784. if global_s32bit <> RESULT_BOOL32BIT then
  785. failed:=true;*}
  786. if failed then
  787. fail
  788. else
  789. WriteLn('Passed!');
  790. {$ifndef tp}
  791. clear_globals;
  792. clear_values;
  793. failed:=false;
  794. write('Mixed value parameter test (src : LOC_JUMP (orddef)))...');
  795. proc_value_bool8bit_mixed(byte(NOT RESULT_U8BIT), value_s64bit = 0, RESULT_U8BIT);
  796. if global_u8bit <> RESULT_BOOL8BIT then
  797. failed:=true;
  798. if value_u8bit <> RESULT_U8BIT then
  799. failed := true;
  800. {* IMPOSSIBLE TO GENERATE LOC_JUMP WITH SIZE <> S_B ON VERSION 1.0.x
  801. proc_value_bool16bit(value_s64bit < 0);
  802. if global_u16bit <> RESULT_BOOL16BIT then
  803. failed:=true;
  804. proc_value_bool32bit(bool1 and bool2);
  805. if global_s32bit <> RESULT_BOOL32BIT then
  806. failed:=true;*}
  807. if failed then
  808. fail
  809. else
  810. WriteLn('Passed!');
  811. {$endif}
  812. { arraydef,
  813. recorddef,
  814. objectdef,
  815. stringdef,
  816. setdef : all considered the same by code generator.
  817. }
  818. write('Mixed value parameter test (src : LOC_REFERENCE (recorddef)))...');
  819. clear_globals;
  820. clear_values;
  821. failed := false;
  822. value_smallrec.b := RESULT_U8BIT;
  823. value_smallrec.w := RESULT_U16BIT;
  824. proc_value_smallrecord_mixed(byte(NOT RESULT_U8BIT), value_smallrec, RESULT_U8BIT);
  825. if global_u8bit <> RESULT_U8BIT then
  826. failed := true;
  827. if value_u8bit <> RESULT_U8BIT then
  828. failed := true;
  829. clear_globals;
  830. clear_values;
  831. fillchar(value_largerec,sizeof(value_largerec),RESULT_U8BIT);
  832. proc_value_largerecord_mixed(byte(NOT RESULT_U8BIT), value_largerec, RESULT_U8BIT);
  833. if global_u8bit <> RESULT_U8BIT then
  834. failed := true;
  835. if value_u8bit <> RESULT_U8BIT then
  836. failed := true;
  837. if failed then
  838. fail
  839. else
  840. WriteLn('Passed!');
  841. write('Mixed value parameter test (src : LOC_REFERENCE (setdef)))...');
  842. clear_globals;
  843. clear_values;
  844. failed := false;
  845. value_smallset := [A_A,A_D];
  846. proc_value_smallset_mixed(byte(NOT RESULT_U8BIT), value_smallset, RESULT_U8BIT);
  847. if global_u8bit <> RESULT_U8BIT then
  848. failed := true;
  849. if value_u8bit <> RESULT_U8BIT then
  850. failed := true;
  851. clear_globals;
  852. clear_values;
  853. value_largeset := ['I'];
  854. proc_value_largeset_mixed(byte(NOT RESULT_U8BIT), value_largeset, RESULT_U8BIT);
  855. if global_u8bit <> RESULT_U8BIT then
  856. failed := true;
  857. if value_u8bit <> RESULT_U8BIT then
  858. failed := true;
  859. if failed then
  860. fail
  861. else
  862. WriteLn('Passed!');
  863. write('Mixed value parameter test (src : LOC_REFERENCE (stringdef)))...');
  864. clear_globals;
  865. clear_values;
  866. failed := false;
  867. value_smallstring := RESULT_SMALLSTRING;
  868. proc_value_smallstring_mixed(byte(NOT RESULT_U8BIT), value_smallstring, RESULT_U8BIT);
  869. if global_u8bit <> RESULT_U8BIT then
  870. failed := true;
  871. if value_u8bit <> RESULT_U8BIT then
  872. failed := true;
  873. clear_globals;
  874. clear_values;
  875. value_bigstring := RESULT_BIGSTRING;
  876. proc_value_bigstring_mixed(byte(NOT RESULT_U8BIT), value_bigstring, RESULT_U8BIT);
  877. if global_u8bit <> RESULT_U8BIT then
  878. failed := true;
  879. if value_u8bit <> RESULT_U8BIT then
  880. failed := true;
  881. if failed then
  882. fail
  883. else
  884. WriteLn('Passed!');
  885. { open array by value with cdecl modifier!!!!!!!!!!!!!!!!!!!!!!!!!!!}
  886. { DON'T KNOW WHY/HOW TO TEST!!!!! }
  887. write('Mixed value parameter test (src : LOC_REFERENCE (arraydef)))...');
  888. clear_globals;
  889. clear_values;
  890. failed:=false;
  891. fillchar(value_smallarray,sizeof(value_smallarray),#0);
  892. value_smallarray[SMALL_INDEX] := RESULT_U8BIT;
  893. proc_value_smallarray_mixed(byte(NOT RESULT_U8BIT), value_smallarray, RESULT_U8BIT);
  894. if global_u8bit <> RESULT_U8BIT then
  895. failed := true;
  896. if value_u8bit <> RESULT_U8BIT then
  897. failed := true;
  898. clear_globals;
  899. clear_values;
  900. fillchar(value_smallarray,sizeof(value_smallarray),#0);
  901. value_smallarray[SMALL_INDEX] := RESULT_U8BIT;
  902. proc_value_smallarray_open_mixed(byte(NOT RESULT_U8BIT), value_smallarray, RESULT_U8BIT);
  903. if global_u8bit <> RESULT_U8BIT then
  904. failed := true;
  905. if value_u8bit <> RESULT_U8BIT then
  906. failed := true;
  907. if failed then
  908. fail
  909. else
  910. WriteLn('Passed!');
  911. end.
  912. {
  913. $Log$
  914. Revision 1.6 2003-04-22 10:24:29 florian
  915. * fixed defines for powerpc
  916. Revision 1.5 2002/11/09 21:47:37 carl
  917. + updated tests for correct parsing (array of const now allowed with high!)
  918. Revision 1.4 2002/09/22 09:08:41 carl
  919. * gets64bit was not returning an int64!
  920. Revision 1.3 2002/09/07 15:40:55 peter
  921. * old logs removed and tabs fixed
  922. Revision 1.2 2002/05/13 13:45:37 peter
  923. * updated to compile tests with kylix
  924. Revision 1.1 2002/04/13 17:49:45 carl
  925. + value parameter passing for different calling conventions
  926. }