max_stars_repo_path
stringlengths
4
261
max_stars_repo_name
stringlengths
6
106
max_stars_count
int64
0
38.8k
id
stringlengths
1
6
text
stringlengths
7
1.05M
archive/agda-3/src/Test/ProblemWithSym.agda
m0davis/oscar
0
6577
{-# OPTIONS --allow-unsolved-metas #-} open import Everything module Test.ProblemWithSym where module _ {a} {A : ¶ → Set a} where private AList = Descender⟨ A ⟩ instance test-works : Transassociativity.class (flip AList) Proposequality transitivity test-works .⋆ f g h = symmetry (transassociativity h g f) test-fails : Transassociativity.class (flip AList) Proposequality transitivity test-fails .⋆ f g h = symmetry (transassociativity h g f) -- FIXME this was problematic when using a version of symmetry which did not include a negative argument in .⋆ It deserves explanation. test-hole : Transassociativity.class (flip AList) Proposequality transitivity test-hole .⋆ f g h = symmetry {!!}
test/mw.asm
Kylogias/jdh-8
911
85821
; TEST ; a = 1 ; b = 2 ; c = 3 ; d = 1 mw a, 1 mw b, 2 mw c, 3 mw d, a mw a, d halt
oeis/026/A026006.asm
neoneye/loda-programs
11
14410
; A026006: Expansion of 1/((1-2x)(1-5x)(1-8x)(1-12x)). ; Submitted by <NAME> ; 1,27,483,7271,100083,1308831,16594651,206375367,2535071715,30892653935,374502469419,4524435989463,54536889623347,656393971978239,7892348208238587,94833193717469159,1138998700671586179 mov $1,1 mov $2,$0 mov $3,$0 lpb $2 mov $0,$3 sub $2,1 sub $0,$2 seq $0,16320 ; Expansion of 1/((1-2x)(1-8x)(1-12x)). mul $1,5 add $1,$0 lpe mov $0,$1
mc-sema/validator/x86_64/tests/FICOM_32m.asm
randolphwong/mcsema
2
245327
BITS 64 ;TEST_FILE_META_BEGIN ;TEST_TYPE=TEST_F ;TEST_IGNOREFLAGS= ;TEST_FILE_META_END ; set up st0 to be 3.141593 FLD1 ;TEST_BEGIN_RECORDING lea rdi, [rsp-08] mov dword [rdi], 0x1 FICOM dword [rdi] ;TEST_END_RECORDING
user/ln.asm
Vidhi1109/Modified-XV6
0
99051
<filename>user/ln.asm user/_ln: file format elf64-littleriscv Disassembly of section .text: 0000000000000000 <main>: #include "kernel/stat.h" #include "user/user.h" int main(int argc, char *argv[]) { 0: 1101 addi sp,sp,-32 2: ec06 sd ra,24(sp) 4: e822 sd s0,16(sp) 6: e426 sd s1,8(sp) 8: 1000 addi s0,sp,32 if(argc != 3){ a: 478d li a5,3 c: 02f50063 beq a0,a5,2c <main+0x2c> fprintf(2, "Usage: ln old new\n"); 10: 00000597 auipc a1,0x0 14: 7f058593 addi a1,a1,2032 # 800 <malloc+0xea> 18: 4509 li a0,2 1a: 00000097 auipc ra,0x0 1e: 616080e7 jalr 1558(ra) # 630 <fprintf> exit(1); 22: 4505 li a0,1 24: 00000097 auipc ra,0x0 28: 2a8080e7 jalr 680(ra) # 2cc <exit> 2c: 84ae mv s1,a1 } if(link(argv[1], argv[2]) < 0) 2e: 698c ld a1,16(a1) 30: 6488 ld a0,8(s1) 32: 00000097 auipc ra,0x0 36: 2fa080e7 jalr 762(ra) # 32c <link> 3a: 00054763 bltz a0,48 <main+0x48> fprintf(2, "link %s %s: failed\n", argv[1], argv[2]); exit(0); 3e: 4501 li a0,0 40: 00000097 auipc ra,0x0 44: 28c080e7 jalr 652(ra) # 2cc <exit> fprintf(2, "link %s %s: failed\n", argv[1], argv[2]); 48: 6894 ld a3,16(s1) 4a: 6490 ld a2,8(s1) 4c: 00000597 auipc a1,0x0 50: 7cc58593 addi a1,a1,1996 # 818 <malloc+0x102> 54: 4509 li a0,2 56: 00000097 auipc ra,0x0 5a: 5da080e7 jalr 1498(ra) # 630 <fprintf> 5e: b7c5 j 3e <main+0x3e> 0000000000000060 <strcpy>: #include "kernel/fcntl.h" #include "user/user.h" char* strcpy(char *s, const char *t) { 60: 1141 addi sp,sp,-16 62: e422 sd s0,8(sp) 64: 0800 addi s0,sp,16 char *os; os = s; while((*s++ = *t++) != 0) 66: 87aa mv a5,a0 68: 0585 addi a1,a1,1 6a: 0785 addi a5,a5,1 6c: fff5c703 lbu a4,-1(a1) 70: fee78fa3 sb a4,-1(a5) 74: fb75 bnez a4,68 <strcpy+0x8> ; return os; } 76: 6422 ld s0,8(sp) 78: 0141 addi sp,sp,16 7a: 8082 ret 000000000000007c <strcmp>: int strcmp(const char *p, const char *q) { 7c: 1141 addi sp,sp,-16 7e: e422 sd s0,8(sp) 80: 0800 addi s0,sp,16 while(*p && *p == *q) 82: 00054783 lbu a5,0(a0) 86: cb91 beqz a5,9a <strcmp+0x1e> 88: 0005c703 lbu a4,0(a1) 8c: 00f71763 bne a4,a5,9a <strcmp+0x1e> p++, q++; 90: 0505 addi a0,a0,1 92: 0585 addi a1,a1,1 while(*p && *p == *q) 94: 00054783 lbu a5,0(a0) 98: fbe5 bnez a5,88 <strcmp+0xc> return (uchar)*p - (uchar)*q; 9a: 0005c503 lbu a0,0(a1) } 9e: 40a7853b subw a0,a5,a0 a2: 6422 ld s0,8(sp) a4: 0141 addi sp,sp,16 a6: 8082 ret 00000000000000a8 <strlen>: uint strlen(const char *s) { a8: 1141 addi sp,sp,-16 aa: e422 sd s0,8(sp) ac: 0800 addi s0,sp,16 int n; for(n = 0; s[n]; n++) ae: 00054783 lbu a5,0(a0) b2: cf91 beqz a5,ce <strlen+0x26> b4: 0505 addi a0,a0,1 b6: 87aa mv a5,a0 b8: 4685 li a3,1 ba: 9e89 subw a3,a3,a0 bc: 00f6853b addw a0,a3,a5 c0: 0785 addi a5,a5,1 c2: fff7c703 lbu a4,-1(a5) c6: fb7d bnez a4,bc <strlen+0x14> ; return n; } c8: 6422 ld s0,8(sp) ca: 0141 addi sp,sp,16 cc: 8082 ret for(n = 0; s[n]; n++) ce: 4501 li a0,0 d0: bfe5 j c8 <strlen+0x20> 00000000000000d2 <memset>: void* memset(void *dst, int c, uint n) { d2: 1141 addi sp,sp,-16 d4: e422 sd s0,8(sp) d6: 0800 addi s0,sp,16 char *cdst = (char *) dst; int i; for(i = 0; i < n; i++){ d8: ca19 beqz a2,ee <memset+0x1c> da: 87aa mv a5,a0 dc: 1602 slli a2,a2,0x20 de: 9201 srli a2,a2,0x20 e0: 00a60733 add a4,a2,a0 cdst[i] = c; e4: 00b78023 sb a1,0(a5) for(i = 0; i < n; i++){ e8: 0785 addi a5,a5,1 ea: fee79de3 bne a5,a4,e4 <memset+0x12> } return dst; } ee: 6422 ld s0,8(sp) f0: 0141 addi sp,sp,16 f2: 8082 ret 00000000000000f4 <strchr>: char* strchr(const char *s, char c) { f4: 1141 addi sp,sp,-16 f6: e422 sd s0,8(sp) f8: 0800 addi s0,sp,16 for(; *s; s++) fa: 00054783 lbu a5,0(a0) fe: cb99 beqz a5,114 <strchr+0x20> if(*s == c) 100: 00f58763 beq a1,a5,10e <strchr+0x1a> for(; *s; s++) 104: 0505 addi a0,a0,1 106: 00054783 lbu a5,0(a0) 10a: fbfd bnez a5,100 <strchr+0xc> return (char*)s; return 0; 10c: 4501 li a0,0 } 10e: 6422 ld s0,8(sp) 110: 0141 addi sp,sp,16 112: 8082 ret return 0; 114: 4501 li a0,0 116: bfe5 j 10e <strchr+0x1a> 0000000000000118 <gets>: char* gets(char *buf, int max) { 118: 711d addi sp,sp,-96 11a: ec86 sd ra,88(sp) 11c: e8a2 sd s0,80(sp) 11e: e4a6 sd s1,72(sp) 120: e0ca sd s2,64(sp) 122: fc4e sd s3,56(sp) 124: f852 sd s4,48(sp) 126: f456 sd s5,40(sp) 128: f05a sd s6,32(sp) 12a: ec5e sd s7,24(sp) 12c: 1080 addi s0,sp,96 12e: 8baa mv s7,a0 130: 8a2e mv s4,a1 int i, cc; char c; for(i=0; i+1 < max; ){ 132: 892a mv s2,a0 134: 4481 li s1,0 cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; if(c == '\n' || c == '\r') 136: 4aa9 li s5,10 138: 4b35 li s6,13 for(i=0; i+1 < max; ){ 13a: 89a6 mv s3,s1 13c: 2485 addiw s1,s1,1 13e: 0344d863 bge s1,s4,16e <gets+0x56> cc = read(0, &c, 1); 142: 4605 li a2,1 144: faf40593 addi a1,s0,-81 148: 4501 li a0,0 14a: 00000097 auipc ra,0x0 14e: 19a080e7 jalr 410(ra) # 2e4 <read> if(cc < 1) 152: 00a05e63 blez a0,16e <gets+0x56> buf[i++] = c; 156: faf44783 lbu a5,-81(s0) 15a: 00f90023 sb a5,0(s2) if(c == '\n' || c == '\r') 15e: 01578763 beq a5,s5,16c <gets+0x54> 162: 0905 addi s2,s2,1 164: fd679be3 bne a5,s6,13a <gets+0x22> for(i=0; i+1 < max; ){ 168: 89a6 mv s3,s1 16a: a011 j 16e <gets+0x56> 16c: 89a6 mv s3,s1 break; } buf[i] = '\0'; 16e: 99de add s3,s3,s7 170: 00098023 sb zero,0(s3) return buf; } 174: 855e mv a0,s7 176: 60e6 ld ra,88(sp) 178: 6446 ld s0,80(sp) 17a: 64a6 ld s1,72(sp) 17c: 6906 ld s2,64(sp) 17e: 79e2 ld s3,56(sp) 180: 7a42 ld s4,48(sp) 182: 7aa2 ld s5,40(sp) 184: 7b02 ld s6,32(sp) 186: 6be2 ld s7,24(sp) 188: 6125 addi sp,sp,96 18a: 8082 ret 000000000000018c <stat>: int stat(const char *n, struct stat *st) { 18c: 1101 addi sp,sp,-32 18e: ec06 sd ra,24(sp) 190: e822 sd s0,16(sp) 192: e426 sd s1,8(sp) 194: e04a sd s2,0(sp) 196: 1000 addi s0,sp,32 198: 892e mv s2,a1 int fd; int r; fd = open(n, O_RDONLY); 19a: 4581 li a1,0 19c: 00000097 auipc ra,0x0 1a0: 170080e7 jalr 368(ra) # 30c <open> if(fd < 0) 1a4: 02054563 bltz a0,1ce <stat+0x42> 1a8: 84aa mv s1,a0 return -1; r = fstat(fd, st); 1aa: 85ca mv a1,s2 1ac: 00000097 auipc ra,0x0 1b0: 178080e7 jalr 376(ra) # 324 <fstat> 1b4: 892a mv s2,a0 close(fd); 1b6: 8526 mv a0,s1 1b8: 00000097 auipc ra,0x0 1bc: 13c080e7 jalr 316(ra) # 2f4 <close> return r; } 1c0: 854a mv a0,s2 1c2: 60e2 ld ra,24(sp) 1c4: 6442 ld s0,16(sp) 1c6: 64a2 ld s1,8(sp) 1c8: 6902 ld s2,0(sp) 1ca: 6105 addi sp,sp,32 1cc: 8082 ret return -1; 1ce: 597d li s2,-1 1d0: bfc5 j 1c0 <stat+0x34> 00000000000001d2 <atoi>: int atoi(const char *s) { 1d2: 1141 addi sp,sp,-16 1d4: e422 sd s0,8(sp) 1d6: 0800 addi s0,sp,16 int n; n = 0; while('0' <= *s && *s <= '9') 1d8: 00054683 lbu a3,0(a0) 1dc: fd06879b addiw a5,a3,-48 1e0: 0ff7f793 zext.b a5,a5 1e4: 4625 li a2,9 1e6: 02f66863 bltu a2,a5,216 <atoi+0x44> 1ea: 872a mv a4,a0 n = 0; 1ec: 4501 li a0,0 n = n*10 + *s++ - '0'; 1ee: 0705 addi a4,a4,1 1f0: 0025179b slliw a5,a0,0x2 1f4: 9fa9 addw a5,a5,a0 1f6: 0017979b slliw a5,a5,0x1 1fa: 9fb5 addw a5,a5,a3 1fc: fd07851b addiw a0,a5,-48 while('0' <= *s && *s <= '9') 200: 00074683 lbu a3,0(a4) 204: fd06879b addiw a5,a3,-48 208: 0ff7f793 zext.b a5,a5 20c: fef671e3 bgeu a2,a5,1ee <atoi+0x1c> return n; } 210: 6422 ld s0,8(sp) 212: 0141 addi sp,sp,16 214: 8082 ret n = 0; 216: 4501 li a0,0 218: bfe5 j 210 <atoi+0x3e> 000000000000021a <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 21a: 1141 addi sp,sp,-16 21c: e422 sd s0,8(sp) 21e: 0800 addi s0,sp,16 char *dst; const char *src; dst = vdst; src = vsrc; if (src > dst) { 220: 02b57463 bgeu a0,a1,248 <memmove+0x2e> while(n-- > 0) 224: 00c05f63 blez a2,242 <memmove+0x28> 228: 1602 slli a2,a2,0x20 22a: 9201 srli a2,a2,0x20 22c: 00c507b3 add a5,a0,a2 dst = vdst; 230: 872a mv a4,a0 *dst++ = *src++; 232: 0585 addi a1,a1,1 234: 0705 addi a4,a4,1 236: fff5c683 lbu a3,-1(a1) 23a: fed70fa3 sb a3,-1(a4) while(n-- > 0) 23e: fee79ae3 bne a5,a4,232 <memmove+0x18> src += n; while(n-- > 0) *--dst = *--src; } return vdst; } 242: 6422 ld s0,8(sp) 244: 0141 addi sp,sp,16 246: 8082 ret dst += n; 248: 00c50733 add a4,a0,a2 src += n; 24c: 95b2 add a1,a1,a2 while(n-- > 0) 24e: fec05ae3 blez a2,242 <memmove+0x28> 252: fff6079b addiw a5,a2,-1 256: 1782 slli a5,a5,0x20 258: 9381 srli a5,a5,0x20 25a: fff7c793 not a5,a5 25e: 97ba add a5,a5,a4 *--dst = *--src; 260: 15fd addi a1,a1,-1 262: 177d addi a4,a4,-1 264: 0005c683 lbu a3,0(a1) 268: 00d70023 sb a3,0(a4) while(n-- > 0) 26c: fee79ae3 bne a5,a4,260 <memmove+0x46> 270: bfc9 j 242 <memmove+0x28> 0000000000000272 <memcmp>: int memcmp(const void *s1, const void *s2, uint n) { 272: 1141 addi sp,sp,-16 274: e422 sd s0,8(sp) 276: 0800 addi s0,sp,16 const char *p1 = s1, *p2 = s2; while (n-- > 0) { 278: ca05 beqz a2,2a8 <memcmp+0x36> 27a: fff6069b addiw a3,a2,-1 27e: 1682 slli a3,a3,0x20 280: 9281 srli a3,a3,0x20 282: 0685 addi a3,a3,1 284: 96aa add a3,a3,a0 if (*p1 != *p2) { 286: 00054783 lbu a5,0(a0) 28a: 0005c703 lbu a4,0(a1) 28e: 00e79863 bne a5,a4,29e <memcmp+0x2c> return *p1 - *p2; } p1++; 292: 0505 addi a0,a0,1 p2++; 294: 0585 addi a1,a1,1 while (n-- > 0) { 296: fed518e3 bne a0,a3,286 <memcmp+0x14> } return 0; 29a: 4501 li a0,0 29c: a019 j 2a2 <memcmp+0x30> return *p1 - *p2; 29e: 40e7853b subw a0,a5,a4 } 2a2: 6422 ld s0,8(sp) 2a4: 0141 addi sp,sp,16 2a6: 8082 ret return 0; 2a8: 4501 li a0,0 2aa: bfe5 j 2a2 <memcmp+0x30> 00000000000002ac <memcpy>: void * memcpy(void *dst, const void *src, uint n) { 2ac: 1141 addi sp,sp,-16 2ae: e406 sd ra,8(sp) 2b0: e022 sd s0,0(sp) 2b2: 0800 addi s0,sp,16 return memmove(dst, src, n); 2b4: 00000097 auipc ra,0x0 2b8: f66080e7 jalr -154(ra) # 21a <memmove> } 2bc: 60a2 ld ra,8(sp) 2be: 6402 ld s0,0(sp) 2c0: 0141 addi sp,sp,16 2c2: 8082 ret 00000000000002c4 <fork>: # generated by usys.pl - do not edit #include "kernel/syscall.h" .global fork fork: li a7, SYS_fork 2c4: 4885 li a7,1 ecall 2c6: 00000073 ecall ret 2ca: 8082 ret 00000000000002cc <exit>: .global exit exit: li a7, SYS_exit 2cc: 4889 li a7,2 ecall 2ce: 00000073 ecall ret 2d2: 8082 ret 00000000000002d4 <wait>: .global wait wait: li a7, SYS_wait 2d4: 488d li a7,3 ecall 2d6: 00000073 ecall ret 2da: 8082 ret 00000000000002dc <pipe>: .global pipe pipe: li a7, SYS_pipe 2dc: 4891 li a7,4 ecall 2de: 00000073 ecall ret 2e2: 8082 ret 00000000000002e4 <read>: .global read read: li a7, SYS_read 2e4: 4895 li a7,5 ecall 2e6: 00000073 ecall ret 2ea: 8082 ret 00000000000002ec <write>: .global write write: li a7, SYS_write 2ec: 48c1 li a7,16 ecall 2ee: 00000073 ecall ret 2f2: 8082 ret 00000000000002f4 <close>: .global close close: li a7, SYS_close 2f4: 48d5 li a7,21 ecall 2f6: 00000073 ecall ret 2fa: 8082 ret 00000000000002fc <kill>: .global kill kill: li a7, SYS_kill 2fc: 4899 li a7,6 ecall 2fe: 00000073 ecall ret 302: 8082 ret 0000000000000304 <exec>: .global exec exec: li a7, SYS_exec 304: 489d li a7,7 ecall 306: 00000073 ecall ret 30a: 8082 ret 000000000000030c <open>: .global open open: li a7, SYS_open 30c: 48bd li a7,15 ecall 30e: 00000073 ecall ret 312: 8082 ret 0000000000000314 <mknod>: .global mknod mknod: li a7, SYS_mknod 314: 48c5 li a7,17 ecall 316: 00000073 ecall ret 31a: 8082 ret 000000000000031c <unlink>: .global unlink unlink: li a7, SYS_unlink 31c: 48c9 li a7,18 ecall 31e: 00000073 ecall ret 322: 8082 ret 0000000000000324 <fstat>: .global fstat fstat: li a7, SYS_fstat 324: 48a1 li a7,8 ecall 326: 00000073 ecall ret 32a: 8082 ret 000000000000032c <link>: .global link link: li a7, SYS_link 32c: 48cd li a7,19 ecall 32e: 00000073 ecall ret 332: 8082 ret 0000000000000334 <mkdir>: .global mkdir mkdir: li a7, SYS_mkdir 334: 48d1 li a7,20 ecall 336: 00000073 ecall ret 33a: 8082 ret 000000000000033c <chdir>: .global chdir chdir: li a7, SYS_chdir 33c: 48a5 li a7,9 ecall 33e: 00000073 ecall ret 342: 8082 ret 0000000000000344 <dup>: .global dup dup: li a7, SYS_dup 344: 48a9 li a7,10 ecall 346: 00000073 ecall ret 34a: 8082 ret 000000000000034c <getpid>: .global getpid getpid: li a7, SYS_getpid 34c: 48ad li a7,11 ecall 34e: 00000073 ecall ret 352: 8082 ret 0000000000000354 <sbrk>: .global sbrk sbrk: li a7, SYS_sbrk 354: 48b1 li a7,12 ecall 356: 00000073 ecall ret 35a: 8082 ret 000000000000035c <sleep>: .global sleep sleep: li a7, SYS_sleep 35c: 48b5 li a7,13 ecall 35e: 00000073 ecall ret 362: 8082 ret 0000000000000364 <uptime>: .global uptime uptime: li a7, SYS_uptime 364: 48b9 li a7,14 ecall 366: 00000073 ecall ret 36a: 8082 ret 000000000000036c <waitx>: .global waitx waitx: li a7, SYS_waitx 36c: 48d9 li a7,22 ecall 36e: 00000073 ecall ret 372: 8082 ret 0000000000000374 <trace>: .global trace trace: li a7, SYS_trace 374: 48e1 li a7,24 ecall 376: 00000073 ecall ret 37a: 8082 ret 000000000000037c <set_priority>: .global set_priority set_priority: li a7, SYS_set_priority 37c: 48dd li a7,23 ecall 37e: 00000073 ecall ret 382: 8082 ret 0000000000000384 <putc>: static char digits[] = "0123456789ABCDEF"; static void putc(int fd, char c) { 384: 1101 addi sp,sp,-32 386: ec06 sd ra,24(sp) 388: e822 sd s0,16(sp) 38a: 1000 addi s0,sp,32 38c: feb407a3 sb a1,-17(s0) write(fd, &c, 1); 390: 4605 li a2,1 392: fef40593 addi a1,s0,-17 396: 00000097 auipc ra,0x0 39a: f56080e7 jalr -170(ra) # 2ec <write> } 39e: 60e2 ld ra,24(sp) 3a0: 6442 ld s0,16(sp) 3a2: 6105 addi sp,sp,32 3a4: 8082 ret 00000000000003a6 <printint>: static void printint(int fd, int xx, int base, int sgn) { 3a6: 7139 addi sp,sp,-64 3a8: fc06 sd ra,56(sp) 3aa: f822 sd s0,48(sp) 3ac: f426 sd s1,40(sp) 3ae: f04a sd s2,32(sp) 3b0: ec4e sd s3,24(sp) 3b2: 0080 addi s0,sp,64 3b4: 84aa mv s1,a0 char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 3b6: c299 beqz a3,3bc <printint+0x16> 3b8: 0805c963 bltz a1,44a <printint+0xa4> neg = 1; x = -xx; } else { x = xx; 3bc: 2581 sext.w a1,a1 neg = 0; 3be: 4881 li a7,0 3c0: fc040693 addi a3,s0,-64 } i = 0; 3c4: 4701 li a4,0 do{ buf[i++] = digits[x % base]; 3c6: 2601 sext.w a2,a2 3c8: 00000517 auipc a0,0x0 3cc: 4c850513 addi a0,a0,1224 # 890 <digits> 3d0: 883a mv a6,a4 3d2: 2705 addiw a4,a4,1 3d4: 02c5f7bb remuw a5,a1,a2 3d8: 1782 slli a5,a5,0x20 3da: 9381 srli a5,a5,0x20 3dc: 97aa add a5,a5,a0 3de: 0007c783 lbu a5,0(a5) 3e2: 00f68023 sb a5,0(a3) }while((x /= base) != 0); 3e6: 0005879b sext.w a5,a1 3ea: 02c5d5bb divuw a1,a1,a2 3ee: 0685 addi a3,a3,1 3f0: fec7f0e3 bgeu a5,a2,3d0 <printint+0x2a> if(neg) 3f4: 00088c63 beqz a7,40c <printint+0x66> buf[i++] = '-'; 3f8: fd070793 addi a5,a4,-48 3fc: 00878733 add a4,a5,s0 400: 02d00793 li a5,45 404: fef70823 sb a5,-16(a4) 408: 0028071b addiw a4,a6,2 while(--i >= 0) 40c: 02e05863 blez a4,43c <printint+0x96> 410: fc040793 addi a5,s0,-64 414: 00e78933 add s2,a5,a4 418: fff78993 addi s3,a5,-1 41c: 99ba add s3,s3,a4 41e: 377d addiw a4,a4,-1 420: 1702 slli a4,a4,0x20 422: 9301 srli a4,a4,0x20 424: 40e989b3 sub s3,s3,a4 putc(fd, buf[i]); 428: fff94583 lbu a1,-1(s2) 42c: 8526 mv a0,s1 42e: 00000097 auipc ra,0x0 432: f56080e7 jalr -170(ra) # 384 <putc> while(--i >= 0) 436: 197d addi s2,s2,-1 438: ff3918e3 bne s2,s3,428 <printint+0x82> } 43c: 70e2 ld ra,56(sp) 43e: 7442 ld s0,48(sp) 440: 74a2 ld s1,40(sp) 442: 7902 ld s2,32(sp) 444: 69e2 ld s3,24(sp) 446: 6121 addi sp,sp,64 448: 8082 ret x = -xx; 44a: 40b005bb negw a1,a1 neg = 1; 44e: 4885 li a7,1 x = -xx; 450: bf85 j 3c0 <printint+0x1a> 0000000000000452 <vprintf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void vprintf(int fd, const char *fmt, va_list ap) { 452: 7119 addi sp,sp,-128 454: fc86 sd ra,120(sp) 456: f8a2 sd s0,112(sp) 458: f4a6 sd s1,104(sp) 45a: f0ca sd s2,96(sp) 45c: ecce sd s3,88(sp) 45e: e8d2 sd s4,80(sp) 460: e4d6 sd s5,72(sp) 462: e0da sd s6,64(sp) 464: fc5e sd s7,56(sp) 466: f862 sd s8,48(sp) 468: f466 sd s9,40(sp) 46a: f06a sd s10,32(sp) 46c: ec6e sd s11,24(sp) 46e: 0100 addi s0,sp,128 char *s; int c, i, state; state = 0; for(i = 0; fmt[i]; i++){ 470: 0005c903 lbu s2,0(a1) 474: 18090f63 beqz s2,612 <vprintf+0x1c0> 478: 8aaa mv s5,a0 47a: 8b32 mv s6,a2 47c: 00158493 addi s1,a1,1 state = 0; 480: 4981 li s3,0 if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 482: 02500a13 li s4,37 486: 4c55 li s8,21 488: 00000c97 auipc s9,0x0 48c: 3b0c8c93 addi s9,s9,944 # 838 <malloc+0x122> printptr(fd, va_arg(ap, uint64)); } else if(c == 's'){ s = va_arg(ap, char*); if(s == 0) s = "(null)"; while(*s != 0){ 490: 02800d93 li s11,40 putc(fd, 'x'); 494: 4d41 li s10,16 putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); 496: 00000b97 auipc s7,0x0 49a: 3fab8b93 addi s7,s7,1018 # 890 <digits> 49e: a839 j 4bc <vprintf+0x6a> putc(fd, c); 4a0: 85ca mv a1,s2 4a2: 8556 mv a0,s5 4a4: 00000097 auipc ra,0x0 4a8: ee0080e7 jalr -288(ra) # 384 <putc> 4ac: a019 j 4b2 <vprintf+0x60> } else if(state == '%'){ 4ae: 01498d63 beq s3,s4,4c8 <vprintf+0x76> for(i = 0; fmt[i]; i++){ 4b2: 0485 addi s1,s1,1 4b4: fff4c903 lbu s2,-1(s1) 4b8: 14090d63 beqz s2,612 <vprintf+0x1c0> if(state == 0){ 4bc: fe0999e3 bnez s3,4ae <vprintf+0x5c> if(c == '%'){ 4c0: ff4910e3 bne s2,s4,4a0 <vprintf+0x4e> state = '%'; 4c4: 89d2 mv s3,s4 4c6: b7f5 j 4b2 <vprintf+0x60> if(c == 'd'){ 4c8: 11490c63 beq s2,s4,5e0 <vprintf+0x18e> 4cc: f9d9079b addiw a5,s2,-99 4d0: 0ff7f793 zext.b a5,a5 4d4: 10fc6e63 bltu s8,a5,5f0 <vprintf+0x19e> 4d8: f9d9079b addiw a5,s2,-99 4dc: 0ff7f713 zext.b a4,a5 4e0: 10ec6863 bltu s8,a4,5f0 <vprintf+0x19e> 4e4: 00271793 slli a5,a4,0x2 4e8: 97e6 add a5,a5,s9 4ea: 439c lw a5,0(a5) 4ec: 97e6 add a5,a5,s9 4ee: 8782 jr a5 printint(fd, va_arg(ap, int), 10, 1); 4f0: 008b0913 addi s2,s6,8 4f4: 4685 li a3,1 4f6: 4629 li a2,10 4f8: 000b2583 lw a1,0(s6) 4fc: 8556 mv a0,s5 4fe: 00000097 auipc ra,0x0 502: ea8080e7 jalr -344(ra) # 3a6 <printint> 506: 8b4a mv s6,s2 } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 508: 4981 li s3,0 50a: b765 j 4b2 <vprintf+0x60> printint(fd, va_arg(ap, uint64), 10, 0); 50c: 008b0913 addi s2,s6,8 510: 4681 li a3,0 512: 4629 li a2,10 514: 000b2583 lw a1,0(s6) 518: 8556 mv a0,s5 51a: 00000097 auipc ra,0x0 51e: e8c080e7 jalr -372(ra) # 3a6 <printint> 522: 8b4a mv s6,s2 state = 0; 524: 4981 li s3,0 526: b771 j 4b2 <vprintf+0x60> printint(fd, va_arg(ap, int), 16, 0); 528: 008b0913 addi s2,s6,8 52c: 4681 li a3,0 52e: 866a mv a2,s10 530: 000b2583 lw a1,0(s6) 534: 8556 mv a0,s5 536: 00000097 auipc ra,0x0 53a: e70080e7 jalr -400(ra) # 3a6 <printint> 53e: 8b4a mv s6,s2 state = 0; 540: 4981 li s3,0 542: bf85 j 4b2 <vprintf+0x60> printptr(fd, va_arg(ap, uint64)); 544: 008b0793 addi a5,s6,8 548: f8f43423 sd a5,-120(s0) 54c: 000b3983 ld s3,0(s6) putc(fd, '0'); 550: 03000593 li a1,48 554: 8556 mv a0,s5 556: 00000097 auipc ra,0x0 55a: e2e080e7 jalr -466(ra) # 384 <putc> putc(fd, 'x'); 55e: 07800593 li a1,120 562: 8556 mv a0,s5 564: 00000097 auipc ra,0x0 568: e20080e7 jalr -480(ra) # 384 <putc> 56c: 896a mv s2,s10 putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]); 56e: 03c9d793 srli a5,s3,0x3c 572: 97de add a5,a5,s7 574: 0007c583 lbu a1,0(a5) 578: 8556 mv a0,s5 57a: 00000097 auipc ra,0x0 57e: e0a080e7 jalr -502(ra) # 384 <putc> for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4) 582: 0992 slli s3,s3,0x4 584: 397d addiw s2,s2,-1 586: fe0914e3 bnez s2,56e <vprintf+0x11c> printptr(fd, va_arg(ap, uint64)); 58a: f8843b03 ld s6,-120(s0) state = 0; 58e: 4981 li s3,0 590: b70d j 4b2 <vprintf+0x60> s = va_arg(ap, char*); 592: 008b0913 addi s2,s6,8 596: 000b3983 ld s3,0(s6) if(s == 0) 59a: 02098163 beqz s3,5bc <vprintf+0x16a> while(*s != 0){ 59e: 0009c583 lbu a1,0(s3) 5a2: c5ad beqz a1,60c <vprintf+0x1ba> putc(fd, *s); 5a4: 8556 mv a0,s5 5a6: 00000097 auipc ra,0x0 5aa: dde080e7 jalr -546(ra) # 384 <putc> s++; 5ae: 0985 addi s3,s3,1 while(*s != 0){ 5b0: 0009c583 lbu a1,0(s3) 5b4: f9e5 bnez a1,5a4 <vprintf+0x152> s = va_arg(ap, char*); 5b6: 8b4a mv s6,s2 state = 0; 5b8: 4981 li s3,0 5ba: bde5 j 4b2 <vprintf+0x60> s = "(null)"; 5bc: 00000997 auipc s3,0x0 5c0: 27498993 addi s3,s3,628 # 830 <malloc+0x11a> while(*s != 0){ 5c4: 85ee mv a1,s11 5c6: bff9 j 5a4 <vprintf+0x152> putc(fd, va_arg(ap, uint)); 5c8: 008b0913 addi s2,s6,8 5cc: 000b4583 lbu a1,0(s6) 5d0: 8556 mv a0,s5 5d2: 00000097 auipc ra,0x0 5d6: db2080e7 jalr -590(ra) # 384 <putc> 5da: 8b4a mv s6,s2 state = 0; 5dc: 4981 li s3,0 5de: bdd1 j 4b2 <vprintf+0x60> putc(fd, c); 5e0: 85d2 mv a1,s4 5e2: 8556 mv a0,s5 5e4: 00000097 auipc ra,0x0 5e8: da0080e7 jalr -608(ra) # 384 <putc> state = 0; 5ec: 4981 li s3,0 5ee: b5d1 j 4b2 <vprintf+0x60> putc(fd, '%'); 5f0: 85d2 mv a1,s4 5f2: 8556 mv a0,s5 5f4: 00000097 auipc ra,0x0 5f8: d90080e7 jalr -624(ra) # 384 <putc> putc(fd, c); 5fc: 85ca mv a1,s2 5fe: 8556 mv a0,s5 600: 00000097 auipc ra,0x0 604: d84080e7 jalr -636(ra) # 384 <putc> state = 0; 608: 4981 li s3,0 60a: b565 j 4b2 <vprintf+0x60> s = va_arg(ap, char*); 60c: 8b4a mv s6,s2 state = 0; 60e: 4981 li s3,0 610: b54d j 4b2 <vprintf+0x60> } } } 612: 70e6 ld ra,120(sp) 614: 7446 ld s0,112(sp) 616: 74a6 ld s1,104(sp) 618: 7906 ld s2,96(sp) 61a: 69e6 ld s3,88(sp) 61c: 6a46 ld s4,80(sp) 61e: 6aa6 ld s5,72(sp) 620: 6b06 ld s6,64(sp) 622: 7be2 ld s7,56(sp) 624: 7c42 ld s8,48(sp) 626: 7ca2 ld s9,40(sp) 628: 7d02 ld s10,32(sp) 62a: 6de2 ld s11,24(sp) 62c: 6109 addi sp,sp,128 62e: 8082 ret 0000000000000630 <fprintf>: void fprintf(int fd, const char *fmt, ...) { 630: 715d addi sp,sp,-80 632: ec06 sd ra,24(sp) 634: e822 sd s0,16(sp) 636: 1000 addi s0,sp,32 638: e010 sd a2,0(s0) 63a: e414 sd a3,8(s0) 63c: e818 sd a4,16(s0) 63e: ec1c sd a5,24(s0) 640: 03043023 sd a6,32(s0) 644: 03143423 sd a7,40(s0) va_list ap; va_start(ap, fmt); 648: fe843423 sd s0,-24(s0) vprintf(fd, fmt, ap); 64c: 8622 mv a2,s0 64e: 00000097 auipc ra,0x0 652: e04080e7 jalr -508(ra) # 452 <vprintf> } 656: 60e2 ld ra,24(sp) 658: 6442 ld s0,16(sp) 65a: 6161 addi sp,sp,80 65c: 8082 ret 000000000000065e <printf>: void printf(const char *fmt, ...) { 65e: 711d addi sp,sp,-96 660: ec06 sd ra,24(sp) 662: e822 sd s0,16(sp) 664: 1000 addi s0,sp,32 666: e40c sd a1,8(s0) 668: e810 sd a2,16(s0) 66a: ec14 sd a3,24(s0) 66c: f018 sd a4,32(s0) 66e: f41c sd a5,40(s0) 670: 03043823 sd a6,48(s0) 674: 03143c23 sd a7,56(s0) va_list ap; va_start(ap, fmt); 678: 00840613 addi a2,s0,8 67c: fec43423 sd a2,-24(s0) vprintf(1, fmt, ap); 680: 85aa mv a1,a0 682: 4505 li a0,1 684: 00000097 auipc ra,0x0 688: dce080e7 jalr -562(ra) # 452 <vprintf> } 68c: 60e2 ld ra,24(sp) 68e: 6442 ld s0,16(sp) 690: 6125 addi sp,sp,96 692: 8082 ret 0000000000000694 <free>: static Header base; static Header *freep; void free(void *ap) { 694: 1141 addi sp,sp,-16 696: e422 sd s0,8(sp) 698: 0800 addi s0,sp,16 Header *bp, *p; bp = (Header*)ap - 1; 69a: ff050693 addi a3,a0,-16 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 69e: 00000797 auipc a5,0x0 6a2: 20a7b783 ld a5,522(a5) # 8a8 <freep> 6a6: a02d j 6d0 <free+0x3c> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 6a8: 4618 lw a4,8(a2) 6aa: 9f2d addw a4,a4,a1 6ac: fee52c23 sw a4,-8(a0) bp->s.ptr = p->s.ptr->s.ptr; 6b0: 6398 ld a4,0(a5) 6b2: 6310 ld a2,0(a4) 6b4: a83d j 6f2 <free+0x5e> } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 6b6: ff852703 lw a4,-8(a0) 6ba: 9f31 addw a4,a4,a2 6bc: c798 sw a4,8(a5) p->s.ptr = bp->s.ptr; 6be: ff053683 ld a3,-16(a0) 6c2: a091 j 706 <free+0x72> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6c4: 6398 ld a4,0(a5) 6c6: 00e7e463 bltu a5,a4,6ce <free+0x3a> 6ca: 00e6ea63 bltu a3,a4,6de <free+0x4a> { 6ce: 87ba mv a5,a4 for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6d0: fed7fae3 bgeu a5,a3,6c4 <free+0x30> 6d4: 6398 ld a4,0(a5) 6d6: 00e6e463 bltu a3,a4,6de <free+0x4a> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6da: fee7eae3 bltu a5,a4,6ce <free+0x3a> if(bp + bp->s.size == p->s.ptr){ 6de: ff852583 lw a1,-8(a0) 6e2: 6390 ld a2,0(a5) 6e4: 02059813 slli a6,a1,0x20 6e8: 01c85713 srli a4,a6,0x1c 6ec: 9736 add a4,a4,a3 6ee: fae60de3 beq a2,a4,6a8 <free+0x14> bp->s.ptr = p->s.ptr->s.ptr; 6f2: fec53823 sd a2,-16(a0) if(p + p->s.size == bp){ 6f6: 4790 lw a2,8(a5) 6f8: 02061593 slli a1,a2,0x20 6fc: 01c5d713 srli a4,a1,0x1c 700: 973e add a4,a4,a5 702: fae68ae3 beq a3,a4,6b6 <free+0x22> p->s.ptr = bp->s.ptr; 706: e394 sd a3,0(a5) } else p->s.ptr = bp; freep = p; 708: 00000717 auipc a4,0x0 70c: 1af73023 sd a5,416(a4) # 8a8 <freep> } 710: 6422 ld s0,8(sp) 712: 0141 addi sp,sp,16 714: 8082 ret 0000000000000716 <malloc>: return freep; } void* malloc(uint nbytes) { 716: 7139 addi sp,sp,-64 718: fc06 sd ra,56(sp) 71a: f822 sd s0,48(sp) 71c: f426 sd s1,40(sp) 71e: f04a sd s2,32(sp) 720: ec4e sd s3,24(sp) 722: e852 sd s4,16(sp) 724: e456 sd s5,8(sp) 726: e05a sd s6,0(sp) 728: 0080 addi s0,sp,64 Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 72a: 02051493 slli s1,a0,0x20 72e: 9081 srli s1,s1,0x20 730: 04bd addi s1,s1,15 732: 8091 srli s1,s1,0x4 734: 0014899b addiw s3,s1,1 738: 0485 addi s1,s1,1 if((prevp = freep) == 0){ 73a: 00000517 auipc a0,0x0 73e: 16e53503 ld a0,366(a0) # 8a8 <freep> 742: c515 beqz a0,76e <malloc+0x58> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 744: 611c ld a5,0(a0) if(p->s.size >= nunits){ 746: 4798 lw a4,8(a5) 748: 02977f63 bgeu a4,s1,786 <malloc+0x70> 74c: 8a4e mv s4,s3 74e: 0009871b sext.w a4,s3 752: 6685 lui a3,0x1 754: 00d77363 bgeu a4,a3,75a <malloc+0x44> 758: 6a05 lui s4,0x1 75a: 000a0b1b sext.w s6,s4 p = sbrk(nu * sizeof(Header)); 75e: 004a1a1b slliw s4,s4,0x4 p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 762: 00000917 auipc s2,0x0 766: 14690913 addi s2,s2,326 # 8a8 <freep> if(p == (char*)-1) 76a: 5afd li s5,-1 76c: a895 j 7e0 <malloc+0xca> base.s.ptr = freep = prevp = &base; 76e: 00000797 auipc a5,0x0 772: 14278793 addi a5,a5,322 # 8b0 <base> 776: 00000717 auipc a4,0x0 77a: 12f73923 sd a5,306(a4) # 8a8 <freep> 77e: e39c sd a5,0(a5) base.s.size = 0; 780: 0007a423 sw zero,8(a5) if(p->s.size >= nunits){ 784: b7e1 j 74c <malloc+0x36> if(p->s.size == nunits) 786: 02e48c63 beq s1,a4,7be <malloc+0xa8> p->s.size -= nunits; 78a: 4137073b subw a4,a4,s3 78e: c798 sw a4,8(a5) p += p->s.size; 790: 02071693 slli a3,a4,0x20 794: 01c6d713 srli a4,a3,0x1c 798: 97ba add a5,a5,a4 p->s.size = nunits; 79a: 0137a423 sw s3,8(a5) freep = prevp; 79e: 00000717 auipc a4,0x0 7a2: 10a73523 sd a0,266(a4) # 8a8 <freep> return (void*)(p + 1); 7a6: 01078513 addi a0,a5,16 if((p = morecore(nunits)) == 0) return 0; } } 7aa: 70e2 ld ra,56(sp) 7ac: 7442 ld s0,48(sp) 7ae: 74a2 ld s1,40(sp) 7b0: 7902 ld s2,32(sp) 7b2: 69e2 ld s3,24(sp) 7b4: 6a42 ld s4,16(sp) 7b6: 6aa2 ld s5,8(sp) 7b8: 6b02 ld s6,0(sp) 7ba: 6121 addi sp,sp,64 7bc: 8082 ret prevp->s.ptr = p->s.ptr; 7be: 6398 ld a4,0(a5) 7c0: e118 sd a4,0(a0) 7c2: bff1 j 79e <malloc+0x88> hp->s.size = nu; 7c4: 01652423 sw s6,8(a0) free((void*)(hp + 1)); 7c8: 0541 addi a0,a0,16 7ca: 00000097 auipc ra,0x0 7ce: eca080e7 jalr -310(ra) # 694 <free> return freep; 7d2: 00093503 ld a0,0(s2) if((p = morecore(nunits)) == 0) 7d6: d971 beqz a0,7aa <malloc+0x94> for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 7d8: 611c ld a5,0(a0) if(p->s.size >= nunits){ 7da: 4798 lw a4,8(a5) 7dc: fa9775e3 bgeu a4,s1,786 <malloc+0x70> if(p == freep) 7e0: 00093703 ld a4,0(s2) 7e4: 853e mv a0,a5 7e6: fef719e3 bne a4,a5,7d8 <malloc+0xc2> p = sbrk(nu * sizeof(Header)); 7ea: 8552 mv a0,s4 7ec: 00000097 auipc ra,0x0 7f0: b68080e7 jalr -1176(ra) # 354 <sbrk> if(p == (char*)-1) 7f4: fd5518e3 bne a0,s5,7c4 <malloc+0xae> return 0; 7f8: 4501 li a0,0 7fa: bf45 j 7aa <malloc+0x94>
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/loop_optimization14.adb
best08618/asylo
7
28849
<gh_stars>1-10 -- PR middle-end/55321 -- { dg-do compile } -- { dg-options "-O" } with Loop_Optimization14_Pkg; use Loop_Optimization14_Pkg; package body Loop_Optimization14 is procedure Finalize_Pool (Pool : in out Rec) is Raised : Boolean := False; begin Pool.A := True; while not Pool.B loop begin Proc (Pool.B); exception when others => if not Raised then Raised := True; end if; end; end loop; end; end Loop_Optimization14;
Transynther/x86/_processed/AVXALIGN/_zr_/i3-7100_9_0x84_notsx.log_21829_1960.asm
ljhsiun2/medusa
9
240907
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r15 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0xe197, %r13 nop nop nop nop nop cmp $64471, %r12 movups (%r13), %xmm3 vpextrq $1, %xmm3, %rbx nop nop nop nop nop cmp %r15, %r15 lea addresses_D_ht+0x4557, %rcx dec %r10 mov (%rcx), %bp nop nop nop nop sub %rbp, %rbp lea addresses_normal_ht+0x18e37, %rcx nop nop dec %rbx movw $0x6162, (%rcx) nop nop nop nop sub %rbx, %rbx lea addresses_UC_ht+0x5a57, %rsi lea addresses_A_ht+0x11eaf, %rdi nop nop xor $9078, %r15 mov $70, %rcx rep movsb nop nop nop nop nop add $18124, %r13 lea addresses_WC_ht+0x73c7, %rdi nop nop nop nop nop xor $28162, %rbx movl $0x61626364, (%rdi) nop nop nop sub %r10, %r10 lea addresses_D_ht+0x8d57, %rcx clflush (%rcx) nop nop nop nop cmp %rbp, %rbp movb (%rcx), %r15b nop nop nop nop nop sub %r15, %r15 lea addresses_UC_ht+0x6157, %rsi lea addresses_D_ht+0x82c, %rdi nop nop nop nop cmp $31915, %r12 mov $0, %rcx rep movsl nop xor $22431, %r12 lea addresses_D_ht+0x16357, %rsi lea addresses_UC_ht+0x11957, %rdi clflush (%rsi) nop nop nop nop and $40894, %rbx mov $32, %rcx rep movsq nop nop nop dec %r10 lea addresses_D_ht+0xd97, %rsi lea addresses_UC_ht+0x66d7, %rdi nop nop nop dec %r12 mov $40, %rcx rep movsl nop nop nop cmp $227, %rbp lea addresses_D_ht+0x59eb, %r10 nop nop nop nop nop sub $34660, %r13 mov (%r10), %bx nop nop nop and $55897, %rbx lea addresses_A_ht+0xeb57, %rsi lea addresses_normal_ht+0x2b17, %rdi clflush (%rsi) nop nop nop xor $6939, %r15 mov $37, %rcx rep movsw sub %rsi, %rsi lea addresses_WT_ht+0x9557, %r10 nop sub $30764, %r12 mov $0x6162636465666768, %rcx movq %rcx, %xmm7 vmovups %ymm7, (%r10) nop nop sub $45274, %r15 lea addresses_WT_ht+0xecaa, %rdi nop nop and $24778, %rbp movb (%rdi), %r15b nop nop nop nop nop cmp $20510, %r15 lea addresses_UC_ht+0xb57, %r13 dec %r10 mov (%r13), %rbx nop nop nop cmp $19324, %rsi lea addresses_UC_ht+0x11557, %r10 nop nop nop nop inc %rbx movups (%r10), %xmm7 vpextrq $1, %xmm7, %r15 nop nop nop nop and $13677, %rbp pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r15 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r15 push %r8 push %rax push %rbp push %rcx // Store lea addresses_WC+0x1803b, %rcx nop nop nop xor %rbp, %rbp movl $0x51525354, (%rcx) nop add %r15, %r15 // Store lea addresses_D+0xd1b7, %rbp nop nop nop add $23918, %r11 movb $0x51, (%rbp) nop nop nop cmp %r15, %r15 // Store mov $0x2740a70000000657, %rcx xor $25572, %r11 mov $0x5152535455565758, %rbp movq %rbp, %xmm3 vmovaps %ymm3, (%rcx) nop nop nop nop nop dec %r8 // Store lea addresses_PSE+0xdd7, %rbp nop nop nop sub $30850, %rax movl $0x51525354, (%rbp) nop nop nop sub $48985, %r8 // Faulty Load lea addresses_UC+0x1cd57, %rax nop nop nop and %r8, %r8 vmovaps (%rax), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $0, %xmm6, %rbp lea oracles, %r8 and $0xff, %rbp shlq $12, %rbp mov (%r8,%rbp,1), %rbp pop %rcx pop %rbp pop %rax pop %r8 pop %r15 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_UC', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WC', 'same': False, 'size': 4, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_NC', 'same': False, 'size': 32, 'congruent': 6, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'dst': {'type': 'addresses_PSE', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_UC', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 16, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 2, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_normal_ht', 'same': True, 'size': 2, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_D_ht', 'same': True, 'size': 1, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_D_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 32, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'same': True, 'size': 1, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 8, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 16, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
src/main/antlr4/se/kth/mal/Mal.g4
simwr872/MAL
0
4923
grammar Mal; compilationUnit: (associations | category | include)* EOF; // Revisit where meta is placed? meta: metaType Colon String; metaType: Info | Rationale | Assumptions; type: LeftBracket Identifier RightBracket; include: Include (Identifier | Dot | Separator)+; associations: Associations LeftBrace association* RightBrace; association: Identifier type multiplicity LeftRelation Identifier RightRelation multiplicity type Identifier meta*; multiplicity: Single | ZeroSingle | SingleMany | Many; category: Category Identifier meta* LeftBrace asset* RightBrace; asset: assetType Identifier (Extends Identifier)? meta* LeftBrace attackstep* RightBrace; assetType: Asset | AbstractAsset; attackstep: attackstepType Identifier ttc? meta* existence? (reachedType statement (Comma statement)*)?; attackstepType: AttackstepAll | AttackstepAny | Defense | DefenseExistence | DefenseNonExistence; ttc: LeftBracket Identifier Parameters? RightBracket; existence: Existence Identifier (Comma Identifier)*; reachedType: AttackstepReach | AttackstepInherit; statement: (Let Identifier Assign)? expr; expr : expr Dot expr | LeftParen expr RightParen type? | expr (operator expr)+ | Identifier type? Transitive?; operator: Intersection | Union; // LEXER AttackstepAny: '|'; AttackstepAll: '&'; AttackstepReach: '->'; AttackstepInherit: '+>'; Defense: '#'; DefenseExistence: '3'; DefenseNonExistence: 'E'; Existence: '<-'; LeftRelation: '<--'; RightRelation: '-->'; Single: '1'; ZeroSingle: '0-1'; SingleMany: '1-*'; Many: '*'; LeftParen: '('; RightParen: ')'; LeftBracket: '['; RightBracket: ']'; LeftBrace: '{'; RightBrace: '}'; Colon: ':'; Comma: ','; Dot: '.'; Transitive: '+'; Assign: '='; Intersection: '/\\'; Union: '\\/'; Associations: 'associations'; Category: 'category'; Info: 'info'; Rationale: 'rationale'; Assumptions: 'assumptions'; Include: 'include'; Asset: 'asset'; AbstractAsset: 'abstractAsset'; Extends: 'extends'; Let: 'let'; Identifier: Letter (Letter | Digit)*; // Since we want to avoid having a number lexer rule we have to handle whitespace here Parameters: LeftParen Space* Number (Space* Comma Space* Number)* Space* RightParen; Separator: [\\/]; String: '"' ~["\\]* '"'; fragment Letter: [a-zA-Z$_]; fragment Number: (Digit* '.')? Digit+; fragment Digit: [0-9]; fragment Space: [ \t\r\n]; Whitespace: Space+ -> skip; Comment: '//' ~[\r\n]* -> skip;
2018/csaw18finalsctf/v35/bears.asm
theKidOfArcrania/ctf-writeups
5
86473
<reponame>theKidOfArcrania/ctf-writeups<gh_stars>1-10 CMD_STOP = 100 CMD_PASSIVE = 101 CMD_AGGRESSIVE = 102 CMD_FURMWARE_UPDATE = 200 REPORT_ALIVE = 0 REPORT_SPOTTED = 1 IN_PORT = 0 OUT_PORT = 1 MIN_WAIT_TIME = 30 MAX_WAIT_TIME = 180 MIN_WALK_TIME = 60 MAX_WALK_TIME = 240 SCAN_DISTANCE = 120 ATTACK_TIME = 180 main: mov eax, SYS_RAND int 0x80 mov [id], eax ; Randomize keep alive timing and eax, 63 mov dword [keep_alive_time], eax mov byte [mode], CMD_AGGRESSIVE .waiting: ; Decide how long to wait here push MAX_WAIT_TIME push MIN_WAIT_TIME call rand_int mov esi, eax .wait_loop: pause cmp byte [mode], CMD_STOP je .stop call process_commands call look_for_player test eax, eax jnz .wait_loop ; Stop moving and wait mov eax, SYS_WALK xor ebx, ebx xor ecx, ecx int 0x80 dec esi jnz .wait_loop .wander: ; Pick a random direction push 4 push 0 call rand_int ; Walk in that direction mov ebx, [directions + eax * 8] mov ecx, [directions + eax * 8 + 4] mov eax, SYS_WALK int 0x80 ; Pick a random amount of time to walk push MAX_WALK_TIME push MIN_WALK_TIME call rand_int mov esi, eax .walk_loop: pause cmp byte [mode], CMD_STOP je .stop call process_commands call look_for_player test eax, eax jnz .waiting dec esi jnz .walk_loop jmp .waiting .stop: mov eax, SYS_WALK xor ebx, ebx xor ecx, ecx int 0x80 pause call process_commands cmp byte [mode], CMD_STOP jne .waiting jmp .stop look_for_player: push ebx ; If not in aggressive mode, stop now cmp byte [mode], CMD_AGGRESSIVE jne .player_not_found ; Scan area mov eax, SYS_SCAN_AREA mov ebx, SCAN_DISTANCE mov ecx, scan_results mov edx, end_scan - scan_results int 0x80 mov ecx, 0 .scan_loop: cmp ecx, eax jge .player_not_found imul edx, ecx, 12 cmp dword [scan_results + edx + 8], SCAN_PLAYER jne .next ; Found the player, walk there mov eax, SYS_WALK mov ebx, [scan_results + edx] mov ecx, [scan_results + edx + 4] int 0x80 ; Send spotted report to controller on alive interval cmp dword [keep_alive_time], 0 jnz .check_for_fire mov byte [report_buffer], REPORT_SPOTTED mov eax, [id] mov [report_buffer + 1], eax mov eax, SYS_WRITE mov ebx, OUT_PORT mov ecx, report_buffer mov edx, 5 int 0x80 .check_for_fire: ; Check for firing cannon cmp dword [time_until_attack], 0 je .attack dec dword [time_until_attack] mov eax, 1 jmp .done .attack: mov eax, SYS_ATTACK int 0x80 mov dword [time_until_attack], ATTACK_TIME mov eax, 1 jmp .done .next: inc ecx jmp .scan_loop .player_not_found: xor eax, eax .done: pop ebx ret rand_int: .min = 4 .max = 8 mov ecx, [esp + .max] sub ecx, [esp + .min] mov eax, SYS_RAND int 0x80 xor edx, edx div ecx add edx, [esp + .min] xchg eax, edx ret 8 process_commands: push ebx ; Check if time for alive report cmp dword [keep_alive_time], 0 jnz .check_for_command ; Send alive report to controller mov byte [report_buffer], REPORT_ALIVE mov eax, [id] mov [report_buffer + 1], eax mov al, [mode] mov [report_buffer + 5], al mov eax, SYS_WRITE mov ebx, OUT_PORT mov ecx, report_buffer mov edx, 6 int 0x80 mov dword [keep_alive_time], 120 .check_for_command: dec dword [keep_alive_time] ; See if a command byte is available mov eax, SYS_CAN_READ mov ebx, IN_PORT mov ecx, 1 int 0x80 test eax, eax jz .done ; Grab the command byte in al, IN_PORT mov cl, al cmp al, CMD_FURMWARE_UPDATE je .update ; Grab the target id in eax, IN_PORT ; Check for broadcast cmp eax, 0xffffffff je .do_command cmp eax, [id] jne .done .do_command: mov byte [mode], cl jmp .done .update: in ax, IN_PORT movzx edx, ax mov eax, SYS_READ mov ebx, 0 mov ecx, update_buffer int 0x80 mov eax, SYS_ROM_UPDATE mov ebx, ecx mov ecx, edx int 0x80 .done: pop ebx ret directions: dd 1, 0 dd -1, 0 dd 0, 1 dd 0, -1 .data id: dd 0 scan_results: dd 0, 0, 0 dd 0, 0, 0 dd 0, 0, 0 dd 0, 0, 0 dd 0, 0, 0 dd 0, 0, 0 dd 0, 0, 0 dd 0, 0, 0 end_scan: time_until_attack: dd 0 keep_alive_time: dd 0 report_buffer: db 0 dd 0 db 0 mode: db 0 update_buffer:
writeconsole-shellcodes/w64-writeconsole-shellcode.asm
mitthu/testival
1
176182
; Copyright (c) 2006-2010, Berend-Jan "SkyLined" Wever <<EMAIL>> ; Project homepage: http://code.google.com/p/testival/ ; All rights reserved. See COPYRIGHT.txt for details. BITS 64 SECTION .text ; Windows x64 null-free shellcode that writes "Hello, world!" to stdout. ; Works in any console application for Windows 5.1-7.0 all service packs. ; (See http://skypher.com/wiki/index.php/Hacking/Shellcode). ; This version uses 16-bit hashes. %define message `Hello, world!\r\n` %strlen sizeof_message message %include "w64-writeconsole-shellcode-hash-list.asm" %define B2W(b1,b2) (((b2) << 8) + (b1)) %define W2DW(w1,w2) (((w2) << 16) + (w1)) %define W2QW(w1,w2,w3,w4) (((w4) << 48) + ((w3) << 32) + ((w2) << 16) + (w1)) %define B2DW(b1,b2,b3,b4) (((b4) << 24) + ((b3) << 16) + ((b2) << 8) + (b1)) %define B2DQ(b1,b2,b3,b4,b5,b6,b7,b8) (((b8) << 56) + ((b7) << 48) + ((b6) << 40) + ((b5) << 32) + ((b4) << 24) + ((b3) << 16) + ((b2) << 8) + (b1)) %define DW2QW(dw1,dw2) (((dw2) << 32) + (dw1)) %macro PUSHDW 1 %if %1 > 0x7FFFFFFF PUSH -(0x100000000 - %1) %else PUSH %1 %endif %endmacro global shellcode shellcode: global _shellcode _shellcode: MOV R12, W2QW(hash_kernel32_GetStdHandle, hash_kernel32_WriteFile, hash_kernel32_FlushFileBuffers, hash_ntdll_RtlExitUserProcess); MOV RSI, RSP PUSH BYTE -11 ; GetStdHandle(nStdHandle) = STD_OUTPUT_HANDLE POP R13 ; R13 = argument1 == STD_OUTPUT_HANDLE PUSH RAX ; argument2 == garbage next_hash: PUSH BYTE 0x60 ; [ESP] = 0x60 POP RAX ; RCX = 0x60 ; Find base address of kernel32.dll. This code should work on Windows 5.1-7.0 ; Base on http://milw0rm.com/shellcode/2126 by <NAME> <<EMAIL>> MOV R11, [GS:RAX] ; R11 = &(PEB) ([GS:0x60]) MOV R11, [R11+0x18] ; R11 = ntdll!PebLdr MOV R11, [R11+0x30] ; R11 = ntdll!PebLdr.InInitOrder (first module) next_module: MOV RBP, [R11 + 0x10] ; RBP = InInitOrder[X].base_address MOV R11, [R11] ; R11 = InInitOrder[X].flink == InInitOrder[X+1] get_proc_address_loop: ; Find the PE header and export and names tables of the module: MOV EAX, [RBP + 0x3C] ; RAX = offset PE header ADD EAX, BYTE 0x10 ; export table is at offset 0x88, which does not fit an unsigned byte. MOV EAX, [RBP + RAX + 0x78] ; RAX = offset(export table) %define extra_offset 0x18 LEA RBX, [RBP + RAX + extra_offset] ; RBX = &(export table) + extra_offset (Avoid NULL) ; Hash each function name and check it against the requested hash: MOV EAX, [RBX - extra_offset + 0x18] ; ECX = number of name pointers MOV RCX, RAX ; RCX = number of exported functions next_function_loop: ; Get the next function name: MOV EAX, [RBX - extra_offset + 0x20] ; RAX = offset(names table) LEA RDI, [RBP + RAX - 4] ; RDI = &(names table) - 4 (Avoid NULL) MOV EAX, [RDI + RCX * 4] ; RAX = offset(function name) ADD RAX, RBP ; RAX = &(function name) XOR RDI, RDI ; RDI = 0 XCHG RAX, RDI ; RAX = 0, RDI = &(function name) CQO ; RDX = 0 hash_loop: XOR DL, [RDI] ; DX ^= name byte ROR DX, hash_ror_value ; Rotate DX for hash function SCASB ; [RDI++] == 0 ? JNE hash_loop ; Not 0, more chars in string... CMP DX, R12W ; hash == target hash ? LOOPNE next_function_loop ; No, try next function if there is one. JNE next_module ; Try next module ; Find the address of the requested function: MOV EAX, [RBX - extra_offset + 0x24] ; RAX = offset ordinals table LEA RDX, [RBP + RAX + extra_offset] ; RDX = &oridinals table + extra_offset (Avoid NULL) MOVZX RDX, WORD [RDX - extra_offset + 2 * RCX] ; RCX = ordinal number of function MOV EAX, [RBX - extra_offset + 0x1C] ; RAX = offset address table LEA RCX, [RBP + RAX + extra_offset] ; RCX = &address table + extra_offset (Avoid NULL) MOV EAX, [RCX - extra_offset + 4 * RDX] ; RAX = offset function in DLL ADD RAX, RBP ; RAX = &(function) ; Second argument (Garbage, &message, &message) POP RDX ; __in LPCVOID lpBuffer = message ; First argument: (STD_OUTPUT_HANDLE, GetStdHandle(STD_OUTPUT_HANDLE), WriteFile(...) (!= 0)) MOV RCX, R13 ; GetStdHandle(): __in DWORD nStdHandle = STD_OUTPUT_HANDLE ; WriteConsole(): __in HANDLE hFile = GetStdHandle(STD_OUTPUT_HANDLE) ; ExitProcess(): __in UINT uExitCode = WriteFile(...) (!= 0) PUSH BYTE sizeof_message ; __in DWORD nNumberOfBytesToWrite = strlen(message) POP R8 MOV R9,RSP ; __out_opt LPDWORD lpNumberOfBytesWritten = Stack XOR R10,R10 ; ; PUSH R10 ; Stack align to 16 bytes (does not seem to be required PUSH R10 ; __inout_opt LPOVERLAPPED lpOverlapped = NULL SUB RSP, BYTE 0x20 ; 4 * 8 "Register Parameter Stack" CALL RAX CMP R12W, hash_kernel32_GetStdHandle ; JNE do_not_save_handle MOV R13, RAX do_not_save_handle: SHR R12, BYTE 0x10 ; Next hash CALL next_hash db message
dimension/cell/lib/string/md5/md5.asm
ekscrypto/Unununium
7
10210
<reponame>ekscrypto/Unununium ;; $Header: /cvsroot/uuu/dimension/cell/lib/string/md5/md5.asm,v 1.2 2002/08/11 07:41:24 lukas2000 Exp $ ;; ;; md5 - A cell implementing the MD5 secure message-digest algorithm ;; Written by <NAME> ;; The code in this file and the MD5 algorithm are public domain. ;; ;; todo: ;; ----- ;; * globalfuncise _transform so things too big to put in memory can be md5ed ;; * clean hash,md5; i wrote it at 2am and it's really big...i think it sucks ; ----------------------------------- ; strucs ;============================================================================== struc stack ; structure for the stuff on the stack most of the time .size: resd 1 ; total size in bytes, ECX from call .remaining: resd 1 ; bytes left counter, ECX from call .X: resd 16 ; working buffer .a: resd 1 ;] .b: resd 1 ;]\__ to save the state in _transform .c: resd 1 ;]/ .d: resd 1 ;] endstruc ; ----------------------------------- ; macros ;============================================================================== ; ---===--- fundamental MD5 functions ---===--- %macro F 3 ; F(X,Y,Z) = XY v not(X) Z mov edi, %1 mov ebp, %1 and edi, %2 not ebp and ebp, %3 or edi, ebp %endmacro %macro G 3 ; G(X,Y,Z) = XZ v Y not(Z) mov edi, %3 mov ebp, %3 and edi, %1 not ebp and ebp, %2 or edi, ebp %endmacro %macro H 3 ; H(X,Y,Z) = X xor Y xor Z mov edi, %1 xor edi, %2 xor edi, %3 %endmacro %macro I 3 ; I(X,Y,Z) = Y xor (X v not(Z)) mov edi, %3 not edi or edi, %1 xor edi, %2 %endmacro ; ---===--- functions for the 4 rounds of transformations ---===--- %macro FF 7 ; a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ F e%{2}x, e%{3}x, e%{4}x ; result in edi add edi, e%{1}x add edi, [esp+stack.X+%5*4+4] add edi, %7 rol edi, %6 lea e%{1}x, [edi+e%{2}x] %endmacro %macro GG 7 ; a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ G e%{2}x, e%{3}x, e%{4}x ; result in edi add edi, e%{1}x add edi, [esp+stack.X+%5*4+4] add edi, %7 rol edi, %6 lea e%{1}x, [edi+e%{2}x] %endmacro %macro HH 7 ; a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ H e%{2}x, e%{3}x, e%{4}x ; result in edi add edi, e%{1}x add edi, [esp+stack.X+%5*4+4] add edi, %7 rol edi, %6 lea e%{1}x, [edi+e%{2}x] %endmacro %macro II 7 ; a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ I e%{2}x, e%{3}x, e%{4}x ; result in edi add edi, e%{1}x add edi, [esp+stack.X+%5*4+4] add edi, %7 rol edi, %6 lea e%{1}x, [edi+e%{2}x] %endmacro ; ----------------------------------- ; section .c_init ;============================================================================== section .c_init global _start _start: ; We do nothing here ; added by Luke retn ; ----------------------------------- ; section .text ;============================================================================== section .text globalfunc lib.string.md5 ;> ;; parameters: ;; ----------- ;; ESI = ptr to data ;; ECX = legnth of data in bytes ;; ;; returned values: ;; ---------------- ;; EAX:EBX:ECX:EDX = result; This is little endian so start with the low-order ;; byte of EAX and end with the high-order byte of EDX ;< sub esp, byte stack_size mov [esp+stack.size], ecx mov [esp+stack.remaining], ecx mov eax, 0x67452301 mov ebx, 0xefcdab89 mov ecx, 0x98badcfe mov edx, 0x10325476 ; first do as much of the transform as we can .full_block: push ecx mov ecx, 64 sub [esp+stack.remaining+4], ecx lea edi, [esp+stack.X+4] jl .partial shr ecx, 2 rep movsd pop ecx call _transform jmp short .full_block .partial: ; [esp+stack.remaining+4] = accual number of bytes remaining - 16 mov ecx, [esp+stack.remaining+4] add ecx, byte 64 mov ebp, 64 test ecx, ecx jz .none_left sub ebp, ecx ; EBP = bytes we have to pad rep movsb ; copy the rest .none_left: mov byte[edi], 0x80 ; slap on the zero inc edi sub ebp, byte 9 jl .not_enough_for_size .add_size: mov ecx, [esp+stack.size+4] shl ecx, 3 mov [edi+ebp], ecx mov ecx, [esp+stack.size+4] shr ecx, 32-3 mov [edi+ebp+4], ecx test ebp, ebp jz .go_and_finish .zero_loop: dec ebp mov byte[edi+ebp], 0 jnz .zero_loop .go_and_finish: pop ecx call _transform add esp, byte stack_size retn .not_enough_for_size: ; ebp = number of bytes left to pad - 8 (the 0x80 has already been added) add ebp, byte 8 jz .go_go_go .zero_loop2: dec ebp mov byte[edi+ebp], 0 jnz .zero_loop2 .go_go_go: pop ecx call _transform push ecx lea edi, [esp+stack.X+4] xor ecx, ecx mov ebp, 64-8 jmp .add_size ; ----------------------------------- ; _transform ;============================================================================== _transform: ;> ;; does an md5 transform ;; ;; parameters: ;; ----------- ;; X from stack ;; EAX, EBX, ECX, EDX = state ;; ;; returned values: ;; ---------------- ;; EAX, EBX, ECX, EDX = new state ;< mov [esp+stack.a+4], eax mov [esp+stack.b+4], ebx mov [esp+stack.c+4], ecx mov [esp+stack.d+4], edx FF a, b, c, d, 0, 7, 0xd76aa478 FF d, a, b, c, 1, 12, 0xe8c7b756 FF c, d, a, b, 2, 17, 0x242070db FF b, c, d, a, 3, 22, 0xc1bdceee FF a, b, c, d, 4, 7, 0xf57c0faf FF d, a, b, c, 5, 12, 0x4787c62a FF c, d, a, b, 6, 17, 0xa8304613 FF b, c, d, a, 7, 22, 0xfd469501 FF a, b, c, d, 8, 7, 0x698098d8 FF d, a, b, c, 9, 12, 0x8b44f7af FF c, d, a, b, 10, 17, 0xffff5bb1 FF b, c, d, a, 11, 22, 0x895cd7be FF a, b, c, d, 12, 7, 0x6b901122 FF d, a, b, c, 13, 12, 0xfd987193 FF c, d, a, b, 14, 17, 0xa679438e FF b, c, d, a, 15, 22, 0x49b40821 GG a, b, c, d, 1, 5, 0xf61e2562 GG d, a, b, c, 6, 9, 0xc040b340 GG c, d, a, b, 11, 14, 0x265e5a51 GG b, c, d, a, 0, 20, 0xe9b6c7aa GG a, b, c, d, 5, 5, 0xd62f105d GG d, a, b, c, 10, 9, 0x2441453 GG c, d, a, b, 15, 14, 0xd8a1e681 GG b, c, d, a, 4, 20, 0xe7d3fbc8 GG a, b, c, d, 9, 5, 0x21e1cde6 GG d, a, b, c, 14, 9, 0xc33707d6 GG c, d, a, b, 3, 14, 0xf4d50d87 GG b, c, d, a, 8, 20, 0x455a14ed GG a, b, c, d, 13, 5, 0xa9e3e905 GG d, a, b, c, 2, 9, 0xfcefa3f8 GG c, d, a, b, 7, 14, 0x676f02d9 GG b, c, d, a, 12, 20, 0x8d2a4c8a HH a, b, c, d, 5, 4, 0xfffa3942 HH d, a, b, c, 8, 11, 0x8771f681 HH c, d, a, b, 11, 16, 0x6d9d6122 HH b, c, d, a, 14, 23, 0xfde5380c HH a, b, c, d, 1, 4, 0xa4beea44 HH d, a, b, c, 4, 11, 0x4bdecfa9 HH c, d, a, b, 7, 16, 0xf6bb4b60 HH b, c, d, a, 10, 23, 0xbebfbc70 HH a, b, c, d, 13, 4, 0x289b7ec6 HH d, a, b, c, 0, 11, 0xeaa127fa HH c, d, a, b, 3, 16, 0xd4ef3085 HH b, c, d, a, 6, 23, 0x4881d05 HH a, b, c, d, 9, 4, 0xd9d4d039 HH d, a, b, c, 12, 11, 0xe6db99e5 HH c, d, a, b, 15, 16, 0x1fa27cf8 HH b, c, d, a, 2, 23, 0xc4ac5665 II a, b, c, d, 0, 6, 0xf4292244 II d, a, b, c, 7, 10, 0x432aff97 II c, d, a, b, 14, 15, 0xab9423a7 II b, c, d, a, 5, 21, 0xfc93a039 II a, b, c, d, 12, 6, 0x655b59c3 II d, a, b, c, 3, 10, 0x8f0ccc92 II c, d, a, b, 10, 15, 0xffeff47d II b, c, d, a, 1, 21, 0x85845dd1 II a, b, c, d, 8, 6, 0x6fa87e4f II d, a, b, c, 15, 10, 0xfe2ce6e0 II c, d, a, b, 6, 15, 0xa3014314 II b, c, d, a, 13, 21, 0x4e0811a1 II a, b, c, d, 4, 6, 0xf7537e82 II d, a, b, c, 11, 10, 0xbd3af235 II c, d, a, b, 2, 15, 0x2ad7d2bb II b, c, d, a, 9, 21, 0xeb86d391 add eax, [esp+stack.a+4] add ebx, [esp+stack.b+4] add ecx, [esp+stack.c+4] add edx, [esp+stack.d+4] retn ; ----------------------------------- ; cell info ;============================================================================== section .c_info ; version: db 1,0,0,'a' ; ptr to cell's name dd str_cellname ; ptr to author's name dd str_author ; ptr to copyrights dd str_copyrights str_cellname: db "md5 - a cell implementing the MD5 secure message-digest algorithm",0 str_author: db "<NAME> <<EMAIL>>",0 str_copyrights: db "public domain",0
tests_resultats/test_svg.adb
zyron92/banana_tree_generator
0
27318
with Parseur_Temp,Svg_Helpers,Ada.Text_IO, Ada.Integer_Text_IO; use Parseur_Temp,Svg_Helpers,Ada.Text_IO, Ada.Integer_Text_IO; procedure Test_Svg is Fichier : File_Type; P1: Coord_Point := (X=>-2.5, Y=>-4.33012701892219); P2: Coord_Point := (X=>-0.492608180923429, Y=>-6.55956149535438); begin Create(Fichier,Out_File,"test_svg_OK.svg"); Header(14.5190978224269,14.5190978224269,Fichier); Translation_Image(6.43444280220142,7.92820323027551,Fichier); Appliquer_Couleur_Epaisseur(True,0,0,0,"0.1",Fichier); Tracer_Ligne_Droite(P1,P2,Fichier); Fin_Couleur_Translation(Fichier); Appliquer_Couleur_Epaisseur(False,255,0,0,"0.1",Fichier); Tracer_Courbe(-1.49630409046171,-5.44484425713829,-1.41780015609729,-3.94689995500642,-1.66723373785405,-5.12039269405429,-1.1296818135361,-3.72002205430849, Fichier); Fin_Couleur_Translation(Fichier); Fin_Couleur_Translation(Fichier); Footer(Fichier); Close (Fichier); end Test_Svg;
oeis/216/A216441.asm
neoneye/loda-programs
11
174213
; A216441: a(n) = n! mod !n. ; Submitted by <NAME> ; 0,0,6,32,190,1332,10654,95888,958878,10547660,126571918,1645434936,23036089102,345541336532,5528661384510,93987243536672,1691770383660094,32143637289541788,642872745790835758,13500327661607550920,297007208555366120238,6831165796773420765476,163947979122562098371422,4098699478064052459285552,106566186429665363941424350,2877287033600964826418457452,80564036940827015139716808654,2336357071283983439051787450968,70090712138519503171553623529038,2172812076294104598318162329400180 lpb $0 mov $2,$0 mov $3,$0 seq $3,6347 ; a(n) = (n+1) a(n-1) + (-1)^n. lpb $0 dif $0,$2 lpe lpe mov $0,$3 mul $0,2
wof/lcs/123p/7C.asm
zengfr/arcade_game_romhacking_sourcecode_top_secret_data
6
86441
copyright zengfr site:http://github.com/zengfr/romhack 001DC2 move.w ($7c,A0), D2 [123p+ 80] 001DC6 lea ($288,A5), A1 [123p+ 7C] 002FF6 move.w D0, D1 [123p+ 7C] 00815E move.w D0, ($7e,A1) [123p+ 7C] 008258 jsr $f76.w [123p+ 7C] 008874 beq $8882 [123p+ 7C] 008B3E move.w D0, ($7e,A1) [123p+ 7C] 008FB4 jsr $f76.w [123p+ 7C] 0092DC cmp.w ($7c,A1), D0 [123p+ 7C] 009436 move.w ($7e,A1), D5 [123p+ 7C] 0094C0 cmp.w ($7e,A1), D5 [123p+ 7C] 0096A8 jsr $f76.w [123p+ 7C] 01A61C move.w #$4, ($3f78,A5) 01A622 move.w #$8, ($4058,A5) [123p+ 7C] 01A628 move.w #$0, ($3e3e,A5) [123p+ 7C] 01A74C dbra D7, $1a74a 01A75E dbra D4, $1a75c 01ABB2 movea.l #$a679a, A4 [123p+ 7C] 01AC8E move.w D3, D4 [123p+ 7C] 01EA9E jsr $f76.w [123p+ 7C] copyright zengfr site:http://github.com/zengfr/romhack
data/mapHeaders/Route18.asm
AmateurPanda92/pokemon-rby-dx
9
241865
Route18_h: db OVERWORLD ; tileset db ROUTE_18_HEIGHT, ROUTE_18_WIDTH ; dimensions (y, x) dw Route18_Blocks ; blocks dw Route18_TextPointers ; texts dw Route18_Script ; scripts db NORTH | EAST ; connections NORTH_MAP_CONNECTION ROUTE_18, ROUTE_17, 0, 0, Route17_Blocks EAST_MAP_CONNECTION ROUTE_18, FUCHSIA_CITY, -3, 1, FuchsiaCity_Blocks, 1 dw Route18_Object ; objects
Examples/ch09/Bsearch/B_main.asm
satadriver/LiunuxOS_t
0
83096
TITLE Bubble Sort and Binary Search B_main.asm) ; Bubble sort an array of signed integers, and perform ; a binary search. ; Main module, calls Bsearch.asm, Bsort.asm, FillArry.asm ; Last update: 1/18/02 INCLUDE Irvine32.inc INCLUDE Bsearch.inc ; procedure prototypes LOWVAL = -5000 ; minimum value HIGHVAL = +5000 ; maximum value ARRAY_SIZE = 50 ; size of the array .data array DWORD ARRAY_SIZE DUP(?) .code main PROC call Randomize ; Fill an array with random signed integers INVOKE FillArray, ADDR array, ARRAY_SIZE, LOWVAL, HIGHVAL ; Display the array INVOKE PrintArray, ADDR array, ARRAY_SIZE call WaitMsg ; Perform a bubble sort and redisplay the array INVOKE BubbleSort, ADDR array, ARRAY_SIZE INVOKE PrintArray, ADDR array, ARRAY_SIZE ; Demonstrate a binary search call AskForSearchVal ; returned in EAX INVOKE BinarySearch, ADDR array, ARRAY_SIZE, eax call ShowResults exit main ENDP ;-------------------------------------------------------- AskForSearchVal PROC ; ; Prompt the user for a signed integer. ; Receives: nothing ; Returns: EAX = value input by user ;-------------------------------------------------------- .data prompt BYTE "Enter a signed decimal integer " BYTE "to find in the array: ",0 .code call Crlf mov edx,OFFSET prompt call WriteString call ReadInt ret AskForSearchVal ENDP ;-------------------------------------------------------- ShowResults PROC ; ; Display the resulting value from the binary search. ; Receives: EAX = position number to be displayed ; Returns: nothing ;-------------------------------------------------------- .data msg1 BYTE "The value was not found.",0 msg2 BYTE "The value was found at position ",0 .code .IF eax == -1 mov edx,OFFSET msg1 call WriteString .ELSE mov edx,OFFSET msg2 call WriteString call WriteDec .ENDIF call Crlf call Crlf ret ShowResults ENDP END main
src/common/marsupilamifourteen.ads
damaki/libkeccak
26
23756
<reponame>damaki/libkeccak<filename>src/common/marsupilamifourteen.ads ------------------------------------------------------------------------------- -- Copyright (c) 2019, <NAME> -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY -- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with Keccak.Keccak_1600.Rounds_14; with Keccak.Generic_KangarooTwelve; with Keccak.Parallel_Keccak_1600.Rounds_14; with Keccak.Generic_Parallel_Sponge; with Keccak.Generic_Parallel_XOF; with Keccak.Generic_Sponge; with Keccak.Generic_XOF; with Keccak.Padding; with Interfaces; -- @summary -- Defines the MarsupilamiFourteen instance. -- -- @description -- MarsupilamiFourteen is a variant of KangarooTwelve which provides 256-bit -- security (compared to 128-bit for KangarooTwelve). MarsupilamiFourteen is -- identical to KangarooTwelve except for the following differences: -- -- * MarsupilamiFourteen uses a 512-bit capacity (256-bit for KangarooTwelve) -- * MarsupilamiFourteen uses a 14-round Keccak permutation (14 rounds for KangarooTwelve) -- * MarsupilamiFourteen uses a 512-bit chaining value (256-bit for KangarooTwelve) -- -- @group MarsupilamiFourteen package MarsupilamiFourteen with SPARK_Mode => On is -- @summary -- Implementation-defined packages for creating a M14 instance. -- -- @private package Implementation is M14_Capacity : constant := 512; -- Capacity in bits (security parameter) for MarsupilamiFourteen. -- Now we can build a XOF on each parallel sponge package XOF_S1 is new Keccak.Generic_XOF (XOF_Sponge => Keccak.Keccak_1600.Rounds_14.Sponge, Capacity => M14_Capacity, Suffix => 0, -- Add no suffix here, since suffix is dynamic (01 or 11) Suffix_Size => 0); package XOF_P2 is new Keccak.Generic_Parallel_XOF (Sponge => Keccak.Parallel_Keccak_1600.Rounds_14.Parallel_Sponge_P2, Capacity => M14_Capacity, Suffix => 2#011#, Suffix_Size => 3); package XOF_P4 is new Keccak.Generic_Parallel_XOF (Sponge => Keccak.Parallel_Keccak_1600.Rounds_14.Parallel_Sponge_P4, Capacity => M14_Capacity, Suffix => 2#011#, Suffix_Size => 3); package XOF_P8 is new Keccak.Generic_Parallel_XOF (Sponge => Keccak.Parallel_Keccak_1600.Rounds_14.Parallel_Sponge_P8, Capacity => M14_Capacity, Suffix => 2#011#, Suffix_Size => 3); end Implementation; package M14 is new Keccak.Generic_KangarooTwelve (CV_Size_Bytes => 512 / 8, XOF_Serial => Implementation.XOF_S1, XOF_Parallel_2 => Implementation.XOF_P2, XOF_Parallel_4 => Implementation.XOF_P4, XOF_Parallel_8 => Implementation.XOF_P8); end MarsupilamiFourteen;
Transynther/x86/_processed/AVXALIGN/_zr_/i7-7700_9_0x48_notsx.log_21829_652.asm
ljhsiun2/medusa
9
7523
<reponame>ljhsiun2/medusa<filename>Transynther/x86/_processed/AVXALIGN/_zr_/i7-7700_9_0x48_notsx.log_21829_652.asm .global s_prepare_buffers s_prepare_buffers: push %r12 push %r14 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x10cdc, %rbx nop nop nop xor $15966, %r14 movups (%rbx), %xmm0 vpextrq $1, %xmm0, %rdx nop nop nop nop nop add $35439, %r12 lea addresses_WC_ht+0x1bf60, %rsi lea addresses_D_ht+0x9ce0, %rdi clflush (%rsi) nop nop nop nop and %rax, %rax mov $26, %rcx rep movsq nop cmp $8586, %r14 lea addresses_D_ht+0x6e60, %r12 sub $30210, %r14 mov (%r12), %ax nop nop nop nop nop xor $21200, %rax lea addresses_WC_ht+0x1ed40, %rax clflush (%rax) nop nop nop add $39398, %rdi movups (%rax), %xmm1 vpextrq $1, %xmm1, %r12 nop nop nop nop nop add %r14, %r14 lea addresses_UC_ht+0x14260, %r12 clflush (%r12) nop nop nop add $1142, %rbx mov $0x6162636465666768, %r14 movq %r14, (%r12) nop dec %rax lea addresses_WC_ht+0x1791f, %rdx cmp $17801, %rsi mov $0x6162636465666768, %rcx movq %rcx, %xmm0 and $0xffffffffffffffc0, %rdx vmovntdq %ymm0, (%rdx) nop nop nop and %rdi, %rdi lea addresses_D_ht+0x118c0, %r12 nop nop nop sub $37148, %rax vmovups (%r12), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $0, %xmm7, %rsi nop nop cmp $4640, %rdi lea addresses_UC_ht+0x320, %rax nop nop nop nop nop sub $33245, %r14 movups (%rax), %xmm5 vpextrq $0, %xmm5, %rsi nop nop nop nop and $48114, %rcx lea addresses_UC_ht+0x1e0e0, %rcx sub $56121, %rax movw $0x6162, (%rcx) sub %rdi, %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r14 pop %r12 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r15 push %rbp // Faulty Load mov $0x567d600000000e60, %r12 inc %r13 mov (%r12), %r15 lea oracles, %rbp and $0xff, %r15 shlq $12, %r15 mov (%rbp,%r15,1), %r15 pop %rbp pop %r15 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_NC', 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': True, 'AVXalign': True, 'size': 8, 'type': 'addresses_NC', 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 1}} {'dst': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_WC_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 9}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WC_ht', 'congruent': 5}} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC_ht', 'congruent': 9}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 0}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_D_ht', 'congruent': 5}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_UC_ht', 'congruent': 4}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC_ht', 'congruent': 7}, 'OP': 'STOR'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
Driver/Video/VGAlike/MEGA/megaOutput.asm
steakknife/pcgeos
504
240406
<filename>Driver/Video/VGAlike/MEGA/megaOutput.asm<gh_stars>100-1000 COMMENT }%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1988 -- All Rights Reserved PROJECT: PC GEOS MODULE: MEGA video driver FILE: megaOutput.asm AUTHOR: <NAME>, <NAME> ROUTINES: Name Description ---- ----------- GBL VidDrawRect draw a filled rectangle REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 4/88 initial version Tony 11/88 converted from Bitmap jeremy 4/91 monochrome support DESCRIPTION: This is the source for the MEGA screen driver output routines. This file is included in the file Kernel/Screen/mega.asm The complete specification for screen drivers can be found on the system in the pcgeos spec directory (/usr/pcgeos/Spec/video.doc). $Id: megaOutput.asm,v 1.1 97/04/18 11:42:13 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} COMMENT @----------------------------------------------------------------------- FUNCTION: OptRectOneWord DESCRIPTION: Draw an unclipped rectangle in the GR_COPY draw mode CALLED BY: INTERNAL DrawSimpleRect PASS: cx - pattern index es:di - buffer address for first left:top of rectangle ds - Window structure bp - number of lines to draw al - left mask ah - right mask RETURN: DESTROYED: ax, bx, cx, dx, si, di, bp REGISTER/STACK USAGE: dx = EGA output register al = EGA bitmask register index ah = pattern byte, byte to store bx = pattern index cx = mask for bits to save dx = mask for new bits si = temp (screen AND bits to save) es:di = screen buffer address bp = counter PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version -------------------------------------------------------------------------------@ OptRectOneWord proc near xchg bx, cx ; bx <- index to pattern mov cx, ax ; save masks and ch, cl ; ch = mask of rectangle mov dx, GR_CONTROL jmp short OROW_loopEntry OROW_loop: add di, BWID_SCR inc bx ; bx <- new pattern index and bx, 7 OROW_loopEntry: SetMEGAColor mov ah, cs:[bx][ditherMatrix] and ah, ch ; ah <- white's pattern mask mov al, BITMASK ; set bitmask reg out dx, ax or es:[di], al ; paint the white pixels ClearMEGAColor mov ah, cs:[bx][ditherMatrix] not ah and ah, ch ; ah <- black's pattern mask mov al, BITMASK ; set bitmask reg out dx, ax or es:[di], al ; paint the black pixels dec bp ;loop to do all lines jnz OROW_loop ret OptRectOneWord endp public OptRectOneWord COMMENT @----------------------------------------------------------------------- FUNCTION: DrawOptRect DESCRIPTION: Draw a rectangle with draw mode GR_COPY and all bits in the draw mask set CALLED BY: INTERNAL DrawSimpleRect PASS: dx - number of bytes covered by rectangle + 1 zero flag - set if rect is one byte wide cx - pattern index es:di - buffer address for first left:top of rectangle ds - Window structure bp - number of lines to draw al - left mask ah - right mask RETURN: DESTROYED: ax, bx, cx, dx, si, di, bp REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version -------------------------------------------------------------------------------@ DrawOptRect proc near jz OptRectOneWord mov bx, ax ; pass masks ; calculate # of bytes in the middle of the line, offset to next line dec dx ;number of middle bytes mov cs:[BOR_middleCount],dx ;pass number of middle bytes neg dx add dx, BWID_SCR-1 mov cs:[BOR_nextScanOffset], dx mov dx, GR_CONTROL ; set up control reg for ega mov al, BITMASK mov si, cx GOTO BlastOptRect DrawOptRect endp public DrawOptRect COMMENT @----------------------------------------------------------------------- FUNCTION: BlastOptRect DESCRIPTION: Draw an unclipped rectangle in the GR_COPY draw mode CALLED BY: INTERNAL VidDrawRect PASS: es:di - buffer address for first left:top of rectangle ds - Window structure bp - number of lines to draw BOR_middleCount - number of middle words dx - GR_CONTROL bl - left mask bh - right mask BOR_nextScanOffset - offset to next scan line RETURN: DESTROYED: ax, bx, cx, dx, si, di, bp REGISTER/STACK USAGE: ax = pattern word, word to store bx = pattern index cx = for left and right: (screen AND bits to save), for middle: counter si = temp for left (pattern word) dx = offset to next scan line es:di = screen buffer address bp = counter PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version -------------------------------------------------------------------------------@ BOR_loop: ; move to next scan line BOR_1 label word BOR_nextScanOffset = BOR_1 + 2 add di, 1234h ;MODIFIED inc si BlastOptRect proc near ; figure out index to pattern mask for this scan line and si, 7 ; ; Set draw color: SetMEGAColor ; handle left byte specially mov ah, bl and ah, cs:[si][ditherMatrix] ; mov al, BITMASK out dx, ax or es:[di], al ;modify word ; Reset draw color: ClearMEGAColor mov ah, cs:[si][ditherMatrix] not ah and ah, bl mov al, BITMASK out dx, ax or es:[di], al ;modify word inc di ; draw middle bytes BOR_2 label word BOR_middleCount = BOR_2 + 1 mov cx,1234h ;MODIFIED tst cx jz handleRightByte mov al, BITMASK ; mov ah, cs:[si][ditherMatrix] tst ah ; are we drawing just black? jz doBlackWrite ; jump if so cmp ah, 0xff ; are we drawing just white? je doWhiteWrite ; jump if so ; Mixed pattern: we need to read/write twice. out dx, ax ; SetMEGAColor push ds, si push cx, di push si segmov ds, es, ax ; mov si, di ; rep movsb ; blast out white pixels ClearMEGAColor pop si mov ah, cs:[si][ditherMatrix] not ah ; mov al, BITMASK ; out dx, ax ; pop cx, di ; blast out black pixels mov si, di ; rep movsb ; blammo. pop ds, si ; jmp short handleRightByte ; doBlackWrite: ; The middle bytes are all the reset color. Blast 'em. not ah ; out dx, ax ; ClearMEGAColor rep stosb ; jmp short handleRightByte ; doWhiteWrite: ; The middle bytes are all white. Blast 'em. out dx, ax ; SetMEGAColor rep stosb ; ; FALL THROUGH TO handleRightByte handleRightByte: ; handle right byte specially ; Set draw color: SetMEGAColor mov ah, bh ; ah <- right word mask and ah, cs:[si][ditherMatrix] mov al, BITMASK out dx, ax or es:[di], al ;modify word ; Reset draw color: ClearMEGAColor mov ah, cs:[si][ditherMatrix] not ah ; and ah, bh ; mov al, BITMASK out dx, ax or es:[di], al ;modify word dec bp ;loop to do all lines LONG jnz BOR_loop ret BlastOptRect endp public BlastOptRect COMMENT @----------------------------------------------------------------------- FUNCTION: SpecialRectOneWord DESCRIPTION: Draw an unclipped rectangle in the GR_COPY draw mode CALLED BY: INTERNAL DrawSimpleRect PASS: cx - pattern index es:di - buffer address for first left:top of rectangle ds - Window structure bp - number of lines to draw al - left mask ah - right mask RETURN: DESTROYED: ax, bx, cx, dx, si, di, bp REGISTER/STACK USAGE: dx = EGA output register al = EGA bitmask register index ah = pattern byte, byte to store bx = pattern index cx = mask for bits to save dx = mask for new bits si = temp (screen AND bits to save) es:di = screen buffer address bp = counter PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version -------------------------------------------------------------------------------@ SpecialRectOneWord proc near mov bx, cx ; use bx as pattern index and al, ah mov cl, al ; cl = mask ; We have to figure out if the bits in the maskBuffer should be ; drawn in black or white. mov ah, 0xff ; assume white on black clr al ; If the mode is INVERT, the set color is "white," or set bits. cmp cs:currentDrawMode, MM_INVERT je setMaskColors ; If the mode is XOR, the set color is "white," or set bits. cmp cs:currentDrawMode, MM_XOR je setMaskColors ; If the mode is SET, the set color is "white," or set bits. cmp cs:currentDrawMode, MM_SET je setMaskColors ; For other modes, set the draw color to the reverse ; of the ditherMatrix. tst cs:[ditherMatrix] ; draw in black? jnz setMaskColors ; jump if not. not ax ; else, yep, draw in black. setMaskColors: mov cs:maskSetColor, ah mov cs:maskResetColor, al mov dx, GR_CONTROL jmp short SROW_loopEntry SROW_loop: inc bl and bl, 7 add di, BWID_SCR SROW_loopEntry: clr al ; mov ah, cs:maskSetColor ; draw white pixels first out dx, ax ; mov al, BITMASK ; set bitmask reg mov ah, {byte} cs:[bx][maskBuffer] ; get pattern byte and ah,cl ; and in mask out dx, ax ; set update mask or es:[di], al dec bp ;loop to do all lines jnz SROW_loop ret SpecialRectOneWord endp public SpecialRectOneWord COMMENT @----------------------------------------------------------------------- FUNCTION: DrawSpecialRect DESCRIPTION: Draw a rectangle with draw mode GR_COPY and all bits in the draw mask set CALLED BY: INTERNAL DrawSimpleRect PASS: dx - number of bytes covered by rectangle + 1 zero flag - set if rect is one byte wide cx - pattern index es:di - buffer address for first left:top of rectangle ds - Window structure bp - number of lines to draw al - left mask ah - right mask RETURN: DESTROYED: ax, bx, cx, dx, si, di, bp REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version -------------------------------------------------------------------------------@ DrawSpecialRect proc near jz SpecialRectOneWord mov word ptr cs:[d_LRmasks], ax ; store masks ; calculate # of bytes in the middle of the line, offset to next line dec dx ;number of middle bytes mov si,dx ;pass number of middle bytes neg dx add dx, BWID_SCR-2 mov cs:[BSR_nextScanOffset], dx mov dx, GR_CONTROL ; set up control reg for ega mov al, BITMASK mov bx, cx ; bx = pattern index GOTO BlastSpecialRect DrawSpecialRect endp public DrawSpecialRect COMMENT @----------------------------------------------------------------------- FUNCTION: BlastSpecialRect DESCRIPTION: Draw an unclipped rectangle in the GR_COPY draw mode CALLED BY: INTERNAL VidDrawRect PASS: bx - index into pattern buffer (0-7) es:di - buffer address for first left:top of rectangle ds - Window structure bp - number of lines to draw si - number of middle words dx - GR_CONTROL BSR_nextScanOffset - offset to next scan line RETURN: DESTROYED: ax, bx, cx, dx, si, di, bp REGISTER/STACK USAGE: ax = pattern word, word to store bx = pattern index cx = for left and right: (screen AND bits to save), for middle: counter dx = offset to next scan line es:di = screen buffer address bp = counter PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/88 Initial version -------------------------------------------------------------------------------@ BlastSpecialRect proc near ; We have to figure out if the bits in the maskBuffer should be ; drawn in black or white. mov ah, 0xff ; assume white on black clr al ; If the mode is INVERT, the set color is "white," or set bits. cmp cs:currentDrawMode, MM_INVERT je setMaskColors ; If the mode is XOR, the set color is "white," or set bits. cmp cs:currentDrawMode, MM_XOR je setMaskColors ; If the mode is SET, the set color is "white," or set bits. cmp cs:currentDrawMode, MM_SET je setMaskColors ; For other modes, set the draw color to the reverse ; of the ditherMatrix. tst cs:[ditherMatrix] ; draw in black? jnz setMaskColors ; jump if not. not ax ; else, yep, draw in black. setMaskColors: mov cs:maskSetColor, ah mov cs:maskResetColor, al jmp short BlastSpecialRectEntry BSR_loop: ; update pattern pointer inc bl and bl, 7 ; move to next scan line BSR_1 label word BSR_nextScanOffset = BSR_1 + 2 add di, 1234h ;MODIFIED BlastSpecialRectEntry: ; handle left byte specially clr al mov ah, cs:maskSetColor out dx, ax mov al, BITMASK mov ah, {byte} cs:[bx][maskBuffer] ; use pattern byte and ah, cs:[d_leftMask] out dx, ax or es:[di], al ;modify word inc di ; draw middle bytes mov cx,si jcxz BSR_noMiddle BSR_inner: clr al mov ah, cs:maskSetColor out dx, ax mov al, BITMASK mov ah, {byte} cs:[bx][maskBuffer] ; use pattern byte out dx, ax or es:[di], al inc di loop BSR_inner BSR_noMiddle: ; handle right word specially clr al mov ah, cs:maskSetColor out dx, ax mov al, BITMASK mov ah, {byte} cs:[bx][maskBuffer] ; use pattern byte and ah, cs:[d_rightMask] out dx, ax or es:[di], al ;modify word inc di dec bp ;loop to do all lines jnz BSR_loop ret BlastSpecialRect endp public BlastSpecialRect
build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/Expression.g4
jixuan1989/plc4x
0
5352
<filename>build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/Expression.g4 grammar Expression; // Borrowed part of this Grammar: // https://github.com/bkiers/tiny-language-antlr4/blob/master/src/main/antlr4/tl/antlr4/TL.g4 // Which is under UNLICENCE: // https://unlicense.org/ // Which is regarded beint Category A: // https://issues.apache.org/jira/browse/LEGAL-463 expressionString : expression EOF ; expression : '-' expression #unaryMinusExpression | '!' expression #notExpression | <assoc=right> expression '^' expression #powerExpression | expression op=( '*' | '/' | '%' ) expression #multExpression | expression op=( '+' | '-' ) expression #addExpression | expression op=( '>=' | '<=' | '>' | '<' ) expression #compExpression | expression op=( '==' | '!=' ) expression #eqExpression | expression '&&' expression #andExpression | expression '||' expression #orExpression | expression '?' expression ':' expression #ifExpression | Number #numberExpression | Bool #boolExpression | Null #nullExpression | identifierSegment #identifierExpression | String indexes? #stringExpression | '(' expression ')' indexes? #expressionExpression ; identifierSegment : name=Identifier args=identifierSegmentArguments? index=identifierSegmentIndexes? ('.' rest=identifierSegmentRest)? ; identifierSegmentArguments : arguments ; identifierSegmentIndexes : indexes ; identifierSegmentRest : identifierSegment ; arguments : '(' (expression (',' expression)*)? ')' ; indexes : ( '[' expression ']' )+ ; Null : 'null'; Bool : 'true' | 'false' ; Number : Int ( '.' Digit* )? ; Identifier : [a-zA-Z_] [a-zA-Z_0-9]* ; String : ["] ( ~["\r\n\\] | '\\' ~[\r\n] )* ["] | ['] ( ~['\r\n\\] | '\\' ~[\r\n] )* ['] ; Space : [ \t\r\n\u000C] -> skip ; fragment Int : [1-9] Digit* | '0' ; fragment Digit : [0-9] ;
Applications/System-Events/attach action to/attach action to POSIX file a as alias using (POSIX file f as alias).applescript
looking-for-a-job/applescript-examples
1
1413
#!/usr/bin/osascript set a to "/path/to/script.applescript" set f to "/path/to/folder" tell application "System Events" attach action to POSIX file a as alias using (POSIX file f as alias) end tell
Task/Hostname/Ada/hostname.ada
LaudateCorpus1/RosettaCodeData
1
24633
<gh_stars>1-10 with Ada.Text_IO; use Ada.Text_IO; with GNAT.Sockets; procedure Demo is begin Put_Line (GNAT.Sockets.Host_Name); end Demo;
src/main/antlr4/imports/SharedParser.g4
gvlasov/inflectible
30
2312
parser grammar GrammemesParser; options { tokenVocab=GrammemesLexer; } grammemes: GRAMMEME+; conceptId: CONCEPT_ID;
externals/mpir-3.0.0/mpn/powerpc32/add_n.asm
JaminChan/eos_win
12
9247
dnl PowerPC-32 mpn_add_n -- add limb vectors. dnl Copyright 2002, 2005 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of the GNU Lesser General Public License as published dnl by the Free Software Foundation; either version 2.1 of the License, or (at dnl your option) any later version. dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public dnl License for more details. dnl You should have received a copy of the GNU Lesser General Public License dnl along with the GNU MP Library; see the file COPYING.LIB. If not, write dnl to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, dnl Boston, MA 02110-1301, USA. include(`../config.m4') C cycles/limb C 603e: ? C 604e: 3.25 C 75x (G3): 3.5 C 7400,7410 (G4): 3.5 C 744x,745x (G4+): 4.25 C power4/ppc970: 2.0 C power5: 2.5 C INPUT PARAMETERS C rp r3 C s1p r4 C s2p r5 C n r6 C cy r7 ASM_START() PROLOGUE(mpn_add_nc) addic r0,r7,-1 C set hw cy from cy argument cmpwi cr0,r6,15 C more than 15 limbs? ble L(com) C branch if <= 15 limbs b L(BIG) EPILOGUE(mpn_add_nc) PROLOGUE(mpn_add_n) addic r0,r0,0 C clear hw cy cmpwi cr0,r6,15 C more than 15 limbs? bgt L(BIG) C branch if > 15 limbs L(com): mtctr r6 C copy size into CTR addi r3,r3,-4 C offset rp, it's updated before it's used lwz r0,0(r4) C load s1 limb lwz r7,0(r5) C load s2 limb adde r10,r7,r0 bdz L(endS) L(loopS): lwzu r0,4(r4) C load s1 limb lwzu r7,4(r5) C load s2 limb stwu r10,4(r3) C store result limb adde r10,r7,r0 bdnz L(loopS) L(endS): stwu r10,4(r3) C store result limb li r3,0 addze r3,r3 blr L(BIG): stmw r30,-8(r1) C should avoid this for small sizes! andi. r12,r6,3 mtctr r12 C copy size into CTR addi r4,r4,-4 addi r5,r5,-4 addi r3,r3,-4 beq L(multiple_of_4) lwzu r0,4(r4) C load s1 limb lwzu r7,4(r5) C load s2 limb adde r10,r7,r0 bdz L(end0) L(loop0): lwzu r0,4(r4) C load s1 limb lwzu r7,4(r5) C load s2 limb stwu r10,4(r3) C store result limb adde r10,r7,r0 bdnz L(loop0) L(end0): stwu r10,4(r3) C store result limb L(multiple_of_4): srwi r6,r6,2 mtctr r6 C copy size into CTR lwz r0,4(r4) C load s1 limb lwz r7,4(r5) C load s2 limb lwz r8,8(r4) C load s1 limb lwz r9,8(r5) C load s2 limb lwz r10,12(r4) C load s1 limb lwz r11,12(r5) C load s2 limb lwzu r12,16(r4) C load s1 limb adde r31,r7,r0 C add limbs with cy, set cy lwzu r6,16(r5) C load s2 limb bdz L(enda) L(loop): lwz r0,4(r4) C load s1 limb adde r30,r9,r8 C add limbs with cy, set cy lwz r7,4(r5) C load s2 limb stw r31,4(r3) C store result limb lwz r8,8(r4) C load s1 limb adde r31,r11,r10 C add limbs with cy, set cy lwz r9,8(r5) C load s2 limb stw r30,8(r3) C store result limb lwz r10,12(r4) C load s1 limb adde r30,r6,r12 C add limbs with cy, set cy lwz r11,12(r5) C load s2 limb stw r31,12(r3) C store result limb lwzu r12,16(r4) C load s1 limb adde r31,r7,r0 C add limbs with cy, set cy stwu r30,16(r3) C store result limb lwzu r6,16(r5) C load s2 limb bdnz L(loop) C decrement CTR and loop back L(enda): adde r30,r9,r8 C add limbs with cy, set cy stw r31,4(r3) C store result limb adde r31,r11,r10 C add limbs with cy, set cy stw r30,8(r3) C store result limb adde r30,r6,r12 C add limbs with cy, set cy stw r31,12(r3) C store result limb stw r30,16(r3) C store result limb L(end): li r3,0 addze r3,r3 lmw r30,-8(r1) blr EPILOGUE(mpn_add_n)
07/MemoryAccess/PointerTest/PointerTest.asm
DarkCleopas/vm-translator
0
20979
@3030 // push constant 3030 D=A @SP A=M M=D @SP M=M+1 @SP // pop pointer 0 M=M-1 A=M D=M @R3 M=D @3040 // push constant 3040 D=A @SP A=M M=D @SP M=M+1 @SP // pop pointer 1 M=M-1 A=M D=M @R4 M=D @32 // push constant 32 D=A @SP A=M M=D @SP M=M+1 @THIS // pop this 2 D=M @2 D=D+A @R13 M=D @SP M=M-1 A=M D=M @R13 A=M M=D @46 // push constant 46 D=A @SP A=M M=D @SP M=M+1 @THAT // pop that 6 D=M @6 D=D+A @R13 M=D @SP M=M-1 A=M D=M @R13 A=M M=D @R3 // push pointer 0 D=M @SP A=M M=D @SP M=M+1 @R4 // push pointer 1 D=M @SP A=M M=D @SP M=M+1 @SP AM=M-1 D=M A=A-1 M=D+M @THIS // push this 2 D=M @2 A=D+A D=M @SP A=M M=D @SP M=M+1 @SP AM=M-1 D=M A=A-1 M=M-D @THAT // push that 6 D=M @6 A=D+A D=M @SP A=M M=D @SP M=M+1 @SP AM=M-1 D=M A=A-1 M=D+M
Data/MonoidalHeap.agda
oisdk/agda-playground
6
14618
{-# OPTIONS --cubical --safe #-} open import Algebra open import Relation.Binary open import Algebra.Monus module Data.MonoidalHeap {s} (monus : TMPOM s) where open TMPOM monus open import Prelude open import Data.List using (List; _∷_; []) import Data.Nat as ℕ import Data.Nat.Properties as ℕ 𝒮 : Type s 𝒮 = 𝑆 → 𝑆 ⟦_⇑⟧ : 𝑆 → 𝒮 ⟦_⇑⟧ = _∙_ ⟦_⇓⟧ : 𝒮 → 𝑆 ⟦ x ⇓⟧ = x ε infixl 10 _⊙_ _⊙_ : (𝑆 → A) → 𝑆 → 𝑆 → A f ⊙ x = λ y → f (x ∙ y) infixr 6 _∹_&_ data Heap (V : 𝑆 → Type a) : Type (a ℓ⊔ s) where [] : Heap V _∹_&_ : (key : 𝑆) (val : V key) (children : List (Heap (V ⊙ key))) → Heap V Heap⋆ : (V : 𝑆 → Type a) → Type (a ℓ⊔ s) Heap⋆ V = List (Heap V) private variable v : Level V : 𝑆 → Type v ⊙ε : V ≡ V ⊙ ε ⊙ε {V = V} i x = V (sym (ε∙ x) i) lemma : ∀ x y k → x ≡ y ∙ k → ⟦ x ⇑⟧ ≡ ⟦ y ⇑⟧ ∘ ⟦ k ⇑⟧ lemma x y k x≡y∙k i z = (cong (_∙ z) x≡y∙k ; assoc y k z) i merge : Heap V → Heap V → Heap V merge [] ys = ys merge (x ∹ xv & xs) [] = x ∹ xv & xs merge {V = V} (x ∹ xv & xs) (y ∹ yv & ys) with x ≤|≥ y ... | inl (k , x≤y) = x ∹ xv & (k ∹ subst V x≤y yv & subst (List ∘ Heap ∘ _∘_ V) (lemma y x k x≤y) ys ∷ xs) ... | inr (k , x≥y) = y ∹ yv & (k ∹ subst V x≥y xv & subst (List ∘ Heap ∘ _∘_ V) (lemma x y k x≥y) xs ∷ ys) mergeQs⁺ : Heap V → Heap⋆ V → Heap V mergeQs⁺ x₁ [] = x₁ mergeQs⁺ x₁ (x₂ ∷ []) = merge x₁ x₂ mergeQs⁺ x₁ (x₂ ∷ x₃ ∷ xs) = merge (merge x₁ x₂) (mergeQs⁺ x₃ xs) mergeQs : Heap⋆ V → Heap V mergeQs [] = [] mergeQs (x ∷ xs) = mergeQs⁺ x xs singleton : ∀ x → V x → Heap V singleton x xv = x ∹ xv & [] insert : ∀ x → V x → Heap V → Heap V insert x xv = merge (singleton x xv) minView : Heap V → Maybe (∃ p × V p × Heap (V ⊙ p)) minView [] = nothing minView (x ∹ xv & xs) = just (x , xv , mergeQs xs) variable v₁ v₂ : Level V₁ : 𝑆 → Type v₁ V₂ : 𝑆 → Type v₂ mutual maps : (∀ {x} → V₁ x → V₂ x) → Heap⋆ V₁ → Heap⋆ V₂ maps f [] = [] maps f (x ∷ xs) = map f x ∷ maps f xs map : (∀ {x} → V₁ x → V₂ x) → Heap V₁ → Heap V₂ map f [] = [] map f (k ∹ v & xs) = k ∹ f v & maps f xs mutual size : Heap V → ℕ size [] = zero size (_ ∹ _ & xs) = suc (sizes xs) sizes : Heap⋆ V → ℕ sizes [] = 0 sizes (x ∷ xs) = size x ℕ.+ sizes xs open import Data.Maybe using (maybe) open import Path.Reasoning open import Cubical.Foundations.Prelude using (substRefl) lemma₂ : ∀ {x y : 𝑆 → 𝑆} xs (p : x ≡ y) → sizes (subst (List ∘ Heap ∘ _∘_ V) p xs) ≡ sizes xs lemma₂ {V = V} xs = J (λ _ p → sizes (subst (List ∘ Heap ∘ _∘_ V) p xs) ≡ sizes xs) (cong sizes (substRefl {B = List ∘ Heap ∘ _∘_ V} xs)) merge-size : (xs ys : Heap V) → size (merge xs ys) ≡ size xs ℕ.+ size ys merge-size [] ys = refl merge-size (x ∹ xv & xs) [] = sym (ℕ.+-idʳ _) merge-size {V = V} (x ∹ xv & xs) (y ∹ yv & ys) with x ≤|≥ y merge-size {V = V} (x ∹ xv & xs) (y ∹ yv & ys) | inr (k , x≥y) = suc (suc (sizes (subst (List ∘ Heap ∘ _∘_ V) (lemma x y k x≥y) xs)) ℕ.+ sizes ys) ≡˘⟨ ℕ.+-suc _ (sizes ys) ⟩ suc (sizes (subst (List ∘ Heap ∘ _∘_ V) (lemma x y k x≥y) xs)) ℕ.+ suc (sizes ys) ≡⟨ cong (ℕ._+ suc (sizes ys)) (cong suc (lemma₂ {V = V} xs (lemma x y k x≥y))) ⟩ suc (sizes xs) ℕ.+ suc (sizes ys) ∎ merge-size {V = V} (x ∹ xv & xs) (y ∹ yv & ys) | inl (k , x≤y) = suc (suc (sizes (subst (List ∘ Heap ∘ _∘_ V) (lemma y x k x≤y) ys)) ℕ.+ sizes xs) ≡˘⟨ ℕ.+-suc _ (sizes xs) ⟩ suc (sizes (subst (List ∘ Heap ∘ _∘_ V) (lemma y x k x≤y) ys)) ℕ.+ suc (sizes xs) ≡⟨ cong (ℕ._+ suc (sizes xs)) (cong suc (lemma₂ {V = V} ys (lemma y x k x≤y))) ⟩ suc (sizes ys) ℕ.+ suc (sizes xs) ≡⟨ ℕ.+-comm (suc (sizes ys)) (suc (sizes xs)) ⟩ suc (sizes xs) ℕ.+ suc (sizes ys) ∎ mutual minViewSizes : (xs : Heap⋆ V) → sizes xs ≡ size (mergeQs xs) minViewSizes [] = refl minViewSizes (x ∷ xs) = minViewSizes⁺ x xs minViewSizes⁺ : (x : Heap V) → (xs : Heap⋆ V) → sizes (x ∷ xs) ≡ size (mergeQs⁺ x xs) minViewSizes⁺ x₁ [] = ℕ.+-idʳ _ minViewSizes⁺ x₁ (x₂ ∷ []) = cong (λ z → size x₁ ℕ.+ z) (ℕ.+-idʳ _) ; sym (merge-size x₁ x₂) minViewSizes⁺ x₁ (x₂ ∷ x₃ ∷ xs) = size x₁ ℕ.+ (size x₂ ℕ.+ sizes (x₃ ∷ xs)) ≡˘⟨ ℕ.+-assoc (size x₁) (size x₂) (sizes (x₃ ∷ xs)) ⟩ (size x₁ ℕ.+ size x₂) ℕ.+ sizes (x₃ ∷ xs) ≡⟨ cong ((size x₁ ℕ.+ size x₂) ℕ.+_) (minViewSizes⁺ x₃ xs) ⟩ (size x₁ ℕ.+ size x₂) ℕ.+ size (mergeQs⁺ x₃ xs) ≡˘⟨ cong (ℕ._+ size (mergeQs⁺ x₃ xs)) (merge-size x₁ x₂) ⟩ size (merge x₁ x₂) ℕ.+ size (mergeQs⁺ x₃ xs) ≡˘⟨ merge-size (merge x₁ x₂) (mergeQs⁺ x₃ xs) ⟩ size (merge (merge x₁ x₂) (mergeQs⁺ x₃ xs)) ∎ minViewSize : (xs : Heap V) → size xs ≡ maybe zero (suc ∘ size ∘ snd ∘ snd) (minView xs) minViewSize [] = refl minViewSize (x ∹ xv & xs) = cong suc (minViewSizes xs) zer : Heap⋆ V zer = [] one : Heap⋆ V one = [] ∷ [] open import Data.List using (_++_; concatMap) _<+>_ : Heap⋆ V → Heap⋆ V → Heap⋆ V _<+>_ = _++_ multIn : (p : 𝑆 → 𝑆) → (c : ∀ {x y} → V (p x) → V y → V (p (x ∙ y))) → (V ⇒ V ∘ p) → Heap⋆ (V ∘ p) → Heap⋆ V → Heap⋆ (V ∘ p) multIn {V = V} p c f [] ys = [] multIn {V = V} p c f ([] ∷ xs) ys = maps f ys ++ multIn p c f xs ys multIn {V = V} p c f (x ∹ xv & xc ∷ xs) ys = x ∹ xv & multIn (p ∘ ⟦ x ⇑⟧) (λ v₁ v₂ → subst V (cong p (assoc x _ _)) (c v₁ v₂)) (c xv) xc ys ∷ multIn p c f xs ys appl : (∀ {x y} → V x → V y → V (x ∙ y)) → Heap⋆ V → Heap⋆ V → Heap⋆ V appl {V = V} f xs ys = multIn {V = V} id f id xs ys
src/tools/Dependency_Graph_Extractor/src/extraction-with_clauses.adb
selroc/Renaissance-Ada
1
16255
<filename>src/tools/Dependency_Graph_Extractor/src/extraction-with_clauses.adb with Extraction.Node_Edge_Types; with Extraction.Utilities; package body Extraction.With_Clauses is use type LALCO.Ada_Node_Kind_Type; procedure Extract_Edges (Node : LAL.Ada_Node'Class; Graph : Graph_Operations.Graph_Context) is begin if Node.Kind = LALCO.Ada_With_Clause then declare With_Clause : constant LAL.With_Clause := Node.As_With_Clause; begin for Package_Name of With_Clause.F_Packages loop if not Utilities.Get_Referenced_Decl(Package_Name).Is_Null then -- TODO: Remove after TB01-005 has been fixed declare Target_Name : constant LAL.Defining_Name := Utilities.Get_Referenced_Defining_Name(Package_Name); Target_Decl : constant LAL.Basic_Decl := Utilities.Get_Referenced_Decl(Package_Name); begin Graph.Write_Edge(Package_Name.Unit, Target_Name, Target_Decl, Node_Edge_Types.Edge_Type_Imports); end; end if; end loop; end; end if; end Extract_Edges; end Extraction.With_Clauses;
source/amf/uml/amf-internals-uml_multiplicity_elements.adb
svn2github/matreshka
24
26999
<filename>source/amf/uml/amf-internals-uml_multiplicity_elements.adb ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Factories.UML_Factories; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.Stores; with AMF.UML.Literal_Integers; with AMF.UML.Literal_Unlimited_Naturals; package body AMF.Internals.UML_Multiplicity_Elements is use type AMF.UML.Value_Specifications.UML_Value_Specification_Access; UML_URI : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("http://www.omg.org/spec/UML/20100901"); -------------------- -- Get_Is_Ordered -- -------------------- overriding function Get_Is_Ordered (Self : not null access constant UML_Multiplicity_Element_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Ordered (Self.Element); end Get_Is_Ordered; ------------------- -- Get_Is_Unique -- ------------------- overriding function Get_Is_Unique (Self : not null access constant UML_Multiplicity_Element_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Unique (Self.Element); end Get_Is_Unique; --------------- -- Get_Lower -- --------------- overriding function Get_Lower (Self : not null access constant UML_Multiplicity_Element_Proxy) return AMF.Optional_Integer is begin -- [UML2.4.1] 7.3.33 MultiplicityElement (from Kernel) -- -- [5] The derived lower attribute must equal the lowerBound. -- -- lower = lowerBound() return UML_Multiplicity_Element_Proxy'Class (Self.all).Lower_Bound; end Get_Lower; --------------------- -- Get_Lower_Value -- --------------------- overriding function Get_Lower_Value (Self : not null access constant UML_Multiplicity_Element_Proxy) return AMF.UML.Value_Specifications.UML_Value_Specification_Access is begin return AMF.UML.Value_Specifications.UML_Value_Specification_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Lower_Value (Self.Element))); end Get_Lower_Value; --------------- -- Get_Upper -- --------------- overriding function Get_Upper (Self : not null access constant UML_Multiplicity_Element_Proxy) return AMF.Optional_Unlimited_Natural is begin -- [UML2.4.1] 7.3.33 MultiplicityElement (from Kernel) -- -- [6] The derived upper attribute must equal the upperBound. -- -- upper = upperBound() return UML_Multiplicity_Element_Proxy'Class (Self.all).Upper_Bound; end Get_Upper; --------------------- -- Get_Upper_Value -- --------------------- overriding function Get_Upper_Value (Self : not null access constant UML_Multiplicity_Element_Proxy) return AMF.UML.Value_Specifications.UML_Value_Specification_Access is begin return AMF.UML.Value_Specifications.UML_Value_Specification_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Upper_Value (Self.Element))); end Get_Upper_Value; -------------------- -- Is_Multivalued -- -------------------- overriding function Is_Multivalued (Self : not null access constant UML_Multiplicity_Element_Proxy) return Boolean is -- 7.3.33 MultiplicityElement (from Kernel) -- -- [1] The query isMultivalued() checks whether this multiplicity has an -- upper bound greater than one. -- -- MultiplicityElement::isMultivalued() : Boolean; -- pre: upperBound()->notEmpty() -- isMultivalued = (upperBound() > 1) Upper_Bound : constant Optional_Unlimited_Natural := UML_Multiplicity_Element_Proxy'Class (Self.all).Upper_Bound; begin if Upper_Bound.Is_Empty then raise Constraint_Error; end if; return Upper_Bound.Value > 1; end Is_Multivalued; ----------------- -- Lower_Bound -- ----------------- overriding function Lower_Bound (Self : not null access constant UML_Multiplicity_Element_Proxy) return AMF.Optional_Integer is -- 7.3.33 MultiplicityElement (from Kernel) -- -- [4] The query lowerBound() returns the lower bound of the -- multiplicity as an integer. -- -- MultiplicityElement::lowerBound() : [Integer]; -- lowerBound = -- if lowerValue->isEmpty() then 1 -- else lowerValue.integerValue() endif Lower_Value : constant AMF.UML.Value_Specifications.UML_Value_Specification_Access := UML_Multiplicity_Element_Proxy'Class (Self.all).Get_Lower_Value; begin if Lower_Value = null then return (False, 1); else return Lower_Value.Integer_Value; end if; end Lower_Bound; -------------------- -- Set_Is_Ordered -- -------------------- overriding procedure Set_Is_Ordered (Self : not null access UML_Multiplicity_Element_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Ordered (Self.Element, To); end Set_Is_Ordered; ------------------- -- Set_Is_Unique -- ------------------- overriding procedure Set_Is_Unique (Self : not null access UML_Multiplicity_Element_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Unique (Self.Element, To); end Set_Is_Unique; --------------- -- Set_Lower -- --------------- overriding procedure Set_Lower (Self : not null access UML_Multiplicity_Element_Proxy; To : AMF.Optional_Integer) is Lower : AMF.UML.Value_Specifications.UML_Value_Specification_Access := UML_Multiplicity_Element_Proxy'Class (Self.all).Get_Lower_Value; Factory : AMF.Factories.UML_Factories.UML_Factory_Access; begin if To.Is_Empty then if Lower /= null then -- XXX Remove of the element is not implemented. raise Program_Error; end if; else if Lower = null then Factory := AMF.Factories.UML_Factories.UML_Factory_Access (AMF.Stores.Store'Class (Self.Extent.all).Get_Factory (UML_URI)); Lower := AMF.UML.Value_Specifications.UML_Value_Specification_Access (Factory.Create_Literal_Integer); UML_Multiplicity_Element_Proxy'Class (Self.all).Set_Lower_Value (Lower); end if; AMF.UML.Literal_Integers.UML_Literal_Integer'Class (Lower.all).Set_Value (To.Value); end if; end Set_Lower; --------------------- -- Set_Lower_Value -- --------------------- overriding procedure Set_Lower_Value (Self : not null access UML_Multiplicity_Element_Proxy; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Lower_Value (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Lower_Value; --------------- -- Set_Upper -- --------------- overriding procedure Set_Upper (Self : not null access UML_Multiplicity_Element_Proxy; To : AMF.Optional_Unlimited_Natural) is Upper : AMF.UML.Value_Specifications.UML_Value_Specification_Access := UML_Multiplicity_Element_Proxy'Class (Self.all).Get_Upper_Value; Factory : AMF.Factories.UML_Factories.UML_Factory_Access; begin if To.Is_Empty then if Upper /= null then -- XXX Remove of the element is not implemented. raise Program_Error; end if; else if Upper = null then Factory := AMF.Factories.UML_Factories.UML_Factory_Access (AMF.Stores.Store'Class (Self.Extent.all).Get_Factory (UML_URI)); Upper := AMF.UML.Value_Specifications.UML_Value_Specification_Access (Factory.Create_Literal_Unlimited_Natural); UML_Multiplicity_Element_Proxy'Class (Self.all).Set_Upper_Value (Upper); end if; AMF.UML.Literal_Unlimited_Naturals.UML_Literal_Unlimited_Natural'Class (Upper.all).Set_Value (To.Value); end if; end Set_Upper; --------------------- -- Set_Upper_Value -- --------------------- overriding procedure Set_Upper_Value (Self : not null access UML_Multiplicity_Element_Proxy; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Upper_Value (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Upper_Value; ----------------- -- Upper_Bound -- ----------------- overriding function Upper_Bound (Self : not null access constant UML_Multiplicity_Element_Proxy) return AMF.Optional_Unlimited_Natural is -- 7.3.33 MultiplicityElement (from Kernel) -- -- [5] The query upperBound() returns the upper bound of the -- multiplicity for a bounded multiplicity as an unlimited natural. -- -- MultiplicityElement::upperBound() : [UnlimitedNatural]; -- upperBound = -- if upperValue->isEmpty() then 1 -- else upperValue.unlimitedValue() endif Upper_Value : constant AMF.UML.Value_Specifications.UML_Value_Specification_Access := UML_Multiplicity_Element_Proxy'Class (Self.all).Get_Upper_Value; begin if Upper_Value = null then return (False, (False, 1)); else return Upper_Value.Unlimited_Value; end if; end Upper_Bound; end AMF.Internals.UML_Multiplicity_Elements;
src/firmware-tests/Platform/Lcd/EnableDisable/StateAfterDisabledTest.asm
pete-restall/Cluck2Sesame-Prototype
1
171167
<gh_stars>1-10 #include "Platform.inc" #include "FarCalls.inc" #include "Lcd.inc" #include "../LcdStates.inc" #include "TestFixture.inc" radix decimal StateAfterDisabledTest code global testArrange testArrange: fcall initialiseLcd fcall enableLcd testAct: fcall disableLcd testAssert: .assertStateIs LCD_STATE_DISABLED return end
oeis/258/A258993.asm
neoneye/loda-programs
11
168012
<gh_stars>10-100 ; A258993: Triangle read by rows: T(n,k) = binomial(n+k,n-k), k = 0..n-1. ; Submitted by <NAME>(s1.) ; 1,1,3,1,6,5,1,10,15,7,1,15,35,28,9,1,21,70,84,45,11,1,28,126,210,165,66,13,1,36,210,462,495,286,91,15,1,45,330,924,1287,1001,455,120,17,1,55,495,1716,3003,3003,1820,680,153,19,1,66,715,3003,6435,8008,6188,3060,969,190,21,1,78,1001,5005,12870,19448,18564,11628,4845,1330,231,23,1,91,1365,8008,24310,43758,50388,38760,20349,7315,1771,276,25,1,105,1820,12376,43758,92378,125970,116280,74613 lpb $0 mov $1,1 add $1,$0 add $2,1 sub $0,$2 lpe mul $0,2 bin $1,$0 mov $0,$1
src/StaticFactory.asm
sharksym/vgmplay-sharksym
6
90264
; ; Factory for static object instances. ; StaticFactory: MACRO ?instance, ?constructor, ?destructor instance: dw ?instance constructor: dw ?constructor destructor: dw ?destructor constructed: db 0 _size: ENDM ; ix = this ; ix <- instance ; f <- c: succeeded StaticFactory_Create: PROC bit 0,(ix + StaticFactory.constructed) jr nz,Failed push ix call Construct ex (sp),ix ld (ix + StaticFactory.constructed),1 pop ix scf ret Failed: and a ret Construct: push hl ld l,(ix + StaticFactory.instance) ld h,(ix + StaticFactory.instance + 1) push hl ld l,(ix + StaticFactory.constructor) ld h,(ix + StaticFactory.constructor + 1) pop ix ex (sp),hl ret ENDP ; ix = this ; f <- c: succeeded StaticFactory_Destroy: PROC bit 0,(ix + StaticFactory.constructed) jr z,Failed ld (ix + StaticFactory.constructed),0 call Destruct scf ret Failed: and a ret Destruct: push hl ld l,(ix + StaticFactory.instance) ld h,(ix + StaticFactory.instance + 1) push hl ld l,(ix + StaticFactory.destructor) ld h,(ix + StaticFactory.destructor + 1) pop ix ex (sp),hl ret ENDP ; ix = this ; ix <- instance ; de <- instance StaticFactory_GetInstance: ld e,(ix + StaticFactory.instance) ld d,(ix + StaticFactory.instance + 1) ld ixl,e ld ixh,d ret ; ix = this ; f <- nz: constructed StaticFactory_IsConstructed: bit 0,(ix + StaticFactory.constructed) ret
libsrc/stdio_new/buf/scbb0/scbb0_isempty.asm
meesokim/z88dk
8
91796
; scbb0_isempty ; 08.2009 aralbrec PUBLIC scbb0_isempty ; reports whether the buffer has no chars to read ; ; enter : hl = & struct scbb0 ; exit : a = number of chars in buffer for reading ; z flag set if buffer is empty ; uses : af .scbb0_isempty ld a,(hl) sub $80 ret
programs/oeis/129/A129538.asm
neoneye/loda
22
163205
<gh_stars>10-100 ; A129538: a(n) = smallest positive integer such that lcm(a(1), a(2), ..., a(n)) is a multiple of the n-th triangular number n(n+1)/2. ; 1,3,2,5,1,7,4,9,1,11,1,13,1,1,8,17,1,19,1,1,1,23,1,25,1,27,1,29,1,31,16,1,1,1,1,37,1,1,1,41,1,43,1,1,1,47,1,49,1,1,1,53,1,1,1,1,1,59,1,61,1,1,32,1,1,67,1,1,1,71,1,73,1,1,1,1,1,79,1,81,1,83,1,1,1,1,1,89,1,1,1,1 add $0,1 seq $0,100994 ; If n is a prime power p^m, m >= 1, then n, otherwise 1. dif $0,2
oeis/243/A243036.asm
neoneye/loda-programs
11
15955
<gh_stars>10-100 ; A243036: Number of entries of length n in A240602. ; Submitted by <NAME> ; 2,1,2,1,2,2,4,1,2,2,4,2,4,4,8,1,2,2,4,2,4,4,8,2,4,4,8,4,8,8,16,1,2,2,4,2,4,4,8,2,4,4,8,4,8,8,16,2,4,4,8,4,8,8,16,4,8,8,16,8,16,16,32,1,2,2,4,2,4,4,8,2,4,4,8,4,8,8,16,2,4,4,8,4 sub $3,$0 mov $4,$0 cmp $4,0 add $0,$4 mov $2,2 pow $2,$0 sub $3,2 bin $3,$0 gcd $2,$3 mov $0,$2
Task/Higher-order-functions/Ada/higher-order-functions-2.ada
LaudateCorpus1/RosettaCodeData
1
20813
with Ada.Text_Io; use Ada.Text_Io; procedure Subprogram_As_Argument_2 is -- Definition of an access to long_float type Lf_Access is access Long_Float; -- Definition of a function returning Lf_Access taking an -- integer as a parameter function Func_To_Be_Passed(Item : Integer) return Lf_Access is Result : Lf_Access := new Long_Float; begin Result.All := 3.14159 * Long_Float(Item); return Result; end Func_To_Be_Passed; -- Definition of an access to function type matching the function -- signature above type Func_Access is access function(Item : Integer) return Lf_Access; -- Definition of an integer access type type Int_Access is access Integer; -- Define a function taking an instance of Func_Access as its -- parameter and returning an integer access type function Complex_Func(Item : Func_Access; Parm2 : Integer) return Int_Access is Result : Int_Access := new Integer; begin Result.All := Integer(Item(Parm2).all / 3.14149); return Result; end Complex_Func; -- Declare an access variable to hold the access to the function F_Ptr : Func_Access := Func_To_Be_Passed'access; -- Declare an access to integer variable to hold the result Int_Ptr : Int_Access; begin -- Call the function using the access variable Int_Ptr := Complex_Func(F_Ptr, 3); Put_Line(Integer'Image(Int_Ptr.All)); end Subprogram_As_Argument_2;
resources/assets/js/Parser/Lemon/LemonParser.g4
kanungo2000/grammar_review_tool
6
290
parser grammar LemonParser; options {tokenVocab = LemonLexer;} file: (grammarRule|directive)+; grammarRule: leftSide ASSIGN rightSide; leftSide: NONTERMINAL param?; rightSide: ((symbol param?)+)? DOT precedence? codeBlock?; precedence: LBRACKET TERMINAL RBRACKET; symbol: TERMINAL|NONTERMINAL; param: LPAREN symbol RPAREN; directive : PERCENT NONTERMINAL ( symbol | // name, token_prefix (TERMINAL+ DOT) | // left, right, nonassoc codeBlock | // declare_class destructor extra_argument // include_class include parse_accept // parse_failure stack_overflow // syntax_error token_destructor token_type NONTERMINAL | // start_symbol INT | // stack_size (NONTERMINAL codeBlock) // type ) ; codeBlock : BEGIN_CODE CODE_CONTENT* END_CODE;
legacy/Data/Num.agda
banacorn/numeral
1
12649
<filename>legacy/Data/Num.agda module Data.Num where open import Data.List using (List; []; _∷_; foldr) open import Data.Nat open ≤-Reasoning open import Data.Nat.Etc open import Data.Nat.DivMod open import Data.Nat.DivMod.Properties using (div-mono) open import Data.Nat.Properties using (m≤m+n; n≤m+n;_+-mono_; pred-mono; ∸-mono; ≰⇒>; n∸n≡0; +-∸-assoc; m+n∸n≡m) open import Data.Nat.Properties.Simple using (+-right-identity; +-suc; +-assoc; +-comm; distribʳ-*-+) open import Data.Fin.Properties using (bounded) open import Data.Fin using (Fin; fromℕ≤; inject≤; #_) renaming (toℕ to F→N; fromℕ to N→F; zero to Fz; suc to Fs) open import Data.Product open import Data.Maybe open import Induction.Nat using (rec; Rec) import Level open import Function open import Data.Unit using (tt) open import Relation.Nullary open import Relation.Nullary.Decidable using (True; False; toWitness; toWitnessFalse; fromWitness; fromWitnessFalse) open import Relation.Nullary.Negation using (contradiction; contraposition) open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_; refl; cong; sym; trans; inspect) open PropEq.≡-Reasoning renaming (begin_ to beginEq_; _≡⟨_⟩_ to _≡Eq⟨_⟩_; _∎ to _∎Eq) -- Surjective (ℕm): -- base = 1, digits = {m ... (m + n) - 1}, m ≥ 1, n ≥ m -- base > 1, digits = {m ... (m + n) - 1}, m ≥ 0, n ≥ max base (base × m) -- Bijective: -- base ≥ 1, digits = {1 .. base} -- -- Digits: -- Digit m n represents a Digit ranging from m to (m + n - 1) -- e.g. Digit 2 0 2 = {0, 1} for ordinary binary number -- Digit 2 1 2 = {1, 2} for zeroless binary number -- Digit 2 0 3 = {0, 1, 2} for redundant binary number -- data Digit : (base from range : ℕ) → Set where -- unary digit: {0, 1 .. n-1} U0 : ∀ {n} → Fin n → {2≤n : True (2 ≤? n)} -- i.e. must have digit '1' → Digit 1 0 n -- unary digit: {m .. m+n-1} U1 : ∀ {m n} → Fin n → {m≤n : True (suc m ≤? n)} → Digit 1 (suc m) n -- k-adic digit: {m .. m+n-1} D : ∀ {b m n} → Fin n → let base = suc (suc b) in {b≤n : True (base ≤? n)} → {bm≤n : True ((base * m) ≤? n)} → Digit base m n -- without offset, {0 .. n-1} D→F : ∀ {b m n} → Digit b m n → Fin n D→F (U0 x) = x D→F (U1 x) = x D→F (D x) = x -- with offset, {m .. m+n-1} D→N : ∀ {b m n} → Digit b m n → ℕ D→N {m = m} d = m + F→N (D→F d) -- infix 4 _D≤_ -- _D<_ _≥′_ _>′_ -- data _D≤_ {b m n} (x : Digit b m n) : (y : Digit b m n) → Set where -- D≤-refl : x D≤ x -- D≤-step : ∀ {y} (xD≤y : x D≤ y) → x D≤ -- ≤′-step : ∀ {n} (m≤′n : m ≤′ n) → m ≤′ suc n private -- alias ℕ-isDecTotalOrder = DecTotalOrder.isDecTotalOrder decTotalOrder ℕ-isTotalOrder = IsDecTotalOrder.isTotalOrder ℕ-isDecTotalOrder ℕ-isPartialOrder = IsTotalOrder.isPartialOrder ℕ-isTotalOrder ℕ-isPreorder = IsPartialOrder.isPreorder ℕ-isPartialOrder ≤-refl = IsPreorder.reflexive ℕ-isPreorder ≤-antisym = IsPartialOrder.antisym ℕ-isPartialOrder ≤-total = IsTotalOrder.total ℕ-isTotalOrder -- helper function for adding two 'Fin n' with offset 'm' -- (m + x) + (m + y) - m = m + x + y D+sum : ∀ {n} (m : ℕ) → (x y : Fin n) → ℕ D+sum m x y = m + (F→N x) + (F→N y) maxpress-pred : ℕ → Set maxpress-pred _ = ℕ → ℕ maxpress-rec-struct : (x : ℕ) → Rec Level.zero maxpress-pred x → (bound : ℕ) → ℕ maxpress-rec-struct zero p bound = 0 maxpress-rec-struct (suc x) p bound with bound ≤? suc (p bound) maxpress-rec-struct (suc x) p bound | yes q = suc (p bound) ∸ bound maxpress-rec-struct (suc x) p bound | no ¬q = suc (p bound) -- if x ≥ bound, then substract bound from x, until x < bound maxpress : (x bound : ℕ) → ℕ maxpress = rec maxpress-pred maxpress-rec-struct maxpressed<bound : (x bound : ℕ) → (≢0 : False (bound ≟ 0)) → maxpress x bound < bound maxpressed<bound zero zero () maxpressed<bound zero (suc bound) ≢0 = s≤s z≤n maxpressed<bound (suc x) zero () maxpressed<bound (suc x) (suc bound) ≢0 with suc bound ≤? suc (maxpress x (suc bound)) maxpressed<bound (suc x) (suc bound) ≢0 | yes p = begin suc (maxpress x (suc bound) ∸ bound) ≤⟨ ≤-refl (sym (+-∸-assoc 1 p)) ⟩ suc (maxpress x (suc bound)) ∸ bound ≤⟨ ∸-mono {suc (maxpress x (suc bound))} {suc bound} {bound} {bound} (maxpressed<bound x (suc bound) tt) (≤-refl refl) ⟩ suc bound ∸ bound ≤⟨ ≤-refl (m+n∸n≡m 1 bound) ⟩ suc zero ≤⟨ s≤s z≤n ⟩ suc bound ∎ maxpressed<bound (suc x) (suc bound) ≢0 | no ¬p = ≰⇒> ¬p maxpress′ : (x bound : ℕ) → (≢0 : False (bound ≟ 0)) → Fin bound maxpress′ x bound ≢0 = fromℕ≤ {maxpress x bound} (maxpressed<bound x bound ≢0) _D+_ : ∀ {b m n} → Digit b m n → Digit b m n → Digit b m n _D+_ {zero} () () _D+_ {suc zero} x _ = x _D+_ {suc (suc b)} {m} {n} (D x) (D y {b≤n} {bm≤n}) = D (maxpress′ (D+sum m x y) n n≢0) {b≤n} {bm≤n} where n≢0 = fromWitnessFalse $ >⇒≢ $ begin suc zero ≤⟨ s≤s z≤n ⟩ suc (suc b) ≤⟨ toWitness b≤n ⟩ n ∎ -- 2 ≤ base -- ⇒ max * 2 ≤ max * base -- ⇒ max * 2 / base ≤ max {- _D⊕_ : ∀ {b m n} → Digit b m n → Digit b m n → Maybe (Digit b m n) _D⊕_ (U0 x) y = just y _D⊕_ (U1 x) y = just y _D⊕_ {suc (suc b)} {m} {n} (D x) (D y) with suc (D+sum m x y) ≤? n _D⊕_ {suc (suc b)} {m} {n} (D x) (D y) | yes p = nothing _D⊕_ {suc (suc b)} {m} {n} (D x) (D y {b≤n} {bm≤n}) | no ¬p with D+sum m x y divMod (suc (suc b)) | inspect (λ w → _divMod_ (D+sum m x y) (suc (suc b)) {≢0 = w}) tt _D⊕_ {suc (suc b)} {m} {n} (D x) (D y {b≤n} {bm≤n}) | no ¬p | result quotient remainder property | PropEq.[ eq ] = let base = suc (suc b) sum = D+sum m x y quotient<n = begin suc quotient ≤⟨ div-mono base tt {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ n ∎ in just (D (fromℕ≤ {quotient} quotient<n) {b≤n} {bm≤n}) -} {- let base = suc (suc b) sum = D+sum m x y result quotient remainder property = _divMod_ sum base {tt} quotient<n = begin DivMod.quotient (sum divMod {! base !}) ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ n ∎ in just (D (fromℕ≤ {quotient} quotient<n) {b≤n} {bm≤n}) -} {- begin {! !} <⟨ {! !} ⟩ {! !} <⟨ {! !} ⟩ {! !} ∎ begin {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ≤⟨ {! !} ⟩ {! !} ∎ beginEq {! !} ≡Eq⟨ {! !} ⟩ {! !} ≡Eq⟨ {! !} ⟩ {! !} ≡Eq⟨ {! !} ⟩ {! !} ≡Eq⟨ {! !} ⟩ {! !} ∎Eq -} data System : (base from range : ℕ) → Set where Sys : ∀ {b m n} → List (Digit (suc b) m n) → System (suc b) m n {- _S+_ : ∀ {b m n} → System b m n → System b m n → System b m n Sys [] S+ Sys ys = Sys ys Sys xs S+ Sys [] = Sys xs Sys (x ∷ xs) S+ Sys (y ∷ ys) = {! x !} S→N : ∀ {b m n} → System b m n → ℕ S→N {zero} () S→N {suc b} (Sys list) = foldr (shift-then-add (suc b)) 0 list where shift-then-add : ∀ {m n} → (b : ℕ) → Digit b m n → ℕ → ℕ shift-then-add b x acc = (D→N x) + (acc * b) -} -- -- Example -- private one : Digit 2 1 2 one = D Fz two : Digit 2 1 2 two = D (Fs Fz) u0 : Digit 1 0 2 u0 = U0 Fz u1 : Digit 1 1 1 u1 = U1 Fz a0 : Digit 3 0 4 a0 = D Fz a1 : Digit 3 0 4 a1 = D (Fs Fz) a2 : Digit 3 0 4 a2 = D (Fs (Fs Fz)) a3 : Digit 3 0 4 a3 = D (Fs (Fs (Fs Fz))) a : System 2 1 2 a = Sys (one ∷ two ∷ two ∷ [])
Type/WellOrdering.agda
Lolirofle/stuff-in-agda
6
8033
<reponame>Lolirofle/stuff-in-agda module Type.WellOrdering where import Lvl open import Functional open import Logic open import Logic.Propositional open import Logic.Predicate open import Type open import Type.Dependent private variable ℓ ℓ₁ ℓ₂ : Lvl.Level -- Types with terms that are well-founded trees. -- Constructs types that are similar to some kind of tree. -- The first parameter is the index for a constructor. -- The second parameter is the arity for each constructor. -- -- A type able to describe all non-dependent inductively defined data types assuming there are some previously defined types. -- When described like this, the parameters should be interpreted as the following: -- • The first parameter `A` indicates the "number" of branches based on another type's "cardinality" and should also contain the data for every branch. -- • The second parameter `B` is used when the type to be defined refers to itself. -- Examples: -- open import Data -- open import Data.Boolean -- -- module _ (L R : Type{Lvl.𝟎}) where -- E : Type{Lvl.𝟎} -- E = W{A = Σ(Bool)(if_then R else L)}(const Empty) -- Either type using W. -- l : L → E -- Left branch introduction. -- l x = sup (intro 𝐹 x) empty -- r : R → E -- Rght branch introduction. -- r x = sup (intro 𝑇 x) empty -- -- N = W{A = Bool}(if_then Unit{Lvl.𝟎} else Empty{Lvl.𝟎}) -- Natural numbers using W. -- z : N -- Zero branch introduction. -- z = sup 𝐹 empty -- z' : _ → N -- Zero branch introduction (defined like this because empty functions are not unique (from no function extensionality) resulting in more than one zero for this definition of the natural numbers). -- z' empty = sup 𝐹 empty -- s : N → N -- Successor branch introduction. -- s n = sup 𝑇 (\{<> → n}) -- e : ∀{P : N → Type{Lvl.𝟎}} → (∀{empty} → P(z empty)) → (∀{n} → P(n) → P(s n)) → (∀{n} → P(n)) -- TODO: Is this a correct eliminator? Note: It does not pass the termination checker -- e pz ps {sup 𝐹 b} = pz -- e pz ps {sup 𝑇 b} = ps (e pz (\{n} → ps{n}) {b <>}) record W {A : Type{ℓ₁}} (B : A → Type{ℓ₂}) : Type{ℓ₁ Lvl.⊔ ℓ₂} where inductive eta-equality constructor sup field a : A b : B(a) → W(B) -- TODO: Is the type of this eliminator correct? -- W-elim : ∀{A : Type{ℓ₁}}{B : A → Type{ℓ₂}}{P : W(B) → Type{ℓ}} → (∀{a : A}{b : B(a) → W(B)} → (∀{ba : B(a)} → P(b(ba))) → P(sup a b)) → (∀{w : W(B)} → P(w)) -- TODO: Note that this is essentially Sets.IterativeSet V : ∀{ℓ₁} → Type{Lvl.𝐒(ℓ₁)} V {ℓ₁} = W {A = Type{ℓ₁}} id
src/console.ads
JeremyGrosser/the_grid
0
11259
<reponame>JeremyGrosser/the_grid package Console is procedure Initialize; procedure Put (C : Character) with Export, Convention => C, External_Name => "putchar"; end Console;
src/tom/library/sl/ada/identitystrategy.adb
rewriting/tom
36
6048
<gh_stars>10-100 with VisitablePackage, EnvironmentPackage; use VisitablePackage, EnvironmentPackage; with Ada.Text_IO; use Ada.Text_IO; package body IdentityStrategy is ---------------------------------------------------------------------------- -- Object implementation ---------------------------------------------------------------------------- overriding function toString(o: Identity) return String is begin return "Identity()"; end; ---------------------------------------------------------------------------- -- Strategy implementation ---------------------------------------------------------------------------- overriding function visitLight(str:access Identity; any: ObjectPtr; i: access Introspector'Class) return ObjectPtr is begin return any; end; overriding function visit(str: access Identity; i: access Introspector'Class) return Integer is begin return EnvironmentPackage.SUCCESS; end; ---------------------------------------------------------------------------- procedure makeIdentity(i : in out Identity) is begin initSubterm(i); end; function newIdentity return StrategyPtr is id : StrategyPtr := new Identity; begin makeIdentity(Identity(id.all)); return id; end; ---------------------------------------------------------------------------- end IdentityStrategy;
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_1_134.asm
ljhsiun2/medusa
9
23155
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r8 push %rax push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x1d6c6, %rdx nop nop nop nop nop add $10968, %rax vmovups (%rdx), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $0, %xmm5, %rbx nop nop nop inc %r11 lea addresses_WT_ht+0x1b87e, %r8 nop and %rbp, %rbp movw $0x6162, (%r8) nop cmp %r11, %r11 lea addresses_D_ht+0xeefe, %rsi lea addresses_A_ht+0x1a1fe, %rdi clflush (%rsi) nop nop nop add %rbp, %rbp mov $69, %rcx rep movsl nop nop nop nop and $53780, %rdx lea addresses_normal_ht+0x609e, %rsi lea addresses_WC_ht+0x582a, %rdi nop nop and %r8, %r8 mov $46, %rcx rep movsq nop nop nop nop nop sub %rbp, %rbp lea addresses_normal_ht+0x198fe, %rdi nop nop cmp %r8, %r8 mov $0x6162636465666768, %rbx movq %rbx, %xmm0 and $0xffffffffffffffc0, %rdi vmovaps %ymm0, (%rdi) nop nop nop and $2008, %rdx lea addresses_WT_ht+0x166fe, %rsi nop nop nop nop nop inc %r8 mov $0x6162636465666768, %rdi movq %rdi, (%rsi) nop nop nop and %rcx, %rcx lea addresses_UC_ht+0x127f6, %rbp nop nop nop nop nop dec %r11 mov (%rbp), %edi nop add $25142, %rbp lea addresses_UC_ht+0x1a23a, %r11 nop nop nop cmp %rsi, %rsi mov $0x6162636465666768, %rcx movq %rcx, %xmm7 and $0xffffffffffffffc0, %r11 vmovntdq %ymm7, (%r11) nop nop add %rbx, %rbx lea addresses_normal_ht+0x13432, %rsi nop nop nop nop add %r11, %r11 mov (%rsi), %di nop nop nop nop nop cmp $27541, %rax lea addresses_WT_ht+0x1a73e, %rsi lea addresses_normal_ht+0x231e, %rdi nop nop nop nop nop inc %rbx mov $89, %rcx rep movsb nop nop nop nop nop cmp %r8, %r8 lea addresses_D_ht+0x16c2e, %r8 nop nop nop nop lfence mov $0x6162636465666768, %rax movq %rax, %xmm5 vmovups %ymm5, (%r8) add %rdi, %rdi lea addresses_normal_ht+0xb57e, %rdi nop add %rax, %rax mov (%rdi), %r11d nop nop xor $24868, %r11 lea addresses_UC_ht+0x6efe, %rsi lea addresses_UC_ht+0x2f7e, %rdi nop nop nop nop sub $35478, %rbx mov $73, %rcx rep movsq nop nop nop nop add %rdx, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r8 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r14 push %r8 push %r9 push %rax push %rbx // Store lea addresses_WT+0xf0fe, %rax nop and %rbx, %rbx mov $0x5152535455565758, %r14 movq %r14, (%rax) nop inc %r14 // Store lea addresses_RW+0x14c5e, %r10 inc %r11 mov $0x5152535455565758, %r14 movq %r14, %xmm6 vmovaps %ymm6, (%r10) add $65206, %r9 // Store lea addresses_WC+0x759e, %r9 nop nop nop sub $40792, %r8 movw $0x5152, (%r9) nop nop nop nop add %r11, %r11 // Store mov $0xb5e, %r10 nop nop nop nop cmp %rax, %rax movb $0x51, (%r10) cmp %rax, %rax // Store lea addresses_PSE+0x82fe, %r10 nop nop nop add $4925, %r9 mov $0x5152535455565758, %r8 movq %r8, %xmm2 vmovaps %ymm2, (%r10) nop nop nop add $33765, %r11 // Store lea addresses_A+0x141fe, %r11 nop nop nop add $40607, %rax movl $0x51525354, (%r11) nop cmp %r11, %r11 // Store lea addresses_PSE+0x54ee, %r11 nop nop nop nop cmp $50528, %rax movw $0x5152, (%r11) nop nop nop nop cmp %r14, %r14 // Faulty Load lea addresses_normal+0x11efe, %r8 nop nop nop and $36851, %rax mov (%r8), %r10w lea oracles, %r14 and $0xff, %r10 shlq $12, %r10 mov (%r14,%r10,1), %r10 pop %rbx pop %rax pop %r9 pop %r8 pop %r14 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 1, 'NT': True, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': True, 'size': 8, 'NT': False, 'same': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': True, 'size': 32, 'NT': False, 'same': False, 'congruent': 4}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 3}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': True, 'size': 1, 'NT': False, 'same': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': True, 'size': 32, 'NT': False, 'same': False, 'congruent': 6}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 8}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 3}} [Faulty Load] {'src': {'type': 'addresses_normal', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': True, 'size': 2, 'NT': False, 'same': False, 'congruent': 4}} {'src': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 32, 'NT': False, 'same': False, 'congruent': 9}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 11}} {'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 32, 'NT': True, 'same': False, 'congruent': 2}} {'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 2}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 4}} {'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 5}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}} {'34': 1} 34 */
test/Succeed/fol-theorems/Where2.agda
asr/apia
10
6260
<filename>test/Succeed/fol-theorems/Where2.agda ------------------------------------------------------------------------------ -- Testing the conjectures inside a @where@ clause ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Where2 where infixl 6 _+_ infix 4 _≡_ postulate D : Set zero : D succ : D → D _≡_ : D → D → Set data N : D → Set where nzero : N zero nsucc : ∀ {n} → N n → N (succ n) N-ind : (A : D → Set) → A zero → (∀ {n} → A n → A (succ n)) → ∀ {n} → N n → A n N-ind A A0 h nzero = A0 N-ind A A0 h (nsucc Nn) = h (N-ind A A0 h Nn) postulate _+_ : D → D → D +-0x : ∀ n → zero + n ≡ n +-Sx : ∀ m n → succ m + n ≡ succ (m + n) {-# ATP axioms +-0x +-Sx #-} +-assoc : ∀ {m n o} → N m → N n → N o → m + n + o ≡ m + (n + o) +-assoc {n = n} {o} Nm Nn No = N-ind A A0 is Nm where A : D → Set A i = i + n + o ≡ i + (n + o) postulate A0 : zero + n + o ≡ zero + (n + o) {-# ATP prove A0 #-} postulate is : ∀ {i} → i + n + o ≡ i + (n + o) → succ i + n + o ≡ succ i + (n + o) {-# ATP prove is #-}
Source/Assembly/test.65c02.asm
neilpate/6502-Sandbox
0
89006
.target "6502" .org $8000 reset: ldx #$0 ;X will hold the current count, this number will just go up ldy #$0 ;Y will hold the current segment count, want this to reset loop: inx stx $0 ;Just for debug iny sty $1 ;just for debug tya cmp #5 ;Compare accumulator value to 5 beq resety ;Zero flag will be set when the count reaches 5 jmp loop resety: ldy #$0 jmp loop .org $fffc .word reset .word $0000
programs/oeis/037/A037270.asm
karttu/loda
1
81776
<reponame>karttu/loda ; A037270: a(n) = n^2*(n^2 + 1)/2. ; 0,1,10,45,136,325,666,1225,2080,3321,5050,7381,10440,14365,19306,25425,32896,41905,52650,65341,80200,97461,117370,140185,166176,195625,228826,266085,307720,354061,405450,462241,524800,593505,668746,750925,840456,937765,1043290,1157481,1280800,1413721,1556730,1710325,1875016,2051325,2239786,2440945,2655360,2883601,3126250,3383901,3657160,3946645,4252986,4576825,4918816,5279625,5659930,6060421,6481800,6924781,7390090,7878465,8390656,8927425,9489546,10077805,10693000,11335941,12007450,12708361,13439520,14201785,14996026,15823125,16683976,17579485,18510570,19478161,20483200,21526641,22609450,23732605,24897096,26103925,27354106,28648665,29988640,31375081,32809050,34291621,35823880,37406925,39041866,40729825,42471936,44269345,46123210,48034701,50005000,52035301,54126810,56280745,58498336,60780825,63129466,65545525,68030280,70585021,73211050,75909681,78682240,81530065,84454506,87456925,90538696,93701205,96945850,100274041,103687200,107186761,110774170,114450885,118218376,122078125,126031626,130080385,134225920,138469761,142813450,147258541,151806600,156459205,161217946,166084425,171060256,176147065,181346490,186660181,192089800,197637021,203303530,209091025,215001216,221035825,227196586,233485245,239903560,246453301,253136250,259954201,266908960,274002345,281236186,288612325,296132616,303798925,311613130,319577121,327692800,335962081,344386890,352969165,361710856,370613925,379680346,388912105,398311200,407879641,417619450,427532661,437621320,447887485,458333226,468960625,479771776,490768785,501953770,513328861,524896200,536657941,548616250,560773305,573131296,585692425,598458906,611432965,624616840,638012781,651623050,665449921,679495680,693762625,708253066,722969325,737913736,753088645,768496410,784139401,800020000,816140601,832503610,849111445,865966536,883071325,900428266,918039825,935908480,954036721,972427050,991081981,1010004040,1029195765,1048659706,1068398425,1088414496,1108710505,1129289050,1150152741,1171304200,1192746061,1214480970,1236511585,1258840576,1281470625,1304404426,1327644685,1351194120,1375055461,1399231450,1423724841,1448538400,1473674905,1499137146,1524927925,1551050056,1577506365,1604299690,1631432881,1658908800,1686730321,1714900330,1743421725,1772297416,1801530325,1831123386,1861079545,1891401760,1922093001 pow $0,2 sub $1,$0 bin $1,2
programs/oeis/227/A227179.asm
neoneye/loda
22
162675
; A227179: After initial 0, integers from 0 to n(n-1) followed by integers from 0 to n(n+1) and so on. ; 0,0,0,1,2,0,1,2,3,4,5,6,0,1,2,3,4,5,6,7,8,9,10,11,12,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 lpb $0 sub $0,1 mov $1,$0 trn $0,$2 add $3,2 add $2,$3 lpe mov $0,$1
src/Prelude/Semiring.agda
t-more/agda-prelude
111
8457
module Prelude.Semiring where open import Agda.Builtin.Nat using (Nat; zero; suc) open import Prelude.Function record Semiring {a} (A : Set a) : Set a where infixl 6 _+_ infixl 7 _*_ field zro one : A _+_ _*_ : A → A → A open Semiring {{...}} public {-# DISPLAY Semiring.zro _ = zro #-} {-# DISPLAY Semiring.one _ = one #-} {-# DISPLAY Semiring._+_ _ a b = a + b #-} {-# DISPLAY Semiring._*_ _ a b = a * b #-} infixr 8 _^_ _^_ : ∀ {a} {A : Set a} {{_ : Semiring A}} → A → Nat → A n ^ zero = one n ^ suc m = n ^ m * n record Subtractive {a} (A : Set a) : Set a where infixl 6 _-_ field _-_ : A → A → A negate : A → A open Subtractive {{...}} public {-# DISPLAY Subtractive._-_ _ a b = a - b #-} {-# DISPLAY Subtractive.negate _ = negate #-}
src/x86/mc_ssse3.asm
feiser2016/dav1d
0
87192
; Copyright © 2018, VideoLAN and dav1d authors ; Copyright © 2018, Two Orioles, LLC ; Copyright © 2018, VideoLabs ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; ; 1. Redistributions of source code must retain the above copyright notice, this ; list of conditions and the following disclaimer. ; ; 2. Redistributions in binary form must reproduce the above copyright notice, ; this list of conditions and the following disclaimer in the documentation ; and/or other materials provided with the distribution. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %include "config.asm" %include "ext/x86/x86inc.asm" SECTION_RODATA 16 ; dav1d_obmc_masks[] with 64-x interleaved obmc_masks: db 0, 0, 0, 0 ; 2 @4 db 45, 19, 64, 0 ; 4 @8 db 39, 25, 50, 14, 59, 5, 64, 0 ; 8 @16 db 36, 28, 42, 22, 48, 16, 53, 11, 57, 7, 61, 3, 64, 0, 64, 0 ; 16 @32 db 34, 30, 37, 27, 40, 24, 43, 21, 46, 18, 49, 15, 52, 12, 54, 10 db 56, 8, 58, 6, 60, 4, 61, 3, 64, 0, 64, 0, 64, 0, 64, 0 ; 32 @64 db 33, 31, 35, 29, 36, 28, 38, 26, 40, 24, 41, 23, 43, 21, 44, 20 db 45, 19, 47, 17, 48, 16, 50, 14, 51, 13, 52, 12, 53, 11, 55, 9 db 56, 8, 57, 7, 58, 6, 59, 5, 60, 4, 60, 4, 61, 3, 62, 2 db 64, 0, 64, 0, 64, 0, 64, 0, 64, 0, 64, 0, 64, 0, 64, 0 blend_shuf: db 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3 pb_64: times 16 db 64 pw_8: times 8 dw 8 pw_26: times 8 dw 26 pw_258: times 8 dw 258 pw_512: times 8 dw 512 pw_1024: times 8 dw 1024 pw_2048: times 8 dw 2048 %macro BIDIR_JMP_TABLE 1-* ;evaluated at definition time (in loop below) %xdefine %1_table (%%table - 2*%2) %xdefine %%base %1_table %xdefine %%prefix mangle(private_prefix %+ _%1) ; dynamically generated label %%table: %rep %0 - 1 ; repeat for num args dd %%prefix %+ .w%2 - %%base %rotate 1 %endrep %endmacro BIDIR_JMP_TABLE avg_ssse3, 4, 8, 16, 32, 64, 128 BIDIR_JMP_TABLE w_avg_ssse3, 4, 8, 16, 32, 64, 128 BIDIR_JMP_TABLE mask_ssse3, 4, 8, 16, 32, 64, 128 BIDIR_JMP_TABLE w_mask_420_ssse3, 4, 8, 16, 16, 16, 16 BIDIR_JMP_TABLE blend_ssse3, 4, 8, 16, 32 BIDIR_JMP_TABLE blend_v_ssse3, 2, 4, 8, 16, 32 BIDIR_JMP_TABLE blend_h_ssse3, 2, 4, 8, 16, 16, 16, 16 SECTION .text INIT_XMM ssse3 %if WIN64 DECLARE_REG_TMP 6, 4 %else DECLARE_REG_TMP 6, 7 %endif %macro BIDIR_FN 1 ; op %1 0 lea stride3q, [strideq*3] jmp wq .w4_loop: %1_INC_PTR 2 %1 0 lea dstq, [dstq+strideq*4] .w4: ; tile 4x movd [dstq ], m0 ; copy dw[0] pshuflw m1, m0, q1032 ; swap dw[1] and dw[0] movd [dstq+strideq*1], m1 ; copy dw[1] punpckhqdq m0, m0 ; swap dw[3,2] with dw[1,0] movd [dstq+strideq*2], m0 ; dw[2] psrlq m0, 32 ; shift right in dw[3] movd [dstq+stride3q ], m0 ; copy sub hd, 4 jg .w4_loop RET .w8_loop: %1_INC_PTR 2 %1 0 lea dstq, [dstq+strideq*2] .w8: movq [dstq ], m0 movhps [dstq+strideq*1], m0 sub hd, 2 jg .w8_loop RET .w16_loop: %1_INC_PTR 2 %1 0 lea dstq, [dstq+strideq] .w16: mova [dstq ], m0 dec hd jg .w16_loop RET .w32_loop: %1_INC_PTR 4 %1 0 lea dstq, [dstq+strideq] .w32: mova [dstq ], m0 %1 2 mova [dstq + 16 ], m0 dec hd jg .w32_loop RET .w64_loop: %1_INC_PTR 8 %1 0 add dstq, strideq .w64: %assign i 0 %rep 4 mova [dstq + i*16 ], m0 %assign i i+1 %if i < 4 %1 2*i %endif %endrep dec hd jg .w64_loop RET .w128_loop: %1_INC_PTR 16 %1 0 add dstq, strideq .w128: %assign i 0 %rep 8 mova [dstq + i*16 ], m0 %assign i i+1 %if i < 8 %1 2*i %endif %endrep dec hd jg .w128_loop RET %endmacro %macro AVG 1 ; src_offset ; writes AVG of tmp1 tmp2 uint16 coeffs into uint8 pixel mova m0, [tmp1q+(%1+0)*mmsize] ; load 8 coef(2bytes) from tmp1 paddw m0, [tmp2q+(%1+0)*mmsize] ; load/add 8 coef(2bytes) tmp2 mova m1, [tmp1q+(%1+1)*mmsize] paddw m1, [tmp2q+(%1+1)*mmsize] pmulhrsw m0, m2 pmulhrsw m1, m2 packuswb m0, m1 ; pack/trunc 16 bits from m0 & m1 to 8 bit %endmacro %macro AVG_INC_PTR 1 add tmp1q, %1*mmsize add tmp2q, %1*mmsize %endmacro cglobal avg, 4, 7, 3, dst, stride, tmp1, tmp2, w, h, stride3 lea r6, [avg_ssse3_table] tzcnt wd, wm ; leading zeros movifnidn hd, hm ; move h(stack) to h(register) if not already that register movsxd wq, dword [r6+wq*4] ; push table entry matching the tile width (tzcnt) in widen reg mova m2, [pw_1024+r6-avg_ssse3_table] ; fill m2 with shift/align add wq, r6 BIDIR_FN AVG %macro W_AVG 1 ; src_offset ; (a * weight + b * (16 - weight) + 128) >> 8 ; = ((a - b) * weight + (b << 4) + 128) >> 8 ; = ((((b - a) * (-weight << 12)) >> 16) + b + 8) >> 4 mova m0, [tmp2q+(%1+0)*mmsize] psubw m2, m0, [tmp1q+(%1+0)*mmsize] mova m1, [tmp2q+(%1+1)*mmsize] psubw m3, m1, [tmp1q+(%1+1)*mmsize] paddw m2, m2 ; compensate for the weight only being half paddw m3, m3 ; of what it should be pmulhw m2, m4 ; (b-a) * (-weight << 12) pmulhw m3, m4 ; (b-a) * (-weight << 12) paddw m0, m2 ; ((b-a) * -weight) + b paddw m1, m3 pmulhrsw m0, m5 pmulhrsw m1, m5 packuswb m0, m1 %endmacro %define W_AVG_INC_PTR AVG_INC_PTR cglobal w_avg, 4, 7, 6, dst, stride, tmp1, tmp2, w, h, stride3 lea r6, [w_avg_ssse3_table] tzcnt wd, wm movifnidn hd, hm movd m0, r6m pshuflw m0, m0, q0000 punpcklqdq m0, m0 movsxd wq, dword [r6+wq*4] pxor m4, m4 psllw m0, 11 ; can't shift by 12, sign bit must be preserved psubw m4, m0 mova m5, [pw_2048+r6-w_avg_ssse3_table] add wq, r6 BIDIR_FN W_AVG %macro MASK 1 ; src_offset ; (a * m + b * (64 - m) + 512) >> 10 ; = ((a - b) * m + (b << 6) + 512) >> 10 ; = ((((b - a) * (-m << 10)) >> 16) + b + 8) >> 4 mova m3, [maskq+(%1+0)*(mmsize/2)] mova m0, [tmp2q+(%1+0)*mmsize] ; b psubw m1, m0, [tmp1q+(%1+0)*mmsize] ; b - a mova m6, m3 ; m psubb m3, m4, m6 ; -m paddw m1, m1 ; (b - a) << 1 paddb m3, m3 ; -m << 1 punpcklbw m2, m4, m3 ; -m << 9 (<< 8 when ext as uint16) pmulhw m1, m2 ; (-m * (b - a)) << 10 paddw m0, m1 ; + b mova m1, [tmp2q+(%1+1)*mmsize] ; b psubw m2, m1, [tmp1q+(%1+1)*mmsize] ; b - a paddw m2, m2 ; (b - a) << 1 mova m6, m3 ; (-m << 1) punpckhbw m3, m4, m6 ; (-m << 9) pmulhw m2, m3 ; (-m << 9) paddw m1, m2 ; (-m * (b - a)) << 10 pmulhrsw m0, m5 ; round pmulhrsw m1, m5 ; round packuswb m0, m1 ; interleave 16 -> 8 %endmacro %macro MASK_INC_PTR 1 add maskq, %1*mmsize/2 add tmp1q, %1*mmsize add tmp2q, %1*mmsize %endmacro %if ARCH_X86_64 cglobal mask, 4, 8, 7, dst, stride, tmp1, tmp2, w, h, mask, stride3 movifnidn hd, hm %else cglobal mask, 4, 7, 7, dst, stride, tmp1, tmp2, w, mask, stride3 %define hd dword r5m %endif lea r6, [mask_ssse3_table] tzcnt wd, wm movsxd wq, dword [r6+wq*4] pxor m4, m4 mova m5, [pw_2048+r6-mask_ssse3_table] add wq, r6 mov maskq, r6m BIDIR_FN MASK %undef hd %if ARCH_X86_64 %define reg_pw_8 m8 %define reg_pw_27 m9 %define reg_pw_2048 m10 %else %define reg_pw_8 [pw_8] %define reg_pw_27 [pw_26] ; 64 - 38 %define reg_pw_2048 [pw_2048] %endif %macro W_MASK_420_B 2 ; src_offset in bytes, mask_out ;**** do m0 = u16.dst[7..0], m%2 = u16.m[7..0] **** mova m0, [tmp1q+(%1)] mova m1, [tmp2q+(%1)] psubw m1, m0 ; tmp1 - tmp2 pabsw m3, m1 ; abs(tmp1 - tmp2) paddw m3, reg_pw_8 ; abs(tmp1 - tmp2) + 8 psrlw m3, 8 ; (abs(tmp1 - tmp2) + 8) >> 8 psubusw m%2, reg_pw_27, m3 ; 64 - min(m, 64) psllw m2, m%2, 10 pmulhw m1, m2 ; tmp2 * () paddw m0, m1 ; tmp1 + () ;**** do m1 = u16.dst[7..0], m%2 = u16.m[7..0] **** mova m1, [tmp1q+(%1)+mmsize] mova m2, [tmp2q+(%1)+mmsize] psubw m2, m1 ; tmp1 - tmp2 pabsw m7, m2 ; abs(tmp1 - tmp2) paddw m7, reg_pw_8 ; abs(tmp1 - tmp2) + 8 psrlw m7, 8 ; (abs(tmp1 - tmp2) + 8) >> 8 psubusw m3, reg_pw_27, m7 ; 64 - min(m, 64) phaddw m%2, m3 ; pack both u16.m[8..0]runs as u8.m [15..0] psllw m3, 10 pmulhw m2, m3 paddw m1, m2 ;******** pmulhrsw m0, reg_pw_2048 ; round/scale 2048 pmulhrsw m1, reg_pw_2048 ; round/scale 2048 packuswb m0, m1 ; concat m0 = u8.dst[15..0] %endmacro %macro W_MASK_420 2 W_MASK_420_B (%1*16), %2 %endmacro %if ARCH_X86_64 ; args: dst, stride, tmp1, tmp2, w, h, mask, sign cglobal w_mask_420, 4, 9, 11, dst, stride, tmp1, tmp2, w, h, mask, stride3 lea r7, [w_mask_420_ssse3_table] mov wd, wm tzcnt r8d, wd movifnidn hd, hm mov maskq, maskmp movd m0, r7m pshuflw m0, m0, q0000 ; sign punpcklqdq m0, m0 movsxd r8, dword [r7+r8*4] mova reg_pw_8, [pw_8] mova reg_pw_27, [pw_26] ; 64 - 38 mova reg_pw_2048, [pw_2048] mova m6, [pw_258] ; 64 * 4 + 2 psubw m6, m0 add r8, r7 W_MASK_420 0, 4 lea stride3q, [strideq*3] jmp r8 %define dst_bak r8 %define loop_w r7 %define orig_w wq %else cglobal w_mask_420, 4, 7, 8, dst, stride, tmp1, tmp2, w, mask, stride3 tzcnt r6d, r4m mov wd, w_mask_420_ssse3_table add wd, [wq+r6*4] mov maskq, r6mp movd m0, r7m pshuflw m0, m0, q0000 ; sign punpcklqdq m0, m0 mova m6, [pw_258] ; 64 * 4 + 2 psubw m6, m0 W_MASK_420 0, 4 lea stride3q, [strideq*3] jmp wd %define dst_bak r0m %define loop_w r6q %define orig_w r4m %define hd dword r5m %endif .w4_loop: add tmp1q, 2*16 add tmp2q, 2*16 W_MASK_420 0, 4 lea dstq, [dstq+strideq*4] add maskq, 4 .w4: movd [dstq ], m0 ; copy m0[0] pshuflw m1, m0, q1032 movd [dstq+strideq*1], m1 ; copy m0[1] punpckhqdq m0, m0 movd [dstq+strideq*2], m0 ; copy m0[2] psrlq m0, 32 movd [dstq+stride3q ], m0 ; copy m0[3] pshufd m5, m4, q3131; DBDB even lines repeated pshufd m4, m4, q2020; CACA odd lines repeated psubw m1, m6, m4 ; m9 == 64 * 4 + 2 psubw m1, m5 ; C-D A-B C-D A-B psrlw m1, 2 ; >> 2 packuswb m1, m1 movd [maskq], m1 sub hd, 4 jg .w4_loop RET .w8_loop: add tmp1q, 2*16 add tmp2q, 2*16 W_MASK_420 0, 4 lea dstq, [dstq+strideq*2] add maskq, 4 .w8: movq [dstq ], m0 movhps [dstq+strideq*1], m0 pshufd m1, m4, q3232 psubw m0, m6, m4 psubw m0, m1 psrlw m0, 2 packuswb m0, m0 movd [maskq], m0 sub hd, 2 jg .w8_loop RET .w16: ; w32/64/128 mov dst_bak, dstq mov loop_w, orig_w ; use width as counter %if ARCH_X86_32 mov wq, orig_w ; because we altered it in 32bit setup %endif jmp .w16ge_inner_loop_first .w16ge_loop: lea tmp1q, [tmp1q+wq*2] ; skip even line pixels lea tmp2q, [tmp2q+wq*2] ; skip even line pixels lea dstq, [dstq+strideq*2] mov dst_bak, dstq mov loop_w, orig_w .w16ge_inner_loop: W_MASK_420_B 0, 4 .w16ge_inner_loop_first: mova [dstq ], m0 W_MASK_420_B wq*2, 5 ; load matching even line (offset = widthpx * (16+16)) mova [dstq+strideq*1], m0 psubw m1, m6, m4 ; m9 == 64 * 4 + 2 psubw m1, m5 ; - odd line mask psrlw m1, 2 ; >> 2 packuswb m1, m1 movq [maskq], m1 add tmp1q, 2*16 add tmp2q, 2*16 add maskq, 8 add dstq, 16 sub loop_w, 16 jg .w16ge_inner_loop mov dstq, dst_bak sub hd, 2 jg .w16ge_loop RET %undef reg_pw_8 %undef reg_pw_27 %undef reg_pw_2048 %undef dst_bak %undef loop_w %undef orig_w %undef hd %macro BLEND_64M 4; a, b, mask1, mask2 punpcklbw m0, %1, %2; {b;a}[7..0] punpckhbw %1, %2 ; {b;a}[15..8] pmaddubsw m0, %3 ; {b*m[0] + (64-m[0])*a}[7..0] u16 pmaddubsw %1, %4 ; {b*m[1] + (64-m[1])*a}[15..8] u16 pmulhrsw m0, m5 ; {((b*m[0] + (64-m[0])*a) + 1) / 32}[7..0] u16 pmulhrsw %1, m5 ; {((b*m[1] + (64-m[0])*a) + 1) / 32}[15..8] u16 packuswb m0, %1 ; {blendpx}[15..0] u8 %endmacro %macro BLEND 2; a, b psubb m3, m4, m0 ; m3 = (64 - m) punpcklbw m2, m3, m0 ; {m;(64-m)}[7..0] punpckhbw m3, m0 ; {m;(64-m)}[15..8] BLEND_64M %1, %2, m2, m3 %endmacro cglobal blend, 3, 7, 7, dst, ds, tmp, w, h, mask %define base r6-blend_ssse3_table lea r6, [blend_ssse3_table] tzcnt wd, wm movifnidn hd, hm movifnidn maskq, maskmp movsxd wq, dword [r6+wq*4] mova m4, [base+pb_64] mova m5, [base+pw_512] add wq, r6 lea r6, [dsq*3] jmp wq .w4: movq m0, [maskq]; m movd m1, [dstq+dsq*0] ; a movd m6, [dstq+dsq*1] punpckldq m1, m6 movq m6, [tmpq] ; b psubb m3, m4, m0 ; m3 = (64 - m) punpcklbw m2, m3, m0 ; {m;(64-m)}[7..0] punpcklbw m1, m6 ; {b;a}[7..0] pmaddubsw m1, m2 ; {b*m[0] + (64-m[0])*a}[7..0] u16 pmulhrsw m1, m5 ; {((b*m[0] + (64-m[0])*a) + 1) / 32}[7..0] u16 packuswb m1, m0 ; {blendpx}[15..0] u8 movd [dstq+dsq*0], m1 psrlq m1, 32 movd [dstq+dsq*1], m1 add maskq, 8 add tmpq, 8 lea dstq, [dstq+dsq*2] ; dst_stride * 2 sub hd, 2 jg .w4 RET .w8: mova m0, [maskq]; m movq m1, [dstq+dsq*0] ; a movhps m1, [dstq+dsq*1] mova m6, [tmpq] ; b BLEND m1, m6 movq [dstq+dsq*0], m0 movhps [dstq+dsq*1], m0 add maskq, 16 add tmpq, 16 lea dstq, [dstq+dsq*2] ; dst_stride * 2 sub hd, 2 jg .w8 RET .w16: mova m0, [maskq]; m mova m1, [dstq] ; a mova m6, [tmpq] ; b BLEND m1, m6 mova [dstq], m0 add maskq, 16 add tmpq, 16 add dstq, dsq ; dst_stride dec hd jg .w16 RET .w32: %assign i 0 %rep 2 mova m0, [maskq+16*i]; m mova m1, [dstq+16*i] ; a mova m6, [tmpq+16*i] ; b BLEND m1, m6 mova [dstq+i*16], m0 %assign i i+1 %endrep add maskq, 32 add tmpq, 32 add dstq, dsq ; dst_stride dec hd jg .w32 RET cglobal blend_v, 3, 6, 8, dst, ds, tmp, w, h, mask %define base r5-blend_v_ssse3_table lea r5, [blend_v_ssse3_table] tzcnt wd, wm movifnidn hd, hm movsxd wq, dword [r5+wq*4] mova m5, [base+pw_512] add wq, r5 add maskq, obmc_masks-blend_v_ssse3_table jmp wq .w2: movd m3, [maskq+4] punpckldq m3, m3 ; 2 mask blend is provided for 4 pixels / 2 lines .w2_loop: movd m1, [dstq+dsq*0] ; a {..;a;a} pinsrw m1, [dstq+dsq*1], 1 movd m2, [tmpq] ; b punpcklbw m0, m1, m2; {b;a}[7..0] pmaddubsw m0, m3 ; {b*m + (64-m)*a}[7..0] u16 pmulhrsw m0, m5 ; {((b*m + (64-m)*a) + 1) / 32}[7..0] u16 packuswb m0, m1 ; {blendpx}[8..0] u8 movd r3d, m0 mov [dstq+dsq*0], r3w shr r3d, 16 mov [dstq+dsq*1], r3w add tmpq, 2*2 lea dstq, [dstq + dsq * 2] sub hd, 2 jg .w2_loop RET .w4: movddup m3, [maskq+8] ; 4 mask blend is provided for 8 pixels / 2 lines .w4_loop: movd m1, [dstq+dsq*0] ; a movd m2, [dstq+dsq*1] ; punpckldq m1, m2 movq m2, [tmpq] ; b punpcklbw m1, m2 ; {b;a}[7..0] pmaddubsw m1, m3 ; {b*m + (64-m)*a}[7..0] u16 pmulhrsw m1, m5 ; {((b*m + (64-m)*a) + 1) / 32}[7..0] u16 packuswb m1, m1 ; {blendpx}[8..0] u8 movd [dstq], m1 psrlq m1, 32 movd [dstq+dsq*1], m1 add tmpq, 2*4 lea dstq, [dstq+dsq*2] sub hd, 2 jg .w4_loop RET .w8: mova m3, [maskq+16] ; 8 mask blend is provided for 16 pixels .w8_loop: movq m1, [dstq+dsq*0] ; a movhps m1, [dstq+dsq*1] mova m2, [tmpq]; b BLEND_64M m1, m2, m3, m3 movq [dstq+dsq*0], m0 punpckhqdq m0, m0 movq [dstq+dsq*1], m0 add tmpq, 16 lea dstq, [dstq+dsq*2] sub hd, 2 jg .w8_loop RET .w16: ; 16 mask blend is provided for 32 pixels mova m3, [maskq+32] ; obmc_masks_16[0] (64-m[0]) mova m4, [maskq+48] ; obmc_masks_16[1] (64-m[1]) .w16_loop: mova m1, [dstq] ; a mova m2, [tmpq] ; b BLEND_64M m1, m2, m3, m4 mova [dstq], m0 add tmpq, 16 add dstq, dsq dec hd jg .w16_loop RET .w32: mova m3, [maskq+64 ] ; obmc_masks_32[0] (64-m[0]) mova m4, [maskq+80 ] ; obmc_masks_32[1] (64-m[1]) mova m6, [maskq+96 ] ; obmc_masks_32[2] (64-m[2]) mova m7, [maskq+112] ; obmc_masks_32[3] (64-m[3]) ; 16 mask blend is provided for 64 pixels .w32_loop: mova m1, [dstq+16*0] ; a mova m2, [tmpq+16*0] ; b BLEND_64M m1, m2, m3, m4 mova [dstq+16*0], m0 mova m1, [dstq+16*1] ; a mova m2, [tmpq+16*1] ; b BLEND_64M m1, m2, m6, m7 mova [dstq+16*1], m0 add tmpq, 32 add dstq, dsq dec hd jg .w32_loop RET cglobal blend_h, 4, 7, 6, dst, ds, tmp, w, h, mask %define base r5-blend_h_ssse3_table lea r5, [blend_h_ssse3_table] mov r6d, wd tzcnt wd, wd mov hd, hm movsxd wq, dword [r5+wq*4] mova m5, [base+pw_512] add wq, r5 lea maskq, [base+obmc_masks+hq*4] neg hq jmp wq .w2: movd m0, [dstq+dsq*0] pinsrw m0, [dstq+dsq*1], 1 movd m2, [maskq+hq*2] movd m1, [tmpq] punpcklwd m2, m2 punpcklbw m0, m1 pmaddubsw m0, m2 pmulhrsw m0, m5 packuswb m0, m0 movd r3d, m0 mov [dstq+dsq*0], r3w shr r3d, 16 mov [dstq+dsq*1], r3w lea dstq, [dstq+dsq*2] add tmpq, 2*2 add hq, 2 jl .w2 RET .w4: mova m3, [blend_shuf] .w4_loop: movd m0, [dstq+dsq*0] movd m2, [dstq+dsq*1] punpckldq m0, m2 ; a movq m1, [tmpq] ; b movq m2, [maskq+hq*2] ; m pshufb m2, m3 punpcklbw m0, m1 pmaddubsw m0, m2 pmulhrsw m0, m5 packuswb m0, m0 movd [dstq+dsq*0], m0 psrlq m0, 32 movd [dstq+dsq*1], m0 lea dstq, [dstq+dsq*2] add tmpq, 4*2 add hq, 2 jl .w4_loop RET .w8: movd m4, [maskq+hq*2] punpcklwd m4, m4 pshufd m3, m4, q0000 pshufd m4, m4, q1111 movq m1, [dstq+dsq*0] ; a movhps m1, [dstq+dsq*1] mova m2, [tmpq] BLEND_64M m1, m2, m3, m4 movq [dstq+dsq*0], m0 movhps [dstq+dsq*1], m0 lea dstq, [dstq+dsq*2] add tmpq, 8*2 add hq, 2 jl .w8 RET ; w16/w32/w64/w128 .w16: sub dsq, r6 .w16_loop0: movd m3, [maskq+hq*2] pshuflw m3, m3, q0000 punpcklqdq m3, m3 mov wd, r6d .w16_loop: mova m1, [dstq] ; a mova m2, [tmpq] ; b BLEND_64M m1, m2, m3, m3 mova [dstq], m0 add dstq, 16 add tmpq, 16 sub wd, 16 jg .w16_loop add dstq, dsq inc hq jl .w16_loop0 RET
data/pokemon/dex_entries/haunter.asm
Dev727/ancientplatinum
28
161447
<gh_stars>10-100 db "GAS@" ; species name dw 503, 2 ; height, weight db "It hides in the" next "dark, planning to" next "take the life of" page "the next living" next "thing that wanders" next "close by.@"
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca.log_15226_1300.asm
ljhsiun2/medusa
9
93702
<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %r9 push %rbp push %rdi push %rdx // Store lea addresses_US+0xfc2d, %r12 nop nop nop nop cmp $9397, %rbp movw $0x5152, (%r12) nop nop dec %rbp // Faulty Load lea addresses_D+0x12ad, %rdi nop nop cmp %r9, %r9 mov (%rdi), %r12w lea oracles, %rbp and $0xff, %r12 shlq $12, %r12 mov (%rbp,%r12,1), %r12 pop %rdx pop %rdi pop %rbp pop %r9 pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_US'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 2, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'36': 15226} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
tests/roms/assertions.asm
AndreaOrru/Gilgamesh
25
163426
incsrc lorom.asm org $8000 reset: jsr unknown ; $008000 .loop: bra .loop ; $008003 unknown: jmp ($9000) ; $008005 return: rts ; $008008 org $9000 dw return
programs/oeis/329/A329480.asm
neoneye/loda
22
98534
; A329480: a(n) = (1 - A075677(n))/6 if 6|(A075677(n)-1) or a(n) = (A075677(n) + 1)/6 if 6|(A075677(n)+1). ; 0,1,0,2,-1,3,1,4,-2,5,0,6,-3,7,2,8,-4,9,-1,10,-5,11,3,12,-6,13,1,14,-7,15,4,16,-8,17,-2,18,-9,19,5,20,-10,21,0,22,-11,23,6,24,-12,25,-3,26,-13,27,7,28,-14,29,2,30,-15,31,8,32,-16,33,-4,34,-17 add $0,1 mov $2,2 mov $3,$0 div $3,$0 mov $4,$0 lpb $3 mov $5,$4 lpb $5 sub $0,1 mul $0,-1 mov $6,$0 div $0,$2 mod $6,$2 cmp $6,0 sub $5,$6 lpe cmp $6,3 cmp $6,0 sub $3,$6 lpe div $0,2
oeis/015/A015214.asm
neoneye/loda-programs
11
170051
; A015214: Sum of Gaussian binomial coefficients for q=22. ; Submitted by <NAME> ; 1,2,25,1016,268207,238539494,1382716988605,27048350125366292,3449045122716021610219,1484308738900247467387102658,4163928976044712815287479196411545,39423133831682965670575172359334015725424,2433059985326120369557181599944136945275448021063,506784493996609815036893536232357806554059407725366784286,688093836296661558486357231219032217859120848600062137239553552885,3153122547167648227076072451767607891907847574179955952065686003084507493068 mov $1,$0 mov $0,0 add $1,1 mov $2,1 lpb $1 sub $1,1 mov $4,$2 mul $2,22 mul $4,$3 add $0,$4 sub $3,$4 add $3,$0 add $3,$2 lpe mov $0,$3 div $0,484 add $0,1
test-resources/ExamplesFromRoy/gm_text_types.1.ads
hergin/ada2fuml
0
923
package Gm_Text_Types is -- This type defines the text block name length. subtype Name_Length_Type is Positive range 1 .. 25; -- This type defines a text block name associated with a text block. subtype Name_Type is String (Name_Length_Type); Default_Name : constant Name_Type := Name_Type'(others => 'a'); end Gm_Text_Types;
P6/data_P6_2/cal_R_same_test33.asm
alxzzhou/BUAA_CO_2020
1
84136
lui $1,2105 ori $1,$1,4032 lui $2,29725 ori $2,$2,13998 lui $3,55026 ori $3,$3,7808 lui $4,8333 ori $4,$4,6966 lui $5,27987 ori $5,$5,32846 lui $6,26007 ori $6,$6,16836 mthi $1 mtlo $2 sec0: nop nop nop subu $6,$6,$6 sec1: nop nop or $6,$2,$1 subu $2,$6,$6 sec2: nop nop addiu $6,$5,5796 subu $3,$6,$6 sec3: nop nop mflo $6 subu $3,$6,$6 sec4: nop nop lhu $6,12($0) subu $4,$6,$6 sec5: nop slt $6,$5,$4 nop subu $4,$6,$6 sec6: nop nor $6,$2,$0 and $6,$3,$6 subu $5,$6,$6 sec7: nop sltu $6,$4,$1 lui $6,5206 subu $1,$6,$6 sec8: nop and $6,$5,$3 mflo $6 subu $4,$6,$6 sec9: nop xor $6,$4,$3 lh $6,12($0) subu $3,$6,$6 sec10: nop ori $6,$2,48968 nop subu $1,$6,$6 sec11: nop addiu $6,$2,4045 sltu $6,$4,$1 subu $4,$6,$6 sec12: nop xori $6,$3,15056 lui $6,57315 subu $2,$6,$6 sec13: nop xori $6,$5,27781 mflo $6 subu $2,$6,$6 sec14: nop andi $6,$3,7114 lhu $6,6($0) subu $5,$6,$6 sec15: nop mfhi $6 nop subu $4,$6,$6 sec16: nop mflo $6 or $6,$4,$4 subu $3,$6,$6 sec17: nop mfhi $6 sltiu $6,$3,31294 subu $5,$6,$6 sec18: nop mflo $6 mflo $6 subu $6,$6,$6 sec19: nop mfhi $6 lhu $6,16($0) subu $6,$6,$6 sec20: nop lbu $6,2($0) nop subu $1,$6,$6 sec21: nop lw $6,0($0) and $6,$4,$2 subu $5,$6,$6 sec22: nop lh $6,10($0) sltiu $6,$3,16417 subu $2,$6,$6 sec23: nop lbu $6,1($0) mflo $6 subu $5,$6,$6 sec24: nop lw $6,0($0) lhu $6,8($0) subu $6,$6,$6 sec25: or $6,$2,$2 nop nop subu $5,$6,$6 sec26: and $6,$6,$2 nop sltu $6,$1,$1 subu $3,$6,$6 sec27: or $6,$4,$0 nop slti $6,$2,-11909 subu $2,$6,$6 sec28: xor $6,$4,$3 nop mflo $6 subu $6,$6,$6 sec29: sltu $6,$0,$3 nop lbu $6,10($0) subu $5,$6,$6 sec30: addu $6,$2,$3 and $6,$5,$5 nop subu $3,$6,$6 sec31: slt $6,$4,$2 xor $6,$1,$1 slt $6,$2,$3 subu $1,$6,$6 sec32: slt $6,$2,$1 subu $6,$1,$6 ori $6,$4,11508 subu $3,$6,$6 sec33: addu $6,$2,$6 nor $6,$6,$2 mflo $6 subu $4,$6,$6 sec34: or $6,$4,$4 nor $6,$5,$4 lhu $6,8($0) subu $5,$6,$6 sec35: sltu $6,$2,$3 sltiu $6,$2,-22334 nop subu $4,$6,$6 sec36: addu $6,$3,$0 xori $6,$0,60982 or $6,$1,$0 subu $3,$6,$6 sec37: slt $6,$6,$2 addiu $6,$5,-9988 sltiu $6,$3,-619 subu $5,$6,$6 sec38: or $6,$1,$2 sltiu $6,$3,14620 mfhi $6 subu $3,$6,$6 sec39: xor $6,$1,$1 andi $6,$5,36694 lb $6,10($0) subu $1,$6,$6 sec40: xor $6,$4,$2 mflo $6 nop subu $3,$6,$6 sec41: xor $6,$4,$5 mfhi $6 sltu $6,$3,$2 subu $4,$6,$6 sec42: or $6,$6,$3 mfhi $6 lui $6,29428 subu $2,$6,$6 sec43: slt $6,$2,$4 mflo $6 mflo $6 subu $3,$6,$6 sec44: subu $6,$4,$1 mflo $6 lb $6,2($0) subu $1,$6,$6 sec45: subu $6,$5,$6 lw $6,12($0) nop subu $5,$6,$6 sec46: subu $6,$3,$6 lh $6,2($0) xor $6,$4,$1 subu $3,$6,$6 sec47: sltu $6,$0,$3 lh $6,14($0) sltiu $6,$3,-20755 subu $1,$6,$6 sec48: addu $6,$4,$5 lb $6,1($0) mfhi $6 subu $4,$6,$6 sec49: sltu $6,$3,$1 lbu $6,14($0) lb $6,4($0) subu $3,$6,$6 sec50: lui $6,13561 nop nop subu $3,$6,$6 sec51: ori $6,$1,43914 nop slt $6,$4,$3 subu $2,$6,$6 sec52: andi $6,$1,44581 nop lui $6,50250 subu $4,$6,$6 sec53: sltiu $6,$2,-22322 nop mfhi $6 subu $3,$6,$6 sec54: slti $6,$3,-17217 nop lb $6,10($0) subu $0,$6,$6 sec55: sltiu $6,$4,-60 nor $6,$3,$5 nop subu $5,$6,$6 sec56: ori $6,$4,14478 or $6,$1,$5 nor $6,$0,$3 subu $3,$6,$6 sec57: lui $6,45734 xor $6,$6,$1 slti $6,$5,-8262 subu $3,$6,$6 sec58: andi $6,$5,24652 and $6,$1,$3 mflo $6 subu $0,$6,$6 sec59: andi $6,$2,33781 xor $6,$3,$4 lb $6,6($0) subu $5,$6,$6 sec60: addiu $6,$0,28945 ori $6,$3,8728 nop subu $4,$6,$6 sec61: lui $6,32007 addiu $6,$1,-30364 subu $6,$1,$0 subu $4,$6,$6 sec62: addiu $6,$6,-27230 ori $6,$0,14633 ori $6,$6,35112 subu $4,$6,$6 sec63: ori $6,$4,60504 xori $6,$2,30176 mflo $6 subu $3,$6,$6 sec64: sltiu $6,$0,-558 lui $6,27978 lb $6,12($0) subu $0,$6,$6 sec65: sltiu $6,$1,-22862 mfhi $6 nop subu $6,$6,$6 sec66: ori $6,$1,8828 mfhi $6 addu $6,$0,$4 subu $3,$6,$6 sec67: xori $6,$1,26300 mfhi $6 ori $6,$5,1607 subu $1,$6,$6 sec68: addiu $6,$2,-8752 mfhi $6 mfhi $6 subu $3,$6,$6 sec69: lui $6,13881 mfhi $6 lw $6,0($0) subu $4,$6,$6 sec70: andi $6,$5,7492 lbu $6,16($0) nop subu $4,$6,$6 sec71: xori $6,$4,33726 lbu $6,1($0) addu $6,$5,$4 subu $3,$6,$6 sec72: sltiu $6,$4,-28604 lh $6,2($0) xori $6,$1,16193 subu $3,$6,$6 sec73: andi $6,$2,60228 lh $6,10($0) mfhi $6 subu $3,$6,$6 sec74: sltiu $6,$1,26099 lhu $6,4($0) lhu $6,16($0) subu $3,$6,$6 sec75: mfhi $6 nop nop subu $0,$6,$6 sec76: mflo $6 nop nor $6,$1,$5 subu $3,$6,$6 sec77: mflo $6 nop lui $6,35201 subu $1,$6,$6 sec78: mfhi $6 nop mflo $6 subu $2,$6,$6 sec79: mfhi $6 nop lw $6,0($0) subu $3,$6,$6 sec80: mflo $6 sltu $6,$5,$2 nop subu $2,$6,$6 sec81: mfhi $6 addu $6,$1,$3 subu $6,$3,$3 subu $2,$6,$6 sec82: mfhi $6 xor $6,$5,$3 ori $6,$1,30594 subu $4,$6,$6 sec83: mfhi $6 nor $6,$0,$6 mflo $6 subu $3,$6,$6 sec84: mflo $6 nor $6,$4,$6 lb $6,1($0) subu $2,$6,$6 sec85: mfhi $6 slti $6,$3,16466 nop subu $3,$6,$6 sec86: mfhi $6 andi $6,$1,27365 slt $6,$1,$3 subu $1,$6,$6 sec87: mfhi $6 xori $6,$4,7865 sltiu $6,$4,4796 subu $4,$6,$6 sec88: mflo $6 addiu $6,$0,2820 mfhi $6 subu $3,$6,$6 sec89: mflo $6 andi $6,$2,49673 lh $6,14($0) subu $3,$6,$6 sec90: mflo $6 mflo $6 nop subu $3,$6,$6 sec91: mfhi $6 mflo $6 subu $6,$5,$3 subu $2,$6,$6 sec92: mflo $6 mfhi $6 andi $6,$3,24583 subu $1,$6,$6 sec93: mfhi $6 mflo $6 mfhi $6 subu $4,$6,$6 sec94: mflo $6 mflo $6 lh $6,8($0) subu $2,$6,$6 sec95: mfhi $6 lb $6,5($0) nop subu $5,$6,$6 sec96: mflo $6 lb $6,2($0) sltu $6,$2,$4 subu $3,$6,$6 sec97: mfhi $6 lbu $6,11($0) xori $6,$4,31124 subu $5,$6,$6 sec98: mflo $6 lw $6,0($0) mflo $6 subu $5,$6,$6 sec99: mfhi $6 lb $6,9($0) lb $6,15($0) subu $1,$6,$6 sec100: lb $6,15($0) nop nop subu $1,$6,$6 sec101: lhu $6,4($0) nop addu $6,$6,$2 subu $6,$6,$6 sec102: lh $6,8($0) nop lui $6,13626 subu $3,$6,$6 sec103: lw $6,0($0) nop mfhi $6 subu $3,$6,$6 sec104: lbu $6,14($0) nop lb $6,12($0) subu $5,$6,$6 sec105: lb $6,4($0) subu $6,$3,$4 nop subu $6,$6,$6 sec106: lh $6,2($0) sltu $6,$2,$4 subu $6,$4,$4 subu $2,$6,$6 sec107: lw $6,4($0) or $6,$3,$2 addiu $6,$4,26110 subu $4,$6,$6 sec108: lbu $6,16($0) xor $6,$1,$2 mfhi $6 subu $4,$6,$6 sec109: lhu $6,4($0) sltu $6,$2,$2 lw $6,16($0) subu $2,$6,$6 sec110: lbu $6,8($0) sltiu $6,$3,-1820 nop subu $3,$6,$6 sec111: lh $6,8($0) slti $6,$0,-22563 or $6,$4,$3 subu $4,$6,$6 sec112: lw $6,8($0) andi $6,$1,29580 ori $6,$6,45168 subu $3,$6,$6 sec113: lb $6,15($0) sltiu $6,$3,29170 mfhi $6 subu $2,$6,$6 sec114: lh $6,2($0) ori $6,$3,152 lb $6,7($0) subu $3,$6,$6 sec115: lbu $6,11($0) mflo $6 nop subu $3,$6,$6 sec116: lh $6,16($0) mflo $6 or $6,$4,$2 subu $4,$6,$6 sec117: lb $6,11($0) mflo $6 lui $6,24512 subu $5,$6,$6 sec118: lh $6,6($0) mflo $6 mfhi $6 subu $5,$6,$6 sec119: lhu $6,8($0) mflo $6 lw $6,12($0) subu $2,$6,$6 sec120: lhu $6,10($0) lb $6,16($0) nop subu $3,$6,$6 sec121: lbu $6,16($0) lhu $6,0($0) sltu $6,$4,$6 subu $5,$6,$6 sec122: lh $6,14($0) lh $6,4($0) lui $6,23468 subu $1,$6,$6 sec123: lb $6,7($0) lbu $6,11($0) mfhi $6 subu $1,$6,$6 sec124: lhu $6,14($0) lbu $6,1($0) lbu $6,14($0) subu $2,$6,$6
other.7z/SFC.7z/SFC/ソースデータ/ゼルダの伝説神々のトライフォース/日本_Ver3/asm/z00_grnd.asm
prismotizm/gigaleak
0
241843
<filename>other.7z/SFC.7z/SFC/ソースデータ/ゼルダの伝説神々のトライフォース/日本_Ver3/asm/z00_grnd.asm Name: z00_grnd.asm Type: file Size: 110882 Last-Modified: '2016-05-13T04:36:32Z' SHA-1: EE2DA3BE6F1D328EDD6B3EFD0AE3D4ED6D9B53C4 Description: null
archive/d/debug/helloworld.asm
asharma13524/sample-programs
422
13946
<filename>archive/d/debug/helloworld.asm ; ------------------------------------------------------------------ ; helloworld.asm ; ; This is a Win64 console program that writes "Hello World" ; on a single line and then exits. ; ; To assemble to .obj: nasm -f Win64 helloworld.asm ; To compile to .exe: gcc helloworld.obj -o helloworld.exe ; ------------------------------------------------------------------ global _main ; declare main() method extern _printf ; link to external library segment .data message: db 'Hello world', 0xA, 0 ; text message ; 0xA (10) is hex for (NL), carriage return ; 0 terminates the line ; code is put in the .text section section .text _main: ; the entry point! void main() push message ; save message to the stack call _printf ; display the first value on the stack add esp, 4 ; clear the stack ret ; return
orka/src/orka/interface/orka-loggers.ads
onox/orka
52
11643
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2018 onox <<EMAIL>> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with GL.Debug; package Orka.Loggers is pragma Preelaborate; type Source is (Worker, Game_Loop, Resource_Loader, OpenGL, Window_System, Shader_Compiler, Third_Party, Application, Other); type Message_Type is new GL.Debug.Message_Type; type Severity is (Error, Warning, Info, Debug); type Logger is synchronized interface; procedure Log (Object : in out Logger; From : Source; Kind : Message_Type; Level : Severity; Message : String) is abstract with Synchronization => By_Protected_Procedure; type Logger_Ptr is not null access all Logger'Class; end Orka.Loggers;
programs/oeis/309/A309674.asm
karttu/loda
0
174834
<reponame>karttu/loda ; A309674: a(1) = 1, a(n) = hamming_weight(Sum_{k=1..n-1} a(k) ) for n>=2. ; 1,1,1,2,2,3,2,2,3,2,3,3,3,3,5,2,3,3,3,5,3,5,4,1,2,3,3,3,3,5,3,5,4,2,3,4,4,5,4,5,6,2,3,3,3,3,5,3,5,4,2,3,4,4,5,4,5,6,3,3,5,4,3,5,4,5,4,5,5,7,6,6,2,2,3,3,3,5,3,5,4,2,3,4,4,5,4,5,6,3,3,5,4,3,5,4,5,4,5,5,7,6,6,3,4,4,5,4,5,6,4,5,5,7,6,6,4,5,6,5,6,6,5,7,7,7,7,3,3,3,3,5,3,5,4,2,3,4,4,5,4,5,6,3,3,5,4,3,5,4,5,4,5,5,7,6,6,3,4,4,5,4,5,6,4,5,5,7,6,6,4,5,6,5,6,6,5,7,7,7,7,4,5,4,3,5,4,5,4,5,5,7,6,6,4,5,6,5,6,6,5,7,7,7,7,5,4,5,5,6,6,5,7,7,7,7,6,6,8,8,9,6,8,8,9,4,4,5,3,5,4,2,3,4,4,5,4,5,6,3,3,5,4,3,5,4,5,4,5,5 mov $7,2 mov $9,$0 lpb $7,1 sub $7,1 add $0,$7 sub $0,1 mov $2,$0 mov $5,1 mov $6,2 lpb $2,1 mov $3,$5 div $3,2 mul $5,$6 lpb $5,1 sub $5,$3 div $3,2 lpe sub $2,1 lpe mov $4,$7 mov $8,$5 lpb $4,1 mov $1,$8 sub $4,1 lpe lpe lpb $9,1 sub $1,$8 mov $9,0 lpe
test/asset/agda-stdlib-1.0/Category/Monad/State.agda
omega12345/agda-mode
0
5103
------------------------------------------------------------------------ -- The Agda standard library -- -- The state monad ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Category.Monad.State where open import Category.Applicative.Indexed open import Category.Monad open import Function.Identity.Categorical as Id using (Identity) open import Category.Monad.Indexed open import Data.Product open import Data.Unit open import Function open import Level ------------------------------------------------------------------------ -- Indexed state IStateT : ∀ {i f} {I : Set i} → (I → Set f) → (Set f → Set f) → IFun I f IStateT S M i j A = S i → M (A × S j) ------------------------------------------------------------------------ -- Indexed state applicative StateTIApplicative : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonad M → RawIApplicative (IStateT S M) StateTIApplicative S Mon = record { pure = λ a s → return (a , s) ; _⊛_ = λ f t s → do (f′ , s′) ← f s (t′ , s′′) ← t s′ return (f′ t′ , s′′) } where open RawMonad Mon StateTIApplicativeZero : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonadZero M → RawIApplicativeZero (IStateT S M) StateTIApplicativeZero S Mon = record { applicative = StateTIApplicative S monad ; ∅ = const ∅ } where open RawMonadZero Mon StateTIAlternative : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonadPlus M → RawIAlternative (IStateT S M) StateTIAlternative S Mon = record { applicativeZero = StateTIApplicativeZero S monadZero ; _∣_ = λ m n s → m s ∣ n s } where open RawMonadPlus Mon ------------------------------------------------------------------------ -- Indexed state monad StateTIMonad : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonad M → RawIMonad (IStateT S M) StateTIMonad S Mon = record { return = λ x s → return (x , s) ; _>>=_ = λ m f s → m s >>= uncurry f } where open RawMonad Mon StateTIMonadZero : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonadZero M → RawIMonadZero (IStateT S M) StateTIMonadZero S Mon = record { monad = StateTIMonad S (RawMonadZero.monad Mon) ; applicativeZero = StateTIApplicativeZero S Mon } where open RawMonadZero Mon StateTIMonadPlus : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonadPlus M → RawIMonadPlus (IStateT S M) StateTIMonadPlus S Mon = record { monad = StateTIMonad S monad ; alternative = StateTIAlternative S Mon } where open RawMonadPlus Mon ------------------------------------------------------------------------ -- State monad operations record RawIMonadState {i f} {I : Set i} (S : I → Set f) (M : IFun I f) : Set (i ⊔ suc f) where field monad : RawIMonad M get : ∀ {i} → M i i (S i) put : ∀ {i j} → S j → M i j (Lift f ⊤) open RawIMonad monad public modify : ∀ {i j} → (S i → S j) → M i j (Lift f ⊤) modify f = get >>= put ∘ f StateTIMonadState : ∀ {i f} {I : Set i} (S : I → Set f) {M} → RawMonad M → RawIMonadState S (IStateT S M) StateTIMonadState S Mon = record { monad = StateTIMonad S Mon ; get = λ s → return (s , s) ; put = λ s _ → return (_ , s) } where open RawIMonad Mon ------------------------------------------------------------------------ -- Ordinary state monads RawMonadState : ∀ {f} → Set f → (Set f → Set f) → Set _ RawMonadState S M = RawIMonadState {I = ⊤} (λ _ → S) (λ _ _ → M) module RawMonadState {f} {S : Set f} {M : Set f → Set f} (Mon : RawMonadState S M) where open RawIMonadState Mon public StateT : ∀ {f} → Set f → (Set f → Set f) → Set f → Set f StateT S M = IStateT {I = ⊤} (λ _ → S) M _ _ StateTMonad : ∀ {f} (S : Set f) {M} → RawMonad M → RawMonad (StateT S M) StateTMonad S = StateTIMonad (λ _ → S) StateTMonadZero : ∀ {f} (S : Set f) {M} → RawMonadZero M → RawMonadZero (StateT S M) StateTMonadZero S = StateTIMonadZero (λ _ → S) StateTMonadPlus : ∀ {f} (S : Set f) {M} → RawMonadPlus M → RawMonadPlus (StateT S M) StateTMonadPlus S = StateTIMonadPlus (λ _ → S) StateTMonadState : ∀ {f} (S : Set f) {M} → RawMonad M → RawMonadState S (StateT S M) StateTMonadState S = StateTIMonadState (λ _ → S) State : ∀ {f} → Set f → Set f → Set f State S = StateT S Identity StateMonad : ∀ {f} (S : Set f) → RawMonad (State S) StateMonad S = StateTMonad S Id.monad StateMonadState : ∀ {f} (S : Set f) → RawMonadState S (State S) StateMonadState S = StateTMonadState S Id.monad LiftMonadState : ∀ {f S₁} (S₂ : Set f) {M} → RawMonadState S₁ M → RawMonadState S₁ (StateT S₂ M) LiftMonadState S₂ Mon = record { monad = StateTIMonad (λ _ → S₂) monad ; get = λ s → get >>= λ x → return (x , s) ; put = λ s′ s → put s′ >> return (_ , s) } where open RawIMonadState Mon
aunit/aunit-reporter.ads
btmalone/alog
0
1941
<filename>aunit/aunit-reporter.ads ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- A U N I T . R E P O R T E R -- -- -- -- S p e c -- -- -- -- -- -- Copyright (C) 2008-2013, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT is maintained by AdaCore (http://www.adacore.com) -- -- -- ------------------------------------------------------------------------------ with AUnit.Options; use AUnit.Options; with AUnit.Test_Results; use AUnit.Test_Results; package AUnit.Reporter is type Reporter is abstract tagged null record; procedure Report (Engine : Reporter; R : in out Result'Class; Options : AUnit_Options := Default_Options) is abstract; -- This procedure is called by AUnit.Run to report the result after running -- the whole testsuite (or the selected subset of tests). end AUnit.Reporter;
Data/List/Relation/Membership.agda
Lolirofle/stuff-in-agda
6
8037
<reponame>Lolirofle/stuff-in-agda open import Type open import Structure.Setoid renaming (_≡_ to _≡ₑ_) -- Finite sets represented by lists module Data.List.Relation.Membership {ℓ ℓₑ} {T : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(T)⦄ where open import Data.List open import Data.List.Relation.Quantification using (ExistsElement ; ExistsUniqueElement) open import Functional open import Logic _∈_ : T → List(T) → Stmt _∈_ = ExistsElement ∘ (_≡ₑ_) module _∈_ where pattern use {x}{l} px = ExistsElement.•_ {x = x}{l = l} px pattern skip {x}{l} el = ExistsElement.⊰_ {l = l}{x = x} el open _∈_ public open import Relator.Sets(_∈_) public _∈!_ : T → List(T) → Stmt _∈!_ = ExistsUniqueElement ∘ (_≡ₑ_)
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0.log_21829_1528.asm
ljhsiun2/medusa
9
177905
<filename>Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0.log_21829_1528.asm .global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r14 push %r15 push %r8 push %r9 push %rcx lea addresses_WC_ht+0x1c3ee, %r13 nop nop nop cmp $25092, %r14 mov $0x6162636465666768, %rcx movq %rcx, %xmm6 and $0xffffffffffffffc0, %r13 vmovntdq %ymm6, (%r13) nop nop sub %r9, %r9 lea addresses_A_ht+0x138ee, %r15 clflush (%r15) nop nop sub %rcx, %rcx movb $0x61, (%r15) nop xor %rcx, %rcx lea addresses_normal_ht+0x80ee, %r13 nop nop nop nop nop cmp %r11, %r11 mov (%r13), %rcx nop nop nop nop nop add %r15, %r15 lea addresses_D_ht+0xc91e, %r11 clflush (%r11) nop nop nop xor $28647, %r14 movw $0x6162, (%r11) nop nop nop nop cmp $2736, %r14 lea addresses_D_ht+0x9a4, %rcx nop sub %r15, %r15 vmovups (%rcx), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $1, %xmm1, %r11 nop nop nop cmp $20983, %rcx lea addresses_UC_ht+0x11ae, %r11 clflush (%r11) nop add %r8, %r8 movl $0x61626364, (%r11) nop cmp %r8, %r8 lea addresses_WT_ht+0x1bdee, %rcx add $54639, %r15 movb $0x61, (%rcx) nop inc %r14 pop %rcx pop %r9 pop %r8 pop %r15 pop %r14 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r15 push %rbx push %rcx push %rdx // Faulty Load lea addresses_RW+0x18ee, %rcx nop and %r10, %r10 mov (%rcx), %rbx lea oracles, %r15 and $0xff, %rbx shlq $12, %rbx mov (%r15,%rbx,1), %rbx pop %rdx pop %rcx pop %rbx pop %r15 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_RW', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_RW', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 4, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1}} {'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': True, 'congruent': 3, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 2}} {'src': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 4}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_1674.asm
ljhsiun2/medusa
9
21548
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r8 push %rbx push %rcx push %rsi lea addresses_normal_ht+0x97de, %rbx nop nop nop xor %r13, %r13 vmovups (%rbx), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %r8 nop nop add $56393, %rcx lea addresses_D_ht+0x1103e, %rcx nop cmp $61563, %r12 mov $0x6162636465666768, %rsi movq %rsi, (%rcx) nop nop nop nop cmp $49824, %rbx pop %rsi pop %rcx pop %rbx pop %r8 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r9 push %rbp push %rsi // Load lea addresses_A+0x663e, %r9 nop nop nop inc %r13 mov (%r9), %si xor $50275, %r9 // Faulty Load lea addresses_normal+0x1ce3e, %rbp nop nop nop nop sub $39151, %rsi mov (%rbp), %r14 lea oracles, %r10 and $0xff, %r14 shlq $12, %r14 mov (%r10,%r14,1), %r14 pop %rsi pop %rbp pop %r9 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_normal', 'same': False, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A', 'same': False, 'size': 2, 'congruent': 11, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_normal', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
examples/GUIgeneric/GUIFeaturesPart5.agda
stephanadls/state-dependent-gui
2
4329
-- {-# OPTIONS --allow-unsolved-metas #-} module GUIgeneric.GUIFeaturesPart5 where open import GUIgeneric.Prelude renaming (addButton to addButton') open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add) open import GUIgeneric.GUI open import GUIgeneric.GUIExampleLib open import StateSizedIO.GUI.WxGraphicsLibLevel3 renaming (addButton to addButton') open import GUIgeneric.GUIFeatures open import GUIgeneric.GUIFeaturesPart2 hiding ( main ; main1 ) open import GUIgeneric.GUIFeaturesPart3 hiding ( main ; Tea ; Cancel) open import GUIgeneric.GUIFeaturesPart4 hiding ( main ; cancelNewStateSM ; cancelStateAdded ; cancelFeatureAdded ) open import GUIgeneric.GUIExample hiding (main ) data StatesBasicVM : Set where pay change soda serveSoda open' close : StatesBasicVM basicVM : FMachine StatesBasicVM basicVM .Features = ⊤ basicVM .AddStateF = ⊥ basicVM .GUIF f (inj₁ pay) = simpleSMState "Pay" (inj₁ change) basicVM .GUIF f (inj₁ change) = simpleSMState "Get Change" (inj₁ soda) basicVM .GUIF f (inj₁ soda) = simpleSMState "Soda" (inj₁ serveSoda) basicVM .GUIF f (inj₁ serveSoda) = simpleSMState "Serve Soda" (inj₁ open') basicVM .GUIF f (inj₁ open') = simpleSMState "Open" (inj₁ close) basicVM .GUIF f (inj₁ close) = simpleSMState "Close" (inj₁ pay) basicVM .GUIF f (inj₂ ()) newState : {A B : Set} → A ⊎ B ⊎ ⊤ newState = (inj₂ (inj₂ tt)) {- handler for the new state to be added to the tea machine -} teaNewStateSM : (fm : FMachine StatesBasicVM) → SMachineState (StatesBasicVM ⊎ fm .AddStateF ⊎ ⊤) newState teaNewStateSM fm = simpleSMState "Serve Tea" (inj₁ open') {- add the new state to the feature machine -} TeaMAddNewState : FMachine StatesBasicVM → FMachine StatesBasicVM TeaMAddNewState fm = addOneStateFMachine fm (teaNewStateSM fm) {- add a dummy feature "FeatureTea" to the feature machine -} TeaMAddFeature : FMachine StatesBasicVM → FMachine StatesBasicVM TeaMAddFeature fm = addDummyFeatures (TeaMAddNewState fm) FeatureTea {- redefine in the feature machine one button -} Tea : FMachine StatesBasicVM → FMachine StatesBasicVM Tea fm .Features = TeaMAddFeature fm .Features Tea fm .AddStateF = TeaMAddFeature fm .AddStateF Tea fm .GUIF (f , yesTea) (inj₁ soda) = addBtn2StateMachine ( TeaMAddFeature fm .GUIF (f , yesTea) (inj₁ soda)) "Tea" newState Tea fm .GUIF f s = TeaMAddFeature fm .GUIF f s {- handler for the new state to be added to the cancel machine -} cancelNewStateSM : (fm : FMachine StatesBasicVM) → SMachineState (StatesBasicVM ⊎ fm .AddStateF ⊎ ⊤) newState cancelNewStateSM fm = simpleSMState "Cancelling" (inj₁ pay) {- add the state to the old feature machine -} cancelStateAdded : FMachine StatesBasicVM → FMachine StatesBasicVM cancelStateAdded fm = addOneStateFMachine fm (cancelNewStateSM fm) {- add a dummy feature "FeatureCancel" to the feature machine -} cancelFeatureAdded : FMachine StatesBasicVM → FMachine StatesBasicVM cancelFeatureAdded fm = addDummyFeatures (cancelStateAdded fm) FeatureCancel {- redefine in the feature machine one button -} Cancel : FMachine StatesBasicVM → FMachine StatesBasicVM Cancel fm .Features = cancelFeatureAdded fm .Features Cancel fm .AddStateF = cancelFeatureAdded fm .AddStateF Cancel fm .GUIF (f , yesCancel) (inj₁ soda) = addBtn2StateMachine (cancelFeatureAdded fm .GUIF (f , yesCancel) (inj₁ soda)) "Cancel" newState Cancel fm .GUIF f s = cancelFeatureAdded fm .GUIF f s {- add the Dummy free feature -} FreeMAddFeature : FMachine StatesBasicVM → FMachine StatesBasicVM FreeMAddFeature fm = addDummyFeatures fm FeatureFree {- redefine the pay button to free in case feature free is yesFree -} Free : FMachine StatesBasicVM → FMachine StatesBasicVM Free fm .Features = FreeMAddFeature fm .Features Free fm .AddStateF = FreeMAddFeature fm .AddStateF Free fm .GUIF (f , yesFree) (inj₁ pay) = simpleSMState "Free" (inj₁ soda) Free fm .GUIF (f , yesFree) (inj₁ open') = simpleSMState "Skip" (inj₁ pay) Free fm .GUIF f s = FreeMAddFeature fm .GUIF f s main1 : NativeIO Unit main1 = compileFeatureVM (Tea (Cancel basicVM)) ((_ , yesCancel) , yesTea) (inj₁ pay) main2 : NativeIO Unit main2 = compileFeatureVM (Free basicVM) (_ , yesFree) (inj₁ pay) -- multiFeatureMachine : FMachine StatesBasicVM multiFeatureMachine = Free (Cancel (Tea basicVM)) main : NativeIO Unit main = compileFeatureVM multiFeatureMachine (((_ , yesTea) , yesCancel) , noFree) (inj₁ pay)
corpus/MySQLBase.g4
raku-community-modules/ANTLR4-Grammar
28
813
lexer grammar MySQLBase; @header { } SELECT: 'select'; FROM: 'from'; WHERE: 'where'; AND: 'and' | '&&'; OR: 'or' | '||'; XOR: 'xor'; IS: 'is'; NULL: 'null'; LIKE: 'like'; IN: 'in'; EXISTS: 'exists'; ALL: 'all'; ANY: 'any'; TRUE: 'true'; FALSE: 'false'; DIVIDE : 'div' | '/' ; MOD: 'mod' | '%' ; BETWEEN: 'between'; REGEXP: 'regexp'; PLUS : '+' ; MINUS : '-' ; NEGATION: '~' ; VERTBAR : '|' ; BITAND : '&' ; POWER_OP: '^' ; BINARY: 'binary'; SHIFT_LEFT : '<<' ; SHIFT_RIGHT : '>>' ; ESCAPE: 'escape'; ASTERISK: '*' ; RPAREN : ')' ; LPAREN : '(' ; RBRACK : ']' ; LBRACK : '[' ; COLON : ':' ; ALL_FIELDS : '.*' ; EQ: '='; LTH: '<'; GTH: '>'; NOT_EQ: '!='; NOT: 'not'; LET: '<='; GET: '>='; SEMI: ';'; COMMA: ','; DOT: '.'; COLLATE: 'collate'; INNER: 'inner'; OUTER: 'outer'; JOIN: 'join'; CROSS: 'cross'; USING: 'using'; INDEX: 'index'; KEY: 'key'; ORDER: 'order'; GROUP: 'group'; BY: 'by'; FOR: 'for'; USE: 'use'; IGNORE: 'ignore'; PARTITION: 'partition'; STRAIGHT_JOIN: 'straight_join'; NATURAL: 'natural'; LEFT: 'left'; RIGHT: 'right'; OJ: 'oj'; ON: 'on'; ID: ('a'..'z' | 'A' .. 'Z' | '_')+ ; INT: '0'..'9'+ ; NEWLINE: '\r' ? '\n' -> skip; WS: (' ' | '\t' | '\n' | '\r')+ -> skip; USER_VAR: '@' (USER_VAR_SUBFIX1 | USER_VAR_SUBFIX2 | USER_VAR_SUBFIX3 | USER_VAR_SUBFIX4) ; fragment USER_VAR_SUBFIX1: ( '`' (~'`' )+ '`' ) ; fragment USER_VAR_SUBFIX2: ( '\'' (~'\'')+ '\'' ) ; fragment USER_VAR_SUBFIX3: ( '\"' (~'\"')+ '\"' ) ; fragment USER_VAR_SUBFIX4: ( 'A'..'Z' | 'a'..'z' | '_' | '$' | '0'..'9' | DOT )+ ;
oeis/003/A003408.asm
neoneye/loda-programs
11
29082
<reponame>neoneye/loda-programs ; A003408: a(n) = binomial(3n+6, n). ; 1,9,66,455,3060,20349,134596,888030,5852925,38567100,254186856,1676056044,11058116888,73006209045,482320623240,3188675231420,21094923659355,139646485582065,925029565741050,6131164307078475,40661170824914640,269807672771096460,1791242627540058576,11897861344151333400,79065487387985398300,525652003943603702568,3496176570135581124912,23262852200346573844008,154845501803470319664240,1031079709925550569660805,6868096454739518200146192,45764000431735762419272568,305034117784512049976284935 mov $1,2 add $1,$0 mul $1,3 bin $1,$0 mov $0,$1
Validation/pyFrame3DD-master/gcc-master/gcc/ada/freeze.adb
djamal2727/Main-Bearing-Analytical-Model
0
15497
<reponame>djamal2727/Main-Bearing-Analytical-Model ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- F R E E Z E -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Aspects; use Aspects; with Atree; use Atree; with Checks; use Checks; with Contracts; use Contracts; with Debug; use Debug; with Einfo; use Einfo; with Elists; use Elists; with Errout; use Errout; with Exp_Ch3; use Exp_Ch3; with Exp_Ch7; use Exp_Ch7; with Exp_Pakd; use Exp_Pakd; with Exp_Util; use Exp_Util; with Exp_Tss; use Exp_Tss; with Ghost; use Ghost; with Layout; use Layout; with Lib; use Lib; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Restrict; use Restrict; with Rident; use Rident; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Cat; use Sem_Cat; with Sem_Ch3; use Sem_Ch3; with Sem_Ch6; use Sem_Ch6; with Sem_Ch7; use Sem_Ch7; with Sem_Ch8; use Sem_Ch8; with Sem_Ch13; use Sem_Ch13; with Sem_Eval; use Sem_Eval; with Sem_Mech; use Sem_Mech; with Sem_Prag; use Sem_Prag; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; with Targparm; use Targparm; with Tbuild; use Tbuild; with Ttypes; use Ttypes; with Uintp; use Uintp; with Urealp; use Urealp; with Warnsw; use Warnsw; package body Freeze is ----------------------- -- Local Subprograms -- ----------------------- procedure Adjust_Esize_For_Alignment (Typ : Entity_Id); -- Typ is a type that is being frozen. If no size clause is given, -- but a default Esize has been computed, then this default Esize is -- adjusted up if necessary to be consistent with a given alignment, -- but never to a value greater than Long_Long_Integer'Size. This -- is used for all discrete types and for fixed-point types. procedure Build_And_Analyze_Renamed_Body (Decl : Node_Id; New_S : Entity_Id; After : in out Node_Id); -- Build body for a renaming declaration, insert in tree and analyze procedure Check_Address_Clause (E : Entity_Id); -- Apply legality checks to address clauses for object declarations, -- at the point the object is frozen. Also ensure any initialization is -- performed only after the object has been frozen. procedure Check_Component_Storage_Order (Encl_Type : Entity_Id; Comp : Entity_Id; ADC : Node_Id; Comp_ADC_Present : out Boolean); -- For an Encl_Type that has a Scalar_Storage_Order attribute definition -- clause, verify that the component type has an explicit and compatible -- attribute/aspect. For arrays, Comp is Empty; for records, it is the -- entity of the component under consideration. For an Encl_Type that -- does not have a Scalar_Storage_Order attribute definition clause, -- verify that the component also does not have such a clause. -- ADC is the attribute definition clause if present (or Empty). On return, -- Comp_ADC_Present is set True if the component has a Scalar_Storage_Order -- attribute definition clause. procedure Check_Debug_Info_Needed (T : Entity_Id); -- As each entity is frozen, this routine is called to deal with the -- setting of Debug_Info_Needed for the entity. This flag is set if -- the entity comes from source, or if we are in Debug_Generated_Code -- mode or if the -gnatdV debug flag is set. However, it never sets -- the flag if Debug_Info_Off is set. This procedure also ensures that -- subsidiary entities have the flag set as required. procedure Check_Expression_Function (N : Node_Id; Nam : Entity_Id); -- When an expression function is frozen by a use of it, the expression -- itself is frozen. Check that the expression does not include references -- to deferred constants without completion. We report this at the freeze -- point of the function, to provide a better error message. -- -- In most cases the expression itself is frozen by the time the function -- itself is frozen, because the formals will be frozen by then. However, -- Attribute references to outer types are freeze points for those types; -- this routine generates the required freeze nodes for them. procedure Check_Inherited_Conditions (R : Entity_Id); -- For a tagged derived type, create wrappers for inherited operations -- that have a class-wide condition, so it can be properly rewritten if -- it involves calls to other overriding primitives. procedure Check_Strict_Alignment (E : Entity_Id); -- E is a base type. If E is tagged or has a component that is aliased -- or tagged or contains something this is aliased or tagged, set -- Strict_Alignment. procedure Check_Unsigned_Type (E : Entity_Id); pragma Inline (Check_Unsigned_Type); -- If E is a fixed-point or discrete type, then all the necessary work -- to freeze it is completed except for possible setting of the flag -- Is_Unsigned_Type, which is done by this procedure. The call has no -- effect if the entity E is not a discrete or fixed-point type. procedure Freeze_And_Append (Ent : Entity_Id; N : Node_Id; Result : in out List_Id); -- Freezes Ent using Freeze_Entity, and appends the resulting list of -- nodes to Result, modifying Result from No_List if necessary. N has -- the same usage as in Freeze_Entity. procedure Freeze_Enumeration_Type (Typ : Entity_Id); -- Freeze enumeration type. The Esize field is set as processing -- proceeds (i.e. set by default when the type is declared and then -- adjusted by rep clauses. What this procedure does is to make sure -- that if a foreign convention is specified, and no specific size -- is given, then the size must be at least Integer'Size. procedure Freeze_Static_Object (E : Entity_Id); -- If an object is frozen which has Is_Statically_Allocated set, then -- all referenced types must also be marked with this flag. This routine -- is in charge of meeting this requirement for the object entity E. procedure Freeze_Subprogram (E : Entity_Id); -- Perform freezing actions for a subprogram (create extra formals, -- and set proper default mechanism values). Note that this routine -- is not called for internal subprograms, for which neither of these -- actions is needed (or desirable, we do not want for example to have -- these extra formals present in initialization procedures, where they -- would serve no purpose). In this call E is either a subprogram or -- a subprogram type (i.e. an access to a subprogram). function Is_Fully_Defined (T : Entity_Id) return Boolean; -- True if T is not private and has no private components, or has a full -- view. Used to determine whether the designated type of an access type -- should be frozen when the access type is frozen. This is done when an -- allocator is frozen, or an expression that may involve attributes of -- the designated type. Otherwise freezing the access type does not freeze -- the designated type. procedure Process_Default_Expressions (E : Entity_Id; After : in out Node_Id); -- This procedure is called for each subprogram to complete processing of -- default expressions at the point where all types are known to be frozen. -- The expressions must be analyzed in full, to make sure that all error -- processing is done (they have only been preanalyzed). If the expression -- is not an entity or literal, its analysis may generate code which must -- not be executed. In that case we build a function body to hold that -- code. This wrapper function serves no other purpose (it used to be -- called to evaluate the default, but now the default is inlined at each -- point of call). procedure Set_Component_Alignment_If_Not_Set (Typ : Entity_Id); -- Typ is a record or array type that is being frozen. This routine sets -- the default component alignment from the scope stack values if the -- alignment is otherwise not specified. procedure Set_SSO_From_Default (T : Entity_Id); -- T is a record or array type that is being frozen. If it is a base type, -- and if SSO_Set_Low/High_By_Default is set, then Reverse_Storage order -- will be set appropriately. Note that an explicit occurrence of aspect -- Scalar_Storage_Order or an explicit setting of this aspect with an -- attribute definition clause occurs, then these two flags are reset in -- any case, so call will have no effect. procedure Undelay_Type (T : Entity_Id); -- T is a type of a component that we know to be an Itype. We don't want -- this to have a Freeze_Node, so ensure it doesn't. Do the same for any -- Full_View or Corresponding_Record_Type. procedure Warn_Overlay (Expr : Node_Id; Typ : Entity_Id; Nam : Node_Id); -- Expr is the expression for an address clause for entity Nam whose type -- is Typ. If Typ has a default initialization, and there is no explicit -- initialization in the source declaration, check whether the address -- clause might cause overlaying of an entity, and emit a warning on the -- side effect that the initialization will cause. ------------------------------- -- Adjust_Esize_For_Alignment -- ------------------------------- procedure Adjust_Esize_For_Alignment (Typ : Entity_Id) is Align : Uint; begin if Known_Esize (Typ) and then Known_Alignment (Typ) then Align := Alignment_In_Bits (Typ); if Align > Esize (Typ) and then Align <= Standard_Long_Long_Integer_Size then Set_Esize (Typ, Align); end if; end if; end Adjust_Esize_For_Alignment; ------------------------------------ -- Build_And_Analyze_Renamed_Body -- ------------------------------------ procedure Build_And_Analyze_Renamed_Body (Decl : Node_Id; New_S : Entity_Id; After : in out Node_Id) is Body_Decl : constant Node_Id := Unit_Declaration_Node (New_S); Ent : constant Entity_Id := Defining_Entity (Decl); Body_Node : Node_Id; Renamed_Subp : Entity_Id; begin -- If the renamed subprogram is intrinsic, there is no need for a -- wrapper body: we set the alias that will be called and expanded which -- completes the declaration. This transformation is only legal if the -- renamed entity has already been elaborated. -- Note that it is legal for a renaming_as_body to rename an intrinsic -- subprogram, as long as the renaming occurs before the new entity -- is frozen (RM 8.5.4 (5)). if Nkind (Body_Decl) = N_Subprogram_Renaming_Declaration and then Is_Entity_Name (Name (Body_Decl)) then Renamed_Subp := Entity (Name (Body_Decl)); else Renamed_Subp := Empty; end if; if Present (Renamed_Subp) and then Is_Intrinsic_Subprogram (Renamed_Subp) and then (not In_Same_Source_Unit (Renamed_Subp, Ent) or else Sloc (Renamed_Subp) < Sloc (Ent)) -- We can make the renaming entity intrinsic if the renamed function -- has an interface name, or if it is one of the shift/rotate -- operations known to the compiler. and then (Present (Interface_Name (Renamed_Subp)) or else Chars (Renamed_Subp) in Name_Rotate_Left | Name_Rotate_Right | Name_Shift_Left | Name_Shift_Right | Name_Shift_Right_Arithmetic) then Set_Interface_Name (Ent, Interface_Name (Renamed_Subp)); if Present (Alias (Renamed_Subp)) then Set_Alias (Ent, Alias (Renamed_Subp)); else Set_Alias (Ent, Renamed_Subp); end if; Set_Is_Intrinsic_Subprogram (Ent); Set_Has_Completion (Ent); else Body_Node := Build_Renamed_Body (Decl, New_S); Insert_After (After, Body_Node); Mark_Rewrite_Insertion (Body_Node); Analyze (Body_Node); After := Body_Node; end if; end Build_And_Analyze_Renamed_Body; ------------------------ -- Build_Renamed_Body -- ------------------------ function Build_Renamed_Body (Decl : Node_Id; New_S : Entity_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (New_S); -- We use for the source location of the renamed body, the location of -- the spec entity. It might seem more natural to use the location of -- the renaming declaration itself, but that would be wrong, since then -- the body we create would look as though it was created far too late, -- and this could cause problems with elaboration order analysis, -- particularly in connection with instantiations. N : constant Node_Id := Unit_Declaration_Node (New_S); Nam : constant Node_Id := Name (N); Old_S : Entity_Id; Spec : constant Node_Id := New_Copy_Tree (Specification (Decl)); Actuals : List_Id := No_List; Call_Node : Node_Id; Call_Name : Node_Id; Body_Node : Node_Id; Formal : Entity_Id; O_Formal : Entity_Id; Param_Spec : Node_Id; Pref : Node_Id := Empty; -- If the renamed entity is a primitive operation given in prefix form, -- the prefix is the target object and it has to be added as the first -- actual in the generated call. begin -- Determine the entity being renamed, which is the target of the call -- statement. If the name is an explicit dereference, this is a renaming -- of a subprogram type rather than a subprogram. The name itself is -- fully analyzed. if Nkind (Nam) = N_Selected_Component then Old_S := Entity (Selector_Name (Nam)); elsif Nkind (Nam) = N_Explicit_Dereference then Old_S := Etype (Nam); elsif Nkind (Nam) = N_Indexed_Component then if Is_Entity_Name (Prefix (Nam)) then Old_S := Entity (Prefix (Nam)); else Old_S := Entity (Selector_Name (Prefix (Nam))); end if; elsif Nkind (Nam) = N_Character_Literal then Old_S := Etype (New_S); else Old_S := Entity (Nam); end if; if Is_Entity_Name (Nam) then -- If the renamed entity is a predefined operator, retain full name -- to ensure its visibility. if Ekind (Old_S) = E_Operator and then Nkind (Nam) = N_Expanded_Name then Call_Name := New_Copy (Name (N)); else Call_Name := New_Occurrence_Of (Old_S, Loc); end if; else if Nkind (Nam) = N_Selected_Component and then Present (First_Formal (Old_S)) and then (Is_Controlling_Formal (First_Formal (Old_S)) or else Is_Class_Wide_Type (Etype (First_Formal (Old_S)))) then -- Retrieve the target object, to be added as a first actual -- in the call. Call_Name := New_Occurrence_Of (Old_S, Loc); Pref := Prefix (Nam); else Call_Name := New_Copy (Name (N)); end if; -- Original name may have been overloaded, but is fully resolved now Set_Is_Overloaded (Call_Name, False); end if; -- For simple renamings, subsequent calls can be expanded directly as -- calls to the renamed entity. The body must be generated in any case -- for calls that may appear elsewhere. This is not done in the case -- where the subprogram is an instantiation because the actual proper -- body has not been built yet. This is also not done in GNATprove mode -- as we need to check other conditions for creating a body to inline -- in that case, which are controlled in Analyze_Subprogram_Body_Helper. if Ekind (Old_S) in E_Function | E_Procedure and then Nkind (Decl) = N_Subprogram_Declaration and then not Is_Generic_Instance (Old_S) and then not GNATprove_Mode then Set_Body_To_Inline (Decl, Old_S); end if; -- Check whether the return type is a limited view. If the subprogram -- is already frozen the generated body may have a non-limited view -- of the type, that must be used, because it is the one in the spec -- of the renaming declaration. if Ekind (Old_S) = E_Function and then Is_Entity_Name (Result_Definition (Spec)) then declare Ret_Type : constant Entity_Id := Etype (Result_Definition (Spec)); begin if Has_Non_Limited_View (Ret_Type) then Set_Result_Definition (Spec, New_Occurrence_Of (Non_Limited_View (Ret_Type), Loc)); end if; end; end if; -- The body generated for this renaming is an internal artifact, and -- does not constitute a freeze point for the called entity. Set_Must_Not_Freeze (Call_Name); Formal := First_Formal (Defining_Entity (Decl)); if Present (Pref) then declare Pref_Type : constant Entity_Id := Etype (Pref); Form_Type : constant Entity_Id := Etype (First_Formal (Old_S)); begin -- The controlling formal may be an access parameter, or the -- actual may be an access value, so adjust accordingly. if Is_Access_Type (Pref_Type) and then not Is_Access_Type (Form_Type) then Actuals := New_List (Make_Explicit_Dereference (Loc, Relocate_Node (Pref))); elsif Is_Access_Type (Form_Type) and then not Is_Access_Type (Pref) then Actuals := New_List ( Make_Attribute_Reference (Loc, Attribute_Name => Name_Access, Prefix => Relocate_Node (Pref))); else Actuals := New_List (Pref); end if; end; elsif Present (Formal) then Actuals := New_List; else Actuals := No_List; end if; if Present (Formal) then while Present (Formal) loop Append (New_Occurrence_Of (Formal, Loc), Actuals); Next_Formal (Formal); end loop; end if; -- If the renamed entity is an entry, inherit its profile. For other -- renamings as bodies, both profiles must be subtype conformant, so it -- is not necessary to replace the profile given in the declaration. -- However, default values that are aggregates are rewritten when -- partially analyzed, so we recover the original aggregate to insure -- that subsequent conformity checking works. Similarly, if the default -- expression was constant-folded, recover the original expression. Formal := First_Formal (Defining_Entity (Decl)); if Present (Formal) then O_Formal := First_Formal (Old_S); Param_Spec := First (Parameter_Specifications (Spec)); while Present (Formal) loop if Is_Entry (Old_S) then if Nkind (Parameter_Type (Param_Spec)) /= N_Access_Definition then Set_Etype (Formal, Etype (O_Formal)); Set_Entity (Parameter_Type (Param_Spec), Etype (O_Formal)); end if; elsif Nkind (Default_Value (O_Formal)) = N_Aggregate or else Nkind (Original_Node (Default_Value (O_Formal))) /= Nkind (Default_Value (O_Formal)) then Set_Expression (Param_Spec, New_Copy_Tree (Original_Node (Default_Value (O_Formal)))); end if; Next_Formal (Formal); Next_Formal (O_Formal); Next (Param_Spec); end loop; end if; -- If the renamed entity is a function, the generated body contains a -- return statement. Otherwise, build a procedure call. If the entity is -- an entry, subsequent analysis of the call will transform it into the -- proper entry or protected operation call. If the renamed entity is -- a character literal, return it directly. if Ekind (Old_S) = E_Function or else Ekind (Old_S) = E_Operator or else (Ekind (Old_S) = E_Subprogram_Type and then Etype (Old_S) /= Standard_Void_Type) then Call_Node := Make_Simple_Return_Statement (Loc, Expression => Make_Function_Call (Loc, Name => Call_Name, Parameter_Associations => Actuals)); elsif Ekind (Old_S) = E_Enumeration_Literal then Call_Node := Make_Simple_Return_Statement (Loc, Expression => New_Occurrence_Of (Old_S, Loc)); elsif Nkind (Nam) = N_Character_Literal then Call_Node := Make_Simple_Return_Statement (Loc, Expression => Call_Name); else Call_Node := Make_Procedure_Call_Statement (Loc, Name => Call_Name, Parameter_Associations => Actuals); end if; -- Create entities for subprogram body and formals Set_Defining_Unit_Name (Spec, Make_Defining_Identifier (Loc, Chars => Chars (New_S))); Param_Spec := First (Parameter_Specifications (Spec)); while Present (Param_Spec) loop Set_Defining_Identifier (Param_Spec, Make_Defining_Identifier (Loc, Chars => Chars (Defining_Identifier (Param_Spec)))); Next (Param_Spec); end loop; Body_Node := Make_Subprogram_Body (Loc, Specification => Spec, Declarations => New_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (Call_Node))); if Nkind (Decl) /= N_Subprogram_Declaration then Rewrite (N, Make_Subprogram_Declaration (Loc, Specification => Specification (N))); end if; -- Link the body to the entity whose declaration it completes. If -- the body is analyzed when the renamed entity is frozen, it may -- be necessary to restore the proper scope (see package Exp_Ch13). if Nkind (N) = N_Subprogram_Renaming_Declaration and then Present (Corresponding_Spec (N)) then Set_Corresponding_Spec (Body_Node, Corresponding_Spec (N)); else Set_Corresponding_Spec (Body_Node, New_S); end if; return Body_Node; end Build_Renamed_Body; -------------------------- -- Check_Address_Clause -- -------------------------- procedure Check_Address_Clause (E : Entity_Id) is Addr : constant Node_Id := Address_Clause (E); Typ : constant Entity_Id := Etype (E); Decl : Node_Id; Expr : Node_Id; Init : Node_Id; Lhs : Node_Id; Tag_Assign : Node_Id; begin if Present (Addr) then -- For a deferred constant, the initialization value is on full view if Ekind (E) = E_Constant and then Present (Full_View (E)) then Decl := Declaration_Node (Full_View (E)); else Decl := Declaration_Node (E); end if; Expr := Expression (Addr); if Needs_Constant_Address (Decl, Typ) then Check_Constant_Address_Clause (Expr, E); -- Has_Delayed_Freeze was set on E when the address clause was -- analyzed, and must remain set because we want the address -- clause to be elaborated only after any entity it references -- has been elaborated. end if; -- If Rep_Clauses are to be ignored, remove address clause from -- list attached to entity, because it may be illegal for gigi, -- for example by breaking order of elaboration. if Ignore_Rep_Clauses then declare Rep : Node_Id; begin Rep := First_Rep_Item (E); if Rep = Addr then Set_First_Rep_Item (E, Next_Rep_Item (Addr)); else while Present (Rep) and then Next_Rep_Item (Rep) /= Addr loop Next_Rep_Item (Rep); end loop; end if; if Present (Rep) then Set_Next_Rep_Item (Rep, Next_Rep_Item (Addr)); end if; end; -- And now remove the address clause Kill_Rep_Clause (Addr); elsif not Error_Posted (Expr) and then not Needs_Finalization (Typ) then Warn_Overlay (Expr, Typ, Name (Addr)); end if; Init := Expression (Decl); -- If a variable, or a non-imported constant, overlays a constant -- object and has an initialization value, then the initialization -- may end up writing into read-only memory. Detect the cases of -- statically identical values and remove the initialization. In -- the other cases, give a warning. We will give other warnings -- later for the variable if it is assigned. if (Ekind (E) = E_Variable or else (Ekind (E) = E_Constant and then not Is_Imported (E))) and then Overlays_Constant (E) and then Present (Init) then declare O_Ent : Entity_Id; Off : Boolean; begin Find_Overlaid_Entity (Addr, O_Ent, Off); if Ekind (O_Ent) = E_Constant and then Etype (O_Ent) = Typ and then Present (Constant_Value (O_Ent)) and then Compile_Time_Compare (Init, Constant_Value (O_Ent), Assume_Valid => True) = EQ then Set_No_Initialization (Decl); return; elsif Comes_From_Source (Init) and then Address_Clause_Overlay_Warnings then Error_Msg_Sloc := Sloc (Addr); Error_Msg_NE ("??constant& may be modified via address clause#", Decl, O_Ent); end if; end; end if; -- Remove side effects from initial expression, except in the case of -- limited build-in-place calls and aggregates, which have their own -- expansion elsewhere. This exception is necessary to avoid copying -- limited objects. if Present (Init) and then not Is_Limited_View (Typ) then -- Capture initialization value at point of declaration, and make -- explicit assignment legal, because object may be a constant. Remove_Side_Effects (Init); Lhs := New_Occurrence_Of (E, Sloc (Decl)); Set_Assignment_OK (Lhs); -- Move initialization to freeze actions, once the object has -- been frozen and the address clause alignment check has been -- performed. Append_Freeze_Action (E, Make_Assignment_Statement (Sloc (Decl), Name => Lhs, Expression => Expression (Decl))); Set_No_Initialization (Decl); -- If the object is tagged, check whether the tag must be -- reassigned explicitly. Tag_Assign := Make_Tag_Assignment (Decl); if Present (Tag_Assign) then Append_Freeze_Action (E, Tag_Assign); end if; end if; end if; end Check_Address_Clause; ----------------------------- -- Check_Compile_Time_Size -- ----------------------------- procedure Check_Compile_Time_Size (T : Entity_Id) is procedure Set_Small_Size (T : Entity_Id; S : Uint); -- Sets the compile time known size in the RM_Size field of T, checking -- for a size clause that was given which attempts to give a small size. function Size_Known (T : Entity_Id) return Boolean; -- Recursive function that does all the work function Static_Discriminated_Components (T : Entity_Id) return Boolean; -- If T is a constrained subtype, its size is not known if any of its -- discriminant constraints is not static and it is not a null record. -- The test is conservative and doesn't check that the components are -- in fact constrained by non-static discriminant values. Could be made -- more precise ??? -------------------- -- Set_Small_Size -- -------------------- procedure Set_Small_Size (T : Entity_Id; S : Uint) is begin if S > System_Max_Integer_Size then return; -- Check for bad size clause given elsif Has_Size_Clause (T) then if RM_Size (T) < S then Error_Msg_Uint_1 := S; Error_Msg_NE (Size_Too_Small_Message, Size_Clause (T), T); end if; -- Set size if not set already elsif Unknown_RM_Size (T) then Set_RM_Size (T, S); end if; end Set_Small_Size; ---------------- -- Size_Known -- ---------------- function Size_Known (T : Entity_Id) return Boolean is Index : Entity_Id; Comp : Entity_Id; Ctyp : Entity_Id; Low : Node_Id; High : Node_Id; begin if Size_Known_At_Compile_Time (T) then return True; -- Always True for elementary types, even generic formal elementary -- types. We used to return False in the latter case, but the size -- is known at compile time, even in the template, we just do not -- know the exact size but that's not the point of this routine. elsif Is_Elementary_Type (T) or else Is_Task_Type (T) then return True; -- Array types elsif Is_Array_Type (T) then -- String literals always have known size, and we can set it if Ekind (T) = E_String_Literal_Subtype then Set_Small_Size (T, Component_Size (T) * String_Literal_Length (T)); return True; -- Unconstrained types never have known at compile time size elsif not Is_Constrained (T) then return False; -- Don't do any recursion on type with error posted, since we may -- have a malformed type that leads us into a loop. elsif Error_Posted (T) then return False; -- Otherwise if component size unknown, then array size unknown elsif not Size_Known (Component_Type (T)) then return False; end if; -- Check for all indexes static, and also compute possible size -- (in case it is not greater than System_Max_Integer_Size and -- thus may be packable). declare Size : Uint := Component_Size (T); Dim : Uint; begin Index := First_Index (T); while Present (Index) loop if Nkind (Index) = N_Range then Get_Index_Bounds (Index, Low, High); elsif Error_Posted (Scalar_Range (Etype (Index))) then return False; else Low := Type_Low_Bound (Etype (Index)); High := Type_High_Bound (Etype (Index)); end if; if not Compile_Time_Known_Value (Low) or else not Compile_Time_Known_Value (High) or else Etype (Index) = Any_Type then return False; else Dim := Expr_Value (High) - Expr_Value (Low) + 1; if Dim >= 0 then Size := Size * Dim; else Size := Uint_0; end if; end if; Next_Index (Index); end loop; Set_Small_Size (T, Size); return True; end; -- For non-generic private types, go to underlying type if present elsif Is_Private_Type (T) and then not Is_Generic_Type (T) and then Present (Underlying_Type (T)) then -- Don't do any recursion on type with error posted, since we may -- have a malformed type that leads us into a loop. if Error_Posted (T) then return False; else return Size_Known (Underlying_Type (T)); end if; -- Record types elsif Is_Record_Type (T) then -- A class-wide type is never considered to have a known size if Is_Class_Wide_Type (T) then return False; -- A subtype of a variant record must not have non-static -- discriminated components. elsif T /= Base_Type (T) and then not Static_Discriminated_Components (T) then return False; -- Don't do any recursion on type with error posted, since we may -- have a malformed type that leads us into a loop. elsif Error_Posted (T) then return False; end if; -- Now look at the components of the record declare -- The following two variables are used to keep track of the -- size of packed records if we can tell the size of the packed -- record in the front end. Packed_Size_Known is True if so far -- we can figure out the size. It is initialized to True for a -- packed record, unless the record has either discriminants or -- independent components, or is a strict-alignment type, since -- it cannot be fully packed in this case. -- The reason we eliminate the discriminated case is that -- we don't know the way the back end lays out discriminated -- packed records. If Packed_Size_Known is True, then -- Packed_Size is the size in bits so far. Packed_Size_Known : Boolean := Is_Packed (T) and then not Has_Discriminants (T) and then not Has_Independent_Components (T) and then not Strict_Alignment (T); Packed_Size : Uint := Uint_0; -- Size in bits so far begin -- Test for variant part present if Has_Discriminants (T) and then Present (Parent (T)) and then Nkind (Parent (T)) = N_Full_Type_Declaration and then Nkind (Type_Definition (Parent (T))) = N_Record_Definition and then not Null_Present (Type_Definition (Parent (T))) and then Present (Variant_Part (Component_List (Type_Definition (Parent (T))))) then -- If variant part is present, and type is unconstrained, -- then we must have defaulted discriminants, or a size -- clause must be present for the type, or else the size -- is definitely not known at compile time. if not Is_Constrained (T) and then No (Discriminant_Default_Value (First_Discriminant (T))) and then Unknown_RM_Size (T) then return False; end if; end if; -- Loop through components Comp := First_Component_Or_Discriminant (T); while Present (Comp) loop Ctyp := Etype (Comp); -- We do not know the packed size if there is a component -- clause present (we possibly could, but this would only -- help in the case of a record with partial rep clauses. -- That's because in the case of full rep clauses, the -- size gets figured out anyway by a different circuit). if Present (Component_Clause (Comp)) then Packed_Size_Known := False; end if; -- We do not know the packed size for an independent -- component or if it is of a strict-alignment type, -- since packing does not touch these (RM 13.2(7)). if Is_Independent (Comp) or else Is_Independent (Ctyp) or else Strict_Alignment (Ctyp) then Packed_Size_Known := False; end if; -- We need to identify a component that is an array where -- the index type is an enumeration type with non-standard -- representation, and some bound of the type depends on a -- discriminant. -- This is because gigi computes the size by doing a -- substitution of the appropriate discriminant value in -- the size expression for the base type, and gigi is not -- clever enough to evaluate the resulting expression (which -- involves a call to rep_to_pos) at compile time. -- It would be nice if gigi would either recognize that -- this expression can be computed at compile time, or -- alternatively figured out the size from the subtype -- directly, where all the information is at hand ??? if Is_Array_Type (Etype (Comp)) and then Present (Packed_Array_Impl_Type (Etype (Comp))) then declare Ocomp : constant Entity_Id := Original_Record_Component (Comp); OCtyp : constant Entity_Id := Etype (Ocomp); Ind : Node_Id; Indtyp : Entity_Id; Lo, Hi : Node_Id; begin Ind := First_Index (OCtyp); while Present (Ind) loop Indtyp := Etype (Ind); if Is_Enumeration_Type (Indtyp) and then Has_Non_Standard_Rep (Indtyp) then Lo := Type_Low_Bound (Indtyp); Hi := Type_High_Bound (Indtyp); if Is_Entity_Name (Lo) and then Ekind (Entity (Lo)) = E_Discriminant then return False; elsif Is_Entity_Name (Hi) and then Ekind (Entity (Hi)) = E_Discriminant then return False; end if; end if; Next_Index (Ind); end loop; end; end if; -- Clearly size of record is not known if the size of one of -- the components is not known. if not Size_Known (Ctyp) then return False; end if; -- Accumulate packed size if possible if Packed_Size_Known then -- We can deal with elementary types, small packed arrays -- if the representation is a modular type and also small -- record types as checked by Set_Small_Size. if Is_Elementary_Type (Ctyp) or else (Is_Array_Type (Ctyp) and then Present (Packed_Array_Impl_Type (Ctyp)) and then Is_Modular_Integer_Type (Packed_Array_Impl_Type (Ctyp))) or else Is_Record_Type (Ctyp) then -- If RM_Size is known and static, then we can keep -- accumulating the packed size. if Known_Static_RM_Size (Ctyp) then Packed_Size := Packed_Size + RM_Size (Ctyp); -- If we have a field whose RM_Size is not known then -- we can't figure out the packed size here. else Packed_Size_Known := False; end if; -- For other types we can't figure out the packed size else Packed_Size_Known := False; end if; end if; Next_Component_Or_Discriminant (Comp); end loop; if Packed_Size_Known then Set_Small_Size (T, Packed_Size); end if; return True; end; -- All other cases, size not known at compile time else return False; end if; end Size_Known; ------------------------------------- -- Static_Discriminated_Components -- ------------------------------------- function Static_Discriminated_Components (T : Entity_Id) return Boolean is Constraint : Elmt_Id; begin if Has_Discriminants (T) and then Present (Discriminant_Constraint (T)) and then Present (First_Component (T)) then Constraint := First_Elmt (Discriminant_Constraint (T)); while Present (Constraint) loop if not Compile_Time_Known_Value (Node (Constraint)) then return False; end if; Next_Elmt (Constraint); end loop; end if; return True; end Static_Discriminated_Components; -- Start of processing for Check_Compile_Time_Size begin Set_Size_Known_At_Compile_Time (T, Size_Known (T)); end Check_Compile_Time_Size; ----------------------------------- -- Check_Component_Storage_Order -- ----------------------------------- procedure Check_Component_Storage_Order (Encl_Type : Entity_Id; Comp : Entity_Id; ADC : Node_Id; Comp_ADC_Present : out Boolean) is Comp_Base : Entity_Id; Comp_ADC : Node_Id; Encl_Base : Entity_Id; Err_Node : Node_Id; Component_Aliased : Boolean; Comp_Byte_Aligned : Boolean := False; -- Set for the record case, True if Comp is aligned on byte boundaries -- (in which case it is allowed to have different storage order). Comp_SSO_Differs : Boolean; -- Set True when the component is a nested composite, and it does not -- have the same scalar storage order as Encl_Type. begin -- Record case if Present (Comp) then Err_Node := Comp; Comp_Base := Etype (Comp); if Is_Tag (Comp) then Comp_Byte_Aligned := True; Component_Aliased := False; else -- If a component clause is present, check if the component starts -- and ends on byte boundaries. Otherwise conservatively assume it -- does so only in the case where the record is not packed. if Present (Component_Clause (Comp)) then Comp_Byte_Aligned := (Normalized_First_Bit (Comp) mod System_Storage_Unit = 0) and then (Esize (Comp) mod System_Storage_Unit = 0); else Comp_Byte_Aligned := not Is_Packed (Encl_Type); end if; Component_Aliased := Is_Aliased (Comp); end if; -- Array case else Err_Node := Encl_Type; Comp_Base := Component_Type (Encl_Type); Component_Aliased := Has_Aliased_Components (Encl_Type); end if; -- Note: the Reverse_Storage_Order flag is set on the base type, but -- the attribute definition clause is attached to the first subtype. -- Also, if the base type is incomplete or private, go to full view -- if known Encl_Base := Base_Type (Encl_Type); if Present (Underlying_Type (Encl_Base)) then Encl_Base := Underlying_Type (Encl_Base); end if; Comp_Base := Base_Type (Comp_Base); if Present (Underlying_Type (Comp_Base)) then Comp_Base := Underlying_Type (Comp_Base); end if; Comp_ADC := Get_Attribute_Definition_Clause (First_Subtype (Comp_Base), Attribute_Scalar_Storage_Order); Comp_ADC_Present := Present (Comp_ADC); -- Case of record or array component: check storage order compatibility. -- But, if the record has Complex_Representation, then it is treated as -- a scalar in the back end so the storage order is irrelevant. if (Is_Record_Type (Comp_Base) and then not Has_Complex_Representation (Comp_Base)) or else Is_Array_Type (Comp_Base) then Comp_SSO_Differs := Reverse_Storage_Order (Encl_Base) /= Reverse_Storage_Order (Comp_Base); -- Parent and extension must have same storage order if Present (Comp) and then Chars (Comp) = Name_uParent then if Comp_SSO_Differs then Error_Msg_N ("record extension must have same scalar storage order as " & "parent", Err_Node); end if; -- If component and composite SSO differs, check that component -- falls on byte boundaries and isn't bit packed. elsif Comp_SSO_Differs then -- Component SSO differs from enclosing composite: -- Reject if composite is a bit-packed array, as it is rewritten -- into an array of scalars. if Is_Bit_Packed_Array (Encl_Base) then Error_Msg_N ("type of packed array must have same scalar storage order " & "as component", Err_Node); -- Reject if not byte aligned elsif Is_Record_Type (Encl_Base) and then not Comp_Byte_Aligned then Error_Msg_N ("type of non-byte-aligned component must have same scalar " & "storage order as enclosing composite", Err_Node); -- Warn if specified only for the outer composite elsif Present (ADC) and then No (Comp_ADC) then Error_Msg_NE ("scalar storage order specified for & does not apply to " & "component?", Err_Node, Encl_Base); end if; end if; -- Enclosing type has explicit SSO: non-composite component must not -- be aliased. elsif Present (ADC) and then Component_Aliased then Error_Msg_N ("aliased component not permitted for type with explicit " & "Scalar_Storage_Order", Err_Node); end if; end Check_Component_Storage_Order; ----------------------------- -- Check_Debug_Info_Needed -- ----------------------------- procedure Check_Debug_Info_Needed (T : Entity_Id) is begin if Debug_Info_Off (T) then return; elsif Comes_From_Source (T) or else Debug_Generated_Code or else Debug_Flag_VV or else Needs_Debug_Info (T) then Set_Debug_Info_Needed (T); end if; end Check_Debug_Info_Needed; ------------------------------- -- Check_Expression_Function -- ------------------------------- procedure Check_Expression_Function (N : Node_Id; Nam : Entity_Id) is function Find_Constant (Nod : Node_Id) return Traverse_Result; -- Function to search for deferred constant ------------------- -- Find_Constant -- ------------------- function Find_Constant (Nod : Node_Id) return Traverse_Result is begin -- When a constant is initialized with the result of a dispatching -- call, the constant declaration is rewritten as a renaming of the -- displaced function result. This scenario is not a premature use of -- a constant even though the Has_Completion flag is not set. if Is_Entity_Name (Nod) and then Present (Entity (Nod)) and then Ekind (Entity (Nod)) = E_Constant and then Scope (Entity (Nod)) = Current_Scope and then Nkind (Declaration_Node (Entity (Nod))) = N_Object_Declaration and then not Is_Imported (Entity (Nod)) and then not Has_Completion (Entity (Nod)) and then not Is_Frozen (Entity (Nod)) then Error_Msg_NE ("premature use of& in call or instance", N, Entity (Nod)); elsif Nkind (Nod) = N_Attribute_Reference then Analyze (Prefix (Nod)); if Is_Entity_Name (Prefix (Nod)) and then Is_Type (Entity (Prefix (Nod))) then Freeze_Before (N, Entity (Prefix (Nod))); end if; end if; return OK; end Find_Constant; procedure Check_Deferred is new Traverse_Proc (Find_Constant); -- Local variables Decl : Node_Id; -- Start of processing for Check_Expression_Function begin Decl := Original_Node (Unit_Declaration_Node (Nam)); -- The subprogram body created for the expression function is not -- itself a freeze point. if Scope (Nam) = Current_Scope and then Nkind (Decl) = N_Expression_Function and then Nkind (N) /= N_Subprogram_Body then Check_Deferred (Expression (Decl)); end if; end Check_Expression_Function; -------------------------------- -- Check_Inherited_Conditions -- -------------------------------- procedure Check_Inherited_Conditions (R : Entity_Id) is Prim_Ops : constant Elist_Id := Primitive_Operations (R); Decls : List_Id; Needs_Wrapper : Boolean; Op_Node : Elmt_Id; Par_Prim : Entity_Id; Prim : Entity_Id; procedure Build_Inherited_Condition_Pragmas (Subp : Entity_Id); -- Build corresponding pragmas for an operation whose ancestor has -- class-wide pre/postconditions. If the operation is inherited, the -- pragmas force the creation of a wrapper for the inherited operation. -- If the ancestor is being overridden, the pragmas are constructed only -- to verify their legality, in case they contain calls to other -- primitives that may haven been overridden. --------------------------------------- -- Build_Inherited_Condition_Pragmas -- --------------------------------------- procedure Build_Inherited_Condition_Pragmas (Subp : Entity_Id) is A_Post : Node_Id; A_Pre : Node_Id; New_Prag : Node_Id; begin A_Pre := Get_Class_Wide_Pragma (Par_Prim, Pragma_Precondition); if Present (A_Pre) then New_Prag := New_Copy_Tree (A_Pre); Build_Class_Wide_Expression (Prag => New_Prag, Subp => Prim, Par_Subp => Par_Prim, Adjust_Sloc => False, Needs_Wrapper => Needs_Wrapper); if Needs_Wrapper and then not Comes_From_Source (Subp) and then Expander_Active then Append (New_Prag, Decls); end if; end if; A_Post := Get_Class_Wide_Pragma (Par_Prim, Pragma_Postcondition); if Present (A_Post) then New_Prag := New_Copy_Tree (A_Post); Build_Class_Wide_Expression (Prag => New_Prag, Subp => Prim, Par_Subp => Par_Prim, Adjust_Sloc => False, Needs_Wrapper => Needs_Wrapper); if Needs_Wrapper and then not Comes_From_Source (Subp) and then Expander_Active then Append (New_Prag, Decls); end if; end if; end Build_Inherited_Condition_Pragmas; -- Start of processing for Check_Inherited_Conditions begin Op_Node := First_Elmt (Prim_Ops); while Present (Op_Node) loop Prim := Node (Op_Node); -- Map the overridden primitive to the overriding one. This takes -- care of all overridings and is done only once. if Present (Overridden_Operation (Prim)) and then Comes_From_Source (Prim) then Par_Prim := Overridden_Operation (Prim); Update_Primitives_Mapping (Par_Prim, Prim); end if; Next_Elmt (Op_Node); end loop; -- Perform validity checks on the inherited conditions of overriding -- operations, for conformance with LSP, and apply SPARK-specific -- restrictions on inherited conditions. Op_Node := First_Elmt (Prim_Ops); while Present (Op_Node) loop Prim := Node (Op_Node); if Present (Overridden_Operation (Prim)) and then Comes_From_Source (Prim) then Par_Prim := Overridden_Operation (Prim); -- Analyze the contract items of the overridden operation, before -- they are rewritten as pragmas. Analyze_Entry_Or_Subprogram_Contract (Par_Prim); -- In GNATprove mode this is where we can collect the inherited -- conditions, because we do not create the Check pragmas that -- normally convey the modified class-wide conditions on -- overriding operations. if GNATprove_Mode then Collect_Inherited_Class_Wide_Conditions (Prim); -- Otherwise build the corresponding pragmas to check for legality -- of the inherited condition. else Build_Inherited_Condition_Pragmas (Prim); end if; end if; Next_Elmt (Op_Node); end loop; -- Now examine the inherited operations to check whether they require -- a wrapper to handle inherited conditions that call other primitives, -- so that LSP can be verified/enforced. Op_Node := First_Elmt (Prim_Ops); while Present (Op_Node) loop Decls := Empty_List; Prim := Node (Op_Node); Needs_Wrapper := False; if not Comes_From_Source (Prim) and then Present (Alias (Prim)) then Par_Prim := Alias (Prim); -- Analyze the contract items of the parent operation, and -- determine whether a wrapper is needed. This is determined -- when the condition is rewritten in sem_prag, using the -- mapping between overridden and overriding operations built -- in the loop above. Analyze_Entry_Or_Subprogram_Contract (Par_Prim); Build_Inherited_Condition_Pragmas (Prim); end if; if Needs_Wrapper and then not Is_Abstract_Subprogram (Par_Prim) and then Expander_Active then -- We need to build a new primitive that overrides the inherited -- one, and whose inherited expression has been updated above. -- These expressions are the arguments of pragmas that are part -- of the declarations of the wrapper. The wrapper holds a single -- statement that is a call to the class-wide clone, where the -- controlling actuals are conversions to the corresponding type -- in the parent primitive: -- procedure New_Prim (F1 : T1; ...); -- procedure New_Prim (F1 : T1; ...) is -- pragma Check (Precondition, Expr); -- begin -- Par_Prim_Clone (Par_Type (F1), ...); -- end; -- If the primitive is a function the statement is a return -- statement with a call. declare Loc : constant Source_Ptr := Sloc (R); Par_R : constant Node_Id := Parent (R); New_Body : Node_Id; New_Decl : Node_Id; New_Spec : Node_Id; begin New_Spec := Build_Overriding_Spec (Par_Prim, R); New_Decl := Make_Subprogram_Declaration (Loc, Specification => New_Spec); -- Insert the declaration and the body of the wrapper after -- type declaration that generates inherited operation. For -- a null procedure, the declaration implies a null body. if Nkind (New_Spec) = N_Procedure_Specification and then Null_Present (New_Spec) then Insert_After_And_Analyze (Par_R, New_Decl); else -- Build body as wrapper to a call to the already built -- class-wide clone. New_Body := Build_Class_Wide_Clone_Call (Loc, Decls, Par_Prim, New_Spec); Insert_List_After_And_Analyze (Par_R, New_List (New_Decl, New_Body)); end if; end; end if; Next_Elmt (Op_Node); end loop; end Check_Inherited_Conditions; ---------------------------- -- Check_Strict_Alignment -- ---------------------------- procedure Check_Strict_Alignment (E : Entity_Id) is Comp : Entity_Id; begin if Is_By_Reference_Type (E) then Set_Strict_Alignment (E); elsif Is_Array_Type (E) then Set_Strict_Alignment (E, Strict_Alignment (Component_Type (E))); -- ??? AI12-001: Any component of a packed type that contains an -- aliased part must be aligned according to the alignment of its -- subtype (RM 13.2(7)). This means that the following test: -- if Has_Aliased_Components (E) then -- Set_Strict_Alignment (E); -- end if; -- should be implemented here. Unfortunately it would break Florist, -- which has the bad habit of overaligning all the types it declares -- on 32-bit platforms. Other legacy codebases could also be affected -- because this check has historically been missing in GNAT. elsif Is_Record_Type (E) then Comp := First_Component (E); while Present (Comp) loop if not Is_Type (Comp) and then (Is_Aliased (Comp) or else Strict_Alignment (Etype (Comp))) then Set_Strict_Alignment (E); return; end if; Next_Component (Comp); end loop; end if; end Check_Strict_Alignment; ------------------------- -- Check_Unsigned_Type -- ------------------------- procedure Check_Unsigned_Type (E : Entity_Id) is Ancestor : Entity_Id; Lo_Bound : Node_Id; Btyp : Entity_Id; begin if not Is_Discrete_Or_Fixed_Point_Type (E) then return; end if; -- Do not attempt to analyze case where range was in error if No (Scalar_Range (E)) or else Error_Posted (Scalar_Range (E)) then return; end if; -- The situation that is nontrivial is something like: -- subtype x1 is integer range -10 .. +10; -- subtype x2 is x1 range 0 .. V1; -- subtype x3 is x2 range V2 .. V3; -- subtype x4 is x3 range V4 .. V5; -- where Vn are variables. Here the base type is signed, but we still -- know that x4 is unsigned because of the lower bound of x2. -- The only way to deal with this is to look up the ancestor chain Ancestor := E; loop if Ancestor = Any_Type or else Etype (Ancestor) = Any_Type then return; end if; Lo_Bound := Type_Low_Bound (Ancestor); if Compile_Time_Known_Value (Lo_Bound) then if Expr_Rep_Value (Lo_Bound) >= 0 then Set_Is_Unsigned_Type (E, True); end if; return; else Ancestor := Ancestor_Subtype (Ancestor); -- If no ancestor had a static lower bound, go to base type if No (Ancestor) then -- Note: the reason we still check for a compile time known -- value for the base type is that at least in the case of -- generic formals, we can have bounds that fail this test, -- and there may be other cases in error situations. Btyp := Base_Type (E); if Btyp = Any_Type or else Etype (Btyp) = Any_Type then return; end if; Lo_Bound := Type_Low_Bound (Base_Type (E)); if Compile_Time_Known_Value (Lo_Bound) and then Expr_Rep_Value (Lo_Bound) >= 0 then Set_Is_Unsigned_Type (E, True); end if; return; end if; end if; end loop; end Check_Unsigned_Type; ----------------------------- -- Is_Atomic_VFA_Aggregate -- ----------------------------- function Is_Atomic_VFA_Aggregate (N : Node_Id) return Boolean is Loc : constant Source_Ptr := Sloc (N); New_N : Node_Id; Par : Node_Id; Temp : Entity_Id; Typ : Entity_Id; begin Par := Parent (N); -- Array may be qualified, so find outer context if Nkind (Par) = N_Qualified_Expression then Par := Parent (Par); end if; if not Comes_From_Source (Par) then return False; end if; case Nkind (Par) is when N_Assignment_Statement => Typ := Etype (Name (Par)); if not Is_Atomic_Or_VFA (Typ) and then not (Is_Entity_Name (Name (Par)) and then Is_Atomic_Or_VFA (Entity (Name (Par)))) then return False; end if; when N_Object_Declaration => Typ := Etype (Defining_Identifier (Par)); if not Is_Atomic_Or_VFA (Typ) and then not Is_Atomic_Or_VFA (Defining_Identifier (Par)) then return False; end if; when others => return False; end case; Temp := Make_Temporary (Loc, 'T', N); New_N := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Constant_Present => True, Object_Definition => New_Occurrence_Of (Typ, Loc), Expression => Relocate_Node (N)); Insert_Before (Par, New_N); Analyze (New_N); Set_Expression (Par, New_Occurrence_Of (Temp, Loc)); return True; end Is_Atomic_VFA_Aggregate; ----------------------------------------------- -- Explode_Initialization_Compound_Statement -- ----------------------------------------------- procedure Explode_Initialization_Compound_Statement (E : Entity_Id) is Init_Stmts : constant Node_Id := Initialization_Statements (E); begin if Present (Init_Stmts) and then Nkind (Init_Stmts) = N_Compound_Statement then Insert_List_Before (Init_Stmts, Actions (Init_Stmts)); -- Note that we rewrite Init_Stmts into a NULL statement, rather than -- just removing it, because Freeze_All may rely on this particular -- Node_Id still being present in the enclosing list to know where to -- stop freezing. Rewrite (Init_Stmts, Make_Null_Statement (Sloc (Init_Stmts))); Set_Initialization_Statements (E, Empty); end if; end Explode_Initialization_Compound_Statement; ---------------- -- Freeze_All -- ---------------- -- Note: the easy coding for this procedure would be to just build a -- single list of freeze nodes and then insert them and analyze them -- all at once. This won't work, because the analysis of earlier freeze -- nodes may recursively freeze types which would otherwise appear later -- on in the freeze list. So we must analyze and expand the freeze nodes -- as they are generated. procedure Freeze_All (From : Entity_Id; After : in out Node_Id) is procedure Freeze_All_Ent (From : Entity_Id; After : in out Node_Id); -- This is the internal recursive routine that does freezing of entities -- (but NOT the analysis of default expressions, which should not be -- recursive, we don't want to analyze those till we are sure that ALL -- the types are frozen). -------------------- -- Freeze_All_Ent -- -------------------- procedure Freeze_All_Ent (From : Entity_Id; After : in out Node_Id) is E : Entity_Id; Flist : List_Id; Lastn : Node_Id; procedure Process_Flist; -- If freeze nodes are present, insert and analyze, and reset cursor -- for next insertion. ------------------- -- Process_Flist -- ------------------- procedure Process_Flist is begin if Is_Non_Empty_List (Flist) then Lastn := Next (After); Insert_List_After_And_Analyze (After, Flist); if Present (Lastn) then After := Prev (Lastn); else After := Last (List_Containing (After)); end if; end if; end Process_Flist; -- Start of processing for Freeze_All_Ent begin E := From; while Present (E) loop -- If the entity is an inner package which is not a package -- renaming, then its entities must be frozen at this point. Note -- that such entities do NOT get frozen at the end of the nested -- package itself (only library packages freeze). -- Same is true for task declarations, where anonymous records -- created for entry parameters must be frozen. if Ekind (E) = E_Package and then No (Renamed_Object (E)) and then not Is_Child_Unit (E) and then not Is_Frozen (E) then Push_Scope (E); Install_Visible_Declarations (E); Install_Private_Declarations (E); Freeze_All (First_Entity (E), After); End_Package_Scope (E); if Is_Generic_Instance (E) and then Has_Delayed_Freeze (E) then Set_Has_Delayed_Freeze (E, False); Expand_N_Package_Declaration (Unit_Declaration_Node (E)); end if; elsif Ekind (E) in Task_Kind and then Nkind (Parent (E)) in N_Single_Task_Declaration | N_Task_Type_Declaration then Push_Scope (E); Freeze_All (First_Entity (E), After); End_Scope; -- For a derived tagged type, we must ensure that all the -- primitive operations of the parent have been frozen, so that -- their addresses will be in the parent's dispatch table at the -- point it is inherited. elsif Ekind (E) = E_Record_Type and then Is_Tagged_Type (E) and then Is_Tagged_Type (Etype (E)) and then Is_Derived_Type (E) then declare Prim_List : constant Elist_Id := Primitive_Operations (Etype (E)); Prim : Elmt_Id; Subp : Entity_Id; begin Prim := First_Elmt (Prim_List); while Present (Prim) loop Subp := Node (Prim); if Comes_From_Source (Subp) and then not Is_Frozen (Subp) then Flist := Freeze_Entity (Subp, After); Process_Flist; end if; Next_Elmt (Prim); end loop; end; end if; if not Is_Frozen (E) then Flist := Freeze_Entity (E, After); Process_Flist; -- If already frozen, and there are delayed aspects, this is where -- we do the visibility check for these aspects (see Sem_Ch13 spec -- for a description of how we handle aspect visibility). elsif Has_Delayed_Aspects (E) then declare Ritem : Node_Id; begin Ritem := First_Rep_Item (E); while Present (Ritem) loop if Nkind (Ritem) = N_Aspect_Specification and then Entity (Ritem) = E and then Is_Delayed_Aspect (Ritem) then Check_Aspect_At_End_Of_Declarations (Ritem); end if; Next_Rep_Item (Ritem); end loop; end; end if; -- If an incomplete type is still not frozen, this may be a -- premature freezing because of a body declaration that follows. -- Indicate where the freezing took place. Freezing will happen -- if the body comes from source, but not if it is internally -- generated, for example as the body of a type invariant. -- If the freezing is caused by the end of the current declarative -- part, it is a Taft Amendment type, and there is no error. if not Is_Frozen (E) and then Ekind (E) = E_Incomplete_Type then declare Bod : constant Node_Id := Next (After); begin -- The presence of a body freezes all entities previously -- declared in the current list of declarations, but this -- does not apply if the body does not come from source. -- A type invariant is transformed into a subprogram body -- which is placed at the end of the private part of the -- current package, but this body does not freeze incomplete -- types that may be declared in this private part. if Comes_From_Source (Bod) and then Nkind (Bod) in N_Entry_Body | N_Package_Body | N_Protected_Body | N_Subprogram_Body | N_Task_Body | N_Body_Stub and then List_Containing (After) = List_Containing (Parent (E)) then Error_Msg_Sloc := Sloc (Next (After)); Error_Msg_NE ("type& is frozen# before its full declaration", Parent (E), E); end if; end; end if; Next_Entity (E); end loop; end Freeze_All_Ent; -- Local variables Decl : Node_Id; E : Entity_Id; Item : Entity_Id; -- Start of processing for Freeze_All begin Freeze_All_Ent (From, After); -- Now that all types are frozen, we can deal with default expressions -- that require us to build a default expression functions. This is the -- point at which such functions are constructed (after all types that -- might be used in such expressions have been frozen). -- For subprograms that are renaming_as_body, we create the wrapper -- bodies as needed. -- We also add finalization chains to access types whose designated -- types are controlled. This is normally done when freezing the type, -- but this misses recursive type definitions where the later members -- of the recursion introduce controlled components. -- Loop through entities E := From; while Present (E) loop if Is_Subprogram (E) then if not Default_Expressions_Processed (E) then Process_Default_Expressions (E, After); end if; if not Has_Completion (E) then Decl := Unit_Declaration_Node (E); if Nkind (Decl) = N_Subprogram_Renaming_Declaration then if Error_Posted (Decl) then Set_Has_Completion (E); else Build_And_Analyze_Renamed_Body (Decl, E, After); end if; elsif Nkind (Decl) = N_Subprogram_Declaration and then Present (Corresponding_Body (Decl)) and then Nkind (Unit_Declaration_Node (Corresponding_Body (Decl))) = N_Subprogram_Renaming_Declaration then Build_And_Analyze_Renamed_Body (Decl, Corresponding_Body (Decl), After); end if; end if; -- Freeze the default expressions of entries, entry families, and -- protected subprograms. elsif Is_Concurrent_Type (E) then Item := First_Entity (E); while Present (Item) loop if (Is_Entry (Item) or else Is_Subprogram (Item)) and then not Default_Expressions_Processed (Item) then Process_Default_Expressions (Item, After); end if; Next_Entity (Item); end loop; end if; -- Historical note: We used to create a finalization master for an -- access type whose designated type is not controlled, but contains -- private controlled compoments. This form of postprocessing is no -- longer needed because the finalization master is now created when -- the access type is frozen (see Exp_Ch3.Freeze_Type). Next_Entity (E); end loop; end Freeze_All; ----------------------- -- Freeze_And_Append -- ----------------------- procedure Freeze_And_Append (Ent : Entity_Id; N : Node_Id; Result : in out List_Id) is L : constant List_Id := Freeze_Entity (Ent, N); begin if Is_Non_Empty_List (L) then if Result = No_List then Result := L; else Append_List (L, Result); end if; end if; end Freeze_And_Append; ------------------- -- Freeze_Before -- ------------------- procedure Freeze_Before (N : Node_Id; T : Entity_Id; Do_Freeze_Profile : Boolean := True) is -- Freeze T, then insert the generated Freeze nodes before the node N. -- Flag Freeze_Profile is used when T is an overloadable entity, and -- indicates whether its profile should be frozen at the same time. Freeze_Nodes : constant List_Id := Freeze_Entity (T, N, Do_Freeze_Profile); Pack : constant Entity_Id := Scope (T); begin if Ekind (T) = E_Function then Check_Expression_Function (N, T); end if; if Is_Non_Empty_List (Freeze_Nodes) then -- If the entity is a type declared in an inner package, it may be -- frozen by an outer declaration before the package itself is -- frozen. Install the package scope to analyze the freeze nodes, -- which may include generated subprograms such as predicate -- functions, etc. if Is_Type (T) and then From_Nested_Package (T) then Push_Scope (Pack); Install_Visible_Declarations (Pack); Install_Private_Declarations (Pack); Insert_Actions (N, Freeze_Nodes); End_Package_Scope (Pack); else Insert_Actions (N, Freeze_Nodes); end if; end if; end Freeze_Before; ------------------- -- Freeze_Entity -- ------------------- -- WARNING: This routine manages Ghost regions. Return statements must be -- replaced by gotos which jump to the end of the routine and restore the -- Ghost mode. function Freeze_Entity (E : Entity_Id; N : Node_Id; Do_Freeze_Profile : Boolean := True) return List_Id is Loc : constant Source_Ptr := Sloc (N); Saved_GM : constant Ghost_Mode_Type := Ghost_Mode; Saved_IGR : constant Node_Id := Ignored_Ghost_Region; -- Save the Ghost-related attributes to restore on exit Atype : Entity_Id; Comp : Entity_Id; F_Node : Node_Id; Formal : Entity_Id; Indx : Node_Id; Result : List_Id := No_List; -- List of freezing actions, left at No_List if none Test_E : Entity_Id := E; -- This could use a comment ??? procedure Add_To_Result (Fnod : Node_Id); -- Add freeze action Fnod to list Result function After_Last_Declaration return Boolean; -- If Loc is a freeze_entity that appears after the last declaration -- in the scope, inhibit error messages on late completion. procedure Check_Current_Instance (Comp_Decl : Node_Id); -- Check that an Access or Unchecked_Access attribute with a prefix -- which is the current instance type can only be applied when the type -- is limited. procedure Check_Suspicious_Convention (Rec_Type : Entity_Id); -- Give a warning for pragma Convention with language C or C++ applied -- to a discriminated record type. This is suppressed for the unchecked -- union case, since the whole point in this case is interface C. We -- also do not generate this within instantiations, since we will have -- generated a message on the template. procedure Check_Suspicious_Modulus (Utype : Entity_Id); -- Give warning for modulus of 8, 16, 32, or 64 given as an explicit -- integer literal without an explicit corresponding size clause. The -- caller has checked that Utype is a modular integer type. procedure Freeze_Array_Type (Arr : Entity_Id); -- Freeze array type, including freezing index and component types procedure Freeze_Object_Declaration (E : Entity_Id); -- Perform checks and generate freeze node if needed for a constant or -- variable declared by an object declaration. function Freeze_Generic_Entities (Pack : Entity_Id) return List_Id; -- Create Freeze_Generic_Entity nodes for types declared in a generic -- package. Recurse on inner generic packages. function Freeze_Profile (E : Entity_Id) return Boolean; -- Freeze formals and return type of subprogram. If some type in the -- profile is incomplete and we are in an instance, freezing of the -- entity will take place elsewhere, and the function returns False. procedure Freeze_Record_Type (Rec : Entity_Id); -- Freeze record type, including freezing component types, and freezing -- primitive operations if this is a tagged type. function Has_Boolean_Aspect_Import (E : Entity_Id) return Boolean; -- Determine whether an arbitrary entity is subject to Boolean aspect -- Import and its value is specified as True. procedure Inherit_Freeze_Node (Fnod : Node_Id; Typ : Entity_Id); -- Set type Typ's freeze node to refer to Fnode. This routine ensures -- that any attributes attached to Typ's original node are preserved. procedure Wrap_Imported_Subprogram (E : Entity_Id); -- If E is an entity for an imported subprogram with pre/post-conditions -- then this procedure will create a wrapper to ensure that proper run- -- time checking of the pre/postconditions. See body for details. ------------------- -- Add_To_Result -- ------------------- procedure Add_To_Result (Fnod : Node_Id) is begin Append_New_To (Result, Fnod); end Add_To_Result; ---------------------------- -- After_Last_Declaration -- ---------------------------- function After_Last_Declaration return Boolean is Spec : constant Node_Id := Parent (Current_Scope); begin if Nkind (Spec) = N_Package_Specification then if Present (Private_Declarations (Spec)) then return Loc >= Sloc (Last (Private_Declarations (Spec))); elsif Present (Visible_Declarations (Spec)) then return Loc >= Sloc (Last (Visible_Declarations (Spec))); else return False; end if; else return False; end if; end After_Last_Declaration; ---------------------------- -- Check_Current_Instance -- ---------------------------- procedure Check_Current_Instance (Comp_Decl : Node_Id) is function Is_Aliased_View_Of_Type (Typ : Entity_Id) return Boolean; -- Determine whether Typ is compatible with the rules for aliased -- views of types as defined in RM 3.10 in the various dialects. function Process (N : Node_Id) return Traverse_Result; -- Process routine to apply check to given node ----------------------------- -- Is_Aliased_View_Of_Type -- ----------------------------- function Is_Aliased_View_Of_Type (Typ : Entity_Id) return Boolean is Typ_Decl : constant Node_Id := Parent (Typ); begin -- Common case if Nkind (Typ_Decl) = N_Full_Type_Declaration and then Limited_Present (Type_Definition (Typ_Decl)) then return True; -- The following paragraphs describe what a legal aliased view of -- a type is in the various dialects of Ada. -- Ada 95 -- The current instance of a limited type, and a formal parameter -- or generic formal object of a tagged type. -- Ada 95 limited type -- * Type with reserved word "limited" -- * A protected or task type -- * A composite type with limited component elsif Ada_Version <= Ada_95 then return Is_Limited_Type (Typ); -- Ada 2005 -- The current instance of a limited tagged type, a protected -- type, a task type, or a type that has the reserved word -- "limited" in its full definition ... a formal parameter or -- generic formal object of a tagged type. -- Ada 2005 limited type -- * Type with reserved word "limited", "synchronized", "task" -- or "protected" -- * A composite type with limited component -- * A derived type whose parent is a non-interface limited type elsif Ada_Version = Ada_2005 then return (Is_Limited_Type (Typ) and then Is_Tagged_Type (Typ)) or else (Is_Derived_Type (Typ) and then not Is_Interface (Etype (Typ)) and then Is_Limited_Type (Etype (Typ))); -- Ada 2012 and beyond -- The current instance of an immutably limited type ... a formal -- parameter or generic formal object of a tagged type. -- Ada 2012 limited type -- * Type with reserved word "limited", "synchronized", "task" -- or "protected" -- * A composite type with limited component -- * A derived type whose parent is a non-interface limited type -- * An incomplete view -- Ada 2012 immutably limited type -- * Explicitly limited record type -- * Record extension with "limited" present -- * Non-formal limited private type that is either tagged -- or has at least one access discriminant with a default -- expression -- * Task type, protected type or synchronized interface -- * Type derived from immutably limited type else return Is_Immutably_Limited_Type (Typ) or else Is_Incomplete_Type (Typ); end if; end Is_Aliased_View_Of_Type; ------------- -- Process -- ------------- function Process (N : Node_Id) return Traverse_Result is begin case Nkind (N) is when N_Attribute_Reference => if Attribute_Name (N) in Name_Access | Name_Unchecked_Access and then Is_Entity_Name (Prefix (N)) and then Is_Type (Entity (Prefix (N))) and then Entity (Prefix (N)) = E then if Ada_Version < Ada_2012 then Error_Msg_N ("current instance must be a limited type", Prefix (N)); else Error_Msg_N ("current instance must be an immutably limited " & "type (RM-2012, 7.5 (8.1/3))", Prefix (N)); end if; return Abandon; else return OK; end if; when others => return OK; end case; end Process; procedure Traverse is new Traverse_Proc (Process); -- Local variables Rec_Type : constant Entity_Id := Scope (Defining_Identifier (Comp_Decl)); -- Start of processing for Check_Current_Instance begin if not Is_Aliased_View_Of_Type (Rec_Type) then Traverse (Comp_Decl); end if; end Check_Current_Instance; --------------------------------- -- Check_Suspicious_Convention -- --------------------------------- procedure Check_Suspicious_Convention (Rec_Type : Entity_Id) is begin if Has_Discriminants (Rec_Type) and then Is_Base_Type (Rec_Type) and then not Is_Unchecked_Union (Rec_Type) and then (Convention (Rec_Type) = Convention_C or else Convention (Rec_Type) = Convention_CPP) and then Comes_From_Source (Rec_Type) and then not In_Instance and then not Has_Warnings_Off (Rec_Type) then declare Cprag : constant Node_Id := Get_Rep_Pragma (Rec_Type, Name_Convention); A2 : Node_Id; begin if Present (Cprag) then A2 := Next (First (Pragma_Argument_Associations (Cprag))); if Convention (Rec_Type) = Convention_C then Error_Msg_N ("?x?discriminated record has no direct equivalent in " & "C", A2); else Error_Msg_N ("?x?discriminated record has no direct equivalent in " & "C++", A2); end if; Error_Msg_NE ("\?x?use of convention for type& is dubious", A2, Rec_Type); end if; end; end if; end Check_Suspicious_Convention; ------------------------------ -- Check_Suspicious_Modulus -- ------------------------------ procedure Check_Suspicious_Modulus (Utype : Entity_Id) is Decl : constant Node_Id := Declaration_Node (Underlying_Type (Utype)); begin if not Warn_On_Suspicious_Modulus_Value then return; end if; if Nkind (Decl) = N_Full_Type_Declaration then declare Tdef : constant Node_Id := Type_Definition (Decl); begin if Nkind (Tdef) = N_Modular_Type_Definition then declare Modulus : constant Node_Id := Original_Node (Expression (Tdef)); begin if Nkind (Modulus) = N_Integer_Literal then declare Modv : constant Uint := Intval (Modulus); Sizv : constant Uint := RM_Size (Utype); begin -- First case, modulus and size are the same. This -- happens if you have something like mod 32, with -- an explicit size of 32, this is for sure a case -- where the warning is given, since it is seems -- very unlikely that someone would want e.g. a -- five bit type stored in 32 bits. It is much -- more likely they wanted a 32-bit type. if Modv = Sizv then null; -- Second case, the modulus is 32 or 64 and no -- size clause is present. This is a less clear -- case for giving the warning, but in the case -- of 32/64 (5-bit or 6-bit types) these seem rare -- enough that it is a likely error (and in any -- case using 2**5 or 2**6 in these cases seems -- clearer. We don't include 8 or 16 here, simply -- because in practice 3-bit and 4-bit types are -- more common and too many false positives if -- we warn in these cases. elsif not Has_Size_Clause (Utype) and then (Modv = Uint_32 or else Modv = Uint_64) then null; -- No warning needed else return; end if; -- If we fall through, give warning Error_Msg_Uint_1 := Modv; Error_Msg_N ("?M?2 '*'*^' may have been intended here", Modulus); end; end if; end; end if; end; end if; end Check_Suspicious_Modulus; ----------------------- -- Freeze_Array_Type -- ----------------------- procedure Freeze_Array_Type (Arr : Entity_Id) is FS : constant Entity_Id := First_Subtype (Arr); Ctyp : constant Entity_Id := Component_Type (Arr); Clause : Entity_Id; Non_Standard_Enum : Boolean := False; -- Set true if any of the index types is an enumeration type with a -- non-standard representation. begin Freeze_And_Append (Ctyp, N, Result); Indx := First_Index (Arr); while Present (Indx) loop Freeze_And_Append (Etype (Indx), N, Result); if Is_Enumeration_Type (Etype (Indx)) and then Has_Non_Standard_Rep (Etype (Indx)) then Non_Standard_Enum := True; end if; Next_Index (Indx); end loop; -- Processing that is done only for base types if Ekind (Arr) = E_Array_Type then -- Deal with default setting of reverse storage order Set_SSO_From_Default (Arr); -- Propagate flags for component type if Is_Controlled (Ctyp) or else Has_Controlled_Component (Ctyp) then Set_Has_Controlled_Component (Arr); end if; if Has_Unchecked_Union (Ctyp) then Set_Has_Unchecked_Union (Arr); end if; -- The array type requires its own invariant procedure in order to -- verify the component invariant over all elements. In GNATprove -- mode, the component invariants are checked by other means. They -- should not be added to the array type invariant procedure, so -- that the procedure can be used to check the array type -- invariants if any. if Has_Invariants (Ctyp) and then not GNATprove_Mode then Set_Has_Own_Invariants (Arr); -- The array type is an implementation base type. Propagate the -- same property to the first subtype. if Is_Itype (Arr) then Set_Has_Own_Invariants (First_Subtype (Arr)); end if; end if; -- Warn for pragma Pack overriding foreign convention if Has_Foreign_Convention (Ctyp) and then Has_Pragma_Pack (Arr) then declare CN : constant Name_Id := Get_Convention_Name (Convention (Ctyp)); PP : constant Node_Id := Get_Pragma (First_Subtype (Arr), Pragma_Pack); begin if Present (PP) then Error_Msg_Name_1 := CN; Error_Msg_Sloc := Sloc (Arr); Error_Msg_N ("pragma Pack affects convention % components #??", PP); Error_Msg_Name_1 := CN; Error_Msg_N ("\array components may not have % compatible " & "representation??", PP); end if; end; end if; -- Check for Aliased or Atomic_Components/Atomic/VFA with -- unsuitable packing or explicit component size clause given. if (Has_Aliased_Components (Arr) or else Has_Atomic_Components (Arr) or else Is_Atomic_Or_VFA (Ctyp)) and then (Has_Component_Size_Clause (Arr) or else Is_Packed (Arr)) then Alias_Atomic_Check : declare procedure Complain_CS (T : String); -- Outputs error messages for incorrect CS clause or pragma -- Pack for aliased or atomic/VFA components (T is "aliased" -- or "atomic/vfa"); ----------------- -- Complain_CS -- ----------------- procedure Complain_CS (T : String) is begin if Has_Component_Size_Clause (Arr) then Clause := Get_Attribute_Definition_Clause (FS, Attribute_Component_Size); Error_Msg_N ("incorrect component size for " & T & " components", Clause); Error_Msg_Uint_1 := Esize (Ctyp); Error_Msg_N ("\only allowed value is^", Clause); else Error_Msg_N ("?cannot pack " & T & " components (RM 13.2(7))", Get_Rep_Pragma (FS, Name_Pack)); Set_Is_Packed (Arr, False); end if; end Complain_CS; -- Start of processing for Alias_Atomic_Check begin -- If object size of component type isn't known, we cannot -- be sure so we defer to the back end. if not Known_Static_Esize (Ctyp) then null; -- Case where component size has no effect. First check for -- object size of component type multiple of the storage -- unit size. elsif Esize (Ctyp) mod System_Storage_Unit = 0 -- OK in both packing case and component size case if RM -- size is known and static and same as the object size. and then ((Known_Static_RM_Size (Ctyp) and then Esize (Ctyp) = RM_Size (Ctyp)) -- Or if we have an explicit component size clause and -- the component size and object size are equal. or else (Has_Component_Size_Clause (Arr) and then Component_Size (Arr) = Esize (Ctyp))) then null; elsif Has_Aliased_Components (Arr) then Complain_CS ("aliased"); elsif Has_Atomic_Components (Arr) or else Is_Atomic (Ctyp) then Complain_CS ("atomic"); elsif Is_Volatile_Full_Access (Ctyp) then Complain_CS ("volatile full access"); end if; end Alias_Atomic_Check; end if; -- Check for Independent_Components/Independent with unsuitable -- packing or explicit component size clause given. if (Has_Independent_Components (Arr) or else Is_Independent (Ctyp)) and then (Has_Component_Size_Clause (Arr) or else Is_Packed (Arr)) then begin -- If object size of component type isn't known, we cannot -- be sure so we defer to the back end. if not Known_Static_Esize (Ctyp) then null; -- Case where component size has no effect. First check for -- object size of component type multiple of the storage -- unit size. elsif Esize (Ctyp) mod System_Storage_Unit = 0 -- OK in both packing case and component size case if RM -- size is known and multiple of the storage unit size. and then ((Known_Static_RM_Size (Ctyp) and then RM_Size (Ctyp) mod System_Storage_Unit = 0) -- Or if we have an explicit component size clause and -- the component size is larger than the object size. or else (Has_Component_Size_Clause (Arr) and then Component_Size (Arr) >= Esize (Ctyp))) then null; else if Has_Component_Size_Clause (Arr) then Clause := Get_Attribute_Definition_Clause (FS, Attribute_Component_Size); Error_Msg_N ("incorrect component size for " & "independent components", Clause); Error_Msg_Uint_1 := Esize (Ctyp); Error_Msg_N ("\minimum allowed is^", Clause); else Error_Msg_N ("?cannot pack independent components (RM 13.2(7))", Get_Rep_Pragma (FS, Name_Pack)); Set_Is_Packed (Arr, False); end if; end if; end; end if; -- If packing was requested or if the component size was -- set explicitly, then see if bit packing is required. This -- processing is only done for base types, since all of the -- representation aspects involved are type-related. -- This is not just an optimization, if we start processing the -- subtypes, they interfere with the settings on the base type -- (this is because Is_Packed has a slightly different meaning -- before and after freezing). declare Csiz : Uint; Esiz : Uint; begin if Is_Packed (Arr) and then Known_Static_RM_Size (Ctyp) and then not Has_Component_Size_Clause (Arr) then Csiz := UI_Max (RM_Size (Ctyp), 1); elsif Known_Component_Size (Arr) then Csiz := Component_Size (Arr); elsif not Known_Static_Esize (Ctyp) then Csiz := Uint_0; else Esiz := Esize (Ctyp); -- We can set the component size if it is less than 16, -- rounding it up to the next storage unit size. if Esiz <= 8 then Csiz := Uint_8; elsif Esiz <= 16 then Csiz := Uint_16; else Csiz := Uint_0; end if; -- Set component size up to match alignment if it would -- otherwise be less than the alignment. This deals with -- cases of types whose alignment exceeds their size (the -- padded type cases). if Csiz /= 0 then declare A : constant Uint := Alignment_In_Bits (Ctyp); begin if Csiz < A then Csiz := A; end if; end; end if; end if; -- Case of component size that may result in bit packing if 1 <= Csiz and then Csiz <= System_Max_Integer_Size then declare Ent : constant Entity_Id := First_Subtype (Arr); Pack_Pragma : constant Node_Id := Get_Rep_Pragma (Ent, Name_Pack); Comp_Size_C : constant Node_Id := Get_Attribute_Definition_Clause (Ent, Attribute_Component_Size); begin -- Warn if we have pack and component size so that the -- pack is ignored. -- Note: here we must check for the presence of a -- component size before checking for a Pack pragma to -- deal with the case where the array type is a derived -- type whose parent is currently private. if Present (Comp_Size_C) and then Has_Pragma_Pack (Ent) and then Warn_On_Redundant_Constructs then Error_Msg_Sloc := Sloc (Comp_Size_C); Error_Msg_NE ("?r?pragma Pack for& ignored!", Pack_Pragma, Ent); Error_Msg_N ("\?r?explicit component size given#!", Pack_Pragma); Set_Is_Packed (Base_Type (Ent), False); Set_Is_Bit_Packed_Array (Base_Type (Ent), False); end if; -- Set component size if not already set by a component -- size clause. if not Present (Comp_Size_C) then Set_Component_Size (Arr, Csiz); end if; -- Check for base type of 8, 16, 32 bits, where an -- unsigned subtype has a length one less than the -- base type (e.g. Natural subtype of Integer). -- In such cases, if a component size was not set -- explicitly, then generate a warning. if Has_Pragma_Pack (Arr) and then not Present (Comp_Size_C) and then (Csiz = 7 or else Csiz = 15 or else Csiz = 31) and then Esize (Base_Type (Ctyp)) = Csiz + 1 then Error_Msg_Uint_1 := Csiz; if Present (Pack_Pragma) then Error_Msg_N ("??pragma Pack causes component size to be ^!", Pack_Pragma); Error_Msg_N ("\??use Component_Size to set desired value!", Pack_Pragma); end if; end if; -- Bit packing is never needed for 8, 16, 32, 64 if Addressable (Csiz) then -- If the Esize of the component is known and equal to -- the component size then even packing is not needed. if Known_Static_Esize (Ctyp) and then Esize (Ctyp) = Csiz then -- Here the array was requested to be packed, but -- the packing request had no effect whatsoever, -- so flag Is_Packed is reset. -- Note: semantically this means that we lose track -- of the fact that a derived type inherited pragma -- Pack that was non-effective, but that is fine. -- We regard a Pack pragma as a request to set a -- representation characteristic, and this request -- may be ignored. Set_Is_Packed (Base_Type (Arr), False); Set_Has_Non_Standard_Rep (Base_Type (Arr), False); else Set_Is_Packed (Base_Type (Arr), True); Set_Has_Non_Standard_Rep (Base_Type (Arr), True); end if; Set_Is_Bit_Packed_Array (Base_Type (Arr), False); -- Bit packing is not needed for multiples of the storage -- unit if the type is composite because the back end can -- byte pack composite types efficiently. That's not true -- for discrete types because every read would generate a -- lot of instructions, so we keep using the manipulation -- routines of the runtime for them. elsif Csiz mod System_Storage_Unit = 0 and then Is_Composite_Type (Ctyp) then Set_Is_Packed (Base_Type (Arr), True); Set_Has_Non_Standard_Rep (Base_Type (Arr), True); Set_Is_Bit_Packed_Array (Base_Type (Arr), False); -- In all other cases, bit packing is needed else Set_Is_Packed (Base_Type (Arr), True); Set_Has_Non_Standard_Rep (Base_Type (Arr), True); Set_Is_Bit_Packed_Array (Base_Type (Arr), True); end if; end; end if; end; -- Warn for case of atomic type Clause := Get_Rep_Pragma (FS, Name_Atomic); if Present (Clause) and then not Addressable (Component_Size (FS)) then Error_Msg_NE ("non-atomic components of type& may not be " & "accessible by separate tasks??", Clause, Arr); if Has_Component_Size_Clause (Arr) then Error_Msg_Sloc := Sloc (Get_Attribute_Definition_Clause (FS, Attribute_Component_Size)); Error_Msg_N ("\because of component size clause#??", Clause); elsif Has_Pragma_Pack (Arr) then Error_Msg_Sloc := Sloc (Get_Rep_Pragma (FS, Name_Pack)); Error_Msg_N ("\because of pragma Pack#??", Clause); end if; end if; -- Check for scalar storage order declare Dummy : Boolean; begin Check_Component_Storage_Order (Encl_Type => Arr, Comp => Empty, ADC => Get_Attribute_Definition_Clause (First_Subtype (Arr), Attribute_Scalar_Storage_Order), Comp_ADC_Present => Dummy); end; -- Processing that is done only for subtypes else -- Acquire alignment from base type if Unknown_Alignment (Arr) then Set_Alignment (Arr, Alignment (Base_Type (Arr))); Adjust_Esize_Alignment (Arr); end if; end if; -- Specific checks for bit-packed arrays if Is_Bit_Packed_Array (Arr) then -- Check number of elements for bit-packed arrays that come from -- source and have compile time known ranges. The bit-packed -- arrays circuitry does not support arrays with more than -- Integer'Last + 1 elements, and when this restriction is -- violated, causes incorrect data access. -- For the case where this is not compile time known, a run-time -- check should be generated??? if Comes_From_Source (Arr) and then Is_Constrained (Arr) then declare Elmts : Uint; Index : Node_Id; Ilen : Node_Id; Ityp : Entity_Id; begin Elmts := Uint_1; Index := First_Index (Arr); while Present (Index) loop Ityp := Etype (Index); -- Never generate an error if any index is of a generic -- type. We will check this in instances. if Is_Generic_Type (Ityp) then Elmts := Uint_0; exit; end if; Ilen := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Ityp, Loc), Attribute_Name => Name_Range_Length); Analyze_And_Resolve (Ilen); -- No attempt is made to check number of elements if not -- compile time known. if Nkind (Ilen) /= N_Integer_Literal then Elmts := Uint_0; exit; end if; Elmts := Elmts * Intval (Ilen); Next_Index (Index); end loop; if Elmts > Intval (High_Bound (Scalar_Range (Standard_Integer))) + 1 then Error_Msg_N ("bit packed array type may not have " & "more than Integer''Last+1 elements", Arr); end if; end; end if; -- Check size if Known_RM_Size (Arr) then declare SizC : constant Node_Id := Size_Clause (Arr); Discard : Boolean; begin -- It is not clear if it is possible to have no size clause -- at this stage, but it is not worth worrying about. Post -- error on the entity name in the size clause if present, -- else on the type entity itself. if Present (SizC) then Check_Size (Name (SizC), Arr, RM_Size (Arr), Discard); else Check_Size (Arr, Arr, RM_Size (Arr), Discard); end if; end; end if; end if; -- If any of the index types was an enumeration type with a non- -- standard rep clause, then we indicate that the array type is -- always packed (even if it is not bit-packed). if Non_Standard_Enum then Set_Has_Non_Standard_Rep (Base_Type (Arr)); Set_Is_Packed (Base_Type (Arr)); end if; Set_Component_Alignment_If_Not_Set (Arr); -- If the array is packed and bit-packed or packed to eliminate holes -- in the non-contiguous enumeration index types, we must create the -- packed array type to be used to actually implement the type. This -- is only needed for real array types (not for string literal types, -- since they are present only for the front end). if Is_Packed (Arr) and then (Is_Bit_Packed_Array (Arr) or else Non_Standard_Enum) and then Ekind (Arr) /= E_String_Literal_Subtype then Create_Packed_Array_Impl_Type (Arr); Freeze_And_Append (Packed_Array_Impl_Type (Arr), N, Result); -- Make sure that we have the necessary routines to implement the -- packing, and complain now if not. Note that we only test this -- for constrained array types. if Is_Constrained (Arr) and then Is_Bit_Packed_Array (Arr) and then Present (Packed_Array_Impl_Type (Arr)) and then Is_Array_Type (Packed_Array_Impl_Type (Arr)) then declare CS : constant Uint := Component_Size (Arr); RE : constant RE_Id := Get_Id (UI_To_Int (CS)); begin if RE /= RE_Null and then not RTE_Available (RE) then Error_Msg_CRT ("packing of " & UI_Image (CS) & "-bit components", First_Subtype (Etype (Arr))); -- Cancel the packing Set_Is_Packed (Base_Type (Arr), False); Set_Is_Bit_Packed_Array (Base_Type (Arr), False); Set_Packed_Array_Impl_Type (Arr, Empty); goto Skip_Packed; end if; end; end if; -- Size information of packed array type is copied to the array -- type, since this is really the representation. But do not -- override explicit existing size values. If the ancestor subtype -- is constrained the Packed_Array_Impl_Type will be inherited -- from it, but the size may have been provided already, and -- must not be overridden either. if not Has_Size_Clause (Arr) and then (No (Ancestor_Subtype (Arr)) or else not Has_Size_Clause (Ancestor_Subtype (Arr))) then Set_Esize (Arr, Esize (Packed_Array_Impl_Type (Arr))); Set_RM_Size (Arr, RM_Size (Packed_Array_Impl_Type (Arr))); end if; if not Has_Alignment_Clause (Arr) then Set_Alignment (Arr, Alignment (Packed_Array_Impl_Type (Arr))); end if; end if; <<Skip_Packed>> -- A Ghost type cannot have a component of protected or task type -- (SPARK RM 6.9(19)). if Is_Ghost_Entity (Arr) and then Is_Concurrent_Type (Ctyp) then Error_Msg_N ("ghost array type & cannot have concurrent component type", Arr); end if; end Freeze_Array_Type; ------------------------------- -- Freeze_Object_Declaration -- ------------------------------- procedure Freeze_Object_Declaration (E : Entity_Id) is procedure Check_Large_Modular_Array (Typ : Entity_Id); -- Check that the size of array type Typ can be computed without -- overflow, and generates a Storage_Error otherwise. This is only -- relevant for array types whose index has System_Max_Integer_Size -- bits, where wrap-around arithmetic might yield a meaningless value -- for the length of the array, or its corresponding attribute. procedure Check_Pragma_Thread_Local_Storage (Var_Id : Entity_Id); -- Ensure that the initialization state of variable Var_Id subject -- to pragma Thread_Local_Storage agrees with the semantics of the -- pragma. function Has_Default_Initialization (Obj_Id : Entity_Id) return Boolean; -- Determine whether object Obj_Id default initialized ------------------------------- -- Check_Large_Modular_Array -- ------------------------------- procedure Check_Large_Modular_Array (Typ : Entity_Id) is Obj_Loc : constant Source_Ptr := Sloc (E); Idx_Typ : Entity_Id; begin -- Nothing to do when expansion is disabled because this routine -- generates a runtime check. if not Expander_Active then return; -- Nothing to do for String literal subtypes because their index -- cannot be a modular type. elsif Ekind (Typ) = E_String_Literal_Subtype then return; -- Nothing to do for an imported object because the object will -- be created on the exporting side. elsif Is_Imported (E) then return; -- Nothing to do for unconstrained array types. This case arises -- when the object declaration is illegal. elsif not Is_Constrained (Typ) then return; end if; Idx_Typ := Etype (First_Index (Typ)); -- To prevent arithmetic overflow with large values, we raise -- Storage_Error under the following guard: -- -- (Arr'Last / 2 - Arr'First / 2) > (2 ** 30) -- -- This takes care of the boundary case, but it is preferable to -- use a smaller limit, because even on 64-bit architectures an -- array of more than 2 ** 30 bytes is likely to raise -- Storage_Error. if Is_Modular_Integer_Type (Idx_Typ) and then RM_Size (Idx_Typ) = RM_Size (Standard_Long_Long_Integer) then Insert_Action (Declaration_Node (E), Make_Raise_Storage_Error (Obj_Loc, Condition => Make_Op_Ge (Obj_Loc, Left_Opnd => Make_Op_Subtract (Obj_Loc, Left_Opnd => Make_Op_Divide (Obj_Loc, Left_Opnd => Make_Attribute_Reference (Obj_Loc, Prefix => New_Occurrence_Of (Typ, Obj_Loc), Attribute_Name => Name_Last), Right_Opnd => Make_Integer_Literal (Obj_Loc, Uint_2)), Right_Opnd => Make_Op_Divide (Obj_Loc, Left_Opnd => Make_Attribute_Reference (Obj_Loc, Prefix => New_Occurrence_Of (Typ, Obj_Loc), Attribute_Name => Name_First), Right_Opnd => Make_Integer_Literal (Obj_Loc, Uint_2))), Right_Opnd => Make_Integer_Literal (Obj_Loc, (Uint_2 ** 30))), Reason => SE_Object_Too_Large)); end if; end Check_Large_Modular_Array; --------------------------------------- -- Check_Pragma_Thread_Local_Storage -- --------------------------------------- procedure Check_Pragma_Thread_Local_Storage (Var_Id : Entity_Id) is function Has_Incompatible_Initialization (Var_Decl : Node_Id) return Boolean; -- Determine whether variable Var_Id with declaration Var_Decl is -- initialized with a value that violates the semantics of pragma -- Thread_Local_Storage. ------------------------------------- -- Has_Incompatible_Initialization -- ------------------------------------- function Has_Incompatible_Initialization (Var_Decl : Node_Id) return Boolean is Init_Expr : constant Node_Id := Expression (Var_Decl); begin -- The variable is default-initialized. This directly violates -- the semantics of the pragma. if Has_Default_Initialization (Var_Id) then return True; -- The variable has explicit initialization. In this case only -- a handful of values satisfy the semantics of the pragma. elsif Has_Init_Expression (Var_Decl) and then Present (Init_Expr) then -- "null" is a legal form of initialization if Nkind (Init_Expr) = N_Null then return False; -- A static expression is a legal form of initialization elsif Is_Static_Expression (Init_Expr) then return False; -- A static aggregate is a legal form of initialization elsif Nkind (Init_Expr) = N_Aggregate and then Compile_Time_Known_Aggregate (Init_Expr) then return False; -- All other initialization expressions violate the semantic -- of the pragma. else return True; end if; -- The variable lacks any kind of initialization, which agrees -- with the semantics of the pragma. else return False; end if; end Has_Incompatible_Initialization; -- Local declarations Var_Decl : constant Node_Id := Declaration_Node (Var_Id); -- Start of processing for Check_Pragma_Thread_Local_Storage begin -- A variable whose initialization is suppressed lacks any kind of -- initialization. if Suppress_Initialization (Var_Id) then null; -- The variable has default initialization, or is explicitly -- initialized to a value other than null, static expression, -- or a static aggregate. elsif Has_Incompatible_Initialization (Var_Decl) then Error_Msg_NE ("Thread_Local_Storage variable& is improperly initialized", Var_Decl, Var_Id); Error_Msg_NE ("\only allowed initialization is explicit NULL, static " & "expression or static aggregate", Var_Decl, Var_Id); end if; end Check_Pragma_Thread_Local_Storage; -------------------------------- -- Has_Default_Initialization -- -------------------------------- function Has_Default_Initialization (Obj_Id : Entity_Id) return Boolean is Obj_Decl : constant Node_Id := Declaration_Node (Obj_Id); Obj_Typ : constant Entity_Id := Etype (Obj_Id); begin return Comes_From_Source (Obj_Id) and then not Is_Imported (Obj_Id) and then not Has_Init_Expression (Obj_Decl) and then ((Has_Non_Null_Base_Init_Proc (Obj_Typ) and then not No_Initialization (Obj_Decl) and then not Initialization_Suppressed (Obj_Typ)) or else (Needs_Simple_Initialization (Obj_Typ) and then not Is_Internal (Obj_Id))); end Has_Default_Initialization; -- Local variables Typ : constant Entity_Id := Etype (E); Def : Node_Id; -- Start of processing for Freeze_Object_Declaration begin -- Abstract type allowed only for C++ imported variables or constants -- Note: we inhibit this check for objects that do not come from -- source because there is at least one case (the expansion of -- x'Class'Input where x is abstract) where we legitimately -- generate an abstract object. if Is_Abstract_Type (Typ) and then Comes_From_Source (Parent (E)) and then not (Is_Imported (E) and then Is_CPP_Class (Typ)) then Def := Object_Definition (Parent (E)); Error_Msg_N ("type of object cannot be abstract", Def); if Is_CPP_Class (Etype (E)) then Error_Msg_NE ("\} may need a cpp_constructor", Def, Typ); elsif Present (Expression (Parent (E))) then Error_Msg_N -- CODEFIX ("\maybe a class-wide type was meant", Def); end if; end if; -- For object created by object declaration, perform required -- categorization (preelaborate and pure) checks. Defer these -- checks to freeze time since pragma Import inhibits default -- initialization and thus pragma Import affects these checks. Validate_Object_Declaration (Declaration_Node (E)); -- If there is an address clause, check that it is valid and if need -- be move initialization to the freeze node. Check_Address_Clause (E); -- Similar processing is needed for aspects that may affect object -- layout, like Address, if there is an initialization expression. -- We don't do this if there is a pragma Linker_Section, because it -- would prevent the back end from statically initializing the -- object; we don't want elaboration code in that case. if Has_Delayed_Aspects (E) and then Expander_Active and then Is_Array_Type (Typ) and then Present (Expression (Declaration_Node (E))) and then No (Linker_Section_Pragma (E)) then declare Decl : constant Node_Id := Declaration_Node (E); Lhs : constant Node_Id := New_Occurrence_Of (E, Loc); begin -- Capture initialization value at point of declaration, and -- make explicit assignment legal, because object may be a -- constant. Remove_Side_Effects (Expression (Decl)); Set_Assignment_OK (Lhs); -- Move initialization to freeze actions Append_Freeze_Action (E, Make_Assignment_Statement (Loc, Name => Lhs, Expression => Expression (Decl))); Set_No_Initialization (Decl); -- Set_Is_Frozen (E, False); end; end if; -- Reset Is_True_Constant for non-constant aliased object. We -- consider that the fact that a non-constant object is aliased may -- indicate that some funny business is going on, e.g. an aliased -- object is passed by reference to a procedure which captures the -- address of the object, which is later used to assign a new value, -- even though the compiler thinks that it is not modified. Such -- code is highly dubious, but we choose to make it "work" for -- non-constant aliased objects. -- Note that we used to do this for all aliased objects, whether or -- not constant, but this caused anomalies down the line because we -- ended up with static objects that were not Is_True_Constant. Not -- resetting Is_True_Constant for (aliased) constant objects ensures -- that this anomaly never occurs. -- However, we don't do that for internal entities. We figure that if -- we deliberately set Is_True_Constant for an internal entity, e.g. -- a dispatch table entry, then we mean it. if Ekind (E) /= E_Constant and then (Is_Aliased (E) or else Is_Aliased (Typ)) and then not Is_Internal_Name (Chars (E)) then Set_Is_True_Constant (E, False); end if; -- If the object needs any kind of default initialization, an error -- must be issued if No_Default_Initialization applies. The check -- doesn't apply to imported objects, which are not ever default -- initialized, and is why the check is deferred until freezing, at -- which point we know if Import applies. Deferred constants are also -- exempted from this test because their completion is explicit, or -- through an import pragma. if Ekind (E) = E_Constant and then Present (Full_View (E)) then null; elsif Has_Default_Initialization (E) then Check_Restriction (No_Default_Initialization, Declaration_Node (E)); end if; -- Ensure that a variable subject to pragma Thread_Local_Storage -- -- * Lacks default initialization, or -- -- * The initialization expression is either "null", a static -- constant, or a compile-time known aggregate. if Has_Pragma_Thread_Local_Storage (E) then Check_Pragma_Thread_Local_Storage (E); end if; -- For imported objects, set Is_Public unless there is also an -- address clause, which means that there is no external symbol -- needed for the Import (Is_Public may still be set for other -- unrelated reasons). Note that we delayed this processing -- till freeze time so that we can be sure not to set the flag -- if there is an address clause. If there is such a clause, -- then the only purpose of the Import pragma is to suppress -- implicit initialization. if Is_Imported (E) and then No (Address_Clause (E)) then Set_Is_Public (E); end if; -- For source objects that are not Imported and are library level, if -- no linker section pragma was given inherit the appropriate linker -- section from the corresponding type. if Comes_From_Source (E) and then not Is_Imported (E) and then Is_Library_Level_Entity (E) and then No (Linker_Section_Pragma (E)) then Set_Linker_Section_Pragma (E, Linker_Section_Pragma (Typ)); end if; -- For convention C objects of an enumeration type, warn if the size -- is not integer size and no explicit size given. Skip warning for -- Boolean and Character, and assume programmer expects 8-bit sizes -- for these cases. if (Convention (E) = Convention_C or else Convention (E) = Convention_CPP) and then Is_Enumeration_Type (Typ) and then not Is_Character_Type (Typ) and then not Is_Boolean_Type (Typ) and then Esize (Typ) < Standard_Integer_Size and then not Has_Size_Clause (E) then Error_Msg_Uint_1 := UI_From_Int (Standard_Integer_Size); Error_Msg_N ("??convention C enumeration object has size less than ^", E); Error_Msg_N ("\??use explicit size clause to set size", E); end if; -- Declaring too big an array in disabled ghost code is OK if Is_Array_Type (Typ) and then not Is_Ignored_Ghost_Entity (E) then Check_Large_Modular_Array (Typ); end if; end Freeze_Object_Declaration; ----------------------------- -- Freeze_Generic_Entities -- ----------------------------- function Freeze_Generic_Entities (Pack : Entity_Id) return List_Id is E : Entity_Id; F : Node_Id; Flist : List_Id; begin Flist := New_List; E := First_Entity (Pack); while Present (E) loop if Is_Type (E) and then not Is_Generic_Type (E) then F := Make_Freeze_Generic_Entity (Sloc (Pack)); Set_Entity (F, E); Append_To (Flist, F); elsif Ekind (E) = E_Generic_Package then Append_List_To (Flist, Freeze_Generic_Entities (E)); end if; Next_Entity (E); end loop; return Flist; end Freeze_Generic_Entities; -------------------- -- Freeze_Profile -- -------------------- function Freeze_Profile (E : Entity_Id) return Boolean is F_Type : Entity_Id; R_Type : Entity_Id; Warn_Node : Node_Id; begin -- Loop through formals Formal := First_Formal (E); while Present (Formal) loop F_Type := Etype (Formal); -- AI05-0151: incomplete types can appear in a profile. By the -- time the entity is frozen, the full view must be available, -- unless it is a limited view. if Is_Incomplete_Type (F_Type) and then Present (Full_View (F_Type)) and then not From_Limited_With (F_Type) then F_Type := Full_View (F_Type); Set_Etype (Formal, F_Type); end if; if not From_Limited_With (F_Type) then Freeze_And_Append (F_Type, N, Result); end if; if Is_Private_Type (F_Type) and then Is_Private_Type (Base_Type (F_Type)) and then No (Full_View (Base_Type (F_Type))) and then not Is_Generic_Type (F_Type) and then not Is_Derived_Type (F_Type) then -- If the type of a formal is incomplete, subprogram is being -- frozen prematurely. Within an instance (but not within a -- wrapper package) this is an artifact of our need to regard -- the end of an instantiation as a freeze point. Otherwise it -- is a definite error. if In_Instance then Set_Is_Frozen (E, False); Result := No_List; return False; elsif not After_Last_Declaration and then not Freezing_Library_Level_Tagged_Type then Error_Msg_Node_1 := F_Type; Error_Msg ("type & must be fully defined before this point", Loc); end if; end if; -- Check suspicious parameter for C function. These tests apply -- only to exported/imported subprograms. if Warn_On_Export_Import and then Comes_From_Source (E) and then Convention (E) in Convention_C_Family and then (Is_Imported (E) or else Is_Exported (E)) and then Convention (E) /= Convention (Formal) and then not Has_Warnings_Off (E) and then not Has_Warnings_Off (F_Type) and then not Has_Warnings_Off (Formal) then -- Qualify mention of formals with subprogram name Error_Msg_Qual_Level := 1; -- Check suspicious use of fat C pointer, but do not emit -- a warning on an access to subprogram when unnesting is -- active. if Is_Access_Type (F_Type) and then Esize (F_Type) > Ttypes.System_Address_Size and then (not Unnest_Subprogram_Mode or else not Is_Access_Subprogram_Type (F_Type)) then Error_Msg_N ("?x?type of & does not correspond to C pointer!", Formal); -- Check suspicious return of boolean elsif Root_Type (F_Type) = Standard_Boolean and then Convention (F_Type) = Convention_Ada and then not Has_Warnings_Off (F_Type) and then not Has_Size_Clause (F_Type) then Error_Msg_N ("& is an 8-bit Ada Boolean?x?", Formal); Error_Msg_N ("\use appropriate corresponding type in C " & "(e.g. char)?x?", Formal); -- Check suspicious tagged type elsif (Is_Tagged_Type (F_Type) or else (Is_Access_Type (F_Type) and then Is_Tagged_Type (Designated_Type (F_Type)))) and then Convention (E) = Convention_C then Error_Msg_N ("?x?& involves a tagged type which does not " & "correspond to any C type!", Formal); -- Check wrong convention subprogram pointer elsif Ekind (F_Type) = E_Access_Subprogram_Type and then not Has_Foreign_Convention (F_Type) then Error_Msg_N ("?x?subprogram pointer & should " & "have foreign convention!", Formal); Error_Msg_Sloc := Sloc (F_Type); Error_Msg_NE ("\?x?add Convention pragma to declaration of &#", Formal, F_Type); end if; -- Turn off name qualification after message output Error_Msg_Qual_Level := 0; end if; -- Check for unconstrained array in exported foreign convention -- case. if Has_Foreign_Convention (E) and then not Is_Imported (E) and then Is_Array_Type (F_Type) and then not Is_Constrained (F_Type) and then Warn_On_Export_Import then Error_Msg_Qual_Level := 1; -- If this is an inherited operation, place the warning on -- the derived type declaration, rather than on the original -- subprogram. if Nkind (Original_Node (Parent (E))) = N_Full_Type_Declaration then Warn_Node := Parent (E); if Formal = First_Formal (E) then Error_Msg_NE ("??in inherited operation&", Warn_Node, E); end if; else Warn_Node := Formal; end if; Error_Msg_NE ("?x?type of argument& is unconstrained array", Warn_Node, Formal); Error_Msg_NE ("?x?foreign caller must pass bounds explicitly", Warn_Node, Formal); Error_Msg_Qual_Level := 0; end if; if not From_Limited_With (F_Type) then if Is_Access_Type (F_Type) then F_Type := Designated_Type (F_Type); end if; -- If the formal is an anonymous_access_to_subprogram -- freeze the subprogram type as well, to prevent -- scope anomalies in gigi, because there is no other -- clear point at which it could be frozen. if Is_Itype (Etype (Formal)) and then Ekind (F_Type) = E_Subprogram_Type then Freeze_And_Append (F_Type, N, Result); end if; end if; Next_Formal (Formal); end loop; -- Case of function: similar checks on return type if Ekind (E) = E_Function then -- Freeze return type R_Type := Etype (E); -- AI05-0151: the return type may have been incomplete at the -- point of declaration. Replace it with the full view, unless the -- current type is a limited view. In that case the full view is -- in a different unit, and gigi finds the non-limited view after -- the other unit is elaborated. if Ekind (R_Type) = E_Incomplete_Type and then Present (Full_View (R_Type)) and then not From_Limited_With (R_Type) then R_Type := Full_View (R_Type); Set_Etype (E, R_Type); end if; Freeze_And_Append (R_Type, N, Result); -- Check suspicious return type for C function if Warn_On_Export_Import and then Comes_From_Source (E) and then Convention (E) in Convention_C_Family and then (Is_Imported (E) or else Is_Exported (E)) then -- Check suspicious return of fat C pointer if Is_Access_Type (R_Type) and then Esize (R_Type) > Ttypes.System_Address_Size and then not Has_Warnings_Off (E) and then not Has_Warnings_Off (R_Type) then Error_Msg_N ("?x?return type of& does not correspond to C pointer!", E); -- Check suspicious return of boolean elsif Root_Type (R_Type) = Standard_Boolean and then Convention (R_Type) = Convention_Ada and then not Has_Warnings_Off (E) and then not Has_Warnings_Off (R_Type) and then not Has_Size_Clause (R_Type) then declare N : constant Node_Id := Result_Definition (Declaration_Node (E)); begin Error_Msg_NE ("return type of & is an 8-bit Ada Boolean?x?", N, E); Error_Msg_NE ("\use appropriate corresponding type in C " & "(e.g. char)?x?", N, E); end; -- Check suspicious return tagged type elsif (Is_Tagged_Type (R_Type) or else (Is_Access_Type (R_Type) and then Is_Tagged_Type (Designated_Type (R_Type)))) and then Convention (E) = Convention_C and then not Has_Warnings_Off (E) and then not Has_Warnings_Off (R_Type) then Error_Msg_N ("?x?return type of & does not " & "correspond to C type!", E); -- Check return of wrong convention subprogram pointer elsif Ekind (R_Type) = E_Access_Subprogram_Type and then not Has_Foreign_Convention (R_Type) and then not Has_Warnings_Off (E) and then not Has_Warnings_Off (R_Type) then Error_Msg_N ("?x?& should return a foreign " & "convention subprogram pointer", E); Error_Msg_Sloc := Sloc (R_Type); Error_Msg_NE ("\?x?add Convention pragma to declaration of& #", E, R_Type); end if; end if; -- Give warning for suspicious return of a result of an -- unconstrained array type in a foreign convention function. if Has_Foreign_Convention (E) -- We are looking for a return of unconstrained array and then Is_Array_Type (R_Type) and then not Is_Constrained (R_Type) -- Exclude imported routines, the warning does not belong on -- the import, but rather on the routine definition. and then not Is_Imported (E) -- Check that general warning is enabled, and that it is not -- suppressed for this particular case. and then Warn_On_Export_Import and then not Has_Warnings_Off (E) and then not Has_Warnings_Off (R_Type) then Error_Msg_N ("?x?foreign convention function& should not return " & "unconstrained array!", E); end if; end if; -- Check suspicious use of Import in pure unit (cases where the RM -- allows calls to be omitted). if Is_Imported (E) -- It might be suspicious if the compilation unit has the Pure -- aspect/pragma. and then Has_Pragma_Pure (Cunit_Entity (Current_Sem_Unit)) -- The RM allows omission of calls only in the case of -- library-level subprograms (see RM-10.2.1(18)). and then Is_Library_Level_Entity (E) -- Ignore internally generated entity. This happens in some cases -- of subprograms in specs, where we generate an implied body. and then Comes_From_Source (Import_Pragma (E)) -- Assume run-time knows what it is doing and then not GNAT_Mode -- Assume explicit Pure_Function means import is pure and then not Has_Pragma_Pure_Function (E) -- Don't need warning in relaxed semantics mode and then not Relaxed_RM_Semantics -- Assume convention Intrinsic is OK, since this is specialized. -- This deals with the DEC unit current_exception.ads and then Convention (E) /= Convention_Intrinsic -- Assume that ASM interface knows what it is doing. This deals -- with e.g. unsigned.ads in the AAMP back end. and then Convention (E) /= Convention_Assembler then Error_Msg_N ("pragma Import in Pure unit??", Import_Pragma (E)); Error_Msg_NE ("\calls to & may be omitted (RM 10.2.1(18/3))??", Import_Pragma (E), E); end if; return True; end Freeze_Profile; ------------------------ -- Freeze_Record_Type -- ------------------------ procedure Freeze_Record_Type (Rec : Entity_Id) is ADC : Node_Id; Comp : Entity_Id; IR : Node_Id; Prev : Entity_Id; Junk : Boolean; pragma Warnings (Off, Junk); Aliased_Component : Boolean := False; -- Set True if we find at least one component which is aliased. This -- is used to prevent Implicit_Packing of the record, since packing -- cannot modify the size of alignment of an aliased component. All_Elem_Components : Boolean := True; -- True if all components are of a type whose underlying type is -- elementary. All_Sized_Components : Boolean := True; -- True if all components have a known RM_Size All_Storage_Unit_Components : Boolean := True; -- True if all components have an RM_Size that is a multiple of the -- storage unit. Elem_Component_Total_Esize : Uint := Uint_0; -- Accumulates total Esize values of all elementary components. Used -- for processing of Implicit_Packing. Placed_Component : Boolean := False; -- Set True if we find at least one component with a component -- clause (used to warn about useless Bit_Order pragmas, and also -- to detect cases where Implicit_Packing may have an effect). Sized_Component_Total_RM_Size : Uint := Uint_0; -- Accumulates total RM_Size values of all sized components. Used -- for processing of Implicit_Packing. Sized_Component_Total_Round_RM_Size : Uint := Uint_0; -- Accumulates total RM_Size values of all sized components, rounded -- individually to a multiple of the storage unit. SSO_ADC : Node_Id; -- Scalar_Storage_Order attribute definition clause for the record SSO_ADC_Component : Boolean := False; -- Set True if we find at least one component whose type has a -- Scalar_Storage_Order attribute definition clause. Unplaced_Component : Boolean := False; -- Set True if we find at least one component with no component -- clause (used to warn about useless Pack pragmas). function Check_Allocator (N : Node_Id) return Node_Id; -- If N is an allocator, possibly wrapped in one or more level of -- qualified expression(s), return the inner allocator node, else -- return Empty. procedure Check_Itype (Typ : Entity_Id); -- If the component subtype is an access to a constrained subtype of -- an already frozen type, make the subtype frozen as well. It might -- otherwise be frozen in the wrong scope, and a freeze node on -- subtype has no effect. Similarly, if the component subtype is a -- regular (not protected) access to subprogram, set the anonymous -- subprogram type to frozen as well, to prevent an out-of-scope -- freeze node at some eventual point of call. Protected operations -- are handled elsewhere. procedure Freeze_Choices_In_Variant_Part (VP : Node_Id); -- Make sure that all types mentioned in Discrete_Choices of the -- variants referenceed by the Variant_Part VP are frozen. This is -- a recursive routine to deal with nested variants. --------------------- -- Check_Allocator -- --------------------- function Check_Allocator (N : Node_Id) return Node_Id is Inner : Node_Id; begin Inner := N; loop if Nkind (Inner) = N_Allocator then return Inner; elsif Nkind (Inner) = N_Qualified_Expression then Inner := Expression (Inner); else return Empty; end if; end loop; end Check_Allocator; ----------------- -- Check_Itype -- ----------------- procedure Check_Itype (Typ : Entity_Id) is Desig : constant Entity_Id := Designated_Type (Typ); begin if not Is_Frozen (Desig) and then Is_Frozen (Base_Type (Desig)) then Set_Is_Frozen (Desig); -- In addition, add an Itype_Reference to ensure that the -- access subtype is elaborated early enough. This cannot be -- done if the subtype may depend on discriminants. if Ekind (Comp) = E_Component and then Is_Itype (Etype (Comp)) and then not Has_Discriminants (Rec) then IR := Make_Itype_Reference (Sloc (Comp)); Set_Itype (IR, Desig); Add_To_Result (IR); end if; elsif Ekind (Typ) = E_Anonymous_Access_Subprogram_Type and then Convention (Desig) /= Convention_Protected then Set_Is_Frozen (Desig); end if; end Check_Itype; ------------------------------------ -- Freeze_Choices_In_Variant_Part -- ------------------------------------ procedure Freeze_Choices_In_Variant_Part (VP : Node_Id) is pragma Assert (Nkind (VP) = N_Variant_Part); Variant : Node_Id; Choice : Node_Id; CL : Node_Id; begin -- Loop through variants Variant := First_Non_Pragma (Variants (VP)); while Present (Variant) loop -- Loop through choices, checking that all types are frozen Choice := First_Non_Pragma (Discrete_Choices (Variant)); while Present (Choice) loop if Nkind (Choice) in N_Has_Etype and then Present (Etype (Choice)) then Freeze_And_Append (Etype (Choice), N, Result); end if; Next_Non_Pragma (Choice); end loop; -- Check for nested variant part to process CL := Component_List (Variant); if not Null_Present (CL) then if Present (Variant_Part (CL)) then Freeze_Choices_In_Variant_Part (Variant_Part (CL)); end if; end if; Next_Non_Pragma (Variant); end loop; end Freeze_Choices_In_Variant_Part; -- Start of processing for Freeze_Record_Type begin -- Freeze components and embedded subtypes Comp := First_Entity (Rec); Prev := Empty; while Present (Comp) loop if Is_Aliased (Comp) then Aliased_Component := True; end if; -- Handle the component and discriminant case if Ekind (Comp) in E_Component | E_Discriminant then declare CC : constant Node_Id := Component_Clause (Comp); begin -- Freezing a record type freezes the type of each of its -- components. However, if the type of the component is -- part of this record, we do not want or need a separate -- Freeze_Node. Note that Is_Itype is wrong because that's -- also set in private type cases. We also can't check for -- the Scope being exactly Rec because of private types and -- record extensions. if Is_Itype (Etype (Comp)) and then Is_Record_Type (Underlying_Type (Scope (Etype (Comp)))) then Undelay_Type (Etype (Comp)); end if; Freeze_And_Append (Etype (Comp), N, Result); -- Warn for pragma Pack overriding foreign convention if Has_Foreign_Convention (Etype (Comp)) and then Has_Pragma_Pack (Rec) -- Don't warn for aliased components, since override -- cannot happen in that case. and then not Is_Aliased (Comp) then declare CN : constant Name_Id := Get_Convention_Name (Convention (Etype (Comp))); PP : constant Node_Id := Get_Pragma (Rec, Pragma_Pack); begin if Present (PP) then Error_Msg_Name_1 := CN; Error_Msg_Sloc := Sloc (Comp); Error_Msg_N ("pragma Pack affects convention % component#??", PP); Error_Msg_Name_1 := CN; Error_Msg_NE ("\component & may not have % compatible " & "representation??", PP, Comp); end if; end; end if; -- Check for error of component clause given for variable -- sized type. We have to delay this test till this point, -- since the component type has to be frozen for us to know -- if it is variable length. if Present (CC) then Placed_Component := True; -- We omit this test in a generic context, it will be -- applied at instantiation time. if Inside_A_Generic then null; -- Also omit this test in CodePeer mode, since we do not -- have sufficient info on size and rep clauses. elsif CodePeer_Mode then null; -- Do the check elsif not Size_Known_At_Compile_Time (Underlying_Type (Etype (Comp))) then Error_Msg_N ("component clause not allowed for variable " & "length component", CC); end if; else Unplaced_Component := True; end if; -- Case of component requires byte alignment if Must_Be_On_Byte_Boundary (Etype (Comp)) then -- Set the enclosing record to also require byte align Set_Must_Be_On_Byte_Boundary (Rec); -- Check for component clause that is inconsistent with -- the required byte boundary alignment. if Present (CC) and then Normalized_First_Bit (Comp) mod System_Storage_Unit /= 0 then Error_Msg_N ("component & must be byte aligned", Component_Name (Component_Clause (Comp))); end if; end if; end; end if; -- Gather data for possible Implicit_Packing later. Note that at -- this stage we might be dealing with a real component, or with -- an implicit subtype declaration. if Known_Static_RM_Size (Etype (Comp)) then declare Comp_Type : constant Entity_Id := Etype (Comp); Comp_Size : constant Uint := RM_Size (Comp_Type); SSU : constant Int := Ttypes.System_Storage_Unit; begin Sized_Component_Total_RM_Size := Sized_Component_Total_RM_Size + Comp_Size; Sized_Component_Total_Round_RM_Size := Sized_Component_Total_Round_RM_Size + (Comp_Size + SSU - 1) / SSU * SSU; if Present (Underlying_Type (Comp_Type)) and then Is_Elementary_Type (Underlying_Type (Comp_Type)) then Elem_Component_Total_Esize := Elem_Component_Total_Esize + Esize (Comp_Type); else All_Elem_Components := False; if Comp_Size mod SSU /= 0 then All_Storage_Unit_Components := False; end if; end if; end; else All_Sized_Components := False; end if; -- If the component is an Itype with Delayed_Freeze and is either -- a record or array subtype and its base type has not yet been -- frozen, we must remove this from the entity list of this record -- and put it on the entity list of the scope of its base type. -- Note that we know that this is not the type of a component -- since we cleared Has_Delayed_Freeze for it in the previous -- loop. Thus this must be the Designated_Type of an access type, -- which is the type of a component. if Is_Itype (Comp) and then Is_Type (Scope (Comp)) and then Is_Composite_Type (Comp) and then Base_Type (Comp) /= Comp and then Has_Delayed_Freeze (Comp) and then not Is_Frozen (Base_Type (Comp)) then declare Will_Be_Frozen : Boolean := False; S : Entity_Id; begin -- We have a difficult case to handle here. Suppose Rec is -- subtype being defined in a subprogram that's created as -- part of the freezing of Rec'Base. In that case, we know -- that Comp'Base must have already been frozen by the time -- we get to elaborate this because Gigi doesn't elaborate -- any bodies until it has elaborated all of the declarative -- part. But Is_Frozen will not be set at this point because -- we are processing code in lexical order. -- We detect this case by going up the Scope chain of Rec -- and seeing if we have a subprogram scope before reaching -- the top of the scope chain or that of Comp'Base. If we -- do, then mark that Comp'Base will actually be frozen. If -- so, we merely undelay it. S := Scope (Rec); while Present (S) loop if Is_Subprogram (S) then Will_Be_Frozen := True; exit; elsif S = Scope (Base_Type (Comp)) then exit; end if; S := Scope (S); end loop; if Will_Be_Frozen then Undelay_Type (Comp); else if Present (Prev) then Link_Entities (Prev, Next_Entity (Comp)); else Set_First_Entity (Rec, Next_Entity (Comp)); end if; -- Insert in entity list of scope of base type (which -- must be an enclosing scope, because still unfrozen). Append_Entity (Comp, Scope (Base_Type (Comp))); end if; end; -- If the component is an access type with an allocator as default -- value, the designated type will be frozen by the corresponding -- expression in init_proc. In order to place the freeze node for -- the designated type before that for the current record type, -- freeze it now. -- Same process if the component is an array of access types, -- initialized with an aggregate. If the designated type is -- private, it cannot contain allocators, and it is premature -- to freeze the type, so we check for this as well. elsif Is_Access_Type (Etype (Comp)) and then Present (Parent (Comp)) and then Present (Expression (Parent (Comp))) then declare Alloc : constant Node_Id := Check_Allocator (Expression (Parent (Comp))); begin if Present (Alloc) then -- If component is pointer to a class-wide type, freeze -- the specific type in the expression being allocated. -- The expression may be a subtype indication, in which -- case freeze the subtype mark. if Is_Class_Wide_Type (Designated_Type (Etype (Comp))) then if Is_Entity_Name (Expression (Alloc)) then Freeze_And_Append (Entity (Expression (Alloc)), N, Result); elsif Nkind (Expression (Alloc)) = N_Subtype_Indication then Freeze_And_Append (Entity (Subtype_Mark (Expression (Alloc))), N, Result); end if; elsif Is_Itype (Designated_Type (Etype (Comp))) then Check_Itype (Etype (Comp)); else Freeze_And_Append (Designated_Type (Etype (Comp)), N, Result); end if; end if; end; elsif Is_Access_Type (Etype (Comp)) and then Is_Itype (Designated_Type (Etype (Comp))) then Check_Itype (Etype (Comp)); -- Freeze the designated type when initializing a component with -- an aggregate in case the aggregate contains allocators. -- type T is ...; -- type T_Ptr is access all T; -- type T_Array is array ... of T_Ptr; -- type Rec is record -- Comp : T_Array := (others => ...); -- end record; elsif Is_Array_Type (Etype (Comp)) and then Is_Access_Type (Component_Type (Etype (Comp))) then declare Comp_Par : constant Node_Id := Parent (Comp); Desig_Typ : constant Entity_Id := Designated_Type (Component_Type (Etype (Comp))); begin -- The only case when this sort of freezing is not done is -- when the designated type is class-wide and the root type -- is the record owning the component. This scenario results -- in a circularity because the class-wide type requires -- primitives that have not been created yet as the root -- type is in the process of being frozen. -- type Rec is tagged; -- type Rec_Ptr is access all Rec'Class; -- type Rec_Array is array ... of Rec_Ptr; -- type Rec is record -- Comp : Rec_Array := (others => ...); -- end record; if Is_Class_Wide_Type (Desig_Typ) and then Root_Type (Desig_Typ) = Rec then null; elsif Is_Fully_Defined (Desig_Typ) and then Present (Comp_Par) and then Nkind (Comp_Par) = N_Component_Declaration and then Present (Expression (Comp_Par)) and then Nkind (Expression (Comp_Par)) = N_Aggregate then Freeze_And_Append (Desig_Typ, N, Result); end if; end; end if; Prev := Comp; Next_Entity (Comp); end loop; SSO_ADC := Get_Attribute_Definition_Clause (Rec, Attribute_Scalar_Storage_Order); -- If the record type has Complex_Representation, then it is treated -- as a scalar in the back end so the storage order is irrelevant. if Has_Complex_Representation (Rec) then if Present (SSO_ADC) then Error_Msg_N ("??storage order has no effect with Complex_Representation", SSO_ADC); end if; else -- Deal with default setting of reverse storage order Set_SSO_From_Default (Rec); -- Check consistent attribute setting on component types declare Comp_ADC_Present : Boolean; begin Comp := First_Component (Rec); while Present (Comp) loop Check_Component_Storage_Order (Encl_Type => Rec, Comp => Comp, ADC => SSO_ADC, Comp_ADC_Present => Comp_ADC_Present); SSO_ADC_Component := SSO_ADC_Component or Comp_ADC_Present; Next_Component (Comp); end loop; end; -- Now deal with reverse storage order/bit order issues if Present (SSO_ADC) then -- Check compatibility of Scalar_Storage_Order with Bit_Order, -- if the former is specified. if Reverse_Bit_Order (Rec) /= Reverse_Storage_Order (Rec) then -- Note: report error on Rec, not on SSO_ADC, as ADC may -- apply to some ancestor type. Error_Msg_Sloc := Sloc (SSO_ADC); Error_Msg_N ("scalar storage order for& specified# inconsistent with " & "bit order", Rec); end if; -- Warn if there is a Scalar_Storage_Order attribute definition -- clause but no component clause, no component that itself has -- such an attribute definition, and no pragma Pack. if not (Placed_Component or else SSO_ADC_Component or else Is_Packed (Rec)) then Error_Msg_N ("??scalar storage order specified but no component " & "clause", SSO_ADC); end if; end if; end if; -- Deal with Bit_Order aspect ADC := Get_Attribute_Definition_Clause (Rec, Attribute_Bit_Order); if Present (ADC) and then Base_Type (Rec) = Rec then if not (Placed_Component or else Present (SSO_ADC) or else Is_Packed (Rec)) then -- Warn if clause has no effect when no component clause is -- present, but suppress warning if the Bit_Order is required -- due to the presence of a Scalar_Storage_Order attribute. Error_Msg_N ("??bit order specification has no effect", ADC); Error_Msg_N ("\??since no component clauses were specified", ADC); -- Here is where we do the processing to adjust component clauses -- for reversed bit order, when not using reverse SSO. If an error -- has been reported on Rec already (such as SSO incompatible with -- bit order), don't bother adjusting as this may generate extra -- noise. elsif Reverse_Bit_Order (Rec) and then not Reverse_Storage_Order (Rec) and then not Error_Posted (Rec) then Adjust_Record_For_Reverse_Bit_Order (Rec); -- Case where we have both an explicit Bit_Order and the same -- Scalar_Storage_Order: leave record untouched, the back-end -- will take care of required layout conversions. else null; end if; end if; -- Check for useless pragma Pack when all components placed. We only -- do this check for record types, not subtypes, since a subtype may -- have all its components placed, and it still makes perfectly good -- sense to pack other subtypes or the parent type. We do not give -- this warning if Optimize_Alignment is set to Space, since the -- pragma Pack does have an effect in this case (it always resets -- the alignment to one). if Ekind (Rec) = E_Record_Type and then Is_Packed (Rec) and then not Unplaced_Component and then Optimize_Alignment /= 'S' then -- Reset packed status. Probably not necessary, but we do it so -- that there is no chance of the back end doing something strange -- with this redundant indication of packing. Set_Is_Packed (Rec, False); -- Give warning if redundant constructs warnings on if Warn_On_Redundant_Constructs then Error_Msg_N -- CODEFIX ("??pragma Pack has no effect, no unplaced components", Get_Rep_Pragma (Rec, Name_Pack)); end if; end if; -- If this is the record corresponding to a remote type, freeze the -- remote type here since that is what we are semantically freezing. -- This prevents the freeze node for that type in an inner scope. if Ekind (Rec) = E_Record_Type then if Present (Corresponding_Remote_Type (Rec)) then Freeze_And_Append (Corresponding_Remote_Type (Rec), N, Result); end if; -- Check for controlled components, unchecked unions, and type -- invariants. Comp := First_Component (Rec); while Present (Comp) loop -- Do not set Has_Controlled_Component on a class-wide -- equivalent type. See Make_CW_Equivalent_Type. if not Is_Class_Wide_Equivalent_Type (Rec) and then (Has_Controlled_Component (Etype (Comp)) or else (Chars (Comp) /= Name_uParent and then Is_Controlled (Etype (Comp))) or else (Is_Protected_Type (Etype (Comp)) and then Present (Corresponding_Record_Type (Etype (Comp))) and then Has_Controlled_Component (Corresponding_Record_Type (Etype (Comp))))) then Set_Has_Controlled_Component (Rec); end if; if Has_Unchecked_Union (Etype (Comp)) then Set_Has_Unchecked_Union (Rec); end if; -- The record type requires its own invariant procedure in -- order to verify the invariant of each individual component. -- Do not consider internal components such as _parent because -- parent class-wide invariants are always inherited. -- In GNATprove mode, the component invariants are checked by -- other means. They should not be added to the record type -- invariant procedure, so that the procedure can be used to -- check the recordy type invariants if any. if Comes_From_Source (Comp) and then Has_Invariants (Etype (Comp)) and then not GNATprove_Mode then Set_Has_Own_Invariants (Rec); end if; -- Scan component declaration for likely misuses of current -- instance, either in a constraint or a default expression. if Has_Per_Object_Constraint (Comp) then Check_Current_Instance (Parent (Comp)); end if; Next_Component (Comp); end loop; end if; -- Enforce the restriction that access attributes with a current -- instance prefix can only apply to limited types. This comment -- is floating here, but does not seem to belong here??? -- Set component alignment if not otherwise already set Set_Component_Alignment_If_Not_Set (Rec); -- For first subtypes, check if there are any fixed-point fields with -- component clauses, where we must check the size. This is not done -- till the freeze point since for fixed-point types, we do not know -- the size until the type is frozen. Similar processing applies to -- bit-packed arrays. if Is_First_Subtype (Rec) then Comp := First_Component (Rec); while Present (Comp) loop if Present (Component_Clause (Comp)) and then (Is_Fixed_Point_Type (Etype (Comp)) or else Is_Bit_Packed_Array (Etype (Comp))) then Check_Size (Component_Name (Component_Clause (Comp)), Etype (Comp), Esize (Comp), Junk); end if; Next_Component (Comp); end loop; end if; -- See if Size is too small as is (and implicit packing might help) if not Is_Packed (Rec) -- No implicit packing if even one component is explicitly placed and then not Placed_Component -- Or even one component is aliased and then not Aliased_Component -- Must have size clause and all sized components and then Has_Size_Clause (Rec) and then All_Sized_Components -- Do not try implicit packing on records with discriminants, too -- complicated, especially in the variant record case. and then not Has_Discriminants (Rec) -- We want to implicitly pack if the specified size of the record -- is less than the sum of the object sizes (no point in packing -- if this is not the case), if we can compute it, i.e. if we have -- only elementary components. Otherwise, we have at least one -- composite component and we want to implicitly pack only if bit -- packing is required for it, as we are sure in this case that -- the back end cannot do the expected layout without packing. and then ((All_Elem_Components and then RM_Size (Rec) < Elem_Component_Total_Esize) or else (not All_Elem_Components and then not All_Storage_Unit_Components and then RM_Size (Rec) < Sized_Component_Total_Round_RM_Size)) -- And the total RM size cannot be greater than the specified size -- since otherwise packing will not get us where we have to be. and then Sized_Component_Total_RM_Size <= RM_Size (Rec) -- Never do implicit packing in CodePeer or SPARK modes since -- we don't do any packing in these modes, since this generates -- over-complex code that confuses static analysis, and in -- general, neither CodePeer not GNATprove care about the -- internal representation of objects. and then not (CodePeer_Mode or GNATprove_Mode) then -- If implicit packing enabled, do it if Implicit_Packing then Set_Is_Packed (Rec); -- Otherwise flag the size clause else declare Sz : constant Node_Id := Size_Clause (Rec); begin Error_Msg_NE -- CODEFIX ("size given for& too small", Sz, Rec); Error_Msg_N -- CODEFIX ("\use explicit pragma Pack " & "or use pragma Implicit_Packing", Sz); end; end if; end if; -- The following checks are relevant only when SPARK_Mode is on as -- they are not standard Ada legality rules. if SPARK_Mode = On then -- A discriminated type cannot be effectively volatile -- (SPARK RM 7.1.3(5)). if Is_Effectively_Volatile (Rec) then if Has_Discriminants (Rec) then Error_Msg_N ("discriminated type & cannot be volatile", Rec); end if; -- A non-effectively volatile record type cannot contain -- effectively volatile components (SPARK RM 7.1.3(6)). else Comp := First_Component (Rec); while Present (Comp) loop if Comes_From_Source (Comp) and then Is_Effectively_Volatile (Etype (Comp)) then Error_Msg_Name_1 := Chars (Rec); Error_Msg_N ("component & of non-volatile type % cannot be " & "volatile", Comp); end if; Next_Component (Comp); end loop; end if; -- A type which does not yield a synchronized object cannot have -- a component that yields a synchronized object (SPARK RM 9.5). if not Yields_Synchronized_Object (Rec) then Comp := First_Component (Rec); while Present (Comp) loop if Comes_From_Source (Comp) and then Yields_Synchronized_Object (Etype (Comp)) then Error_Msg_Name_1 := Chars (Rec); Error_Msg_N ("component & of non-synchronized type % cannot be " & "synchronized", Comp); end if; Next_Component (Comp); end loop; end if; -- A Ghost type cannot have a component of protected or task type -- (SPARK RM 6.9(19)). if Is_Ghost_Entity (Rec) then Comp := First_Component (Rec); while Present (Comp) loop if Comes_From_Source (Comp) and then Is_Concurrent_Type (Etype (Comp)) then Error_Msg_Name_1 := Chars (Rec); Error_Msg_N ("component & of ghost type % cannot be concurrent", Comp); end if; Next_Component (Comp); end loop; end if; end if; -- Make sure that if we have an iterator aspect, then we have -- either Constant_Indexing or Variable_Indexing. declare Iterator_Aspect : Node_Id; begin Iterator_Aspect := Find_Aspect (Rec, Aspect_Iterator_Element); if No (Iterator_Aspect) then Iterator_Aspect := Find_Aspect (Rec, Aspect_Default_Iterator); end if; if Present (Iterator_Aspect) then if Has_Aspect (Rec, Aspect_Constant_Indexing) or else Has_Aspect (Rec, Aspect_Variable_Indexing) then null; else Error_Msg_N ("Iterator_Element requires indexing aspect", Iterator_Aspect); end if; end if; end; -- All done if not a full record definition if Ekind (Rec) /= E_Record_Type then return; end if; -- Finally we need to check the variant part to make sure that -- all types within choices are properly frozen as part of the -- freezing of the record type. Check_Variant_Part : declare D : constant Node_Id := Declaration_Node (Rec); T : Node_Id; C : Node_Id; begin -- Find component list C := Empty; if Nkind (D) = N_Full_Type_Declaration then T := Type_Definition (D); if Nkind (T) = N_Record_Definition then C := Component_List (T); elsif Nkind (T) = N_Derived_Type_Definition and then Present (Record_Extension_Part (T)) then C := Component_List (Record_Extension_Part (T)); end if; end if; -- Case of variant part present if Present (C) and then Present (Variant_Part (C)) then Freeze_Choices_In_Variant_Part (Variant_Part (C)); end if; -- Note: we used to call Check_Choices here, but it is too early, -- since predicated subtypes are frozen here, but their freezing -- actions are in Analyze_Freeze_Entity, which has not been called -- yet for entities frozen within this procedure, so we moved that -- call to the Analyze_Freeze_Entity for the record type. end Check_Variant_Part; -- Check that all the primitives of an interface type are abstract -- or null procedures. if Is_Interface (Rec) and then not Error_Posted (Parent (Rec)) then declare Elmt : Elmt_Id; Subp : Entity_Id; begin Elmt := First_Elmt (Primitive_Operations (Rec)); while Present (Elmt) loop Subp := Node (Elmt); if not Is_Abstract_Subprogram (Subp) -- Avoid reporting the error on inherited primitives and then Comes_From_Source (Subp) then Error_Msg_Name_1 := Chars (Subp); if Ekind (Subp) = E_Procedure then if not Null_Present (Parent (Subp)) then Error_Msg_N ("interface procedure % must be abstract or null", Parent (Subp)); end if; else Error_Msg_N ("interface function % must be abstract", Parent (Subp)); end if; end if; Next_Elmt (Elmt); end loop; end; end if; -- For a derived tagged type, check whether inherited primitives -- might require a wrapper to handle class-wide conditions. if Is_Tagged_Type (Rec) and then Is_Derived_Type (Rec) then Check_Inherited_Conditions (Rec); end if; end Freeze_Record_Type; ------------------------------- -- Has_Boolean_Aspect_Import -- ------------------------------- function Has_Boolean_Aspect_Import (E : Entity_Id) return Boolean is Decl : constant Node_Id := Declaration_Node (E); Asp : Node_Id; Expr : Node_Id; begin if Has_Aspects (Decl) then Asp := First (Aspect_Specifications (Decl)); while Present (Asp) loop Expr := Expression (Asp); -- The value of aspect Import is True when the expression is -- either missing or it is explicitly set to True. if Get_Aspect_Id (Asp) = Aspect_Import and then (No (Expr) or else (Compile_Time_Known_Value (Expr) and then Is_True (Expr_Value (Expr)))) then return True; end if; Next (Asp); end loop; end if; return False; end Has_Boolean_Aspect_Import; ------------------------- -- Inherit_Freeze_Node -- ------------------------- procedure Inherit_Freeze_Node (Fnod : Node_Id; Typ : Entity_Id) is Typ_Fnod : constant Node_Id := Freeze_Node (Typ); begin Set_Freeze_Node (Typ, Fnod); Set_Entity (Fnod, Typ); -- The input type had an existing node. Propagate relevant attributes -- from the old freeze node to the inherited freeze node. -- ??? if both freeze nodes have attributes, would they differ? if Present (Typ_Fnod) then -- Attribute Access_Types_To_Process if Present (Access_Types_To_Process (Typ_Fnod)) and then No (Access_Types_To_Process (Fnod)) then Set_Access_Types_To_Process (Fnod, Access_Types_To_Process (Typ_Fnod)); end if; -- Attribute Actions if Present (Actions (Typ_Fnod)) and then No (Actions (Fnod)) then Set_Actions (Fnod, Actions (Typ_Fnod)); end if; -- Attribute First_Subtype_Link if Present (First_Subtype_Link (Typ_Fnod)) and then No (First_Subtype_Link (Fnod)) then Set_First_Subtype_Link (Fnod, First_Subtype_Link (Typ_Fnod)); end if; -- Attribute TSS_Elist if Present (TSS_Elist (Typ_Fnod)) and then No (TSS_Elist (Fnod)) then Set_TSS_Elist (Fnod, TSS_Elist (Typ_Fnod)); end if; end if; end Inherit_Freeze_Node; ------------------------------ -- Wrap_Imported_Subprogram -- ------------------------------ -- The issue here is that our normal approach of checking preconditions -- and postconditions does not work for imported procedures, since we -- are not generating code for the body. To get around this we create -- a wrapper, as shown by the following example: -- procedure K (A : Integer); -- pragma Import (C, K); -- The spec is rewritten by removing the effects of pragma Import, but -- leaving the convention unchanged, as though the source had said: -- procedure K (A : Integer); -- pragma Convention (C, K); -- and we create a body, added to the entity K freeze actions, which -- looks like: -- procedure K (A : Integer) is -- procedure K (A : Integer); -- pragma Import (C, K); -- begin -- K (A); -- end K; -- Now the contract applies in the normal way to the outer procedure, -- and the inner procedure has no contracts, so there is no problem -- in just calling it to get the original effect. -- In the case of a function, we create an appropriate return statement -- for the subprogram body that calls the inner procedure. procedure Wrap_Imported_Subprogram (E : Entity_Id) is function Copy_Import_Pragma return Node_Id; -- Obtain a copy of the Import_Pragma which belongs to subprogram E ------------------------ -- Copy_Import_Pragma -- ------------------------ function Copy_Import_Pragma return Node_Id is -- The subprogram should have an import pragma, otherwise it does -- need a wrapper. Prag : constant Node_Id := Import_Pragma (E); pragma Assert (Present (Prag)); -- Save all semantic fields of the pragma Save_Asp : constant Node_Id := Corresponding_Aspect (Prag); Save_From : constant Boolean := From_Aspect_Specification (Prag); Save_Prag : constant Node_Id := Next_Pragma (Prag); Save_Rep : constant Node_Id := Next_Rep_Item (Prag); Result : Node_Id; begin -- Reset all semantic fields. This avoids a potential infinite -- loop when the pragma comes from an aspect as the duplication -- will copy the aspect, then copy the corresponding pragma and -- so on. Set_Corresponding_Aspect (Prag, Empty); Set_From_Aspect_Specification (Prag, False); Set_Next_Pragma (Prag, Empty); Set_Next_Rep_Item (Prag, Empty); Result := Copy_Separate_Tree (Prag); -- Restore the original semantic fields Set_Corresponding_Aspect (Prag, Save_Asp); Set_From_Aspect_Specification (Prag, Save_From); Set_Next_Pragma (Prag, Save_Prag); Set_Next_Rep_Item (Prag, Save_Rep); return Result; end Copy_Import_Pragma; -- Local variables Loc : constant Source_Ptr := Sloc (E); CE : constant Name_Id := Chars (E); Bod : Node_Id; Forml : Entity_Id; Parms : List_Id; Prag : Node_Id; Spec : Node_Id; Stmt : Node_Id; -- Start of processing for Wrap_Imported_Subprogram begin -- Nothing to do if not imported if not Is_Imported (E) then return; -- Test enabling conditions for wrapping elsif Is_Subprogram (E) and then Present (Contract (E)) and then Present (Pre_Post_Conditions (Contract (E))) and then not GNATprove_Mode then -- Here we do the wrap -- Note on calls to Copy_Separate_Tree. The trees we are copying -- here are fully analyzed, but we definitely want fully syntactic -- unanalyzed trees in the body we construct, so that the analysis -- generates the right visibility, and that is exactly what the -- calls to Copy_Separate_Tree give us. Prag := Copy_Import_Pragma; -- Fix up spec so it is no longer imported and has convention Ada Set_Has_Completion (E, False); Set_Import_Pragma (E, Empty); Set_Interface_Name (E, Empty); Set_Is_Imported (E, False); Set_Convention (E, Convention_Ada); -- Grab the subprogram declaration and specification Spec := Declaration_Node (E); -- Build parameter list that we need Parms := New_List; Forml := First_Formal (E); while Present (Forml) loop Append_To (Parms, Make_Identifier (Loc, Chars (Forml))); Next_Formal (Forml); end loop; -- Build the call -- An imported function whose result type is anonymous access -- creates a new anonymous access type when it is relocated into -- the declarations of the body generated below. As a result, the -- accessibility level of these two anonymous access types may not -- be compatible even though they are essentially the same type. -- Use an unchecked type conversion to reconcile this case. Note -- that the conversion is safe because in the named access type -- case, both the body and imported function utilize the same -- type. if Ekind (E) in E_Function | E_Generic_Function then Stmt := Make_Simple_Return_Statement (Loc, Expression => Unchecked_Convert_To (Etype (E), Make_Function_Call (Loc, Name => Make_Identifier (Loc, CE), Parameter_Associations => Parms))); else Stmt := Make_Procedure_Call_Statement (Loc, Name => Make_Identifier (Loc, CE), Parameter_Associations => Parms); end if; -- Now build the body Bod := Make_Subprogram_Body (Loc, Specification => Copy_Separate_Tree (Spec), Declarations => New_List ( Make_Subprogram_Declaration (Loc, Specification => Copy_Separate_Tree (Spec)), Prag), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (Stmt), End_Label => Make_Identifier (Loc, CE))); -- Append the body to freeze result Add_To_Result (Bod); return; -- Case of imported subprogram that does not get wrapped else -- Set Is_Public. All imported entities need an external symbol -- created for them since they are always referenced from another -- object file. Note this used to be set when we set Is_Imported -- back in Sem_Prag, but now we delay it to this point, since we -- don't want to set this flag if we wrap an imported subprogram. Set_Is_Public (E); end if; end Wrap_Imported_Subprogram; -- Start of processing for Freeze_Entity begin -- The entity being frozen may be subject to pragma Ghost. Set the mode -- now to ensure that any nodes generated during freezing are properly -- flagged as Ghost. Set_Ghost_Mode (E); -- We are going to test for various reasons why this entity need not be -- frozen here, but in the case of an Itype that's defined within a -- record, that test actually applies to the record. if Is_Itype (E) and then Is_Record_Type (Scope (E)) then Test_E := Scope (E); elsif Is_Itype (E) and then Present (Underlying_Type (Scope (E))) and then Is_Record_Type (Underlying_Type (Scope (E))) then Test_E := Underlying_Type (Scope (E)); end if; -- Do not freeze if already frozen since we only need one freeze node if Is_Frozen (E) then Result := No_List; goto Leave; -- Do not freeze if we are preanalyzing without freezing elsif Inside_Preanalysis_Without_Freezing > 0 then Result := No_List; goto Leave; elsif Ekind (E) = E_Generic_Package then Result := Freeze_Generic_Entities (E); goto Leave; -- It is improper to freeze an external entity within a generic because -- its freeze node will appear in a non-valid context. The entity will -- be frozen in the proper scope after the current generic is analyzed. -- However, aspects must be analyzed because they may be queried later -- within the generic itself, and the corresponding pragma or attribute -- definition has not been analyzed yet. After this, indicate that the -- entity has no further delayed aspects, to prevent a later aspect -- analysis out of the scope of the generic. elsif Inside_A_Generic and then External_Ref_In_Generic (Test_E) then if Has_Delayed_Aspects (E) then Analyze_Aspects_At_Freeze_Point (E); Set_Has_Delayed_Aspects (E, False); end if; Result := No_List; goto Leave; -- AI05-0213: A formal incomplete type does not freeze the actual. In -- the instance, the same applies to the subtype renaming the actual. elsif Is_Private_Type (E) and then Is_Generic_Actual_Type (E) and then No (Full_View (Base_Type (E))) and then Ada_Version >= Ada_2012 then Result := No_List; goto Leave; -- Formal subprograms are never frozen elsif Is_Formal_Subprogram (E) then Result := No_List; goto Leave; -- Generic types are never frozen as they lack delayed semantic checks elsif Is_Generic_Type (E) then Result := No_List; goto Leave; -- Do not freeze a global entity within an inner scope created during -- expansion. A call to subprogram E within some internal procedure -- (a stream attribute for example) might require freezing E, but the -- freeze node must appear in the same declarative part as E itself. -- The two-pass elaboration mechanism in gigi guarantees that E will -- be frozen before the inner call is elaborated. We exclude constants -- from this test, because deferred constants may be frozen early, and -- must be diagnosed (e.g. in the case of a deferred constant being used -- in a default expression). If the enclosing subprogram comes from -- source, or is a generic instance, then the freeze point is the one -- mandated by the language, and we freeze the entity. A subprogram that -- is a child unit body that acts as a spec does not have a spec that -- comes from source, but can only come from source. elsif In_Open_Scopes (Scope (Test_E)) and then Scope (Test_E) /= Current_Scope and then Ekind (Test_E) /= E_Constant then declare S : Entity_Id; begin S := Current_Scope; while Present (S) loop if Is_Overloadable (S) then if Comes_From_Source (S) or else Is_Generic_Instance (S) or else Is_Child_Unit (S) then exit; else Result := No_List; goto Leave; end if; end if; S := Scope (S); end loop; end; -- Similarly, an inlined instance body may make reference to global -- entities, but these references cannot be the proper freezing point -- for them, and in the absence of inlining freezing will take place in -- their own scope. Normally instance bodies are analyzed after the -- enclosing compilation, and everything has been frozen at the proper -- place, but with front-end inlining an instance body is compiled -- before the end of the enclosing scope, and as a result out-of-order -- freezing must be prevented. elsif Front_End_Inlining and then In_Instance_Body and then Present (Scope (Test_E)) then declare S : Entity_Id; begin S := Scope (Test_E); while Present (S) loop if Is_Generic_Instance (S) then exit; else S := Scope (S); end if; end loop; if No (S) then Result := No_List; goto Leave; end if; end; end if; -- Add checks to detect proper initialization of scalars that may appear -- as subprogram parameters. if Is_Subprogram (E) and then Check_Validity_Of_Parameters then Apply_Parameter_Validity_Checks (E); end if; -- Deal with delayed aspect specifications. The analysis of the aspect -- is required to be delayed to the freeze point, thus we analyze the -- pragma or attribute definition clause in the tree at this point. We -- also analyze the aspect specification node at the freeze point when -- the aspect doesn't correspond to pragma/attribute definition clause. -- In addition, a derived type may have inherited aspects that were -- delayed in the parent, so these must also be captured now. -- For a record type, we deal with the delayed aspect specifications on -- components first, which is consistent with the non-delayed case and -- makes it possible to have a single processing to detect conflicts. if Is_Record_Type (E) then declare Comp : Entity_Id; Rec_Pushed : Boolean := False; -- Set True if the record type E has been pushed on the scope -- stack. Needed for the analysis of delayed aspects specified -- to the components of Rec. begin Comp := First_Entity (E); while Present (Comp) loop if Ekind (Comp) = E_Component and then Has_Delayed_Aspects (Comp) then if not Rec_Pushed then Push_Scope (E); Rec_Pushed := True; -- The visibility to the discriminants must be restored -- in order to properly analyze the aspects. if Has_Discriminants (E) then Install_Discriminants (E); end if; end if; Analyze_Aspects_At_Freeze_Point (Comp); end if; Next_Entity (Comp); end loop; -- Pop the scope if Rec scope has been pushed on the scope stack -- during the delayed aspect analysis process. if Rec_Pushed then if Has_Discriminants (E) then Uninstall_Discriminants (E); end if; Pop_Scope; end if; end; end if; if Has_Delayed_Aspects (E) or else May_Inherit_Delayed_Rep_Aspects (E) then Analyze_Aspects_At_Freeze_Point (E); end if; -- Here to freeze the entity Set_Is_Frozen (E); -- Case of entity being frozen is other than a type if not Is_Type (E) then -- If entity is exported or imported and does not have an external -- name, now is the time to provide the appropriate default name. -- Skip this if the entity is stubbed, since we don't need a name -- for any stubbed routine. For the case on intrinsics, if no -- external name is specified, then calls will be handled in -- Exp_Intr.Expand_Intrinsic_Call, and no name is needed. If an -- external name is provided, then Expand_Intrinsic_Call leaves -- calls in place for expansion by GIGI. if (Is_Imported (E) or else Is_Exported (E)) and then No (Interface_Name (E)) and then Convention (E) /= Convention_Stubbed and then Convention (E) /= Convention_Intrinsic then Set_Encoded_Interface_Name (E, Get_Default_External_Name (E)); -- If entity is an atomic object appearing in a declaration and -- the expression is an aggregate, assign it to a temporary to -- ensure that the actual assignment is done atomically rather -- than component-wise (the assignment to the temp may be done -- component-wise, but that is harmless). elsif Is_Atomic_Or_VFA (E) and then Nkind (Parent (E)) = N_Object_Declaration and then Present (Expression (Parent (E))) and then Nkind (Expression (Parent (E))) = N_Aggregate and then Is_Atomic_VFA_Aggregate (Expression (Parent (E))) then null; end if; -- Subprogram case if Is_Subprogram (E) then -- Check for needing to wrap imported subprogram Wrap_Imported_Subprogram (E); -- Freeze all parameter types and the return type (RM 13.14(14)). -- However skip this for internal subprograms. This is also where -- any extra formal parameters are created since we now know -- whether the subprogram will use a foreign convention. -- In Ada 2012, freezing a subprogram does not always freeze the -- corresponding profile (see AI05-019). An attribute reference -- is not a freezing point of the profile. Flag Do_Freeze_Profile -- indicates whether the profile should be frozen now. -- Other constructs that should not freeze ??? -- This processing doesn't apply to internal entities (see below) if not Is_Internal (E) and then Do_Freeze_Profile then if not Freeze_Profile (E) then goto Leave; end if; end if; -- Must freeze its parent first if it is a derived subprogram if Present (Alias (E)) then Freeze_And_Append (Alias (E), N, Result); end if; -- We don't freeze internal subprograms, because we don't normally -- want addition of extra formals or mechanism setting to happen -- for those. However we do pass through predefined dispatching -- cases, since extra formals may be needed in some cases, such as -- for the stream 'Input function (build-in-place formals). if not Is_Internal (E) or else Is_Predefined_Dispatching_Operation (E) then Freeze_Subprogram (E); end if; -- If warning on suspicious contracts then check for the case of -- a postcondition other than False for a No_Return subprogram. if No_Return (E) and then Warn_On_Suspicious_Contract and then Present (Contract (E)) then declare Prag : Node_Id := Pre_Post_Conditions (Contract (E)); Exp : Node_Id; begin while Present (Prag) loop if Pragma_Name_Unmapped (Prag) in Name_Post | Name_Postcondition | Name_Refined_Post then Exp := Expression (First (Pragma_Argument_Associations (Prag))); if Nkind (Exp) /= N_Identifier or else Chars (Exp) /= Name_False then Error_Msg_NE ("useless postcondition, & is marked " & "No_Return?T?", Exp, E); end if; end if; Prag := Next_Pragma (Prag); end loop; end; end if; -- Here for other than a subprogram or type else -- If entity has a type, and it is not a generic unit, then freeze -- it first (RM 13.14(10)). if Present (Etype (E)) and then Ekind (E) /= E_Generic_Function then Freeze_And_Append (Etype (E), N, Result); -- For an object of an anonymous array type, aspects on the -- object declaration apply to the type itself. This is the -- case for Atomic_Components, Volatile_Components, and -- Independent_Components. In these cases analysis of the -- generated pragma will mark the anonymous types accordingly, -- and the object itself does not require a freeze node. if Ekind (E) = E_Variable and then Is_Itype (Etype (E)) and then Is_Array_Type (Etype (E)) and then Has_Delayed_Aspects (E) then Set_Has_Delayed_Aspects (E, False); Set_Has_Delayed_Freeze (E, False); Set_Freeze_Node (E, Empty); end if; end if; -- Special processing for objects created by object declaration if Nkind (Declaration_Node (E)) = N_Object_Declaration then Freeze_Object_Declaration (E); end if; -- Check that a constant which has a pragma Volatile[_Components] -- or Atomic[_Components] also has a pragma Import (RM C.6(13)). -- Note: Atomic[_Components] also sets Volatile[_Components] if Ekind (E) = E_Constant and then (Has_Volatile_Components (E) or else Is_Volatile (E)) and then not Is_Imported (E) and then not Has_Boolean_Aspect_Import (E) then -- Make sure we actually have a pragma, and have not merely -- inherited the indication from elsewhere (e.g. an address -- clause, which is not good enough in RM terms). if Has_Rep_Pragma (E, Name_Atomic) or else Has_Rep_Pragma (E, Name_Atomic_Components) then Error_Msg_N ("stand alone atomic constant must be " & "imported (RM C.6(13))", E); elsif Has_Rep_Pragma (E, Name_Volatile) or else Has_Rep_Pragma (E, Name_Volatile_Components) then Error_Msg_N ("stand alone volatile constant must be " & "imported (RM C.6(13))", E); end if; end if; -- Static objects require special handling if (Ekind (E) = E_Constant or else Ekind (E) = E_Variable) and then Is_Statically_Allocated (E) then Freeze_Static_Object (E); end if; -- Remaining step is to layout objects if Ekind (E) in E_Variable | E_Constant | E_Loop_Parameter or else Is_Formal (E) then Layout_Object (E); end if; -- For an object that does not have delayed freezing, and whose -- initialization actions have been captured in a compound -- statement, move them back now directly within the enclosing -- statement sequence. if Ekind (E) in E_Constant | E_Variable and then not Has_Delayed_Freeze (E) then Explode_Initialization_Compound_Statement (E); end if; -- Do not generate a freeze node for a generic unit if Is_Generic_Unit (E) then Result := No_List; goto Leave; end if; end if; -- Case of a type or subtype being frozen else -- Verify several SPARK legality rules related to Ghost types now -- that the type is frozen. Check_Ghost_Type (E); -- We used to check here that a full type must have preelaborable -- initialization if it completes a private type specified with -- pragma Preelaborable_Initialization, but that missed cases where -- the types occur within a generic package, since the freezing -- that occurs within a containing scope generally skips traversal -- of a generic unit's declarations (those will be frozen within -- instances). This check was moved to Analyze_Package_Specification. -- The type may be defined in a generic unit. This can occur when -- freezing a generic function that returns the type (which is -- defined in a parent unit). It is clearly meaningless to freeze -- this type. However, if it is a subtype, its size may be determi- -- nable and used in subsequent checks, so might as well try to -- compute it. -- In Ada 2012, Freeze_Entities is also used in the front end to -- trigger the analysis of aspect expressions, so in this case we -- want to continue the freezing process. -- Is_Generic_Unit (Scope (E)) is dubious here, do we want instead -- In_Generic_Scope (E)??? if Present (Scope (E)) and then Is_Generic_Unit (Scope (E)) and then (not Has_Predicates (E) and then not Has_Delayed_Freeze (E)) then Check_Compile_Time_Size (E); Result := No_List; goto Leave; end if; -- Check for error of Type_Invariant'Class applied to an untagged -- type (check delayed to freeze time when full type is available). declare Prag : constant Node_Id := Get_Pragma (E, Pragma_Invariant); begin if Present (Prag) and then Class_Present (Prag) and then not Is_Tagged_Type (E) then Error_Msg_NE ("Type_Invariant''Class cannot be specified for &", Prag, E); Error_Msg_N ("\can only be specified for a tagged type", Prag); end if; end; -- Deal with special cases of freezing for subtype if E /= Base_Type (E) then -- Before we do anything else, a specific test for the case of a -- size given for an array where the array would need to be packed -- in order for the size to be honored, but is not. This is the -- case where implicit packing may apply. The reason we do this so -- early is that, if we have implicit packing, the layout of the -- base type is affected, so we must do this before we freeze the -- base type. -- We could do this processing only if implicit packing is enabled -- since in all other cases, the error would be caught by the back -- end. However, we choose to do the check even if we do not have -- implicit packing enabled, since this allows us to give a more -- useful error message (advising use of pragma Implicit_Packing -- or pragma Pack). if Is_Array_Type (E) then declare Ctyp : constant Entity_Id := Component_Type (E); Rsiz : constant Uint := RM_Size (Ctyp); SZ : constant Node_Id := Size_Clause (E); Btyp : constant Entity_Id := Base_Type (E); Lo : Node_Id; Hi : Node_Id; Indx : Node_Id; Dim : Uint; Num_Elmts : Uint := Uint_1; -- Number of elements in array begin -- Check enabling conditions. These are straightforward -- except for the test for a limited composite type. This -- eliminates the rare case of a array of limited components -- where there are issues of whether or not we can go ahead -- and pack the array (since we can't freely pack and unpack -- arrays if they are limited). -- Note that we check the root type explicitly because the -- whole point is we are doing this test before we have had -- a chance to freeze the base type (and it is that freeze -- action that causes stuff to be inherited). -- The conditions on the size are identical to those used in -- Freeze_Array_Type to set the Is_Packed flag. if Has_Size_Clause (E) and then Known_Static_RM_Size (E) and then not Is_Packed (E) and then not Has_Pragma_Pack (E) and then not Has_Component_Size_Clause (E) and then Known_Static_RM_Size (Ctyp) and then Rsiz <= System_Max_Integer_Size and then not (Addressable (Rsiz) and then Known_Static_Esize (Ctyp) and then Esize (Ctyp) = Rsiz) and then not (Rsiz mod System_Storage_Unit = 0 and then Is_Composite_Type (Ctyp)) and then not Is_Limited_Composite (E) and then not Is_Packed (Root_Type (E)) and then not Has_Component_Size_Clause (Root_Type (E)) and then not (CodePeer_Mode or GNATprove_Mode) then -- Compute number of elements in array Indx := First_Index (E); while Present (Indx) loop Get_Index_Bounds (Indx, Lo, Hi); if not (Compile_Time_Known_Value (Lo) and then Compile_Time_Known_Value (Hi)) then goto No_Implicit_Packing; end if; Dim := Expr_Value (Hi) - Expr_Value (Lo) + 1; if Dim >= 0 then Num_Elmts := Num_Elmts * Dim; else Num_Elmts := Uint_0; end if; Next_Index (Indx); end loop; -- What we are looking for here is the situation where -- the RM_Size given would be exactly right if there was -- a pragma Pack, resulting in the component size being -- the RM_Size of the component type. if RM_Size (E) = Num_Elmts * Rsiz then -- For implicit packing mode, just set the component -- size and Freeze_Array_Type will do the rest. if Implicit_Packing then Set_Component_Size (Btyp, Rsiz); -- Otherwise give an error message else Error_Msg_NE ("size given for& too small", SZ, E); Error_Msg_N -- CODEFIX ("\use explicit pragma Pack or use pragma " & "Implicit_Packing", SZ); end if; end if; end if; end; end if; <<No_Implicit_Packing>> -- If ancestor subtype present, freeze that first. Note that this -- will also get the base type frozen. Need RM reference ??? Atype := Ancestor_Subtype (E); if Present (Atype) then Freeze_And_Append (Atype, N, Result); -- No ancestor subtype present else -- See if we have a nearest ancestor that has a predicate. -- That catches the case of derived type with a predicate. -- Need RM reference here ??? Atype := Nearest_Ancestor (E); if Present (Atype) and then Has_Predicates (Atype) then Freeze_And_Append (Atype, N, Result); end if; -- Freeze base type before freezing the entity (RM 13.14(15)) if E /= Base_Type (E) then Freeze_And_Append (Base_Type (E), N, Result); end if; end if; -- A subtype inherits all the type-related representation aspects -- from its parents (RM 13.1(8)). Inherit_Aspects_At_Freeze_Point (E); -- For a derived type, freeze its parent type first (RM 13.14(15)) elsif Is_Derived_Type (E) then Freeze_And_Append (Etype (E), N, Result); Freeze_And_Append (First_Subtype (Etype (E)), N, Result); -- A derived type inherits each type-related representation aspect -- of its parent type that was directly specified before the -- declaration of the derived type (RM 13.1(15)). Inherit_Aspects_At_Freeze_Point (E); end if; -- Case of array type if Is_Array_Type (E) then Freeze_Array_Type (E); end if; -- Check for incompatible size and alignment for array/record type if Warn_On_Size_Alignment and then (Is_Array_Type (E) or else Is_Record_Type (E)) and then Has_Size_Clause (E) and then Has_Alignment_Clause (E) -- If explicit Object_Size clause given assume that the programmer -- knows what he is doing, and expects the compiler behavior. and then not Has_Object_Size_Clause (E) -- It does not really make sense to warn for the minimum alignment -- since the programmer could not get rid of the warning. and then Alignment (E) > 1 -- Check for size not a multiple of alignment and then RM_Size (E) mod (Alignment (E) * System_Storage_Unit) /= 0 then declare SC : constant Node_Id := Size_Clause (E); AC : constant Node_Id := Alignment_Clause (E); Loc : Node_Id; Abits : constant Uint := Alignment (E) * System_Storage_Unit; begin if Present (SC) and then Present (AC) then -- Give a warning if Sloc (SC) > Sloc (AC) then Loc := SC; Error_Msg_NE ("?Z?size is not a multiple of alignment for &", Loc, E); Error_Msg_Sloc := Sloc (AC); Error_Msg_Uint_1 := Alignment (E); Error_Msg_N ("\?Z?alignment of ^ specified #", Loc); else Loc := AC; Error_Msg_NE ("?Z?size is not a multiple of alignment for &", Loc, E); Error_Msg_Sloc := Sloc (SC); Error_Msg_Uint_1 := RM_Size (E); Error_Msg_N ("\?Z?size of ^ specified #", Loc); end if; Error_Msg_Uint_1 := ((RM_Size (E) / Abits) + 1) * Abits; Error_Msg_N ("\?Z?Object_Size will be increased to ^", Loc); end if; end; end if; -- For a class-wide type, the corresponding specific type is -- frozen as well (RM 13.14(15)) if Is_Class_Wide_Type (E) then Freeze_And_Append (Root_Type (E), N, Result); -- If the base type of the class-wide type is still incomplete, -- the class-wide remains unfrozen as well. This is legal when -- E is the formal of a primitive operation of some other type -- which is being frozen. if not Is_Frozen (Root_Type (E)) then Set_Is_Frozen (E, False); goto Leave; end if; -- The equivalent type associated with a class-wide subtype needs -- to be frozen to ensure that its layout is done. if Ekind (E) = E_Class_Wide_Subtype and then Present (Equivalent_Type (E)) then Freeze_And_Append (Equivalent_Type (E), N, Result); end if; -- Generate an itype reference for a library-level class-wide type -- at the freeze point. Otherwise the first explicit reference to -- the type may appear in an inner scope which will be rejected by -- the back-end. if Is_Itype (E) and then Is_Compilation_Unit (Scope (E)) then declare Ref : constant Node_Id := Make_Itype_Reference (Loc); begin Set_Itype (Ref, E); -- From a gigi point of view, a class-wide subtype derives -- from its record equivalent type. As a result, the itype -- reference must appear after the freeze node of the -- equivalent type or gigi will reject the reference. if Ekind (E) = E_Class_Wide_Subtype and then Present (Equivalent_Type (E)) then Insert_After (Freeze_Node (Equivalent_Type (E)), Ref); else Add_To_Result (Ref); end if; end; end if; -- For a record type or record subtype, freeze all component types -- (RM 13.14(15)). We test for E_Record_(sub)Type here, rather than -- using Is_Record_Type, because we don't want to attempt the freeze -- for the case of a private type with record extension (we will do -- that later when the full type is frozen). elsif Ekind (E) in E_Record_Type | E_Record_Subtype then if not In_Generic_Scope (E) then Freeze_Record_Type (E); end if; -- Report a warning if a discriminated record base type has a -- convention with language C or C++ applied to it. This check is -- done even within generic scopes (but not in instantiations), -- which is why we don't do it as part of Freeze_Record_Type. Check_Suspicious_Convention (E); -- For a concurrent type, freeze corresponding record type. This does -- not correspond to any specific rule in the RM, but the record type -- is essentially part of the concurrent type. Also freeze all local -- entities. This includes record types created for entry parameter -- blocks and whatever local entities may appear in the private part. elsif Is_Concurrent_Type (E) then if Present (Corresponding_Record_Type (E)) then Freeze_And_Append (Corresponding_Record_Type (E), N, Result); end if; Comp := First_Entity (E); while Present (Comp) loop if Is_Type (Comp) then Freeze_And_Append (Comp, N, Result); elsif (Ekind (Comp)) /= E_Function then -- The guard on the presence of the Etype seems to be needed -- for some CodePeer (-gnatcC) cases, but not clear why??? if Present (Etype (Comp)) then if Is_Itype (Etype (Comp)) and then Underlying_Type (Scope (Etype (Comp))) = E then Undelay_Type (Etype (Comp)); end if; Freeze_And_Append (Etype (Comp), N, Result); end if; end if; Next_Entity (Comp); end loop; -- Private types are required to point to the same freeze node as -- their corresponding full views. The freeze node itself has to -- point to the partial view of the entity (because from the partial -- view, we can retrieve the full view, but not the reverse). -- However, in order to freeze correctly, we need to freeze the full -- view. If we are freezing at the end of a scope (or within the -- scope) of the private type, the partial and full views will have -- been swapped, the full view appears first in the entity chain and -- the swapping mechanism ensures that the pointers are properly set -- (on scope exit). -- If we encounter the partial view before the full view (e.g. when -- freezing from another scope), we freeze the full view, and then -- set the pointers appropriately since we cannot rely on swapping to -- fix things up (subtypes in an outer scope might not get swapped). -- If the full view is itself private, the above requirements apply -- to the underlying full view instead of the full view. But there is -- no swapping mechanism for the underlying full view so we need to -- set the pointers appropriately in both cases. elsif Is_Incomplete_Or_Private_Type (E) and then not Is_Generic_Type (E) then -- The construction of the dispatch table associated with library -- level tagged types forces freezing of all the primitives of the -- type, which may cause premature freezing of the partial view. -- For example: -- package Pkg is -- type T is tagged private; -- type DT is new T with private; -- procedure Prim (X : in out T; Y : in out DT'Class); -- private -- type T is tagged null record; -- Obj : T; -- type DT is new T with null record; -- end; -- In this case the type will be frozen later by the usual -- mechanism: an object declaration, an instantiation, or the -- end of a declarative part. if Is_Library_Level_Tagged_Type (E) and then not Present (Full_View (E)) then Set_Is_Frozen (E, False); goto Leave; -- Case of full view present elsif Present (Full_View (E)) then -- If full view has already been frozen, then no further -- processing is required if Is_Frozen (Full_View (E)) then Set_Has_Delayed_Freeze (E, False); Set_Freeze_Node (E, Empty); -- Otherwise freeze full view and patch the pointers so that -- the freeze node will elaborate both views in the back end. -- However, if full view is itself private, freeze underlying -- full view instead and patch the pointers so that the freeze -- node will elaborate the three views in the back end. else declare Full : Entity_Id := Full_View (E); begin if Is_Private_Type (Full) and then Present (Underlying_Full_View (Full)) then Full := Underlying_Full_View (Full); end if; Freeze_And_Append (Full, N, Result); if Full /= Full_View (E) and then Has_Delayed_Freeze (Full_View (E)) then F_Node := Freeze_Node (Full); if Present (F_Node) then Inherit_Freeze_Node (Fnod => F_Node, Typ => Full_View (E)); else Set_Has_Delayed_Freeze (Full_View (E), False); Set_Freeze_Node (Full_View (E), Empty); end if; end if; if Has_Delayed_Freeze (E) then F_Node := Freeze_Node (Full_View (E)); if Present (F_Node) then Inherit_Freeze_Node (Fnod => F_Node, Typ => E); else -- {Incomplete,Private}_Subtypes with Full_Views -- constrained by discriminants. Set_Has_Delayed_Freeze (E, False); Set_Freeze_Node (E, Empty); end if; end if; end; end if; Check_Debug_Info_Needed (E); -- AI-117 requires that the convention of a partial view be the -- same as the convention of the full view. Note that this is a -- recognized breach of privacy, but it's essential for logical -- consistency of representation, and the lack of a rule in -- RM95 was an oversight. Set_Convention (E, Convention (Full_View (E))); Set_Size_Known_At_Compile_Time (E, Size_Known_At_Compile_Time (Full_View (E))); -- Size information is copied from the full view to the -- incomplete or private view for consistency. -- We skip this is the full view is not a type. This is very -- strange of course, and can only happen as a result of -- certain illegalities, such as a premature attempt to derive -- from an incomplete type. if Is_Type (Full_View (E)) then Set_Size_Info (E, Full_View (E)); Set_RM_Size (E, RM_Size (Full_View (E))); end if; goto Leave; -- Case of underlying full view present elsif Is_Private_Type (E) and then Present (Underlying_Full_View (E)) then if not Is_Frozen (Underlying_Full_View (E)) then Freeze_And_Append (Underlying_Full_View (E), N, Result); end if; -- Patch the pointers so that the freeze node will elaborate -- both views in the back end. if Has_Delayed_Freeze (E) then F_Node := Freeze_Node (Underlying_Full_View (E)); if Present (F_Node) then Inherit_Freeze_Node (Fnod => F_Node, Typ => E); else Set_Has_Delayed_Freeze (E, False); Set_Freeze_Node (E, Empty); end if; end if; Check_Debug_Info_Needed (E); goto Leave; -- Case of no full view present. If entity is subtype or derived, -- it is safe to freeze, correctness depends on the frozen status -- of parent. Otherwise it is either premature usage, or a Taft -- amendment type, so diagnosis is at the point of use and the -- type might be frozen later. elsif E /= Base_Type (E) then declare Btyp : constant Entity_Id := Base_Type (E); begin -- However, if the base type is itself private and has no -- (underlying) full view either, wait until the full type -- declaration is seen and all the full views are created. if Is_Private_Type (Btyp) and then No (Full_View (Btyp)) and then No (Underlying_Full_View (Btyp)) and then Has_Delayed_Freeze (Btyp) and then No (Freeze_Node (Btyp)) then Set_Is_Frozen (E, False); Result := No_List; goto Leave; end if; end; elsif Is_Derived_Type (E) then null; else Set_Is_Frozen (E, False); Result := No_List; goto Leave; end if; -- For access subprogram, freeze types of all formals, the return -- type was already frozen, since it is the Etype of the function. -- Formal types can be tagged Taft amendment types, but otherwise -- they cannot be incomplete. elsif Ekind (E) = E_Subprogram_Type then Formal := First_Formal (E); while Present (Formal) loop if Ekind (Etype (Formal)) = E_Incomplete_Type and then No (Full_View (Etype (Formal))) then if Is_Tagged_Type (Etype (Formal)) then null; -- AI05-151: Incomplete types are allowed in access to -- subprogram specifications. elsif Ada_Version < Ada_2012 then Error_Msg_NE ("invalid use of incomplete type&", E, Etype (Formal)); end if; end if; Freeze_And_Append (Etype (Formal), N, Result); Next_Formal (Formal); end loop; Freeze_Subprogram (E); -- For access to a protected subprogram, freeze the equivalent type -- (however this is not set if we are not generating code or if this -- is an anonymous type used just for resolution). elsif Is_Access_Protected_Subprogram_Type (E) then if Present (Equivalent_Type (E)) then Freeze_And_Append (Equivalent_Type (E), N, Result); end if; end if; -- Generic types are never seen by the back-end, and are also not -- processed by the expander (since the expander is turned off for -- generic processing), so we never need freeze nodes for them. if Is_Generic_Type (E) then goto Leave; end if; -- Some special processing for non-generic types to complete -- representation details not known till the freeze point. if Is_Fixed_Point_Type (E) then Freeze_Fixed_Point_Type (E); -- Some error checks required for ordinary fixed-point type. Defer -- these till the freeze-point since we need the small and range -- values. We only do these checks for base types if Is_Ordinary_Fixed_Point_Type (E) and then Is_Base_Type (E) then if Small_Value (E) < Ureal_2_M_80 then Error_Msg_Name_1 := Name_Small; Error_Msg_N ("`&''%` too small, minimum allowed is 2.0'*'*(-80)", E); elsif Small_Value (E) > Ureal_2_80 then Error_Msg_Name_1 := Name_Small; Error_Msg_N ("`&''%` too large, maximum allowed is 2.0'*'*80", E); end if; if Expr_Value_R (Type_Low_Bound (E)) < Ureal_M_10_36 then Error_Msg_Name_1 := Name_First; Error_Msg_N ("`&''%` too small, minimum allowed is -10.0'*'*36", E); end if; if Expr_Value_R (Type_High_Bound (E)) > Ureal_10_36 then Error_Msg_Name_1 := Name_Last; Error_Msg_N ("`&''%` too large, maximum allowed is 10.0'*'*36", E); end if; end if; elsif Is_Enumeration_Type (E) then Freeze_Enumeration_Type (E); elsif Is_Integer_Type (E) then Adjust_Esize_For_Alignment (E); if Is_Modular_Integer_Type (E) and then Warn_On_Suspicious_Modulus_Value then Check_Suspicious_Modulus (E); end if; -- The pool applies to named and anonymous access types, but not -- to subprogram and to internal types generated for 'Access -- references. elsif Is_Access_Type (E) and then not Is_Access_Subprogram_Type (E) and then Ekind (E) /= E_Access_Attribute_Type then -- If a pragma Default_Storage_Pool applies, and this type has no -- Storage_Pool or Storage_Size clause (which must have occurred -- before the freezing point), then use the default. This applies -- only to base types. -- None of this applies to access to subprograms, for which there -- are clearly no pools. if Present (Default_Pool) and then Is_Base_Type (E) and then not Has_Storage_Size_Clause (E) and then No (Associated_Storage_Pool (E)) then -- Case of pragma Default_Storage_Pool (null) if Nkind (Default_Pool) = N_Null then Set_No_Pool_Assigned (E); -- Case of pragma Default_Storage_Pool (Standard) elsif Entity (Default_Pool) = Standard_Standard then Set_Associated_Storage_Pool (E, RTE (RE_Global_Pool_Object)); -- Case of pragma Default_Storage_Pool (storage_pool_NAME) else Set_Associated_Storage_Pool (E, Entity (Default_Pool)); end if; end if; -- Check restriction for standard storage pool if No (Associated_Storage_Pool (E)) then Check_Restriction (No_Standard_Storage_Pools, E); end if; -- Deal with error message for pure access type. This is not an -- error in Ada 2005 if there is no pool (see AI-366). if Is_Pure_Unit_Access_Type (E) and then (Ada_Version < Ada_2005 or else not No_Pool_Assigned (E)) and then not Is_Generic_Unit (Scope (E)) then Error_Msg_N ("named access type not allowed in pure unit", E); if Ada_Version >= Ada_2005 then Error_Msg_N ("\would be legal if Storage_Size of 0 given??", E); elsif No_Pool_Assigned (E) then Error_Msg_N ("\would be legal in Ada 2005??", E); else Error_Msg_N ("\would be legal in Ada 2005 if " & "Storage_Size of 0 given??", E); end if; end if; end if; -- Case of composite types if Is_Composite_Type (E) then -- AI-117 requires that all new primitives of a tagged type must -- inherit the convention of the full view of the type. Inherited -- and overriding operations are defined to inherit the convention -- of their parent or overridden subprogram (also specified in -- AI-117), which will have occurred earlier (in Derive_Subprogram -- and New_Overloaded_Entity). Here we set the convention of -- primitives that are still convention Ada, which will ensure -- that any new primitives inherit the type's convention. Class- -- wide types can have a foreign convention inherited from their -- specific type, but are excluded from this since they don't have -- any associated primitives. if Is_Tagged_Type (E) and then not Is_Class_Wide_Type (E) and then Convention (E) /= Convention_Ada then declare Prim_List : constant Elist_Id := Primitive_Operations (E); Prim : Elmt_Id; begin Prim := First_Elmt (Prim_List); while Present (Prim) loop if Convention (Node (Prim)) = Convention_Ada then Set_Convention (Node (Prim), Convention (E)); end if; Next_Elmt (Prim); end loop; end; end if; -- If the type is a simple storage pool type, then this is where -- we attempt to locate and validate its Allocate, Deallocate, and -- Storage_Size operations (the first is required, and the latter -- two are optional). We also verify that the full type for a -- private type is allowed to be a simple storage pool type. if Present (Get_Rep_Pragma (E, Name_Simple_Storage_Pool_Type)) and then (Is_Base_Type (E) or else Has_Private_Declaration (E)) then -- If the type is marked Has_Private_Declaration, then this is -- a full type for a private type that was specified with the -- pragma Simple_Storage_Pool_Type, and here we ensure that the -- pragma is allowed for the full type (for example, it can't -- be an array type, or a nonlimited record type). if Has_Private_Declaration (E) then if (not Is_Record_Type (E) or else not Is_Limited_View (E)) and then not Is_Private_Type (E) then Error_Msg_Name_1 := Name_Simple_Storage_Pool_Type; Error_Msg_N ("pragma% can only apply to full type that is an " & "explicitly limited type", E); end if; end if; Validate_Simple_Pool_Ops : declare Pool_Type : Entity_Id renames E; Address_Type : constant Entity_Id := RTE (RE_Address); Stg_Cnt_Type : constant Entity_Id := RTE (RE_Storage_Count); procedure Validate_Simple_Pool_Op_Formal (Pool_Op : Entity_Id; Pool_Op_Formal : in out Entity_Id; Expected_Mode : Formal_Kind; Expected_Type : Entity_Id; Formal_Name : String; OK_Formal : in out Boolean); -- Validate one formal Pool_Op_Formal of the candidate pool -- operation Pool_Op. The formal must be of Expected_Type -- and have mode Expected_Mode. OK_Formal will be set to -- False if the formal doesn't match. If OK_Formal is False -- on entry, then the formal will effectively be ignored -- (because validation of the pool op has already failed). -- Upon return, Pool_Op_Formal will be updated to the next -- formal, if any. procedure Validate_Simple_Pool_Operation (Op_Name : Name_Id); -- Search for and validate a simple pool operation with the -- name Op_Name. If the name is Allocate, then there must be -- exactly one such primitive operation for the simple pool -- type. If the name is Deallocate or Storage_Size, then -- there can be at most one such primitive operation. The -- profile of the located primitive must conform to what -- is expected for each operation. ------------------------------------ -- Validate_Simple_Pool_Op_Formal -- ------------------------------------ procedure Validate_Simple_Pool_Op_Formal (Pool_Op : Entity_Id; Pool_Op_Formal : in out Entity_Id; Expected_Mode : Formal_Kind; Expected_Type : Entity_Id; Formal_Name : String; OK_Formal : in out Boolean) is begin -- If OK_Formal is False on entry, then simply ignore -- the formal, because an earlier formal has already -- been flagged. if not OK_Formal then return; -- If no formal is passed in, then issue an error for a -- missing formal. elsif not Present (Pool_Op_Formal) then Error_Msg_NE ("simple storage pool op missing formal " & Formal_Name & " of type&", Pool_Op, Expected_Type); OK_Formal := False; return; end if; if Etype (Pool_Op_Formal) /= Expected_Type then -- If the pool type was expected for this formal, then -- this will not be considered a candidate operation -- for the simple pool, so we unset OK_Formal so that -- the op and any later formals will be ignored. if Expected_Type = Pool_Type then OK_Formal := False; return; else Error_Msg_NE ("wrong type for formal " & Formal_Name & " of simple storage pool op; expected type&", Pool_Op_Formal, Expected_Type); end if; end if; -- Issue error if formal's mode is not the expected one if Ekind (Pool_Op_Formal) /= Expected_Mode then Error_Msg_N ("wrong mode for formal of simple storage pool op", Pool_Op_Formal); end if; -- Advance to the next formal Next_Formal (Pool_Op_Formal); end Validate_Simple_Pool_Op_Formal; ------------------------------------ -- Validate_Simple_Pool_Operation -- ------------------------------------ procedure Validate_Simple_Pool_Operation (Op_Name : Name_Id) is Op : Entity_Id; Found_Op : Entity_Id := Empty; Formal : Entity_Id; Is_OK : Boolean; begin pragma Assert (Op_Name in Name_Allocate | Name_Deallocate | Name_Storage_Size); Error_Msg_Name_1 := Op_Name; -- For each homonym declared immediately in the scope -- of the simple storage pool type, determine whether -- the homonym is an operation of the pool type, and, -- if so, check that its profile is as expected for -- a simple pool operation of that name. Op := Get_Name_Entity_Id (Op_Name); while Present (Op) loop if Ekind (Op) in E_Function | E_Procedure and then Scope (Op) = Current_Scope then Formal := First_Entity (Op); Is_OK := True; -- The first parameter must be of the pool type -- in order for the operation to qualify. if Op_Name = Name_Storage_Size then Validate_Simple_Pool_Op_Formal (Op, Formal, E_In_Parameter, Pool_Type, "Pool", Is_OK); else Validate_Simple_Pool_Op_Formal (Op, Formal, E_In_Out_Parameter, Pool_Type, "Pool", Is_OK); end if; -- If another operation with this name has already -- been located for the type, then flag an error, -- since we only allow the type to have a single -- such primitive. if Present (Found_Op) and then Is_OK then Error_Msg_NE ("only one % operation allowed for " & "simple storage pool type&", Op, Pool_Type); end if; -- In the case of Allocate and Deallocate, a formal -- of type System.Address is required. if Op_Name = Name_Allocate then Validate_Simple_Pool_Op_Formal (Op, Formal, E_Out_Parameter, Address_Type, "Storage_Address", Is_OK); elsif Op_Name = Name_Deallocate then Validate_Simple_Pool_Op_Formal (Op, Formal, E_In_Parameter, Address_Type, "Storage_Address", Is_OK); end if; -- In the case of Allocate and Deallocate, formals -- of type Storage_Count are required as the third -- and fourth parameters. if Op_Name /= Name_Storage_Size then Validate_Simple_Pool_Op_Formal (Op, Formal, E_In_Parameter, Stg_Cnt_Type, "Size_In_Storage_Units", Is_OK); Validate_Simple_Pool_Op_Formal (Op, Formal, E_In_Parameter, Stg_Cnt_Type, "Alignment", Is_OK); end if; -- If no mismatched formals have been found (Is_OK) -- and no excess formals are present, then this -- operation has been validated, so record it. if not Present (Formal) and then Is_OK then Found_Op := Op; end if; end if; Op := Homonym (Op); end loop; -- There must be a valid Allocate operation for the type, -- so issue an error if none was found. if Op_Name = Name_Allocate and then not Present (Found_Op) then Error_Msg_N ("missing % operation for simple " & "storage pool type", Pool_Type); elsif Present (Found_Op) then -- Simple pool operations can't be abstract if Is_Abstract_Subprogram (Found_Op) then Error_Msg_N ("simple storage pool operation must not be " & "abstract", Found_Op); end if; -- The Storage_Size operation must be a function with -- Storage_Count as its result type. if Op_Name = Name_Storage_Size then if Ekind (Found_Op) = E_Procedure then Error_Msg_N ("% operation must be a function", Found_Op); elsif Etype (Found_Op) /= Stg_Cnt_Type then Error_Msg_NE ("wrong result type for%, expected type&", Found_Op, Stg_Cnt_Type); end if; -- Allocate and Deallocate must be procedures elsif Ekind (Found_Op) = E_Function then Error_Msg_N ("% operation must be a procedure", Found_Op); end if; end if; end Validate_Simple_Pool_Operation; -- Start of processing for Validate_Simple_Pool_Ops begin Validate_Simple_Pool_Operation (Name_Allocate); Validate_Simple_Pool_Operation (Name_Deallocate); Validate_Simple_Pool_Operation (Name_Storage_Size); end Validate_Simple_Pool_Ops; end if; end if; -- Now that all types from which E may depend are frozen, see if -- strict alignment is required, a component clause on a record -- is correct, the size is known at compile time and if it must -- be unsigned, in that order. if Base_Type (E) = E then Check_Strict_Alignment (E); end if; if Ekind (E) in E_Record_Type | E_Record_Subtype then declare RC : constant Node_Id := Get_Record_Representation_Clause (E); begin if Present (RC) then Check_Record_Representation_Clause (RC); end if; end; end if; Check_Compile_Time_Size (E); Check_Unsigned_Type (E); -- Do not allow a size clause for a type which does not have a size -- that is known at compile time if (Has_Size_Clause (E) or else Has_Object_Size_Clause (E)) and then not Size_Known_At_Compile_Time (E) then -- Suppress this message if errors posted on E, even if we are -- in all errors mode, since this is often a junk message if not Error_Posted (E) then Error_Msg_N ("size clause not allowed for variable length type", Size_Clause (E)); end if; end if; -- Now we set/verify the representation information, in particular -- the size and alignment values. This processing is not required for -- generic types, since generic types do not play any part in code -- generation, and so the size and alignment values for such types -- are irrelevant. Ditto for types declared within a generic unit, -- which may have components that depend on generic parameters, and -- that will be recreated in an instance. if Inside_A_Generic then null; -- Otherwise we call the layout procedure else Layout_Type (E); end if; -- If this is an access to subprogram whose designated type is itself -- a subprogram type, the return type of this anonymous subprogram -- type must be decorated as well. if Ekind (E) = E_Anonymous_Access_Subprogram_Type and then Ekind (Designated_Type (E)) = E_Subprogram_Type then Layout_Type (Etype (Designated_Type (E))); end if; -- If the type has a Defaut_Value/Default_Component_Value aspect, -- this is where we analyze the expression (after the type is frozen, -- since in the case of Default_Value, we are analyzing with the -- type itself, and we treat Default_Component_Value similarly for -- the sake of uniformity). if Is_First_Subtype (E) and then Has_Default_Aspect (E) then declare Nam : Name_Id; Exp : Node_Id; Typ : Entity_Id; begin if Is_Scalar_Type (E) then Nam := Name_Default_Value; Typ := E; Exp := Default_Aspect_Value (Typ); else Nam := Name_Default_Component_Value; Typ := Component_Type (E); Exp := Default_Aspect_Component_Value (E); end if; Analyze_And_Resolve (Exp, Typ); if Etype (Exp) /= Any_Type then if not Is_OK_Static_Expression (Exp) then Error_Msg_Name_1 := Nam; Flag_Non_Static_Expr ("aspect% requires static expression", Exp); end if; end if; end; end if; -- End of freeze processing for type entities end if; -- Here is where we logically freeze the current entity. If it has a -- freeze node, then this is the point at which the freeze node is -- linked into the result list. if Has_Delayed_Freeze (E) then -- If a freeze node is already allocated, use it, otherwise allocate -- a new one. The preallocation happens in the case of anonymous base -- types, where we preallocate so that we can set First_Subtype_Link. -- Note that we reset the Sloc to the current freeze location. if Present (Freeze_Node (E)) then F_Node := Freeze_Node (E); Set_Sloc (F_Node, Loc); else F_Node := New_Node (N_Freeze_Entity, Loc); Set_Freeze_Node (E, F_Node); Set_Access_Types_To_Process (F_Node, No_Elist); Set_TSS_Elist (F_Node, No_Elist); Set_Actions (F_Node, No_List); end if; Set_Entity (F_Node, E); Add_To_Result (F_Node); -- A final pass over record types with discriminants. If the type -- has an incomplete declaration, there may be constrained access -- subtypes declared elsewhere, which do not depend on the discrimi- -- nants of the type, and which are used as component types (i.e. -- the full view is a recursive type). The designated types of these -- subtypes can only be elaborated after the type itself, and they -- need an itype reference. if Ekind (E) = E_Record_Type and then Has_Discriminants (E) then declare Comp : Entity_Id; IR : Node_Id; Typ : Entity_Id; begin Comp := First_Component (E); while Present (Comp) loop Typ := Etype (Comp); if Ekind (Comp) = E_Component and then Is_Access_Type (Typ) and then Scope (Typ) /= E and then Base_Type (Designated_Type (Typ)) = E and then Is_Itype (Designated_Type (Typ)) then IR := Make_Itype_Reference (Sloc (Comp)); Set_Itype (IR, Designated_Type (Typ)); Append (IR, Result); end if; Next_Component (Comp); end loop; end; end if; end if; -- When a type is frozen, the first subtype of the type is frozen as -- well (RM 13.14(15)). This has to be done after freezing the type, -- since obviously the first subtype depends on its own base type. if Is_Type (E) then Freeze_And_Append (First_Subtype (E), N, Result); -- If we just froze a tagged non-class wide record, then freeze the -- corresponding class-wide type. This must be done after the tagged -- type itself is frozen, because the class-wide type refers to the -- tagged type which generates the class. if Is_Tagged_Type (E) and then not Is_Class_Wide_Type (E) and then Present (Class_Wide_Type (E)) then Freeze_And_Append (Class_Wide_Type (E), N, Result); end if; end if; Check_Debug_Info_Needed (E); -- If subprogram has address clause then reset Is_Public flag, since we -- do not want the backend to generate external references. if Is_Subprogram (E) and then Present (Address_Clause (E)) and then not Is_Library_Level_Entity (E) then Set_Is_Public (E, False); end if; -- The Ghost mode of the enclosing context is ignored, while the -- entity being frozen is living. Insert the freezing action prior -- to the start of the enclosing ignored Ghost region. As a result -- the freezeing action will be preserved when the ignored Ghost -- context is eliminated. The insertion must take place even when -- the context is a spec expression, otherwise "Handling of Default -- and Per-Object Expressions" will suppress the insertion, and the -- freeze node will be dropped on the floor. if Saved_GM = Ignore and then Ghost_Mode /= Ignore and then Present (Ignored_Ghost_Region) then Insert_Actions (Assoc_Node => Ignored_Ghost_Region, Ins_Actions => Result, Spec_Expr_OK => True); Result := No_List; end if; <<Leave>> Restore_Ghost_Region (Saved_GM, Saved_IGR); return Result; end Freeze_Entity; ----------------------------- -- Freeze_Enumeration_Type -- ----------------------------- procedure Freeze_Enumeration_Type (Typ : Entity_Id) is begin -- By default, if no size clause is present, an enumeration type with -- Convention C is assumed to interface to a C enum and has integer -- size, except for a boolean type because it is assumed to interface -- to _Bool introduced in C99. This applies to types. For subtypes, -- verify that its base type has no size clause either. Treat other -- foreign conventions in the same way, and also make sure alignment -- is set right. if Has_Foreign_Convention (Typ) and then not Is_Boolean_Type (Typ) and then not Has_Size_Clause (Typ) and then not Has_Size_Clause (Base_Type (Typ)) and then Esize (Typ) < Standard_Integer_Size -- Don't do this if Short_Enums on target and then not Target_Short_Enums then Init_Esize (Typ, Standard_Integer_Size); Set_Alignment (Typ, Alignment (Standard_Integer)); -- Normal Ada case or size clause present or not Long_C_Enums on target else -- If the enumeration type interfaces to C, and it has a size clause -- that specifies less than int size, it warrants a warning. The -- user may intend the C type to be an enum or a char, so this is -- not by itself an error that the Ada compiler can detect, but it -- it is a worth a heads-up. For Boolean and Character types we -- assume that the programmer has the proper C type in mind. if Convention (Typ) = Convention_C and then Has_Size_Clause (Typ) and then Esize (Typ) /= Esize (Standard_Integer) and then not Is_Boolean_Type (Typ) and then not Is_Character_Type (Typ) -- Don't do this if Short_Enums on target and then not Target_Short_Enums then Error_Msg_N ("C enum types have the size of a C int??", Size_Clause (Typ)); end if; Adjust_Esize_For_Alignment (Typ); end if; end Freeze_Enumeration_Type; ----------------------- -- Freeze_Expression -- ----------------------- procedure Freeze_Expression (N : Node_Id) is function Find_Aggregate_Component_Desig_Type return Entity_Id; -- If the expression is an array aggregate, the type of the component -- expressions is also frozen. If the component type is an access type -- and the expressions include allocators, the designed type is frozen -- as well. function In_Expanded_Body (N : Node_Id) return Boolean; -- Given an N_Handled_Sequence_Of_Statements node, determines whether it -- is the statement sequence of an expander-generated subprogram: body -- created for an expression function, for a predicate function, an init -- proc, a stream subprogram, or a renaming as body. If so, this is not -- a freezing context and the entity will be frozen at a later point. function Has_Decl_In_List (E : Entity_Id; N : Node_Id; L : List_Id) return Boolean; -- Determines whether an entity E referenced in node N is declared in -- the list L. ----------------------------------------- -- Find_Aggregate_Component_Desig_Type -- ----------------------------------------- function Find_Aggregate_Component_Desig_Type return Entity_Id is Assoc : Node_Id; Exp : Node_Id; begin if Present (Expressions (N)) then Exp := First (Expressions (N)); while Present (Exp) loop if Nkind (Exp) = N_Allocator then return Designated_Type (Component_Type (Etype (N))); end if; Next (Exp); end loop; end if; if Present (Component_Associations (N)) then Assoc := First (Component_Associations (N)); while Present (Assoc) loop if Nkind (Expression (Assoc)) = N_Allocator then return Designated_Type (Component_Type (Etype (N))); end if; Next (Assoc); end loop; end if; return Empty; end Find_Aggregate_Component_Desig_Type; ---------------------- -- In_Expanded_Body -- ---------------------- function In_Expanded_Body (N : Node_Id) return Boolean is P : constant Node_Id := Parent (N); Id : Entity_Id; begin if Nkind (P) /= N_Subprogram_Body then return False; -- AI12-0157: An expression function that is a completion is a freeze -- point. If the body is the result of expansion, it is not. elsif Was_Expression_Function (P) then return not Comes_From_Source (P); -- This is the body of a generated predicate function elsif Present (Corresponding_Spec (P)) and then Is_Predicate_Function (Corresponding_Spec (P)) then return True; else Id := Defining_Unit_Name (Specification (P)); -- The following are expander-created bodies, or bodies that -- are not freeze points. if Nkind (Id) = N_Defining_Identifier and then (Is_Init_Proc (Id) or else Is_TSS (Id, TSS_Stream_Input) or else Is_TSS (Id, TSS_Stream_Output) or else Is_TSS (Id, TSS_Stream_Read) or else Is_TSS (Id, TSS_Stream_Write) or else Nkind (Original_Node (P)) = N_Subprogram_Renaming_Declaration) then return True; else return False; end if; end if; end In_Expanded_Body; ---------------------- -- Has_Decl_In_List -- ---------------------- function Has_Decl_In_List (E : Entity_Id; N : Node_Id; L : List_Id) return Boolean is Decl_Node : Node_Id; begin -- If E is an itype, pretend that it is declared in N if Is_Itype (E) then Decl_Node := N; else Decl_Node := Declaration_Node (E); end if; return Is_List_Member (Decl_Node) and then List_Containing (Decl_Node) = L; end Has_Decl_In_List; -- Local variables In_Spec_Exp : constant Boolean := In_Spec_Expression; Desig_Typ : Entity_Id; Nam : Entity_Id; P : Node_Id; Parent_P : Node_Id; Typ : Entity_Id; Allocator_Typ : Entity_Id := Empty; Freeze_Outside : Boolean := False; -- This flag is set true if the entity must be frozen outside the -- current subprogram. This happens in the case of expander generated -- subprograms (_Init_Proc, _Input, _Output, _Read, _Write) which do -- not freeze all entities like other bodies, but which nevertheless -- may reference entities that have to be frozen before the body and -- obviously cannot be frozen inside the body. Freeze_Outside_Subp : Entity_Id := Empty; -- This entity is set if we are inside a subprogram body and the frozen -- entity is defined in the enclosing scope of this subprogram. In such -- case we must skip the subprogram body when climbing the parents chain -- to locate the correct placement for the freezing node. -- Start of processing for Freeze_Expression begin -- Immediate return if freezing is inhibited. This flag is set by the -- analyzer to stop freezing on generated expressions that would cause -- freezing if they were in the source program, but which are not -- supposed to freeze, since they are created. if Must_Not_Freeze (N) then return; end if; -- If expression is non-static, then it does not freeze in a default -- expression, see section "Handling of Default Expressions" in the -- spec of package Sem for further details. Note that we have to make -- sure that we actually have a real expression (if we have a subtype -- indication, we can't test Is_OK_Static_Expression). However, we -- exclude the case of the prefix of an attribute of a static scalar -- subtype from this early return, because static subtype attributes -- should always cause freezing, even in default expressions, but -- the attribute may not have been marked as static yet (because in -- Resolve_Attribute, the call to Eval_Attribute follows the call of -- Freeze_Expression on the prefix). if In_Spec_Exp and then Nkind (N) in N_Subexpr and then not Is_OK_Static_Expression (N) and then (Nkind (Parent (N)) /= N_Attribute_Reference or else not (Is_Entity_Name (N) and then Is_Type (Entity (N)) and then Is_OK_Static_Subtype (Entity (N)))) then return; end if; -- Freeze type of expression if not frozen already Typ := Empty; if Nkind (N) in N_Has_Etype then if not Is_Frozen (Etype (N)) then Typ := Etype (N); -- Base type may be an derived numeric type that is frozen at the -- point of declaration, but first_subtype is still unfrozen. elsif not Is_Frozen (First_Subtype (Etype (N))) then Typ := First_Subtype (Etype (N)); end if; end if; -- For entity name, freeze entity if not frozen already. A special -- exception occurs for an identifier that did not come from source. -- We don't let such identifiers freeze a non-internal entity, i.e. -- an entity that did come from source, since such an identifier was -- generated by the expander, and cannot have any semantic effect on -- the freezing semantics. For example, this stops the parameter of -- an initialization procedure from freezing the variable. if Is_Entity_Name (N) and then not Is_Frozen (Entity (N)) and then (Nkind (N) /= N_Identifier or else Comes_From_Source (N) or else not Comes_From_Source (Entity (N))) then Nam := Entity (N); if Present (Nam) and then Ekind (Nam) = E_Function then Check_Expression_Function (N, Nam); end if; else Nam := Empty; end if; -- For an allocator freeze designated type if not frozen already -- For an aggregate whose component type is an access type, freeze the -- designated type now, so that its freeze does not appear within the -- loop that might be created in the expansion of the aggregate. If the -- designated type is a private type without full view, the expression -- cannot contain an allocator, so the type is not frozen. -- For a function, we freeze the entity when the subprogram declaration -- is frozen, but a function call may appear in an initialization proc. -- before the declaration is frozen. We need to generate the extra -- formals, if any, to ensure that the expansion of the call includes -- the proper actuals. This only applies to Ada subprograms, not to -- imported ones. Desig_Typ := Empty; case Nkind (N) is when N_Allocator => Desig_Typ := Designated_Type (Etype (N)); if Nkind (Expression (N)) = N_Qualified_Expression then Allocator_Typ := Entity (Subtype_Mark (Expression (N))); end if; when N_Aggregate => if Is_Array_Type (Etype (N)) and then Is_Access_Type (Component_Type (Etype (N))) then -- Check whether aggregate includes allocators Desig_Typ := Find_Aggregate_Component_Desig_Type; end if; when N_Indexed_Component | N_Selected_Component | N_Slice => if Is_Access_Type (Etype (Prefix (N))) then Desig_Typ := Designated_Type (Etype (Prefix (N))); end if; when N_Identifier => if Present (Nam) and then Ekind (Nam) = E_Function and then Nkind (Parent (N)) = N_Function_Call and then Convention (Nam) = Convention_Ada then Create_Extra_Formals (Nam); end if; when others => null; end case; if Desig_Typ /= Empty and then (Is_Frozen (Desig_Typ) or else (not Is_Fully_Defined (Desig_Typ))) then Desig_Typ := Empty; end if; -- All done if nothing needs freezing if No (Typ) and then No (Nam) and then No (Desig_Typ) and then No (Allocator_Typ) then return; end if; -- Check if we are inside a subprogram body and the frozen entity is -- defined in the enclosing scope of this subprogram. In such case we -- must skip the subprogram when climbing the parents chain to locate -- the correct placement for the freezing node. -- This is not needed for default expressions and other spec expressions -- in generic units since the Move_Freeze_Nodes mechanism (sem_ch12.adb) -- takes care of placing them at the proper place, after the generic -- unit. if Present (Nam) and then Scope (Nam) /= Current_Scope and then not (In_Spec_Exp and then Inside_A_Generic) then declare S : Entity_Id := Current_Scope; begin while Present (S) and then In_Same_Source_Unit (Nam, S) loop if Scope (S) = Scope (Nam) then if Is_Subprogram (S) and then Has_Completion (S) then Freeze_Outside_Subp := S; end if; exit; end if; S := Scope (S); end loop; end; end if; -- Examine the enclosing context by climbing the parent chain -- If we identified that we must freeze the entity outside of a given -- subprogram then we just climb up to that subprogram checking if some -- enclosing node is marked as Must_Not_Freeze (since in such case we -- must not freeze yet this entity). P := N; if Present (Freeze_Outside_Subp) then loop -- Do not freeze the current expression if another expression in -- the chain of parents must not be frozen. if Nkind (P) in N_Subexpr and then Must_Not_Freeze (P) then return; end if; Parent_P := Parent (P); -- If we don't have a parent, then we are not in a well-formed -- tree. This is an unusual case, but there are some legitimate -- situations in which this occurs, notably when the expressions -- in the range of a type declaration are resolved. We simply -- ignore the freeze request in this case. if No (Parent_P) then return; end if; -- If the parent is a subprogram body, the candidate insertion -- point is just ahead of it. if Nkind (Parent_P) = N_Subprogram_Body and then Unique_Defining_Entity (Parent_P) = Freeze_Outside_Subp then P := Parent_P; exit; end if; P := Parent_P; end loop; -- Otherwise the traversal serves two purposes - to detect scenarios -- where freezeing is not needed and to find the proper insertion point -- for the freeze nodes. Although somewhat similar to Insert_Actions, -- this traversal is freezing semantics-sensitive. Inserting freeze -- nodes blindly in the tree may result in types being frozen too early. else loop -- Do not freeze the current expression if another expression in -- the chain of parents must not be frozen. if Nkind (P) in N_Subexpr and then Must_Not_Freeze (P) then return; end if; Parent_P := Parent (P); -- If we don't have a parent, then we are not in a well-formed -- tree. This is an unusual case, but there are some legitimate -- situations in which this occurs, notably when the expressions -- in the range of a type declaration are resolved. We simply -- ignore the freeze request in this case. Is this right ??? if No (Parent_P) then return; end if; -- See if we have got to an appropriate point in the tree case Nkind (Parent_P) is -- A special test for the exception of (RM 13.14(8)) for the -- case of per-object expressions (RM 3.8(18)) occurring in -- component definition or a discrete subtype definition. Note -- that we test for a component declaration which includes both -- cases we are interested in, and furthermore the tree does -- not have explicit nodes for either of these two constructs. when N_Component_Declaration => -- The case we want to test for here is an identifier that -- is a per-object expression, this is either a discriminant -- that appears in a context other than the component -- declaration or it is a reference to the type of the -- enclosing construct. -- For either of these cases, we skip the freezing if not In_Spec_Expression and then Nkind (N) = N_Identifier and then (Present (Entity (N))) then -- We recognize the discriminant case by just looking for -- a reference to a discriminant. It can only be one for -- the enclosing construct. Skip freezing in this case. if Ekind (Entity (N)) = E_Discriminant then return; -- For the case of a reference to the enclosing record, -- (or task or protected type), we look for a type that -- matches the current scope. elsif Entity (N) = Current_Scope then return; end if; end if; -- If we have an enumeration literal that appears as the choice -- in the aggregate of an enumeration representation clause, -- then freezing does not occur (RM 13.14(10)). when N_Enumeration_Representation_Clause => -- The case we are looking for is an enumeration literal if Nkind (N) in N_Identifier | N_Character_Literal and then Is_Enumeration_Type (Etype (N)) then -- If enumeration literal appears directly as the choice, -- do not freeze (this is the normal non-overloaded case) if Nkind (Parent (N)) = N_Component_Association and then First (Choices (Parent (N))) = N then return; -- If enumeration literal appears as the name of function -- which is the choice, then also do not freeze. This -- happens in the overloaded literal case, where the -- enumeration literal is temporarily changed to a -- function call for overloading analysis purposes. elsif Nkind (Parent (N)) = N_Function_Call and then Nkind (Parent (Parent (N))) = N_Component_Association and then First (Choices (Parent (Parent (N)))) = Parent (N) then return; end if; end if; -- Normally if the parent is a handled sequence of statements, -- then the current node must be a statement, and that is an -- appropriate place to insert a freeze node. when N_Handled_Sequence_Of_Statements => -- An exception occurs when the sequence of statements is -- for an expander generated body that did not do the usual -- freeze all operation. In this case we usually want to -- freeze outside this body, not inside it, and we skip -- past the subprogram body that we are inside. if In_Expanded_Body (Parent_P) then declare Subp_Body : constant Node_Id := Parent (Parent_P); Spec_Id : Entity_Id; begin -- Freeze the entity only when it is declared inside -- the body of the expander generated procedure. This -- case is recognized by the subprogram scope of the -- entity or its type, which is either the spec of an -- enclosing body, or (in the case of init_procs for -- which there is no separate spec) the current scope. if Nkind (Subp_Body) = N_Subprogram_Body then declare S : Entity_Id; begin Spec_Id := Corresponding_Spec (Subp_Body); if Present (Typ) then S := Scope (Typ); elsif Present (Nam) then S := Scope (Nam); else S := Standard_Standard; end if; while S /= Standard_Standard and then not Is_Subprogram (S) loop S := Scope (S); end loop; if S = Spec_Id then exit; elsif Present (Typ) and then Scope (Typ) = Current_Scope and then Defining_Entity (Subp_Body) = Current_Scope then exit; end if; end; end if; -- If the entity is not frozen by an expression -- function that is not a completion, continue -- climbing the tree. if Nkind (Subp_Body) = N_Subprogram_Body and then Was_Expression_Function (Subp_Body) then null; -- Freeze outside the body else Parent_P := Parent (Parent_P); Freeze_Outside := True; end if; end; -- Here if normal case where we are in handled statement -- sequence and want to do the insertion right there. else exit; end if; -- If parent is a body or a spec or a block, then the current -- node is a statement or declaration and we can insert the -- freeze node before it. when N_Block_Statement | N_Entry_Body | N_Package_Body | N_Package_Specification | N_Protected_Body | N_Subprogram_Body | N_Task_Body => exit; -- The expander is allowed to define types in any statements -- list, so any of the following parent nodes also mark a -- freezing point if the actual node is in a list of -- statements or declarations. when N_Abortable_Part | N_Accept_Alternative | N_Case_Statement_Alternative | N_Compilation_Unit_Aux | N_Conditional_Entry_Call | N_Delay_Alternative | N_Elsif_Part | N_Entry_Call_Alternative | N_Exception_Handler | N_Extended_Return_Statement | N_Freeze_Entity | N_If_Statement | N_Selective_Accept | N_Triggering_Alternative => exit when Is_List_Member (P); -- The freeze nodes produced by an expression coming from the -- Actions list of an N_Expression_With_Actions, short-circuit -- expression or N_Case_Expression_Alternative node must remain -- within the Actions list if they freeze an entity declared in -- this list, as inserting the freeze nodes further up the tree -- may lead to use before declaration issues for the entity. when N_Case_Expression_Alternative | N_Expression_With_Actions | N_Short_Circuit => exit when (Present (Nam) and then Has_Decl_In_List (Nam, P, Actions (Parent_P))) or else (Present (Typ) and then Has_Decl_In_List (Typ, P, Actions (Parent_P))); -- Likewise for an N_If_Expression and its two Actions list when N_If_Expression => declare L1 : constant List_Id := Then_Actions (Parent_P); L2 : constant List_Id := Else_Actions (Parent_P); begin exit when (Present (Nam) and then Has_Decl_In_List (Nam, P, L1)) or else (Present (Typ) and then Has_Decl_In_List (Typ, P, L1)) or else (Present (Nam) and then Has_Decl_In_List (Nam, P, L2)) or else (Present (Typ) and then Has_Decl_In_List (Typ, P, L2)); end; -- N_Loop_Statement is a special case: a type that appears in -- the source can never be frozen in a loop (this occurs only -- because of a loop expanded by the expander), so we keep on -- going. Otherwise we terminate the search. Same is true of -- any entity which comes from source (if it has a predefined -- type, this type does not appear to come from source, but the -- entity should not be frozen here). when N_Loop_Statement => exit when not Comes_From_Source (Etype (N)) and then (No (Nam) or else not Comes_From_Source (Nam)); -- For all other cases, keep looking at parents when others => null; end case; -- We fall through the case if we did not yet find the proper -- place in the free for inserting the freeze node, so climb. P := Parent_P; end loop; end if; -- If the expression appears in a record or an initialization procedure, -- the freeze nodes are collected and attached to the current scope, to -- be inserted and analyzed on exit from the scope, to insure that -- generated entities appear in the correct scope. If the expression is -- a default for a discriminant specification, the scope is still void. -- The expression can also appear in the discriminant part of a private -- or concurrent type. -- If the expression appears in a constrained subcomponent of an -- enclosing record declaration, the freeze nodes must be attached to -- the outer record type so they can eventually be placed in the -- enclosing declaration list. -- The other case requiring this special handling is if we are in a -- default expression, since in that case we are about to freeze a -- static type, and the freeze scope needs to be the outer scope, not -- the scope of the subprogram with the default parameter. -- For default expressions and other spec expressions in generic units, -- the Move_Freeze_Nodes mechanism (see sem_ch12.adb) takes care of -- placing them at the proper place, after the generic unit. if (In_Spec_Exp and not Inside_A_Generic) or else Freeze_Outside or else (Is_Type (Current_Scope) and then (not Is_Concurrent_Type (Current_Scope) or else not Has_Completion (Current_Scope))) or else Ekind (Current_Scope) = E_Void then declare Freeze_Nodes : List_Id := No_List; Pos : Int := Scope_Stack.Last; begin if Present (Desig_Typ) then Freeze_And_Append (Desig_Typ, N, Freeze_Nodes); end if; if Present (Typ) then Freeze_And_Append (Typ, N, Freeze_Nodes); end if; if Present (Nam) then Freeze_And_Append (Nam, N, Freeze_Nodes); end if; -- The current scope may be that of a constrained component of -- an enclosing record declaration, or of a loop of an enclosing -- quantified expression, which is above the current scope in the -- scope stack. Indeed in the context of a quantified expression, -- a scope is created and pushed above the current scope in order -- to emulate the loop-like behavior of the quantified expression. -- If the expression is within a top-level pragma, as for a pre- -- condition on a library-level subprogram, nothing to do. if not Is_Compilation_Unit (Current_Scope) and then (Is_Record_Type (Scope (Current_Scope)) or else Nkind (Parent (Current_Scope)) = N_Quantified_Expression) then Pos := Pos - 1; end if; if Is_Non_Empty_List (Freeze_Nodes) then -- When the current scope is transient, insert the freeze nodes -- prior to the expression that produced them. Transient scopes -- may create additional declarations when finalizing objects -- or managing the secondary stack. Inserting the freeze nodes -- of those constructs prior to the scope would result in a -- freeze-before-declaration, therefore the freeze node must -- remain interleaved with their constructs. if Scope_Is_Transient then Insert_Actions (N, Freeze_Nodes); elsif No (Scope_Stack.Table (Pos).Pending_Freeze_Actions) then Scope_Stack.Table (Pos).Pending_Freeze_Actions := Freeze_Nodes; else Append_List (Freeze_Nodes, Scope_Stack.Table (Pos).Pending_Freeze_Actions); end if; end if; end; return; end if; -- Now we have the right place to do the freezing. First, a special -- adjustment, if we are in spec-expression analysis mode, these freeze -- actions must not be thrown away (normally all inserted actions are -- thrown away in this mode. However, the freeze actions are from static -- expressions and one of the important reasons we are doing this -- special analysis is to get these freeze actions. Therefore we turn -- off the In_Spec_Expression mode to propagate these freeze actions. -- This also means they get properly analyzed and expanded. In_Spec_Expression := False; -- Freeze the subtype mark before a qualified expression on an -- allocator as per AARM 13.14(4.a). This is needed in particular to -- generate predicate functions. if Present (Allocator_Typ) then Freeze_Before (P, Allocator_Typ); end if; -- Freeze the designated type of an allocator (RM 13.14(13)) if Present (Desig_Typ) then Freeze_Before (P, Desig_Typ); end if; -- Freeze type of expression (RM 13.14(10)). Note that we took care of -- the enumeration representation clause exception in the loop above. if Present (Typ) then Freeze_Before (P, Typ); end if; -- Freeze name if one is present (RM 13.14(11)) if Present (Nam) then Freeze_Before (P, Nam); end if; -- Restore In_Spec_Expression flag In_Spec_Expression := In_Spec_Exp; end Freeze_Expression; ----------------------- -- Freeze_Expr_Types -- ----------------------- procedure Freeze_Expr_Types (Def_Id : Entity_Id; Typ : Entity_Id; Expr : Node_Id; N : Node_Id) is function Cloned_Expression return Node_Id; -- Build a duplicate of the expression of the return statement that has -- no defining entities shared with the original expression. function Freeze_Type_Refs (Node : Node_Id) return Traverse_Result; -- Freeze all types referenced in the subtree rooted at Node ----------------------- -- Cloned_Expression -- ----------------------- function Cloned_Expression return Node_Id is function Clone_Id (Node : Node_Id) return Traverse_Result; -- Tree traversal routine that clones the defining identifier of -- iterator and loop parameter specification nodes. -------------- -- Clone_Id -- -------------- function Clone_Id (Node : Node_Id) return Traverse_Result is begin if Nkind (Node) in N_Iterator_Specification | N_Loop_Parameter_Specification then Set_Defining_Identifier (Node, New_Copy (Defining_Identifier (Node))); end if; return OK; end Clone_Id; procedure Clone_Def_Ids is new Traverse_Proc (Clone_Id); -- Local variable Dup_Expr : constant Node_Id := New_Copy_Tree (Expr); -- Start of processing for Cloned_Expression begin -- We must duplicate the expression with semantic information to -- inherit the decoration of global entities in generic instances. -- Set the parent of the new node to be the parent of the original -- to get the proper context, which is needed for complete error -- reporting and for semantic analysis. Set_Parent (Dup_Expr, Parent (Expr)); -- Replace the defining identifier of iterators and loop param -- specifications by a clone to ensure that the cloned expression -- and the original expression don't have shared identifiers; -- otherwise, as part of the preanalysis of the expression, these -- shared identifiers may be left decorated with itypes which -- will not be available in the tree passed to the backend. Clone_Def_Ids (Dup_Expr); return Dup_Expr; end Cloned_Expression; ---------------------- -- Freeze_Type_Refs -- ---------------------- function Freeze_Type_Refs (Node : Node_Id) return Traverse_Result is procedure Check_And_Freeze_Type (Typ : Entity_Id); -- Check that Typ is fully declared and freeze it if so --------------------------- -- Check_And_Freeze_Type -- --------------------------- procedure Check_And_Freeze_Type (Typ : Entity_Id) is begin -- Skip Itypes created by the preanalysis, and itypes whose -- scope is another type (i.e. component subtypes that depend -- on a discriminant), if Is_Itype (Typ) and then (Scope_Within_Or_Same (Scope (Typ), Def_Id) or else Is_Type (Scope (Typ))) then return; end if; -- This provides a better error message than generating primitives -- whose compilation fails much later. Refine the error message if -- possible. Check_Fully_Declared (Typ, Node); if Error_Posted (Node) then if Has_Private_Component (Typ) and then not Is_Private_Type (Typ) then Error_Msg_NE ("\type& has private component", Node, Typ); end if; else Freeze_Before (N, Typ); end if; end Check_And_Freeze_Type; -- Start of processing for Freeze_Type_Refs begin -- Check that a type referenced by an entity can be frozen if Is_Entity_Name (Node) and then Present (Entity (Node)) then Check_And_Freeze_Type (Etype (Entity (Node))); -- Check that the enclosing record type can be frozen if Ekind (Entity (Node)) in E_Component | E_Discriminant then Check_And_Freeze_Type (Scope (Entity (Node))); end if; -- Freezing an access type does not freeze the designated type, but -- freezing conversions between access to interfaces requires that -- the interface types themselves be frozen, so that dispatch table -- entities are properly created. -- Unclear whether a more general rule is needed ??? elsif Nkind (Node) = N_Type_Conversion and then Is_Access_Type (Etype (Node)) and then Is_Interface (Designated_Type (Etype (Node))) then Check_And_Freeze_Type (Designated_Type (Etype (Node))); end if; -- An implicit dereference freezes the designated type. In the case -- of a dispatching call whose controlling argument is an access -- type, the dereference is not made explicit, so we must check for -- such a call and freeze the designated type. if Nkind (Node) in N_Has_Etype and then Present (Etype (Node)) and then Is_Access_Type (Etype (Node)) and then Nkind (Parent (Node)) = N_Function_Call and then Node = Controlling_Argument (Parent (Node)) then Check_And_Freeze_Type (Designated_Type (Etype (Node))); -- An explicit dereference freezes the designated type as well, -- even though that type is not attached to an entity in the -- expression. elsif Nkind (Node) in N_Has_Etype and then Nkind (Parent (Node)) = N_Explicit_Dereference then Check_And_Freeze_Type (Designated_Type (Etype (Node))); -- An iterator specification freezes the iterator type, even though -- that type is not attached to an entity in the construct. elsif Nkind (Node) in N_Has_Etype and then Nkind (Parent (Node)) = N_Iterator_Specification and then Node = Name (Parent (Node)) then declare Iter : constant Node_Id := Find_Value_Of_Aspect (Etype (Node), Aspect_Default_Iterator); begin if Present (Iter) then Check_And_Freeze_Type (Etype (Iter)); end if; end; end if; -- No point in posting several errors on the same expression if Serious_Errors_Detected > 0 then return Abandon; else return OK; end if; end Freeze_Type_Refs; procedure Freeze_References is new Traverse_Proc (Freeze_Type_Refs); -- Local variables Saved_First_Entity : constant Entity_Id := First_Entity (Def_Id); Saved_Last_Entity : constant Entity_Id := Last_Entity (Def_Id); Dup_Expr : constant Node_Id := Cloned_Expression; -- Start of processing for Freeze_Expr_Types begin -- Preanalyze a duplicate of the expression to have available the -- minimum decoration needed to locate referenced unfrozen types -- without adding any decoration to the function expression. -- This routine is also applied to expressions in the contract for -- the subprogram. If that happens when expanding the code for -- pre/postconditions during expansion of the subprogram body, the -- subprogram is already installed. if Def_Id /= Current_Scope then Push_Scope (Def_Id); Install_Formals (Def_Id); Preanalyze_Spec_Expression (Dup_Expr, Typ); End_Scope; else Preanalyze_Spec_Expression (Dup_Expr, Typ); end if; -- Restore certain attributes of Def_Id since the preanalysis may -- have introduced itypes to this scope, thus modifying attributes -- First_Entity and Last_Entity. Set_First_Entity (Def_Id, Saved_First_Entity); Set_Last_Entity (Def_Id, Saved_Last_Entity); if Present (Last_Entity (Def_Id)) then Set_Next_Entity (Last_Entity (Def_Id), Empty); end if; -- Freeze all types referenced in the expression Freeze_References (Dup_Expr); end Freeze_Expr_Types; ----------------------------- -- Freeze_Fixed_Point_Type -- ----------------------------- -- Certain fixed-point types and subtypes, including implicit base types -- and declared first subtypes, have not yet set up a range. This is -- because the range cannot be set until the Small and Size values are -- known, and these are not known till the type is frozen. -- To signal this case, Scalar_Range contains an unanalyzed syntactic range -- whose bounds are unanalyzed real literals. This routine will recognize -- this case, and transform this range node into a properly typed range -- with properly analyzed and resolved values. procedure Freeze_Fixed_Point_Type (Typ : Entity_Id) is Rng : constant Node_Id := Scalar_Range (Typ); Lo : constant Node_Id := Low_Bound (Rng); Hi : constant Node_Id := High_Bound (Rng); Btyp : constant Entity_Id := Base_Type (Typ); Brng : constant Node_Id := Scalar_Range (Btyp); BLo : constant Node_Id := Low_Bound (Brng); BHi : constant Node_Id := High_Bound (Brng); Par : constant Entity_Id := First_Subtype (Typ); Small : constant Ureal := Small_Value (Typ); Loval : Ureal; Hival : Ureal; Atype : Entity_Id; Orig_Lo : Ureal; Orig_Hi : Ureal; -- Save original bounds (for shaving tests) Actual_Size : Nat; -- Actual size chosen function Fsize (Lov, Hiv : Ureal) return Nat; -- Returns size of type with given bounds. Also leaves these -- bounds set as the current bounds of the Typ. ----------- -- Fsize -- ----------- function Fsize (Lov, Hiv : Ureal) return Nat is begin Set_Realval (Lo, Lov); Set_Realval (Hi, Hiv); return Minimum_Size (Typ); end Fsize; -- Start of processing for Freeze_Fixed_Point_Type begin -- The type, or its first subtype if we are freezing the anonymous -- base, may have a delayed Small aspect. It must be analyzed now, -- so that all characteristics of the type (size, bounds) can be -- computed and validated in the call to Minimum_Size that follows. if Has_Delayed_Aspects (First_Subtype (Typ)) then Analyze_Aspects_At_Freeze_Point (First_Subtype (Typ)); Set_Has_Delayed_Aspects (First_Subtype (Typ), False); end if; -- If Esize of a subtype has not previously been set, set it now if Unknown_Esize (Typ) then Atype := Ancestor_Subtype (Typ); if Present (Atype) then Set_Esize (Typ, Esize (Atype)); else Set_Esize (Typ, Esize (Base_Type (Typ))); end if; end if; -- The 'small attribute may have been specified with an aspect, -- in which case it is processed after a subtype declaration, so -- inherit now the specified value. if Typ /= Par and then Present (Find_Aspect (Par, Aspect_Small)) then Set_Small_Value (Typ, Small_Value (Par)); end if; -- Immediate return if the range is already analyzed. This means that -- the range is already set, and does not need to be computed by this -- routine. if Analyzed (Rng) then return; end if; -- Immediate return if either of the bounds raises Constraint_Error if Raises_Constraint_Error (Lo) or else Raises_Constraint_Error (Hi) then return; end if; Loval := Realval (Lo); Hival := Realval (Hi); Orig_Lo := Loval; Orig_Hi := Hival; -- Ordinary fixed-point case if Is_Ordinary_Fixed_Point_Type (Typ) then -- For the ordinary fixed-point case, we are allowed to fudge the -- end-points up or down by small. Generally we prefer to fudge up, -- i.e. widen the bounds for non-model numbers so that the end points -- are included. However there are cases in which this cannot be -- done, and indeed cases in which we may need to narrow the bounds. -- The following circuit makes the decision. -- Note: our terminology here is that Incl_EP means that the bounds -- are widened by Small if necessary to include the end points, and -- Excl_EP means that the bounds are narrowed by Small to exclude the -- end-points if this reduces the size. -- Note that in the Incl case, all we care about is including the -- end-points. In the Excl case, we want to narrow the bounds as -- much as permitted by the RM, to give the smallest possible size. Fudge : declare Loval_Incl_EP : Ureal; Hival_Incl_EP : Ureal; Loval_Excl_EP : Ureal; Hival_Excl_EP : Ureal; Size_Incl_EP : Nat; Size_Excl_EP : Nat; Model_Num : Ureal; First_Subt : Entity_Id; Actual_Lo : Ureal; Actual_Hi : Ureal; begin -- First step. Base types are required to be symmetrical. Right -- now, the base type range is a copy of the first subtype range. -- This will be corrected before we are done, but right away we -- need to deal with the case where both bounds are non-negative. -- In this case, we set the low bound to the negative of the high -- bound, to make sure that the size is computed to include the -- required sign. Note that we do not need to worry about the -- case of both bounds negative, because the sign will be dealt -- with anyway. Furthermore we can't just go making such a bound -- symmetrical, since in a twos-complement system, there is an -- extra negative value which could not be accommodated on the -- positive side. if Typ = Btyp and then not UR_Is_Negative (Loval) and then Hival > Loval then Loval := -Hival; Set_Realval (Lo, Loval); end if; -- Compute the fudged bounds. If the bound is a model number, (or -- greater if given low bound, smaller if high bound) then we do -- nothing to include it, but we are allowed to backoff to the -- next adjacent model number when we exclude it. If it is not a -- model number then we straddle the two values with the model -- numbers on either side. Model_Num := UR_Trunc (Loval / Small) * Small; if UR_Ge (Loval, Model_Num) then Loval_Incl_EP := Model_Num; else Loval_Incl_EP := Model_Num - Small; end if; -- The low value excluding the end point is Small greater, but -- we do not do this exclusion if the low value is positive, -- since it can't help the size and could actually hurt by -- crossing the high bound. if UR_Is_Negative (Loval_Incl_EP) then Loval_Excl_EP := Loval_Incl_EP + Small; -- If the value went from negative to zero, then we have the -- case where Loval_Incl_EP is the model number just below -- zero, so we want to stick to the negative value for the -- base type to maintain the condition that the size will -- include signed values. if Typ = Btyp and then UR_Is_Zero (Loval_Excl_EP) then Loval_Excl_EP := Loval_Incl_EP; end if; else Loval_Excl_EP := Loval_Incl_EP; end if; -- Similar processing for upper bound and high value Model_Num := UR_Trunc (Hival / Small) * Small; if UR_Le (Hival, Model_Num) then Hival_Incl_EP := Model_Num; else Hival_Incl_EP := Model_Num + Small; end if; if UR_Is_Positive (Hival_Incl_EP) then Hival_Excl_EP := Hival_Incl_EP - Small; else Hival_Excl_EP := Hival_Incl_EP; end if; -- One further adjustment is needed. In the case of subtypes, we -- cannot go outside the range of the base type, or we get -- peculiarities, and the base type range is already set. This -- only applies to the Incl values, since clearly the Excl values -- are already as restricted as they are allowed to be. if Typ /= Btyp then Loval_Incl_EP := UR_Max (Loval_Incl_EP, Realval (BLo)); Hival_Incl_EP := UR_Min (Hival_Incl_EP, Realval (BHi)); end if; -- Get size including and excluding end points Size_Incl_EP := Fsize (Loval_Incl_EP, Hival_Incl_EP); Size_Excl_EP := Fsize (Loval_Excl_EP, Hival_Excl_EP); -- No need to exclude end-points if it does not reduce size if Fsize (Loval_Incl_EP, Hival_Excl_EP) = Size_Excl_EP then Loval_Excl_EP := Loval_Incl_EP; end if; if Fsize (Loval_Excl_EP, Hival_Incl_EP) = Size_Excl_EP then Hival_Excl_EP := Hival_Incl_EP; end if; -- Now we set the actual size to be used. We want to use the -- bounds fudged up to include the end-points but only if this -- can be done without violating a specifically given size -- size clause or causing an unacceptable increase in size. -- Case of size clause given if Has_Size_Clause (Typ) then -- Use the inclusive size only if it is consistent with -- the explicitly specified size. if Size_Incl_EP <= RM_Size (Typ) then Actual_Lo := Loval_Incl_EP; Actual_Hi := Hival_Incl_EP; Actual_Size := Size_Incl_EP; -- If the inclusive size is too large, we try excluding -- the end-points (will be caught later if does not work). else Actual_Lo := Loval_Excl_EP; Actual_Hi := Hival_Excl_EP; Actual_Size := Size_Excl_EP; end if; -- Case of size clause not given else -- If we have a base type whose corresponding first subtype -- has an explicit size that is large enough to include our -- end-points, then do so. There is no point in working hard -- to get a base type whose size is smaller than the specified -- size of the first subtype. First_Subt := First_Subtype (Typ); if Has_Size_Clause (First_Subt) and then Size_Incl_EP <= Esize (First_Subt) then Actual_Size := Size_Incl_EP; Actual_Lo := Loval_Incl_EP; Actual_Hi := Hival_Incl_EP; -- If excluding the end-points makes the size smaller and -- results in a size of 8,16,32,64, then we take the smaller -- size. For the 64 case, this is compulsory. For the other -- cases, it seems reasonable. We like to include end points -- if we can, but not at the expense of moving to the next -- natural boundary of size. elsif Size_Incl_EP /= Size_Excl_EP and then Addressable (Size_Excl_EP) then Actual_Size := Size_Excl_EP; Actual_Lo := Loval_Excl_EP; Actual_Hi := Hival_Excl_EP; -- Otherwise we can definitely include the end points else Actual_Size := Size_Incl_EP; Actual_Lo := Loval_Incl_EP; Actual_Hi := Hival_Incl_EP; end if; -- One pathological case: normally we never fudge a low bound -- down, since it would seem to increase the size (if it has -- any effect), but for ranges containing single value, or no -- values, the high bound can be small too large. Consider: -- type t is delta 2.0**(-14) -- range 131072.0 .. 0; -- That lower bound is *just* outside the range of 32 bits, and -- does need fudging down in this case. Note that the bounds -- will always have crossed here, since the high bound will be -- fudged down if necessary, as in the case of: -- type t is delta 2.0**(-14) -- range 131072.0 .. 131072.0; -- So we detect the situation by looking for crossed bounds, -- and if the bounds are crossed, and the low bound is greater -- than zero, we will always back it off by small, since this -- is completely harmless. if Actual_Lo > Actual_Hi then if UR_Is_Positive (Actual_Lo) then Actual_Lo := Loval_Incl_EP - Small; Actual_Size := Fsize (Actual_Lo, Actual_Hi); -- And of course, we need to do exactly the same parallel -- fudge for flat ranges in the negative region. elsif UR_Is_Negative (Actual_Hi) then Actual_Hi := Hival_Incl_EP + Small; Actual_Size := Fsize (Actual_Lo, Actual_Hi); end if; end if; end if; Set_Realval (Lo, Actual_Lo); Set_Realval (Hi, Actual_Hi); end Fudge; -- For the decimal case, none of this fudging is required, since there -- are no end-point problems in the decimal case (the end-points are -- always included). else Actual_Size := Fsize (Loval, Hival); end if; -- At this stage, the actual size has been calculated and the proper -- required bounds are stored in the low and high bounds. if Actual_Size > 64 then Error_Msg_Uint_1 := UI_From_Int (Actual_Size); Error_Msg_N ("size required (^) for type& too large, maximum allowed is 64", Typ); Actual_Size := 64; end if; -- Check size against explicit given size if Has_Size_Clause (Typ) then if Actual_Size > RM_Size (Typ) then Error_Msg_Uint_1 := RM_Size (Typ); Error_Msg_Uint_2 := UI_From_Int (Actual_Size); Error_Msg_NE ("size given (^) for type& too small, minimum allowed is ^", Size_Clause (Typ), Typ); else Actual_Size := UI_To_Int (Esize (Typ)); end if; -- Increase size to next natural boundary if no size clause given else if Actual_Size <= 8 then Actual_Size := 8; elsif Actual_Size <= 16 then Actual_Size := 16; elsif Actual_Size <= 32 then Actual_Size := 32; else Actual_Size := 64; end if; Init_Esize (Typ, Actual_Size); Adjust_Esize_For_Alignment (Typ); end if; -- If we have a base type, then expand the bounds so that they extend to -- the full width of the allocated size in bits, to avoid junk range -- checks on intermediate computations. if Base_Type (Typ) = Typ then Set_Realval (Lo, -(Small * (Uint_2 ** (Actual_Size - 1)))); Set_Realval (Hi, (Small * (Uint_2 ** (Actual_Size - 1) - 1))); end if; -- Final step is to reanalyze the bounds using the proper type -- and set the Corresponding_Integer_Value fields of the literals. Set_Etype (Lo, Empty); Set_Analyzed (Lo, False); Analyze (Lo); -- Resolve with universal fixed if the base type, and with the base -- type if we are freezing a subtype. Note we can't resolve the base -- type with itself, that would be a reference before definition. -- The resolution of the bounds of a subtype, if they are given by real -- literals, includes the setting of the Corresponding_Integer_Value, -- as for other literals of a fixed-point type. if Typ = Btyp then Resolve (Lo, Universal_Fixed); Set_Corresponding_Integer_Value (Lo, UR_To_Uint (Realval (Lo) / Small)); else Resolve (Lo, Btyp); end if; -- Similar processing for high bound Set_Etype (Hi, Empty); Set_Analyzed (Hi, False); Analyze (Hi); if Typ = Btyp then Resolve (Hi, Universal_Fixed); Set_Corresponding_Integer_Value (Hi, UR_To_Uint (Realval (Hi) / Small)); else Resolve (Hi, Btyp); end if; -- Set type of range to correspond to bounds Set_Etype (Rng, Etype (Lo)); -- Set Esize to calculated size if not set already if Unknown_Esize (Typ) then Init_Esize (Typ, Actual_Size); end if; -- Set RM_Size if not already set. If already set, check value declare Minsiz : constant Uint := UI_From_Int (Minimum_Size (Typ)); begin if RM_Size (Typ) /= Uint_0 then if RM_Size (Typ) < Minsiz then Error_Msg_Uint_1 := RM_Size (Typ); Error_Msg_Uint_2 := Minsiz; Error_Msg_NE ("size given (^) for type& too small, minimum allowed is ^", Size_Clause (Typ), Typ); end if; else Set_RM_Size (Typ, Minsiz); end if; end; -- Check for shaving if Comes_From_Source (Typ) then -- In SPARK mode the given bounds must be strictly representable if SPARK_Mode = On then if Orig_Lo < Expr_Value_R (Lo) then Error_Msg_NE ("declared low bound of type & is outside type range", Lo, Typ); end if; if Orig_Hi > Expr_Value_R (Hi) then Error_Msg_NE ("declared high bound of type & is outside type range", Hi, Typ); end if; else if Orig_Lo < Expr_Value_R (Lo) then Error_Msg_N ("declared low bound of type & is outside type range??", Typ); Error_Msg_N ("\low bound adjusted up by delta (RM 3.5.9(13))??", Typ); end if; if Orig_Hi > Expr_Value_R (Hi) then Error_Msg_N ("declared high bound of type & is outside type range??", Typ); Error_Msg_N ("\high bound adjusted down by delta (RM 3.5.9(13))??", Typ); end if; end if; end if; end Freeze_Fixed_Point_Type; ------------------ -- Freeze_Itype -- ------------------ procedure Freeze_Itype (T : Entity_Id; N : Node_Id) is L : List_Id; begin Set_Has_Delayed_Freeze (T); L := Freeze_Entity (T, N); if Is_Non_Empty_List (L) then Insert_Actions (N, L); end if; end Freeze_Itype; -------------------------- -- Freeze_Static_Object -- -------------------------- procedure Freeze_Static_Object (E : Entity_Id) is Cannot_Be_Static : exception; -- Exception raised if the type of a static object cannot be made -- static. This happens if the type depends on non-global objects. procedure Ensure_Expression_Is_SA (N : Node_Id); -- Called to ensure that an expression used as part of a type definition -- is statically allocatable, which means that the expression type is -- statically allocatable, and the expression is either static, or a -- reference to a library level constant. procedure Ensure_Type_Is_SA (Typ : Entity_Id); -- Called to mark a type as static, checking that it is possible -- to set the type as static. If it is not possible, then the -- exception Cannot_Be_Static is raised. ----------------------------- -- Ensure_Expression_Is_SA -- ----------------------------- procedure Ensure_Expression_Is_SA (N : Node_Id) is Ent : Entity_Id; begin Ensure_Type_Is_SA (Etype (N)); if Is_OK_Static_Expression (N) then return; elsif Nkind (N) = N_Identifier then Ent := Entity (N); if Present (Ent) and then Ekind (Ent) = E_Constant and then Is_Library_Level_Entity (Ent) then return; end if; end if; raise Cannot_Be_Static; end Ensure_Expression_Is_SA; ----------------------- -- Ensure_Type_Is_SA -- ----------------------- procedure Ensure_Type_Is_SA (Typ : Entity_Id) is N : Node_Id; C : Entity_Id; begin -- If type is library level, we are all set if Is_Library_Level_Entity (Typ) then return; end if; -- We are also OK if the type already marked as statically allocated, -- which means we processed it before. if Is_Statically_Allocated (Typ) then return; end if; -- Mark type as statically allocated Set_Is_Statically_Allocated (Typ); -- Check that it is safe to statically allocate this type if Is_Scalar_Type (Typ) or else Is_Real_Type (Typ) then Ensure_Expression_Is_SA (Type_Low_Bound (Typ)); Ensure_Expression_Is_SA (Type_High_Bound (Typ)); elsif Is_Array_Type (Typ) then N := First_Index (Typ); while Present (N) loop Ensure_Type_Is_SA (Etype (N)); Next_Index (N); end loop; Ensure_Type_Is_SA (Component_Type (Typ)); elsif Is_Access_Type (Typ) then if Ekind (Designated_Type (Typ)) = E_Subprogram_Type then declare F : Entity_Id; T : constant Entity_Id := Etype (Designated_Type (Typ)); begin if T /= Standard_Void_Type then Ensure_Type_Is_SA (T); end if; F := First_Formal (Designated_Type (Typ)); while Present (F) loop Ensure_Type_Is_SA (Etype (F)); Next_Formal (F); end loop; end; else Ensure_Type_Is_SA (Designated_Type (Typ)); end if; elsif Is_Record_Type (Typ) then C := First_Entity (Typ); while Present (C) loop if Ekind (C) = E_Discriminant or else Ekind (C) = E_Component then Ensure_Type_Is_SA (Etype (C)); elsif Is_Type (C) then Ensure_Type_Is_SA (C); end if; Next_Entity (C); end loop; elsif Ekind (Typ) = E_Subprogram_Type then Ensure_Type_Is_SA (Etype (Typ)); C := First_Formal (Typ); while Present (C) loop Ensure_Type_Is_SA (Etype (C)); Next_Formal (C); end loop; else raise Cannot_Be_Static; end if; end Ensure_Type_Is_SA; -- Start of processing for Freeze_Static_Object begin Ensure_Type_Is_SA (Etype (E)); exception when Cannot_Be_Static => -- If the object that cannot be static is imported or exported, then -- issue an error message saying that this object cannot be imported -- or exported. If it has an address clause it is an overlay in the -- current partition and the static requirement is not relevant. -- Do not issue any error message when ignoring rep clauses. if Ignore_Rep_Clauses then null; elsif Is_Imported (E) then if No (Address_Clause (E)) then Error_Msg_N ("& cannot be imported (local type is not constant)", E); end if; -- Otherwise must be exported, something is wrong if compiler -- is marking something as statically allocated which cannot be). else pragma Assert (Is_Exported (E)); Error_Msg_N ("& cannot be exported (local type is not constant)", E); end if; end Freeze_Static_Object; ----------------------- -- Freeze_Subprogram -- ----------------------- procedure Freeze_Subprogram (E : Entity_Id) is function Check_Extra_Formals (E : Entity_Id) return Boolean; -- Return True if the decoration of the attributes associated with extra -- formals are properly set. procedure Set_Profile_Convention (Subp_Id : Entity_Id); -- Set the conventions of all anonymous access-to-subprogram formals and -- result subtype of subprogram Subp_Id to the convention of Subp_Id. ------------------------- -- Check_Extra_Formals -- ------------------------- function Check_Extra_Formals (E : Entity_Id) return Boolean is Last_Formal : Entity_Id := Empty; Formal : Entity_Id; Has_Extra_Formals : Boolean := False; begin -- No check required if expansion is disabled because extra -- formals are only generated when we are generating code. -- See Create_Extra_Formals. if not Expander_Active then return True; end if; -- Check attribute Extra_Formal: If available, it must be set only -- on the last formal of E. Formal := First_Formal (E); while Present (Formal) loop if Present (Extra_Formal (Formal)) then if Has_Extra_Formals then return False; end if; Has_Extra_Formals := True; end if; Last_Formal := Formal; Next_Formal (Formal); end loop; -- Check attribute Extra_Accessibility_Of_Result if Ekind (E) in E_Function | E_Subprogram_Type and then Needs_Result_Accessibility_Level (E) and then No (Extra_Accessibility_Of_Result (E)) then return False; end if; -- Check attribute Extra_Formals: If E has extra formals, then this -- attribute must point to the first extra formal of E. if Has_Extra_Formals then return Present (Extra_Formals (E)) and then Present (Extra_Formal (Last_Formal)) and then Extra_Formal (Last_Formal) = Extra_Formals (E); -- When E has no formals, the first extra formal is available through -- the Extra_Formals attribute. elsif Present (Extra_Formals (E)) then return No (First_Formal (E)); else return True; end if; end Check_Extra_Formals; ---------------------------- -- Set_Profile_Convention -- ---------------------------- procedure Set_Profile_Convention (Subp_Id : Entity_Id) is Conv : constant Convention_Id := Convention (Subp_Id); procedure Set_Type_Convention (Typ : Entity_Id); -- Set the convention of anonymous access-to-subprogram type Typ and -- its designated type to Conv. ------------------------- -- Set_Type_Convention -- ------------------------- procedure Set_Type_Convention (Typ : Entity_Id) is begin -- Set the convention on both the anonymous access-to-subprogram -- type and the subprogram type it points to because both types -- participate in conformance-related checks. if Ekind (Typ) = E_Anonymous_Access_Subprogram_Type then Set_Convention (Typ, Conv); Set_Convention (Designated_Type (Typ), Conv); end if; end Set_Type_Convention; -- Local variables Formal : Entity_Id; -- Start of processing for Set_Profile_Convention begin Formal := First_Formal (Subp_Id); while Present (Formal) loop Set_Type_Convention (Etype (Formal)); Next_Formal (Formal); end loop; if Ekind (Subp_Id) = E_Function then Set_Type_Convention (Etype (Subp_Id)); end if; end Set_Profile_Convention; -- Local variables F : Entity_Id; Retype : Entity_Id; -- Start of processing for Freeze_Subprogram begin -- Subprogram may not have an address clause unless it is imported if Present (Address_Clause (E)) then if not Is_Imported (E) then Error_Msg_N ("address clause can only be given for imported subprogram", Name (Address_Clause (E))); end if; end if; -- Reset the Pure indication on an imported subprogram unless an -- explicit Pure_Function pragma was present or the subprogram is an -- intrinsic. We do this because otherwise it is an insidious error -- to call a non-pure function from pure unit and have calls -- mysteriously optimized away. What happens here is that the Import -- can bypass the normal check to ensure that pure units call only pure -- subprograms. -- The reason for the intrinsic exception is that in general, intrinsic -- functions (such as shifts) are pure anyway. The only exceptions are -- the intrinsics in GNAT.Source_Info, and that unit is not marked Pure -- in any case, so no problem arises. if Is_Imported (E) and then Is_Pure (E) and then not Has_Pragma_Pure_Function (E) and then not Is_Intrinsic_Subprogram (E) then Set_Is_Pure (E, False); end if; -- For C++ constructors check that their external name has been given -- (either in pragma CPP_Constructor or in a pragma import). if Is_Constructor (E) and then Convention (E) = Convention_CPP and then (No (Interface_Name (E)) or else String_Equal (L => Strval (Interface_Name (E)), R => Strval (Get_Default_External_Name (E)))) then Error_Msg_N ("'C++ constructor must have external name or link name", E); end if; -- We also reset the Pure indication on a subprogram with an Address -- parameter, because the parameter may be used as a pointer and the -- referenced data may change even if the address value does not. -- Note that if the programmer gave an explicit Pure_Function pragma, -- then we believe the programmer, and leave the subprogram Pure. We -- also suppress this check on run-time files. if Is_Pure (E) and then Is_Subprogram (E) and then not Has_Pragma_Pure_Function (E) and then not Is_Internal_Unit (Current_Sem_Unit) then Check_Function_With_Address_Parameter (E); end if; -- Ensure that all anonymous access-to-subprogram types inherit the -- convention of their related subprogram (RM 6.3.1 13.1/3). This is -- not done for a defaulted convention Ada because those types also -- default to Ada. Convention Protected must not be propagated when -- the subprogram is an entry because this would be illegal. The only -- way to force convention Protected on these kinds of types is to -- include keyword "protected" in the access definition. if Convention (E) /= Convention_Ada and then Convention (E) /= Convention_Protected then Set_Profile_Convention (E); end if; -- For non-foreign convention subprograms, this is where we create -- the extra formals (for accessibility level and constrained bit -- information). We delay this till the freeze point precisely so -- that we know the convention. if not Has_Foreign_Convention (E) then if No (Extra_Formals (E)) then -- Extra formals are shared by derived subprograms; therefore, if -- the ultimate alias of E has been frozen before E then the extra -- formals have been added, but the attribute Extra_Formals is -- still unset (and must be set now). if Present (Alias (E)) and then Is_Frozen (Ultimate_Alias (E)) and then Present (Extra_Formals (Ultimate_Alias (E))) and then Last_Formal (Ultimate_Alias (E)) = Last_Formal (E) then Set_Extra_Formals (E, Extra_Formals (Ultimate_Alias (E))); if Ekind (E) = E_Function then Set_Extra_Accessibility_Of_Result (E, Extra_Accessibility_Of_Result (Ultimate_Alias (E))); end if; else Create_Extra_Formals (E); end if; end if; pragma Assert (Check_Extra_Formals (E)); Set_Mechanisms (E); -- If this is convention Ada and a Valued_Procedure, that's odd if Ekind (E) = E_Procedure and then Is_Valued_Procedure (E) and then Convention (E) = Convention_Ada and then Warn_On_Export_Import then Error_Msg_N ("??Valued_Procedure has no effect for convention Ada", E); Set_Is_Valued_Procedure (E, False); end if; -- Case of foreign convention else Set_Mechanisms (E); -- For foreign conventions, warn about return of unconstrained array if Ekind (E) = E_Function then Retype := Underlying_Type (Etype (E)); -- If no return type, probably some other error, e.g. a -- missing full declaration, so ignore. if No (Retype) then null; -- If the return type is generic, we have emitted a warning -- earlier on, and there is nothing else to check here. Specific -- instantiations may lead to erroneous behavior. elsif Is_Generic_Type (Etype (E)) then null; -- Display warning if returning unconstrained array elsif Is_Array_Type (Retype) and then not Is_Constrained (Retype) -- Check appropriate warning is enabled (should we check for -- Warnings (Off) on specific entities here, probably so???) and then Warn_On_Export_Import then Error_Msg_N ("?x?foreign convention function& should not return " & "unconstrained array", E); return; end if; end if; -- If any of the formals for an exported foreign convention -- subprogram have defaults, then emit an appropriate warning since -- this is odd (default cannot be used from non-Ada code) if Is_Exported (E) then F := First_Formal (E); while Present (F) loop if Warn_On_Export_Import and then Present (Default_Value (F)) then Error_Msg_N ("?x?parameter cannot be defaulted in non-Ada call", Default_Value (F)); end if; Next_Formal (F); end loop; end if; end if; -- Pragma Inline_Always is disallowed for dispatching subprograms -- because the address of such subprograms is saved in the dispatch -- table to support dispatching calls, and dispatching calls cannot -- be inlined. This is consistent with the restriction against using -- 'Access or 'Address on an Inline_Always subprogram. if Is_Dispatching_Operation (E) and then Has_Pragma_Inline_Always (E) then Error_Msg_N ("pragma Inline_Always not allowed for dispatching subprograms", E); end if; -- Because of the implicit representation of inherited predefined -- operators in the front-end, the overriding status of the operation -- may be affected when a full view of a type is analyzed, and this is -- not captured by the analysis of the corresponding type declaration. -- Therefore the correctness of a not-overriding indicator must be -- rechecked when the subprogram is frozen. if Nkind (E) = N_Defining_Operator_Symbol and then not Error_Posted (Parent (E)) then Check_Overriding_Indicator (E, Empty, Is_Primitive (E)); end if; if Modify_Tree_For_C and then Nkind (Parent (E)) = N_Function_Specification and then Is_Array_Type (Etype (E)) and then Is_Constrained (Etype (E)) and then not Is_Unchecked_Conversion_Instance (E) and then not Rewritten_For_C (E) then Build_Procedure_Form (Unit_Declaration_Node (E)); end if; end Freeze_Subprogram; ---------------------- -- Is_Fully_Defined -- ---------------------- function Is_Fully_Defined (T : Entity_Id) return Boolean is begin if Ekind (T) = E_Class_Wide_Type then return Is_Fully_Defined (Etype (T)); elsif Is_Array_Type (T) then return Is_Fully_Defined (Component_Type (T)); elsif Is_Record_Type (T) and not Is_Private_Type (T) then -- Verify that the record type has no components with private types -- without completion. declare Comp : Entity_Id; begin Comp := First_Component (T); while Present (Comp) loop if not Is_Fully_Defined (Etype (Comp)) then return False; end if; Next_Component (Comp); end loop; return True; end; -- For the designated type of an access to subprogram, all types in -- the profile must be fully defined. elsif Ekind (T) = E_Subprogram_Type then declare F : Entity_Id; begin F := First_Formal (T); while Present (F) loop if not Is_Fully_Defined (Etype (F)) then return False; end if; Next_Formal (F); end loop; return Is_Fully_Defined (Etype (T)); end; else return not Is_Private_Type (T) or else Present (Full_View (Base_Type (T))); end if; end Is_Fully_Defined; --------------------------------- -- Process_Default_Expressions -- --------------------------------- procedure Process_Default_Expressions (E : Entity_Id; After : in out Node_Id) is Loc : constant Source_Ptr := Sloc (E); Dbody : Node_Id; Formal : Node_Id; Dcopy : Node_Id; Dnam : Entity_Id; begin Set_Default_Expressions_Processed (E); -- A subprogram instance and its associated anonymous subprogram share -- their signature. The default expression functions are defined in the -- wrapper packages for the anonymous subprogram, and should not be -- generated again for the instance. if Is_Generic_Instance (E) and then Present (Alias (E)) and then Default_Expressions_Processed (Alias (E)) then return; end if; Formal := First_Formal (E); while Present (Formal) loop if Present (Default_Value (Formal)) then -- We work with a copy of the default expression because we -- do not want to disturb the original, since this would mess -- up the conformance checking. Dcopy := New_Copy_Tree (Default_Value (Formal)); -- The analysis of the expression may generate insert actions, -- which of course must not be executed. We wrap those actions -- in a procedure that is not called, and later on eliminated. -- The following cases have no side effects, and are analyzed -- directly. if Nkind (Dcopy) = N_Identifier or else Nkind (Dcopy) in N_Expanded_Name | N_Integer_Literal | N_Character_Literal | N_String_Literal | N_Real_Literal or else (Nkind (Dcopy) = N_Attribute_Reference and then Attribute_Name (Dcopy) = Name_Null_Parameter) or else Known_Null (Dcopy) then -- If there is no default function, we must still do a full -- analyze call on the default value, to ensure that all error -- checks are performed, e.g. those associated with static -- evaluation. Note: this branch will always be taken if the -- analyzer is turned off (but we still need the error checks). -- Note: the setting of parent here is to meet the requirement -- that we can only analyze the expression while attached to -- the tree. Really the requirement is that the parent chain -- be set, we don't actually need to be in the tree. Set_Parent (Dcopy, Declaration_Node (Formal)); Analyze (Dcopy); -- Default expressions are resolved with their own type if the -- context is generic, to avoid anomalies with private types. if Ekind (Scope (E)) = E_Generic_Package then Resolve (Dcopy); else Resolve (Dcopy, Etype (Formal)); end if; -- If that resolved expression will raise constraint error, -- then flag the default value as raising constraint error. -- This allows a proper error message on the calls. if Raises_Constraint_Error (Dcopy) then Set_Raises_Constraint_Error (Default_Value (Formal)); end if; -- If the default is a parameterless call, we use the name of -- the called function directly, and there is no body to build. elsif Nkind (Dcopy) = N_Function_Call and then No (Parameter_Associations (Dcopy)) then null; -- Else construct and analyze the body of a wrapper procedure -- that contains an object declaration to hold the expression. -- Given that this is done only to complete the analysis, it is -- simpler to build a procedure than a function which might -- involve secondary stack expansion. else Dnam := Make_Temporary (Loc, 'D'); Dbody := Make_Subprogram_Body (Loc, Specification => Make_Procedure_Specification (Loc, Defining_Unit_Name => Dnam), Declarations => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Make_Temporary (Loc, 'T'), Object_Definition => New_Occurrence_Of (Etype (Formal), Loc), Expression => New_Copy_Tree (Dcopy))), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Empty_List)); Set_Scope (Dnam, Scope (E)); Set_Assignment_OK (First (Declarations (Dbody))); Set_Is_Eliminated (Dnam); Insert_After (After, Dbody); Analyze (Dbody); After := Dbody; end if; end if; Next_Formal (Formal); end loop; end Process_Default_Expressions; ---------------------------------------- -- Set_Component_Alignment_If_Not_Set -- ---------------------------------------- procedure Set_Component_Alignment_If_Not_Set (Typ : Entity_Id) is begin -- Ignore if not base type, subtypes don't need anything if Typ /= Base_Type (Typ) then return; end if; -- Do not override existing representation if Is_Packed (Typ) then return; elsif Has_Specified_Layout (Typ) then return; elsif Component_Alignment (Typ) /= Calign_Default then return; else Set_Component_Alignment (Typ, Scope_Stack.Table (Scope_Stack.Last).Component_Alignment_Default); end if; end Set_Component_Alignment_If_Not_Set; -------------------------- -- Set_SSO_From_Default -- -------------------------- procedure Set_SSO_From_Default (T : Entity_Id) is Reversed : Boolean; begin -- Set default SSO for an array or record base type, except in case of -- a type extension (which always inherits the SSO of its parent type). if Is_Base_Type (T) and then (Is_Array_Type (T) or else (Is_Record_Type (T) and then not (Is_Tagged_Type (T) and then Is_Derived_Type (T)))) then Reversed := (Bytes_Big_Endian and then SSO_Set_Low_By_Default (T)) or else (not Bytes_Big_Endian and then SSO_Set_High_By_Default (T)); if (SSO_Set_Low_By_Default (T) or else SSO_Set_High_By_Default (T)) -- For a record type, if bit order is specified explicitly, -- then do not set SSO from default if not consistent. Note that -- we do not want to look at a Bit_Order attribute definition -- for a parent: if we were to inherit Bit_Order, then both -- SSO_Set_*_By_Default flags would have been cleared already -- (by Inherit_Aspects_At_Freeze_Point). and then not (Is_Record_Type (T) and then Has_Rep_Item (T, Name_Bit_Order, Check_Parents => False) and then Reverse_Bit_Order (T) /= Reversed) then -- If flags cause reverse storage order, then set the result. Note -- that we would have ignored the pragma setting the non default -- storage order in any case, hence the assertion at this point. pragma Assert (not Reversed or else Support_Nondefault_SSO_On_Target); Set_Reverse_Storage_Order (T, Reversed); -- For a record type, also set reversed bit order. Note: if a bit -- order has been specified explicitly, then this is a no-op. if Is_Record_Type (T) then Set_Reverse_Bit_Order (T, Reversed); end if; end if; end if; end Set_SSO_From_Default; ------------------ -- Undelay_Type -- ------------------ procedure Undelay_Type (T : Entity_Id) is begin Set_Has_Delayed_Freeze (T, False); Set_Freeze_Node (T, Empty); -- Since we don't want T to have a Freeze_Node, we don't want its -- Full_View or Corresponding_Record_Type to have one either. -- ??? Fundamentally, this whole handling is unpleasant. What we really -- want is to be sure that for an Itype that's part of record R and is a -- subtype of type T, that it's frozen after the later of the freeze -- points of R and T. We have no way of doing that directly, so what we -- do is force most such Itypes to be frozen as part of freezing R via -- this procedure and only delay the ones that need to be delayed -- (mostly the designated types of access types that are defined as part -- of the record). if Is_Private_Type (T) and then Present (Full_View (T)) and then Is_Itype (Full_View (T)) and then Is_Record_Type (Scope (Full_View (T))) then Undelay_Type (Full_View (T)); end if; if Is_Concurrent_Type (T) and then Present (Corresponding_Record_Type (T)) and then Is_Itype (Corresponding_Record_Type (T)) and then Is_Record_Type (Scope (Corresponding_Record_Type (T))) then Undelay_Type (Corresponding_Record_Type (T)); end if; end Undelay_Type; ------------------ -- Warn_Overlay -- ------------------ procedure Warn_Overlay (Expr : Node_Id; Typ : Entity_Id; Nam : Entity_Id) is Ent : constant Entity_Id := Entity (Nam); -- The object to which the address clause applies Init : Node_Id; Old : Entity_Id := Empty; Decl : Node_Id; begin -- No warning if address clause overlay warnings are off if not Address_Clause_Overlay_Warnings then return; end if; -- No warning if there is an explicit initialization Init := Original_Node (Expression (Declaration_Node (Ent))); if Present (Init) and then Comes_From_Source (Init) then return; end if; -- We only give the warning for non-imported entities of a type for -- which a non-null base init proc is defined, or for objects of access -- types with implicit null initialization, or when Normalize_Scalars -- applies and the type is scalar or a string type (the latter being -- tested for because predefined String types are initialized by inline -- code rather than by an init_proc). Note that we do not give the -- warning for Initialize_Scalars, since we suppressed initialization -- in this case. Also, do not warn if Suppress_Initialization is set -- either on the type, or on the object via pragma or aspect. if Present (Expr) and then not Is_Imported (Ent) and then not Initialization_Suppressed (Typ) and then not (Ekind (Ent) = E_Variable and then Initialization_Suppressed (Ent)) and then (Has_Non_Null_Base_Init_Proc (Typ) or else Is_Access_Type (Typ) or else (Normalize_Scalars and then (Is_Scalar_Type (Typ) or else Is_String_Type (Typ)))) then if Nkind (Expr) = N_Attribute_Reference and then Is_Entity_Name (Prefix (Expr)) then Old := Entity (Prefix (Expr)); elsif Is_Entity_Name (Expr) and then Ekind (Entity (Expr)) = E_Constant then Decl := Declaration_Node (Entity (Expr)); if Nkind (Decl) = N_Object_Declaration and then Present (Expression (Decl)) and then Nkind (Expression (Decl)) = N_Attribute_Reference and then Is_Entity_Name (Prefix (Expression (Decl))) then Old := Entity (Prefix (Expression (Decl))); elsif Nkind (Expr) = N_Function_Call then return; end if; -- A function call (most likely to To_Address) is probably not an -- overlay, so skip warning. Ditto if the function call was inlined -- and transformed into an entity. elsif Nkind (Original_Node (Expr)) = N_Function_Call then return; end if; -- If a pragma Import follows, we assume that it is for the current -- target of the address clause, and skip the warning. There may be -- a source pragma or an aspect that specifies import and generates -- the corresponding pragma. These will indicate that the entity is -- imported and that is checked above so that the spurious warning -- (generated when the entity is frozen) will be suppressed. The -- pragma may be attached to the aspect, so it is not yet a list -- member. if Is_List_Member (Parent (Expr)) then Decl := Next (Parent (Expr)); if Present (Decl) and then Nkind (Decl) = N_Pragma and then Pragma_Name (Decl) = Name_Import then return; end if; end if; -- Otherwise give warning message if Present (Old) then Error_Msg_Node_2 := Old; Error_Msg_N ("default initialization of & may modify &??", Nam); else Error_Msg_N ("default initialization of & may modify overlaid storage??", Nam); end if; -- Add friendly warning if initialization comes from a packed array -- component. if Is_Record_Type (Typ) then declare Comp : Entity_Id; begin Comp := First_Component (Typ); while Present (Comp) loop if Nkind (Parent (Comp)) = N_Component_Declaration and then Present (Expression (Parent (Comp))) then exit; elsif Is_Array_Type (Etype (Comp)) and then Present (Packed_Array_Impl_Type (Etype (Comp))) then Error_Msg_NE ("\packed array component& " & "will be initialized to zero??", Nam, Comp); exit; else Next_Component (Comp); end if; end loop; end; end if; Error_Msg_N ("\use pragma Import for & to " & "suppress initialization (RM B.1(24))??", Nam); end if; end Warn_Overlay; end Freeze;
oeis/196/A196288.asm
neoneye/loda-programs
11
80654
; A196288: n^8 + n. ; 0,2,258,6564,65540,390630,1679622,5764808,16777224,43046730,100000010,214358892,429981708,815730734,1475789070,2562890640,4294967312,6975757458,11019960594,16983563060,25600000020,37822859382,54875873558,78310985304,110075314200,152587890650,208827064602,282429536508,377801998364,500246412990,656100000030,852891037472,1099511627808,1406408618274,1785793904930,2251875390660,2821109907492,3512479453958,4347792138534,5352009260520,6553600000040,7984925229162,9682651996458,11688200277644 mov $1,$0 pow $1,8 add $0,$1
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xca.log_21829_572.asm
ljhsiun2/medusa
9
284
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r13 push %r14 push %r8 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x16ea, %r8 nop nop nop nop nop xor %rbx, %rbx movl $0x61626364, (%r8) nop nop nop nop nop sub $51861, %r10 lea addresses_normal_ht+0x103e6, %r10 nop nop nop and $32802, %rdx movb $0x61, (%r10) nop nop inc %r13 lea addresses_normal_ht+0x12d2a, %r10 nop nop add $29757, %rbx movups (%r10), %xmm4 vpextrq $1, %xmm4, %r11 nop nop cmp $2089, %rbx lea addresses_A_ht+0x101f2, %rdx nop nop nop nop inc %r14 movb (%rdx), %r10b nop nop nop xor %r10, %r10 lea addresses_A_ht+0x17ae6, %rsi lea addresses_WC_ht+0x148be, %rdi nop nop nop nop add %r11, %r11 mov $65, %rcx rep movsl nop nop nop nop add %rdx, %rdx lea addresses_D_ht+0x8666, %rdx nop nop nop and $41551, %rdi mov (%rdx), %r13d add %rdi, %rdi lea addresses_WT_ht+0x13a6e, %rsi lea addresses_UC_ht+0xfde6, %rdi clflush (%rsi) nop nop nop nop nop xor $54353, %r10 mov $89, %rcx rep movsw nop cmp %rsi, %rsi lea addresses_UC_ht+0xa5e6, %r14 clflush (%r14) nop nop and %r8, %r8 movups (%r14), %xmm1 vpextrq $1, %xmm1, %r11 nop and $48844, %rbx lea addresses_D_ht+0x11850, %r8 nop nop nop nop cmp %r11, %r11 vmovups (%r8), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $0, %xmm0, %rbx nop and %r10, %r10 lea addresses_normal_ht+0x58e6, %rbx nop nop nop nop nop add $41068, %rsi mov (%rbx), %r8 nop nop nop nop nop add $14521, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r8 pop %r14 pop %r13 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r15 push %r9 push %rax push %rdi push %rdx // Load lea addresses_D+0xbcde, %r15 nop nop nop nop nop xor $52640, %r13 mov (%r15), %r9d nop nop cmp %r13, %r13 // Store lea addresses_UC+0xd4e6, %rdi clflush (%rdi) nop nop nop cmp $21514, %rax movw $0x5152, (%rdi) sub %rdx, %rdx // Store mov $0xfe6, %r9 nop nop cmp $25675, %r14 movl $0x51525354, (%r9) sub %r14, %r14 // Faulty Load lea addresses_PSE+0x8de6, %r13 nop nop nop nop add $15205, %r14 movb (%r13), %al lea oracles, %rdx and $0xff, %rax shlq $12, %rax mov (%rdx,%rax,1), %rax pop %rdx pop %rdi pop %rax pop %r9 pop %r15 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 8}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_PSE', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_UC_ht', 'same': True, 'AVXalign': False, 'congruent': 2}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 1}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_D_ht', 'same': True, 'AVXalign': False, 'congruent': 6}} {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_WT_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 7}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 1}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 8}} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
Task/Ethiopian-multiplication/Ada/ethiopian-multiplication.ada
LaudateCorpus1/RosettaCodeData
1
26512
with ada.text_io;use ada.text_io; procedure ethiopian is function double (n : Natural) return Natural is (2*n); function halve (n : Natural) return Natural is (n/2); function is_even (n : Natural) return Boolean is (n mod 2 = 0); function mul (l, r : Natural) return Natural is (if l = 0 then 0 elsif l = 1 then r elsif is_even (l) then mul (halve (l),double (r)) else r + double (mul (halve (l), r))); begin put_line (mul (17,34)'img); end ethiopian;
oeis/001/A001656.asm
neoneye/loda-programs
11
24535
<filename>oeis/001/A001656.asm ; A001656: Fibonomial coefficients. ; 1,5,40,260,1820,12376,85085,582505,3994320,27372840,187628376,1285992240,8814405145,60414613805,414088493560,2838203264876,19453338487220,133335155341960,913892777190965,6263914210945105,42933506893289376,294270633534536400,2016960929177233200,13824455867227336800,94754230150521634225,649455155162580332501,4451431856049964494280,30510567837023743494740,209122543003544099066060,1433347233186664800308920,9824308089306042092975501,67336809391947952230540985,461533357654349723790868080 add $0,1 seq $0,166536 ; A product of consecutive doubled Fibonacci numbers. bin $0,2 div $0,3
asm/bootloader/print_pm.asm
damilolarandolph/pong-os
2
4825
<reponame>damilolarandolph/pong-os [bits 32] VIDEO_MEMORY equ 0xb8000 print_string_pm: pusha mov edx, VIDEO_MEMORY mov ah, 0x0f .printchar: mov al, [ebx] cmp al, 0 je .done mov [edx], ax add edx, 2 inc ebx jmp .printchar .done: popa ret
programs/oeis/059/A059570.asm
neoneye/loda
22
244900
<reponame>neoneye/loda<gh_stars>10-100 ; A059570: Number of fixed points in all 231-avoiding involutions in S_n. ; 1,2,6,14,34,78,178,398,882,1934,4210,9102,19570,41870,89202,189326,400498,844686,1776754,3728270,7806066,16311182,34020466,70837134,147266674,305718158,633805938,1312351118,2714180722,5607318414,11572550770,23860929422,49153514610,101170340750,208067304562,427587855246,878082202738,1801977389966,3695580748914,7574413435790,15515330747506,31763669246862,64993353997426,132918739002254,271701540019314,555131204068238,1133718656195698,2314349808509838,4722524609256562,9632699202986894,19640698374921330,40031996687737742,81565193251265650,166132786254111630,338270372011383922,688550343029089166,1401119884070820978,2850278164166927246,5796633120384425074,11785419824869991310,23955146817942264946,48678907972289094542,98895044617387318386,200864546580392895374,407878007852022307954,828053845086517650318,1680703348937981369458,3410598015405854876558,6919578665871494028402,14035922601862556607374,28465375743964250315890,57717812568406774834062,117009747297770098072690,237167738917453292954510,480631966478732779527282,973856910245117946291086,1972899775065540667055218,3996171459281690883056526,8093086736864600864005234,16387661110331639923794830,33178297493868156239158386,67162545534146065261454222,135936992161111636089183346,275097786507862283310916494,556643177387002588886932594,1126181563516561222304064398,2278153544518234533668527218,4607887924006693245457851278,9318937517953834847157296242,18844198375788566406797779854,38101043431338926238561934450,77027380222201439327056618382,155705347163450052353978735730,314711867764994452107688469390,636026082406177599014838934642,1285256858564732587628601861006,2596923104634219954455051705458,5246664984277949467305799377806,10598967518574918051402990689394,21409210137187874336388765246350 add $0,1 seq $0,66373 ; a(n) = (3*n-2)*2^(n-3). mul $0,2 mov $1,4 add $1,$0 div $1,18 mov $0,$1
other.7z/SFC.7z/SFC/ソースデータ/ゼルダの伝説神々のトライフォース/日本_Ver3/asm/bged_dt0.asm
prismotizm/gigaleak
0
243134
Name: bged_dt0.asm Type: file Size: 174050 Last-Modified: '2016-05-13T04:36:32Z' SHA-1: 6A6156C3E2B4DE6882B90BEB98501DF04CDC1764 Description: null
oeis/291/A291006.asm
neoneye/loda-programs
11
18141
; A291006: p-INVERT of (1,1,1,1,1,...), where p(S) = 1 - S - S^2 - S^3 - S^4. ; Submitted by <NAME>(s4) ; 1,3,9,27,80,235,688,2013,5891,17244,50482,147791,432672,1266680,3708288,10856241,31782309,93044665,272394011,797450348,2334585333,6834643282,20008841823,58577124509,171488162320,502042223184,1469759722591,4302812676894,12596750780526,36877768599840,107961953093765,316065308676367,925300779450229,2708875377802959,7930400552377400,23216739107488335,67968442605790000,198981828105504761,582531633773756415,1705397460551995652,4992656758597165506,14616312083106896043,42790159476295373664 lpb $0 sub $0,1 add $1,1 add $3,$2 add $2,1 sub $3,$4 add $3,$1 add $4,$2 add $1,$4 add $2,$3 lpe mov $0,$2 add $0,1
stdlib/src/font.asm
brian-kelley/GoldOS
5
3280
bits 32 global fontbin section .data align 4 ; Font bitmap credit: https://github.com/dhepper/font8x8 ; To get glyph for character c, take 8 bytes starting at address: ; fontbin + (c - '!') << 3 fontbin: incbin "stdlib/src/font.bin"
tools/xml2ayacc/tokens.adb
faelys/gela-asis
4
14728
------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ with Gela.Containers.Lists; with Text_Streams.File; with XML_IO.Stream_Readers; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package body Tokens is package Unbounded_String_Lists is new Gela.Containers.Lists (Unbounded_String, "="); type Delimiter is record Name : Unbounded_String; Text : Unbounded_String; end record; function "=" (Left, Right : Delimiter) return Boolean; package Delimiter_Lists is new Gela.Containers.Lists (Delimiter, "="); All_Delimiters : Delimiter_Lists.List; All_Tokens : Unbounded_String_Lists.List; All_Keywords : Unbounded_String_Lists.List; function "=" (Left, Right : Delimiter) return Boolean is begin return Left.Text = Right.Text; end "="; -------------------- -- Delimiter_Name -- -------------------- function Delimiter_Name (Text : String) return String is use Delimiter_Lists; To_Find : constant Delimiter := (Name => Null_Unbounded_String, Text => To_Unbounded_String (Text)); Found : constant Cursor := Find (All_Delimiters, To_Find); begin if Has_Element (Found) then return To_String (Element (Found).Name); else return ""; end if; end Delimiter_Name; -------------- -- Is_Token -- -------------- function Is_Token (Name : String) return Boolean is use Unbounded_String_Lists; To_Find : constant Unbounded_String := To_Unbounded_String (Name); begin return Contains (All_Tokens, To_Find); end Is_Token; --------------- -- Read_File -- --------------- procedure Read_File (Name : String) is use XML_IO; package R renames XML_IO.Stream_Readers; Stream : aliased Text_Streams.File.File_Text_Stream; Parser : R.Reader (Stream'Access, R.Default_Buffer_Size); function Get_Attribute (Name : String) return Unbounded_String is begin return To_Unbounded_String (R.Attribute_Value (Parser, Name)); end Get_Attribute; procedure On_Element is use Unbounded_String_Lists; Local_Name : constant String := R.Name (Parser); begin if Local_Name = "token" then if Get_Attribute ("type") = "yes" then Append (All_Tokens, Get_Attribute ("name")); end if; elsif Local_Name = "keyword" then Append (All_Keywords, Get_Attribute ("name")); elsif Local_Name = "delimiter" then declare use Delimiter_Lists; Delim : constant Delimiter := (Name => Get_Attribute ("name"), Text => Get_Attribute ("text")); begin Append (All_Delimiters, Delim); end; end if; end On_Element; begin Text_Streams.File.Open (Stream, Name); R.Initialize (Parser); while R.More_Pieces (Parser) loop case R.Piece_Kind (Parser) is when Start_Element => On_Element; when others => null; end case; R.Next (Parser); end loop; end Read_File; ------------------- -- For_Each_Name -- ------------------- procedure For_Each_Name is use Unbounded_String_Lists; C : Cursor; D : Delimiter_Lists.Cursor; begin C := First (All_Tokens); while Has_Element (C) loop Action (To_String (Element (C))); C := Next (C); end loop; D := Delimiter_Lists.First (All_Delimiters); while Delimiter_Lists.Has_Element (D) loop Action (To_String (Delimiter_Lists.Element (D).Name)); D := Delimiter_Lists.Next (D); end loop; C := First (All_Keywords); while Has_Element (C) loop Action (To_String (Element (C))); C := Next (C); end loop; end For_Each_Name; ------------------ -- Token_Length -- ------------------ function Token_Length (Name : String) return Natural is use Delimiter_Lists; C : Cursor; begin C := First (All_Delimiters); while Has_Element (C) loop declare X : constant Delimiter := Element (C); begin if X.Name = Name then return Length (X.Text); end if; end; C := Next (C); end loop; if Unbounded_String_Lists.Contains (All_Tokens, To_Unbounded_String (Name)) then return 0; end if; return Name'Length; end Token_Length; end Tokens; ------------------------------------------------------------------------------ -- Copyright (c) 2006, <NAME> -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * Neither the name of the <NAME>, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------
Task/Day-of-the-week/AppleScript/day-of-the-week-1.applescript
LaudateCorpus1/RosettaCodeData
1
889
<reponame>LaudateCorpus1/RosettaCodeData<filename>Task/Day-of-the-week/AppleScript/day-of-the-week-1.applescript set ChristmasSundays to {} set Christmas to (current date) set month of Christmas to December set day of Christmas to 25 repeat with year from 2008 to 2121 set year of Christmas to year if weekday of Christmas is Sunday then set end of ChristmasSundays to year end repeat ChristmasSundays
source/RunImage.adb
bracke/Meaning
0
21134
<reponame>bracke/Meaning with Main; procedure RunImage is --pragma Suppress(All_Checks); begin Main.Main; end RunImage;
libsrc/math/genmath/c/sccz80/dleq.asm
jpoikela/z88dk
640
7062
<gh_stars>100-1000 ; ; Z88dk Generic Floating Point Math Library ; ; TOS >= FA ; ; $Id: dleq.asm,v 1.3 2016-06-21 21:16:49 dom Exp $: SECTION code_fp PUBLIC dleq EXTERN dcompar EXTERN f_yes EXTERN f_no .dleq call dcompar jp z,f_yes jp p,f_yes jp f_no
source/main.ads
bracke/Ext2Dir
1
19777
-- StrongEd$WrapWidth=256 -- StrongEd$Mode=Ada -- with RASCAL.Utility; use RASCAL.Utility; package Main is type Names is array(natural range <>) of ustring; type Options is (Remove_Extension,Change_Name,Set_FileType, Set_Access,Remove_Original,Verbose,Help,Descend,Move_Sub_Content); type Bit_Array is array (Options'Range) of Boolean; type Path_Variables is (source,target); type String_Array is array (Path_Variables'Range) of ustring; Bits : Bit_Array := (others => false); Paths : String_Array := (U(""),U("")); -- procedure Main; -- procedure Proces_File(FilePath : in string; Target : in String); -- procedure Proces_Dir (Path : in String; Target : in String); -- procedure Help; ---- end Main;
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c35102a.ada
best08618/asylo
7
14928
-- C35102A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT AN ENUMERATION LITERAL BELONGING TO ONE ENUMERATION TYPE -- MAY BE DECLARED IN ANOTHER ENUMERATION TYPE DEFINITION IN THE SAME -- DECLARATIVE REGION. -- R.WILLIAMS 8/20/86 -- GMT 6/30/87 MOVED THE CALL TO REPORT.TEST INTO A NEWLY -- CREATED PACKAGE NAMED SHOW_TEST_HEADER. -- ADDED CODE FOR MY_PACK AND MY_FTN. WITH REPORT; USE REPORT; PROCEDURE C35102A IS TYPE E1 IS ('A', 'B', 'C', RED, YELLOW, BLUE); TYPE E2 IS ('A', 'C', RED, BLUE); PACKAGE SHOW_TEST_HEADER IS -- PURPOSE OF THIS PACKAGE: -- WE WANT THE TEST HEADER INFORMATION TO BE -- PRINTED BEFORE ANY OF THE PASS/FAIL MESSAGES. END SHOW_TEST_HEADER; PACKAGE BODY SHOW_TEST_HEADER IS BEGIN TEST ( "C35102A", "CHECK THAT AN ENUMERATION LITERAL BELONGING " & "TO ONE ENUMERATION TYPE MAY BE DECLARED IN " & "ANOTHER ENUMERATION TYPE DEFINITION IN THE " & "SAME DECLARATIVE REGION" ); END SHOW_TEST_HEADER; FUNCTION MY_FTN ( E : E1 ) RETURN E2 IS TYPE ENUM1 IS ('A', 'B', 'C', RED, YELLOW, BLUE); TYPE ENUM2 IS ('A', 'C', RED, BLUE); BEGIN IF ENUM2'SUCC ('A') /= 'C' THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN MY_FTN - 1" ); END IF; IF ENUM1'POS (RED) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN ENUM1 " & "IN MY_FTN - 1" ); END IF; RETURN E2'VAL ( IDENT_INT ( E1'POS(E) ) ); END MY_FTN; PACKAGE MY_PACK IS END MY_PACK; PACKAGE BODY MY_PACK IS TYPE ENUM1 IS ('A', 'B', 'C', RED, YELLOW, BLUE); TYPE ENUM2 IS ('A', 'C', RED, BLUE); BEGIN -- MY_PACK IF ENUM2'SUCC ('A') /= 'C' THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN MY_PACK - 1" ); END IF; IF ENUM1'POS (RED) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN ENUM1 " & "IN MY_PACK - 1" ); END IF; END MY_PACK; PACKAGE PKG IS TYPE ENUM1 IS ('A', 'B', 'C', RED, YELLOW, BLUE); TYPE ENUM2 IS ('A', 'C', RED, BLUE); END PKG; PACKAGE BODY PKG IS BEGIN IF ENUM2'SUCC ('A') /= 'C' THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN PKG - 1" ); END IF; IF ENUM1'POS (RED) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN ENUM1 " & "IN PKG - 1" ); END IF; END PKG; PACKAGE PRIV IS TYPE ENUM1 IS PRIVATE; TYPE ENUM2 IS PRIVATE; FUNCTION FE1 (E : E1) RETURN ENUM1; FUNCTION FE2 (E : E2) RETURN ENUM2; PRIVATE TYPE ENUM1 IS ('A', 'B', 'C', RED, YELLOW, BLUE); TYPE ENUM2 IS ('A', 'C', RED, BLUE); END PRIV; PACKAGE BODY PRIV IS FUNCTION FE1 (E : E1) RETURN ENUM1 IS BEGIN RETURN ENUM1'VAL (IDENT_INT (E1'POS (E))); END FE1; FUNCTION FE2 (E : E2) RETURN ENUM2 IS BEGIN RETURN ENUM2'VAL (IDENT_INT (E2'POS (E))); END FE2; BEGIN IF ENUM2'SUCC ('A') /= 'C' THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN PRIV - 1" ); END IF; IF ENUM1'POS (RED) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN ENUM1 " & "IN PRIV - 1" ); END IF; END PRIV; PACKAGE LPRIV IS TYPE ENUM1 IS LIMITED PRIVATE; TYPE ENUM2 IS LIMITED PRIVATE; FUNCTION FE1 (E : E1) RETURN ENUM1; FUNCTION FE2 (E : E2) RETURN ENUM2; FUNCTION EQUALS (A, B : ENUM1) RETURN BOOLEAN; FUNCTION EQUALS (A, B : ENUM2) RETURN BOOLEAN; PRIVATE TYPE ENUM1 IS ('A', 'B', 'C', RED, YELLOW, BLUE); TYPE ENUM2 IS ('A', 'C', RED, BLUE); END LPRIV; PACKAGE BODY LPRIV IS FUNCTION FE1 (E : E1) RETURN ENUM1 IS BEGIN RETURN ENUM1'VAL (IDENT_INT (E1'POS (E))); END FE1; FUNCTION FE2 (E : E2) RETURN ENUM2 IS BEGIN RETURN ENUM2'VAL (IDENT_INT (E2'POS (E))); END FE2; FUNCTION EQUALS (A, B : ENUM1) RETURN BOOLEAN IS BEGIN IF A = B THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END EQUALS; FUNCTION EQUALS (A, B : ENUM2) RETURN BOOLEAN IS BEGIN IF A = B THEN RETURN TRUE; ELSE RETURN FALSE; END IF; END EQUALS; BEGIN IF ENUM2'SUCC ('A') /= 'C' THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN LPRIV - 1" ); END IF; IF ENUM1'POS (RED) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN ENUM1 " & "IN LPRIV - 2" ); END IF; END LPRIV; TASK T1; TASK BODY T1 IS TYPE ENUM1 IS ('A', 'B', 'C', RED, YELLOW, BLUE); TYPE ENUM2 IS ('A', 'C', RED, BLUE); BEGIN IF ENUM2'SUCC ('A') /= 'C' THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN T1" ); END IF; IF ENUM1'POS (RED) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN ENUM1 " & "IN T1" ); END IF; END T1; TASK T2 IS ENTRY E; END T2; TASK BODY T2 IS BEGIN ACCEPT E DO DECLARE TYPE ENUM1 IS ('A', 'B', 'C', RED, YELLOW, BLUE); TYPE ENUM2 IS ('A', 'C', RED, BLUE); BEGIN IF ENUM2'SUCC ('A') /= 'C' THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN T2.E" ); END IF; IF ENUM1'POS (RED) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN " & "ENUM1 IN T2.E" ); END IF; END; END E; END T2; GENERIC PROCEDURE GP1; PROCEDURE GP1 IS TYPE ENUM1 IS ('A', 'B', 'C', RED, YELLOW, BLUE); TYPE ENUM2 IS ('A', 'C', RED, BLUE); BEGIN IF ENUM2'SUCC ('A') /= 'C' THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN GP1" ); END IF; IF ENUM1'POS (RED) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN ENUM1 " & "IN GP1" ); END IF; END GP1; GENERIC TYPE E1 IS (<>); TYPE E2 IS (<>); PROCEDURE GP2; PROCEDURE GP2 IS BEGIN IF E2'SUCC (E2'VALUE ("'A'")) /= E2'VALUE ("'C'") THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN E2 " & "IN GP2" ); END IF; IF E1'POS (E1'VALUE ("RED")) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN E1 " & "IN GP2" ); END IF; END GP2; PROCEDURE NEWGP1 IS NEW GP1; PROCEDURE NEWGP2 IS NEW GP2 (E1, E2); BEGIN DECLARE TYPE ENUM1 IS ('A', 'B', 'C', RED, YELLOW, BLUE); TYPE ENUM2 IS ('A', 'C', RED, BLUE); BEGIN IF ENUM2'SUCC ('A') /= 'C' THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN BLOCK" ); END IF; IF ENUM1'POS (RED) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN ENUM1 " & "IN BLOCK" ); END IF; END; DECLARE USE PKG; BEGIN IF ENUM2'SUCC ('A') /= 'C' THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN PKG - 2" ); END IF; IF ENUM1'POS (RED) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN ENUM1 " & "IN PKG - 2" ); END IF; END; DECLARE USE PRIV; BEGIN IF FE2 (E2'SUCC('A')) /= FE2 ('C') THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN PRIV - 2" ); END IF; IF FE1 (RED) /= FE1 (E1'VAL (3)) THEN FAILED ( "RED NOT DECLARED CORRECTLY IN ENUM1 " & "IN PRIV - 2" ); END IF; END; DECLARE USE LPRIV; BEGIN IF NOT EQUALS (FE2 (E2'SUCC('A')), FE2 ('C')) THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN ENUM2 " & "IN LPRIV - 2" ); END IF; IF NOT EQUALS (FE1 (RED), FE1 (E1'VAL (3))) THEN FAILED ( "RED NOT DECLARED CORRECTLY IN ENUM1 " & "IN LPRIV - 2" ); END IF; END; BEGIN IF E2'SUCC ('A') /= 'C' THEN FAILED ( "'A' NOT DECLARED CORRECTLY IN E2" ); END IF; IF E1'POS (RED) /= 3 THEN FAILED ( "RED NOT DECLARED CORRECTLY IN E1" ); END IF; END; NEWGP1; NEWGP2; T2.E; RESULT; END C35102A;
Transynther/x86/_processed/NONE/_st_/i9-9900K_12_0xa0.log_21829_1054.asm
ljhsiun2/medusa
9
18267
<reponame>ljhsiun2/medusa<filename>Transynther/x86/_processed/NONE/_st_/i9-9900K_12_0xa0.log_21829_1054.asm .global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r14 push %r15 push %r8 push %rcx push %rdi push %rsi lea addresses_WT_ht+0x10a86, %rsi lea addresses_normal_ht+0x1e55a, %rdi sub $54682, %r14 mov $121, %rcx rep movsw add %r14, %r14 lea addresses_D_ht+0x2ea6, %r13 clflush (%r13) nop nop nop and $13397, %r15 movw $0x6162, (%r13) nop add $20106, %rsi lea addresses_WC_ht+0x1d51a, %rdi nop nop nop cmp $61773, %r15 movups (%rdi), %xmm4 vpextrq $1, %xmm4, %r14 cmp $1445, %rcx lea addresses_A_ht+0x12f06, %r13 nop nop nop mfence movups (%r13), %xmm3 vpextrq $1, %xmm3, %r15 and $7539, %r15 lea addresses_A_ht+0x15166, %r14 nop nop nop nop cmp $24972, %rdi mov $0x6162636465666768, %r15 movq %r15, (%r14) nop nop inc %rdi lea addresses_normal_ht+0x107a6, %rdi nop nop nop nop and %rsi, %rsi mov $0x6162636465666768, %r14 movq %r14, (%rdi) nop nop nop cmp %r15, %r15 lea addresses_WT_ht+0xccbe, %rsi nop nop nop add $4838, %rcx mov (%rsi), %rdi and $61938, %r13 lea addresses_A_ht+0x7ca6, %rsi lea addresses_normal_ht+0x1b8a6, %rdi xor %r12, %r12 mov $116, %rcx rep movsw nop nop nop nop inc %rsi lea addresses_WT_ht+0x11ca6, %rsi lea addresses_WT_ht+0x41c2, %rdi nop nop and $2700, %r8 mov $110, %rcx rep movsw nop nop add %r14, %r14 lea addresses_normal_ht+0x1dc78, %rsi lea addresses_UC_ht+0xfea6, %rdi nop xor %r15, %r15 mov $124, %rcx rep movsw cmp %rsi, %rsi lea addresses_WT_ht+0xf8d6, %rsi lea addresses_UC_ht+0x1a2a6, %rdi nop nop nop nop nop add $6884, %r14 mov $98, %rcx rep movsw nop nop nop nop nop and $51420, %r13 pop %rsi pop %rdi pop %rcx pop %r8 pop %r15 pop %r14 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r15 push %rbp push %rbx push %rcx push %rdx // Store mov $0x560ddc0000000906, %r14 nop nop nop nop nop cmp %r15, %r15 movb $0x51, (%r14) nop xor $25246, %r15 // Store lea addresses_UC+0x6a6, %r15 nop nop nop nop sub $18031, %rcx movb $0x51, (%r15) nop nop cmp $10261, %r14 // Store mov $0xaa6, %r10 nop nop nop nop nop xor %rbx, %rbx mov $0x5152535455565758, %r14 movq %r14, %xmm4 vmovups %ymm4, (%r10) dec %rdx // Faulty Load lea addresses_WT+0x9aa6, %rbp clflush (%rbp) nop nop nop nop dec %r10 mov (%rbp), %ecx lea oracles, %rdx and $0xff, %rcx shlq $12, %rcx mov (%rdx,%rcx,1), %rcx pop %rdx pop %rcx pop %rbx pop %rbp pop %r15 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 5, 'type': 'addresses_NC', 'AVXalign': False, 'size': 1}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_UC', 'AVXalign': True, 'size': 1}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_P', 'AVXalign': False, 'size': 32}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WT', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 2}} {'src': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 8}} {'src': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 7, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_normal_ht'}} {'src': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_WT_ht'}} {'src': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_UC_ht'}} {'src': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 10, 'type': 'addresses_UC_ht'}} {'58': 21829} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
oeis/145/A145697.asm
neoneye/loda-programs
11
104800
<reponame>neoneye/loda-programs ; A145697: Numbers n such that there exists x in N with (x+37)^3-x^3=n^2. ; Submitted by <NAME> ; 1369,806341,475739821,280685688049,165604080209089,97706126637674461,57646449112147722901,34011307270040518837129,20066613642874793966183209,11839268037988858399529256181,6985148075799783580928294963581,4121225525453834323889294499256609,2431516074869686451311102826266435729,1434590362947589552439226778202697823501,846405882623002966252692488036765449429861,499378036157208802499536128714913412465794489,294632194926870570471760063249310876589369318649 mov $2,1 mov $3,1 lpb $0 sub $0,1 mov $1,$3 mul $1,588 add $2,$1 add $3,$2 lpe mov $0,$2 mul $0,1369
oeis/037/A037562.asm
neoneye/loda-programs
11
15962
; A037562: Base 5 digits are, in order, the first n terms of the periodic sequence with initial period 2,2,1. ; Submitted by <NAME>(s4) ; 2,12,61,307,1537,7686,38432,192162,960811,4804057,24020287,120101436,600507182,3002535912,15012679561,75063397807,375316989037,1876584945186,9382924725932,46914623629662,234573118148311,1172865590741557 add $0,1 mov $1,5 pow $1,$0 add $1,47 mov $2,$1 mul $1,2 div $2,31 sub $1,$2 sub $1,18 div $1,4 mov $0,$1 sub $0,19
4 专业科目/计算机组成/习题/hw/自己动手写CPU/Code/Chapter7_2/AsmTest/inst_rom.asm
ladike/912_project
640
81257
inst_rom.om: file format elf32-tradbigmips Disassembly of section .text: 00000000 <_start>: 0: 3401ffff li at,0xffff 4: 00010c00 sll at,at,0x10 8: 3421fffb ori at,at,0xfffb c: 34020006 li v0,0x6 10: 00220018 mult at,v0 14: 70220000 madd at,v0 18: 70220001 maddu at,v0 1c: 70220004 msub at,v0 20: 70220005 msubu at,v0 Disassembly of section .reginfo: 00000000 <_ram_end-0x30>: 0: 00000006 srlv zero,zero,zero ...
loaders_patches_etc/init_and_patch_sarlmoor.asm
alexanderbazhenoff/zx-spectrum-various
0
240798
CHEAT EQU #FF ;0 - cheat off ORG #5B14 DB CHEAT ORG #60AE INCBIN "sarlmoor" ;clear original ROM font ORG #FCB2 DUP #130 DB 0 EDUP ;clear data garbage ORG #FEAE DUP #100 DB 0 EDUP ORG #60AE DUP 4 DB 0 EDUP ORG #60B8 DI ;correct CLS MACRO CLS CALL #7CC3 CALL #7CE1 ENDM ORG #C219 CLS ORG #C268 CLS ORG #C3AC CLS ORG #C484 CLS ORG #7CC3 CALL CLS0002 ORG #7CD2 CALL CLS0002 ORG #7CE1 LD HL,#5800 XOR A CLS0001 DEC HL LD (HL),A CP (HL) JR Z,CLS0001 RET CLS0002 EI HALT LD HL,#5800 RET ;correct 'game over' & 'congratulations' string routines ORG #C4E5 CALL KPAUS11 KPAUS12 CALL KEY_RQ JR Z,KPAUS12 RET ORG #C519 JR #C4E5 ;correct 'slides' routines ORG #C98E GR_MTK LD B,7 GR_MTK0 EI HALT JR #C9A0 DUP 6 DB 0 EDUP ORG #C6AE LD B,6 ORG #C6D1 LD B,6 ORG #C6F4 LD B,6 ORG #C717 LD B,6 ORG #C739 LD B,6 ORG #C918 CALL SYNCP01 LD B,15 ORG #C92A CALL SYNCP01 LD B,15 ORG #C93C CALL SYNCP01 LD B,15 ORG #C94E CALL SYNCP01 LD B,15 ORG #C962 CALL SYNCP01 LD B,15 ;correct border colour on the start of this program ORG #60B9 CALL #7CB2 ;optimizing sprite output routines ORG #CA3A OR A RET Z LD C,A ADD HL,BC JR #CA19 DUP 5 DB 0 EDUP ORG #CA02 LD B,22 PAUS000 EI HALT DJNZ PAUS000 RET KEY_RQ XOR A KEY_RQ1 IN A,(#FE) CPL AND #1F RET ORG #6000 LD A,(#5B14) OR A JR Z,NOCHEAT XOR A LD H,A LD L,A LD (#9E48+1),HL LD (#9EEF+1),HL LD (#87C2+1),HL LD (#AE92+1),HL LD (#9E48),A LD (#9EEF),A LD (#87C2),A LD (#AE92),A LD A,#C9 LD (#AE1D),A LD (#BC83),A LD A,#B7 LD (#A342),A LD HL,#82B0 LD DE,#82B1 LD BC,#8395-#82B0 LD (HL),B LDIR LD A,#CD LD (#9D9F),A LD (#9DE2),A LD (#AEEE),A LD (#B764),A LD (#AEA9),A LD HL,SYNCP02 LD (#AEA9+1),HL LD HL,SKPLEV1 LD (#9D9F+1),HL LD (#9DE2+1),HL LD HL,SKPLEV2 LD (#AEEE+1),HL LD HL,SKPLEV3 LD (#B764+1),HL NOCHEAT JR #60B2 SYNCP01 EI HALT LD BC,#700 CALL SYNCPL JP #CA19 SYNCP02 LD BC,#700 SYNCPL DEC BC LD A,B OR C JR NZ,SYNCPL RET KPAUS11 CALL KEY_RQ JR NZ,KPAUS11 RET CHEATK LD A,#FB CALL KEY_RQ1 CP 4+8+16 RET SKPLEV1 CALL CHEATK LD A,(#6822) RET NZ LD A,1 RET SKPLEV2 CALL CHEATK LD A,(#6822) RET NZ LD A,2 LD (#6D94),A DEC A RET SKPLEV3 CALL CHEATK LD A,(#6822) RET NZ LD A,4 LD (#60E1),A LD A,1 RET RET
Code/CustomControl/RAHexEd/Src/Undo.asm
CherryDT/FbEditMOD
11
93896
<reponame>CherryDT/FbEditMOD .code ExpandUndoMem proc uses ebx edi,hMem:DWORD,cb:DWORD invoke GetProcessHeap mov edi,eax mov ebx,hMem mov eax,[ebx].EDIT.rpundo add eax,cb add eax,sizeof HEUNDO*2 .if eax>[ebx].EDIT.cbundo and eax,-1 xor (MAXUNDOMEM-1) add eax,MAXUNDOMEM mov [ebx].EDIT.cbundo,eax invoke HeapReAlloc,edi,HEAP_GENERATE_EXCEPTIONS or HEAP_NO_SERIALIZE or HEAP_ZERO_MEMORY,[ebx].EDIT.hundo,[ebx].EDIT.cbundo .if !eax invoke MessageBox,[ebx].EDIT.hwnd,offset szMemFailUndo,offset szToolTip,MB_OK xor eax,eax .else mov [ebx].EDIT.hundo,eax .endif .endif ret ExpandUndoMem endp DoUndo proc uses ebx esi edi,hMem:DWORD mov ebx,hMem mov edi,[ebx].EDIT.hundo mov edx,[ebx].EDIT.rpundo .if edx mov edx,[edi+edx].HEUNDO.rpPrev mov [ebx].EDIT.rpundo,edx mov al,[edi+edx].HEUNDO.fun .if al==UNDO_CHARINSERT lea edi,[edi+edx] mov esi,[edi].HEUNDO.cp mov [ebx].EDIT.cpMin,esi mov [ebx].EDIT.cpMax,esi shr esi,1 invoke DeleteChars,ebx,esi,1 .elseif al==UNDO_CHAROVERWRITE lea edi,[edi+edx] mov esi,[edi].HEUNDO.cp mov [ebx].EDIT.cpMin,esi mov [ebx].EDIT.cpMax,esi shr esi,1 invoke GetChar,ebx,esi push eax invoke PutChar,ebx,esi,addr [edi+sizeof HEUNDO],1 pop eax mov [edi+sizeof HEUNDO],al .elseif al==UNDO_INSERTBLOCK lea edi,[edi+edx] mov esi,[edi].HEUNDO.cp mov [ebx].EDIT.cpMin,esi mov [ebx].EDIT.cpMax,esi shr esi,1 invoke DeleteChars,ebx,esi,[edi].HEUNDO.cb .elseif al==UNDO_DELETEBLOCK lea edi,[edi+edx] mov esi,[edi].HEUNDO.cp mov [ebx].EDIT.cpMin,esi shr esi,1 invoke InsertChars,ebx,esi,[edi].HEUNDO.cb invoke PutChar,ebx,esi,addr [edi+sizeof HEUNDO],[edi].HEUNDO.cb add esi,[edi].HEUNDO.cb shl esi,1 mov [ebx].EDIT.cpMax,esi .endif .endif ret DoUndo endp DoRedo proc uses ebx esi edi,hMem:DWORD mov ebx,hMem mov edi,[ebx].EDIT.hundo mov edx,[ebx].EDIT.rpundo mov eax,[edi+edx].HEUNDO.cb .if eax mov al,[edi+edx].HEUNDO.fun .if al==UNDO_CHARINSERT lea edi,[edi+edx] mov esi,[edi].HEUNDO.cp mov [ebx].EDIT.cpMin,esi mov [ebx].EDIT.cpMax,esi shr esi,1 invoke InsertChars,ebx,esi,1 invoke PutChar,ebx,esi,addr [edi+sizeof HEUNDO],1 inc [ebx].EDIT.cpMin inc [ebx].EDIT.cpMax add [ebx].EDIT.rpundo,sizeof HEUNDO+1 .elseif al==UNDO_CHAROVERWRITE lea edi,[edi+edx] mov esi,[edi].HEUNDO.cp mov [ebx].EDIT.cpMin,esi mov [ebx].EDIT.cpMax,esi shr esi,1 invoke GetChar,ebx,esi push eax invoke PutChar,ebx,esi,addr [edi+sizeof HEUNDO],1 pop eax mov [edi+sizeof HEUNDO],al inc [ebx].EDIT.cpMin inc [ebx].EDIT.cpMax add [ebx].EDIT.rpundo,sizeof HEUNDO+1 .elseif al==UNDO_INSERTBLOCK lea edi,[edi+edx] mov esi,[edi].HEUNDO.cp mov [ebx].EDIT.cpMin,esi mov [ebx].EDIT.cpMax,esi shr esi,1 invoke InsertChars,ebx,esi,[edi].HEUNDO.cb invoke PutChar,ebx,esi,addr [edi+sizeof HEUNDO],[edi].HEUNDO.cb mov eax,[edi].HEUNDO.cb add eax,sizeof HEUNDO add [ebx].EDIT.rpundo,eax .elseif al==UNDO_DELETEBLOCK lea edi,[edi+edx] mov esi,[edi].HEUNDO.cp mov [ebx].EDIT.cpMin,esi mov [ebx].EDIT.cpMax,esi shr esi,1 invoke DeleteChars,ebx,esi,[edi].HEUNDO.cb mov eax,[edi].HEUNDO.cb add eax,sizeof HEUNDO add [ebx].EDIT.rpundo,eax .endif .endif ret DoRedo endp SaveUndo proc uses ebx esi edi,hMem:DWORD,nFun:DWORD,cp:DWORD,cr:DWORD,cb:DWORD mov ebx,hMem invoke ExpandUndoMem,ebx,cb or eax,eax je Ex mov edi,[ebx].EDIT.hundo mov edx,[ebx].EDIT.rpundo mov eax,nFun .if eax==UNDO_CHARINSERT || eax==UNDO_CHAROVERWRITE lea edi,[edi+edx] mov [edi].HEUNDO.fun,al mov eax,cp mov [edi].HEUNDO.cp,eax mov [edi].HEUNDO.cb,1 mov eax,cr mov [edi+sizeof HEUNDO],al mov [edi+sizeof HEUNDO+1].HEUNDO.rpPrev,edx add [ebx].EDIT.rpundo,sizeof HEUNDO+1 .elseif eax==UNDO_INSERTBLOCK || eax==UNDO_DELETEBLOCK lea edi,[edi+edx] mov [edi].HEUNDO.fun,al mov esi,cp mov [edi].HEUNDO.cp,esi mov ecx,cb mov [edi].HEUNDO.cb,ecx mov eax,sizeof HEUNDO add eax,cb mov [edi+eax].HEUNDO.rpPrev,edx add eax,edx mov [ebx].EDIT.rpundo,eax shr esi,1 add edi,sizeof HEUNDO .while ecx push ecx invoke GetChar,ebx,esi pop ecx dec ecx mov [edi],al inc esi inc edi .endw .endif Ex: ret SaveUndo endp Undo proc uses ebx,hMem:DWORD,hWin:DWORD mov ebx,hMem invoke DoUndo,ebx invoke ScrollCaret,hWin invoke InvalidateRect,[ebx].EDIT.edta.hwnd,NULL,FALSE invoke InvalidateRect,[ebx].EDIT.edtb.hwnd,NULL,FALSE invoke SetCaret,hWin invoke SelChange,ebx,SEL_TEXT ret Undo endp Redo proc uses ebx,hMem:DWORD,hWin:DWORD mov ebx,hMem invoke DoRedo,ebx invoke ScrollCaret,hWin invoke InvalidateRect,[ebx].EDIT.edta.hwnd,NULL,FALSE invoke InvalidateRect,[ebx].EDIT.edtb.hwnd,NULL,FALSE invoke SetCaret,hWin invoke SelChange,ebx,SEL_TEXT ret Redo endp
src/Categories/Morphism/Properties.agda
MirceaS/agda-categories
0
10064
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Morphism.Properties {o ℓ e} (𝒞 : Category o ℓ e) where open import Data.Product using (_,_; _×_) open Category 𝒞 open HomReasoning import Categories.Morphism as M open M 𝒞 open import Categories.Morphism.Reasoning 𝒞 private variable A B C D : Obj f g h i : A ⇒ B module _ (iso : Iso f g) where open Iso iso Iso-resp-≈ : f ≈ h → g ≈ i → Iso h i Iso-resp-≈ {h = h} {i = i} eq₁ eq₂ = record { isoˡ = begin i ∘ h ≈˘⟨ eq₂ ⟩∘⟨ eq₁ ⟩ g ∘ f ≈⟨ isoˡ ⟩ id ∎ ; isoʳ = begin h ∘ i ≈˘⟨ eq₁ ⟩∘⟨ eq₂ ⟩ f ∘ g ≈⟨ isoʳ ⟩ id ∎ } Iso-swap : Iso g f Iso-swap = record { isoˡ = isoʳ ; isoʳ = isoˡ } Iso⇒Mono : Mono f Iso⇒Mono h i eq = begin h ≈⟨ introˡ isoˡ ⟩ (g ∘ f) ∘ h ≈⟨ pullʳ eq ⟩ g ∘ f ∘ i ≈⟨ cancelˡ isoˡ ⟩ i ∎ Iso⇒Epi : Epi f Iso⇒Epi h i eq = begin h ≈⟨ introʳ isoʳ ⟩ h ∘ f ∘ g ≈⟨ pullˡ eq ⟩ (i ∘ f) ∘ g ≈⟨ cancelʳ isoʳ ⟩ i ∎ Iso-∘ : Iso f g → Iso h i → Iso (h ∘ f) (g ∘ i) Iso-∘ {f = f} {g = g} {h = h} {i = i} iso iso′ = record { isoˡ = begin (g ∘ i) ∘ h ∘ f ≈⟨ cancelInner (isoˡ iso′) ⟩ g ∘ f ≈⟨ isoˡ iso ⟩ id ∎ ; isoʳ = begin (h ∘ f) ∘ g ∘ i ≈⟨ cancelInner (isoʳ iso) ⟩ h ∘ i ≈⟨ isoʳ iso′ ⟩ id ∎ } where open Iso Iso-≈ : f ≈ h → Iso f g → Iso h i → g ≈ i Iso-≈ {f = f} {h = h} {g = g} {i = i} eq iso iso′ = begin g ≈⟨ introˡ (isoˡ iso′) ⟩ (i ∘ h) ∘ g ≈˘⟨ (refl ⟩∘⟨ eq) ⟩∘⟨refl ⟩ (i ∘ f) ∘ g ≈⟨ cancelʳ (isoʳ iso) ⟩ i ∎ where open Iso module _ where open _≅_ isos×≈⇒≈ : ∀ {f g : A ⇒ B} → h ≈ i → (iso₁ : A ≅ C) → (iso₂ : B ≅ D) → CommutativeSquare f (from iso₁) (from iso₂) h → CommutativeSquare g (from iso₁) (from iso₂) i → f ≈ g isos×≈⇒≈ {h = h} {i = i} {f = f} {g = g} eq iso₁ iso₂ sq₁ sq₂ = begin f ≈⟨ switch-fromtoˡ iso₂ sq₁ ⟩ to iso₂ ∘ h ∘ from iso₁ ≈⟨ refl⟩∘⟨ (eq ⟩∘⟨refl ) ⟩ to iso₂ ∘ i ∘ from iso₁ ≈˘⟨ switch-fromtoˡ iso₂ sq₂ ⟩ g ∎
testfiles/stack.asm
ger-ald/pcmac
0
81048
<filename>testfiles/stack.asm ;STACK.ASM ;Demonstration program for the usage of stack directives NONADDRESS EQU -1 ;Any value that can not represent address #list off ;A simple jump instruction macro("JP *",NUMERIC) DB 0C3h DW #0 endm ;LOOP macro definition nestable with break macro("LOOP") #ifndef loop_stack var loop_stack,code_counter_store,address #stack loop_stack #endif #push loop_stack , NONADDRESS #push loop_stack , $ endm ;BREAK macro definition macro("BREAK") JP 0 ; We do not know the address now #push loop_stack , $-2 ;Store the address of ;the second byte of the instruction endm ;ENDLOOP macro definition that fills in the BREAK jumps macro("ENDLOOP") code_counter_store := $ address := pop(loop_stack) #while tos(loop_stack) != NONADDRESS $ := address DW code_counter_store+3 ; 3 is the length of ; the jump-back instruction address := pop(loop_stack) #wend $ := code_counter_store JP address #pop loop_stack endm #if pass = 2 #list on #endif LOOP ;* loop #1 LOOP ; * loop #2 BREAK BREAK ENDLOOP ; * endloop #2 BREAK LOOP ; * loop #3 BREAK ENDLOOP ; * endloop #3 BREAK ;End of file STACK.ASM
oeis/033/A033656.asm
neoneye/loda-programs
0
94658
<reponame>neoneye/loda-programs<gh_stars>0 ; A033656: Trajectory of 21 under map x->x + (x-with-digits-reversed). ; Submitted by <NAME>(w2) ; 21,33,66,132,363,726,1353,4884,9768,18447,92928,175857,934428,1758867,9447438,17794887,96644658,182289327,906271608,1712444217,8836886388,17673772776,85401510447,159803020905 mov $2,$0 lpb $2 mov $0,$1 add $0,21 seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences). add $1,$0 sub $2,1 lpe mov $0,$1 add $0,21
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/inline5_pkg.ads
best08618/asylo
7
26107
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/inline5_pkg.ads package Inline5_Pkg is procedure Test (I : Integer); pragma Inline (Test); end Inline5_Pkg;
test/Succeed/Issue899.agda
redfish64/autonomic-agda
3
10251
<reponame>redfish64/autonomic-agda -- Andreas, 2013-11-07 -- Instance candidates are now considered module judgemental equality. module Issue899 where postulate A B : Set f : {{ x : A }} → B instance a : A instance a' : A a' = a test : B test = f {- The previous code fails with the following message: Resolve implicit argument _x_257 : A. Candidates: [a : A, a : A] There are indeed two values in scope of type A (a and a'), but given that they are definitionally equal, Agda should not complain about it but just pick any one of them. -}
release/src/router/libpcap/msdos/ndis_0.asm
ghsecuritylab/tomato_egg
183
19538
<reponame>ghsecuritylab/tomato_egg<gh_stars>100-1000 PAGE 60,132 NAME NDIS_0 ifdef DOSX .386 _TEXT SEGMENT PUBLIC DWORD USE16 'CODE' _TEXT ENDS _DATA SEGMENT PUBLIC DWORD USE16 'CODE' _DATA ENDS _TEXT32 SEGMENT PUBLIC BYTE USE32 'CODE' _TEXT32 ENDS CB_DSEG EQU <CS> ; DOSX is tiny-model D_SEG EQU <_TEXT SEGMENT> D_END EQU <_TEXT ENDS> ASSUME CS:_TEXT,DS:_TEXT PUSHREGS equ <pushad> POPREGS equ <popad> PUBPROC macro name align 4 public @&name @&name label near endm else .286 _TEXT SEGMENT PUBLIC DWORD 'CODE' _TEXT ENDS _DATA SEGMENT PUBLIC DWORD 'DATA' _DATA ENDS CB_DSEG EQU <SEG _DATA> ; 16bit is small/large model D_SEG EQU <_DATA SEGMENT> D_END EQU <_DATA ENDS> ASSUME CS:_TEXT,DS:_DATA PUSHREGS equ <pusha> POPREGS equ <popa> PUBPROC macro name public _&name _&name label far endm endif ;------------------------------------------- D_SEG D_END _TEXT SEGMENT EXTRN _NdisSystemRequest : near EXTRN _NdisRequestConfirm : near EXTRN _NdisTransmitConfirm : near EXTRN _NdisReceiveLookahead : near EXTRN _NdisIndicationComplete : near EXTRN _NdisReceiveChain : near EXTRN _NdisStatusProc : near EXTRN _NdisAllocStack : near EXTRN _NdisFreeStack : near ; ; *ALL* interrupt threads come through this macro. ; CALLBACK macro callbackProc, argsSize pushf PUSHREGS ;; Save the registers push es push ds mov ax,CB_DSEG ;; Load DS mov ds,ax call _NdisAllocStack ;; Get and install a stack. mov bx,ss ;; Save off the old stack in other regs mov cx,sp mov ss,dx ;; Install the new one mov sp,ax push bx ;; Save the old one on to the new stack push cx sub sp,&argsSize ;; Allocate space for arguments on the stack mov ax,ss ;; Set up the destination for the move mov es,ax mov di,sp mov ds,bx ;; Set up the source for the move. mov si,cx add si,4+6+32 mov cx,&argsSize ;; Move the arguments to the stack. shr cx,1 cld rep movsw mov ax,CB_DSEG ;; Set my data segment again. mov ds,ax call &callbackProc ;; Call the real callback. pop di ;; Pop off the old stack pop si mov bx,ss ;; Save off the current allocated stack. mov cx,sp mov ss,si ;; Restore the old stack mov sp,di push ax ;; Save the return code push bx ;; Free the stack. Push the pointer to it push cx call _NdisFreeStack add sp,4 pop ax ;; Get the return code back add di,32 ;; Get a pointer to ax on the stack mov word ptr ss:[di],ax pop ds pop es POPREGS popf endm ; ; Define all of the callbacks for the NDIS procs. ; PUBPROC systemRequestGlue CALLBACK _NdisSystemRequest,14 RETF PUBPROC requestConfirmGlue CALLBACK _NdisRequestConfirm,12 RETF PUBPROC transmitConfirmGlue CALLBACK _NdisTransmitConfirm,10 RETF PUBPROC receiveLookaheadGlue CALLBACK _NdisReceiveLookahead,16 RETF PUBPROC indicationCompleteGlue CALLBACK _NdisIndicationComplete,4 RETF PUBPROC receiveChainGlue CALLBACK _NdisReceiveChain,16 RETF PUBPROC statusGlue CALLBACK _NdisStatusProc,12 RETF ; ; int FAR NdisGetLinkage (int handle, char *data, int size); ; ifdef DOSX PUBPROC NdisGetLinkage push ebx mov ebx, [esp+8] ; device handle mov eax, 4402h ; IOCTRL read function mov edx, [esp+12] ; DS:EDX -> result data mov ecx, [esp+16] ; ECX = length int 21h pop ebx jc @fail xor eax, eax @fail: ret else PUBPROC NdisGetLinkage enter 0, 0 mov bx, [bp+6] mov ax, 4402h mov dx, [bp+8] mov cx, [bp+12] int 21h jc @fail xor ax, ax @fail: leave retf endif ENDS END
src/keystore-containers.ads
My-Colaborations/ada-keystore
25
23630
----------------------------------------------------------------------- -- keystore-containers -- Container protected keystore -- Copyright (C) 2019, 2020 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Streams; with Ada.Streams; with Keystore.IO.Refs; with Keystore.Passwords.Keys; with Keystore.Repository; with Keystore.Keys; private package Keystore.Containers is type Wallet_Container; -- The `Wallet_Container` protects concurrent accesses to the repository. protected type Wallet_Container is procedure Initialize; procedure Open (Config : in Wallet_Config; Ident : in Wallet_Identifier; Block : in Keystore.IO.Storage_Block; Wallet_Stream : in out Keystore.IO.Refs.Stream_Ref); procedure Open (Name : in String; Password : in out Keystore.Passwords.Provider'Class; From_Repo : in out Keystore.Repository.Wallet_Repository; From_Stream : in out IO.Refs.Stream_Ref); procedure Create (Password : in out Keystore.Passwords.Provider'Class; Config : in Wallet_Config; Block : in IO.Storage_Block; Ident : in Wallet_Identifier; Wallet_Stream : in out IO.Refs.Stream_Ref); procedure Set_Master_Key (Password : in out Keystore.Passwords.Keys.Key_Provider'Class); function Get_State return State_Type; procedure Set_Header_Data (Index : in Header_Slot_Index_Type; Kind : in Header_Slot_Type; Data : in Ada.Streams.Stream_Element_Array); procedure Get_Header_Data (Index : in Header_Slot_Index_Type; Kind : out Header_Slot_Type; Data : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); procedure Unlock (Password : in out Keystore.Passwords.Provider'Class; Slot : out Key_Slot); procedure Set_Key (Password : in out Keystore.Passwords.Provider'Class; New_Password : in out Keystore.Passwords.Provider'Class; Config : in Wallet_Config; Mode : in Mode_Type); procedure Remove_Key (Password : in out Keystore.Passwords.Provider'Class; Slot : in Key_Slot; Force : in Boolean); function Contains (Name : in String) return Boolean; procedure Add (Name : in String; Kind : in Entry_Type; Content : in Ada.Streams.Stream_Element_Array); procedure Add (Name : in String; Kind : in Entry_Type; Input : in out Util.Streams.Input_Stream'Class); procedure Create (Name : in String; Password : in out Keystore.Passwords.Provider'Class; From_Repo : in out Keystore.Repository.Wallet_Repository; From_Stream : in out IO.Refs.Stream_Ref); procedure Set (Name : in String; Kind : in Entry_Type; Content : in Ada.Streams.Stream_Element_Array); procedure Set (Name : in String; Kind : in Entry_Type; Input : in out Util.Streams.Input_Stream'Class); procedure Update (Name : in String; Kind : in Entry_Type; Content : in Ada.Streams.Stream_Element_Array); procedure Find (Name : in String; Result : out Entry_Info); procedure Get_Data (Name : in String; Result : out Entry_Info; Output : out Ada.Streams.Stream_Element_Array); procedure Get_Data (Name : in String; Output : in out Util.Streams.Output_Stream'Class); procedure Read (Name : in String; Offset : in Ada.Streams.Stream_Element_Offset; Content : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); procedure Write (Name : in String; Offset : in Ada.Streams.Stream_Element_Offset; Content : in Ada.Streams.Stream_Element_Array); procedure Delete (Name : in String); procedure List (Filter : in Filter_Type; Content : out Entry_Map); procedure List (Pattern : in GNAT.Regpat.Pattern_Matcher; Filter : in Filter_Type; Content : out Entry_Map); procedure Get_Stats (Stats : out Wallet_Stats); procedure Close; procedure Set_Work_Manager (Workers : in Keystore.Task_Manager_Access); procedure Do_Repository (Process : not null access procedure (Repo : in out Repository.Wallet_Repository; Stream : in out IO.Refs.Stream_Ref)); private Stream : Keystore.IO.Refs.Stream_Ref; Master : Keystore.Keys.Key_Manager; Repository : Keystore.Repository.Wallet_Repository; State : State_Type := S_INVALID; Master_Block : Keystore.IO.Storage_Block; Master_Ident : Wallet_Identifier := Wallet_Identifier'First; end Wallet_Container; procedure Open_Wallet (Container : in out Wallet_Container; Name : in String; Password : in out Keystore.Passwords.Provider'Class; Wallet : in out Wallet_Container); procedure Add_Wallet (Container : in out Wallet_Container; Name : in String; Password : in out Keystore.Passwords.Provider'Class; Wallet : in out Wallet_Container); end Keystore.Containers;
HalfLife.asm
MasterCruelty/HalfLifeAssembly
0
22431
<reponame>MasterCruelty/HalfLifeAssembly<gh_stars>0 .data Stringa_1: .asciiz "Ti trovi nel centro di ricerca Black Mesa. Al momento c'è stato un disastro ed è in corso l'evacuazione. Alcune creature si stanno avvicinando, è il momento di fuggire! cosa fai? <opzioni> : \n (1) Prendo il piede di porco a terra \n (2) Apro la porta davanti a me \n \n Numero scelta: " Stringa_2: .asciiz "Hai ottenuto il piede di porco! \n \n" Stringa_3: .asciiz "La porta davanti a te è bloccata, ma usando il piede di porco riesci a forzarla e a passare. Dopo il tuo passaggio la porta si richiude. \n \n Ti ritrovi in un corridoio abbastanza stretto, in fondo vi è una porta già aperta, per terra vi sono un paio di cadaveri del personale di sicurezza. \n Cosa fai? <opzioni> : \n (1) Corro fino in fondo e attraverso la porta aperta \n (2) Perlustro i dintorni \n \n Numero scelta: " Stringa_err: .asciiz "La porta sembra essere bloccata, ma con il giusto attrezzo potresti riuscire a forzarla. Le creature sono ormai a contatto e sei morto indifeso. \n Game Over." Stringa_4: .asciiz "Hai ottenuto un caricatore per pistole e 1 cura medica! \n \n" Stringa_5: .asciiz "Proseguendo per la stanza successiva... \n Ci sono alcuni sistemi elettrici in fiamme e altri corpi ammassati in un angolo. Inoltre, vi è un'ascensore che sembra essere funzionante. \n Cosa fai? <opzioni> : \n (1) Mi dirigo verso l'ascensore \n (2) Perlustro nella stanza \n (3) Visualizza il mio inventario\n \n Numero scelta: " headcrab: .asciiz "Rovistando tra i cadaveri ti imbatti in un parassita headcrab! \n Cosa fai? <opzioni> : \n (1) Combatto. \n (2) Fuggo verso l'ascensore. \n \n Numero scelta: " fuga_headcrab: .asciiz "Buttandoci sopra un cadavere e dunque rallentando il parassita nemico, sei riuscito a guadagnare abbastanza tempo per raggiungere l'ascensore e far chiudere le porte. \n \n" elevator: .asciiz "Passi alcuni secondi prima di raggiungere l'ultimo piano disponibile, gli ultimi 2 per raggiungere la superficie e uscire da Black Mesa dovrai farli a piedi. Uscito hai a disposizione un corridoio che prosegue verso le scale. Noti in lontananza qualcosa(nelle vicinanze delle scale), forse un uomo accasciato. \n Cosa fai? <opzioni> : \n (1) Procedo diritto per il corridoio per raggiungere le scale \n (2) Esploro il corridoio di sinistra. \n (3) visualizza il mio inventario. \n \n Numero scelta: " cura: .asciiz "I tuoi punti salute non sono al massimo, vuoi curarti? (ripristinerai 6 punti ma non puoi eccedere il massimo, 12) \n Cosa fai? <opzioni> : \n (1) mi curo \n (2) proseguo senza curarmi. \n \n Numero scelta: " hp_left: .asciiz "Ti sono rimasti precisamente " hp: .asciiz " punti salute. \n \n" zombie: .asciiz "Avvicinandoti alle scale, l'uomo, prima accasciato, si è ora alzato e cerca di attaccarti. Impossibile da evitare \n" zombie_2: .asciiz " Che arma usi? <opzioni> : \n (1) uso il piede di porco \n (2) uso la pistola. \n \n Numero scelta: " pistola: .asciiz "Esplorando una delle stanze sei riuscito a trovare una nuova arma. \n \n Hai ottenuto una pistola! 7 proiettili all'interno. \n \n" piano2: .asciiz " Sei riuscito a salire le scale e sei al piano superiore, ormai poco distante dal tetto che ti condurrà alla libertà. A 10 metri di distanza vi è un altro essere dalle dubbie intenzioni amichevoli, dietro di lui una porta semi-aperta. \n Cosa fai? <opzioni> : \n (1) Uccido lo zombie ed entro \n (2) Proseguo senza farmi notare e salgo al piano successivo \n (3) visualizza il mio inventario. \n \n Numero scelta: " zombie_gun: .asciiz "Con l'uso della pistola dalla distanza, sei riuscito ad abbattere il nemico senza che lui riuscisse ad avvicinarsi. \n La pistola è ora scarica. \n \n" empty_room: .asciiz "Dopo aver ucciso lo zombie ed essere entrato nella stanza, ti accorgi che al suo interno non vi è niente di utile. \n \n " pianoFinale: .asciiz "Sei all'ultimo piano. Rimane solo un lungo corridoio da percorrere, la porta in fondo ti porterà all'esterno. \n Cosa fai? <opzioni> : \n (1) Corro verso la porta e la apro. \n (2) perlustro la zona in cerca di oggetti utili. \n (3) visualizza il mio inventario. \n \n Numero scelta: " zombie_final: .asciiz " Mentre ti avvicini alla porta per aprirla, da un angolo sbuca fuori un altro zombie e cerca di attaccarti! \n \n " Ending: .asciiz " Aprendo l'ultima porta, ti ritrovi all'esterno. Complimenti, sei riuscito a fuggire da Black Mesa! " cura2: .asciiz "Perlustrando i dintorni hai trovato una cura medica! \n" reload: .asciiz "La pistola è stata ricaricata utilizzando il caricatore all'interno dell'inventario. \n \n" morte: .asciiz " \n \n Sei morto... Game Over." vittoria: .asciiz " \n \n Hai sconfitto il nemico, puoi proseguire. \n \n " vuoto_I: .asciiz " - vuoto \n" NoCura: .asciiz "Non possiedi una cura medica nell'inventario!! \n \n" pistola_I: .asciiz " - Pistola \n" pistolaScarica_I: .asciiz " - Pistola(scarica) \n " crowbar_I: .asciiz " - Piede di porco \n" medikit_I: .asciiz " - cura medica \n" ammo_I: .asciiz " - Caricatore per pistola \n" .align 2 array_inventario: .space 16 .text .globl main main: li $s0,12 #punti salute utente li $s1,3 #punti salute headcrab li $s2,7 #punti salute zombie li $s3,3 #danni piede di porco li $s4,5 #danni pistola li $t4,2 #danni headcrab li $s6,4 #danni zombie li $s7,6 #cura medica la $s5,array_inventario #in s5 salvo l'indirizzo dell'array che conterrà l'inventario del giocatore la $a0,vuoto_I li $a1,0 jal setta_inventario #set degli spazi dell'inventario con la stringa vuoto_I(si andranno poi a sostituire man mano che si trovano oggetti) li $v0,4 la $a0,Stringa_1 syscall #print_string li $v0,5 syscall #read_int bne $v0,1,stop jal crowbar #salta a crowbar salva PC in $ra li $v0,4 la $a0,Stringa_3 syscall #print_string li $v0,5 syscall corridoio: beq $v0,1,stanza_1 li $v0,4 la $a0,Stringa_4 syscall #print_string la $t1,medikit_I sw $t1,4($s5) #salvo nell'inventario la cura medica in posizione [1] #addi $t3,$t3,4 la $t1,ammo_I sw $t1,8($s5) #salvo caricatore per pistola in posizione [2] #addi $t3,$t3,4 li $t1,0 #reset $t1 stanza_1: li $v0,4 la $a0,Stringa_5 syscall #print_string li $v0,5 syscall #read_int addi $t2,$zero,1 #carico valore 1 in t2 per il ritorno in caso si scelga inventario beq $v0,3,inventario #salta alla funzione inventario con la scelta 3 li $t2,0 beq $v0,1,ascensore #salta all'ascensore con la scelta 1 beq $v0,2,Headcrab #salta a headcrab con la scelta 2 Headcrab: li $v0,4 la $a0,headcrab syscall li $v0,5 syscall beq $v0,2,ascensore_fuga #set dei parametri per chiamata a procedura "combatti" move $a0,$s0 #punti salute utente move $a1,$s1 #punti salute headcrab move $a2,$s3 #piede di porco move $a3,$t4 #danni headcrab jal combatti add $s0,$v0,$zero li $t2,2 #carico valore 2 in t2 per il ritorno in caso di salto a cura bne $s0,12,Cura #salta a cura se $s0 è diverso da 12, quindi se sono stati tolti punti salute j ascensore ascensore: li $v0,4 la $a0,elevator syscall li $t2,2 #carico valore 2 in t2 per il ritorno in caso si scelga inventario li $v0,5 syscall beq $v0,1,scale beq $v0,2,corridoio_sx beq $v0,3,inventario scale: la $t4, pistola_I lw $t5,12($s5) beq $t4,$t5,scale_2 #se si possiedono entrambe le armi, viene richiesto quale si voglia usare, altrimenti di default crowbar li $v0,4 la $a0,zombie syscall #print_string zombie_crowbar: #settaggio dei parametri per chiamare combatti move $a0,$s0 #salute utente move $a1,$s2 #salute zombie move $a2,$s3 #piede di porco move $a3,$s6 #danni zombie jal combatti add $s0,$v0,$zero #in $v0 è contenuto il valore dei punti saluti post-battaglia, il valore di $s0 viene sostituito con esso li $t2,4 bne $s0,12,Cura beq $t6,2,stanza_vuota beq $t6,3,Finale j piano_sup scale_2: li $v0,4 la $a0,zombie syscall #print_string la $a0,zombie_2 syscall li $v0,5 syscall #read_int beq $v0,1,zombie_crowbar #in caso di scelta della pistola, settaggio dei parametri per chiamare combatti move $a0,$s0 #salute utente move $a1,$s2 #salute zombie move $a2,$s4 #pistola move $a3,$s6 #danni zombie jal combatti add $s0,$v0,$zero li $t2,4 bne $s0,12,Cura j piano_sup corridoio_sx: li $v0,4 la $a0,pistola syscall la $t1,pistola_I sw $t1,12($s5) #salvo pistola in posizione [3] #addi $t3,$zero,16 #valore n per il ciclo che serve a visualizzare l'inventario li $t1,0 j scale_2 piano_sup: li $v0,4 la $a0,piano2 syscall #print_string li $v0,5 syscall #read_int li $t2,4 beq $v0,1,zombie_3 beq $v0,2,last_piano beq $v0,3,inventario zombie_3: la $t5,pistola_I lw $t6,12($s5) beq $t5,$t6,zombie_shot #controllo sul possesso dell'oggetto pistola j zombie_crowbar zombie_shot: li $v0,4 la $a0,zombie_2 syscall #print_string li $v0,5 syscall #read_int li $t6,2 #se salta a zombie_crowbar, poi salta a stanza_vuota bne $v0,2,zombie_crowbar li $v0,4 la $a0,zombie_gun syscall #print_string lw $t5,8($s5) la $t6,ammo_I beq $t5,$t6,ricarica #controllo sul possesso dell'oggetto caricatore la $t5,pistolaScarica_I sw $t5,12($s5) j last_piano ricarica: li $v0,4 la $a0,reload syscall #print_string la $t5,vuoto_I sw $t5,8($s5) stanza_vuota: li $v0,4 la $a0,empty_room syscall #print_string last_piano: li $v0,4 la $a0,pianoFinale syscall #print_string li $v0,5 syscall #read_int li $t2,5 li $t1,0 beq $v0,1,zombie_finale beq $v0,3,inventario la $t1,medikit_I sw $t1,4($s5) #salvo cura medica in posizione [1] li $v0,4 la $a0,cura2 syscall #print_string bne $s0,12,Cura zombie_finale: li $v0,4 la $a0,zombie_final syscall la $t1,pistola_I lw $t5,12($s5) li $t6,3 #se salta a zombie_crowbar(pistola scarica), poi salta a Finale bne $t1,$t5,zombie_crowbar li $v0,4 la $a0,zombie_2 syscall #print_string li $v0,5 syscall #read_int beq $v0,1,zombie_crowbar #in caso di scelta della pistola, settaggio dei parametri per chiamare combatti move $a0,$s0 #salute utente move $a1,$s2 #salute zombie move $a2,$s4 #pistola move $a3,$s6 #danni zombie jal combatti Finale: li $v0,4 la $a0,Ending syscall #print_string j End crowbar: li $v0,4 la $a0,Stringa_2 syscall #print_string la $t1,crowbar_I sw $t1,0($s5) #salvo nell'inventario il piede di porco in posizione [0] #addi $t3,$t3,4 li $t1,0 #reset $t1 jr $ra stop: li $v0,4 la $a0,Stringa_err syscall #print_string jr $ra setta_inventario: beq $a1,16,resetta #for(i = 0; i <= 16;i++) sw $a0,0($s5) addi $s5,$s5,4 addi $a1,$a1,4 j setta_inventario resetta: beq $a1,0,back subu $s5,$s5,4 subu $a1,$a1,4 j resetta back: jr $ra inventario: beq $t1,16,reset_arrayInventario #for(i = 0; i <= 16;i++) li $v0,4 lw $a0,0($s5) syscall addi $s5,$s5,4 addi $t1,$t1,4 j inventario reset_arrayInventario: beq $t1,0,ritorno subu $s5,$s5,4 subu $t1,$t1,4 j reset_arrayInventario ritorno: beq $t2,1,stanza_1 #se in t2 è stato caricato 1, inventario è stato chiamato da stanza_1, dunque ritorna li beq $t2,2,ascensore #se in t2 è stato caricato 2, inventario/cura è stato chiamato da ascensore/headcrab, dunque ritorna li beq $t2,4,piano_sup #se in t2 è stato caricato 4, cura è chiamata da zombie/scale, dunque ritorna li(oppure inventario da piano_sup) beq $t2,5,last_piano #se in t2 è stato caricato 5, inventario è chiamato da last_piano, ritorna li combatti: #parametri: $a0 i punti salute utente, $a1 i punti salute del nemico, $a2 l'arma usata dall'utente, $a3 i danni che può causare il nemico addi $sp, $sp, -4 sw $s0, 4($sp) fight: sub $a0,$a0,$a3 blt $a0,0,fine_combatti sub $a1,$a1,$a2 blt $a1,0,fine_combatti j fight fine_combatti: blt $a0,0,game_over add $s0,$a0,$zero li $v0,4 la $a0,vittoria syscall add $v0,$s0,$zero #ripristino i registri 'S' lw $s0,4($sp) addi $sp,$sp,4 jr $ra Cura: li $v0,4 la $a0,hp_left syscall #print_string li $v0,1 add $a0,$s0,$zero syscall #print_int li $v0,4 la $a0,hp syscall #print_string li $v0,4 la $a0,cura syscall #print_string li $v0,5 syscall #read_int beq $v0,1,cura_Si j ritorno cura_Si: la $t6,medikit_I lw $t5,4($s5) bne $t6,$t5,cura_No #controllo sul possesso dell'oggetto cura add $s0,$s0,$s7 la $t6,vuoto_I sw $t6,4($s5) bgt $s0,12,reset_eccesso #controllo sull'eccesso di punti salute j ritorno reset_eccesso: beq $s0,10,ritorno subu $s0,$s0,1 j reset_eccesso cura_No: li $v0,4 la $a0,NoCura syscall #print_string j ritorno ascensore_fuga: li $v0,4 la $a0,fuga_headcrab syscall #print_string j ascensore game_over: li $v0,4 la $a0,morte syscall #print_string End: li $v0,10 syscall #exit
programs/oeis/014/A014483.asm
neoneye/loda
22
174776
<filename>programs/oeis/014/A014483.asm<gh_stars>10-100 ; A014483: Expansion of (1+2*x) / (1-2*x)^4. ; 1,10,56,240,880,2912,8960,26112,72960,197120,518144,1331200,3354624,8314880,20316160,49020928,116981760,276430848,647495680,1504706560,3471835136,7958691840,18136170496,41104179200,92694118400,208071032832,465064427520,1035355553792,2296465326080,5076114472960,11184094838784,24567212933120,53811645251584,117553254891520,256151849533440,556833919991808,1207744803635200,2613951456083968,5645992208629760,12171593719480320,26191466485252096,56262009993297920,120656007985627136,258341252062248960,552306680864440320,1179063493068849152,2513571542026158080,5351402257222991872,11378625933528268800,24164626750609817600,51257719158917300224,108604305014039511040,229859221381362745344,485983435789550223360,1026460427070283448320,2165907161592037900288,4565929446213303664640,9616662385113786482688,20236654709611681546240,42548568127515687649280,89387157173673452896256,187637974874764345344000,393579731556666993278976,824938394976291148267520,1727814283664005152112640,3616336601698167917903872,7563902939983864544624640,15810187836742392822628352,33025574850043684449157120,68943599170845026591703040,143838560701726523563966464,299917495327051167521832960,625000481641314674387451904,1301720321003017703155302400,2709693887870602423618764800,5637598886181645413271994368,11723180346394236850096046080,24365748778605399187556139008,50617724067264523544947589120,105104010757295860448954941440,218139783817083302913157103616,452537202056344138967762862080,938387563997988999473729110016,1945016572661584586601272442880,4029784970070620305798578831360,8345688831721074127633217748992,17277000673276588461560902451200,35752327304581425029224157151232,73956085371957724347817305047040,152925827903021238808976063201280,316103037271364711674391774101504,653161923527752340642275923066880,1349151620654621697274961947787264,2785810746806248355421993188720640,5750380035285305622539419915386880,11865843443436341312709890353922048,24477144667969395777837435736555520,50476103881512780952171663671164928,104058268646234780995360624371302400,214454790293610708998204764769484800 add $0,1 seq $0,87076 ; Sums of the squares of the elements in the subsets of the integers 1 to n.
src/main/antlr/odin_values.g4
nedap/adl-antlr
0
4045
// // grammar defining ODIN terminal value types, including atoms, lists and intervals // grammar odin_values; import base_patterns; string_value : STRING ; string_list_value : string_value ( ( ',' string_value )+ | ',' SYM_LIST_CONTINUE ) ; integer_value : ( '+' | '-' )? INTEGER ; integer_list_value : integer_value ( ( ',' integer_value )+ | ',' SYM_LIST_CONTINUE ) ; integer_interval_value : '|' SYM_GT? integer_value SYM_INTERVAL_SEP SYM_LT? integer_value '|' | '|' relop? integer_value '|' ; integer_interval_list_value : integer_interval_value ( ( ',' integer_interval_value )+ | ',' SYM_LIST_CONTINUE ) ; real_value : ( '+' | '-' )? REAL ; real_list_value : real_value ( ( ',' real_value )+ | ',' SYM_LIST_CONTINUE ) ; real_interval_value : '|' SYM_GT? real_value SYM_INTERVAL_SEP SYM_LT? real_value '|' | '|' relop? real_value '|' ; real_interval_list_value : real_interval_value ( ( ',' real_interval_value )+ | ',' SYM_LIST_CONTINUE ) ; boolean_value : SYM_TRUE | SYM_FALSE ; boolean_list_value : boolean_value ( ( ',' boolean_value )+ | ',' SYM_LIST_CONTINUE ) ; character_value : CHARACTER ; character_list_value : character_value ( ( ',' character_value )+ | ',' SYM_LIST_CONTINUE ) ; date_value : ISO8601_DATE ; date_list_value : date_value ( ( ',' date_value )+ | ',' SYM_LIST_CONTINUE ) ; date_interval_value : '|' SYM_GT? date_value SYM_INTERVAL_SEP SYM_LT? date_value '|' | '|' relop? date_value '|' ; date_interval_list_value : date_interval_value ( ( ',' date_interval_value )+ | ',' SYM_LIST_CONTINUE ) ; time_value : ISO8601_TIME ; time_list_value : time_value ( ( ',' time_value )+ | ',' SYM_LIST_CONTINUE ) ; time_interval_value : '|' SYM_GT? time_value SYM_INTERVAL_SEP SYM_LT? time_value '|' | '|' relop? time_value '|' ; time_interval_list_value : time_interval_value ( ( ',' time_interval_value )+ | ',' SYM_LIST_CONTINUE ) ; date_time_value : ISO8601_DATE_TIME ; date_time_list_value : date_time_value ( ( ',' date_time_value )+ | ',' SYM_LIST_CONTINUE ) ; date_time_interval_value : '|' SYM_GT? date_time_value SYM_INTERVAL_SEP SYM_LT? date_time_value '|' | '|' relop? date_time_value '|' ; date_time_interval_list_value : date_time_interval_value ( ( ',' date_time_interval_value )+ | ',' SYM_LIST_CONTINUE ) ; duration_value : ISO8601_DURATION ; duration_list_value : duration_value ( ( ',' duration_value )+ | ',' SYM_LIST_CONTINUE ) ; duration_interval_value : '|' SYM_GT? duration_value SYM_INTERVAL_SEP SYM_LT? duration_value '|' | '|' relop? duration_value '|' ; duration_interval_list_value : duration_interval_value ( ( ',' duration_interval_value )+ | ',' SYM_LIST_CONTINUE ) ; term_code_value : TERM_CODE_REF ; term_code_list_value : term_code_value ( ( ',' term_code_value )+ | ',' SYM_LIST_CONTINUE ) ; uri_value : URI ; relop : SYM_GT | SYM_LT | SYM_LE | SYM_GE ;
alloy4fun_models/trashltl/models/7/GnMx2ZPDRbTJikPT5.als
Kaixi26/org.alloytools.alloy
0
1675
open main pred idGnMx2ZPDRbTJikPT5_prop8 { once File.link in Trash } pred __repair { idGnMx2ZPDRbTJikPT5_prop8 } check __repair { idGnMx2ZPDRbTJikPT5_prop8 <=> prop8o }
oeis/295/A295729.asm
neoneye/loda-programs
11
29531
; A295729: a(n) = a(n-1) + 3*a(n-2) -2*a(n-3) - 2*a(n-4), where a(0) = -1, a(1) = 0, a(2) = 1, a(3) = 1. ; Submitted by <NAME> ; -1,0,1,1,6,7,21,28,65,93,190,283,537,820,1485,2305,4046,6351,10909,17260,29193,46453,77694,124147,205937,330084,544213,874297,1434894,2309191,3776853,6086044,9928433,16014477,26073982,42088459,68424585,110513044,179461917,289974961,470485454,760460415,1233043021,1993503436,3230740761,5224244197,8463373566,13687617763,22167768545,35855386308,58056709285,93912095593,152035913742,245948009335,398118140805,644066150140,1042452726401,1686518876541,2729508473854,4416027350395,7146609566073 mov $2,-2 lpb $0 sub $0,1 sub $3,$4 add $1,$3 sub $1,$2 add $4,1 add $4,$2 mov $5,$4 mov $4,$2 mov $2,$3 mul $2,2 add $4,$1 add $5,$4 mov $3,$5 sub $4,2 lpe mov $0,$2 div $0,2