tcalval4.pp 27 KB

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