tcalval3.pp 31 KB

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