tcalval4.pp 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  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.
  916. {
  917. $Log$
  918. Revision 1.7 2004-03-27 19:34:13 florian
  919. * alignment fixed
  920. Revision 1.6 2003/04/22 10:24:29 florian
  921. * fixed defines for powerpc
  922. Revision 1.5 2002/11/09 21:47:37 carl
  923. + updated tests for correct parsing (array of const now allowed with high!)
  924. Revision 1.4 2002/09/22 09:08:41 carl
  925. * gets64bit was not returning an int64!
  926. Revision 1.3 2002/09/07 15:40:55 peter
  927. * old logs removed and tabs fixed
  928. Revision 1.2 2002/05/13 13:45:37 peter
  929. * updated to compile tests with kylix
  930. Revision 1.1 2002/04/13 17:49:45 carl
  931. + value parameter passing for different calling conventions
  932. }