tcalval9.pp 32 KB

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