tcalval7.pp 33 KB

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