tcalval1.pp 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  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 std calling convention) }
  19. {****************************************************************}
  20. program tcalval1;
  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);
  193. begin
  194. global_u8bit := v;
  195. end;
  196. procedure proc_value_u16bit(v: word);
  197. begin
  198. global_u16bit := v;
  199. end;
  200. procedure proc_value_s32bit(v : longint);
  201. begin
  202. global_s32bit := v;
  203. end;
  204. procedure proc_value_bool8bit(v: boolean);
  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);
  211. begin
  212. global_u16bit := word(v);
  213. end;
  214. procedure proc_value_bool32bit(v : longbool);
  215. begin
  216. global_s32bit := longint(v);
  217. end;
  218. procedure proc_value_s32real(v : single);
  219. begin
  220. global_s32real := v;
  221. end;
  222. procedure proc_value_s64real(v: double);
  223. begin
  224. global_s64real:= v;
  225. end;
  226. procedure proc_value_pointerdef(p : pchar);
  227. begin
  228. global_ptr:=p;
  229. end;
  230. procedure proc_value_procvardef(p : tprocedure);
  231. begin
  232. global_proc:=p;
  233. end;
  234. procedure proc_value_smallrecord(smallrec : tsmallrecord);
  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);
  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);
  245. begin
  246. if A_D in smallset then
  247. global_u8bit := RESULT_U8BIT;
  248. end;
  249. procedure proc_value_largeset(largeset : tlargeset);
  250. begin
  251. if 'I' in largeset then
  252. global_u8bit := RESULT_U8BIT;
  253. end;
  254. procedure proc_value_smallstring(s:tsmallstring);
  255. begin
  256. if s = RESULT_SMALLSTRING then
  257. global_u8bit := RESULT_u8BIT;
  258. end;
  259. procedure proc_value_bigstring(s:shortstring);
  260. begin
  261. if s = RESULT_BIGSTRING then
  262. global_u8bit := RESULT_u8BIT;
  263. end;
  264. procedure proc_value_smallarray(arr : tsmallarray);
  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);
  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);
  277. begin
  278. global_class:=obj;
  279. end;
  280. procedure proc_value_smallarray_const_1(arr : array of const);
  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);
  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);
  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);
  317. begin
  318. global_u8bit := v;
  319. value_u8bit := b2;
  320. end;
  321. procedure proc_value_u16bit_mixed(b1: byte; v: word; b2: byte);
  322. begin
  323. global_u16bit := v;
  324. value_u8bit := b2;
  325. end;
  326. procedure proc_value_s32bit_mixed(b1 : byte; v : longint; b2: byte);
  327. begin
  328. global_s32bit := v;
  329. value_u8bit := b2;
  330. end;
  331. procedure proc_value_bool8bit_mixed(b1: byte; v: boolean; b2: byte);
  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);
  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);
  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);
  349. begin
  350. global_s32real := v;
  351. value_u8bit := b2;
  352. end;
  353. procedure proc_value_s64real_mixed(b1: byte; v: double; b2: byte);
  354. begin
  355. global_s64real:= v;
  356. value_u8bit := b2;
  357. end;
  358. procedure proc_value_pointerdef_mixed(b1: byte; p : pchar; b2: byte);
  359. begin
  360. global_ptr:=p;
  361. value_u8bit := b2;
  362. end;
  363. procedure proc_value_procvardef_mixed(b1: byte; p : tprocedure; b2: byte);
  364. begin
  365. global_proc:=p;
  366. value_u8bit := b2;
  367. end;
  368. procedure proc_value_smallrecord_mixed(b1: byte; smallrec : tsmallrecord; b2: byte);
  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);
  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);
  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);
  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);
  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);
  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);
  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);
  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);
  419. begin
  420. global_class:=obj;
  421. value_u8bit := b2;
  422. end;
  423. procedure proc_value_s64bit_mixed(b1 : byte; v: int64; b2: byte);
  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);
  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);
  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:37 peter
  1059. * updated to compile tests with kylix
  1060. Revision 1.1 2002/04/10 16:33:18 carl
  1061. + first tries at first calln testing
  1062. }