tcalval8.pp 32 KB

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