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
operacoes/escalares/ex03.asm
mikael-85/assembly_mips
0
26860
#=================================================================== # Descrição: # Carregar um dado da memoria para registrdores # Guardar um dado de um registrador para memoria # * Usando uma word, meia palavra e um byte # #=================================================================== # Convensão dos registradores #=================================================================== # $0 - Sempre zero # $at - Temporário para assembly (reservado) # $v0, $v1 - Valores retornado de uma rotina # $a0 - $a3 - Argumentos para uma sub-rotina # $t0 - $t7 - Temporário (não preservados na chamada da função) # $s0 - $s7 - Registradores salvos (preservado na chamada da função) # $t8, $t9 - Temporários # $k0, $k1 - Kernel (reservado para o S.O) # $gp - Ponteiro global # $sp - Ponteiro para a pilha (stack pointer) # $fp - Ponteiro para o quadro (frame pointer) # $ra - End de retorno (usando em algumas instruções) #=================================================================== .text # carregamos o conteúdo do rótulo memory em $t0 la $s0, memory lw $t0, 0($s0) # carregamos meia palavra em $t1 com extensão de sinal lh $t1, 0($s0) # lhu - sem extensão de sinal # carregamos 1 byte em $t2 com extensão de sinal lb $t2, 0($s0) # lbu - sem extensão de sinal # armazenamos os conteúdos dos registradores na memoria # palavra la $s0, dataW sw $t0, 0($s0) # meia palavra la $s0, dataHW sh $t1, 0($s0) # byte la $s0, dataB sb $t2, 0($s0) .data memory: .word 0xABCDE080 dataW: .word 0 dataHW: .half 0 dataB: .byte 0
trunk/win/lib/openssl-1.0.1e/tmp32/wp-mmx.asm
chundonglinlin/srs.win
9
103321
TITLE wp-mmx.asm IF @Version LT 800 ECHO MASM version 8.00 or later is strongly recommended. ENDIF .686 .XMM IF @Version LT 800 XMMWORD STRUCT 16 DQ 2 dup (?) XMMWORD ENDS ENDIF .MODEL FLAT OPTION DOTNAME IF @Version LT 800 .text$ SEGMENT PAGE 'CODE' ELSE .text$ SEGMENT ALIGN(64) 'CODE' ENDIF ALIGN 16 _whirlpool_block_mmx PROC PUBLIC $L_whirlpool_block_mmx_begin:: push ebp push ebx push esi push edi mov esi,DWORD PTR 20[esp] mov edi,DWORD PTR 24[esp] mov ebp,DWORD PTR 28[esp] mov eax,esp sub esp,148 and esp,-64 lea ebx,DWORD PTR 128[esp] mov DWORD PTR [ebx],esi mov DWORD PTR 4[ebx],edi mov DWORD PTR 8[ebx],ebp mov DWORD PTR 16[ebx],eax call $L000pic_point $L000pic_point: pop ebp lea ebp,DWORD PTR ($L001table-$L000pic_point)[ebp] xor ecx,ecx xor edx,edx movq mm0,QWORD PTR [esi] movq mm1,QWORD PTR 8[esi] movq mm2,QWORD PTR 16[esi] movq mm3,QWORD PTR 24[esi] movq mm4,QWORD PTR 32[esi] movq mm5,QWORD PTR 40[esi] movq mm6,QWORD PTR 48[esi] movq mm7,QWORD PTR 56[esi] $L002outerloop: movq QWORD PTR [esp],mm0 movq QWORD PTR 8[esp],mm1 movq QWORD PTR 16[esp],mm2 movq QWORD PTR 24[esp],mm3 movq QWORD PTR 32[esp],mm4 movq QWORD PTR 40[esp],mm5 movq QWORD PTR 48[esp],mm6 movq QWORD PTR 56[esp],mm7 pxor mm0,QWORD PTR [edi] pxor mm1,QWORD PTR 8[edi] pxor mm2,QWORD PTR 16[edi] pxor mm3,QWORD PTR 24[edi] pxor mm4,QWORD PTR 32[edi] pxor mm5,QWORD PTR 40[edi] pxor mm6,QWORD PTR 48[edi] pxor mm7,QWORD PTR 56[edi] movq QWORD PTR 64[esp],mm0 movq QWORD PTR 72[esp],mm1 movq QWORD PTR 80[esp],mm2 movq QWORD PTR 88[esp],mm3 movq QWORD PTR 96[esp],mm4 movq QWORD PTR 104[esp],mm5 movq QWORD PTR 112[esp],mm6 movq QWORD PTR 120[esp],mm7 xor esi,esi mov DWORD PTR 12[ebx],esi ALIGN 16 $L003round: movq mm0,QWORD PTR 4096[esi*8+ebp] mov eax,DWORD PTR [esp] mov ebx,DWORD PTR 4[esp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm0,QWORD PTR [esi*8+ebp] movq mm1,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 8[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] movq mm2,QWORD PTR 6[esi*8+ebp] movq mm3,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 movq mm4,QWORD PTR 4[esi*8+ebp] movq mm5,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 12[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] movq mm6,QWORD PTR 2[esi*8+ebp] movq mm7,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm1,QWORD PTR [esi*8+ebp] pxor mm2,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 16[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm3,QWORD PTR 6[esi*8+ebp] pxor mm4,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm5,QWORD PTR 4[esi*8+ebp] pxor mm6,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 20[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm7,QWORD PTR 2[esi*8+ebp] pxor mm0,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm2,QWORD PTR [esi*8+ebp] pxor mm3,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 24[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm4,QWORD PTR 6[esi*8+ebp] pxor mm5,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm6,QWORD PTR 4[esi*8+ebp] pxor mm7,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 28[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm0,QWORD PTR 2[esi*8+ebp] pxor mm1,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm3,QWORD PTR [esi*8+ebp] pxor mm4,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 32[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm5,QWORD PTR 6[esi*8+ebp] pxor mm6,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm7,QWORD PTR 4[esi*8+ebp] pxor mm0,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 36[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm1,QWORD PTR 2[esi*8+ebp] pxor mm2,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm4,QWORD PTR [esi*8+ebp] pxor mm5,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 40[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm6,QWORD PTR 6[esi*8+ebp] pxor mm7,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm0,QWORD PTR 4[esi*8+ebp] pxor mm1,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 44[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm2,QWORD PTR 2[esi*8+ebp] pxor mm3,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm5,QWORD PTR [esi*8+ebp] pxor mm6,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 48[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm7,QWORD PTR 6[esi*8+ebp] pxor mm0,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm1,QWORD PTR 4[esi*8+ebp] pxor mm2,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 52[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm3,QWORD PTR 2[esi*8+ebp] pxor mm4,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm6,QWORD PTR [esi*8+ebp] pxor mm7,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 56[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm0,QWORD PTR 6[esi*8+ebp] pxor mm1,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm2,QWORD PTR 4[esi*8+ebp] pxor mm3,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 60[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm4,QWORD PTR 2[esi*8+ebp] pxor mm5,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm7,QWORD PTR [esi*8+ebp] pxor mm0,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 64[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm1,QWORD PTR 6[esi*8+ebp] pxor mm2,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm3,QWORD PTR 4[esi*8+ebp] pxor mm4,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 68[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm5,QWORD PTR 2[esi*8+ebp] pxor mm6,QWORD PTR 1[edi*8+ebp] movq QWORD PTR [esp],mm0 movq QWORD PTR 8[esp],mm1 movq QWORD PTR 16[esp],mm2 movq QWORD PTR 24[esp],mm3 movq QWORD PTR 32[esp],mm4 movq QWORD PTR 40[esp],mm5 movq QWORD PTR 48[esp],mm6 movq QWORD PTR 56[esp],mm7 mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm0,QWORD PTR [esi*8+ebp] pxor mm1,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 72[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm2,QWORD PTR 6[esi*8+ebp] pxor mm3,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm4,QWORD PTR 4[esi*8+ebp] pxor mm5,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 76[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm6,QWORD PTR 2[esi*8+ebp] pxor mm7,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm1,QWORD PTR [esi*8+ebp] pxor mm2,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 80[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm3,QWORD PTR 6[esi*8+ebp] pxor mm4,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm5,QWORD PTR 4[esi*8+ebp] pxor mm6,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 84[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm7,QWORD PTR 2[esi*8+ebp] pxor mm0,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm2,QWORD PTR [esi*8+ebp] pxor mm3,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 88[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm4,QWORD PTR 6[esi*8+ebp] pxor mm5,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm6,QWORD PTR 4[esi*8+ebp] pxor mm7,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 92[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm0,QWORD PTR 2[esi*8+ebp] pxor mm1,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm3,QWORD PTR [esi*8+ebp] pxor mm4,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 96[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm5,QWORD PTR 6[esi*8+ebp] pxor mm6,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm7,QWORD PTR 4[esi*8+ebp] pxor mm0,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 100[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm1,QWORD PTR 2[esi*8+ebp] pxor mm2,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm4,QWORD PTR [esi*8+ebp] pxor mm5,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 104[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm6,QWORD PTR 6[esi*8+ebp] pxor mm7,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm0,QWORD PTR 4[esi*8+ebp] pxor mm1,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 108[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm2,QWORD PTR 2[esi*8+ebp] pxor mm3,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm5,QWORD PTR [esi*8+ebp] pxor mm6,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 112[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm7,QWORD PTR 6[esi*8+ebp] pxor mm0,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm1,QWORD PTR 4[esi*8+ebp] pxor mm2,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 116[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm3,QWORD PTR 2[esi*8+ebp] pxor mm4,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm6,QWORD PTR [esi*8+ebp] pxor mm7,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah mov eax,DWORD PTR 120[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm0,QWORD PTR 6[esi*8+ebp] pxor mm1,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm2,QWORD PTR 4[esi*8+ebp] pxor mm3,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh mov ebx,DWORD PTR 124[esp] lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm4,QWORD PTR 2[esi*8+ebp] pxor mm5,QWORD PTR 1[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr eax,16 pxor mm7,QWORD PTR [esi*8+ebp] pxor mm0,QWORD PTR 7[edi*8+ebp] mov cl,al mov dl,ah lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm1,QWORD PTR 6[esi*8+ebp] pxor mm2,QWORD PTR 5[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] shr ebx,16 pxor mm3,QWORD PTR 4[esi*8+ebp] pxor mm4,QWORD PTR 3[edi*8+ebp] mov cl,bl mov dl,bh lea esi,DWORD PTR [ecx*1+ecx] lea edi,DWORD PTR [edx*1+edx] pxor mm5,QWORD PTR 2[esi*8+ebp] pxor mm6,QWORD PTR 1[edi*8+ebp] lea ebx,DWORD PTR 128[esp] mov esi,DWORD PTR 12[ebx] add esi,1 cmp esi,10 je $L004roundsdone mov DWORD PTR 12[ebx],esi movq QWORD PTR 64[esp],mm0 movq QWORD PTR 72[esp],mm1 movq QWORD PTR 80[esp],mm2 movq QWORD PTR 88[esp],mm3 movq QWORD PTR 96[esp],mm4 movq QWORD PTR 104[esp],mm5 movq QWORD PTR 112[esp],mm6 movq QWORD PTR 120[esp],mm7 jmp $L003round ALIGN 16 $L004roundsdone: mov esi,DWORD PTR [ebx] mov edi,DWORD PTR 4[ebx] mov eax,DWORD PTR 8[ebx] pxor mm0,QWORD PTR [edi] pxor mm1,QWORD PTR 8[edi] pxor mm2,QWORD PTR 16[edi] pxor mm3,QWORD PTR 24[edi] pxor mm4,QWORD PTR 32[edi] pxor mm5,QWORD PTR 40[edi] pxor mm6,QWORD PTR 48[edi] pxor mm7,QWORD PTR 56[edi] pxor mm0,QWORD PTR [esi] pxor mm1,QWORD PTR 8[esi] pxor mm2,QWORD PTR 16[esi] pxor mm3,QWORD PTR 24[esi] pxor mm4,QWORD PTR 32[esi] pxor mm5,QWORD PTR 40[esi] pxor mm6,QWORD PTR 48[esi] pxor mm7,QWORD PTR 56[esi] movq QWORD PTR [esi],mm0 movq QWORD PTR 8[esi],mm1 movq QWORD PTR 16[esi],mm2 movq QWORD PTR 24[esi],mm3 movq QWORD PTR 32[esi],mm4 movq QWORD PTR 40[esi],mm5 movq QWORD PTR 48[esi],mm6 movq QWORD PTR 56[esi],mm7 lea edi,DWORD PTR 64[edi] sub eax,1 jz $L005alldone mov DWORD PTR 4[ebx],edi mov DWORD PTR 8[ebx],eax jmp $L002outerloop $L005alldone: emms mov esp,DWORD PTR 16[ebx] pop edi pop esi pop ebx pop ebp ret ALIGN 64 $L001table: DB 24,24,96,24,192,120,48,216 DB 24,24,96,24,192,120,48,216 DB 35,35,140,35,5,175,70,38 DB 35,35,140,35,5,175,70,38 DB 198,198,63,198,126,249,145,184 DB 198,198,63,198,126,249,145,184 DB 232,232,135,232,19,111,205,251 DB 232,232,135,232,19,111,205,251 DB 135,135,38,135,76,161,19,203 DB 135,135,38,135,76,161,19,203 DB 184,184,218,184,169,98,109,17 DB 184,184,218,184,169,98,109,17 DB 1,1,4,1,8,5,2,9 DB 1,1,4,1,8,5,2,9 DB 79,79,33,79,66,110,158,13 DB 79,79,33,79,66,110,158,13 DB 54,54,216,54,173,238,108,155 DB 54,54,216,54,173,238,108,155 DB 166,166,162,166,89,4,81,255 DB 166,166,162,166,89,4,81,255 DB 210,210,111,210,222,189,185,12 DB 210,210,111,210,222,189,185,12 DB 245,245,243,245,251,6,247,14 DB 245,245,243,245,251,6,247,14 DB 121,121,249,121,239,128,242,150 DB 121,121,249,121,239,128,242,150 DB 111,111,161,111,95,206,222,48 DB 111,111,161,111,95,206,222,48 DB 145,145,126,145,252,239,63,109 DB 145,145,126,145,252,239,63,109 DB 82,82,85,82,170,7,164,248 DB 82,82,85,82,170,7,164,248 DB 96,96,157,96,39,253,192,71 DB 96,96,157,96,39,253,192,71 DB 188,188,202,188,137,118,101,53 DB 188,188,202,188,137,118,101,53 DB 155,155,86,155,172,205,43,55 DB 155,155,86,155,172,205,43,55 DB 142,142,2,142,4,140,1,138 DB 142,142,2,142,4,140,1,138 DB 163,163,182,163,113,21,91,210 DB 163,163,182,163,113,21,91,210 DB 12,12,48,12,96,60,24,108 DB 12,12,48,12,96,60,24,108 DB 123,123,241,123,255,138,246,132 DB 123,123,241,123,255,138,246,132 DB 53,53,212,53,181,225,106,128 DB 53,53,212,53,181,225,106,128 DB 29,29,116,29,232,105,58,245 DB 29,29,116,29,232,105,58,245 DB 224,224,167,224,83,71,221,179 DB 224,224,167,224,83,71,221,179 DB 215,215,123,215,246,172,179,33 DB 215,215,123,215,246,172,179,33 DB 194,194,47,194,94,237,153,156 DB 194,194,47,194,94,237,153,156 DB 46,46,184,46,109,150,92,67 DB 46,46,184,46,109,150,92,67 DB 75,75,49,75,98,122,150,41 DB 75,75,49,75,98,122,150,41 DB 254,254,223,254,163,33,225,93 DB 254,254,223,254,163,33,225,93 DB 87,87,65,87,130,22,174,213 DB 87,87,65,87,130,22,174,213 DB 21,21,84,21,168,65,42,189 DB 21,21,84,21,168,65,42,189 DB 119,119,193,119,159,182,238,232 DB 119,119,193,119,159,182,238,232 DB 55,55,220,55,165,235,110,146 DB 55,55,220,55,165,235,110,146 DB 229,229,179,229,123,86,215,158 DB 229,229,179,229,123,86,215,158 DB 159,159,70,159,140,217,35,19 DB 159,159,70,159,140,217,35,19 DB 240,240,231,240,211,23,253,35 DB 240,240,231,240,211,23,253,35 DB 74,74,53,74,106,127,148,32 DB 74,74,53,74,106,127,148,32 DB 218,218,79,218,158,149,169,68 DB 218,218,79,218,158,149,169,68 DB 88,88,125,88,250,37,176,162 DB 88,88,125,88,250,37,176,162 DB 201,201,3,201,6,202,143,207 DB 201,201,3,201,6,202,143,207 DB 41,41,164,41,85,141,82,124 DB 41,41,164,41,85,141,82,124 DB 10,10,40,10,80,34,20,90 DB 10,10,40,10,80,34,20,90 DB 177,177,254,177,225,79,127,80 DB 177,177,254,177,225,79,127,80 DB 160,160,186,160,105,26,93,201 DB 160,160,186,160,105,26,93,201 DB 107,107,177,107,127,218,214,20 DB 107,107,177,107,127,218,214,20 DB 133,133,46,133,92,171,23,217 DB 133,133,46,133,92,171,23,217 DB 189,189,206,189,129,115,103,60 DB 189,189,206,189,129,115,103,60 DB 93,93,105,93,210,52,186,143 DB 93,93,105,93,210,52,186,143 DB 16,16,64,16,128,80,32,144 DB 16,16,64,16,128,80,32,144 DB 244,244,247,244,243,3,245,7 DB 244,244,247,244,243,3,245,7 DB 203,203,11,203,22,192,139,221 DB 203,203,11,203,22,192,139,221 DB 62,62,248,62,237,198,124,211 DB 62,62,248,62,237,198,124,211 DB 5,5,20,5,40,17,10,45 DB 5,5,20,5,40,17,10,45 DB 103,103,129,103,31,230,206,120 DB 103,103,129,103,31,230,206,120 DB 228,228,183,228,115,83,213,151 DB 228,228,183,228,115,83,213,151 DB 39,39,156,39,37,187,78,2 DB 39,39,156,39,37,187,78,2 DB 65,65,25,65,50,88,130,115 DB 65,65,25,65,50,88,130,115 DB 139,139,22,139,44,157,11,167 DB 139,139,22,139,44,157,11,167 DB 167,167,166,167,81,1,83,246 DB 167,167,166,167,81,1,83,246 DB 125,125,233,125,207,148,250,178 DB 125,125,233,125,207,148,250,178 DB 149,149,110,149,220,251,55,73 DB 149,149,110,149,220,251,55,73 DB 216,216,71,216,142,159,173,86 DB 216,216,71,216,142,159,173,86 DB 251,251,203,251,139,48,235,112 DB 251,251,203,251,139,48,235,112 DB 238,238,159,238,35,113,193,205 DB 238,238,159,238,35,113,193,205 DB 124,124,237,124,199,145,248,187 DB 124,124,237,124,199,145,248,187 DB 102,102,133,102,23,227,204,113 DB 102,102,133,102,23,227,204,113 DB 221,221,83,221,166,142,167,123 DB 221,221,83,221,166,142,167,123 DB 23,23,92,23,184,75,46,175 DB 23,23,92,23,184,75,46,175 DB 71,71,1,71,2,70,142,69 DB 71,71,1,71,2,70,142,69 DB 158,158,66,158,132,220,33,26 DB 158,158,66,158,132,220,33,26 DB 202,202,15,202,30,197,137,212 DB 202,202,15,202,30,197,137,212 DB 45,45,180,45,117,153,90,88 DB 45,45,180,45,117,153,90,88 DB 191,191,198,191,145,121,99,46 DB 191,191,198,191,145,121,99,46 DB 7,7,28,7,56,27,14,63 DB 7,7,28,7,56,27,14,63 DB 173,173,142,173,1,35,71,172 DB 173,173,142,173,1,35,71,172 DB 90,90,117,90,234,47,180,176 DB 90,90,117,90,234,47,180,176 DB 131,131,54,131,108,181,27,239 DB 131,131,54,131,108,181,27,239 DB 51,51,204,51,133,255,102,182 DB 51,51,204,51,133,255,102,182 DB 99,99,145,99,63,242,198,92 DB 99,99,145,99,63,242,198,92 DB 2,2,8,2,16,10,4,18 DB 2,2,8,2,16,10,4,18 DB 170,170,146,170,57,56,73,147 DB 170,170,146,170,57,56,73,147 DB 113,113,217,113,175,168,226,222 DB 113,113,217,113,175,168,226,222 DB 200,200,7,200,14,207,141,198 DB 200,200,7,200,14,207,141,198 DB 25,25,100,25,200,125,50,209 DB 25,25,100,25,200,125,50,209 DB 73,73,57,73,114,112,146,59 DB 73,73,57,73,114,112,146,59 DB 217,217,67,217,134,154,175,95 DB 217,217,67,217,134,154,175,95 DB 242,242,239,242,195,29,249,49 DB 242,242,239,242,195,29,249,49 DB 227,227,171,227,75,72,219,168 DB 227,227,171,227,75,72,219,168 DB 91,91,113,91,226,42,182,185 DB 91,91,113,91,226,42,182,185 DB 136,136,26,136,52,146,13,188 DB 136,136,26,136,52,146,13,188 DB 154,154,82,154,164,200,41,62 DB 154,154,82,154,164,200,41,62 DB 38,38,152,38,45,190,76,11 DB 38,38,152,38,45,190,76,11 DB 50,50,200,50,141,250,100,191 DB 50,50,200,50,141,250,100,191 DB 176,176,250,176,233,74,125,89 DB 176,176,250,176,233,74,125,89 DB 233,233,131,233,27,106,207,242 DB 233,233,131,233,27,106,207,242 DB 15,15,60,15,120,51,30,119 DB 15,15,60,15,120,51,30,119 DB 213,213,115,213,230,166,183,51 DB 213,213,115,213,230,166,183,51 DB 128,128,58,128,116,186,29,244 DB 128,128,58,128,116,186,29,244 DB 190,190,194,190,153,124,97,39 DB 190,190,194,190,153,124,97,39 DB 205,205,19,205,38,222,135,235 DB 205,205,19,205,38,222,135,235 DB 52,52,208,52,189,228,104,137 DB 52,52,208,52,189,228,104,137 DB 72,72,61,72,122,117,144,50 DB 72,72,61,72,122,117,144,50 DB 255,255,219,255,171,36,227,84 DB 255,255,219,255,171,36,227,84 DB 122,122,245,122,247,143,244,141 DB 122,122,245,122,247,143,244,141 DB 144,144,122,144,244,234,61,100 DB 144,144,122,144,244,234,61,100 DB 95,95,97,95,194,62,190,157 DB 95,95,97,95,194,62,190,157 DB 32,32,128,32,29,160,64,61 DB 32,32,128,32,29,160,64,61 DB 104,104,189,104,103,213,208,15 DB 104,104,189,104,103,213,208,15 DB 26,26,104,26,208,114,52,202 DB 26,26,104,26,208,114,52,202 DB 174,174,130,174,25,44,65,183 DB 174,174,130,174,25,44,65,183 DB 180,180,234,180,201,94,117,125 DB 180,180,234,180,201,94,117,125 DB 84,84,77,84,154,25,168,206 DB 84,84,77,84,154,25,168,206 DB 147,147,118,147,236,229,59,127 DB 147,147,118,147,236,229,59,127 DB 34,34,136,34,13,170,68,47 DB 34,34,136,34,13,170,68,47 DB 100,100,141,100,7,233,200,99 DB 100,100,141,100,7,233,200,99 DB 241,241,227,241,219,18,255,42 DB 241,241,227,241,219,18,255,42 DB 115,115,209,115,191,162,230,204 DB 115,115,209,115,191,162,230,204 DB 18,18,72,18,144,90,36,130 DB 18,18,72,18,144,90,36,130 DB 64,64,29,64,58,93,128,122 DB 64,64,29,64,58,93,128,122 DB 8,8,32,8,64,40,16,72 DB 8,8,32,8,64,40,16,72 DB 195,195,43,195,86,232,155,149 DB 195,195,43,195,86,232,155,149 DB 236,236,151,236,51,123,197,223 DB 236,236,151,236,51,123,197,223 DB 219,219,75,219,150,144,171,77 DB 219,219,75,219,150,144,171,77 DB 161,161,190,161,97,31,95,192 DB 161,161,190,161,97,31,95,192 DB 141,141,14,141,28,131,7,145 DB 141,141,14,141,28,131,7,145 DB 61,61,244,61,245,201,122,200 DB 61,61,244,61,245,201,122,200 DB 151,151,102,151,204,241,51,91 DB 151,151,102,151,204,241,51,91 DB 0,0,0,0,0,0,0,0 DB 0,0,0,0,0,0,0,0 DB 207,207,27,207,54,212,131,249 DB 207,207,27,207,54,212,131,249 DB 43,43,172,43,69,135,86,110 DB 43,43,172,43,69,135,86,110 DB 118,118,197,118,151,179,236,225 DB 118,118,197,118,151,179,236,225 DB 130,130,50,130,100,176,25,230 DB 130,130,50,130,100,176,25,230 DB 214,214,127,214,254,169,177,40 DB 214,214,127,214,254,169,177,40 DB 27,27,108,27,216,119,54,195 DB 27,27,108,27,216,119,54,195 DB 181,181,238,181,193,91,119,116 DB 181,181,238,181,193,91,119,116 DB 175,175,134,175,17,41,67,190 DB 175,175,134,175,17,41,67,190 DB 106,106,181,106,119,223,212,29 DB 106,106,181,106,119,223,212,29 DB 80,80,93,80,186,13,160,234 DB 80,80,93,80,186,13,160,234 DB 69,69,9,69,18,76,138,87 DB 69,69,9,69,18,76,138,87 DB 243,243,235,243,203,24,251,56 DB 243,243,235,243,203,24,251,56 DB 48,48,192,48,157,240,96,173 DB 48,48,192,48,157,240,96,173 DB 239,239,155,239,43,116,195,196 DB 239,239,155,239,43,116,195,196 DB 63,63,252,63,229,195,126,218 DB 63,63,252,63,229,195,126,218 DB 85,85,73,85,146,28,170,199 DB 85,85,73,85,146,28,170,199 DB 162,162,178,162,121,16,89,219 DB 162,162,178,162,121,16,89,219 DB 234,234,143,234,3,101,201,233 DB 234,234,143,234,3,101,201,233 DB 101,101,137,101,15,236,202,106 DB 101,101,137,101,15,236,202,106 DB 186,186,210,186,185,104,105,3 DB 186,186,210,186,185,104,105,3 DB 47,47,188,47,101,147,94,74 DB 47,47,188,47,101,147,94,74 DB 192,192,39,192,78,231,157,142 DB 192,192,39,192,78,231,157,142 DB 222,222,95,222,190,129,161,96 DB 222,222,95,222,190,129,161,96 DB 28,28,112,28,224,108,56,252 DB 28,28,112,28,224,108,56,252 DB 253,253,211,253,187,46,231,70 DB 253,253,211,253,187,46,231,70 DB 77,77,41,77,82,100,154,31 DB 77,77,41,77,82,100,154,31 DB 146,146,114,146,228,224,57,118 DB 146,146,114,146,228,224,57,118 DB 117,117,201,117,143,188,234,250 DB 117,117,201,117,143,188,234,250 DB 6,6,24,6,48,30,12,54 DB 6,6,24,6,48,30,12,54 DB 138,138,18,138,36,152,9,174 DB 138,138,18,138,36,152,9,174 DB 178,178,242,178,249,64,121,75 DB 178,178,242,178,249,64,121,75 DB 230,230,191,230,99,89,209,133 DB 230,230,191,230,99,89,209,133 DB 14,14,56,14,112,54,28,126 DB 14,14,56,14,112,54,28,126 DB 31,31,124,31,248,99,62,231 DB 31,31,124,31,248,99,62,231 DB 98,98,149,98,55,247,196,85 DB 98,98,149,98,55,247,196,85 DB 212,212,119,212,238,163,181,58 DB 212,212,119,212,238,163,181,58 DB 168,168,154,168,41,50,77,129 DB 168,168,154,168,41,50,77,129 DB 150,150,98,150,196,244,49,82 DB 150,150,98,150,196,244,49,82 DB 249,249,195,249,155,58,239,98 DB 249,249,195,249,155,58,239,98 DB 197,197,51,197,102,246,151,163 DB 197,197,51,197,102,246,151,163 DB 37,37,148,37,53,177,74,16 DB 37,37,148,37,53,177,74,16 DB 89,89,121,89,242,32,178,171 DB 89,89,121,89,242,32,178,171 DB 132,132,42,132,84,174,21,208 DB 132,132,42,132,84,174,21,208 DB 114,114,213,114,183,167,228,197 DB 114,114,213,114,183,167,228,197 DB 57,57,228,57,213,221,114,236 DB 57,57,228,57,213,221,114,236 DB 76,76,45,76,90,97,152,22 DB 76,76,45,76,90,97,152,22 DB 94,94,101,94,202,59,188,148 DB 94,94,101,94,202,59,188,148 DB 120,120,253,120,231,133,240,159 DB 120,120,253,120,231,133,240,159 DB 56,56,224,56,221,216,112,229 DB 56,56,224,56,221,216,112,229 DB 140,140,10,140,20,134,5,152 DB 140,140,10,140,20,134,5,152 DB 209,209,99,209,198,178,191,23 DB 209,209,99,209,198,178,191,23 DB 165,165,174,165,65,11,87,228 DB 165,165,174,165,65,11,87,228 DB 226,226,175,226,67,77,217,161 DB 226,226,175,226,67,77,217,161 DB 97,97,153,97,47,248,194,78 DB 97,97,153,97,47,248,194,78 DB 179,179,246,179,241,69,123,66 DB 179,179,246,179,241,69,123,66 DB 33,33,132,33,21,165,66,52 DB 33,33,132,33,21,165,66,52 DB 156,156,74,156,148,214,37,8 DB 156,156,74,156,148,214,37,8 DB 30,30,120,30,240,102,60,238 DB 30,30,120,30,240,102,60,238 DB 67,67,17,67,34,82,134,97 DB 67,67,17,67,34,82,134,97 DB 199,199,59,199,118,252,147,177 DB 199,199,59,199,118,252,147,177 DB 252,252,215,252,179,43,229,79 DB 252,252,215,252,179,43,229,79 DB 4,4,16,4,32,20,8,36 DB 4,4,16,4,32,20,8,36 DB 81,81,89,81,178,8,162,227 DB 81,81,89,81,178,8,162,227 DB 153,153,94,153,188,199,47,37 DB 153,153,94,153,188,199,47,37 DB 109,109,169,109,79,196,218,34 DB 109,109,169,109,79,196,218,34 DB 13,13,52,13,104,57,26,101 DB 13,13,52,13,104,57,26,101 DB 250,250,207,250,131,53,233,121 DB 250,250,207,250,131,53,233,121 DB 223,223,91,223,182,132,163,105 DB 223,223,91,223,182,132,163,105 DB 126,126,229,126,215,155,252,169 DB 126,126,229,126,215,155,252,169 DB 36,36,144,36,61,180,72,25 DB 36,36,144,36,61,180,72,25 DB 59,59,236,59,197,215,118,254 DB 59,59,236,59,197,215,118,254 DB 171,171,150,171,49,61,75,154 DB 171,171,150,171,49,61,75,154 DB 206,206,31,206,62,209,129,240 DB 206,206,31,206,62,209,129,240 DB 17,17,68,17,136,85,34,153 DB 17,17,68,17,136,85,34,153 DB 143,143,6,143,12,137,3,131 DB 143,143,6,143,12,137,3,131 DB 78,78,37,78,74,107,156,4 DB 78,78,37,78,74,107,156,4 DB 183,183,230,183,209,81,115,102 DB 183,183,230,183,209,81,115,102 DB 235,235,139,235,11,96,203,224 DB 235,235,139,235,11,96,203,224 DB 60,60,240,60,253,204,120,193 DB 60,60,240,60,253,204,120,193 DB 129,129,62,129,124,191,31,253 DB 129,129,62,129,124,191,31,253 DB 148,148,106,148,212,254,53,64 DB 148,148,106,148,212,254,53,64 DB 247,247,251,247,235,12,243,28 DB 247,247,251,247,235,12,243,28 DB 185,185,222,185,161,103,111,24 DB 185,185,222,185,161,103,111,24 DB 19,19,76,19,152,95,38,139 DB 19,19,76,19,152,95,38,139 DB 44,44,176,44,125,156,88,81 DB 44,44,176,44,125,156,88,81 DB 211,211,107,211,214,184,187,5 DB 211,211,107,211,214,184,187,5 DB 231,231,187,231,107,92,211,140 DB 231,231,187,231,107,92,211,140 DB 110,110,165,110,87,203,220,57 DB 110,110,165,110,87,203,220,57 DB 196,196,55,196,110,243,149,170 DB 196,196,55,196,110,243,149,170 DB 3,3,12,3,24,15,6,27 DB 3,3,12,3,24,15,6,27 DB 86,86,69,86,138,19,172,220 DB 86,86,69,86,138,19,172,220 DB 68,68,13,68,26,73,136,94 DB 68,68,13,68,26,73,136,94 DB 127,127,225,127,223,158,254,160 DB 127,127,225,127,223,158,254,160 DB 169,169,158,169,33,55,79,136 DB 169,169,158,169,33,55,79,136 DB 42,42,168,42,77,130,84,103 DB 42,42,168,42,77,130,84,103 DB 187,187,214,187,177,109,107,10 DB 187,187,214,187,177,109,107,10 DB 193,193,35,193,70,226,159,135 DB 193,193,35,193,70,226,159,135 DB 83,83,81,83,162,2,166,241 DB 83,83,81,83,162,2,166,241 DB 220,220,87,220,174,139,165,114 DB 220,220,87,220,174,139,165,114 DB 11,11,44,11,88,39,22,83 DB 11,11,44,11,88,39,22,83 DB 157,157,78,157,156,211,39,1 DB 157,157,78,157,156,211,39,1 DB 108,108,173,108,71,193,216,43 DB 108,108,173,108,71,193,216,43 DB 49,49,196,49,149,245,98,164 DB 49,49,196,49,149,245,98,164 DB 116,116,205,116,135,185,232,243 DB 116,116,205,116,135,185,232,243 DB 246,246,255,246,227,9,241,21 DB 246,246,255,246,227,9,241,21 DB 70,70,5,70,10,67,140,76 DB 70,70,5,70,10,67,140,76 DB 172,172,138,172,9,38,69,165 DB 172,172,138,172,9,38,69,165 DB 137,137,30,137,60,151,15,181 DB 137,137,30,137,60,151,15,181 DB 20,20,80,20,160,68,40,180 DB 20,20,80,20,160,68,40,180 DB 225,225,163,225,91,66,223,186 DB 225,225,163,225,91,66,223,186 DB 22,22,88,22,176,78,44,166 DB 22,22,88,22,176,78,44,166 DB 58,58,232,58,205,210,116,247 DB 58,58,232,58,205,210,116,247 DB 105,105,185,105,111,208,210,6 DB 105,105,185,105,111,208,210,6 DB 9,9,36,9,72,45,18,65 DB 9,9,36,9,72,45,18,65 DB 112,112,221,112,167,173,224,215 DB 112,112,221,112,167,173,224,215 DB 182,182,226,182,217,84,113,111 DB 182,182,226,182,217,84,113,111 DB 208,208,103,208,206,183,189,30 DB 208,208,103,208,206,183,189,30 DB 237,237,147,237,59,126,199,214 DB 237,237,147,237,59,126,199,214 DB 204,204,23,204,46,219,133,226 DB 204,204,23,204,46,219,133,226 DB 66,66,21,66,42,87,132,104 DB 66,66,21,66,42,87,132,104 DB 152,152,90,152,180,194,45,44 DB 152,152,90,152,180,194,45,44 DB 164,164,170,164,73,14,85,237 DB 164,164,170,164,73,14,85,237 DB 40,40,160,40,93,136,80,117 DB 40,40,160,40,93,136,80,117 DB 92,92,109,92,218,49,184,134 DB 92,92,109,92,218,49,184,134 DB 248,248,199,248,147,63,237,107 DB 248,248,199,248,147,63,237,107 DB 134,134,34,134,68,164,17,194 DB 134,134,34,134,68,164,17,194 DB 24,35,198,232,135,184,1,79 DB 54,166,210,245,121,111,145,82 DB 96,188,155,142,163,12,123,53 DB 29,224,215,194,46,75,254,87 DB 21,119,55,229,159,240,74,218 DB 88,201,41,10,177,160,107,133 DB 189,93,16,244,203,62,5,103 DB 228,39,65,139,167,125,149,216 DB 251,238,124,102,221,23,71,158 DB 202,45,191,7,173,90,131,51 _whirlpool_block_mmx ENDP .text$ ENDS END
tools-src/gnu/gcc/gcc/ada/exp_ch3.adb
enfoTek/tomato.linksys.e2000.nvram-mod
80
10739
<reponame>enfoTek/tomato.linksys.e2000.nvram-mod<gh_stars>10-100 ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ C H 3 -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001 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 2, 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 COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Checks; use Checks; with Einfo; use Einfo; with Elists; use Elists; with Exp_Aggr; use Exp_Aggr; with Exp_Ch4; use Exp_Ch4; with Exp_Ch7; use Exp_Ch7; with Exp_Ch9; use Exp_Ch9; with Exp_Ch11; use Exp_Ch11; with Exp_Disp; use Exp_Disp; with Exp_Dist; use Exp_Dist; with Exp_Smem; use Exp_Smem; with Exp_Strm; use Exp_Strm; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Freeze; use Freeze; with Hostparm; use Hostparm; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Restrict; use Restrict; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Ch3; use Sem_Ch3; with Sem_Ch8; use Sem_Ch8; with Sem_Eval; use Sem_Eval; with Sem_Mech; use Sem_Mech; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Stand; use Stand; with Snames; use Snames; with Tbuild; use Tbuild; with Ttypes; use Ttypes; with Uintp; use Uintp; with Validsw; use Validsw; package body Exp_Ch3 is ----------------------- -- Local Subprograms -- ----------------------- procedure Adjust_Discriminants (Rtype : Entity_Id); -- This is used when freezing a record type. It attempts to construct -- more restrictive subtypes for discriminants so that the max size of -- the record can be calculated more accurately. See the body of this -- procedure for details. procedure Build_Array_Init_Proc (A_Type : Entity_Id; Nod : Node_Id); -- Build initialization procedure for given array type. Nod is a node -- used for attachment of any actions required in its construction. -- It also supplies the source location used for the procedure. procedure Build_Class_Wide_Master (T : Entity_Id); -- for access to class-wide limited types we must build a task master -- because some subsequent extension may add a task component. To avoid -- bringing in the tasking run-time whenever an access-to-class-wide -- limited type is used, we use the soft-link mechanism and add a level -- of indirection to calls to routines that manipulate Master_Ids. function Build_Discriminant_Formals (Rec_Id : Entity_Id; Use_Dl : Boolean) return List_Id; -- This function uses the discriminants of a type to build a list of -- formal parameters, used in the following function. If the flag Use_Dl -- is set, the list is built using the already defined discriminals -- of the type. Otherwise new identifiers are created, with the source -- names of the discriminants. procedure Build_Master_Renaming (N : Node_Id; T : Entity_Id); -- If the designated type of an access type is a task type or contains -- tasks, we make sure that a _Master variable is declared in the current -- scope, and then declare a renaming for it: -- -- atypeM : Master_Id renames _Master; -- -- where atyp is the name of the access type. This declaration is -- used when an allocator for the access type is expanded. The node N -- is the full declaration of the designated type that contains tasks. -- The renaming declaration is inserted before N, and after the Master -- declaration. procedure Build_Record_Init_Proc (N : Node_Id; Pe : Entity_Id); -- Build record initialization procedure. N is the type declaration -- node, and Pe is the corresponding entity for the record type. procedure Build_Variant_Record_Equality (Typ : Entity_Id); -- Create An Equality function for the non-tagged variant record 'Typ' -- and attach it to the TSS list procedure Expand_Tagged_Root (T : Entity_Id); -- Add a field _Tag at the beginning of the record. This field carries -- the value of the access to the Dispatch table. This procedure is only -- called on root (non CPP_Class) types, the _Tag field being inherited -- by the descendants. procedure Expand_Record_Controller (T : Entity_Id); -- T must be a record type that Has_Controlled_Component. Add a field _C -- of type Record_Controller or Limited_Record_Controller in the record T. procedure Freeze_Array_Type (N : Node_Id); -- Freeze an array type. Deals with building the initialization procedure, -- creating the packed array type for a packed array and also with the -- creation of the controlling procedures for the controlled case. The -- argument N is the N_Freeze_Entity node for the type. procedure Freeze_Enumeration_Type (N : Node_Id); -- Freeze enumeration type with non-standard representation. Builds the -- array and function needed to convert between enumeration pos and -- enumeration representation values. N is the N_Freeze_Entity node -- for the type. procedure Freeze_Record_Type (N : Node_Id); -- Freeze record type. Builds all necessary discriminant checking -- and other ancillary functions, and builds dispatch tables where -- needed. The argument N is the N_Freeze_Entity node. This processing -- applies only to E_Record_Type entities, not to class wide types, -- record subtypes, or private types. function Init_Formals (Typ : Entity_Id) return List_Id; -- This function builds the list of formals for an initialization routine. -- The first formal is always _Init with the given type. For task value -- record types and types containing tasks, three additional formals are -- added: -- -- _Master : Master_Id -- _Chain : in out Activation_Chain -- _Task_Id : Task_Image_Type -- -- The caller must append additional entries for discriminants if required. function In_Runtime (E : Entity_Id) return Boolean; -- Check if E is defined in the RTL (in a child of Ada or System). Used -- to avoid to bring in the overhead of _Input, _Output for tagged types. function Make_Eq_Case (Node : Node_Id; CL : Node_Id) return List_Id; -- Building block for variant record equality. Defined to share the -- code between the tagged and non-tagged case. Given a Component_List -- node CL, it generates an 'if' followed by a 'case' statement that -- compares all components of local temporaries named X and Y (that -- are declared as formals at some upper level). Node provides the -- Sloc to be used for the generated code. function Make_Eq_If (Node : Node_Id; L : List_Id) return Node_Id; -- Building block for variant record equality. Defined to share the -- code between the tagged and non-tagged case. Given the list of -- components (or discriminants) L, it generates a return statement -- that compares all components of local temporaries named X and Y -- (that are declared as formals at some upper level). Node provides -- the Sloc to be used for the generated code. procedure Make_Predefined_Primitive_Specs (Tag_Typ : Entity_Id; Predef_List : out List_Id; Renamed_Eq : out Node_Id); -- Create a list with the specs of the predefined primitive operations. -- This list contains _Size, _Read, _Write, _Input and _Output for -- every tagged types, plus _equality, _assign, _deep_finalize and -- _deep_adjust for non limited tagged types. _Size, _Read, _Write, -- _Input and _Output implement the corresponding attributes that need -- to be dispatching when their arguments are classwide. _equality and -- _assign, implement equality and assignment that also must be -- dispatching. _Deep_Finalize and _Deep_Adjust are empty procedures -- unless the type contains some controlled components that require -- finalization actions. The list is returned in Predef_List. The -- parameter Renamed_Eq either returns the value Empty, or else the -- defining unit name for the predefined equality function in the -- case where the type has a primitive operation that is a renaming -- of predefined equality (but only if there is also an overriding -- user-defined equality function). The returned Renamed_Eq will be -- passed to the corresponding parameter of Predefined_Primitive_Bodies. function Has_New_Non_Standard_Rep (T : Entity_Id) return Boolean; -- returns True if there are representation clauses for type T that -- are not inherited. If the result is false, the init_proc and the -- discriminant_checking functions of the parent can be reused by -- a derived type. function Predef_Spec_Or_Body (Loc : Source_Ptr; Tag_Typ : Entity_Id; Name : Name_Id; Profile : List_Id; Ret_Type : Entity_Id := Empty; For_Body : Boolean := False) return Node_Id; -- This function generates the appropriate expansion for a predefined -- primitive operation specified by its name, parameter profile and -- return type (Empty means this is a procedure). If For_Body is false, -- then the returned node is a subprogram declaration. If For_Body is -- true, then the returned node is a empty subprogram body containing -- no declarations and no statements. function Predef_Stream_Attr_Spec (Loc : Source_Ptr; Tag_Typ : Entity_Id; Name : Name_Id; For_Body : Boolean := False) return Node_Id; -- Specialized version of Predef_Spec_Or_Body that apply to _read, _write, -- _input and _output whose specs are constructed in Exp_Strm. function Predef_Deep_Spec (Loc : Source_Ptr; Tag_Typ : Entity_Id; Name : Name_Id; For_Body : Boolean := False) return Node_Id; -- Specialized version of Predef_Spec_Or_Body that apply to _deep_adjust -- and _deep_finalize function Predefined_Primitive_Bodies (Tag_Typ : Entity_Id; Renamed_Eq : Node_Id) return List_Id; -- Create the bodies of the predefined primitives that are described in -- Predefined_Primitive_Specs. When not empty, Renamed_Eq must denote -- the defining unit name of the type's predefined equality as returned -- by Make_Predefined_Primitive_Specs. function Predefined_Primitive_Freeze (Tag_Typ : Entity_Id) return List_Id; -- Freeze entities of all predefined primitive operations. This is needed -- because the bodies of these operations do not normally do any freezeing. -------------------------- -- Adjust_Discriminants -- -------------------------- -- This procedure attempts to define subtypes for discriminants that -- are more restrictive than those declared. Such a replacement is -- possible if we can demonstrate that values outside the restricted -- range would cause constraint errors in any case. The advantage of -- restricting the discriminant types in this way is tha the maximum -- size of the variant record can be calculated more conservatively. -- An example of a situation in which we can perform this type of -- restriction is the following: -- subtype B is range 1 .. 10; -- type Q is array (B range <>) of Integer; -- type V (N : Natural) is record -- C : Q (1 .. N); -- end record; -- In this situation, we can restrict the upper bound of N to 10, since -- any larger value would cause a constraint error in any case. -- There are many situations in which such restriction is possible, but -- for now, we just look for cases like the above, where the component -- in question is a one dimensional array whose upper bound is one of -- the record discriminants. Also the component must not be part of -- any variant part, since then the component does not always exist. procedure Adjust_Discriminants (Rtype : Entity_Id) is Loc : constant Source_Ptr := Sloc (Rtype); Comp : Entity_Id; Ctyp : Entity_Id; Ityp : Entity_Id; Lo : Node_Id; Hi : Node_Id; P : Node_Id; Loval : Uint; Discr : Entity_Id; Dtyp : Entity_Id; Dhi : Node_Id; Dhiv : Uint; Ahi : Node_Id; Ahiv : Uint; Tnn : Entity_Id; begin Comp := First_Component (Rtype); while Present (Comp) loop -- If our parent is a variant, quit, we do not look at components -- that are in variant parts, because they may not always exist. P := Parent (Comp); -- component declaration P := Parent (P); -- component list exit when Nkind (Parent (P)) = N_Variant; -- We are looking for a one dimensional array type Ctyp := Etype (Comp); if not Is_Array_Type (Ctyp) or else Number_Dimensions (Ctyp) > 1 then goto Continue; end if; -- The lower bound must be constant, and the upper bound is a -- discriminant (which is a discriminant of the current record). Ityp := Etype (First_Index (Ctyp)); Lo := Type_Low_Bound (Ityp); Hi := Type_High_Bound (Ityp); if not Compile_Time_Known_Value (Lo) or else Nkind (Hi) /= N_Identifier or else No (Entity (Hi)) or else Ekind (Entity (Hi)) /= E_Discriminant then goto Continue; end if; -- We have an array with appropriate bounds Loval := Expr_Value (Lo); Discr := Entity (Hi); Dtyp := Etype (Discr); -- See if the discriminant has a known upper bound Dhi := Type_High_Bound (Dtyp); if not Compile_Time_Known_Value (Dhi) then goto Continue; end if; Dhiv := Expr_Value (Dhi); -- See if base type of component array has known upper bound Ahi := Type_High_Bound (Etype (First_Index (Base_Type (Ctyp)))); if not Compile_Time_Known_Value (Ahi) then goto Continue; end if; Ahiv := Expr_Value (Ahi); -- The condition for doing the restriction is that the high bound -- of the discriminant is greater than the low bound of the array, -- and is also greater than the high bound of the base type index. if Dhiv > Loval and then Dhiv > Ahiv then -- We can reset the upper bound of the discriminant type to -- whichever is larger, the low bound of the component, or -- the high bound of the base type array index. -- We build a subtype that is declared as -- subtype Tnn is discr_type range discr_type'First .. max; -- And insert this declaration into the tree. The type of the -- discriminant is then reset to this more restricted subtype. Tnn := Make_Defining_Identifier (Loc, New_Internal_Name ('T')); Insert_Action (Declaration_Node (Rtype), Make_Subtype_Declaration (Loc, Defining_Identifier => Tnn, Subtype_Indication => Make_Subtype_Indication (Loc, Subtype_Mark => New_Occurrence_Of (Dtyp, Loc), Constraint => Make_Range_Constraint (Loc, Range_Expression => Make_Range (Loc, Low_Bound => Make_Attribute_Reference (Loc, Attribute_Name => Name_First, Prefix => New_Occurrence_Of (Dtyp, Loc)), High_Bound => Make_Integer_Literal (Loc, Intval => UI_Max (Loval, Ahiv))))))); Set_Etype (Discr, Tnn); end if; <<Continue>> Next_Component (Comp); end loop; end Adjust_Discriminants; --------------------------- -- Build_Array_Init_Proc -- --------------------------- procedure Build_Array_Init_Proc (A_Type : Entity_Id; Nod : Node_Id) is Loc : constant Source_Ptr := Sloc (Nod); Comp_Type : constant Entity_Id := Component_Type (A_Type); Index_List : List_Id; Proc_Id : Entity_Id; Proc_Body : Node_Id; Body_Stmts : List_Id; function Init_Component return List_Id; -- Create one statement to initialize one array component, designated -- by a full set of indices. function Init_One_Dimension (N : Int) return List_Id; -- Create loop to initialize one dimension of the array. The single -- statement in the loop body initializes the inner dimensions if any, -- or else the single component. Note that this procedure is called -- recursively, with N being the dimension to be initialized. A call -- with N greater than the number of dimensions simply generates the -- component initialization, terminating the recursion. -------------------- -- Init_Component -- -------------------- function Init_Component return List_Id is Comp : Node_Id; begin Comp := Make_Indexed_Component (Loc, Prefix => Make_Identifier (Loc, Name_uInit), Expressions => Index_List); if Needs_Simple_Initialization (Comp_Type) then Set_Assignment_OK (Comp); return New_List ( Make_Assignment_Statement (Loc, Name => Comp, Expression => Get_Simple_Init_Val (Comp_Type, Loc))); else return Build_Initialization_Call (Loc, Comp, Comp_Type, True, A_Type); end if; end Init_Component; ------------------------ -- Init_One_Dimension -- ------------------------ function Init_One_Dimension (N : Int) return List_Id is Index : Entity_Id; begin -- If the component does not need initializing, then there is nothing -- to do here, so we return a null body. This occurs when generating -- the dummy Init_Proc needed for Initialize_Scalars processing. if not Has_Non_Null_Base_Init_Proc (Comp_Type) and then not Needs_Simple_Initialization (Comp_Type) and then not Has_Task (Comp_Type) then return New_List (Make_Null_Statement (Loc)); -- If all dimensions dealt with, we simply initialize the component elsif N > Number_Dimensions (A_Type) then return Init_Component; -- Here we generate the required loop else Index := Make_Defining_Identifier (Loc, New_External_Name ('J', N)); Append (New_Reference_To (Index, Loc), Index_List); return New_List ( Make_Implicit_Loop_Statement (Nod, Identifier => Empty, Iteration_Scheme => Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, Defining_Identifier => Index, Discrete_Subtype_Definition => Make_Attribute_Reference (Loc, Prefix => Make_Identifier (Loc, Name_uInit), Attribute_Name => Name_Range, Expressions => New_List ( Make_Integer_Literal (Loc, N))))), Statements => Init_One_Dimension (N + 1))); end if; end Init_One_Dimension; -- Start of processing for Build_Array_Init_Proc begin if Suppress_Init_Proc (A_Type) then return; end if; Index_List := New_List; -- We need an initialization procedure if any of the following is true: -- 1. The component type has an initialization procedure -- 2. The component type needs simple initialization -- 3. Tasks are present -- 4. The type is marked as a publc entity -- The reason for the public entity test is to deal properly with the -- Initialize_Scalars pragma. This pragma can be set in the client and -- not in the declaring package, this means the client will make a call -- to the initialization procedure (because one of conditions 1-3 must -- apply in this case), and we must generate a procedure (even if it is -- null) to satisfy the call in this case. -- Exception: do not build an array init_proc for a type whose root type -- is Standard.String or Standard.Wide_String, since there is no place -- to put the code, and in any case we handle initialization of such -- types (in the Initialize_Scalars case, that's the only time the issue -- arises) in a special manner anyway which does not need an init_proc. if Has_Non_Null_Base_Init_Proc (Comp_Type) or else Needs_Simple_Initialization (Comp_Type) or else Has_Task (Comp_Type) or else (Is_Public (A_Type) and then Root_Type (A_Type) /= Standard_String and then Root_Type (A_Type) /= Standard_Wide_String) then Proc_Id := Make_Defining_Identifier (Loc, Name_uInit_Proc); Body_Stmts := Init_One_Dimension (1); Proc_Body := Make_Subprogram_Body (Loc, Specification => Make_Procedure_Specification (Loc, Defining_Unit_Name => Proc_Id, Parameter_Specifications => Init_Formals (A_Type)), Declarations => New_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Body_Stmts)); Set_Ekind (Proc_Id, E_Procedure); Set_Is_Public (Proc_Id, Is_Public (A_Type)); Set_Is_Inlined (Proc_Id); Set_Is_Internal (Proc_Id); Set_Has_Completion (Proc_Id); if not Debug_Generated_Code then Set_Debug_Info_Off (Proc_Id); end if; -- Associate Init_Proc with type, and determine if the procedure -- is null (happens because of the Initialize_Scalars pragma case, -- where we have to generate a null procedure in case it is called -- by a client with Initialize_Scalars set). Such procedures have -- to be generated, but do not have to be called, so we mark them -- as null to suppress the call. Set_Init_Proc (A_Type, Proc_Id); if List_Length (Body_Stmts) = 1 and then Nkind (First (Body_Stmts)) = N_Null_Statement then Set_Is_Null_Init_Proc (Proc_Id); end if; end if; end Build_Array_Init_Proc; ----------------------------- -- Build_Class_Wide_Master -- ----------------------------- procedure Build_Class_Wide_Master (T : Entity_Id) is Loc : constant Source_Ptr := Sloc (T); M_Id : Entity_Id; Decl : Node_Id; P : Node_Id; begin -- Nothing to do if there is no task hierarchy. if Restrictions (No_Task_Hierarchy) then return; end if; -- Nothing to do if we already built a master entity for this scope if not Has_Master_Entity (Scope (T)) then -- first build the master entity -- _Master : constant Master_Id := Current_Master.all; -- and insert it just before the current declaration Decl := Make_Object_Declaration (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uMaster), Constant_Present => True, Object_Definition => New_Reference_To (Standard_Integer, Loc), Expression => Make_Explicit_Dereference (Loc, New_Reference_To (RTE (RE_Current_Master), Loc))); P := Parent (T); Insert_Before (P, Decl); Analyze (Decl); Set_Has_Master_Entity (Scope (T)); -- Now mark the containing scope as a task master while Nkind (P) /= N_Compilation_Unit loop P := Parent (P); -- If we fall off the top, we are at the outer level, and the -- environment task is our effective master, so nothing to mark. if Nkind (P) = N_Task_Body or else Nkind (P) = N_Block_Statement or else Nkind (P) = N_Subprogram_Body then Set_Is_Task_Master (P, True); exit; end if; end loop; end if; -- Now define the renaming of the master_id. M_Id := Make_Defining_Identifier (Loc, New_External_Name (Chars (T), 'M')); Decl := Make_Object_Renaming_Declaration (Loc, Defining_Identifier => M_Id, Subtype_Mark => New_Reference_To (Standard_Integer, Loc), Name => Make_Identifier (Loc, Name_uMaster)); Insert_Before (Parent (T), Decl); Analyze (Decl); Set_Master_Id (T, M_Id); end Build_Class_Wide_Master; -------------------------------- -- Build_Discr_Checking_Funcs -- -------------------------------- procedure Build_Discr_Checking_Funcs (N : Node_Id) is Rec_Id : Entity_Id; Loc : Source_Ptr; Enclosing_Func_Id : Entity_Id; Sequence : Nat := 1; Type_Def : Node_Id; V : Node_Id; function Build_Case_Statement (Case_Id : Entity_Id; Variant : Node_Id) return Node_Id; -- Need documentation for this spec ??? function Build_Dcheck_Function (Case_Id : Entity_Id; Variant : Node_Id) return Entity_Id; -- Build the discriminant checking function for a given variant procedure Build_Dcheck_Functions (Variant_Part_Node : Node_Id); -- Builds the discriminant checking function for each variant of the -- given variant part of the record type. -------------------------- -- Build_Case_Statement -- -------------------------- function Build_Case_Statement (Case_Id : Entity_Id; Variant : Node_Id) return Node_Id is Actuals_List : List_Id; Alt_List : List_Id := New_List; Case_Node : Node_Id; Case_Alt_Node : Node_Id; Choice : Node_Id; Choice_List : List_Id; D : Entity_Id; Return_Node : Node_Id; begin -- Build a case statement containing only two alternatives. The -- first alternative corresponds exactly to the discrete choices -- given on the variant with contains the components that we are -- generating the checks for. If the discriminant is one of these -- return False. The other alternative consists of the choice -- "Others" and will return True indicating the discriminant did -- not match. Case_Node := New_Node (N_Case_Statement, Loc); -- Replace the discriminant which controls the variant, with the -- name of the formal of the checking function. Set_Expression (Case_Node, Make_Identifier (Loc, Chars (Case_Id))); Choice := First (Discrete_Choices (Variant)); if Nkind (Choice) = N_Others_Choice then Choice_List := New_Copy_List (Others_Discrete_Choices (Choice)); else Choice_List := New_Copy_List (Discrete_Choices (Variant)); end if; if not Is_Empty_List (Choice_List) then Case_Alt_Node := New_Node (N_Case_Statement_Alternative, Loc); Set_Discrete_Choices (Case_Alt_Node, Choice_List); -- In case this is a nested variant, we need to return the result -- of the discriminant checking function for the immediately -- enclosing variant. if Present (Enclosing_Func_Id) then Actuals_List := New_List; D := First_Discriminant (Rec_Id); while Present (D) loop Append (Make_Identifier (Loc, Chars (D)), Actuals_List); Next_Discriminant (D); end loop; Return_Node := Make_Return_Statement (Loc, Expression => Make_Function_Call (Loc, Name => New_Reference_To (Enclosing_Func_Id, Loc), Parameter_Associations => Actuals_List)); else Return_Node := Make_Return_Statement (Loc, Expression => New_Reference_To (Standard_False, Loc)); end if; Set_Statements (Case_Alt_Node, New_List (Return_Node)); Append (Case_Alt_Node, Alt_List); end if; Case_Alt_Node := New_Node (N_Case_Statement_Alternative, Loc); Choice_List := New_List (New_Node (N_Others_Choice, Loc)); Set_Discrete_Choices (Case_Alt_Node, Choice_List); Return_Node := Make_Return_Statement (Loc, Expression => New_Reference_To (Standard_True, Loc)); Set_Statements (Case_Alt_Node, New_List (Return_Node)); Append (Case_Alt_Node, Alt_List); Set_Alternatives (Case_Node, Alt_List); return Case_Node; end Build_Case_Statement; --------------------------- -- Build_Dcheck_Function -- --------------------------- function Build_Dcheck_Function (Case_Id : Entity_Id; Variant : Node_Id) return Entity_Id is Body_Node : Node_Id; Func_Id : Entity_Id; Parameter_List : List_Id; Spec_Node : Node_Id; begin Body_Node := New_Node (N_Subprogram_Body, Loc); Sequence := Sequence + 1; Func_Id := Make_Defining_Identifier (Loc, Chars => New_External_Name (Chars (Rec_Id), 'D', Sequence)); Spec_Node := New_Node (N_Function_Specification, Loc); Set_Defining_Unit_Name (Spec_Node, Func_Id); Parameter_List := Build_Discriminant_Formals (Rec_Id, False); Set_Parameter_Specifications (Spec_Node, Parameter_List); Set_Subtype_Mark (Spec_Node, New_Reference_To (Standard_Boolean, Loc)); Set_Specification (Body_Node, Spec_Node); Set_Declarations (Body_Node, New_List); Set_Handled_Statement_Sequence (Body_Node, Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Build_Case_Statement (Case_Id, Variant)))); Set_Ekind (Func_Id, E_Function); Set_Mechanism (Func_Id, Default_Mechanism); Set_Is_Inlined (Func_Id, True); Set_Is_Pure (Func_Id, True); Set_Is_Public (Func_Id, Is_Public (Rec_Id)); Set_Is_Internal (Func_Id, True); if not Debug_Generated_Code then Set_Debug_Info_Off (Func_Id); end if; Append_Freeze_Action (Rec_Id, Body_Node); Set_Dcheck_Function (Variant, Func_Id); return Func_Id; end Build_Dcheck_Function; ---------------------------- -- Build_Dcheck_Functions -- ---------------------------- procedure Build_Dcheck_Functions (Variant_Part_Node : Node_Id) is Component_List_Node : Node_Id; Decl : Entity_Id; Discr_Name : Entity_Id; Func_Id : Entity_Id; Variant : Node_Id; Saved_Enclosing_Func_Id : Entity_Id; begin -- Build the discriminant checking function for each variant, label -- all components of that variant with the function's name. Discr_Name := Entity (Name (Variant_Part_Node)); Variant := First_Non_Pragma (Variants (Variant_Part_Node)); while Present (Variant) loop Func_Id := Build_Dcheck_Function (Discr_Name, Variant); Component_List_Node := Component_List (Variant); if not Null_Present (Component_List_Node) then Decl := First_Non_Pragma (Component_Items (Component_List_Node)); while Present (Decl) loop Set_Discriminant_Checking_Func (Defining_Identifier (Decl), Func_Id); Next_Non_Pragma (Decl); end loop; if Present (Variant_Part (Component_List_Node)) then Saved_Enclosing_Func_Id := Enclosing_Func_Id; Enclosing_Func_Id := Func_Id; Build_Dcheck_Functions (Variant_Part (Component_List_Node)); Enclosing_Func_Id := Saved_Enclosing_Func_Id; end if; end if; Next_Non_Pragma (Variant); end loop; end Build_Dcheck_Functions; -- Start of processing for Build_Discr_Checking_Funcs begin -- Only build if not done already if not Discr_Check_Funcs_Built (N) then Type_Def := Type_Definition (N); if Nkind (Type_Def) = N_Record_Definition then if No (Component_List (Type_Def)) then -- null record. return; else V := Variant_Part (Component_List (Type_Def)); end if; else pragma Assert (Nkind (Type_Def) = N_Derived_Type_Definition); if No (Component_List (Record_Extension_Part (Type_Def))) then return; else V := Variant_Part (Component_List (Record_Extension_Part (Type_Def))); end if; end if; Rec_Id := Defining_Identifier (N); if Present (V) and then not Is_Unchecked_Union (Rec_Id) then Loc := Sloc (N); Enclosing_Func_Id := Empty; Build_Dcheck_Functions (V); end if; Set_Discr_Check_Funcs_Built (N); end if; end Build_Discr_Checking_Funcs; -------------------------------- -- Build_Discriminant_Formals -- -------------------------------- function Build_Discriminant_Formals (Rec_Id : Entity_Id; Use_Dl : Boolean) return List_Id is D : Entity_Id; Formal : Entity_Id; Loc : Source_Ptr := Sloc (Rec_Id); Param_Spec_Node : Node_Id; Parameter_List : List_Id := New_List; begin if Has_Discriminants (Rec_Id) then D := First_Discriminant (Rec_Id); while Present (D) loop Loc := Sloc (D); if Use_Dl then Formal := Discriminal (D); else Formal := Make_Defining_Identifier (Loc, Chars (D)); end if; Param_Spec_Node := Make_Parameter_Specification (Loc, Defining_Identifier => Formal, Parameter_Type => New_Reference_To (Etype (D), Loc)); Append (Param_Spec_Node, Parameter_List); Next_Discriminant (D); end loop; end if; return Parameter_List; end Build_Discriminant_Formals; ------------------------------- -- Build_Initialization_Call -- ------------------------------- -- References to a discriminant inside the record type declaration -- can appear either in the subtype_indication to constrain a -- record or an array, or as part of a larger expression given for -- the initial value of a component. In both of these cases N appears -- in the record initialization procedure and needs to be replaced by -- the formal parameter of the initialization procedure which -- corresponds to that discriminant. -- In the example below, references to discriminants D1 and D2 in proc_1 -- are replaced by references to formals with the same name -- (discriminals) -- A similar replacement is done for calls to any record -- initialization procedure for any components that are themselves -- of a record type. -- type R (D1, D2 : Integer) is record -- X : Integer := F * D1; -- Y : Integer := F * D2; -- end record; -- procedure proc_1 (Out_2 : out R; D1 : Integer; D2 : Integer) is -- begin -- Out_2.D1 := D1; -- Out_2.D2 := D2; -- Out_2.X := F * D1; -- Out_2.Y := F * D2; -- end; function Build_Initialization_Call (Loc : Source_Ptr; Id_Ref : Node_Id; Typ : Entity_Id; In_Init_Proc : Boolean := False; Enclos_Type : Entity_Id := Empty; Discr_Map : Elist_Id := New_Elmt_List) return List_Id is First_Arg : Node_Id; Args : List_Id; Decls : List_Id; Decl : Node_Id; Discr : Entity_Id; Arg : Node_Id; Proc : constant Entity_Id := Base_Init_Proc (Typ); Init_Type : constant Entity_Id := Etype (First_Formal (Proc)); Full_Init_Type : constant Entity_Id := Underlying_Type (Init_Type); Res : List_Id := New_List; Full_Type : Entity_Id := Typ; Controller_Typ : Entity_Id; begin -- Nothing to do if the Init_Proc is null, unless Initialize_Sclalars -- is active (in which case we make the call anyway, since in the -- actual compiled client it may be non null). if Is_Null_Init_Proc (Proc) and then not Init_Or_Norm_Scalars then return Empty_List; end if; -- Go to full view if private type if Is_Private_Type (Typ) and then Present (Full_View (Typ)) then Full_Type := Full_View (Typ); end if; -- If Typ is derived, the procedure is the initialization procedure for -- the root type. Wrap the argument in an conversion to make it type -- honest. Actually it isn't quite type honest, because there can be -- conflicts of views in the private type case. That is why we set -- Conversion_OK in the conversion node. if (Is_Record_Type (Typ) or else Is_Array_Type (Typ) or else Is_Private_Type (Typ)) and then Init_Type /= Base_Type (Typ) then First_Arg := OK_Convert_To (Etype (Init_Type), Id_Ref); Set_Etype (First_Arg, Init_Type); else First_Arg := Id_Ref; end if; Args := New_List (Convert_Concurrent (First_Arg, Typ)); -- In the tasks case, add _Master as the value of the _Master parameter -- and _Chain as the value of the _Chain parameter. At the outer level, -- these will be variables holding the corresponding values obtained -- from GNARL. At inner levels, they will be the parameters passed down -- through the outer routines. if Has_Task (Full_Type) then if Restrictions (No_Task_Hierarchy) then -- See comments in System.Tasking.Initialization.Init_RTS -- for the value 3. Append_To (Args, Make_Integer_Literal (Loc, 3)); else Append_To (Args, Make_Identifier (Loc, Name_uMaster)); end if; Append_To (Args, Make_Identifier (Loc, Name_uChain)); Decls := Build_Task_Image_Decls (Loc, Id_Ref, Enclos_Type); Decl := Last (Decls); Append_To (Args, New_Occurrence_Of (Defining_Identifier (Decl), Loc)); Append_List (Decls, Res); else Decls := No_List; Decl := Empty; end if; -- Add discriminant values if discriminants are present if Has_Discriminants (Full_Init_Type) then Discr := First_Discriminant (Full_Init_Type); while Present (Discr) loop -- If this is a discriminated concurrent type, the init_proc -- for the corresponding record is being called. Use that -- type directly to find the discriminant value, to handle -- properly intervening renamed discriminants. declare T : Entity_Id := Full_Type; begin if Is_Protected_Type (T) then T := Corresponding_Record_Type (T); end if; Arg := Get_Discriminant_Value ( Discr, T, Discriminant_Constraint (Full_Type)); end; if In_Init_Proc then -- Replace any possible references to the discriminant in the -- call to the record initialization procedure with references -- to the appropriate formal parameter. if Nkind (Arg) = N_Identifier and then Ekind (Entity (Arg)) = E_Discriminant then Arg := New_Reference_To (Discriminal (Entity (Arg)), Loc); -- Case of access discriminants. We replace the reference -- to the type by a reference to the actual object elsif Nkind (Arg) = N_Attribute_Reference and then Is_Access_Type (Etype (Arg)) and then Is_Entity_Name (Prefix (Arg)) and then Is_Type (Entity (Prefix (Arg))) then Arg := Make_Attribute_Reference (Loc, Prefix => New_Copy (Prefix (Id_Ref)), Attribute_Name => Name_Unrestricted_Access); -- Otherwise make a copy of the default expression. Note -- that we use the current Sloc for this, because we do not -- want the call to appear to be at the declaration point. -- Within the expression, replace discriminants with their -- discriminals. else Arg := New_Copy_Tree (Arg, Map => Discr_Map, New_Sloc => Loc); end if; else if Is_Constrained (Full_Type) then Arg := Duplicate_Subexpr (Arg); else -- The constraints come from the discriminant default -- exps, they must be reevaluated, so we use New_Copy_Tree -- but we ensure the proper Sloc (for any embedded calls). Arg := New_Copy_Tree (Arg, New_Sloc => Loc); end if; end if; Append_To (Args, Arg); Next_Discriminant (Discr); end loop; end if; -- If this is a call to initialize the parent component of a derived -- tagged type, indicate that the tag should not be set in the parent. if Is_Tagged_Type (Full_Init_Type) and then not Is_CPP_Class (Full_Init_Type) and then Nkind (Id_Ref) = N_Selected_Component and then Chars (Selector_Name (Id_Ref)) = Name_uParent then Append_To (Args, New_Occurrence_Of (Standard_False, Loc)); end if; Append_To (Res, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Proc, Loc), Parameter_Associations => Args)); if Controlled_Type (Typ) and then Nkind (Id_Ref) = N_Selected_Component then if Chars (Selector_Name (Id_Ref)) /= Name_uParent then Append_List_To (Res, Make_Init_Call ( Ref => New_Copy_Tree (First_Arg), Typ => Typ, Flist_Ref => Find_Final_List (Typ, New_Copy_Tree (First_Arg)), With_Attach => Make_Integer_Literal (Loc, 1))); -- If the enclosing type is an extension with new controlled -- components, it has his own record controller. If the parent -- also had a record controller, attach it to the new one. -- Build_Init_Statements relies on the fact that in this specific -- case the last statement of the result is the attach call to -- the controller. If this is changed, it must be synchronized. elsif Present (Enclos_Type) and then Has_New_Controlled_Component (Enclos_Type) and then Has_Controlled_Component (Typ) then if Is_Return_By_Reference_Type (Typ) then Controller_Typ := RTE (RE_Limited_Record_Controller); else Controller_Typ := RTE (RE_Record_Controller); end if; Append_List_To (Res, Make_Init_Call ( Ref => Make_Selected_Component (Loc, Prefix => New_Copy_Tree (First_Arg), Selector_Name => Make_Identifier (Loc, Name_uController)), Typ => Controller_Typ, Flist_Ref => Find_Final_List (Typ, New_Copy_Tree (First_Arg)), With_Attach => Make_Integer_Literal (Loc, 1))); end if; end if; -- Discard dynamic string allocated for name after call to init_proc, -- to avoid storage leaks. This is done for composite types because -- the allocated name is used as prefix for the id constructed at run- -- time, and this allocated name is not released when the task itself -- is freed. if Has_Task (Full_Type) and then not Is_Task_Type (Full_Type) then Append_To (Res, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Free_Task_Image), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Defining_Identifier (Decl), Loc)))); end if; return Res; end Build_Initialization_Call; --------------------------- -- Build_Master_Renaming -- --------------------------- procedure Build_Master_Renaming (N : Node_Id; T : Entity_Id) is Loc : constant Source_Ptr := Sloc (N); M_Id : Entity_Id; Decl : Node_Id; begin -- Nothing to do if there is no task hierarchy. if Restrictions (No_Task_Hierarchy) then return; end if; M_Id := Make_Defining_Identifier (Loc, New_External_Name (Chars (T), 'M')); Decl := Make_Object_Renaming_Declaration (Loc, Defining_Identifier => M_Id, Subtype_Mark => New_Reference_To (RTE (RE_Master_Id), Loc), Name => Make_Identifier (Loc, Name_uMaster)); Insert_Before (N, Decl); Analyze (Decl); Set_Master_Id (T, M_Id); end Build_Master_Renaming; ---------------------------- -- Build_Record_Init_Proc -- ---------------------------- procedure Build_Record_Init_Proc (N : Node_Id; Pe : Entity_Id) is Loc : Source_Ptr := Sloc (N); Proc_Id : Entity_Id; Rec_Type : Entity_Id; Discr_Map : Elist_Id := New_Elmt_List; Set_Tag : Entity_Id := Empty; function Build_Assignment (Id : Entity_Id; N : Node_Id) return List_Id; -- Build a assignment statement node which assigns to record -- component its default expression if defined. The left hand side -- of the assignment is marked Assignment_OK so that initialization -- of limited private records works correctly, Return also the -- adjustment call for controlled objects procedure Build_Discriminant_Assignments (Statement_List : List_Id); -- If the record has discriminants, adds assignment statements to -- statement list to initialize the discriminant values from the -- arguments of the initialization procedure. function Build_Init_Statements (Comp_List : Node_Id) return List_Id; -- Build a list representing a sequence of statements which initialize -- components of the given component list. This may involve building -- case statements for the variant parts. function Build_Init_Call_Thru (Parameters : List_Id) return List_Id; -- Given a non-tagged type-derivation that declares discriminants, -- such as -- -- type R (R1, R2 : Integer) is record ... end record; -- -- type D (D1 : Integer) is new R (1, D1); -- -- we make the _init_proc of D be -- -- procedure _init_proc(X : D; D1 : Integer) is -- begin -- _init_proc( R(X), 1, D1); -- end _init_proc; -- -- This function builds the call statement in this _init_proc. procedure Build_Init_Procedure; -- Build the tree corresponding to the procedure specification and body -- of the initialization procedure (by calling all the preceding -- auxiliary routines), and install it as the _init TSS. procedure Build_Record_Checks (S : Node_Id; Related_Nod : Node_Id; Check_List : List_Id); -- Add range checks to components of disciminated records. S is a -- subtype indication of a record component. Related_Nod is passed -- for compatibility with Process_Range_Expr_In_Decl. Check_List is -- a list to which the check actions are appended. function Component_Needs_Simple_Initialization (T : Entity_Id) return Boolean; -- Determines if a component needs simple initialization, given its -- type T. This is identical to Needs_Simple_Initialization, except -- that the types Tag and Vtable_Ptr, which are access types which -- would normally require simple initialization to null, do not -- require initialization as components, since they are explicitly -- initialized by other means. procedure Constrain_Array (SI : Node_Id; Related_Nod : Node_Id; Check_List : List_Id); -- Called from Build_Record_Checks. -- Apply a list of index constraints to an unconstrained array type. -- The first parameter is the entity for the resulting subtype. -- Related_Nod is passed for compatibility with Process_Range_Expr_In_ -- Decl. Check_List is a list to which the check actions are appended. procedure Constrain_Index (Index : Node_Id; S : Node_Id; Related_Nod : Node_Id; Check_List : List_Id); -- Called from Build_Record_Checks. -- Process an index constraint in a constrained array declaration. -- The constraint can be a subtype name, or a range with or without -- an explicit subtype mark. The index is the corresponding index of the -- unconstrained array. S is the range expression. Check_List is a list -- to which the check actions are appended. function Parent_Subtype_Renaming_Discrims return Boolean; -- Returns True for base types N that rename discriminants, else False function Requires_Init_Proc (Rec_Id : Entity_Id) return Boolean; -- Determines whether a record initialization procedure needs to be -- generated for the given record type. ---------------------- -- Build_Assignment -- ---------------------- function Build_Assignment (Id : Entity_Id; N : Node_Id) return List_Id is Exp : Node_Id := N; Lhs : Node_Id; Typ : constant Entity_Id := Underlying_Type (Etype (Id)); Kind : Node_Kind := Nkind (N); Res : List_Id; begin Loc := Sloc (N); Lhs := Make_Selected_Component (Loc, Prefix => Make_Identifier (Loc, Name_uInit), Selector_Name => New_Occurrence_Of (Id, Loc)); Set_Assignment_OK (Lhs); -- Case of an access attribute applied to the current -- instance. Replace the reference to the type by a -- reference to the actual object. (Note that this -- handles the case of the top level of the expression -- being given by such an attribute, but doesn't cover -- uses nested within an initial value expression. -- Nested uses are unlikely to occur in practice, -- but theoretically possible. It's not clear how -- to handle them without fully traversing the -- expression. ???) if Kind = N_Attribute_Reference and then (Attribute_Name (N) = Name_Unchecked_Access or else Attribute_Name (N) = Name_Unrestricted_Access) and then Is_Entity_Name (Prefix (N)) and then Is_Type (Entity (Prefix (N))) and then Entity (Prefix (N)) = Rec_Type then Exp := Make_Attribute_Reference (Loc, Prefix => Make_Identifier (Loc, Name_uInit), Attribute_Name => Name_Unrestricted_Access); end if; -- For a derived type the default value is copied from the component -- declaration of the parent. In the analysis of the init_proc for -- the parent the default value may have been expanded into a local -- variable, which is of course not usable here. We must copy the -- original expression and reanalyze. if Nkind (Exp) = N_Identifier and then not Comes_From_Source (Exp) and then Analyzed (Exp) and then not In_Open_Scopes (Scope (Entity (Exp))) and then Nkind (Original_Node (Exp)) = N_Aggregate then Exp := New_Copy_Tree (Original_Node (Exp)); end if; Res := New_List ( Make_Assignment_Statement (Loc, Name => Lhs, Expression => Exp)); Set_No_Ctrl_Actions (First (Res)); -- Adjust the tag if tagged (because of possible view conversions). -- Suppress the tag adjustment when Java_VM because JVM tags are -- represented implicitly in objects. if Is_Tagged_Type (Typ) and then not Java_VM then Append_To (Res, Make_Assignment_Statement (Loc, Name => Make_Selected_Component (Loc, Prefix => New_Copy_Tree (Lhs), Selector_Name => New_Reference_To (Tag_Component (Typ), Loc)), Expression => Unchecked_Convert_To (RTE (RE_Tag), New_Reference_To (Access_Disp_Table (Typ), Loc)))); end if; -- Adjust the component if controlled except if it is an -- aggregate that will be expanded inline if Kind = N_Qualified_Expression then Kind := Nkind (Parent (N)); end if; if Controlled_Type (Typ) and then not (Kind = N_Aggregate or else Kind = N_Extension_Aggregate) then Append_List_To (Res, Make_Adjust_Call ( Ref => New_Copy_Tree (Lhs), Typ => Etype (Id), Flist_Ref => Find_Final_List (Etype (Id), New_Copy_Tree (Lhs)), With_Attach => Make_Integer_Literal (Loc, 1))); end if; return Res; end Build_Assignment; ------------------------------------ -- Build_Discriminant_Assignments -- ------------------------------------ procedure Build_Discriminant_Assignments (Statement_List : List_Id) is D : Entity_Id; Is_Tagged : constant Boolean := Is_Tagged_Type (Rec_Type); begin if Has_Discriminants (Rec_Type) and then not Is_Unchecked_Union (Rec_Type) then D := First_Discriminant (Rec_Type); while Present (D) loop -- Don't generate the assignment for discriminants in derived -- tagged types if the discriminant is a renaming of some -- ancestor discriminant. This initialization will be done -- when initializing the _parent field of the derived record. if Is_Tagged and then Present (Corresponding_Discriminant (D)) then null; else Loc := Sloc (D); Append_List_To (Statement_List, Build_Assignment (D, New_Reference_To (Discriminal (D), Loc))); end if; Next_Discriminant (D); end loop; end if; end Build_Discriminant_Assignments; -------------------------- -- Build_Init_Call_Thru -- -------------------------- function Build_Init_Call_Thru (Parameters : List_Id) return List_Id is Parent_Proc : constant Entity_Id := Base_Init_Proc (Etype (Rec_Type)); Parent_Type : constant Entity_Id := Etype (First_Formal (Parent_Proc)); Uparent_Type : constant Entity_Id := Underlying_Type (Parent_Type); First_Discr_Param : Node_Id; Parent_Discr : Entity_Id; First_Arg : Node_Id; Args : List_Id; Arg : Node_Id; Res : List_Id; begin -- First argument (_Init) is the object to be initialized. -- ??? not sure where to get a reasonable Loc for First_Arg First_Arg := OK_Convert_To (Parent_Type, New_Reference_To (Defining_Identifier (First (Parameters)), Loc)); Set_Etype (First_Arg, Parent_Type); Args := New_List (Convert_Concurrent (First_Arg, Rec_Type)); -- In the tasks case, -- add _Master as the value of the _Master parameter -- add _Chain as the value of the _Chain parameter. -- add _Task_Id as the value of the _Task_Id parameter. -- At the outer level, these will be variables holding the -- corresponding values obtained from GNARL or the expander. -- -- At inner levels, they will be the parameters passed down through -- the outer routines. First_Discr_Param := Next (First (Parameters)); if Has_Task (Rec_Type) then if Restrictions (No_Task_Hierarchy) then -- See comments in System.Tasking.Initialization.Init_RTS -- for the value 3. Append_To (Args, Make_Integer_Literal (Loc, 3)); else Append_To (Args, Make_Identifier (Loc, Name_uMaster)); end if; Append_To (Args, Make_Identifier (Loc, Name_uChain)); Append_To (Args, Make_Identifier (Loc, Name_uTask_Id)); First_Discr_Param := Next (Next (Next (First_Discr_Param))); end if; -- Append discriminant values if Has_Discriminants (Uparent_Type) then pragma Assert (not Is_Tagged_Type (Uparent_Type)); Parent_Discr := First_Discriminant (Uparent_Type); while Present (Parent_Discr) loop -- Get the initial value for this discriminant -- ?????? needs to be cleaned up to use parent_Discr_Constr -- directly. declare Discr_Value : Elmt_Id := First_Elmt (Girder_Constraint (Rec_Type)); Discr : Entity_Id := First_Girder_Discriminant (Uparent_Type); begin while Original_Record_Component (Parent_Discr) /= Discr loop Next_Girder_Discriminant (Discr); Next_Elmt (Discr_Value); end loop; Arg := Node (Discr_Value); end; -- Append it to the list if Nkind (Arg) = N_Identifier and then Ekind (Entity (Arg)) = E_Discriminant then Append_To (Args, New_Reference_To (Discriminal (Entity (Arg)), Loc)); -- Case of access discriminants. We replace the reference -- to the type by a reference to the actual object -- ??? -- elsif Nkind (Arg) = N_Attribute_Reference -- and then Is_Entity_Name (Prefix (Arg)) -- and then Is_Type (Entity (Prefix (Arg))) -- then -- Append_To (Args, -- Make_Attribute_Reference (Loc, -- Prefix => New_Copy (Prefix (Id_Ref)), -- Attribute_Name => Name_Unrestricted_Access)); else Append_To (Args, New_Copy (Arg)); end if; Next_Discriminant (Parent_Discr); end loop; end if; Res := New_List ( Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Parent_Proc, Loc), Parameter_Associations => Args)); return Res; end Build_Init_Call_Thru; -------------------------- -- Build_Init_Procedure -- -------------------------- procedure Build_Init_Procedure is Body_Node : Node_Id; Handled_Stmt_Node : Node_Id; Parameters : List_Id; Proc_Spec_Node : Node_Id; Body_Stmts : List_Id; Record_Extension_Node : Node_Id; Init_Tag : Node_Id; begin Body_Stmts := New_List; Body_Node := New_Node (N_Subprogram_Body, Loc); Proc_Id := Make_Defining_Identifier (Loc, Name_uInit_Proc); Set_Ekind (Proc_Id, E_Procedure); Proc_Spec_Node := New_Node (N_Procedure_Specification, Loc); Set_Defining_Unit_Name (Proc_Spec_Node, Proc_Id); Parameters := Init_Formals (Rec_Type); Append_List_To (Parameters, Build_Discriminant_Formals (Rec_Type, True)); -- For tagged types, we add a flag to indicate whether the routine -- is called to initialize a parent component in the init_proc of -- a type extension. If the flag is false, we do not set the tag -- because it has been set already in the extension. if Is_Tagged_Type (Rec_Type) and then not Is_CPP_Class (Rec_Type) then Set_Tag := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Append_To (Parameters, Make_Parameter_Specification (Loc, Defining_Identifier => Set_Tag, Parameter_Type => New_Occurrence_Of (Standard_Boolean, Loc), Expression => New_Occurrence_Of (Standard_True, Loc))); end if; Set_Parameter_Specifications (Proc_Spec_Node, Parameters); Set_Specification (Body_Node, Proc_Spec_Node); Set_Declarations (Body_Node, New_List); if Parent_Subtype_Renaming_Discrims then -- N is a Derived_Type_Definition that renames the parameters -- of the ancestor type. We init it by expanding our discrims -- and call the ancestor _init_proc with a type-converted object Append_List_To (Body_Stmts, Build_Init_Call_Thru (Parameters)); elsif Nkind (Type_Definition (N)) = N_Record_Definition then Build_Discriminant_Assignments (Body_Stmts); if not Null_Present (Type_Definition (N)) then Append_List_To (Body_Stmts, Build_Init_Statements ( Component_List (Type_Definition (N)))); end if; else -- N is a Derived_Type_Definition with a possible non-empty -- extension. The initialization of a type extension consists -- in the initialization of the components in the extension. Build_Discriminant_Assignments (Body_Stmts); Record_Extension_Node := Record_Extension_Part (Type_Definition (N)); if not Null_Present (Record_Extension_Node) then declare Stmts : List_Id := Build_Init_Statements ( Component_List (Record_Extension_Node)); begin -- The parent field must be initialized first because -- the offset of the new discriminants may depend on it Prepend_To (Body_Stmts, Remove_Head (Stmts)); Append_List_To (Body_Stmts, Stmts); end; end if; end if; -- Add here the assignment to instantiate the Tag -- The assignement corresponds to the code: -- _Init._Tag := Typ'Tag; -- Suppress the tag assignment when Java_VM because JVM tags are -- represented implicitly in objects. if Is_Tagged_Type (Rec_Type) and then not Is_CPP_Class (Rec_Type) and then not Java_VM then Init_Tag := Make_Assignment_Statement (Loc, Name => Make_Selected_Component (Loc, Prefix => Make_Identifier (Loc, Name_uInit), Selector_Name => New_Reference_To (Tag_Component (Rec_Type), Loc)), Expression => New_Reference_To (Access_Disp_Table (Rec_Type), Loc)); -- The tag must be inserted before the assignments to other -- components, because the initial value of the component may -- depend ot the tag (eg. through a dispatching operation on -- an access to the current type). The tag assignment is not done -- when initializing the parent component of a type extension, -- because in that case the tag is set in the extension. -- Extensions of imported C++ classes add a final complication, -- because we cannot inhibit tag setting in the constructor for -- the parent. In that case we insert the tag initialization -- after the calls to initialize the parent. Init_Tag := Make_If_Statement (Loc, Condition => New_Occurrence_Of (Set_Tag, Loc), Then_Statements => New_List (Init_Tag)); if not Is_CPP_Class (Etype (Rec_Type)) then Prepend_To (Body_Stmts, Init_Tag); else declare Nod : Node_Id := First (Body_Stmts); begin -- We assume the first init_proc call is for the parent while Present (Next (Nod)) and then (Nkind (Nod) /= N_Procedure_Call_Statement or else Chars (Name (Nod)) /= Name_uInit_Proc) loop Nod := Next (Nod); end loop; Insert_After (Nod, Init_Tag); end; end if; end if; Handled_Stmt_Node := New_Node (N_Handled_Sequence_Of_Statements, Loc); Set_Statements (Handled_Stmt_Node, Body_Stmts); Set_Exception_Handlers (Handled_Stmt_Node, No_List); Set_Handled_Statement_Sequence (Body_Node, Handled_Stmt_Node); if not Debug_Generated_Code then Set_Debug_Info_Off (Proc_Id); end if; -- Associate Init_Proc with type, and determine if the procedure -- is null (happens because of the Initialize_Scalars pragma case, -- where we have to generate a null procedure in case it is called -- by a client with Initialize_Scalars set). Such procedures have -- to be generated, but do not have to be called, so we mark them -- as null to suppress the call. Set_Init_Proc (Rec_Type, Proc_Id); if List_Length (Body_Stmts) = 1 and then Nkind (First (Body_Stmts)) = N_Null_Statement then Set_Is_Null_Init_Proc (Proc_Id); end if; end Build_Init_Procedure; --------------------------- -- Build_Init_Statements -- --------------------------- function Build_Init_Statements (Comp_List : Node_Id) return List_Id is Alt_List : List_Id; Statement_List : List_Id; Stmts : List_Id; Check_List : List_Id := New_List; Per_Object_Constraint_Components : Boolean; Decl : Node_Id; Variant : Node_Id; Id : Entity_Id; Typ : Entity_Id; begin if Null_Present (Comp_List) then return New_List (Make_Null_Statement (Loc)); end if; Statement_List := New_List; -- Loop through components, skipping pragmas, in 2 steps. The first -- step deals with regular components. The second step deals with -- components have per object constraints, and no explicit initia- -- lization. Per_Object_Constraint_Components := False; -- First step : regular components. Decl := First_Non_Pragma (Component_Items (Comp_List)); while Present (Decl) loop Loc := Sloc (Decl); Build_Record_Checks (Subtype_Indication (Decl), Decl, Check_List); Id := Defining_Identifier (Decl); Typ := Etype (Id); if Has_Per_Object_Constraint (Id) and then No (Expression (Decl)) then -- Skip processing for now and ask for a second pass Per_Object_Constraint_Components := True; else if Present (Expression (Decl)) then Stmts := Build_Assignment (Id, Expression (Decl)); elsif Has_Non_Null_Base_Init_Proc (Typ) then Stmts := Build_Initialization_Call (Loc, Make_Selected_Component (Loc, Prefix => Make_Identifier (Loc, Name_uInit), Selector_Name => New_Occurrence_Of (Id, Loc)), Typ, True, Rec_Type, Discr_Map => Discr_Map); elsif Component_Needs_Simple_Initialization (Typ) then Stmts := Build_Assignment (Id, Get_Simple_Init_Val (Typ, Loc)); else Stmts := No_List; end if; if Present (Check_List) then Append_List_To (Statement_List, Check_List); end if; if Present (Stmts) then -- Add the initialization of the record controller -- before the _Parent field is attached to it when -- the attachment can occur. It does not work to -- simply initialize the controller first: it must be -- initialized after the parent if the parent holds -- discriminants that can be used to compute the -- offset of the controller. This code relies on -- the last statement of the initialization call -- being the attachement of the parent. see -- Build_Initialization_Call. if Chars (Id) = Name_uController and then Rec_Type /= Etype (Rec_Type) and then Has_Controlled_Component (Etype (Rec_Type)) and then Has_New_Controlled_Component (Rec_Type) then Insert_List_Before (Last (Statement_List), Stmts); else Append_List_To (Statement_List, Stmts); end if; end if; end if; Next_Non_Pragma (Decl); end loop; if Per_Object_Constraint_Components then -- Second pass: components with per-object constraints Decl := First_Non_Pragma (Component_Items (Comp_List)); while Present (Decl) loop Loc := Sloc (Decl); Id := Defining_Identifier (Decl); Typ := Etype (Id); if Has_Per_Object_Constraint (Id) and then No (Expression (Decl)) then if Has_Non_Null_Base_Init_Proc (Typ) then Append_List_To (Statement_List, Build_Initialization_Call (Loc, Make_Selected_Component (Loc, Prefix => Make_Identifier (Loc, Name_uInit), Selector_Name => New_Occurrence_Of (Id, Loc)), Typ, True, Rec_Type, Discr_Map => Discr_Map)); elsif Component_Needs_Simple_Initialization (Typ) then Append_List_To (Statement_List, Build_Assignment (Id, Get_Simple_Init_Val (Typ, Loc))); end if; end if; Next_Non_Pragma (Decl); end loop; end if; -- Process the variant part if Present (Variant_Part (Comp_List)) then Alt_List := New_List; Variant := First_Non_Pragma (Variants (Variant_Part (Comp_List))); while Present (Variant) loop Loc := Sloc (Variant); Append_To (Alt_List, Make_Case_Statement_Alternative (Loc, Discrete_Choices => New_Copy_List (Discrete_Choices (Variant)), Statements => Build_Init_Statements (Component_List (Variant)))); Next_Non_Pragma (Variant); end loop; -- The expression of the case statement which is a reference -- to one of the discriminants is replaced by the appropriate -- formal parameter of the initialization procedure. Append_To (Statement_List, Make_Case_Statement (Loc, Expression => New_Reference_To (Discriminal ( Entity (Name (Variant_Part (Comp_List)))), Loc), Alternatives => Alt_List)); end if; -- For a task record type, add the task create call and calls -- to bind any interrupt (signal) entries. if Is_Task_Record_Type (Rec_Type) then Append_To (Statement_List, Make_Task_Create_Call (Rec_Type)); declare Task_Type : constant Entity_Id := Corresponding_Concurrent_Type (Rec_Type); Task_Decl : constant Node_Id := Parent (Task_Type); Task_Def : constant Node_Id := Task_Definition (Task_Decl); Vis_Decl : Node_Id; Ent : Entity_Id; begin if Present (Task_Def) then Vis_Decl := First (Visible_Declarations (Task_Def)); while Present (Vis_Decl) loop Loc := Sloc (Vis_Decl); if Nkind (Vis_Decl) = N_Attribute_Definition_Clause then if Get_Attribute_Id (Chars (Vis_Decl)) = Attribute_Address then Ent := Entity (Name (Vis_Decl)); if Ekind (Ent) = E_Entry then Append_To (Statement_List, Make_Procedure_Call_Statement (Loc, Name => New_Reference_To ( RTE (RE_Bind_Interrupt_To_Entry), Loc), Parameter_Associations => New_List ( Make_Selected_Component (Loc, Prefix => Make_Identifier (Loc, Name_uInit), Selector_Name => Make_Identifier (Loc, Name_uTask_Id)), Entry_Index_Expression ( Loc, Ent, Empty, Task_Type), Expression (Vis_Decl)))); end if; end if; end if; Next (Vis_Decl); end loop; end if; end; end if; -- For a protected type, add statements generated by -- Make_Initialize_Protection. if Is_Protected_Record_Type (Rec_Type) then Append_List_To (Statement_List, Make_Initialize_Protection (Rec_Type)); end if; -- If no initializations when generated for component declarations -- corresponding to this Statement_List, append a null statement -- to the Statement_List to make it a valid Ada tree. if Is_Empty_List (Statement_List) then Append (New_Node (N_Null_Statement, Loc), Statement_List); end if; return Statement_List; end Build_Init_Statements; ------------------------- -- Build_Record_Checks -- ------------------------- procedure Build_Record_Checks (S : Node_Id; Related_Nod : Node_Id; Check_List : List_Id) is P : Node_Id; Subtype_Mark_Id : Entity_Id; begin if Nkind (S) = N_Subtype_Indication then Find_Type (Subtype_Mark (S)); P := Parent (S); Subtype_Mark_Id := Entity (Subtype_Mark (S)); -- Remaining processing depends on type case Ekind (Subtype_Mark_Id) is when Array_Kind => Constrain_Array (S, Related_Nod, Check_List); when others => null; end case; end if; end Build_Record_Checks; ------------------------------------------- -- Component_Needs_Simple_Initialization -- ------------------------------------------- function Component_Needs_Simple_Initialization (T : Entity_Id) return Boolean is begin return Needs_Simple_Initialization (T) and then not Is_RTE (T, RE_Tag) and then not Is_RTE (T, RE_Vtable_Ptr); end Component_Needs_Simple_Initialization; --------------------- -- Constrain_Array -- --------------------- procedure Constrain_Array (SI : Node_Id; Related_Nod : Node_Id; Check_List : List_Id) is C : constant Node_Id := Constraint (SI); Number_Of_Constraints : Nat := 0; Index : Node_Id; S, T : Entity_Id; begin T := Entity (Subtype_Mark (SI)); if Ekind (T) in Access_Kind then T := Designated_Type (T); end if; S := First (Constraints (C)); while Present (S) loop Number_Of_Constraints := Number_Of_Constraints + 1; Next (S); end loop; -- In either case, the index constraint must provide a discrete -- range for each index of the array type and the type of each -- discrete range must be the same as that of the corresponding -- index. (RM 3.6.1) S := First (Constraints (C)); Index := First_Index (T); Analyze (Index); -- Apply constraints to each index type for J in 1 .. Number_Of_Constraints loop Constrain_Index (Index, S, Related_Nod, Check_List); Next (Index); Next (S); end loop; end Constrain_Array; --------------------- -- Constrain_Index -- --------------------- procedure Constrain_Index (Index : Node_Id; S : Node_Id; Related_Nod : Node_Id; Check_List : List_Id) is T : constant Entity_Id := Etype (Index); begin if Nkind (S) = N_Range then Process_Range_Expr_In_Decl (S, T, Related_Nod, Check_List); end if; end Constrain_Index; -------------------------------------- -- Parent_Subtype_Renaming_Discrims -- -------------------------------------- function Parent_Subtype_Renaming_Discrims return Boolean is De : Entity_Id; Dp : Entity_Id; begin if Base_Type (Pe) /= Pe then return False; end if; if Etype (Pe) = Pe or else not Has_Discriminants (Pe) or else Is_Constrained (Pe) or else Is_Tagged_Type (Pe) then return False; end if; -- If there are no explicit girder discriminants we have inherited -- the root type discriminants so far, so no renamings occurred. if First_Discriminant (Pe) = First_Girder_Discriminant (Pe) then return False; end if; -- Check if we have done some trivial renaming of the parent -- discriminants, i.e. someting like -- -- type DT (X1,X2: int) is new PT (X1,X2); De := First_Discriminant (Pe); Dp := First_Discriminant (Etype (Pe)); while Present (De) loop pragma Assert (Present (Dp)); if Corresponding_Discriminant (De) /= Dp then return True; end if; Next_Discriminant (De); Next_Discriminant (Dp); end loop; return Present (Dp); end Parent_Subtype_Renaming_Discrims; ------------------------ -- Requires_Init_Proc -- ------------------------ function Requires_Init_Proc (Rec_Id : Entity_Id) return Boolean is Comp_Decl : Node_Id; Id : Entity_Id; Typ : Entity_Id; begin -- Definitely do not need one if specifically suppressed if Suppress_Init_Proc (Rec_Id) then return False; end if; -- Otherwise we need to generate an initialization procedure if -- Is_CPP_Class is False and at least one of the following applies: -- 1. Discriminants are present, since they need to be initialized -- with the appropriate discriminant constraint expressions. -- However, the discriminant of an unchecked union does not -- count, since the discriminant is not present. -- 2. The type is a tagged type, since the implicit Tag component -- needs to be initialized with a pointer to the dispatch table. -- 3. The type contains tasks -- 4. One or more components has an initial value -- 5. One or more components is for a type which itself requires -- an initialization procedure. -- 6. One or more components is a type that requires simple -- initialization (see Needs_Simple_Initialization), except -- that types Tag and Vtable_Ptr are excluded, since fields -- of these types are initialized by other means. -- 7. The type is the record type built for a task type (since at -- the very least, Create_Task must be called) -- 8. The type is the record type built for a protected type (since -- at least Initialize_Protection must be called) -- 9. The type is marked as a public entity. The reason we add this -- case (even if none of the above apply) is to properly handle -- Initialize_Scalars. If a package is compiled without an IS -- pragma, and the client is compiled with an IS pragma, then -- the client will think an initialization procedure is present -- and call it, when in fact no such procedure is required, but -- since the call is generated, there had better be a routine -- at the other end of the call, even if it does nothing!) -- Note: the reason we exclude the CPP_Class case is ??? if Is_CPP_Class (Rec_Id) then return False; elsif Is_Public (Rec_Id) then return True; elsif (Has_Discriminants (Rec_Id) and then not Is_Unchecked_Union (Rec_Id)) or else Is_Tagged_Type (Rec_Id) or else Is_Concurrent_Record_Type (Rec_Id) or else Has_Task (Rec_Id) then return True; end if; Id := First_Component (Rec_Id); while Present (Id) loop Comp_Decl := Parent (Id); Typ := Etype (Id); if Present (Expression (Comp_Decl)) or else Has_Non_Null_Base_Init_Proc (Typ) or else Component_Needs_Simple_Initialization (Typ) then return True; end if; Next_Component (Id); end loop; return False; end Requires_Init_Proc; -- Start of processing for Build_Record_Init_Proc begin Rec_Type := Defining_Identifier (N); -- This may be full declaration of a private type, in which case -- the visible entity is a record, and the private entity has been -- exchanged with it in the private part of the current package. -- The initialization procedure is built for the record type, which -- is retrievable from the private entity. if Is_Incomplete_Or_Private_Type (Rec_Type) then Rec_Type := Underlying_Type (Rec_Type); end if; -- If there are discriminants, build the discriminant map to replace -- discriminants by their discriminals in complex bound expressions. -- These only arise for the corresponding records of protected types. if Is_Concurrent_Record_Type (Rec_Type) and then Has_Discriminants (Rec_Type) then declare Disc : Entity_Id; begin Disc := First_Discriminant (Rec_Type); while Present (Disc) loop Append_Elmt (Disc, Discr_Map); Append_Elmt (Discriminal (Disc), Discr_Map); Next_Discriminant (Disc); end loop; end; end if; -- Derived types that have no type extension can use the initialization -- procedure of their parent and do not need a procedure of their own. -- This is only correct if there are no representation clauses for the -- type or its parent, and if the parent has in fact been frozen so -- that its initialization procedure exists. if Is_Derived_Type (Rec_Type) and then not Is_Tagged_Type (Rec_Type) and then not Has_New_Non_Standard_Rep (Rec_Type) and then not Parent_Subtype_Renaming_Discrims and then Has_Non_Null_Base_Init_Proc (Etype (Rec_Type)) then Copy_TSS (Base_Init_Proc (Etype (Rec_Type)), Rec_Type); -- Otherwise if we need an initialization procedure, then build one, -- mark it as public and inlinable and as having a completion. elsif Requires_Init_Proc (Rec_Type) then Build_Init_Procedure; Set_Is_Public (Proc_Id, Is_Public (Pe)); -- The initialization of protected records is not worth inlining. -- In addition, when compiled for another unit for inlining purposes, -- it may make reference to entities that have not been elaborated -- yet. The initialization of controlled records contains a nested -- clean-up procedure that makes it impractical to inline as well, -- and leads to undefined symbols if inlined in a different unit. if not Is_Protected_Record_Type (Rec_Type) and then not Controlled_Type (Rec_Type) then Set_Is_Inlined (Proc_Id); end if; Set_Is_Internal (Proc_Id); Set_Has_Completion (Proc_Id); if not Debug_Generated_Code then Set_Debug_Info_Off (Proc_Id); end if; end if; end Build_Record_Init_Proc; ------------------------------------ -- Build_Variant_Record_Equality -- ------------------------------------ -- Generates: -- -- function _Equality (X, Y : T) return Boolean is -- begin -- -- Compare discriminants -- if False or else X.D1 /= Y.D1 or else X.D2 /= Y.D2 then -- return False; -- end if; -- -- Compare components -- if False or else X.C1 /= Y.C1 or else X.C2 /= Y.C2 then -- return False; -- end if; -- -- Compare variant part -- case X.D1 is -- when V1 => -- if False or else X.C2 /= Y.C2 or else X.C3 /= Y.C3 then -- return False; -- end if; -- ... -- when Vn => -- if False or else X.Cn /= Y.Cn then -- return False; -- end if; -- end case; -- return True; -- end _Equality; procedure Build_Variant_Record_Equality (Typ : Entity_Id) is Loc : constant Source_Ptr := Sloc (Typ); F : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uEquality); X : constant Entity_Id := Make_Defining_Identifier (Loc, Name_X); Y : constant Entity_Id := Make_Defining_Identifier (Loc, Name_Y); Def : constant Node_Id := Parent (Typ); Comps : constant Node_Id := Component_List (Type_Definition (Def)); Function_Body : Node_Id; Stmts : List_Id := New_List; begin if Is_Derived_Type (Typ) and then not Has_New_Non_Standard_Rep (Typ) then declare Parent_Eq : Entity_Id := TSS (Root_Type (Typ), Name_uEquality); begin if Present (Parent_Eq) then Copy_TSS (Parent_Eq, Typ); return; end if; end; end if; Function_Body := Make_Subprogram_Body (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => F, Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => X, Parameter_Type => New_Reference_To (Typ, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => Y, Parameter_Type => New_Reference_To (Typ, Loc))), Subtype_Mark => New_Reference_To (Standard_Boolean, Loc)), Declarations => New_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Stmts)); -- For unchecked union case, raise program error. This will only -- happen in the case of dynamic dispatching for a tagged type, -- since in the static cases it is a compile time error. if Has_Unchecked_Union (Typ) then Append_To (Stmts, Make_Raise_Program_Error (Loc)); else Append_To (Stmts, Make_Eq_If (Typ, Discriminant_Specifications (Def))); Append_List_To (Stmts, Make_Eq_Case (Typ, Comps)); end if; Append_To (Stmts, Make_Return_Statement (Loc, Expression => New_Reference_To (Standard_True, Loc))); Set_TSS (Typ, F); Set_Is_Pure (F); if not Debug_Generated_Code then Set_Debug_Info_Off (F); end if; end Build_Variant_Record_Equality; --------------------------- -- Expand_Derived_Record -- --------------------------- -- Add a field _parent at the beginning of the record extension. This is -- used to implement inheritance. Here are some examples of expansion: -- 1. no discriminants -- type T2 is new T1 with null record; -- gives -- type T2 is new T1 with record -- _Parent : T1; -- end record; -- 2. renamed discriminants -- type T2 (B, C : Int) is new T1 (A => B) with record -- _Parent : T1 (A => B); -- D : Int; -- end; -- 3. inherited discriminants -- type T2 is new T1 with record -- discriminant A inherited -- _Parent : T1 (A); -- D : Int; -- end; procedure Expand_Derived_Record (T : Entity_Id; Def : Node_Id) is Indic : constant Node_Id := Subtype_Indication (Def); Loc : constant Source_Ptr := Sloc (Def); Rec_Ext_Part : Node_Id := Record_Extension_Part (Def); Par_Subtype : Entity_Id; Comp_List : Node_Id; Comp_Decl : Node_Id; Parent_N : Node_Id; D : Entity_Id; List_Constr : constant List_Id := New_List; begin -- Expand_Tagged_Extension is called directly from the semantics, so -- we must check to see whether expansion is active before proceeding if not Expander_Active then return; end if; -- This may be a derivation of an untagged private type whose full -- view is tagged, in which case the Derived_Type_Definition has no -- extension part. Build an empty one now. if No (Rec_Ext_Part) then Rec_Ext_Part := Make_Record_Definition (Loc, End_Label => Empty, Component_List => Empty, Null_Present => True); Set_Record_Extension_Part (Def, Rec_Ext_Part); Mark_Rewrite_Insertion (Rec_Ext_Part); end if; Comp_List := Component_List (Rec_Ext_Part); Parent_N := Make_Defining_Identifier (Loc, Name_uParent); -- If the derived type inherits its discriminants the type of the -- _parent field must be constrained by the inherited discriminants if Has_Discriminants (T) and then Nkind (Indic) /= N_Subtype_Indication and then not Is_Constrained (Entity (Indic)) then D := First_Discriminant (T); while (Present (D)) loop Append_To (List_Constr, New_Occurrence_Of (D, Loc)); Next_Discriminant (D); end loop; Par_Subtype := Process_Subtype ( Make_Subtype_Indication (Loc, Subtype_Mark => New_Reference_To (Entity (Indic), Loc), Constraint => Make_Index_Or_Discriminant_Constraint (Loc, Constraints => List_Constr)), Def); -- Otherwise the original subtype_indication is just what is needed else Par_Subtype := Process_Subtype (New_Copy_Tree (Indic), Def); end if; Set_Parent_Subtype (T, Par_Subtype); Comp_Decl := Make_Component_Declaration (Loc, Defining_Identifier => Parent_N, Subtype_Indication => New_Reference_To (Par_Subtype, Loc)); if Null_Present (Rec_Ext_Part) then Set_Component_List (Rec_Ext_Part, Make_Component_List (Loc, Component_Items => New_List (Comp_Decl), Variant_Part => Empty, Null_Present => False)); Set_Null_Present (Rec_Ext_Part, False); elsif Null_Present (Comp_List) or else Is_Empty_List (Component_Items (Comp_List)) then Set_Component_Items (Comp_List, New_List (Comp_Decl)); Set_Null_Present (Comp_List, False); else Insert_Before (First (Component_Items (Comp_List)), Comp_Decl); end if; Analyze (Comp_Decl); end Expand_Derived_Record; ------------------------------------ -- Expand_N_Full_Type_Declaration -- ------------------------------------ procedure Expand_N_Full_Type_Declaration (N : Node_Id) is Def_Id : constant Entity_Id := Defining_Identifier (N); B_Id : Entity_Id := Base_Type (Def_Id); Par_Id : Entity_Id; FN : Node_Id; begin if Is_Access_Type (Def_Id) then -- Anonymous access types are created for the components of the -- record parameter for an entry declaration. No master is created -- for such a type. if Has_Task (Designated_Type (Def_Id)) and then Comes_From_Source (N) then Build_Master_Entity (Def_Id); Build_Master_Renaming (Parent (Def_Id), Def_Id); -- Create a class-wide master because a Master_Id must be generated -- for access-to-limited-class-wide types, whose root may be extended -- with task components. elsif Is_Class_Wide_Type (Designated_Type (Def_Id)) and then Is_Limited_Type (Designated_Type (Def_Id)) and then Tasking_Allowed -- Don't create a class-wide master for types whose convention is -- Java since these types cannot embed Ada tasks anyway. Note that -- the following test cannot catch the following case: -- -- package java.lang.Object is -- type Typ is tagged limited private; -- type Ref is access all Typ'Class; -- private -- type Typ is tagged limited ...; -- pragma Convention (Typ, Java) -- end; -- -- Because the convention appears after we have done the -- processing for type Ref. and then Convention (Designated_Type (Def_Id)) /= Convention_Java then Build_Class_Wide_Master (Def_Id); elsif Ekind (Def_Id) = E_Access_Protected_Subprogram_Type then Expand_Access_Protected_Subprogram_Type (N); end if; elsif Has_Task (Def_Id) then Expand_Previous_Access_Type (N, Def_Id); end if; Par_Id := Etype (B_Id); -- The parent type is private then we need to inherit -- any TSS operations from the full view. if Ekind (Par_Id) in Private_Kind and then Present (Full_View (Par_Id)) then Par_Id := Base_Type (Full_View (Par_Id)); end if; if Nkind (Type_Definition (Original_Node (N))) = N_Derived_Type_Definition and then not Is_Tagged_Type (Def_Id) and then Present (Freeze_Node (Par_Id)) and then Present (TSS_Elist (Freeze_Node (Par_Id))) then Ensure_Freeze_Node (B_Id); FN := Freeze_Node (B_Id); if No (TSS_Elist (FN)) then Set_TSS_Elist (FN, New_Elmt_List); end if; declare T_E : Elist_Id := TSS_Elist (FN); Elmt : Elmt_Id; begin Elmt := First_Elmt (TSS_Elist (Freeze_Node (Par_Id))); while Present (Elmt) loop if Chars (Node (Elmt)) /= Name_uInit then Append_Elmt (Node (Elmt), T_E); end if; Next_Elmt (Elmt); end loop; -- If the derived type itself is private with a full view, -- then associate the full view with the inherited TSS_Elist -- as well. if Ekind (B_Id) in Private_Kind and then Present (Full_View (B_Id)) then Ensure_Freeze_Node (Base_Type (Full_View (B_Id))); Set_TSS_Elist (Freeze_Node (Base_Type (Full_View (B_Id))), TSS_Elist (FN)); end if; end; end if; end Expand_N_Full_Type_Declaration; --------------------------------- -- Expand_N_Object_Declaration -- --------------------------------- -- First we do special processing for objects of a tagged type where this -- is the point at which the type is frozen. The creation of the dispatch -- table and the initialization procedure have to be deferred to this -- point, since we reference previously declared primitive subprograms. -- For all types, we call an initialization procedure if there is one procedure Expand_N_Object_Declaration (N : Node_Id) is Def_Id : constant Entity_Id := Defining_Identifier (N); Typ : constant Entity_Id := Etype (Def_Id); Loc : constant Source_Ptr := Sloc (N); Expr : Node_Id := Expression (N); New_Ref : Node_Id; Id_Ref : Node_Id; Expr_Q : Node_Id; begin -- Don't do anything for deferred constants. All proper actions will -- be expanded during the redeclaration. if No (Expr) and Constant_Present (N) then return; end if; -- Make shared memory routines for shared passive variable if Is_Shared_Passive (Def_Id) then Make_Shared_Var_Procs (N); end if; -- If tasks being declared, make sure we have an activation chain -- defined for the tasks (has no effect if we already have one), and -- also that a Master variable is established and that the appropriate -- enclosing construct is established as a task master. if Has_Task (Typ) then Build_Activation_Chain_Entity (N); Build_Master_Entity (Def_Id); end if; -- Default initialization required, and no expression present if No (Expr) then -- Expand Initialize call for controlled objects. One may wonder why -- the Initialize Call is not done in the regular Init procedure -- attached to the record type. That's because the init procedure is -- recursively called on each component, including _Parent, thus the -- Init call for a controlled object would generate not only one -- Initialize call as it is required but one for each ancestor of -- its type. This processing is suppressed if No_Initialization set. if not Controlled_Type (Typ) or else No_Initialization (N) then null; elsif not Abort_Allowed or else not Comes_From_Source (N) then Insert_Actions_After (N, Make_Init_Call ( Ref => New_Occurrence_Of (Def_Id, Loc), Typ => Base_Type (Typ), Flist_Ref => Find_Final_List (Def_Id), With_Attach => Make_Integer_Literal (Loc, 1))); -- Abort allowed else -- We need to protect the initialize call -- begin -- Defer_Abort.all; -- Initialize (...); -- at end -- Undefer_Abort.all; -- end; -- ??? this won't protect the initialize call for controlled -- components which are part of the init proc, so this block -- should probably also contain the call to _init_proc but this -- requires some code reorganization... declare L : constant List_Id := Make_Init_Call ( Ref => New_Occurrence_Of (Def_Id, Loc), Typ => Base_Type (Typ), Flist_Ref => Find_Final_List (Def_Id), With_Attach => Make_Integer_Literal (Loc, 1)); Blk : constant Node_Id := Make_Block_Statement (Loc, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, L)); begin Prepend_To (L, Build_Runtime_Call (Loc, RE_Abort_Defer)); Set_At_End_Proc (Handled_Statement_Sequence (Blk), New_Occurrence_Of (RTE (RE_Abort_Undefer_Direct), Loc)); Insert_Actions_After (N, New_List (Blk)); Expand_At_End_Handler (Handled_Statement_Sequence (Blk), Entity (Identifier (Blk))); end; end if; -- Call type initialization procedure if there is one. We build the -- call and put it immediately after the object declaration, so that -- it will be expanded in the usual manner. Note that this will -- result in proper handling of defaulted discriminants. The call -- to the Init_Proc is suppressed if No_Initialization is set. if Has_Non_Null_Base_Init_Proc (Typ) and then not No_Initialization (N) then -- The call to the initialization procedure does NOT freeze -- the object being initialized. This is because the call is -- not a source level call. This works fine, because the only -- possible statements depending on freeze status that can -- appear after the _Init call are rep clauses which can -- safely appear after actual references to the object. Id_Ref := New_Reference_To (Def_Id, Loc); Set_Must_Not_Freeze (Id_Ref); Set_Assignment_OK (Id_Ref); Insert_Actions_After (N, Build_Initialization_Call (Loc, Id_Ref, Typ)); -- If simple initialization is required, then set an appropriate -- simple initialization expression in place. This special -- initialization is required even though No_Init_Flag is present. elsif Needs_Simple_Initialization (Typ) then Set_No_Initialization (N, False); Set_Expression (N, Get_Simple_Init_Val (Typ, Loc)); Analyze_And_Resolve (Expression (N), Typ); end if; -- Explicit initialization present else -- Obtain actual expression from qualified expression if Nkind (Expr) = N_Qualified_Expression then Expr_Q := Expression (Expr); else Expr_Q := Expr; end if; -- When we have the appropriate type of aggregate in the -- expression (it has been determined during analysis of the -- aggregate by setting the delay flag), let's perform in -- place assignment and thus avoid creating a temporay. if Is_Delayed_Aggregate (Expr_Q) then Convert_Aggr_In_Object_Decl (N); else -- In most cases, we must check that the initial value meets -- any constraint imposed by the declared type. However, there -- is one very important exception to this rule. If the entity -- has an unconstrained nominal subtype, then it acquired its -- constraints from the expression in the first place, and not -- only does this mean that the constraint check is not needed, -- but an attempt to perform the constraint check can -- cause order of elaboration problems. if not Is_Constr_Subt_For_U_Nominal (Typ) then -- If this is an allocator for an aggregate that has been -- allocated in place, delay checks until assignments are -- made, because the discriminants are not initialized. if Nkind (Expr) = N_Allocator and then No_Initialization (Expr) then null; else Apply_Constraint_Check (Expr, Typ); end if; end if; -- If the type is controlled we attach the object to the final -- list and adjust the target after the copy. This if Controlled_Type (Typ) then declare Flist : Node_Id; F : Entity_Id; begin -- Attach the result to a dummy final list which will never -- be finalized if Delay_Finalize_Attachis set. It is -- important to attach to a dummy final list rather than -- not attaching at all in order to reset the pointers -- coming from the initial value. Equivalent code exists -- in the sec-stack case in Exp_Ch4.Expand_N_Allocator. if Delay_Finalize_Attach (N) then F := Make_Defining_Identifier (Loc, New_Internal_Name ('F')); Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => F, Object_Definition => New_Reference_To (RTE (RE_Finalizable_Ptr), Loc))); Flist := New_Reference_To (F, Loc); else Flist := Find_Final_List (Def_Id); end if; Insert_Actions_After (N, Make_Adjust_Call ( Ref => New_Reference_To (Def_Id, Loc), Typ => Base_Type (Typ), Flist_Ref => Flist, With_Attach => Make_Integer_Literal (Loc, 1))); end; end if; -- For tagged types, when an init value is given, the tag has -- to be re-initialized separately in order to avoid the -- propagation of a wrong tag coming from a view conversion -- unless the type is class wide (in this case the tag comes -- from the init value). Suppress the tag assignment when -- Java_VM because JVM tags are represented implicitly -- in objects. Ditto for types that are CPP_CLASS. if Is_Tagged_Type (Typ) and then not Is_Class_Wide_Type (Typ) and then not Is_CPP_Class (Typ) and then not Java_VM then -- The re-assignment of the tag has to be done even if -- the object is a constant New_Ref := Make_Selected_Component (Loc, Prefix => New_Reference_To (Def_Id, Loc), Selector_Name => New_Reference_To (Tag_Component (Typ), Loc)); Set_Assignment_OK (New_Ref); Insert_After (N, Make_Assignment_Statement (Loc, Name => New_Ref, Expression => Unchecked_Convert_To (RTE (RE_Tag), New_Reference_To (Access_Disp_Table (Base_Type (Typ)), Loc)))); -- For discrete types, set the Is_Known_Valid flag if the -- initializing value is known to be valid. elsif Is_Discrete_Type (Typ) and then Expr_Known_Valid (Expr) then Set_Is_Known_Valid (Def_Id); end if; -- If validity checking on copies, validate initial expression if Validity_Checks_On and then Validity_Check_Copies then Ensure_Valid (Expr); Set_Is_Known_Valid (Def_Id); end if; end if; end if; -- For array type, check for size too large -- We really need this for record types too??? if Is_Array_Type (Typ) then Apply_Array_Size_Check (N, Typ); end if; end Expand_N_Object_Declaration; --------------------------------- -- Expand_N_Subtype_Indication -- --------------------------------- -- Add a check on the range of the subtype. The static case is -- partially duplicated by Process_Range_Expr_In_Decl in Sem_Ch3, -- but we still need to check here for the static case in order to -- avoid generating extraneous expanded code. procedure Expand_N_Subtype_Indication (N : Node_Id) is Ran : Node_Id := Range_Expression (Constraint (N)); Typ : Entity_Id := Entity (Subtype_Mark (N)); begin if Nkind (Parent (N)) = N_Constrained_Array_Definition or else Nkind (Parent (N)) = N_Slice then Resolve (Ran, Typ); Apply_Range_Check (Ran, Typ); end if; end Expand_N_Subtype_Indication; --------------------------- -- Expand_N_Variant_Part -- --------------------------- -- If the last variant does not contain the Others choice, replace -- it with an N_Others_Choice node since Gigi always wants an Others. -- Note that we do not bother to call Analyze on the modified variant -- part, since it's only effect would be to compute the contents of -- the Others_Discrete_Choices node laboriously, and of course we -- already know the list of choices that corresponds to the others -- choice (it's the list we are replacing!) procedure Expand_N_Variant_Part (N : Node_Id) is Last_Var : constant Node_Id := Last_Non_Pragma (Variants (N)); Others_Node : Node_Id; begin if Nkind (First (Discrete_Choices (Last_Var))) /= N_Others_Choice then Others_Node := Make_Others_Choice (Sloc (Last_Var)); Set_Others_Discrete_Choices (Others_Node, Discrete_Choices (Last_Var)); Set_Discrete_Choices (Last_Var, New_List (Others_Node)); end if; end Expand_N_Variant_Part; --------------------------------- -- Expand_Previous_Access_Type -- --------------------------------- procedure Expand_Previous_Access_Type (N : Node_Id; Def_Id : Entity_Id) is T : Entity_Id := First_Entity (Current_Scope); begin -- Find all access types declared in the current scope, whose -- designated type is Def_Id. while Present (T) loop if Is_Access_Type (T) and then Designated_Type (T) = Def_Id then Build_Master_Entity (Def_Id); Build_Master_Renaming (Parent (Def_Id), T); end if; Next_Entity (T); end loop; end Expand_Previous_Access_Type; ------------------------------ -- Expand_Record_Controller -- ------------------------------ procedure Expand_Record_Controller (T : Entity_Id) is Def : Node_Id := Type_Definition (Parent (T)); Comp_List : Node_Id; Comp_Decl : Node_Id; Loc : Source_Ptr; First_Comp : Node_Id; Controller_Type : Entity_Id; Ent : Entity_Id; begin if Nkind (Def) = N_Derived_Type_Definition then Def := Record_Extension_Part (Def); end if; if Null_Present (Def) then Set_Component_List (Def, Make_Component_List (Sloc (Def), Component_Items => Empty_List, Variant_Part => Empty, Null_Present => True)); end if; Comp_List := Component_List (Def); if Null_Present (Comp_List) or else Is_Empty_List (Component_Items (Comp_List)) then Loc := Sloc (Comp_List); else Loc := Sloc (First (Component_Items (Comp_List))); end if; if Is_Return_By_Reference_Type (T) then Controller_Type := RTE (RE_Limited_Record_Controller); else Controller_Type := RTE (RE_Record_Controller); end if; Ent := Make_Defining_Identifier (Loc, Name_uController); Comp_Decl := Make_Component_Declaration (Loc, Defining_Identifier => Ent, Subtype_Indication => New_Reference_To (Controller_Type, Loc)); if Null_Present (Comp_List) or else Is_Empty_List (Component_Items (Comp_List)) then Set_Component_Items (Comp_List, New_List (Comp_Decl)); Set_Null_Present (Comp_List, False); else -- The controller cannot be placed before the _Parent field -- since gigi lays out field in order and _parent must be -- first to preserve the polymorphism of tagged types. First_Comp := First (Component_Items (Comp_List)); if Chars (Defining_Identifier (First_Comp)) /= Name_uParent and then Chars (Defining_Identifier (First_Comp)) /= Name_uTag then Insert_Before (First_Comp, Comp_Decl); else Insert_After (First_Comp, Comp_Decl); end if; end if; New_Scope (T); Analyze (Comp_Decl); Set_Ekind (Ent, E_Component); Init_Component_Location (Ent); -- Move the _controller entity ahead in the list of internal -- entities of the enclosing record so that it is selected -- instead of a potentially inherited one. declare E : Entity_Id := Last_Entity (T); Comp : Entity_Id; begin pragma Assert (Chars (E) = Name_uController); Set_Next_Entity (E, First_Entity (T)); Set_First_Entity (T, E); Comp := Next_Entity (E); while Next_Entity (Comp) /= E loop Next_Entity (Comp); end loop; Set_Next_Entity (Comp, Empty); Set_Last_Entity (T, Comp); end; End_Scope; end Expand_Record_Controller; ------------------------ -- Expand_Tagged_Root -- ------------------------ procedure Expand_Tagged_Root (T : Entity_Id) is Def : constant Node_Id := Type_Definition (Parent (T)); Comp_List : Node_Id; Comp_Decl : Node_Id; Sloc_N : Source_Ptr; begin if Null_Present (Def) then Set_Component_List (Def, Make_Component_List (Sloc (Def), Component_Items => Empty_List, Variant_Part => Empty, Null_Present => True)); end if; Comp_List := Component_List (Def); if Null_Present (Comp_List) or else Is_Empty_List (Component_Items (Comp_List)) then Sloc_N := Sloc (Comp_List); else Sloc_N := Sloc (First (Component_Items (Comp_List))); end if; Comp_Decl := Make_Component_Declaration (Sloc_N, Defining_Identifier => Tag_Component (T), Subtype_Indication => New_Reference_To (RTE (RE_Tag), Sloc_N)); if Null_Present (Comp_List) or else Is_Empty_List (Component_Items (Comp_List)) then Set_Component_Items (Comp_List, New_List (Comp_Decl)); Set_Null_Present (Comp_List, False); else Insert_Before (First (Component_Items (Comp_List)), Comp_Decl); end if; -- We don't Analyze the whole expansion because the tag component has -- already been analyzed previously. Here we just insure that the -- tree is coherent with the semantic decoration Find_Type (Subtype_Indication (Comp_Decl)); end Expand_Tagged_Root; ----------------------- -- Freeze_Array_Type -- ----------------------- procedure Freeze_Array_Type (N : Node_Id) is Typ : constant Entity_Id := Entity (N); Base : constant Entity_Id := Base_Type (Typ); begin -- Nothing to do for packed case if not Is_Bit_Packed_Array (Typ) then -- If the component contains tasks, so does the array type. -- This may not be indicated in the array type because the -- component may have been a private type at the point of -- definition. Same if component type is controlled. Set_Has_Task (Base, Has_Task (Component_Type (Typ))); Set_Has_Controlled_Component (Base, Has_Controlled_Component (Component_Type (Typ)) or else Is_Controlled (Component_Type (Typ))); if No (Init_Proc (Base)) then -- If this is an anonymous array created for a declaration -- with an initial value, its init_proc will never be called. -- The initial value itself may have been expanded into assign- -- ments, in which case the object declaration is carries the -- No_Initialization flag. if Is_Itype (Base) and then Nkind (Associated_Node_For_Itype (Base)) = N_Object_Declaration and then (Present (Expression (Associated_Node_For_Itype (Base))) or else No_Initialization (Associated_Node_For_Itype (Base))) then null; -- We do not need an init proc for string or wide string, since -- the only time these need initialization in normalize or -- initialize scalars mode, and these types are treated specially -- and do not need initialization procedures. elsif Base = Standard_String or else Base = Standard_Wide_String then null; -- Otherwise we have to build an init proc for the subtype else Build_Array_Init_Proc (Base, N); end if; end if; if Typ = Base and then Has_Controlled_Component (Base) then Build_Controlling_Procs (Base); end if; end if; end Freeze_Array_Type; ----------------------------- -- Freeze_Enumeration_Type -- ----------------------------- procedure Freeze_Enumeration_Type (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Entity (N); Ent : Entity_Id; Lst : List_Id; Num : Nat; Arr : Entity_Id; Fent : Entity_Id; Func : Entity_Id; Ityp : Entity_Id; begin -- Build list of literal references Lst := New_List; Num := 0; Ent := First_Literal (Typ); while Present (Ent) loop Append_To (Lst, New_Reference_To (Ent, Sloc (Ent))); Num := Num + 1; Next_Literal (Ent); end loop; -- Now build an array declaration -- typA : array (Natural range 0 .. num - 1) of ctype := -- (v, v, v, v, v, ....) -- where ctype is the corresponding integer type Arr := Make_Defining_Identifier (Loc, Chars => New_External_Name (Chars (Typ), 'A')); Append_Freeze_Action (Typ, Make_Object_Declaration (Loc, Defining_Identifier => Arr, Constant_Present => True, Object_Definition => Make_Constrained_Array_Definition (Loc, Discrete_Subtype_Definitions => New_List ( Make_Subtype_Indication (Loc, Subtype_Mark => New_Reference_To (Standard_Natural, Loc), Constraint => Make_Range_Constraint (Loc, Range_Expression => Make_Range (Loc, Low_Bound => Make_Integer_Literal (Loc, 0), High_Bound => Make_Integer_Literal (Loc, Num - 1))))), Subtype_Indication => New_Reference_To (Typ, Loc)), Expression => Make_Aggregate (Loc, Expressions => Lst))); Set_Enum_Pos_To_Rep (Typ, Arr); -- Now we build the function that converts representation values to -- position values. This function has the form: -- function _Rep_To_Pos (A : etype; F : Boolean) return Integer is -- begin -- case ityp!(A) is -- when enum-lit'Enum_Rep => return posval; -- when enum-lit'Enum_Rep => return posval; -- ... -- when others => -- [raise Program_Error when F] -- return -1; -- end case; -- end; -- Note: the F parameter determines whether the others case (no valid -- representation) raises Program_Error or returns a unique value of -- minus one. The latter case is used, e.g. in 'Valid code. -- Note: the reason we use Enum_Rep values in the case here is to -- avoid the code generator making inappropriate assumptions about -- the range of the values in the case where the value is invalid. -- ityp is a signed or unsigned integer type of appropriate width. -- Note: in the case of No_Run_Time mode, where we cannot handle -- a program error in any case, we suppress the raise and just -- return -1 unconditionally (this is an erroneous program in any -- case and there is no obligation to raise Program_Error here!) -- We also do this if pragma Restrictions (No_Exceptions) is active. -- First build list of cases Lst := New_List; Ent := First_Literal (Typ); while Present (Ent) loop Append_To (Lst, Make_Case_Statement_Alternative (Loc, Discrete_Choices => New_List ( Make_Integer_Literal (Sloc (Enumeration_Rep_Expr (Ent)), Intval => Enumeration_Rep (Ent))), Statements => New_List ( Make_Return_Statement (Loc, Expression => Make_Integer_Literal (Loc, Intval => Enumeration_Pos (Ent)))))); Next_Literal (Ent); end loop; -- Representations are signed if Enumeration_Rep (First_Literal (Typ)) < 0 then if Esize (Typ) <= Standard_Integer_Size then Ityp := Standard_Integer; else Ityp := Universal_Integer; end if; -- Representations are unsigned else if Esize (Typ) <= Standard_Integer_Size then Ityp := RTE (RE_Unsigned); else Ityp := RTE (RE_Long_Long_Unsigned); end if; end if; -- In normal mode, add the others clause with the test if not (No_Run_Time or Restrictions (No_Exceptions)) then Append_To (Lst, Make_Case_Statement_Alternative (Loc, Discrete_Choices => New_List (Make_Others_Choice (Loc)), Statements => New_List ( Make_Raise_Program_Error (Loc, Condition => Make_Identifier (Loc, Name_uF)), Make_Return_Statement (Loc, Expression => Make_Integer_Literal (Loc, -1))))); -- If No_Run_Time mode, unconditionally return -1. Same -- treatment if we have pragma Restrictions (No_Exceptions). else Append_To (Lst, Make_Case_Statement_Alternative (Loc, Discrete_Choices => New_List (Make_Others_Choice (Loc)), Statements => New_List ( Make_Return_Statement (Loc, Expression => Make_Integer_Literal (Loc, -1))))); end if; -- Now we can build the function body Fent := Make_Defining_Identifier (Loc, Name_uRep_To_Pos); Func := Make_Subprogram_Body (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => Fent, Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uA), Parameter_Type => New_Reference_To (Typ, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uF), Parameter_Type => New_Reference_To (Standard_Boolean, Loc))), Subtype_Mark => New_Reference_To (Standard_Integer, Loc)), Declarations => Empty_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Make_Case_Statement (Loc, Expression => Unchecked_Convert_To (Ityp, Make_Identifier (Loc, Name_uA)), Alternatives => Lst)))); Set_TSS (Typ, Fent); Set_Is_Pure (Fent); if not Debug_Generated_Code then Set_Debug_Info_Off (Fent); end if; end Freeze_Enumeration_Type; ------------------------ -- Freeze_Record_Type -- ------------------------ procedure Freeze_Record_Type (N : Node_Id) is Def_Id : constant Node_Id := Entity (N); Comp : Entity_Id; Type_Decl : constant Node_Id := Parent (Def_Id); Predef_List : List_Id; Renamed_Eq : Node_Id := Empty; -- Could use some comments ??? begin -- Build discriminant checking functions if not a derived type (for -- derived types that are not tagged types, we always use the -- discriminant checking functions of the parent type). However, for -- untagged types the derivation may have taken place before the -- parent was frozen, so we copy explicitly the discriminant checking -- functions from the parent into the components of the derived type. if not Is_Derived_Type (Def_Id) or else Has_New_Non_Standard_Rep (Def_Id) or else Is_Tagged_Type (Def_Id) then Build_Discr_Checking_Funcs (Type_Decl); elsif Is_Derived_Type (Def_Id) and then not Is_Tagged_Type (Def_Id) and then Has_Discriminants (Def_Id) then declare Old_Comp : Entity_Id; begin Old_Comp := First_Component (Base_Type (Underlying_Type (Etype (Def_Id)))); Comp := First_Component (Def_Id); while Present (Comp) loop if Ekind (Comp) = E_Component and then Chars (Comp) = Chars (Old_Comp) then Set_Discriminant_Checking_Func (Comp, Discriminant_Checking_Func (Old_Comp)); end if; Next_Component (Old_Comp); Next_Component (Comp); end loop; end; end if; -- Update task and controlled component flags, because some of the -- component types may have been private at the point of the record -- declaration. Comp := First_Component (Def_Id); while Present (Comp) loop if Has_Task (Etype (Comp)) then Set_Has_Task (Def_Id); elsif Has_Controlled_Component (Etype (Comp)) or else (Chars (Comp) /= Name_uParent and then Is_Controlled (Etype (Comp))) then Set_Has_Controlled_Component (Def_Id); end if; Next_Component (Comp); end loop; -- Creation of the Dispatch Table. Note that a Dispatch Table is -- created for regular tagged types as well as for Ada types -- deriving from a C++ Class, but not for tagged types directly -- corresponding to the C++ classes. In the later case we assume -- that the Vtable is created in the C++ side and we just use it. if Is_Tagged_Type (Def_Id) then if Is_CPP_Class (Def_Id) then Set_All_DT_Position (Def_Id); Set_Default_Constructor (Def_Id); else -- Usually inherited primitives are not delayed but the first -- Ada extension of a CPP_Class is an exception since the -- address of the inherited subprogram has to be inserted in -- the new Ada Dispatch Table and this is a freezing action -- (usually the inherited primitive address is inserted in the -- DT by Inherit_DT) if Is_CPP_Class (Etype (Def_Id)) then declare Elmt : Elmt_Id := First_Elmt (Primitive_Operations (Def_Id)); Subp : Entity_Id; begin while Present (Elmt) loop Subp := Node (Elmt); if Present (Alias (Subp)) then Set_Has_Delayed_Freeze (Subp); end if; Next_Elmt (Elmt); end loop; end; end if; if Underlying_Type (Etype (Def_Id)) = Def_Id then Expand_Tagged_Root (Def_Id); end if; -- Unfreeze momentarily the type to add the predefined -- primitives operations. The reason we unfreeze is so -- that these predefined operations will indeed end up -- as primitive operations (which must be before the -- freeze point). Set_Is_Frozen (Def_Id, False); Make_Predefined_Primitive_Specs (Def_Id, Predef_List, Renamed_Eq); Insert_List_Before_And_Analyze (N, Predef_List); Set_Is_Frozen (Def_Id, True); Set_All_DT_Position (Def_Id); -- Add the controlled component before the freezing actions -- it is referenced in those actions. if Has_New_Controlled_Component (Def_Id) then Expand_Record_Controller (Def_Id); end if; -- Suppress creation of a dispatch table when Java_VM because -- the dispatching mechanism is handled internally by the JVM. if not Java_VM then Append_Freeze_Actions (Def_Id, Make_DT (Def_Id)); end if; -- Make sure that the primitives Initialize, Adjust and -- Finalize are Frozen before other TSS subprograms. We -- don't want them Frozen inside. if Is_Controlled (Def_Id) then if not Is_Limited_Type (Def_Id) then Append_Freeze_Actions (Def_Id, Freeze_Entity (Find_Prim_Op (Def_Id, Name_Adjust), Sloc (Def_Id))); end if; Append_Freeze_Actions (Def_Id, Freeze_Entity (Find_Prim_Op (Def_Id, Name_Initialize), Sloc (Def_Id))); Append_Freeze_Actions (Def_Id, Freeze_Entity (Find_Prim_Op (Def_Id, Name_Finalize), Sloc (Def_Id))); end if; -- Freeze rest of primitive operations Append_Freeze_Actions (Def_Id, Predefined_Primitive_Freeze (Def_Id)); end if; -- In the non-tagged case, an equality function is provided only -- for variant records (that are not unchecked unions). elsif Has_Discriminants (Def_Id) and then not Is_Limited_Type (Def_Id) then declare Comps : constant Node_Id := Component_List (Type_Definition (Type_Decl)); begin if Present (Comps) and then Present (Variant_Part (Comps)) and then not Is_Unchecked_Union (Def_Id) then Build_Variant_Record_Equality (Def_Id); end if; end; end if; -- Before building the record initialization procedure, if we are -- dealing with a concurrent record value type, then we must go -- through the discriminants, exchanging discriminals between the -- concurrent type and the concurrent record value type. See the -- section "Handling of Discriminants" in the Einfo spec for details. if Is_Concurrent_Record_Type (Def_Id) and then Has_Discriminants (Def_Id) then declare Ctyp : constant Entity_Id := Corresponding_Concurrent_Type (Def_Id); Conc_Discr : Entity_Id; Rec_Discr : Entity_Id; Temp : Entity_Id; begin Conc_Discr := First_Discriminant (Ctyp); Rec_Discr := First_Discriminant (Def_Id); while Present (Conc_Discr) loop Temp := Discriminal (Conc_Discr); Set_Discriminal (Conc_Discr, Discriminal (Rec_Discr)); Set_Discriminal (Rec_Discr, Temp); Set_Discriminal_Link (Discriminal (Conc_Discr), Conc_Discr); Set_Discriminal_Link (Discriminal (Rec_Discr), Rec_Discr); Next_Discriminant (Conc_Discr); Next_Discriminant (Rec_Discr); end loop; end; end if; if Has_Controlled_Component (Def_Id) then if No (Controller_Component (Def_Id)) then Expand_Record_Controller (Def_Id); end if; Build_Controlling_Procs (Def_Id); end if; Adjust_Discriminants (Def_Id); Build_Record_Init_Proc (Type_Decl, Def_Id); -- For tagged type, build bodies of primitive operations. Note -- that we do this after building the record initialization -- experiment, since the primitive operations may need the -- initialization routine if Is_Tagged_Type (Def_Id) then Predef_List := Predefined_Primitive_Bodies (Def_Id, Renamed_Eq); Append_Freeze_Actions (Def_Id, Predef_List); end if; end Freeze_Record_Type; ----------------- -- Freeze_Type -- ----------------- -- Full type declarations are expanded at the point at which the type -- is frozen. The formal N is the Freeze_Node for the type. Any statements -- or declarations generated by the freezing (e.g. the procedure generated -- for initialization) are chained in the Acions field list of the freeze -- node using Append_Freeze_Actions. procedure Freeze_Type (N : Node_Id) is Def_Id : constant Entity_Id := Entity (N); begin -- Process associated access types needing special processing if Present (Access_Types_To_Process (N)) then declare E : Elmt_Id := First_Elmt (Access_Types_To_Process (N)); begin while Present (E) loop -- If the access type is a RACW, call the expansion procedure -- for this remote pointer. if Is_Remote_Access_To_Class_Wide_Type (Node (E)) then Remote_Types_Tagged_Full_View_Encountered (Def_Id); end if; E := Next_Elmt (E); end loop; end; end if; -- Freeze processing for record types if Is_Record_Type (Def_Id) then if Ekind (Def_Id) = E_Record_Type then Freeze_Record_Type (N); -- The subtype may have been declared before the type was frozen. -- If the type has controlled components it is necessary to create -- the entity for the controller explicitly because it did not -- exist at the point of the subtype declaration. Only the entity is -- needed, the back-end will obtain the layout from the type. -- This is only necessary if this is constrained subtype whose -- component list is not shared with the base type. elsif Ekind (Def_Id) = E_Record_Subtype and then Has_Discriminants (Def_Id) and then Last_Entity (Def_Id) /= Last_Entity (Base_Type (Def_Id)) and then Present (Controller_Component (Def_Id)) then declare Old_C : Entity_Id := Controller_Component (Def_Id); New_C : Entity_Id; begin if Scope (Old_C) = Base_Type (Def_Id) then -- The entity is the one in the parent. Create new one. New_C := New_Copy (Old_C); Set_Parent (New_C, Parent (Old_C)); New_Scope (Def_Id); Enter_Name (New_C); End_Scope; end if; end; end if; -- Freeze processing for array types elsif Is_Array_Type (Def_Id) then Freeze_Array_Type (N); -- Freeze processing for access types -- For pool-specific access types, find out the pool object used for -- this type, needs actual expansion of it in some cases. Here are the -- different cases : -- 1. Rep Clause "for Def_Id'Storage_Size use 0;" -- ---> don't use any storage pool -- 2. Rep Clause : for Def_Id'Storage_Size use Expr. -- Expand: -- Def_Id__Pool : Stack_Bounded_Pool (Expr, DT'Size, DT'Alignment); -- 3. Rep Clause "for Def_Id'Storage_Pool use a_Pool_Object" -- ---> Storage Pool is the specified one -- See GNAT Pool packages in the Run-Time for more details elsif Ekind (Def_Id) = E_Access_Type or else Ekind (Def_Id) = E_General_Access_Type then declare Loc : constant Source_Ptr := Sloc (N); Desig_Type : constant Entity_Id := Designated_Type (Def_Id); Pool_Object : Entity_Id; Siz_Exp : Node_Id; Freeze_Action_Typ : Entity_Id; begin if Has_Storage_Size_Clause (Def_Id) then Siz_Exp := Expression (Parent (Storage_Size_Variable (Def_Id))); else Siz_Exp := Empty; end if; -- Case 1 -- Rep Clause "for Def_Id'Storage_Size use 0;" -- ---> don't use any storage pool if Has_Storage_Size_Clause (Def_Id) and then Compile_Time_Known_Value (Siz_Exp) and then Expr_Value (Siz_Exp) = 0 then null; -- Case 2 -- Rep Clause : for Def_Id'Storage_Size use Expr. -- ---> Expand: -- Def_Id__Pool : Stack_Bounded_Pool -- (Expr, DT'Size, DT'Alignment); elsif Has_Storage_Size_Clause (Def_Id) then declare DT_Size : Node_Id; DT_Align : Node_Id; begin -- For unconstrained composite types we give a size of -- zero so that the pool knows that it needs a special -- algorithm for variable size object allocation. if Is_Composite_Type (Desig_Type) and then not Is_Constrained (Desig_Type) then DT_Size := Make_Integer_Literal (Loc, 0); DT_Align := Make_Integer_Literal (Loc, Maximum_Alignment); else DT_Size := Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Desig_Type, Loc), Attribute_Name => Name_Max_Size_In_Storage_Elements); DT_Align := Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Desig_Type, Loc), Attribute_Name => Name_Alignment); end if; Pool_Object := Make_Defining_Identifier (Loc, Chars => New_External_Name (Chars (Def_Id), 'P')); -- We put the code associated with the pools in the -- entity that has the later freeze node, usually the -- acces type but it can also be the designated_type; -- because the pool code requires both those types to be -- frozen if Is_Frozen (Desig_Type) and then (not Present (Freeze_Node (Desig_Type)) or else Analyzed (Freeze_Node (Desig_Type))) then Freeze_Action_Typ := Def_Id; -- A Taft amendment type cannot get the freeze actions -- since the full view is not there. elsif Is_Incomplete_Or_Private_Type (Desig_Type) and then No (Full_View (Desig_Type)) then Freeze_Action_Typ := Def_Id; else Freeze_Action_Typ := Desig_Type; end if; Append_Freeze_Action (Freeze_Action_Typ, Make_Object_Declaration (Loc, Defining_Identifier => Pool_Object, Object_Definition => Make_Subtype_Indication (Loc, Subtype_Mark => New_Reference_To (RTE (RE_Stack_Bounded_Pool), Loc), Constraint => Make_Index_Or_Discriminant_Constraint (Loc, Constraints => New_List ( -- First discriminant is the Pool Size New_Reference_To ( Storage_Size_Variable (Def_Id), Loc), -- Second discriminant is the element size DT_Size, -- Third discriminant is the alignment DT_Align))))); end; Set_Associated_Storage_Pool (Def_Id, Pool_Object); -- Case 3 -- Rep Clause "for Def_Id'Storage_Pool use a_Pool_Object" -- ---> Storage Pool is the specified one elsif Present (Associated_Storage_Pool (Def_Id)) then -- Nothing to do the associated storage pool has been attached -- when analyzing the rep. clause null; end if; -- For access-to-controlled types (including class-wide types -- and Taft-amendment types which potentially have controlled -- components), expand the list controller object that will -- store the dynamically allocated objects. Do not do this -- transformation for expander-generated access types, but do it -- for types that are the full view of types derived from other -- private types. Also suppress the list controller in the case -- of a designated type with convention Java, since this is used -- when binding to Java API specs, where there's no equivalent -- of a finalization list and we don't want to pull in the -- finalization support if not needed. if not Comes_From_Source (Def_Id) and then not Has_Private_Declaration (Def_Id) then null; elsif (Controlled_Type (Desig_Type) and then Convention (Desig_Type) /= Convention_Java) or else (Is_Incomplete_Or_Private_Type (Desig_Type) and then No (Full_View (Desig_Type)) -- An exception is made for types defined in the run-time -- because Ada.Tags.Tag itself is such a type and cannot -- afford this unnecessary overhead that would generates a -- loop in the expansion scheme... -- Similarly, if No_Run_Time is enabled, the designated type -- cannot be controlled. and then not In_Runtime (Def_Id) and then not No_Run_Time) -- If the designated type is not frozen yet, its controlled -- status must be retrieved explicitly. or else (Is_Array_Type (Desig_Type) and then not Is_Frozen (Desig_Type) and then Controlled_Type (Component_Type (Desig_Type))) then Set_Associated_Final_Chain (Def_Id, Make_Defining_Identifier (Loc, New_External_Name (Chars (Def_Id), 'L'))); Append_Freeze_Action (Def_Id, Make_Object_Declaration (Loc, Defining_Identifier => Associated_Final_Chain (Def_Id), Object_Definition => New_Reference_To (RTE (RE_List_Controller), Loc))); end if; end; -- Freeze processing for enumeration types elsif Ekind (Def_Id) = E_Enumeration_Type then -- We only have something to do if we have a non-standard -- representation (i.e. at least one literal whose pos value -- is not the same as its representation) if Has_Non_Standard_Rep (Def_Id) then Freeze_Enumeration_Type (N); end if; -- private types that are completed by a derivation from a private -- type have an internally generated full view, that needs to be -- frozen. This must be done explicitly because the two views share -- the freeze node, and the underlying full view is not visible when -- the freeze node is analyzed. elsif Is_Private_Type (Def_Id) and then Is_Derived_Type (Def_Id) and then Present (Full_View (Def_Id)) and then Is_Itype (Full_View (Def_Id)) and then Has_Private_Declaration (Full_View (Def_Id)) and then Freeze_Node (Full_View (Def_Id)) = N then Set_Entity (N, Full_View (Def_Id)); Freeze_Type (N); Set_Entity (N, Def_Id); -- All other types require no expander action. There are such -- cases (e.g. task types and protected types). In such cases, -- the freeze nodes are there for use by Gigi. end if; end Freeze_Type; ------------------------- -- Get_Simple_Init_Val -- ------------------------- function Get_Simple_Init_Val (T : Entity_Id; Loc : Source_Ptr) return Node_Id is Val : Node_Id; Typ : Node_Id; Result : Node_Id; Val_RE : RE_Id; begin -- For scalars, we must have normalize/initialize scalars case if Is_Scalar_Type (T) then pragma Assert (Init_Or_Norm_Scalars); -- Processing for Normalize_Scalars case if Normalize_Scalars then -- First prepare a value (out of subtype range if possible) if Is_Real_Type (T) or else Is_Integer_Type (T) then Val := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Base_Type (T), Loc), Attribute_Name => Name_First); elsif Is_Modular_Integer_Type (T) then Val := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Base_Type (T), Loc), Attribute_Name => Name_Last); else pragma Assert (Is_Enumeration_Type (T)); if Esize (T) <= 8 then Typ := RTE (RE_Unsigned_8); elsif Esize (T) <= 16 then Typ := RTE (RE_Unsigned_16); elsif Esize (T) <= 32 then Typ := RTE (RE_Unsigned_32); else Typ := RTE (RE_Unsigned_64); end if; Val := Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Typ, Loc), Attribute_Name => Name_Last); end if; -- Here for Initialize_Scalars case else if Is_Floating_Point_Type (T) then if Root_Type (T) = Standard_Short_Float then Val_RE := RE_IS_Isf; elsif Root_Type (T) = Standard_Float then Val_RE := RE_IS_Ifl; -- The form of the following test is quite deliberate, it -- catches the case of architectures (the most common case) -- where Long_Long_Float is the same as Long_Float, and in -- such cases initializes Long_Long_Float variables from the -- Long_Float constant (since the Long_Long_Float constant is -- only for use on the x86). elsif Esize (Root_Type (T)) = Esize (Standard_Long_Float) then Val_RE := RE_IS_Ilf; -- Otherwise we have extended real on an x86 else pragma Assert (Root_Type (T) = Standard_Long_Long_Float); Val_RE := RE_IS_Ill; end if; elsif Is_Unsigned_Type (Base_Type (T)) then if Esize (T) = 8 then Val_RE := RE_IS_Iu1; elsif Esize (T) = 16 then Val_RE := RE_IS_Iu2; elsif Esize (T) = 32 then Val_RE := RE_IS_Iu4; else pragma Assert (Esize (T) = 64); Val_RE := RE_IS_Iu8; end if; else -- signed type if Esize (T) = 8 then Val_RE := RE_IS_Is1; elsif Esize (T) = 16 then Val_RE := RE_IS_Is2; elsif Esize (T) = 32 then Val_RE := RE_IS_Is4; else pragma Assert (Esize (T) = 64); Val_RE := RE_IS_Is8; end if; end if; Val := New_Occurrence_Of (RTE (Val_RE), Loc); end if; -- The final expression is obtained by doing an unchecked -- conversion of this result to the base type of the -- required subtype. We use the base type to avoid the -- unchecked conversion from chopping bits, and then we -- set Kill_Range_Check to preserve the "bad" value. Result := Unchecked_Convert_To (Base_Type (T), Val); if Nkind (Result) = N_Unchecked_Type_Conversion then Set_Kill_Range_Check (Result, True); end if; return Result; -- String or Wide_String (must have Initialize_Scalars set) elsif Root_Type (T) = Standard_String or else Root_Type (T) = Standard_Wide_String then pragma Assert (Init_Or_Norm_Scalars); return Make_Aggregate (Loc, Component_Associations => New_List ( Make_Component_Association (Loc, Choices => New_List ( Make_Others_Choice (Loc)), Expression => Get_Simple_Init_Val (Component_Type (T), Loc)))); -- Access type is initialized to null elsif Is_Access_Type (T) then return Make_Null (Loc); -- We initialize modular packed bit arrays to zero, to make sure that -- unused bits are zero, as required (see spec of Exp_Pakd). Also note -- that this improves gigi code, since the value tracing knows that -- all bits of the variable start out at zero. The value of zero has -- to be unchecked converted to the proper array type. elsif Is_Bit_Packed_Array (T) then declare PAT : constant Entity_Id := Packed_Array_Type (T); Nod : Node_Id; begin pragma Assert (Is_Modular_Integer_Type (PAT)); Nod := Make_Unchecked_Type_Conversion (Loc, Subtype_Mark => New_Occurrence_Of (T, Loc), Expression => Make_Integer_Literal (Loc, 0)); Set_Etype (Expression (Nod), PAT); return Nod; end; -- Otherwise we have a case of a private type whose underlying type -- needs simple initialization. In this case, we get the value for -- the underlying type, then unchecked convert to the private type. else pragma Assert (Is_Private_Type (T) and then Present (Underlying_Type (T))); Val := Get_Simple_Init_Val (Underlying_Type (T), Loc); -- A special case, if the underlying value is null, then qualify -- it with the underlying type, so that the null is properly typed -- Similarly, if it is an aggregate it must be qualified, because -- an unchecked conversion does not provide a context for it. if Nkind (Val) = N_Null or else Nkind (Val) = N_Aggregate then Val := Make_Qualified_Expression (Loc, Subtype_Mark => New_Occurrence_Of (Underlying_Type (T), Loc), Expression => Val); end if; return Unchecked_Convert_To (T, Val); end if; end Get_Simple_Init_Val; ------------------------------ -- Has_New_Non_Standard_Rep -- ------------------------------ function Has_New_Non_Standard_Rep (T : Entity_Id) return Boolean is begin if not Is_Derived_Type (T) then return Has_Non_Standard_Rep (T) or else Has_Non_Standard_Rep (Root_Type (T)); -- If Has_Non_Standard_Rep is not set on the derived type, the -- representation is fully inherited. elsif not Has_Non_Standard_Rep (T) then return False; else return First_Rep_Item (T) /= First_Rep_Item (Root_Type (T)); -- May need a more precise check here: the First_Rep_Item may -- be a stream attribute, which does not affect the representation -- of the type ??? end if; end Has_New_Non_Standard_Rep; ---------------- -- In_Runtime -- ---------------- function In_Runtime (E : Entity_Id) return Boolean is S1 : Entity_Id := Scope (E); begin while Scope (S1) /= Standard_Standard loop S1 := Scope (S1); end loop; return Chars (S1) = Name_System or else Chars (S1) = Name_Ada; end In_Runtime; ------------------ -- Init_Formals -- ------------------ function Init_Formals (Typ : Entity_Id) return List_Id is Loc : constant Source_Ptr := Sloc (Typ); Formals : List_Id; begin -- First parameter is always _Init : in out typ. Note that we need -- this to be in/out because in the case of the task record value, -- there are default record fields (_Priority, _Size, -Task_Info) -- that may be referenced in the generated initialization routine. Formals := New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uInit), In_Present => True, Out_Present => True, Parameter_Type => New_Reference_To (Typ, Loc))); -- For task record value, or type that contains tasks, add two more -- formals, _Master : Master_Id and _Chain : in out Activation_Chain -- We also add these parameters for the task record type case. if Has_Task (Typ) or else (Is_Record_Type (Typ) and then Is_Task_Record_Type (Typ)) then Append_To (Formals, Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uMaster), Parameter_Type => New_Reference_To (RTE (RE_Master_Id), Loc))); Append_To (Formals, Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uChain), In_Present => True, Out_Present => True, Parameter_Type => New_Reference_To (RTE (RE_Activation_Chain), Loc))); Append_To (Formals, Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uTask_Id), In_Present => True, Parameter_Type => New_Reference_To (RTE (RE_Task_Image_Type), Loc))); end if; return Formals; end Init_Formals; ------------------ -- Make_Eq_Case -- ------------------ -- <Make_Eq_if shared components> -- case X.D1 is -- when V1 => <Make_Eq_Case> on subcomponents -- ... -- when Vn => <Make_Eq_Case> on subcomponents -- end case; function Make_Eq_Case (Node : Node_Id; CL : Node_Id) return List_Id is Loc : constant Source_Ptr := Sloc (Node); Variant : Node_Id; Alt_List : List_Id; Result : List_Id := New_List; begin Append_To (Result, Make_Eq_If (Node, Component_Items (CL))); if No (Variant_Part (CL)) then return Result; end if; Variant := First_Non_Pragma (Variants (Variant_Part (CL))); if No (Variant) then return Result; end if; Alt_List := New_List; while Present (Variant) loop Append_To (Alt_List, Make_Case_Statement_Alternative (Loc, Discrete_Choices => New_Copy_List (Discrete_Choices (Variant)), Statements => Make_Eq_Case (Node, Component_List (Variant)))); Next_Non_Pragma (Variant); end loop; Append_To (Result, Make_Case_Statement (Loc, Expression => Make_Selected_Component (Loc, Prefix => Make_Identifier (Loc, Name_X), Selector_Name => New_Copy (Name (Variant_Part (CL)))), Alternatives => Alt_List)); return Result; end Make_Eq_Case; ---------------- -- Make_Eq_If -- ---------------- -- Generates: -- if -- X.C1 /= Y.C1 -- or else -- X.C2 /= Y.C2 -- ... -- then -- return False; -- end if; -- or a null statement if the list L is empty function Make_Eq_If (Node : Node_Id; L : List_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (Node); C : Node_Id; Field_Name : Name_Id; Cond : Node_Id; begin if No (L) then return Make_Null_Statement (Loc); else Cond := Empty; C := First_Non_Pragma (L); while Present (C) loop Field_Name := Chars (Defining_Identifier (C)); -- The tags must not be compared they are not part of the value. -- Note also that in the following, we use Make_Identifier for -- the component names. Use of New_Reference_To to identify the -- components would be incorrect because the wrong entities for -- discriminants could be picked up in the private type case. if Field_Name /= Name_uTag then Evolve_Or_Else (Cond, Make_Op_Ne (Loc, Left_Opnd => Make_Selected_Component (Loc, Prefix => Make_Identifier (Loc, Name_X), Selector_Name => Make_Identifier (Loc, Field_Name)), Right_Opnd => Make_Selected_Component (Loc, Prefix => Make_Identifier (Loc, Name_Y), Selector_Name => Make_Identifier (Loc, Field_Name)))); end if; Next_Non_Pragma (C); end loop; if No (Cond) then return Make_Null_Statement (Loc); else return Make_Implicit_If_Statement (Node, Condition => Cond, Then_Statements => New_List ( Make_Return_Statement (Loc, Expression => New_Occurrence_Of (Standard_False, Loc)))); end if; end if; end Make_Eq_If; ------------------------------------- -- Make_Predefined_Primitive_Specs -- ------------------------------------- procedure Make_Predefined_Primitive_Specs (Tag_Typ : Entity_Id; Predef_List : out List_Id; Renamed_Eq : out Node_Id) is Loc : constant Source_Ptr := Sloc (Tag_Typ); Res : List_Id := New_List; Prim : Elmt_Id; Eq_Needed : Boolean; Eq_Spec : Node_Id; Eq_Name : Name_Id := Name_Op_Eq; function Is_Predefined_Eq_Renaming (Prim : Node_Id) return Boolean; -- Returns true if Prim is a renaming of an unresolved predefined -- equality operation. function Is_Predefined_Eq_Renaming (Prim : Node_Id) return Boolean is begin return Chars (Prim) /= Name_Op_Eq and then Present (Alias (Prim)) and then Comes_From_Source (Prim) and then Is_Intrinsic_Subprogram (Alias (Prim)) and then Chars (Alias (Prim)) = Name_Op_Eq; end Is_Predefined_Eq_Renaming; -- Start of processing for Make_Predefined_Primitive_Specs begin Renamed_Eq := Empty; -- Spec of _Size Append_To (Res, Predef_Spec_Or_Body (Loc, Tag_Typ => Tag_Typ, Name => Name_uSize, Profile => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_X), Parameter_Type => New_Reference_To (Tag_Typ, Loc))), Ret_Type => Standard_Long_Long_Integer)); -- Specs for dispatching stream attributes. We skip these for limited -- types, since there is no question of dispatching in the limited case. -- We also skip these operations in No_Run_Time mode, where -- dispatching stream operations cannot be used (this is currently -- a No_Run_Time restriction). if not (No_Run_Time or else Is_Limited_Type (Tag_Typ)) then Append_To (Res, Predef_Stream_Attr_Spec (Loc, Tag_Typ, Name_uRead)); Append_To (Res, Predef_Stream_Attr_Spec (Loc, Tag_Typ, Name_uWrite)); Append_To (Res, Predef_Stream_Attr_Spec (Loc, Tag_Typ, Name_uInput)); Append_To (Res, Predef_Stream_Attr_Spec (Loc, Tag_Typ, Name_uOutput)); end if; if not Is_Limited_Type (Tag_Typ) then -- Spec of "=" if expanded if the type is not limited and if a -- user defined "=" was not already declared for the non-full -- view of a private extension Eq_Needed := True; Prim := First_Elmt (Primitive_Operations (Tag_Typ)); while Present (Prim) loop -- If a primitive is encountered that renames the predefined -- equality operator before reaching any explicit equality -- primitive, then we still need to create a predefined -- equality function, because calls to it can occur via -- the renaming. A new name is created for the equality -- to avoid conflicting with any user-defined equality. -- (Note that this doesn't account for renamings of -- equality nested within subpackages???) if Is_Predefined_Eq_Renaming (Node (Prim)) then Eq_Name := New_External_Name (Chars (Node (Prim)), 'E'); elsif Chars (Node (Prim)) = Name_Op_Eq and then (No (Alias (Node (Prim))) or else Nkind (Unit_Declaration_Node (Node (Prim))) = N_Subprogram_Renaming_Declaration) and then Etype (First_Formal (Node (Prim))) = Etype (Next_Formal (First_Formal (Node (Prim)))) then Eq_Needed := False; exit; -- If the parent equality is abstract, the inherited equality is -- abstract as well, and no body can be created for for it. elsif Chars (Node (Prim)) = Name_Op_Eq and then Present (Alias (Node (Prim))) and then Is_Abstract (Alias (Node (Prim))) then Eq_Needed := False; exit; end if; Next_Elmt (Prim); end loop; -- If a renaming of predefined equality was found -- but there was no user-defined equality (so Eq_Needed -- is still true), then set the name back to Name_Op_Eq. -- But in the case where a user-defined equality was -- located after such a renaming, then the predefined -- equality function is still needed, so Eq_Needed must -- be set back to True. if Eq_Name /= Name_Op_Eq then if Eq_Needed then Eq_Name := Name_Op_Eq; else Eq_Needed := True; end if; end if; if Eq_Needed then Eq_Spec := Predef_Spec_Or_Body (Loc, Tag_Typ => Tag_Typ, Name => Eq_Name, Profile => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_X), Parameter_Type => New_Reference_To (Tag_Typ, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_Y), Parameter_Type => New_Reference_To (Tag_Typ, Loc))), Ret_Type => Standard_Boolean); Append_To (Res, Eq_Spec); if Eq_Name /= Name_Op_Eq then Renamed_Eq := Defining_Unit_Name (Specification (Eq_Spec)); Prim := First_Elmt (Primitive_Operations (Tag_Typ)); while Present (Prim) loop -- Any renamings of equality that appeared before an -- overriding equality must be updated to refer to -- the entity for the predefined equality, otherwise -- calls via the renaming would get incorrectly -- resolved to call the user-defined equality function. if Is_Predefined_Eq_Renaming (Node (Prim)) then Set_Alias (Node (Prim), Renamed_Eq); -- Exit upon encountering a user-defined equality elsif Chars (Node (Prim)) = Name_Op_Eq and then No (Alias (Node (Prim))) then exit; end if; Next_Elmt (Prim); end loop; end if; end if; -- Spec for dispatching assignment Append_To (Res, Predef_Spec_Or_Body (Loc, Tag_Typ => Tag_Typ, Name => Name_uAssign, Profile => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_X), Out_Present => True, Parameter_Type => New_Reference_To (Tag_Typ, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_Y), Parameter_Type => New_Reference_To (Tag_Typ, Loc))))); end if; -- Specs for finalization actions that may be required in case a -- future extension contain a controlled element. We generate those -- only for root tagged types where they will get dummy bodies or -- when the type has controlled components and their body must be -- generated. It is also impossible to provide those for tagged -- types defined within s-finimp since it would involve circularity -- problems if In_Finalization_Root (Tag_Typ) then null; -- We also skip these in No_Run_Time mode where finalization is -- never permissible. elsif No_Run_Time then null; elsif Etype (Tag_Typ) = Tag_Typ or else Controlled_Type (Tag_Typ) then if not Is_Limited_Type (Tag_Typ) then Append_To (Res, Predef_Deep_Spec (Loc, Tag_Typ, Name_uDeep_Adjust)); end if; Append_To (Res, Predef_Deep_Spec (Loc, Tag_Typ, Name_uDeep_Finalize)); end if; Predef_List := Res; end Make_Predefined_Primitive_Specs; --------------------------------- -- Needs_Simple_Initialization -- --------------------------------- function Needs_Simple_Initialization (T : Entity_Id) return Boolean is begin -- Cases needing simple initialization are access types, and, if pragma -- Normalize_Scalars or Initialize_Scalars is in effect, then all scalar -- types. if Is_Access_Type (T) or else (Init_Or_Norm_Scalars and then (Is_Scalar_Type (T))) or else (Is_Bit_Packed_Array (T) and then Is_Modular_Integer_Type (Packed_Array_Type (T))) then return True; -- If Initialize/Normalize_Scalars is in effect, string objects also -- need initialization, unless they are created in the course of -- expanding an aggregate (since in the latter case they will be -- filled with appropriate initializing values before they are used). elsif Init_Or_Norm_Scalars and then (Root_Type (T) = Standard_String or else Root_Type (T) = Standard_Wide_String) and then (not Is_Itype (T) or else Nkind (Associated_Node_For_Itype (T)) /= N_Aggregate) then return True; -- Check for private type, in which case test applies to the -- underlying type of the private type. elsif Is_Private_Type (T) then declare RT : constant Entity_Id := Underlying_Type (T); begin if Present (RT) then return Needs_Simple_Initialization (RT); else return False; end if; end; else return False; end if; end Needs_Simple_Initialization; ---------------------- -- Predef_Deep_Spec -- ---------------------- function Predef_Deep_Spec (Loc : Source_Ptr; Tag_Typ : Entity_Id; Name : Name_Id; For_Body : Boolean := False) return Node_Id is Prof : List_Id; Type_B : Entity_Id; begin if Name = Name_uDeep_Finalize then Prof := New_List; Type_B := Standard_Boolean; else Prof := New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_L), In_Present => True, Out_Present => True, Parameter_Type => New_Reference_To (RTE (RE_Finalizable_Ptr), Loc))); Type_B := Standard_Short_Short_Integer; end if; Append_To (Prof, Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_V), In_Present => True, Out_Present => True, Parameter_Type => New_Reference_To (Tag_Typ, Loc))); Append_To (Prof, Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_B), Parameter_Type => New_Reference_To (Type_B, Loc))); return Predef_Spec_Or_Body (Loc, Name => Name, Tag_Typ => Tag_Typ, Profile => Prof, For_Body => For_Body); end Predef_Deep_Spec; ------------------------- -- Predef_Spec_Or_Body -- ------------------------- function Predef_Spec_Or_Body (Loc : Source_Ptr; Tag_Typ : Entity_Id; Name : Name_Id; Profile : List_Id; Ret_Type : Entity_Id := Empty; For_Body : Boolean := False) return Node_Id is Id : Entity_Id := Make_Defining_Identifier (Loc, Name); Spec : Node_Id; begin Set_Is_Public (Id, Is_Public (Tag_Typ)); -- The internal flag is set to mark these declarations because -- they have specific properties. First they are primitives even -- if they are not defined in the type scope (the freezing point -- is not necessarily in the same scope), furthermore the -- predefined equality can be overridden by a user-defined -- equality, no body will be generated in this case. Set_Is_Internal (Id); if not Debug_Generated_Code then Set_Debug_Info_Off (Id); end if; if No (Ret_Type) then Spec := Make_Procedure_Specification (Loc, Defining_Unit_Name => Id, Parameter_Specifications => Profile); else Spec := Make_Function_Specification (Loc, Defining_Unit_Name => Id, Parameter_Specifications => Profile, Subtype_Mark => New_Reference_To (Ret_Type, Loc)); end if; -- If body case, return empty subprogram body. Note that this is -- ill-formed, because there is not even a null statement, and -- certainly not a return in the function case. The caller is -- expected to do surgery on the body to add the appropriate stuff. if For_Body then return Make_Subprogram_Body (Loc, Spec, Empty_List, Empty); -- For the case of _Input and _Output applied to an abstract type, -- generate abstract specifications. These will never be called, -- but we need the slots allocated in the dispatching table so -- that typ'Class'Input and typ'Class'Output will work properly. elsif (Name = Name_uInput or else Name = Name_uOutput) and then Is_Abstract (Tag_Typ) then return Make_Abstract_Subprogram_Declaration (Loc, Spec); -- Normal spec case, where we return a subprogram declaration else return Make_Subprogram_Declaration (Loc, Spec); end if; end Predef_Spec_Or_Body; ----------------------------- -- Predef_Stream_Attr_Spec -- ----------------------------- function Predef_Stream_Attr_Spec (Loc : Source_Ptr; Tag_Typ : Entity_Id; Name : Name_Id; For_Body : Boolean := False) return Node_Id is Ret_Type : Entity_Id; begin if Name = Name_uInput then Ret_Type := Tag_Typ; else Ret_Type := Empty; end if; return Predef_Spec_Or_Body (Loc, Name => Name, Tag_Typ => Tag_Typ, Profile => Build_Stream_Attr_Profile (Loc, Tag_Typ, Name), Ret_Type => Ret_Type, For_Body => For_Body); end Predef_Stream_Attr_Spec; --------------------------------- -- Predefined_Primitive_Bodies -- --------------------------------- function Predefined_Primitive_Bodies (Tag_Typ : Entity_Id; Renamed_Eq : Node_Id) return List_Id is Loc : constant Source_Ptr := Sloc (Tag_Typ); Decl : Node_Id; Res : List_Id := New_List; Prim : Elmt_Id; Eq_Needed : Boolean; Eq_Name : Name_Id; Ent : Entity_Id; begin -- See if we have a predefined "=" operator if Present (Renamed_Eq) then Eq_Needed := True; Eq_Name := Chars (Renamed_Eq); else Eq_Needed := False; Eq_Name := No_Name; Prim := First_Elmt (Primitive_Operations (Tag_Typ)); while Present (Prim) loop if Chars (Node (Prim)) = Name_Op_Eq and then Is_Internal (Node (Prim)) then Eq_Needed := True; Eq_Name := Name_Op_Eq; end if; Next_Elmt (Prim); end loop; end if; -- Body of _Size Decl := Predef_Spec_Or_Body (Loc, Tag_Typ => Tag_Typ, Name => Name_uSize, Profile => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_X), Parameter_Type => New_Reference_To (Tag_Typ, Loc))), Ret_Type => Standard_Long_Long_Integer, For_Body => True); Set_Handled_Statement_Sequence (Decl, Make_Handled_Sequence_Of_Statements (Loc, New_List ( Make_Return_Statement (Loc, Expression => Make_Attribute_Reference (Loc, Prefix => Make_Identifier (Loc, Name_X), Attribute_Name => Name_Size))))); Append_To (Res, Decl); -- Bodies for Dispatching stream IO routines. We need these only for -- non-limited types (in the limited case there is no dispatching). -- and we always skip them in No_Run_Time mode where streams are not -- permitted. if not (Is_Limited_Type (Tag_Typ) or else No_Run_Time) then if No (TSS (Tag_Typ, Name_uRead)) then Build_Record_Read_Procedure (Loc, Tag_Typ, Decl, Ent); Append_To (Res, Decl); end if; if No (TSS (Tag_Typ, Name_uWrite)) then Build_Record_Write_Procedure (Loc, Tag_Typ, Decl, Ent); Append_To (Res, Decl); end if; -- Skip bodies of _Input and _Output for the abstract case, since -- the corresponding specs are abstract (see Predef_Spec_Or_Body) if not Is_Abstract (Tag_Typ) then if No (TSS (Tag_Typ, Name_uInput)) then Build_Record_Or_Elementary_Input_Function (Loc, Tag_Typ, Decl, Ent); Append_To (Res, Decl); end if; if No (TSS (Tag_Typ, Name_uOutput)) then Build_Record_Or_Elementary_Output_Procedure (Loc, Tag_Typ, Decl, Ent); Append_To (Res, Decl); end if; end if; end if; if not Is_Limited_Type (Tag_Typ) then -- Body for equality if Eq_Needed then Decl := Predef_Spec_Or_Body (Loc, Tag_Typ => Tag_Typ, Name => Eq_Name, Profile => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_X), Parameter_Type => New_Reference_To (Tag_Typ, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_Y), Parameter_Type => New_Reference_To (Tag_Typ, Loc))), Ret_Type => Standard_Boolean, For_Body => True); declare Def : constant Node_Id := Parent (Tag_Typ); Variant_Case : Boolean := Has_Discriminants (Tag_Typ); Comps : Node_Id := Empty; Typ_Def : Node_Id := Type_Definition (Def); Stmts : List_Id := New_List; begin if Variant_Case then if Nkind (Typ_Def) = N_Derived_Type_Definition then Typ_Def := Record_Extension_Part (Typ_Def); end if; if Present (Typ_Def) then Comps := Component_List (Typ_Def); end if; Variant_Case := Present (Comps) and then Present (Variant_Part (Comps)); end if; if Variant_Case then Append_To (Stmts, Make_Eq_If (Tag_Typ, Discriminant_Specifications (Def))); Append_List_To (Stmts, Make_Eq_Case (Tag_Typ, Comps)); Append_To (Stmts, Make_Return_Statement (Loc, Expression => New_Reference_To (Standard_True, Loc))); else Append_To (Stmts, Make_Return_Statement (Loc, Expression => Expand_Record_Equality (Tag_Typ, Typ => Tag_Typ, Lhs => Make_Identifier (Loc, Name_X), Rhs => Make_Identifier (Loc, Name_Y), Bodies => Declarations (Decl)))); end if; Set_Handled_Statement_Sequence (Decl, Make_Handled_Sequence_Of_Statements (Loc, Stmts)); end; Append_To (Res, Decl); end if; -- Body for dispatching assignment Decl := Predef_Spec_Or_Body (Loc, Tag_Typ => Tag_Typ, Name => Name_uAssign, Profile => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_X), Out_Present => True, Parameter_Type => New_Reference_To (Tag_Typ, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_Y), Parameter_Type => New_Reference_To (Tag_Typ, Loc))), For_Body => True); Set_Handled_Statement_Sequence (Decl, Make_Handled_Sequence_Of_Statements (Loc, New_List ( Make_Assignment_Statement (Loc, Name => Make_Identifier (Loc, Name_X), Expression => Make_Identifier (Loc, Name_Y))))); Append_To (Res, Decl); end if; -- Generate dummy bodies for finalization actions of types that have -- no controlled components. -- Skip this processing if we are in the finalization routine in the -- runtime itself, otherwise we get hopelessly circularly confused! if In_Finalization_Root (Tag_Typ) then null; -- Skip this in no run time mode (where finalization is never allowed) elsif No_Run_Time then null; elsif (Etype (Tag_Typ) = Tag_Typ or else Is_Controlled (Tag_Typ)) and then not Has_Controlled_Component (Tag_Typ) then if not Is_Limited_Type (Tag_Typ) then Decl := Predef_Deep_Spec (Loc, Tag_Typ, Name_uDeep_Adjust, True); if Is_Controlled (Tag_Typ) then Set_Handled_Statement_Sequence (Decl, Make_Handled_Sequence_Of_Statements (Loc, Make_Adjust_Call ( Ref => Make_Identifier (Loc, Name_V), Typ => Tag_Typ, Flist_Ref => Make_Identifier (Loc, Name_L), With_Attach => Make_Identifier (Loc, Name_B)))); else Set_Handled_Statement_Sequence (Decl, Make_Handled_Sequence_Of_Statements (Loc, New_List ( Make_Null_Statement (Loc)))); end if; Append_To (Res, Decl); end if; Decl := Predef_Deep_Spec (Loc, Tag_Typ, Name_uDeep_Finalize, True); if Is_Controlled (Tag_Typ) then Set_Handled_Statement_Sequence (Decl, Make_Handled_Sequence_Of_Statements (Loc, Make_Final_Call ( Ref => Make_Identifier (Loc, Name_V), Typ => Tag_Typ, With_Detach => Make_Identifier (Loc, Name_B)))); else Set_Handled_Statement_Sequence (Decl, Make_Handled_Sequence_Of_Statements (Loc, New_List ( Make_Null_Statement (Loc)))); end if; Append_To (Res, Decl); end if; return Res; end Predefined_Primitive_Bodies; --------------------------------- -- Predefined_Primitive_Freeze -- --------------------------------- function Predefined_Primitive_Freeze (Tag_Typ : Entity_Id) return List_Id is Loc : constant Source_Ptr := Sloc (Tag_Typ); Res : List_Id := New_List; Prim : Elmt_Id; Frnodes : List_Id; begin Prim := First_Elmt (Primitive_Operations (Tag_Typ)); while Present (Prim) loop if Is_Internal (Node (Prim)) then Frnodes := Freeze_Entity (Node (Prim), Loc); if Present (Frnodes) then Append_List_To (Res, Frnodes); end if; end if; Next_Elmt (Prim); end loop; return Res; end Predefined_Primitive_Freeze; end Exp_Ch3;
arithmetic.g4
jamshidh/antlrToH
0
1793
<reponame>jamshidh/antlrToH /* BSD License Copyright (c) 2013, <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: 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. 3. Neither the name of <NAME> 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. */ grammar arithmetic; equation : expression relop expression ; expression : term ((PLUS | MINUS) term)* ; term : factor ((TIMES | DIV) factor)* ; factor : atom (POW atom)* ; atom : scientific | variable | LPAREN expression RPAREN ; scientific : number (E number)? ; relop : EQ | GT | LT ; number : MINUS? DIGIT + (POINT DIGIT +)? ; variable : MINUS? LETTER (LETTER | DIGIT)* ; LPAREN : '(' ; RPAREN : ')' ; PLUS : '+' ; MINUS : '-' ; TIMES : '*' ; DIV : '/' ; GT : '>' ; LT : '<' ; EQ : '=' ; POINT : '.' ; E : 'e' | 'E' ; POW : '^' ; LETTER : ('a' .. 'z') | ('A' .. 'Z') ; DIGIT : ('0' .. '9') ; WS : [ \r\n\t] + -> channel (HIDDEN) ;
src/util/vecteurs.ads
SKNZ/BezierToSTL
0
9319
<reponame>SKNZ/BezierToSTL with Liste_Generique; package Vecteurs is type Vecteur is array(Positive range<>) of Float; subtype Point2D is Vecteur(1..2); subtype Point3D is Vecteur(1..3); package Liste_Points is new Liste_Generique(Point2D); type Facette is record P1, P2, P3 : Point3D; end record; package Liste_Facettes is new Liste_Generique(Facette); -- addition de 2 vecteurs -- Requiert A, B de taille identique function "+" (A : Vecteur ; B : Vecteur) return Vecteur; -- soustraction de 2 vecteurs -- Requiert A, B de taille identique function "-" (A : Vecteur ; B : Vecteur) return Vecteur; -- multiplication scalaire vecteur function "*" (Facteur : Float ; V : Vecteur) return Vecteur; -- expo scalaire vecteur function "**" (V : Vecteur; Facteur : Positive) return Vecteur; -- division scalaire vecteur function "/" (V : Vecteur; Facteur : Float) return Vecteur; -- Renvoie une réprésentation chainée d'un point function To_String (P : Point2D) return String; function To_String_3D (P : Point3D) return String; end Vecteurs;
Task/Self-describing-numbers/Ada/self-describing-numbers.ada
LaudateCorpus1/RosettaCodeData
1
16522
with Ada.Text_IO; use Ada.Text_IO; procedure SelfDesc is subtype Desc_Int is Long_Integer range 0 .. 10**10-1; function isDesc (innum : Desc_Int) return Boolean is subtype S_Int is Natural range 0 .. 10; type S_Int_Arr is array (0 .. 9) of S_Int; ref, cnt : S_Int_Arr := (others => 0); n, digit : S_Int := 0; num : Desc_Int := innum; begin loop digit := S_Int (num mod 10); ref (9 - n) := digit; cnt (digit) := cnt (digit) + 1; num := num / 10; exit when num = 0; n := n + 1; end loop; return ref (9 - n .. 9) = cnt (0 .. n); end isDesc; begin for i in Desc_Int range 1 .. 100_000_000 loop if isDesc (i) then Put_Line (Desc_Int'Image (i)); end if; end loop; end SelfDesc;
programs/oeis/222/A222716.asm
karttu/loda
0
94471
; A222716: Numbers which are both the sum of n+1 consecutive triangular numbers and the sum of the n-1 immediately following triangular numbers. ; 0,10,100,460,1460,3710,8120,15960,28920,49170,79420,122980,183820,266630,376880,520880,705840,939930,1232340,1593340,2034340,2567950,3208040,3969800,4869800,5926050,7158060,8586900,10235260,12127510,14289760,16749920,19537760,22684970,26225220,30194220,34629780,39571870,45062680,51146680,57870680,65283890,73437980,82387140,92188140,102900390,114586000,127309840,141139600,156145850,172402100,189984860,208973700,229451310,251503560,275219560,300691720,328015810,357291020,388620020,422109020,457867830,496009920,536652480,579916480,625926730,674811940,726704780,781741940,840064190,901816440,967147800,1036211640,1109165650,1186171900,1267396900,1353011660,1443191750,1538117360,1637973360,1742949360,1853239770,1969043860,2090565820,2218014820,2351605070,2491555880,2638091720,2791442280,2951842530,3119532780,3294758740,3477771580,3668827990,3868190240,4076126240,4292909600,4518819690,4754141700,4999166700,5254191700,5519519710,5795459800,6082327160,6380443160,6690135410,7011737820,7345590660,7692040620,8051440870,8424151120,8810537680,9210973520,9625838330,10055518580,10500407580,10960905540,11437419630,11930364040,12440160040,12967236040,13512027650,14074977740,14656536500,15257161500,15877317750,16517477760,17178121600,17859736960,18562819210,19287871460,20035404620,20805937460,21599996670,22418116920,23260840920,24128719480,25022311570,25942184380,26888913380,27863082380,28865283590,29896117680,30956193840,32046129840,33166552090,34318095700,35501404540,36717131300,37965937550,39248493800,40565479560,41917583400,43305503010,44729945260,46191626260,47691271420,49229615510,50807402720,52425386720,54084330720,55785007530,57528199620,59314699180,61145308180,63020838430,64942111640,66909959480,68925223640,70988755890,73101418140,75264082500,77477631340,79742957350,82060963600,84432563600,86858681360,89340251450,91878219060,94473540060,97127181060,99840119470,102613343560,105447852520,108344656520,111304776770,114329245580,117419106420,120575413980,123799234230,127091644480,130453733440,133886601280,137391359690,140969131940,144621052940,148348269300,152151939390,156033233400,159993333400,164033433400,168154739410,172358469500,176645853860,181018134860,185476567110,190022417520,194656965360,199381502320,204197332570,209105772820,214108152380,219205813220,224400110030,229692410280,235084094280,240576555240,246171199330,251869445740,257672726740,263582487740,269600187350,275727297440,281965303200,288315703200,294780009450,301359747460,308056456300,314871688660,321807010910,328864003160,336044259320,343349387160,350781008370,358340758620,366030287620,373851259180,381805351270,389894256080,398119680080,406483344080,414986983290,423632347380,432421200540,441355321540,450436503790,459666555400,469047299240,478580573000,488268229250 lpb $0,1 mov $2,1 add $2,$0 mul $2,$0 sub $0,1 pow $2,2 add $1,$2 lpe div $1,4 mul $1,10
src/main/antlr4/imports/Clauses.g4
Yucukof/edu-antlr4-toy-parser-to-nbc
0
156
grammar Clauses; import Expressions , Declarations , Instructions , Words; clauseWhen: WHEN expression (DECLARE LOCAL varDecl+)? DO instruction+ DONE ; clauseDefault: BY DEFAULT (DECLARE LOCAL (varDecl)+)? DO instruction+ DONE ;
oeis/064/A064170.asm
neoneye/loda-programs
11
19476
; A064170: a(1) = 1; a(n+1) = product of numerator and denominator in Sum_{k=1..n} 1/a(k). ; 1,1,2,10,65,442,3026,20737,142130,974170,6677057,45765226,313679522,2149991425,14736260450,101003831722,692290561601,4745030099482,32522920134770,222915410843905,1527884955772562,10472279279564026,71778070001175617,491974210728665290,3372041405099481410,23112315624967704577,158414167969674450626,1085786860162753449802,7442093853169599697985,51008870112024444436090,349619996931001511354642,2396331108404986135046401,16424697761903901433970162,112576553224922323902744730 trn $0,1 seq $0,1906 ; F(2n) = bisection of Fibonacci sequence: a(n) = 3*a(n-1) - a(n-2). pow $0,2 add $0,1
other.7z/SFC.7z/SFC/ソースデータ/MarioKart/c-select-j.asm
prismotizm/gigaleak
0
6457
<gh_stars>0 Name: c-select-j.asm Type: file Size: 46127 Last-Modified: '1992-07-14T15:00:00Z' SHA-1: 0CA16B7F3743209D4B70D98F6BD379E3FA26F779 Description: null
src/main/fragment/mos6502-common/pwsc1_derefidx_vbuyy=vwsm1.asm
jbrandwood/kickc
2
80897
<reponame>jbrandwood/kickc<gh_stars>1-10 lda {m1} sta {c1},y lda {m1}+1 sta {c1}+1,y
food.asm
elifBalci/image-classification-with-x86Assembly
4
95534
;===================================================================== ; Image Classification with x86 assembly ; ; Author: <NAME> ; Date: 2019-05-23 ; ;TODO: ;********BMP file type check ;********Receiving proper pixel count from c code.e ; ;===================================================================== section .text extern printf global food food: push ebp mov ebp, esp mov eax, [values] ;_________________________________________________________________ mov ecx, 255 ;counter for the loop initialize_array: ;make sure every element of array is equal to 0 push ecx mov DWORD [values + ecx*4], 0 mov eax, [values+ ecx*4] push eax ;|print push DWORD format3 ;| ;call printf ;| add esp, 8 ;| pop ecx loop initialize_array ;_________________________________________________________________ ;_________________________________________________________________ mov ecx, 40006 ;loop counter, goes through every pixel. l1: ;prepares the histogram push ecx; ;for loop counter mov ebx , DWORD [ebp+8] pop ecx mov edx, ecx add edx,edx ; add edx, ecx ;edx = 3*edx - 2 to access green values. sub edx, 2 ; push ecx mov al, [ebx + edx] ;al has the desired value. add DWORD [values + eax*4], 1 push ebx push DWORD format ;call printf add esp, 8 pop ecx loop l1 ;_________________________________________________________________ ;_________________________________________________________________ mov ecx, 255 mov ebx, 0 find_max: ; finds the max value in the histogram. push ecx mov eax, [values+ ecx*4] cmp eax, ebx jl less mov ebx, eax less: pop ecx loop find_max ;_________________________________________________________________ ;_________________________________________________________________ mov ecx, 255 find_mode: push ecx mov eax, [values+ ecx*4] cmp eax, ebx je print_mode pop ecx loop find_mode ;_________________________________________________________________ ;_________________________________________________________________ mov ecx, 255 print_array: push ecx mov eax, [values+ ecx*4] push eax ;|print push DWORD format3 ;| ;call printf ;| add esp, 8 ;| pop ecx loop print_array ;_________________________________________________________________ pop ebp ret print_mode: push ecx ;|print push DWORD format3 ;| ;call printf ;| add esp, 8 ;| pop ecx ;_________________________________________________________________ determine_type: cmp ecx, 20 jle cur; cmp ecx, 66 jle steak jg salam ;_________________________________________________________________ pop ebp ret cur: mov eax, 1 push eax ;|print push DWORD format3 ;| call printf ;| add esp, 8 ;| pop ebp ret ;_________________________________________________________________ steak: mov eax, 3 push eax ;|print push DWORD format3 ;| call printf ;| add esp, 8 ;| pop ebp ret ;_________________________________________________________________ salam: mov eax, 2 push eax ;|print push DWORD format3 ;| call printf ;| add esp, 8 ;| pop ebp ret ;_________________________________________________________________ section .data values: TIMES 1064 DB 0 list: DW 20, 66 ;if less then 20: currant(1), between 20 and 66: steak(3), bigger than 66: salam(2). bmp_file_size: Dd bmp_file_size, 120054 format: DB "** a=%d\ **", 00ah, 0 format2: DB "d* a=%d\ *d", 00ah format3: DB "type is:%d ", 00ah, 0 ;============================================ ; THE STACK ;============================================ ; ; larger addresses ; ; | | ; | ... | ; --------------------------------- ; | function parameter - char *a | EBP+8 ; --------------------------------- ; | return address | EBP+4 ; --------------------------------- ; | saved ebp | EBP, ESP ; --------------------------------- ; | ... here local variables | EBP-x ; | when needed | ; ; \/ \/ ; \/ the stack grows in this \/ ; \/ direction \/ ; ; lower addresses ; ; ;============================================
agda/Instruments.agda
halfaya/MusicTools
28
1995
{-# OPTIONS --erased-cubical --safe #-} module Instruments where open import Data.Fin using (#_) open import MidiEvent using (InstrumentNumber-1; maxChannels) open import Data.Vec using (Vec; []; _∷_) -- Start of an instrument list -- all instruments have this type piano : InstrumentNumber-1 piano = # 0 brightPiano = # 1 electricGrandPiano = # 2 honkyTonkPiano = # 3 electricPiano1 = # 4 electricPiano2 = # 5 harpsichord = # 6 clavinet = # 7 celesta = # 8 vibraphone = # 11 drawbarOrgan = # 16 percussiveOrgan = # 17 rockOrgan = # 18 churchOrgan = # 19 acousticGuitar[nylon] = # 24 acousticGuitar[steel] = # 25 electricGuitar[jazz] = # 26 electricGuitar[clean] = # 27 electricGuitar[muted] = # 28 overdrivenGuitar = # 29 distortionGuitar = # 30 guitarHarmonics = # 31 harp = # 46 ---------------- drums : InstrumentNumber-1 drums = # 0 ---------------- -- Assign piano to all tracks -- Note that channel 10 (9 as Channel-1) is percussion pianos : Vec InstrumentNumber-1 maxChannels pianos = piano ∷ -- 1 piano ∷ -- 2 piano ∷ -- 3 piano ∷ -- 4 piano ∷ -- 5 piano ∷ -- 6 piano ∷ -- 7 piano ∷ -- 8 piano ∷ -- 9 drums ∷ -- 10 (percussion) piano ∷ -- 11 piano ∷ -- 12 piano ∷ -- 13 piano ∷ -- 14 piano ∷ -- 15 piano ∷ -- 16 []
experiments/count/cas.4.3/count.checker.asm
phlo/concubine
0
11290
# <NAME>'s Statistical Counter (PerfBook 5.2) # # Summation (checker) thread: EXIT 1 if global counter is not incremented 3 # times by 4 threads (heap[0] != 3 * 4). # # steps: # * total = 5 # # template parameter: # * 12 = expected global counter value # CHECK 0 # start checker thread ADDI 12 # expected result CMP 0 # compare to global JNZ error # check result EXIT 0 # result == 4 * 3 error: EXIT 1 # error: result != 4 * 3
firmware/coreboot/3rdparty/libgfxinit/common/hw-gfx-gma-pch-transcoder.adb
fabiojna02/OpenCellular
1
4383
-- -- Copyright (C) 2015-2016 secunet Security Networks AG -- Copyright (C) 2016 <NAME> <<EMAIL>> -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- with HW.GFX.GMA.Config; with HW.GFX.GMA.DP_Info; with HW.GFX.GMA.Registers; with HW.Debug; with GNAT.Source_Info; package body HW.GFX.GMA.PCH.Transcoder is type DPLL_SEL_Array is array (FDI_Port_Type) of Word32; DPLL_SEL_TRANSCODER_x_DPLL_ENABLE : constant DPLL_SEL_Array := (FDI_A => 1 * 2 ** 3, FDI_B => 1 * 2 ** 7, FDI_C => 1 * 2 ** 11); DPLL_SEL_TRANSCODER_x_DPLL_SEL_MASK : constant DPLL_SEL_Array := (FDI_A => 1 * 2 ** 0, FDI_B => 1 * 2 ** 4, FDI_C => 1 * 2 ** 8); function DPLL_SEL_TRANSCODER_x_DPLL_SEL (Port : FDI_Port_Type; PLL : Word32) return Word32 is begin return Shift_Left (PLL, (case Port is when FDI_A => 0, when FDI_B => 4, when FDI_C => 8)); end DPLL_SEL_TRANSCODER_x_DPLL_SEL; TRANS_CONF_TRANSCODER_ENABLE : constant := 1 * 2 ** 31; TRANS_CONF_TRANSCODER_STATE : constant := 1 * 2 ** 30; TRANS_CHICKEN2_TIMING_OVERRIDE : constant := 1 * 2 ** 31; TRANS_DP_CTL_OUTPUT_ENABLE : constant := 1 * 2 ** 31; TRANS_DP_CTL_PORT_SELECT_MASK : constant := 3 * 2 ** 29; TRANS_DP_CTL_PORT_SELECT_NONE : constant := 3 * 2 ** 29; TRANS_DP_CTL_ENHANCED_FRAMING : constant := 1 * 2 ** 18; TRANS_DP_CTL_VSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 4; TRANS_DP_CTL_HSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 3; type TRANS_DP_CTL_PORT_SELECT_Array is array (PCH_Port) of Word32; TRANS_DP_CTL_PORT_SELECT : constant TRANS_DP_CTL_PORT_SELECT_Array := (PCH_DP_B => 0 * 2 ** 29, PCH_DP_C => 1 * 2 ** 29, PCH_DP_D => 2 * 2 ** 29, others => 0); function TRANS_DP_CTL_BPC (BPC : BPC_Type) return Word32 is begin return (case BPC is when 6 => 2 * 2 ** 9, when 10 => 1 * 2 ** 9, when 12 => 3 * 2 ** 9, when others => 0 * 2 ** 9); end TRANS_DP_CTL_BPC; function TRANS_DATA_M_TU (Transfer_Unit : Positive) return Word32 is begin return Shift_Left (Word32 (Transfer_Unit - 1), 25); end TRANS_DATA_M_TU; ---------------------------------------------------------------------------- type Transcoder_Registers is record HTOTAL : Registers.Registers_Index; HBLANK : Registers.Registers_Index; HSYNC : Registers.Registers_Index; VTOTAL : Registers.Registers_Index; VBLANK : Registers.Registers_Index; VSYNC : Registers.Registers_Index; CONF : Registers.Registers_Index; DP_CTL : Registers.Registers_Index; DATA_M : Registers.Registers_Index; DATA_N : Registers.Registers_Index; LINK_M : Registers.Registers_Index; LINK_N : Registers.Registers_Index; CHICKEN2 : Registers.Registers_Index; end record; type Transcoder_Registers_Array is array (FDI_Port_Type) of Transcoder_Registers; TRANS : constant Transcoder_Registers_Array := Transcoder_Registers_Array' (FDI_A => (HTOTAL => Registers.TRANS_HTOTAL_A, HBLANK => Registers.TRANS_HBLANK_A, HSYNC => Registers.TRANS_HSYNC_A, VTOTAL => Registers.TRANS_VTOTAL_A, VBLANK => Registers.TRANS_VBLANK_A, VSYNC => Registers.TRANS_VSYNC_A, CONF => Registers.TRANSACONF, DP_CTL => Registers.TRANS_DP_CTL_A, DATA_M => Registers.TRANSA_DATA_M1, DATA_N => Registers.TRANSA_DATA_N1, LINK_M => Registers.TRANSA_DP_LINK_M1, LINK_N => Registers.TRANSA_DP_LINK_N1, CHICKEN2 => Registers.TRANSA_CHICKEN2), FDI_B => (HTOTAL => Registers.TRANS_HTOTAL_B, HBLANK => Registers.TRANS_HBLANK_B, HSYNC => Registers.TRANS_HSYNC_B, VTOTAL => Registers.TRANS_VTOTAL_B, VBLANK => Registers.TRANS_VBLANK_B, VSYNC => Registers.TRANS_VSYNC_B, CONF => Registers.TRANSBCONF, DP_CTL => Registers.TRANS_DP_CTL_B, DATA_M => Registers.TRANSB_DATA_M1, DATA_N => Registers.TRANSB_DATA_N1, LINK_M => Registers.TRANSB_DP_LINK_M1, LINK_N => Registers.TRANSB_DP_LINK_N1, CHICKEN2 => Registers.TRANSB_CHICKEN2), FDI_C => (HTOTAL => Registers.TRANS_HTOTAL_C, HBLANK => Registers.TRANS_HBLANK_C, HSYNC => Registers.TRANS_HSYNC_C, VTOTAL => Registers.TRANS_VTOTAL_C, VBLANK => Registers.TRANS_VBLANK_C, VSYNC => Registers.TRANS_VSYNC_C, CONF => Registers.TRANSCCONF, DP_CTL => Registers.TRANS_DP_CTL_C, DATA_M => Registers.TRANSC_DATA_M1, DATA_N => Registers.TRANSC_DATA_N1, LINK_M => Registers.TRANSC_DP_LINK_M1, LINK_N => Registers.TRANSC_DP_LINK_N1, CHICKEN2 => Registers.TRANSC_CHICKEN2)); ---------------------------------------------------------------------------- procedure On (Port_Cfg : Port_Config; Port : FDI_Port_Type; PLL : Word32) is Mode : constant Mode_Type := Port_Cfg.Mode; function Encode (LSW, MSW : Pos32) return Word32 is begin return (Word32 (LSW) - 1) or ((Word32 (MSW) - 1) * 2 ** 16); end Encode; begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); if Config.Has_DPLL_SEL then Registers.Unset_And_Set_Mask (Register => Registers.PCH_DPLL_SEL, Mask_Unset => DPLL_SEL_TRANSCODER_x_DPLL_SEL_MASK (Port), Mask_Set => DPLL_SEL_TRANSCODER_x_DPLL_ENABLE (Port) or DPLL_SEL_TRANSCODER_x_DPLL_SEL (Port, PLL)); end if; Registers.Write (Register => TRANS (Port).HTOTAL, Value => Encode (Mode.H_Visible, Mode.H_Total)); Registers.Write (Register => TRANS (Port).HBLANK, Value => Encode (Mode.H_Visible, Mode.H_Total)); Registers.Write (Register => TRANS (Port).HSYNC, Value => Encode (Mode.H_Sync_Begin, Mode.H_Sync_End)); Registers.Write (Register => TRANS (Port).VTOTAL, Value => Encode (Mode.V_Visible, Mode.V_Total)); Registers.Write (Register => TRANS (Port).VBLANK, Value => Encode (Mode.V_Visible, Mode.V_Total)); Registers.Write (Register => TRANS (Port).VSYNC, Value => Encode (Mode.V_Sync_Begin, Mode.V_Sync_End)); if Port_Cfg.Display = DP then declare Data_M, Link_M : DP_Info.M_Type; Data_N, Link_N : DP_Info.N_Type; begin DP_Info.Calculate_M_N (Link => Port_Cfg.DP, Mode => Port_Cfg.Mode, Data_M => Data_M, Data_N => Data_N, Link_M => Link_M, Link_N => Link_N); Registers.Write (Register => TRANS (Port).DATA_M, Value => TRANS_DATA_M_TU (64) or Word32 (Data_M)); Registers.Write (Register => TRANS (Port).DATA_N, Value => Word32 (Data_N)); Registers.Write (Register => TRANS (Port).LINK_M, Value => Word32 (Link_M)); Registers.Write (Register => TRANS (Port).LINK_N, Value => Word32 (Link_N)); end; if Config.Has_Trans_DP_Ctl then declare Polarity : constant Word32 := (if Port_Cfg.Mode.H_Sync_Active_High then TRANS_DP_CTL_HSYNC_ACTIVE_HIGH else 0) or (if Port_Cfg.Mode.V_Sync_Active_High then TRANS_DP_CTL_VSYNC_ACTIVE_HIGH else 0); Enhanced_Framing : constant Word32 := (if Port_Cfg.DP.Enhanced_Framing then TRANS_DP_CTL_ENHANCED_FRAMING else 0); begin Registers.Write (Register => TRANS (Port).DP_CTL, Value => TRANS_DP_CTL_OUTPUT_ENABLE or TRANS_DP_CTL_PORT_SELECT (Port_Cfg.PCH_Port) or Enhanced_Framing or TRANS_DP_CTL_BPC (Port_Cfg.Mode.BPC) or Polarity); end; end if; end if; if Config.Has_Trans_Timing_Ovrrde then Registers.Set_Mask (Register => TRANS (Port).CHICKEN2, Mask => TRANS_CHICKEN2_TIMING_OVERRIDE); end if; Registers.Write (Register => TRANS (Port).CONF, Value => TRANS_CONF_TRANSCODER_ENABLE); end On; procedure Off (Port : FDI_Port_Type) is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); Registers.Unset_Mask (Register => TRANS (Port).CONF, Mask => TRANS_CONF_TRANSCODER_ENABLE); Registers.Wait_Unset_Mask (Register => TRANS (Port).CONF, Mask => TRANS_CONF_TRANSCODER_STATE, TOut_MS => 50); if Config.Has_Trans_Timing_Ovrrde then Registers.Unset_Mask (Register => TRANS (Port).CHICKEN2, Mask => TRANS_CHICKEN2_TIMING_OVERRIDE); end if; if Config.Has_Trans_DP_Ctl then Registers.Write (Register => TRANS (Port).DP_CTL, Value => TRANS_DP_CTL_PORT_SELECT_NONE); end if; if Config.Has_DPLL_SEL then Registers.Unset_Mask (Register => Registers.PCH_DPLL_SEL, Mask => DPLL_SEL_TRANSCODER_x_DPLL_ENABLE (Port)); end if; end Off; end HW.GFX.GMA.PCH.Transcoder;
Transynther/x86/_processed/US/_zr_/i7-7700_9_0x48_notsx.log_2_39.asm
ljhsiun2/medusa
9
94517
<filename>Transynther/x86/_processed/US/_zr_/i7-7700_9_0x48_notsx.log_2_39.asm .global s_prepare_buffers s_prepare_buffers: push %r11 push %r15 push %r9 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0xb0cc, %rdi clflush (%rdi) sub %r11, %r11 vmovups (%rdi), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $1, %xmm1, %r15 nop nop nop nop nop add $1386, %r9 lea addresses_UC_ht+0x1424c, %rbp nop inc %rax mov (%rbp), %r11 nop nop nop add %rdi, %rdi lea addresses_normal_ht+0x18cc, %rax add %rbx, %rbx movups (%rax), %xmm0 vpextrq $0, %xmm0, %rdi nop nop add $27997, %r9 lea addresses_normal_ht+0xbecc, %rsi lea addresses_UC_ht+0x68cc, %rdi nop nop dec %rax mov $2, %rcx rep movsl nop nop add %rcx, %rcx lea addresses_A_ht+0x128cc, %r9 nop cmp $51780, %rbp mov $0x6162636465666768, %rcx movq %rcx, %xmm6 vmovups %ymm6, (%r9) nop nop sub %rsi, %rsi lea addresses_normal_ht+0x7ccc, %rsi cmp $57465, %rbx mov $0x6162636465666768, %rax movq %rax, %xmm2 vmovups %ymm2, (%rsi) nop nop nop and %rbp, %rbp lea addresses_WT_ht+0x14288, %rsi lea addresses_UC_ht+0xdecc, %rdi and $61489, %rbx mov $85, %rcx rep movsw nop dec %rdi lea addresses_normal_ht+0x238c, %rsi lea addresses_WC_ht+0x91c, %rdi clflush (%rdi) nop nop and $62873, %r9 mov $53, %rcx rep movsl nop cmp $16685, %r9 pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r9 pop %r15 pop %r11 ret .global s_faulty_load s_faulty_load: push %r14 push %r9 push %rax push %rbx push %rcx push %rdi push %rdx // Store lea addresses_D+0x132ac, %rax nop nop nop sub $54583, %rdx mov $0x5152535455565758, %rdi movq %rdi, %xmm2 movups %xmm2, (%rax) nop nop and %rdi, %rdi // Faulty Load lea addresses_US+0xe8cc, %rbx nop nop add $40978, %r9 vmovups (%rbx), %ymm0 vextracti128 $1, %ymm0, %xmm0 vpextrq $0, %xmm0, %rcx lea oracles, %rbx and $0xff, %rcx shlq $12, %rcx mov (%rbx,%rcx,1), %rcx pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r9 pop %r14 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_US', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D', 'congruent': 5}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_US', 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_UC_ht', 'congruent': 11}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC_ht', 'congruent': 6}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 11}} {'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_normal_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A_ht', 'congruent': 11}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_normal_ht', 'congruent': 10}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}} {'dst': {'same': True, 'congruent': 4, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}} {'00': 2} 00 00 */
programs/oeis/180/A180674.asm
jmorken/loda
1
99140
<reponame>jmorken/loda<filename>programs/oeis/180/A180674.asm ; A180674: a(n) = Fibonacci(n+9) - Fibonacci(9). ; 0,21,55,110,199,343,576,953,1563,2550,4147,6731,10912,17677,28623,46334,74991,121359,196384,317777,514195,832006,1346235,2178275,3524544,5702853,9227431,14930318,24157783,39088135,63245952,102334121,165580107,267914262,433494403,701408699,1134903136,1836311869,2971215039,4807526942,7778742015,12586268991,20365011040,32951280065,53316291139,86267571238,139583862411,225851433683,365435296128,591286729845,956722026007,1548008755886,2504730781927,4052739537847,6557470319808,10610209857689,17167680177531,27777890035254,44945570212819,72723460248107,117669030460960,190392490709101,308061521170095,498454011879230,806515533049359,1304969544928623,2111485077978016,3416454622906673,5527939700884723,8944394323791430 add $0,5 mov $1,6 mov $2,4 lpb $0 sub $0,1 mov $3,$2 mov $2,$1 add $1,$3 lpe sub $1,68 div $1,2
programs/oeis/120/A120154.asm
neoneye/loda
22
83577
; A120154: a(1)=9; a(n)=floor((27+sum(a(1) to a(n-1)))/3). ; 9,12,16,21,28,37,50,66,88,118,157,209,279,372,496,661,882,1176,1568,2090,2787,3716,4955,6606,8808,11744,15659,20879,27838,37118,49490,65987,87983,117310,156414,208552,278069,370759,494345,659127 add $0,1 mov $2,1 lpb $0 sub $0,1 add $2,$1 mov $1,8 add $1,$2 div $1,3 add $2,6 lpe add $1,6 mov $0,$1
hex2bin.asm
tsupplis/msdos11-hacking
3
101750
<filename>hex2bin.asm ; HEX2BIN version 1.02 ; Converts Intel hex format files to straight binary FCB: EQU 5CH READ: EQU 20 SETDMA: EQU 26 OPEN: EQU 15 CLOSE: EQU 16 CREATE: EQU 22 DELETE: EQU 19 BLKWRT: EQU 40 GETSEG: EQU 38 BUFSIZ: EQU 1024 ORG 100H PUT 100H HEX2BIN: MOV DX,HEADER MOV AH,9 INT 21H MOV DI,FCB+9 CMP B,[DI]," " JNZ HAVEXT MOV SI,HEX MOVB MOVW HAVEXT: ;Get load offset (default is -100H) MOV CL,4 ;Needed for shifts MOV [OFFSET],-100H MOV SI,FCB+11H ;Scan second FCB for offset LODB CMP AL," " ;Check if offset present JZ HAVOFF MOV B,[SIGN],0 ;Assume positive sign for now CMP AL,"+" JZ GETOFF ;Get a positive offset CMP AL,"-" JNZ GETOFF1 ;If not + or -, then not signed MOV B,[SIGN],1 ;Flag as negative offset GETOFF: LODB ;Eat sign GETOFF1: CALL HEXCHK ;Check for valid hex character JC HAVOFF ;No offset if not valid XOR BX,BX ;Intialize offset sum to 0 CONVOFF: SHL BX,CL ;Multiply current sum by 16 OR BL,AL ;Add in current hex digit LODB ;Get next digit CALL HEXCHK ;And convert it to binary JNC CONVOFF ;Loop until all hex digits read TEST B,[SIGN],-1 ;Check if offset was to be negative JZ SAVOFF NEG BX SAVOFF: MOV [OFFSET],BX HAVOFF: MOV DX,STARTSEG MOV AX,DS ADD DX,AX ;Compute load segment MOV AH,GETSEG INT 33 MOV ES,DX SEG ES MOV CX,[6] ;Get size of segment MOV [SEGSIZ],CX XOR AX,AX MOV DI,AX MOV BP,AX SHR CX REP STOW ;Fill entire segment with zeros MOV AH,OPEN MOV DX,FCB INT 21H OR AL,AL JNZ NOFIL MOV B,[FCB+32],0 MOV [FCB+14],BUFSIZ ;Set record size to buffer size MOV DX,BUFFER MOV AH,SETDMA INT 33 MOV AH,READ MOV DX,FCB ;All set up for sequential reads MOV SI,BUFFER+BUFSIZ ;Flag input buffer as empty READHEX: CALL GETCH CMP AL,":" ;Search for : to start line JNZ READHEX CALL GETBYT ;Get byte count MOV CL,AL MOV CH,0 JCXZ DONE CALL GETBYT ;Get high byte of load address MOV BH,AL CALL GETBYT ;Get low byte of load address MOV BL,AL ADD BX,[OFFSET] ;Add in offset MOV DI,BX CALL GETBYT ;Throw away type byte READLN: CMP DI,[SEGSIZ] JAE ADERR CALL GETBYT ;Get data byte STOB CMP DI,BP ;Check if this is the largest address so far JBE HAVBIG MOV BP,DI ;Save new largest HAVBIG: LOOP READLN JP READHEX NOFIL: MOV DX,NOFILE QUIT: MOV AH,9 INT 21H INT 20H ADERR: MOV DX,ADDR JMP SHOWERR GETCH: CMP SI,BUFFER+BUFSIZ JNZ NOREAD INT 21H CMP AL,1 JZ ERROR MOV SI,BUFFER NOREAD: LODB CMP AL,1AH JZ DONE RET GETBYT: CALL HEXDIG MOV BL,AL CALL HEXDIG SHL BL SHL BL SHL BL SHL BL OR AL,BL RET HEXCHK: SUB AL,"0" JC RET CMP AL,10 JC CMCRET SUB AL,"A"-"0"-10 JC RET CMP AL,16 CMCRET: CMC RET HEXDIG: CALL GETCH CALL HEXCHK JNC RET ERROR: MOV DX,ERRMES SHOWERR: MOV AH,9 INT 21H DONE: MOV [FCB+9],4F00H+"C" ;"CO" MOV B,[FCB+11],"M" MOV DX,FCB MOV AH,CREATE INT 21H OR AL,AL JNZ NOROOM XOR AX,AX MOV [FCB+33],AX MOV [FCB+35],AX ;Set RR field INC AX MOV [FCB+14],AX ;Set record size XOR DX,DX PUSH DS PUSH ES POP DS ;Get load segment MOV AH,SETDMA INT 21H POP DS MOV CX,BP MOV AH,BLKWRT MOV DX,FCB INT 21H MOV AH,CLOSE INT 21H MOV DX,BYEMES MOV AH,9 INT 21H EXIT: INT 20H NOROOM: MOV DX,DIRFUL JMP QUIT HEADER: DB 13,10,'Seattle Computer Products 8086 Hex Converter Version 1.02A' DB 13,10,'Copyright 1979-1983 by Seattle Computer Products, Inc.' DB 13,10,13,10,'$' HEX: DB "HEX" BYEMES: DB "Done.",0Dh,0Ah,"$" ERRMES: DB "Error in HEX file--conversion, aborted",0Dh,0Ah,"$" NOFILE: DB "File not found",0Dh,0Ah,"$" ADDR: DB "Address out of range--conversion, aborted",0Dh,0Ah,"$" DIRFUL: DB "Disk directory full",0Dh,0Ah,"$" OFFSET: DS 2 SEGSIZ: DS 2 SIGN: DS 1 BUFFER: DS BUFSIZ START: STARTSEG EQU (START+15)/16 
tests/natools-s_expressions-templates-tests-integers.ads
faelys/natools
0
22287
------------------------------------------------------------------------------ -- Copyright (c) 2014, <NAME> -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Natools.S_Expressions.Templates.Tests.Integers provides a test suite for -- -- integer S-expression template system. -- ------------------------------------------------------------------------------ package Natools.S_Expressions.Templates.Tests.Integers is procedure All_Tests (Report : in out NT.Reporter'Class); procedure Alignment (Report : in out NT.Reporter'Class); procedure Default_Format (Report : in out NT.Reporter'Class); procedure Explicit_Default_Format (Report : in out NT.Reporter'Class); procedure Explicit_Images (Report : in out NT.Reporter'Class); procedure Explicit_Sign (Report : in out NT.Reporter'Class); procedure Hexadecimal (Report : in out NT.Reporter'Class); procedure Overflow (Report : in out NT.Reporter'Class); procedure Parse_Errors (Report : in out NT.Reporter'Class); procedure Prefix_And_Suffix (Report : in out NT.Reporter'Class); procedure Static_Hash_Map (Report : in out NT.Reporter'Class); end Natools.S_Expressions.Templates.Tests.Integers;
llvm-gcc-4.2-2.9/gcc/ada/s-chepoo.ads
vidkidz/crossbridge
1
29435
<reponame>vidkidz/crossbridge ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . C H E C K E D _ P O O L S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2006, 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 2, 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 COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Storage_Elements; with System.Storage_Pools; package System.Checked_Pools is type Checked_Pool is abstract new System.Storage_Pools.Root_Storage_Pool with private; -- Equivalent of storage pools with the addition that Dereference is -- called on each implicit or explicit dereference of a pointer which -- has such a storage pool procedure Dereference (Pool : in out Checked_Pool; Storage_Address : Address; Size_In_Storage_Elements : System.Storage_Elements.Storage_Count; Alignment : System.Storage_Elements.Storage_Count) is abstract; -- Called implicitly each time a pointer to a checked pool is dereferenced -- All parameters in the profile are compatible with the profile of -- Allocate/Deallocate: the Storage_Address corresponds to the address of -- the dereferenced object, Size_in_Storage_Elements is its dynamic size -- (and thus may involve an implicit dispatching call to size) and -- Alignment is the alignment of the object. private type Checked_Pool is abstract new System.Storage_Pools.Root_Storage_Pool with null record; end System.Checked_Pools;
Sources/Globe_3d/globe_3d-wire_frame.ads
ForYouEyesOnly/Space-Convoy
1
3324
pragma Warnings (Off); pragma Style_Checks (Off); package GLOBE_3D.Wire_frame is type Segment is record P1, P2 : Positive; -- Indices to o.Point colour : GL.RGBA_Color; end record; type Segment_array is array (Positive range <>) of Segment; type p_Segment_array is access Segment_array; type Wired_3D is new Object_3D with record wire : p_Segment_array := null; end record; type p_Wired_3D is access Wired_3D; type Wired_3D_array is array (Positive range <>) of p_Wired_3D; type p_Wired_3D_array is access Wired_3D_array; procedure Display_one (o : in out Wired_3D); end GLOBE_3D.Wire_frame;
programs/oeis/008/A008577.asm
karttu/loda
1
161917
; A008577: Crystal ball sequence for planar net 4.8.8. ; 1,4,9,17,28,41,57,76,97,121,148,177,209,244,281,321,364,409,457,508,561,617,676,737,801,868,937,1009,1084,1161,1241,1324,1409,1497,1588,1681,1777,1876,1977,2081,2188,2297,2409,2524,2641,2761,2884,3009,3137,3268,3401,3537,3676,3817,3961,4108,4257,4409,4564,4721,4881,5044,5209,5377,5548,5721,5897,6076,6257,6441,6628,6817,7009,7204,7401,7601,7804,8009,8217,8428,8641,8857,9076,9297,9521,9748,9977,10209,10444,10681,10921,11164,11409,11657,11908,12161,12417,12676,12937,13201,13468,13737,14009,14284,14561,14841,15124,15409,15697,15988,16281,16577,16876,17177,17481,17788,18097,18409,18724,19041,19361,19684,20009,20337,20668,21001,21337,21676,22017,22361,22708,23057,23409,23764,24121,24481,24844,25209,25577,25948,26321,26697,27076,27457,27841,28228,28617,29009,29404,29801,30201,30604,31009,31417,31828,32241,32657,33076,33497,33921,34348,34777,35209,35644,36081,36521,36964,37409,37857,38308,38761,39217,39676,40137,40601,41068,41537,42009,42484,42961,43441,43924,44409,44897,45388,45881,46377,46876,47377,47881,48388,48897,49409,49924,50441,50961,51484,52009,52537,53068,53601,54137,54676,55217,55761,56308,56857,57409,57964,58521,59081,59644,60209,60777,61348,61921,62497,63076,63657,64241,64828,65417,66009,66604,67201,67801,68404,69009,69617,70228,70841,71457,72076,72697,73321,73948,74577,75209,75844,76481,77121,77764,78409,79057,79708,80361,81017,81676,82337,83001 mov $1,$0 add $1,$0 add $1,1 pow $1,2 add $1,3 div $1,3
prototyping/Examples/Syntax.agda
Tr4shh/Roblox-Luau
0
170
<reponame>Tr4shh/Roblox-Luau<gh_stars>0 module Examples.Syntax where open import Agda.Builtin.Equality using (_≡_; refl) open import FFI.Data.String using (_++_) open import Luau.Syntax using (var; _$_; return; nil; function_is_end; local_←_; done; _∙_; _⟨_⟩) open import Luau.Syntax.ToString using (exprToString; blockToString) ex1 : exprToString(function "" ⟨ var "x" ⟩ is return (var "f" $ var "x") ∙ done end) ≡ "function(x)\n" ++ " return f(x)\n" ++ "end" ex1 = refl ex2 : blockToString(local var "x" ← nil ∙ return (var "x") ∙ done) ≡ "local x = nil\n" ++ "return x" ex2 = refl ex3 : blockToString(function "f" ⟨ var "x" ⟩ is return (var "x") ∙ done end ∙ return (var "f") ∙ done) ≡ "local function f(x)\n" ++ " return x\n" ++ "end\n" ++ "return f" ex3 = refl
libsrc/_DEVELOPMENT/math/float/math32/c/sccz80/cm32_sccz80_fmod.asm
Frodevan/z88dk
640
244790
SECTION code_fp_math32 PUBLIC cm32_sccz80_fmod EXTERN cm32_sccz80_switch_arg EXTERN _m32_fmodf .cm32_sccz80_fmod call cm32_sccz80_switch_arg jp _m32_fmodf
cc4x86/tests/visual/rasterizer/rasterizer_.asm
artyompal/C-compiler
4
162973
.686 .model flat .xmm .data __dbgprintf dd ? public __dbgprintf __width dd ? public __width __height dd ? public __height __pitch dd ? public __pitch __color dd ? public __color __videomem dd ? public __videomem __mvproj_matrix db 64 dup (?) public __mvproj_matrix __viewport_matrix db 64 dup (?) public __viewport_matrix __clip_z_near_base db 16 dup (?) public __clip_z_near_base __clip_z_near_norm db 16 dup (?) public __clip_z_near_norm __clip_z_far_base db 16 dup (?) public __clip_z_far_base __clip_z_far_norm db 16 dup (?) public __clip_z_far_norm __clip_plane_left_base db 16 dup (?) public __clip_plane_left_base __clip_plane_left_norm db 16 dup (?) public __clip_plane_left_norm __clip_plane_right_base db 16 dup (?) public __clip_plane_right_base __clip_plane_right_norm db 16 dup (?) public __clip_plane_right_norm __clip_plane_top_base db 16 dup (?) public __clip_plane_top_base __clip_plane_top_norm db 16 dup (?) public __clip_plane_top_norm __clip_plane_bottom_base db 16 dup (?) public __clip_plane_bottom_base __clip_plane_bottom_norm db 16 dup (?) public __clip_plane_bottom_norm __texture_data dd ? public __texture_data __texture_width dd ? public __texture_width __texture_height dd ? public __texture_height ___unnamed_double_0 dq 03f1a36e2eb1c432dh public ___unnamed_double_0 ___unnamed_float_1 dd 03f800000h public ___unnamed_float_1 ___unnamed_float_2 dd 00h public ___unnamed_float_2 ___unnamed_float_3 dd 03f000000h public ___unnamed_float_3 align 16 ___unnamed_float4_4 dd 080000000h, 00h, 00h, 00h public ___unnamed_float4_4 ___unnamed_float_5 dd 0bf800000h public ___unnamed_float_5 ___unnamed_float_6 dd 03b808081h public ___unnamed_float_6 .code _vec2f_add proc push ebp mov ebp,esp mov eax,[ebp+12] mov ecx,[ebp+16] movss xmm0,dword ptr [eax] addss xmm0,dword ptr [ecx] mov eax,[ebp+8] movss dword ptr [eax],xmm0 mov eax,4 add eax,[ebp+12] mov ecx,4 add ecx,[ebp+16] movss xmm0,dword ptr [eax] addss xmm0,dword ptr [ecx] mov eax,4 add eax,[ebp+8] movss dword ptr [eax],xmm0 pop ebp ret _vec2f_add endp _vec2f_subtract proc push ebp mov ebp,esp mov eax,[ebp+12] mov ecx,[ebp+16] movss xmm0,dword ptr [eax] subss xmm0,dword ptr [ecx] mov eax,[ebp+8] movss dword ptr [eax],xmm0 mov eax,4 add eax,[ebp+12] mov ecx,4 add ecx,[ebp+16] movss xmm0,dword ptr [eax] subss xmm0,dword ptr [ecx] mov eax,4 add eax,[ebp+8] movss dword ptr [eax],xmm0 pop ebp ret _vec2f_subtract endp _vec2f_mul proc push ebp mov ebp,esp mov eax,[ebp+8] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ebp+12] movss dword ptr [eax],xmm0 mov eax,4 add eax,[ebp+8] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ebp+12] movss dword ptr [eax],xmm0 pop ebp ret _vec2f_mul endp _vec4f_assign proc push ebp mov ebp,esp mov eax,[ebp+8] movss xmm0,dword ptr [ebp+12] movss dword ptr [eax],xmm0 mov eax,4 add eax,[ebp+8] movss xmm0,dword ptr [ebp+16] movss dword ptr [eax],xmm0 mov eax,8 add eax,[ebp+8] movss xmm0,dword ptr [ebp+20] movss dword ptr [eax],xmm0 mov eax,12 add eax,[ebp+8] movss xmm0,dword ptr [ebp+24] movss dword ptr [eax],xmm0 pop ebp ret _vec4f_assign endp _vec4f_add proc push ebp mov ebp,esp mov eax,[ebp+12] mov ecx,[ebp+16] movss xmm0,dword ptr [eax] addss xmm0,dword ptr [ecx] mov eax,[ebp+8] movss dword ptr [eax],xmm0 mov eax,4 add eax,[ebp+12] mov ecx,4 add ecx,[ebp+16] movss xmm0,dword ptr [eax] addss xmm0,dword ptr [ecx] mov eax,4 add eax,[ebp+8] movss dword ptr [eax],xmm0 mov eax,8 add eax,[ebp+12] mov ecx,8 add ecx,[ebp+16] movss xmm0,dword ptr [eax] addss xmm0,dword ptr [ecx] mov eax,8 add eax,[ebp+8] movss dword ptr [eax],xmm0 mov eax,12 add eax,[ebp+12] mov ecx,12 add ecx,[ebp+16] movss xmm0,dword ptr [eax] addss xmm0,dword ptr [ecx] mov eax,12 add eax,[ebp+8] movss dword ptr [eax],xmm0 pop ebp ret _vec4f_add endp _vec4f_subtract proc push ebp mov ebp,esp mov eax,[ebp+12] mov ecx,[ebp+16] movss xmm0,dword ptr [eax] subss xmm0,dword ptr [ecx] mov eax,[ebp+8] movss dword ptr [eax],xmm0 mov eax,4 add eax,[ebp+12] mov ecx,4 add ecx,[ebp+16] movss xmm0,dword ptr [eax] subss xmm0,dword ptr [ecx] mov eax,4 add eax,[ebp+8] movss dword ptr [eax],xmm0 mov eax,8 add eax,[ebp+12] mov ecx,8 add ecx,[ebp+16] movss xmm0,dword ptr [eax] subss xmm0,dword ptr [ecx] mov eax,8 add eax,[ebp+8] movss dword ptr [eax],xmm0 mov eax,12 add eax,[ebp+12] mov ecx,12 add ecx,[ebp+16] movss xmm0,dword ptr [eax] subss xmm0,dword ptr [ecx] mov eax,12 add eax,[ebp+8] movss dword ptr [eax],xmm0 pop ebp ret _vec4f_subtract endp _vec4f_dot proc push ebp mov ebp,esp mov eax,4 add eax,[ebp+8] mov ecx,4 add ecx,[ebp+12] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ecx] mov eax,[ebp+8] mov ecx,[ebp+12] movss xmm1,dword ptr [eax] mulss xmm1,dword ptr [ecx] addss xmm1,xmm0 mov eax,8 add eax,[ebp+8] mov ecx,8 add ecx,[ebp+12] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ecx] addss xmm1,xmm0 mov eax,12 add eax,[ebp+8] mov ecx,12 add ecx,[ebp+12] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ecx] addss xmm1,xmm0 movss xmm0,xmm1 pop ebp ret _vec4f_dot endp _vec4f_mul proc push ebp mov ebp,esp mov eax,[ebp+8] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ebp+12] movss dword ptr [eax],xmm0 mov eax,4 add eax,[ebp+8] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ebp+12] movss dword ptr [eax],xmm0 mov eax,8 add eax,[ebp+8] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ebp+12] movss dword ptr [eax],xmm0 mov eax,12 add eax,[ebp+8] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ebp+12] movss dword ptr [eax],xmm0 pop ebp ret _vec4f_mul endp _matrix4f_make_perspective proc push ebp mov ebp,esp sub esp,8 movss xmm0,dword ptr [ebp+20] mulss xmm0,dword ptr [ebp+12] movss dword ptr [ebp-4],xmm0 movss xmm0,dword ptr [ebp-4] mulss xmm0,dword ptr [ebp+24] movss dword ptr [ebp-8],xmm0 mov eax,[ebp+8] movss xmm0,dword ptr [ebp+12] divss xmm0,dword ptr [ebp-8] movss dword ptr [eax],xmm0 mov eax,4 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,8 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,12 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,16 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,20 add eax,[ebp+8] movss xmm0,dword ptr [ebp+12] divss xmm0,dword ptr [ebp-4] movss dword ptr [eax],xmm0 mov eax,24 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,28 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,32 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,36 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,40 add eax,[ebp+8] movss xmm0,dword ptr [ebp+16] subss xmm0,dword ptr [ebp+12] movss xmm1,dword ptr [ebp+16] divss xmm1,xmm0 movss dword ptr [eax],xmm1 mov eax,44 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [eax],xmm0 mov eax,48 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,52 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,56 add eax,[ebp+8] movss xmm0,dword ptr [ebp+12] mulss xmm0,dword ptr [ebp+16] movss xmm1,dword ptr [ebp+12] subss xmm1,dword ptr [ebp+16] divss xmm0,xmm1 movss dword ptr [eax],xmm0 mov eax,60 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 add esp,8 pop ebp ret _matrix4f_make_perspective endp _matrix4f_make_viewport proc push ebp mov ebp,esp mov eax,[ebp+8] movss xmm0,dword ptr [ebp+12] mulss xmm0,dword ptr [___unnamed_float_3] movss dword ptr [eax],xmm0 mov eax,4 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,8 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,12 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,16 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,20 add eax,[ebp+8] movss xmm0,dword ptr [ebp+16] xorps xmm0,dword ptr [___unnamed_float4_4] mulss xmm0,dword ptr [___unnamed_float_3] movss dword ptr [eax],xmm0 mov eax,24 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,28 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,32 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,36 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,40 add eax,[ebp+8] movss xmm0,dword ptr [ebp+24] subss xmm0,dword ptr [ebp+20] movss dword ptr [eax],xmm0 mov eax,44 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [eax],xmm0 mov eax,48 add eax,[ebp+8] movss xmm0,dword ptr [ebp+12] mulss xmm0,dword ptr [___unnamed_float_3] movss dword ptr [eax],xmm0 mov eax,52 add eax,[ebp+8] movss xmm0,dword ptr [ebp+16] mulss xmm0,dword ptr [___unnamed_float_3] movss dword ptr [eax],xmm0 mov eax,56 add eax,[ebp+8] movss xmm0,dword ptr [ebp+20] movss dword ptr [eax],xmm0 mov eax,60 add eax,[ebp+8] movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [eax],xmm0 pop ebp ret _matrix4f_make_viewport endp _matrix4f_transform proc push ebp mov ebp,esp mov eax,4 add eax,[ebp+12] mov ecx,16 add ecx,[ebp+16] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ecx] mov eax,[ebp+12] mov ecx,[ebp+16] movss xmm1,dword ptr [eax] mulss xmm1,dword ptr [ecx] addss xmm1,xmm0 mov eax,8 add eax,[ebp+12] mov ecx,32 add ecx,[ebp+16] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ecx] addss xmm1,xmm0 mov eax,12 add eax,[ebp+12] mov ecx,48 add ecx,[ebp+16] movss xmm0,dword ptr [eax] mulss xmm0,dword ptr [ecx] addss xmm1,xmm0 mov eax,[ebp+8] movss dword ptr [eax],xmm1 mov eax,4 add eax,[ebp+16] mov ecx,[ebp+12] movss xmm0,dword ptr [ecx] mulss xmm0,dword ptr [eax] mov eax,4 add eax,[ebp+12] mov ecx,20 add ecx,[ebp+16] movss xmm1,dword ptr [eax] mulss xmm1,dword ptr [ecx] addss xmm0,xmm1 mov eax,8 add eax,[ebp+12] mov ecx,36 add ecx,[ebp+16] movss xmm1,dword ptr [eax] mulss xmm1,dword ptr [ecx] addss xmm0,xmm1 mov eax,12 add eax,[ebp+12] mov ecx,52 add ecx,[ebp+16] movss xmm1,dword ptr [eax] mulss xmm1,dword ptr [ecx] addss xmm0,xmm1 mov eax,4 add eax,[ebp+8] movss dword ptr [eax],xmm0 mov eax,8 add eax,[ebp+16] mov ecx,[ebp+12] movss xmm0,dword ptr [ecx] mulss xmm0,dword ptr [eax] mov eax,4 add eax,[ebp+12] mov ecx,24 add ecx,[ebp+16] movss xmm1,dword ptr [eax] mulss xmm1,dword ptr [ecx] addss xmm0,xmm1 mov eax,8 add eax,[ebp+12] mov ecx,40 add ecx,[ebp+16] movss xmm1,dword ptr [eax] mulss xmm1,dword ptr [ecx] addss xmm0,xmm1 mov eax,12 add eax,[ebp+12] mov ecx,56 add ecx,[ebp+16] movss xmm1,dword ptr [eax] mulss xmm1,dword ptr [ecx] addss xmm0,xmm1 mov eax,8 add eax,[ebp+8] movss dword ptr [eax],xmm0 mov eax,12 add eax,[ebp+16] mov ecx,[ebp+12] movss xmm0,dword ptr [ecx] mulss xmm0,dword ptr [eax] mov eax,4 add eax,[ebp+12] mov ecx,28 add ecx,[ebp+16] movss xmm1,dword ptr [eax] mulss xmm1,dword ptr [ecx] addss xmm0,xmm1 mov eax,8 add eax,[ebp+12] mov ecx,44 add ecx,[ebp+16] movss xmm1,dword ptr [eax] mulss xmm1,dword ptr [ecx] addss xmm0,xmm1 mov eax,12 add eax,[ebp+12] mov ecx,60 add ecx,[ebp+16] movss xmm1,dword ptr [eax] mulss xmm1,dword ptr [ecx] addss xmm0,xmm1 mov eax,12 add eax,[ebp+8] movss dword ptr [eax],xmm0 pop ebp ret _matrix4f_transform endp _rasterizer_init proc push ebp mov ebp,esp sub esp,8 mov eax,[ebp+8] mov dword ptr [__dbgprintf],eax mov eax,[ebp+12] mov dword ptr [__width],eax mov eax,[ebp+16] mov dword ptr [__height],eax mov eax,[ebp+20] mov dword ptr [__pitch],eax cvtsi2ss xmm0,dword ptr [ebp+12] cvtsi2ss xmm1,dword ptr [ebp+16] divss xmm0,xmm1 movss dword ptr [esp-4],xmm0 sub esp,4 push dword ptr [ebp+32] push dword ptr [ebp+28] push dword ptr [ebp+24] lea eax,dword ptr [__mvproj_matrix] push eax call _matrix4f_make_perspective add esp,20 push dword ptr [ebp+28] push dword ptr [ebp+24] cvtsi2ss xmm0,dword ptr [ebp+16] movss dword ptr [esp-4],xmm0 cvtsi2ss xmm0,dword ptr [ebp+12] movss dword ptr [esp-8],xmm0 sub esp,8 lea eax,dword ptr [__viewport_matrix] push eax call _matrix4f_make_viewport add esp,20 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 sub esp,4 push dword ptr [ebp+24] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 sub esp,8 lea eax,dword ptr [__clip_z_near_base] push eax call _vec4f_assign add esp,20 movss xmm0,dword ptr [ebp+28] comiss xmm0,dword ptr [ebp+24] jbe label0000 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [ebp-4],xmm0 jmp label0001 label0000: movss xmm0,dword ptr [___unnamed_float_5] movss dword ptr [ebp-4],xmm0 label0001: movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 sub esp,4 push dword ptr [ebp-4] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 sub esp,8 lea eax,dword ptr [__clip_z_near_norm] push eax call _vec4f_assign add esp,20 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 sub esp,4 push dword ptr [ebp+28] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 sub esp,8 lea eax,dword ptr [__clip_z_far_base] push eax call _vec4f_assign add esp,20 movss xmm0,dword ptr [ebp+28] comiss xmm0,dword ptr [ebp+24] jbe label0002 movss xmm0,dword ptr [___unnamed_float_5] movss dword ptr [ebp-8],xmm0 jmp label0003 label0002: movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [ebp-8],xmm0 label0003: movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 sub esp,4 push dword ptr [ebp-8] movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 sub esp,8 lea eax,dword ptr [__clip_z_far_norm] push eax call _vec4f_assign add esp,20 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-12],xmm0 cvtsi2ss xmm0,dword ptr [ebp+12] movss xmm1,dword ptr [___unnamed_float_1] divss xmm1,xmm0 movss xmm0,dword ptr [___unnamed_float_5] addss xmm0,xmm1 movss dword ptr [esp-16],xmm0 sub esp,16 lea eax,dword ptr [__clip_plane_left_base] push eax call _vec4f_assign add esp,20 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-12],xmm0 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-16],xmm0 sub esp,16 lea eax,dword ptr [__clip_plane_left_norm] push eax call _vec4f_assign add esp,20 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-12],xmm0 cvtsi2ss xmm0,dword ptr [ebp+12] movss xmm1,dword ptr [___unnamed_float_1] divss xmm1,xmm0 movss xmm0,dword ptr [___unnamed_float_1] subss xmm0,xmm1 movss dword ptr [esp-16],xmm0 sub esp,16 lea eax,dword ptr [__clip_plane_right_base] push eax call _vec4f_assign add esp,20 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-12],xmm0 movss xmm0,dword ptr [___unnamed_float_5] movss dword ptr [esp-16],xmm0 sub esp,16 lea eax,dword ptr [__clip_plane_right_norm] push eax call _vec4f_assign add esp,20 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 cvtsi2ss xmm0,dword ptr [ebp+16] movss xmm1,dword ptr [___unnamed_float_1] divss xmm1,xmm0 movss xmm0,dword ptr [___unnamed_float_5] addss xmm0,xmm1 movss dword ptr [esp-12],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-16],xmm0 sub esp,16 lea eax,dword ptr [__clip_plane_top_base] push eax call _vec4f_assign add esp,20 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-12],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-16],xmm0 sub esp,16 lea eax,dword ptr [__clip_plane_top_norm] push eax call _vec4f_assign add esp,20 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-12],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-16],xmm0 sub esp,16 lea eax,dword ptr [__clip_plane_bottom_base] push eax call _vec4f_assign add esp,20 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 movss xmm0,dword ptr [___unnamed_float_5] movss dword ptr [esp-12],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-16],xmm0 sub esp,16 lea eax,dword ptr [__clip_plane_bottom_norm] push eax call _vec4f_assign add esp,20 add esp,8 pop ebp ret _rasterizer_init endp _rasterizer_begin_frame proc push ebp mov ebp,esp mov eax,[ebp+8] mov dword ptr [__videomem],eax pop ebp ret _rasterizer_begin_frame endp _rasterizer_set_mvproj proc push ebp mov ebp,esp push edi push esi mov eax,[ebp+8] mov edi,(offset __mvproj_matrix) mov esi,eax mov ecx,16 rep movsd pop esi pop edi pop ebp ret _rasterizer_set_mvproj endp _rasterizer_set_color proc push ebp mov ebp,esp mov eax,[ebp+8] mov dword ptr [__color],eax pop ebp ret _rasterizer_set_color endp _rasterizer_set_texture proc push ebp mov ebp,esp mov eax,[ebp+8] mov dword ptr [__texture_data],eax mov eax,[ebp+12] mov dword ptr [__texture_width],eax mov eax,[ebp+16] mov dword ptr [__texture_height],eax pop ebp ret _rasterizer_set_texture endp __tex2d proc push ebp mov ebp,esp sub esp,8 mov eax,dword ptr [__texture_width] dec eax cvtsi2ss xmm0,eax mulss xmm0,dword ptr [ebp+8] cvttss2si eax,xmm0 mov [ebp-4],eax mov eax,dword ptr [__texture_height] dec eax cvtsi2ss xmm0,eax mulss xmm0,dword ptr [ebp+12] cvttss2si eax,xmm0 mov [ebp-8],eax mov eax,[ebp-8] imul eax,dword ptr [__texture_width] add eax,[ebp-4] sal eax,2 add eax,dword ptr [__texture_data] mov eax,[eax] add esp,8 pop ebp ret __tex2d endp __rasterize_horiz_line proc push ebp mov ebp,esp sub esp,44 mov eax,dword ptr [__pitch] imul eax,[ebp+16] add eax,dword ptr [__videomem] mov ecx,[ebp+8] sal ecx,2 add eax,ecx mov [ebp-4],eax mov eax,[ebp+12] sal eax,2 add eax,[ebp-4] mov ecx,[ebp+8] sal ecx,2 sub eax,ecx mov [ebp-8],eax label0000: push dword ptr [ebp+24] push dword ptr [ebp+20] call __tex2d add esp,8 mov [ebp-12],eax mov eax,[ebp-12] sar eax,24 and eax,255 mov [ebp-40],eax cmp dword ptr [ebp-40],0 je label0003 cvtsi2ss xmm0,dword ptr [ebp-40] mulss xmm0,dword ptr [___unnamed_float_6] movss dword ptr [ebp-44],xmm0 mov eax,[ebp-4] mov eax,[eax] mov [ebp-28],eax mov eax,[ebp-28] and eax,65280 sar eax,8 mov [ebp-32],eax mov eax,[ebp-28] and eax,255 mov [ebp-36],eax mov eax,[ebp-12] and eax,65280 sar eax,8 mov [ebp-20],eax mov eax,[ebp-12] and eax,255 mov [ebp-24],eax cvtsi2ss xmm0,dword ptr [ebp-20] mulss xmm0,dword ptr [ebp-44] cvtsi2ss xmm1,dword ptr [ebp-32] movss xmm2,dword ptr [___unnamed_float_1] subss xmm2,dword ptr [ebp-44] mulss xmm1,xmm2 addss xmm0,xmm1 cvttss2si eax,xmm0 mov [ebp-20],eax cvtsi2ss xmm0,dword ptr [ebp-24] mulss xmm0,dword ptr [ebp-44] cvtsi2ss xmm1,dword ptr [ebp-36] movss xmm2,dword ptr [___unnamed_float_1] subss xmm2,dword ptr [ebp-44] mulss xmm1,xmm2 addss xmm0,xmm1 cvttss2si eax,xmm0 mov [ebp-24],eax mov eax,[ebp-20] sal eax,8 add eax,[ebp-24] mov [ebp-16],eax mov eax,[ebp-4] mov ecx,[ebp-16] mov [eax],ecx label0003: movss xmm0,dword ptr [ebp+20] addss xmm0,dword ptr [ebp+28] movss dword ptr [ebp+20],xmm0 movss xmm0,dword ptr [ebp+24] addss xmm0,dword ptr [ebp+32] movss dword ptr [ebp+24],xmm0 add dword ptr [ebp-4],4 mov eax,[ebp-4] cmp eax,[ebp-8] jl label0000 add esp,44 pop ebp ret __rasterize_horiz_line endp __rasterize_horiz_line__unordered proc push ebp mov ebp,esp mov eax,[ebp+8] cmp eax,[ebp+12] jg label0000 push dword ptr [ebp+40] push dword ptr [ebp+36] push dword ptr [ebp+24] push dword ptr [ebp+20] push dword ptr [ebp+16] push dword ptr [ebp+12] push dword ptr [ebp+8] call __rasterize_horiz_line add esp,28 jmp label0001 label0000: push dword ptr [ebp+40] push dword ptr [ebp+36] push dword ptr [ebp+32] push dword ptr [ebp+28] push dword ptr [ebp+16] push dword ptr [ebp+8] push dword ptr [ebp+12] call __rasterize_horiz_line add esp,28 label0001: pop ebp ret __rasterize_horiz_line__unordered endp __rasterize_triangle_1i proc push ebp mov ebp,esp mov eax,[ebp+8] cmp eax,[ebp+12] jge label0000 mov eax,[ebp+16] cmp eax,[ebp+12] jle label0001 push dword ptr [ebp+40] push dword ptr [ebp+36] mov eax,4 add eax,[ebp+24] push dword ptr [eax] mov eax,[ebp+24] push dword ptr [eax] push dword ptr [ebp+20] push dword ptr [ebp+16] push dword ptr [ebp+8] call __rasterize_horiz_line add esp,28 jmp label0002 label0001: mov eax,[ebp+16] cmp eax,[ebp+8] jge label0003 push dword ptr [ebp+40] push dword ptr [ebp+36] mov eax,4 add eax,[ebp+32] push dword ptr [eax] mov eax,[ebp+32] push dword ptr [eax] push dword ptr [ebp+20] push dword ptr [ebp+12] push dword ptr [ebp+16] call __rasterize_horiz_line add esp,28 jmp label0004 label0003: push dword ptr [ebp+40] push dword ptr [ebp+36] mov eax,4 add eax,[ebp+24] push dword ptr [eax] mov eax,[ebp+24] push dword ptr [eax] push dword ptr [ebp+20] push dword ptr [ebp+12] push dword ptr [ebp+8] call __rasterize_horiz_line add esp,28 label0004: label0002: jmp label0005 label0000: mov eax,[ebp+16] cmp eax,[ebp+12] jge label0006 movss xmm0,dword ptr [ebp+40] xorps xmm0,dword ptr [___unnamed_float4_4] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [ebp+36] xorps xmm0,dword ptr [___unnamed_float4_4] movss dword ptr [esp-8],xmm0 sub esp,8 mov eax,4 add eax,[ebp+32] push dword ptr [eax] mov eax,[ebp+32] push dword ptr [eax] push dword ptr [ebp+20] push dword ptr [ebp+8] push dword ptr [ebp+16] call __rasterize_horiz_line add esp,28 jmp label0007 label0006: mov eax,[ebp+16] cmp eax,[ebp+8] jle label0008 movss xmm0,dword ptr [ebp+40] xorps xmm0,dword ptr [___unnamed_float4_4] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [ebp+36] xorps xmm0,dword ptr [___unnamed_float4_4] movss dword ptr [esp-8],xmm0 sub esp,8 mov eax,4 add eax,[ebp+28] push dword ptr [eax] mov eax,[ebp+28] push dword ptr [eax] push dword ptr [ebp+20] push dword ptr [ebp+16] push dword ptr [ebp+12] call __rasterize_horiz_line add esp,28 jmp label0009 label0008: movss xmm0,dword ptr [ebp+40] xorps xmm0,dword ptr [___unnamed_float4_4] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [ebp+36] xorps xmm0,dword ptr [___unnamed_float4_4] movss dword ptr [esp-8],xmm0 sub esp,8 mov eax,4 add eax,[ebp+28] push dword ptr [eax] mov eax,[ebp+28] push dword ptr [eax] push dword ptr [ebp+20] push dword ptr [ebp+8] push dword ptr [ebp+12] call __rasterize_horiz_line add esp,28 label0009: label0007: label0005: pop ebp ret __rasterize_triangle_1i endp __rasterize_triangle_2i proc push ebp mov ebp,esp sub esp,60 mov eax,[ebp+8] mov ecx,[ebp+12] mov eax,[eax+4] cmp eax,[ecx+4] jle label0000 mov eax,[ebp+8] mov [ebp-4],eax mov eax,[ebp+12] mov [ebp+8],eax mov eax,[ebp-4] mov [ebp+12],eax label0000: mov eax,[ebp+8] mov ecx,[ebp+16] mov eax,[eax+4] cmp eax,[ecx+4] jle label0001 mov eax,[ebp+8] mov [ebp-4],eax mov eax,[ebp+16] mov [ebp+8],eax mov eax,[ebp-4] mov [ebp+16],eax label0001: mov eax,[ebp+12] mov ecx,[ebp+16] mov eax,[eax+4] cmp eax,[ecx+4] jle label0002 mov eax,[ebp+12] mov [ebp-4],eax mov eax,[ebp+16] mov [ebp+12],eax mov eax,[ebp-4] mov [ebp+16],eax label0002: mov eax,[ebp+8] mov ecx,[ebp+16] mov eax,[eax+4] cmp eax,[ecx+4] jne label0003 mov eax,[ebp+8] cmp dword ptr [eax+4],0 jl label0004 mov eax,[ebp+8] mov eax,[eax+4] cmp eax,dword ptr [__height] jge label0004 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-4],xmm0 movss xmm0,dword ptr [___unnamed_float_2] movss dword ptr [esp-8],xmm0 sub esp,8 mov eax,8 add eax,[ebp+16] push eax mov eax,8 add eax,[ebp+12] push eax mov eax,8 add eax,[ebp+8] push eax mov eax,[ebp+8] push dword ptr [eax+4] mov eax,[ebp+16] push dword ptr [eax] mov eax,[ebp+12] push dword ptr [eax] mov eax,[ebp+8] push dword ptr [eax] call __rasterize_triangle_1i add esp,36 label0004: add esp,60 pop ebp ret label0003: mov eax,[ebp+8] mov eax,[eax+4] mov [ebp-16],eax label0006: mov eax,[ebp+12] mov eax,[eax+4] cmp eax,[ebp-16] jle label0007 mov eax,[ebp+8] mov [ebp-44],eax mov eax,[ebp-16] mov ecx,[ebp-44] sub eax,[ecx+4] mov ecx,[ebp+12] mov edx,[ebp+8] mov ecx,[ecx] sub ecx,[edx] imul eax,ecx mov ecx,[ebp+12] mov edx,[ebp+8] mov ecx,[ecx+4] sub ecx,[edx+4] cdq idiv ecx mov ecx,[ebp+8] add eax,[ecx] mov [ebp-8],eax mov eax,[ebp+8] mov [ebp-48],eax mov eax,[ebp-16] mov ecx,[ebp-48] sub eax,[ecx+4] mov ecx,[ebp+16] mov edx,[ebp+8] mov ecx,[ecx] sub ecx,[edx] imul eax,ecx mov ecx,[ebp+16] mov edx,[ebp+8] mov ecx,[ecx+4] sub ecx,[edx+4] cdq idiv ecx mov ecx,[ebp+8] add eax,[ecx] mov [ebp-12],eax mov eax,[ebp+8] mov ecx,[ebp-16] sub ecx,[eax+4] cvtsi2ss xmm0,ecx mov eax,8 add eax,[ebp+12] mov ecx,8 add ecx,[ebp+8] movss xmm1,dword ptr [eax] subss xmm1,dword ptr [ecx] mulss xmm0,xmm1 mov eax,[ebp+12] mov ecx,[ebp+8] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm1,eax divss xmm0,xmm1 mov eax,8 add eax,[ebp+8] addss xmm0,dword ptr [eax] movss dword ptr [ebp-20],xmm0 mov eax,[ebp+8] mov ecx,[ebp-16] sub ecx,[eax+4] cvtsi2ss xmm0,ecx mov eax,8 add eax,[ebp+16] mov ecx,8 add ecx,[ebp+8] movss xmm1,dword ptr [eax] subss xmm1,dword ptr [ecx] mulss xmm0,xmm1 mov eax,[ebp+16] mov ecx,[ebp+8] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm1,eax divss xmm0,xmm1 mov eax,8 add eax,[ebp+8] addss xmm0,dword ptr [eax] movss dword ptr [ebp-28],xmm0 mov eax,[ebp+8] mov ecx,[ebp-16] sub ecx,[eax+4] cvtsi2ss xmm0,ecx mov eax,8 add eax,[ebp+12] mov ecx,8 add ecx,[ebp+8] movss xmm1,dword ptr [eax+4] subss xmm1,dword ptr [ecx+4] mulss xmm0,xmm1 mov eax,[ebp+12] mov ecx,[ebp+8] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm1,eax divss xmm0,xmm1 mov eax,8 add eax,[ebp+8] addss xmm0,dword ptr [eax+4] movss dword ptr [ebp-24],xmm0 mov eax,[ebp+8] mov ecx,[ebp-16] sub ecx,[eax+4] cvtsi2ss xmm0,ecx mov eax,8 add eax,[ebp+16] mov ecx,8 add ecx,[ebp+8] movss xmm1,dword ptr [eax+4] subss xmm1,dword ptr [ecx+4] mulss xmm0,xmm1 mov eax,[ebp+16] mov ecx,[ebp+8] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm1,eax divss xmm0,xmm1 mov eax,8 add eax,[ebp+8] addss xmm0,dword ptr [eax+4] movss dword ptr [ebp-32],xmm0 mov eax,[ebp-12] sub eax,[ebp-8] cvtsi2ss xmm0,eax movss xmm1,dword ptr [ebp-28] subss xmm1,dword ptr [ebp-20] divss xmm1,xmm0 movss dword ptr [ebp-36],xmm1 mov eax,[ebp-12] sub eax,[ebp-8] cvtsi2ss xmm0,eax movss xmm1,dword ptr [ebp-32] subss xmm1,dword ptr [ebp-24] divss xmm1,xmm0 movss dword ptr [ebp-40],xmm1 push dword ptr [ebp-40] push dword ptr [ebp-36] push dword ptr [ebp-32] push dword ptr [ebp-28] push dword ptr [ebp-24] push dword ptr [ebp-20] push dword ptr [ebp-16] push dword ptr [ebp-12] push dword ptr [ebp-8] call __rasterize_horiz_line__unordered add esp,36 inc dword ptr [ebp-16] jmp label0006 label0007: mov eax,[ebp+12] mov ecx,[ebp+8] mov [ebp-52],eax mov edx,[ebp-52] mov eax,[edx+4] sub eax,[ecx+4] mov ecx,[ebp+16] mov edx,[ebp+8] mov ecx,[ecx] sub ecx,[edx] imul eax,ecx mov ecx,[ebp+16] mov edx,[ebp+8] mov ecx,[ecx+4] sub ecx,[edx+4] cdq idiv ecx mov edx,[ebp+8] add eax,[edx] mov [ebp-12],eax mov eax,[ebp+12] mov ecx,[ebp+8] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm0,eax mov eax,8 add eax,[ebp+16] mov ecx,8 add ecx,[ebp+8] movss xmm1,dword ptr [eax] subss xmm1,dword ptr [ecx] mulss xmm0,xmm1 mov eax,[ebp+16] mov ecx,[ebp+8] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm1,eax divss xmm0,xmm1 mov eax,8 add eax,[ebp+8] addss xmm0,dword ptr [eax] movss dword ptr [ebp-28],xmm0 mov eax,[ebp+12] mov ecx,[ebp+8] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm0,eax mov eax,8 add eax,[ebp+16] mov ecx,8 add ecx,[ebp+8] movss xmm1,dword ptr [eax+4] subss xmm1,dword ptr [ecx+4] mulss xmm0,xmm1 mov eax,[ebp+16] mov ecx,[ebp+8] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm1,eax divss xmm0,xmm1 mov eax,8 add eax,[ebp+8] addss xmm0,dword ptr [eax+4] movss dword ptr [ebp-32],xmm0 mov eax,8 add eax,[ebp+12] movss xmm0,dword ptr [ebp-28] subss xmm0,dword ptr [eax] mov eax,[ebp+12] mov ecx,[ebp-12] sub ecx,[eax] cvtsi2ss xmm1,ecx divss xmm0,xmm1 movss dword ptr [ebp-36],xmm0 mov eax,8 add eax,[ebp+12] movss xmm0,dword ptr [ebp-32] subss xmm0,dword ptr [eax+4] mov eax,[ebp+12] mov ecx,[ebp-12] sub ecx,[eax] cvtsi2ss xmm1,ecx divss xmm0,xmm1 movss dword ptr [ebp-40],xmm0 push dword ptr [ebp-40] push dword ptr [ebp-36] mov eax,8 add eax,[ebp+12] push dword ptr [eax+4] mov eax,8 add eax,[ebp+12] push dword ptr [eax] push dword ptr [ebp-32] push dword ptr [ebp-28] mov eax,[ebp+12] push dword ptr [eax+4] mov eax,[ebp+12] push dword ptr [eax] push dword ptr [ebp-12] call __rasterize_horiz_line__unordered add esp,36 mov eax,[ebp+12] mov ecx,1 add ecx,[eax+4] mov [ebp-16],ecx label0009: mov eax,[ebp+16] mov eax,[eax+4] cmp eax,[ebp-16] jle label000a mov eax,[ebp+12] mov [ebp-56],eax mov eax,[ebp-16] mov ecx,[ebp-56] sub eax,[ecx+4] mov ecx,[ebp+16] mov edx,[ebp+12] mov ecx,[ecx] sub ecx,[edx] imul eax,ecx mov ecx,[ebp+16] mov edx,[ebp+12] mov ecx,[ecx+4] sub ecx,[edx+4] cdq idiv ecx mov ecx,[ebp+12] add eax,[ecx] mov [ebp-8],eax mov eax,[ebp+8] mov [ebp-60],eax mov eax,[ebp-16] mov ecx,[ebp-60] sub eax,[ecx+4] mov ecx,[ebp+16] mov edx,[ebp+8] mov ecx,[ecx] sub ecx,[edx] imul eax,ecx mov ecx,[ebp+16] mov edx,[ebp+8] mov ecx,[ecx+4] sub ecx,[edx+4] cdq idiv ecx mov ecx,[ebp+8] add eax,[ecx] mov [ebp-12],eax mov eax,[ebp+12] mov ecx,[ebp-16] sub ecx,[eax+4] cvtsi2ss xmm0,ecx mov eax,8 add eax,[ebp+16] mov ecx,8 add ecx,[ebp+12] movss xmm1,dword ptr [eax] subss xmm1,dword ptr [ecx] mulss xmm0,xmm1 mov eax,[ebp+16] mov ecx,[ebp+12] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm1,eax divss xmm0,xmm1 mov eax,8 add eax,[ebp+12] addss xmm0,dword ptr [eax] movss dword ptr [ebp-20],xmm0 mov eax,[ebp+8] mov ecx,[ebp-16] sub ecx,[eax+4] cvtsi2ss xmm0,ecx mov eax,8 add eax,[ebp+16] mov ecx,8 add ecx,[ebp+8] movss xmm1,dword ptr [eax] subss xmm1,dword ptr [ecx] mulss xmm0,xmm1 mov eax,[ebp+16] mov ecx,[ebp+8] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm1,eax divss xmm0,xmm1 mov eax,8 add eax,[ebp+8] addss xmm0,dword ptr [eax] movss dword ptr [ebp-28],xmm0 mov eax,[ebp+12] mov ecx,[ebp-16] sub ecx,[eax+4] cvtsi2ss xmm0,ecx mov eax,8 add eax,[ebp+16] mov ecx,8 add ecx,[ebp+12] movss xmm1,dword ptr [eax+4] subss xmm1,dword ptr [ecx+4] mulss xmm0,xmm1 mov eax,[ebp+16] mov ecx,[ebp+12] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm1,eax divss xmm0,xmm1 mov eax,8 add eax,[ebp+12] addss xmm0,dword ptr [eax+4] movss dword ptr [ebp-24],xmm0 mov eax,[ebp+8] mov ecx,[ebp-16] sub ecx,[eax+4] cvtsi2ss xmm0,ecx mov eax,8 add eax,[ebp+16] mov ecx,8 add ecx,[ebp+8] movss xmm1,dword ptr [eax+4] subss xmm1,dword ptr [ecx+4] mulss xmm0,xmm1 mov eax,[ebp+16] mov ecx,[ebp+8] mov eax,[eax+4] sub eax,[ecx+4] cvtsi2ss xmm1,eax divss xmm0,xmm1 mov eax,8 add eax,[ebp+8] addss xmm0,dword ptr [eax+4] movss dword ptr [ebp-32],xmm0 mov eax,[ebp-12] sub eax,[ebp-8] cvtsi2ss xmm0,eax movss xmm1,dword ptr [ebp-28] subss xmm1,dword ptr [ebp-20] divss xmm1,xmm0 movss dword ptr [ebp-36],xmm1 mov eax,[ebp-12] sub eax,[ebp-8] cvtsi2ss xmm0,eax movss xmm1,dword ptr [ebp-32] subss xmm1,dword ptr [ebp-24] divss xmm1,xmm0 movss dword ptr [ebp-40],xmm1 push dword ptr [ebp-40] push dword ptr [ebp-36] push dword ptr [ebp-32] push dword ptr [ebp-28] push dword ptr [ebp-24] push dword ptr [ebp-20] push dword ptr [ebp-16] push dword ptr [ebp-12] push dword ptr [ebp-8] call __rasterize_horiz_line__unordered add esp,36 inc dword ptr [ebp-16] jmp label0009 label000a: add esp,60 pop ebp ret __rasterize_triangle_2i endp __clip_on_plain proc push ebp mov ebp,esp sub esp,72 mov eax,192 add eax,[ebp+8] mov dword ptr [eax],0 mov eax,[ebp+12] mov [ebp-4],eax mov eax,[ebp+12] add eax,24 mov [ebp-8],eax label0001: mov eax,192 add eax,[ebp+12] mov eax,[eax] imul eax,24 mov ecx,[ebp+12] add ecx,eax cmp ecx,[ebp-8] jle label0002 push dword ptr [ebp+16] mov eax,[ebp-4] push eax lea eax,[ebp-24] push eax call _vec4f_subtract add esp,12 push dword ptr [ebp+20] lea eax,[ebp-24] push eax call _vec4f_dot add esp,8 movss dword ptr [ebp-52],xmm0 push dword ptr [ebp+16] mov eax,[ebp-8] push eax lea eax,[ebp-24] push eax call _vec4f_subtract add esp,12 push dword ptr [ebp+20] lea eax,[ebp-24] push eax call _vec4f_dot add esp,8 movss dword ptr [ebp-56],xmm0 movss xmm0,dword ptr [___unnamed_float_2] comiss xmm0,dword ptr [ebp-52] ja label0003 mov eax,192 add eax,[ebp+8] mov ecx,[eax] inc dword ptr [eax] imul ecx,24 mov eax,[ebp+8] mov edx,[ebp-4] movq xmm0,qword ptr [edx] movq qword ptr [eax+ecx],xmm0 movq xmm0,qword ptr [edx+8] movq qword ptr [eax+ecx+8],xmm0 movq xmm0,qword ptr [edx+16] movq qword ptr [eax+ecx+16],xmm0 movss dword ptr [ebp-64],xmm0 label0003: movss xmm0,dword ptr [___unnamed_float_2] comiss xmm0,dword ptr [ebp-52] jae label0006 movss xmm0,dword ptr [___unnamed_float_2] comiss xmm0,dword ptr [ebp-56] ja label0005 label0006: movss xmm0,dword ptr [___unnamed_float_2] comiss xmm0,dword ptr [ebp-56] ja label0004 movss xmm0,dword ptr [___unnamed_float_2] comiss xmm0,dword ptr [ebp-52] jbe label0004 label0005: mov eax,[ebp-4] push eax push dword ptr [ebp+16] lea eax,[ebp-24] push eax call _vec4f_subtract add esp,12 mov eax,[ebp-4] push eax mov eax,[ebp-8] push eax lea eax,[ebp-40] push eax call _vec4f_subtract add esp,12 push dword ptr [ebp+20] lea eax,[ebp-24] push eax call _vec4f_dot add esp,8 movss dword ptr [ebp-68],xmm0 push dword ptr [ebp+20] lea eax,[ebp-40] push eax call _vec4f_dot add esp,8 movss dword ptr [ebp-72],xmm0 movss xmm0,dword ptr [ebp-68] divss xmm0,dword ptr [ebp-72] movss dword ptr [ebp-60],xmm0 push dword ptr [ebp-60] lea eax,[ebp-40] push eax call _vec4f_mul add esp,8 lea eax,[ebp-40] push eax mov eax,[ebp-4] push eax mov eax,192 add eax,[ebp+8] mov eax,[eax] imul eax,24 mov ecx,[ebp+8] add ecx,eax push ecx call _vec4f_add add esp,12 mov eax,16 add eax,[ebp-4] push eax mov eax,16 add eax,[ebp-8] push eax lea eax,[ebp-48] push eax call _vec2f_subtract add esp,12 push dword ptr [ebp-60] lea eax,[ebp-48] push eax call _vec2f_mul add esp,8 lea eax,[ebp-48] push eax mov eax,16 add eax,[ebp-4] push eax mov eax,192 add eax,[ebp+8] mov eax,[eax] imul eax,24 mov ecx,[ebp+8] add ecx,eax add ecx,16 push ecx call _vec2f_add add esp,12 mov eax,192 add eax,[ebp+8] inc dword ptr [eax] label0004: add dword ptr [ebp-4],24 add dword ptr [ebp-8],24 jmp label0001 label0002: mov eax,192 add eax,[ebp+8] mov ecx,[eax] inc dword ptr [eax] imul ecx,24 mov eax,[ebp+8] mov edx,[ebp+8] movq xmm0,qword ptr [edx] movq qword ptr [eax+ecx],xmm0 movq xmm0,qword ptr [edx+8] movq qword ptr [eax+ecx+8],xmm0 movq xmm0,qword ptr [edx+16] movq qword ptr [eax+ecx+16],xmm0 add esp,72 pop ebp ret __clip_on_plain endp __clip_poligon proc push ebp mov ebp,esp sub esp,196 lea eax,dword ptr [__clip_z_far_norm] push eax lea eax,dword ptr [__clip_z_far_base] push eax push dword ptr [ebp+8] lea eax,[ebp-196] push eax call __clip_on_plain add esp,16 lea eax,dword ptr [__clip_z_near_norm] push eax lea eax,dword ptr [__clip_z_near_base] push eax lea eax,[ebp-196] push eax push dword ptr [ebp+8] call __clip_on_plain add esp,16 lea eax,dword ptr [__clip_plane_left_norm] push eax lea eax,dword ptr [__clip_plane_left_base] push eax push dword ptr [ebp+8] lea eax,[ebp-196] push eax call __clip_on_plain add esp,16 lea eax,dword ptr [__clip_plane_right_norm] push eax lea eax,dword ptr [__clip_plane_right_base] push eax lea eax,[ebp-196] push eax push dword ptr [ebp+8] call __clip_on_plain add esp,16 lea eax,dword ptr [__clip_plane_top_norm] push eax lea eax,dword ptr [__clip_plane_top_base] push eax push dword ptr [ebp+8] lea eax,[ebp-196] push eax call __clip_on_plain add esp,16 lea eax,dword ptr [__clip_plane_bottom_norm] push eax lea eax,dword ptr [__clip_plane_bottom_base] push eax lea eax,[ebp-196] push eax push dword ptr [ebp+8] call __clip_on_plain add esp,16 mov eax,192 add eax,[ebp+8] cmp dword ptr [eax],1 setg al movzx eax,al add esp,196 pop ebp ret __clip_poligon endp __transform_to_screen_space proc push ebp mov ebp,esp sub esp,20 lea eax,dword ptr [__viewport_matrix] push eax push dword ptr [ebp+12] lea eax,[ebp-16] push eax call _matrix4f_transform add esp,12 movss xmm0,dword ptr [___unnamed_float_1] divss xmm0,dword ptr [ebp-4] movss dword ptr [ebp-20],xmm0 movss xmm0,dword ptr [ebp-16] mulss xmm0,dword ptr [ebp-20] cvttss2si eax,xmm0 mov ecx,[ebp+8] mov [ecx],eax movss xmm0,dword ptr [ebp-12] mulss xmm0,dword ptr [ebp-20] cvttss2si eax,xmm0 mov ecx,4 add ecx,[ebp+8] mov [ecx],eax mov eax,[ebp+8] cmp dword ptr [eax],0 jl label0001 mov eax,[ebp+8] mov eax,[eax] cmp eax,dword ptr [__width] jge label0001 mov eax,4 add eax,[ebp+8] cmp dword ptr [eax],0 jl label0001 mov eax,4 add eax,[ebp+8] mov eax,[eax] cmp eax,dword ptr [__height] jl label0000 label0001: mov dword ptr ds:[0],0 label0000: add esp,20 pop ebp ret __transform_to_screen_space endp __rasterize_polygon_4f proc push ebp mov ebp,esp sub esp,140 push ebx push dword ptr [ebp+8] call __clip_poligon add esp,4 cmp eax,0 jne label0000 pop ebx add esp,140 pop ebp ret label0000: mov eax,192 add eax,[ebp+8] cmp dword ptr [eax],8 jle label0001 mov dword ptr ds:[0],0 label0001: mov dword ptr [ebp-136],0 label0003: mov eax,192 add eax,[ebp+8] mov eax,[eax] cmp eax,[ebp-136] jle label0004 mov eax,[ebp+8] mov ecx,[ebp-136] imul ecx,24 add eax,ecx push eax lea eax,[ebp-132] mov ecx,[ebp-136] sal ecx,4 add eax,ecx push eax call __transform_to_screen_space add esp,8 lea eax,[ebp-132] mov ecx,[ebp-136] sal ecx,4 mov edx,[ebp+8] mov ebx,[ebp-136] imul ebx,24 movq xmm0,qword ptr [edx+ebx+16] movq qword ptr [eax+ecx+8],xmm0 inc dword ptr [ebp-136] movss dword ptr [ebp-140],xmm0 jmp label0003 label0004: mov dword ptr [ebp-136],2 label0006: mov eax,192 add eax,[ebp+8] mov eax,[eax] dec eax cmp eax,[ebp-136] jle label0007 lea eax,[ebp-132] mov ecx,[ebp-136] sal ecx,4 add eax,ecx push eax mov eax,[ebp-136] dec eax sal eax,4 lea ecx,[ebp-132] add ecx,eax push ecx lea eax,[ebp-132] push eax call __rasterize_triangle_2i add esp,12 inc dword ptr [ebp-136] jmp label0006 label0007: pop ebx add esp,140 pop ebp ret __rasterize_polygon_4f endp __transform_to_projection_space proc push ebp mov ebp,esp sub esp,16 movss xmm0,dword ptr [___unnamed_float_1] movss dword ptr [esp-4],xmm0 sub esp,4 mov eax,8 add eax,[ebp+12] push dword ptr [eax] mov eax,4 add eax,[ebp+12] push dword ptr [eax] mov eax,[ebp+12] push dword ptr [eax] lea eax,[ebp-16] push eax call _vec4f_assign add esp,20 lea eax,dword ptr [__mvproj_matrix] push eax lea eax,[ebp-16] push eax push dword ptr [ebp+8] call _matrix4f_transform add esp,12 add esp,16 pop ebp ret __transform_to_projection_space endp _rasterizer_triangle3f proc push ebp mov ebp,esp sub esp,196 push dword ptr [ebp+8] lea eax,[ebp-196] push eax call __transform_to_projection_space add esp,8 mov eax,[ebp+20] movq xmm0,qword ptr [eax] movq qword ptr [ebp-180],xmm0 push dword ptr [ebp+12] lea eax,[ebp-196] add eax,24 push eax call __transform_to_projection_space add esp,8 mov eax,[ebp+24] movq xmm0,qword ptr [eax] movq qword ptr [ebp-156],xmm0 push dword ptr [ebp+16] lea eax,[ebp-196] add eax,48 push eax call __transform_to_projection_space add esp,8 mov eax,[ebp+28] movq xmm0,qword ptr [eax] movq qword ptr [ebp-132],xmm0 movq xmm0,qword ptr [ebp-196] movq qword ptr [ebp-124],xmm0 movq xmm0,qword ptr [ebp-188] movq qword ptr [ebp-116],xmm0 movq xmm0,qword ptr [ebp-180] movq qword ptr [ebp-108],xmm0 mov dword ptr [ebp-4],4 lea eax,[ebp-196] push eax call __rasterize_polygon_4f add esp,4 add esp,196 pop ebp ret _rasterizer_triangle3f endp end
test/antidbg/windows/x86/antidbg.asm
jeppeter/py-obcode
0
24192
.686p .model flat,C .code get_peb_ptr PROC ;mov eax, dword ptr fs:[030h] db 064h,0a1h,030h,00h,00h,00h ret get_peb_ptr ENDP set_single_step PROC pushfd or byte ptr[esp+1],1 popfd ret set_single_step ENDP set_int3 PROC int 3 ret set_int3 ENDP prefix_hop_int3 PROC db 0f3h,064h,0cch ret prefix_hop_int3 ENDP kernel_break PROC int 02dh ret kernel_break ENDP End
gfx/pokemon/ninjask/anim_idle.asm
Ebernacher90/pokecrystal-allworld
0
15726
frame 1, 08 endanim
cards/bn5/ItemCards/136-F003 Sal's Lunch Freebies.asm
RockmanEXEZone/MMBN-Mod-Card-Kit
10
244720
.include "defaults_item.asm" table_file_jp equ "exe5-utf8.tbl" table_file_en equ "bn5-utf8.tbl" game_code_len equ 3 game_code equ 0x4252424A // BRBJ game_code_2 equ 0x42524245 // BRBE game_code_3 equ 0x42524250 // BRBP card_type equ 0 card_id equ 23 card_no equ "023" card_sub equ "Item Card 023" card_sub_x equ 62 card_desc_len equ 1 card_desc_1 equ "Sal's Lunch Freebies" card_desc_2 equ "" card_desc_3 equ "" card_name_jp_full equ "サロマさんのお弁当のおまけ" card_name_jp_game equ "サロマさんのおべんとうのおまけ" card_name_en_full equ "Sal's Lunch Freebies" card_name_en_game equ "Sal's Lunch Freebies" card_game_desc_jp_len equ 3 card_game_desc_jp_1 equ "サロマさんのおべんとうのおまけ!" card_game_desc_jp_2 equ "ブーメランA、バンブーランス*、" card_game_desc_jp_3 equ "マヨイノモリ*を手に入れた!" card_game_desc_en_len equ 3 card_game_desc_en_1 equ "Sal's lunch freebies!" card_game_desc_en_2 equ "Got Boomer A,Lance *" card_game_desc_en_3 equ "and AntiWood *!"
Streams/PredFilter.agda
hbasold/Sandbox
0
4398
<gh_stars>0 -- | In this module we show that the substream relation is transitive. open import Size open import Streams open import Relation.Binary.PropositionalEquality as P open import Data.Product open import Function tl' : ∀{A} → Stream A → Stream A tl' s = tl s {∞} {- data Reachable {A : Set} (P : A → Set) : Stream A → Set where nowR : (s : Stream A) → P (hd s) → Reachable P s laterR : (s : Stream A) → Reachable P (tl s) → Reachable P (tl s) -} {- data Eventually {A : Set} (P : A → Set) (s : Stream A) : Set where now : P (hd s) → Eventually P s later : Eventually P (tl s) → Eventually P s -} record Always {A : Set} (P : A → Set) (s : Stream A) : Set where coinductive field hd-valid : P (hd s) tl-valid : Always P (tl s) open Always public Always-coiter : ∀{A} {P : A → Set} {B : Stream A → Set} (hv : ∀ s → B s → P (hd s)) (tv : ∀ s → B s → B (tl s)) → ∀ s → B s → Always P s hd-valid (Always-coiter hv tv s b) = hv s b tl-valid (Always-coiter hv tv s b) = Always-coiter hv tv (tl s) (tv s b) data E {A : Set} (P : A → Set) (F : Stream A → Set) (s : Stream A) : Set where now : P (hd s) → F (tl s) → E P F s later : E P F (tl s) → E P F s record Fair {A : Set} (P : A → Set) (s : Stream A) : Set where coinductive field step : E P (Fair P) s open Fair public Eventually : ∀{A} → (P : A → Set) → Stream A → Set Eventually P = E P (Fair P) Fair-coiter : ∀{A} {P : A → Set} {B : Stream A → Set} (st : ∀ s → B s → E P B s) → ∀ s → B s → Fair P s xFair-coiter : ∀{A} {P : A → Set} {B : Stream A → Set} (st : ∀ s → B s → E P B s) → ∀ s → E P B s → Eventually P s step (Fair-coiter st s b) = xFair-coiter st s (st s b) xFair-coiter st s (now p b) = now p (Fair-coiter st (tl s) b) xFair-coiter st s (later e) = later (xFair-coiter st (tl s) e) Stream-coiter : ∀{A B : Set} → (B → A) → (B → B) → B → Stream A hd (Stream-coiter h t b) = h b tl (Stream-coiter h t b) = Stream-coiter h t (t b) ∃-elim : ∀{A : Set} {B : A → Set} {C : Set} → ((a : A) → B a → C) → Σ A B → C ∃-elim f (a , b) = f a b ≡-elim : ∀{A : Set} {B : A → A → Set} → ((x : A) → B x x) → {x y : A} → x ≡ y → B x y ≡-elim f {x = x} refl = f x Always-coind : ∀{A} {P : A → Set} {B : Set} -- {C : Stream A → Set} {h : B → A} {t : B → B} (hv : ∀ b → P (h b)) → ∀ b → Always P (Stream-coiter h t b) Always-coind {A} {P = P} {B} {h} {t} hv b = Always-coiter {B = λ s → ∃ λ b → s ≡ Stream-coiter h t b} f g (Stream-coiter h t b) (b , refl) where f : (s : Stream A) → ∃ (λ b → s ≡ Stream-coiter h t b) → P (hd s) f s = ∃-elim u where u : (b : B) → s ≡ Stream-coiter h t b → P (hd s) u b p = subst P (sym (cong hd p)) (hv b) g : (s : Stream A) → ∃ (λ b → s ≡ Stream-coiter h t b) → ∃ (λ b → tl s ≡ Stream-coiter h t b) g s = ∃-elim u where u : (b : B) → s ≡ Stream-coiter h t b → ∃ (λ b₁ → tl s ≡ Stream-coiter h t b₁) u b p = (t b , cong tl' p) {- hd-valid (Always-coind h t hv b) = hv b tl-valid (Always-coind h t hv b) = Always-coind h t hv (t b) -} dcoiter-Fair : ∀{A} {P : A → Set} {B : Set} {C : Stream A → Set} {h : B → A} {t : B → B} (st : ∀ b → C (Stream-coiter h t b) → E P C (Stream-coiter h t b)) → ∀ b → C (Stream-coiter h t b) → Fair P (Stream-coiter h t b) xdcoiter-Fair : ∀{A} {P : A → Set} {B : Set} {C : Stream A → Set} {h : B → A} {t : B → B} (st : ∀ b → C (Stream-coiter h t b) → E P C (Stream-coiter h t b)) → ∀ b → E P C (Stream-coiter h t b) → Eventually P (Stream-coiter h t b) step (dcoiter-Fair st b c) = xdcoiter-Fair st b (st b c) xdcoiter-Fair st b (now p c) = now p (dcoiter-Fair st _ c) xdcoiter-Fair st b (later e) = later (xdcoiter-Fair st _ e) E-iter : ∀{A} {P : A → Set} {F : Stream A → Set} {B : Stream A → Set} (n : ∀ s → P (hd s) → F (tl s) → B s) (l : ∀ s → B (tl s) → B s) → ∀ s → E P F s → B s E-iter n l s (now p f) = n s p f E-iter n l s (later e) = l s (E-iter n l (tl s) e) {- Ev-iter : ∀{A} {P : A → Set} {F : Stream A → Set} {B : Stream A → Set} (st : ∀ s → Fair P s → F s) (n : ∀ s → F (tl s) → B s) (l : ∀ s → B (tl s) → B s) → ∀ s → Eventually P s → B s Ev-iter st n l s (now p f) = n s (st (tl s) f) Ev-iter st n l s (later e) = l s (Ev-iter st n l (tl s) e) -} {- Ev-iter : ∀{A} {P : A → Set} {B : Stream A → Set} (n : ∀ s → Fair P (tl s) → B s) (l : ∀ s → B (tl s) → B s) → ∀ s → Eventually P s → B s Ev-iter n l s (now p f) = n s f Ev-iter n l s (later e) = l s (Ev-iter n l (tl s) e) -} {- Ev-ind : ∀{A} {P : A → Set} (F : (t : Stream A) → Set) (B : (t : Stream A) → Eventually P t → Set) (st : ∀{t} → Fair P t → F t) (n : ∀{t} → (p : P (hd t)) → (f : F (tl t)) → B t (now p f)) → (l : ∀{t e} → B (tl t) e → B t (later e)) → (s : Stream A) → (e : Eventually P s) → B s e Ev-ind F B st n l s (now p f) = let r = n p {!st!} in {!!} Ev-ind F B st n l s (later e) = l (Ev-ind F B st n l (tl s) e) -} filter : ∀{A} {P : A → Set} (s : Stream A) → Fair P s → Stream A xfilter : ∀{A} {P : A → Set} (s : Stream A) → Eventually P s → Stream A filter s p = xfilter s (step p) hd (xfilter s (now p q)) = hd s tl (xfilter s (now p q)) = filter (tl s) q xfilter s (later p) = xfilter (tl s) p filter-find : ∀{A} {P : A → Set} (s : Stream A) → Eventually P s → A × ∃ (Fair P) filter-find = E-iter (λ s p f → (hd s , tl s , f)) (λ s → id) filter-h : ∀{A} {P : A → Set} → ∃ (Fair P) → A filter-h (s , f) = proj₁ (filter-find s (step f)) filter-t : ∀{A} {P : A → Set} → ∃ (Fair P) → ∃ (Fair P) filter-t {A} {P} (s , f) = proj₂ (filter-find s (step f)) filter' : ∀{A} {P : A → Set} → ∃ (Fair P) → Stream A filter' = Stream-coiter filter-h filter-t -- filter' : ∀{A} {P : A → Set} (s : Stream A) → Fair P s → Stream A -- filter' s f = filter'' (s , f) {- filter-pres-fair : ∀{A} {P : A → Set} (u : ∃ (Fair P)) → Fair P (filter' u) filter-pres-fair u = {!!} filter-always' : ∀{A} {P : A → Set} (u : ∃ (Fair P)) → Always P (filter' u) filter-always' {A} {P} (s , f) = Always-coiter {B = Fair P} {!!} {!!} (filter' (s , f)) {!!} -} filter-always' : ∀{A} {P : A → Set} (u : ∃ (Fair P)) → Always P (filter' u) filter-always' {A} {P} = Always-coind f where xf : (s : Stream A) (e : Eventually P s) → P (proj₁ (filter-find s e)) xf s (now p _) = p xf s (later e) = xf (tl s) e f : (u : ∃ (Fair P)) → P (filter-h u) f (s , f) = xf s (step f) filter-always : ∀{A} {P : A → Set} (s : Stream A) → (f : Fair P s) → Always P (filter s f) xfilter-always : ∀{A} {P : A → Set} (s : Stream A) → (e : Eventually P s) → Always P (xfilter s e) filter-always s f = xfilter-always s (step f) hd-valid (xfilter-always s (now p f)) = p tl-valid (xfilter-always s (now p f)) = filter-always (tl s) f xfilter-always s (later e) = xfilter-always (tl s) e {- filter-pres : ∀{A} {P Q : A → Set} (s : Stream A) → (f : Fair P s) → Always Q s → Always Q (filter s f) xfilter-pres : ∀{A} {P Q : A → Set} (s : Stream A) → (e : Eventually P s) → Always Q s → Always Q (xfilter s e) filter-pres s f a = xfilter-pres s (step f) a xfilter-pres = {!!} -} -- xfilter-pres {Q = Q} s e a = -- Ev-ind (λ t e → Always Q (xfilter t e)) -- (λ p f → record { hd-valid = {!hd-valid a!} ; tl-valid = {!!} }) -- {!!} -- s -- e {- hd-valid (xfilter-pres s (now p f) a) = hd-valid a tl-valid (xfilter-pres s (now p f) a) = filter-pres (tl s) f (tl-valid a) xfilter-pres s (later e) a = xfilter-pres (tl s) e (tl-valid a) -}
Demo/MSP430X_MSP430F5438_CCS/Demo_Source/RegTest.asm
ufo2011/CMSIS-FreeRTOS
1
90495
; ;/* ; * FreeRTOS V202111.00 ; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in ; * the Software without restriction, including without limitation the rights to ; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of ; * the Software, and to permit persons to whom the Software is furnished to do so, ; * subject to the following conditions: ; * ; * The above copyright notice and this permission notice shall be included in all ; * copies or substantial portions of the Software. ; * ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ; * ; * http://www.FreeRTOS.org ; * http://aws.amazon.com/freertos ; * ; * 1 tab == 4 spaces! ; */ ; * The definition of the "register test" tasks, as described at the top of ; * main.c .include data_model.h .if $DEFINED( __LARGE_DATA_MODEL__ ) .define "cmp.a", cmp_x .define "incx.w", inc_x .else .define "cmp.w", cmp_x .define "inc.w", inc_x .endif .global usRegTest1Counter .global usRegTest2Counter .global vPortYield .def vRegTest1Task .def vRegTest2Task .text .align 2 vRegTest1Task: .asmfunc ; Fill each general purpose register with a known value. mov_x #0x4444, r4 mov_x #0x5555, r5 mov_x #0x6666, r6 mov_x #0x7777, r7 mov_x #0x8888, r8 mov_x #0x9999, r9 mov_x #0xaaaa, r10 mov_x #0xbbbb, r11 mov_x #0xcccc, r12 mov_x #0xdddd, r13 mov_x #0xeeee, r14 mov_x #0xffff, r15 prvRegTest1Loop: ; Test each general purpose register to check that it still contains the ; expected known value, jumping to vRegTest1Error if any register contains ; an unexpected value. cmp_x #0x4444, r4 jne vRegTest1Error cmp_x #0x5555, r5 jne vRegTest1Error cmp_x #0x6666, r6 jne vRegTest1Error cmp_x #0x7777, r7 jne vRegTest1Error cmp_x #0x8888, r8 jne vRegTest1Error cmp_x #0x9999, r9 jne vRegTest1Error cmp_x #0xaaaa, r10 jne vRegTest1Error cmp_x #0xbbbb, r11 jne vRegTest1Error cmp_x #0xcccc, r12 jne vRegTest1Error cmp_x #0xdddd, r13 jne vRegTest1Error cmp_x #0xeeee, r14 jne vRegTest1Error cmp_x #0xffff, r15 jne vRegTest1Error ; This task is still running without jumping to vRegTest1Error, so increment ; the loop counter so the check task knows the task is running error free. inc_x &usRegTest1Counter ; Loop again, performing the same tests. jmp prvRegTest1Loop nop vRegTest1Error: jmp vRegTest1Error nop .endasmfunc ; ----------------------------------------------------------- ; See the comments in vRegTest1Task. This task is the same, it just uses ; different values in its registers. .align 2 vRegTest2Task: .asmfunc mov_x #0x4441, r4 mov_x #0x5551, r5 mov_x #0x6661, r6 mov_x #0x7771, r7 mov_x #0x8881, r8 mov_x #0x9991, r9 mov_x #0xaaa1, r10 mov_x #0xbbb1, r11 mov_x #0xccc1, r12 mov_x #0xddd1, r13 mov_x #0xeee1, r14 mov_x #0xfff1, r15 prvRegTest2Loop: cmp_x #0x4441, r4 jne vRegTest2Error cmp_x #0x5551, r5 jne vRegTest2Error cmp_x #0x6661, r6 jne vRegTest2Error cmp_x #0x7771, r7 jne vRegTest2Error cmp_x #0x8881, r8 jne vRegTest2Error cmp_x #0x9991, r9 jne vRegTest2Error cmp_x #0xaaa1, r10 jne vRegTest2Error cmp_x #0xbbb1, r11 jne vRegTest2Error cmp_x #0xccc1, r12 jne vRegTest2Error cmp_x #0xddd1, r13 jne vRegTest2Error cmp_x #0xeee1, r14 jne vRegTest2Error cmp_x #0xfff1, r15 jne vRegTest2Error ; Also perform a manual yield, just to increase the scope of the test. call_x #vPortYield inc_x &usRegTest2Counter jmp prvRegTest2Loop nop vRegTest2Error: jmp vRegTest2Error nop .endasmfunc ; /*----------------------------------------------------------- .end
include/bits_types_u_sigset_t_h.ads
docandrew/troodon
5
12742
<reponame>docandrew/troodon pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package bits_types_u_sigset_t_h is -- skipped anonymous struct anon_1 type uu_sigset_t_array937 is array (0 .. 15) of aliased unsigned_long; type uu_sigset_t is record uu_val : aliased uu_sigset_t_array937; -- /usr/include/bits/types/__sigset_t.h:7 end record with Convention => C_Pass_By_Copy; -- /usr/include/bits/types/__sigset_t.h:8 end bits_types_u_sigset_t_h;
src/tools/Dependency_Graph_Extractor/src/extraction-decls.adb
selroc/Renaissance-Ada
1
217
<filename>src/tools/Dependency_Graph_Extractor/src/extraction-decls.adb with Extraction.Node_Edge_Types; with Extraction.Utilities; package body Extraction.Decls is use type LALCO.Ada_Node_Kind_Type; function Is_Standard_Package_Decl(Node : LAL.Ada_Node'Class) return Boolean is Standard_Unit : constant LAL.Compilation_Unit := Node.P_Standard_Unit.Root.As_Compilation_Unit; Standard_Pkg_Decl : constant LAL.Basic_Decl := Standard_Unit.F_Body.As_Library_Item.F_Item; begin return Node.Kind = LALCO.Ada_Package_Decl and then Node = Standard_Pkg_Decl; end Is_Standard_Package_Decl; procedure Extract_Nodes (Node : LAL.Ada_Node'Class; Graph : Graph_Operations.Graph_Context) is begin if Utilities.Is_Relevant_Basic_Decl(Node) then declare Basic_Decl : constant LAL.Basic_Decl := Node.As_Basic_Decl; begin for Defining_Name of Basic_Decl.P_Defining_Names loop Graph.Write_Node(Defining_Name, Basic_Decl); end loop; end; end if; end Extract_Nodes; procedure Extract_Edges (Node : LAL.Ada_Node'Class; Graph : Graph_Operations.Graph_Context) is begin if Utilities.Is_Relevant_Basic_Decl(Node) and then not Is_Standard_Package_Decl(Node) then declare Basic_Decl : constant LAL.Basic_Decl := Node.As_Basic_Decl; Parent : constant LAL.Basic_Decl := Utilities.Get_Parent_Basic_Decl(Basic_Decl); begin for Defining_Name of Basic_Decl.P_Defining_Names loop Graph.Write_Edge(Defining_Name, Basic_Decl, Basic_Decl.Unit, Node_Edge_Types.Edge_Type_Source); if not Basic_Decl.P_Is_Compilation_Unit_Root or else Basic_Decl.Parent.Kind = LALCO.Ada_Subunit then Graph.Write_Edge(Parent, Defining_Name, Basic_Decl, Node_Edge_Types.Edge_Type_Contains); elsif Parent.P_Body_Part_For_Decl /= Basic_Decl and then not Is_Standard_Package_Decl(Parent) then Graph.Write_Edge(Parent, Defining_Name, Basic_Decl, Node_Edge_Types.Edge_Type_Is_Parent_Of); end if; end loop; end; end if; end Extract_Edges; end Extraction.Decls;
dv3/fd/direct.asm
olifink/smsqe
0
171703
<reponame>olifink/smsqe ; DV3 Standard Floppy Disk Check for Direct Sector Open V3.00  1993 <NAME> section dv3 xdef fd_direct include 'dev8_keys_err' include 'dev8_dv3_keys' include 'dev8_dv3_fd_keys' ;+++ ; DV3 check floppy for direct sector open (or for format) ; ; d1 c p sector length ; d2 c p density flag ; d3-d6 scratch ; d7 c p drive ID / number ; a0 c p channel block ; a1/a2 scratch ; a3 c p pointer to linkage block ; a4 c u pointer to physical definition ; ; error return 0 or error ;--- fd_direct cmp.b fdl_maxd(a3),d7 ; drive in range? bgt.s fc_fdnf ; ... no st fdf_dirct(a4) ; set opened for direct access sf ddf_wprot(a4) ; write protect not checked because ; tab might be moved or disk changed ; while channel is open moveq #0,d0 rts fc_fdnf moveq #err.fdnf,d0 rts fd_inam moveq #err.inam,d0 rts end
physics.ads
Kidev/AdaPhysics2D
9
16592
with Worlds; use Worlds; with Entities; use Entities; with Vectors2D; use Vectors2D; with Materials; use Materials; package Physics is -- Update the world of dt procedure StepNormal(This : in out World); -- Update the world of dt with low ram usage procedure StepLowRAM(This : in out World); -- This compute the fluid friction between That and the env That is in (in This) -- It should depend of the shape and speed of That -- It returns a positive force that will oppose the movement in the end function FluidFriction(This : in out World; That : not null EntityClassAcc) return Vec2D; function Archimedes(This : in out World; That : not null EntityClassAcc) return Float; function Tension(This : in out World; Ent : not null EntityClassAcc) return Vec2D; procedure ResetForces(Ent : not null EntityClassAcc); procedure IntegrateForces(This : in out World; Ent : not null EntityClassAcc); procedure IntegrateVelocity(This : in out World; Ent : not null EntityClassAcc); function GetDensestMaterial(This : in out World; That : not null EntityClassAcc) return Material; end Physics;
Parser_Tools/src/implementation/text-pool.adb
robdaemon/AdaYaml
32
10245
<filename>Parser_Tools/src/implementation/text-pool.adb -- part of ParserTools, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "copying.txt" package body Text.Pool is procedure Create (P : in out Reference'Class; Initial_Size : Pool_Offset := Default_Size) is Initial_Chunk : constant Chunk := new Pool_Array (Pool_Offset (1) .. Round_To_Header_Size (Initial_Size)); begin if P.Data /= null then Finalize (P); end if; P.Data := new Pool_Data; P.Data.Chunks (1) := Initial_Chunk; P.Data.Pos := 1; declare H : Header with Import; for H'Address use Initial_Chunk.all (1)'Address; begin H.Refcount := 0; H.Last := Pool_Offset (Initial_Chunk'Last) - Header_Size; end; end Create; function With_Capacity (Size : Pool_Offset) return Reference is begin return Ret : Reference do Create (Ret, Size); end return; end With_Capacity; function From_String (P : Reference'Class; Data : String) return Text.Reference is New_String_Address : constant System.Address := Fitting_Position (Data'Length, P.Data); Target_Data : constant UTF_8_String_Access := To_UTF_8_String_Access (New_String_Address); Null_Terminator : Character with Import; for Null_Terminator'Address use New_String_Address + Data'Length; begin Null_Terminator := Character'Val (0); Target_Data.all := UTF_8_String (Data); return (Ada.Finalization.Controlled with Data => Target_Data); end From_String; function With_Length (P : Reference'Class; Length : Positive) return Text.Reference is use System.Storage_Elements; New_String_Address : constant System.Address := Fitting_Position (Storage_Offset (Length), P.Data); Target_Data : constant UTF_8_String_Access := To_UTF_8_String_Access (New_String_Address); Null_Terminator : Character with Import; for Null_Terminator'Address use New_String_Address + Storage_Offset (Length); begin Null_Terminator := Character'Val (0); return (Ada.Finalization.Controlled with Data => Target_Data); end With_Length; procedure Adjust (Object : in out Reference) is begin if Object.Data /= null then Object.Data.Refcount := Object.Data.Refcount + 1; end if; end Adjust; procedure Finalize (Object : in out Reference) is Reference : Pool_Data_Access := Object.Data; begin Object.Data := null; if Reference /= null then Reference.Refcount := Reference.Refcount - 1; if Reference.Refcount = 0 then -- no reference around; take away Usage + 1 from the current Chunk. -- this enables the whole pool data to be freed once all Content -- references vanish. Decrease_Usage (Reference, Reference.Cur); end if; end if; end Finalize; function Current_Chunk_As_String (P : Reference) return String is (As_String (P.Data.Chunks (P.Data.Cur))); end Text.Pool;
Structure/Setoid/Category.agda
Lolirofle/stuff-in-agda
6
3218
<filename>Structure/Setoid/Category.agda module Structure.Setoid.Category where open import Data import Data.Tuple as Tuple open import Functional open import Function.Equals open import Function.Equals.Proofs open import Function.Proofs open import Logic.Predicate import Lvl open import Structure.Category open import Structure.Categorical.Properties open import Structure.Function open import Structure.Operator open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Structure.Setoid open import Type open import Type.Properties.Singleton private variable ℓ ℓₑ ℓₒ : Lvl.Level -- TODO: Maybe move this? FunctionObject : Setoid{ℓₑ}{ℓₒ} → Setoid{ℓₑ}{ℓₒ} → Type FunctionObject ([∃]-intro A) ([∃]-intro B) = ∃{Obj = (A → B)} Function instance FunctionObject-equiv : ∀{A B : Setoid{ℓₑ}{ℓₒ}} → Equiv(FunctionObject A B) Equiv._≡_ FunctionObject-equiv = (_⊜_) on₂ [∃]-witness Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence FunctionObject-equiv)) = reflexivity(_⊜_) Symmetry.proof (Equivalence.symmetry (Equiv.equivalence FunctionObject-equiv)) = symmetry(_⊜_) Transitivity.proof (Equivalence.transitivity (Equiv.equivalence FunctionObject-equiv)) = transitivity(_⊜_) -- The setoid category contains setoids and functions respecting the congruence property in the setoid. setoidCategory : Category{Obj = Setoid{ℓₑ}{ℓₒ}} FunctionObject Category._∘_ setoidCategory ([∃]-intro f) ([∃]-intro g) = [∃]-intro (f ∘ g) ⦃ [∘]-function {f = f}{g = g} ⦄ Category.id setoidCategory = [∃]-intro id BinaryOperator.congruence (Category.binaryOperator setoidCategory) f₁f₂ g₁g₂ = [⊜][∘]-binaryOperator-raw f₁f₂ g₁g₂ Morphism.Associativity.proof (Category.associativity setoidCategory) {x = _} {y = _} {z = _} {x = [∃]-intro f} {y = [∃]-intro g} {z = [∃]-intro h} = [∘]-associativity {f = f} {g = g} {h = h} Morphism.Identityₗ.proof (Tuple.left (Category.identity setoidCategory)) = [∘]-identityₗ Morphism.Identityᵣ.proof (Tuple.right (Category.identity setoidCategory)) = [∘]-identityᵣ setoidCategoryObject : ∀{ℓₑ}{ℓₒ} → CategoryObject setoidCategoryObject{ℓₑ}{ℓₒ} = intro(setoidCategory{ℓₑ}{ℓₒ}) module _ where open import Data.Proofs open import Relator.Equals Empty-initialObject : Object.Initial(FunctionObject{ℓₑ}) ([∃]-intro Empty) IsUnit.unit Empty-initialObject = [∃]-intro empty _⊜_.proof (IsUnit.uniqueness Empty-initialObject) {} Unit-terminalObject : Object.Terminal(FunctionObject{ℓₑ}) ([∃]-intro Unit) IsUnit.unit Unit-terminalObject = [∃]-intro (const <>) _⊜_.proof (IsUnit.uniqueness Unit-terminalObject) = [≡]-intro
stdlib-exts/Class/Monad/Except.agda
WhatisRT/meta-cedille
35
15763
<gh_stars>10-100 module Class.Monad.Except where open import Class.Monad open import Class.Monoid open import Data.Maybe open import Level private variable a : Level A : Set a record MonadExcept (M : Set a → Set a) {{_ : Monad M}} (E : Set a) : Set (suc a) where field throwError : E → M A catchError : M A → (E → M A) → M A appendIfError : {{_ : Monoid E}} → M A → E → M A appendIfError x s = catchError x λ e → throwError (e + s) maybeToError : Maybe A → E → M A maybeToError (just x) e = return x maybeToError nothing e = throwError e tryElse : M A → M A → M A tryElse x y = catchError x λ _ → y open MonadExcept {{...}} public
src/gl/implementation/gl-pixels.adb
Roldak/OpenGLAda
79
24646
<gh_stars>10-100 -- part of OpenGLAda, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "COPYING" with GL.API; with GL.Enums.Getter; package body GL.Pixels is procedure Set_Pack_Swap_Bytes (Value : Boolean) is begin API.Pixel_Store (Enums.Pack_Swap_Bytes, Low_Level.Bool (Value)); Raise_Exception_On_OpenGL_Error; end Set_Pack_Swap_Bytes; procedure Set_Pack_LSB_First (Value : Boolean) is begin API.Pixel_Store (Enums.Pack_LSB_First, Low_Level.Bool (Value)); Raise_Exception_On_OpenGL_Error; end Set_Pack_LSB_First; procedure Set_Pack_Row_Length (Value : Size) is begin API.Pixel_Store (Enums.Pack_Row_Length, Value); Raise_Exception_On_OpenGL_Error; end Set_Pack_Row_Length; procedure Set_Pack_Image_Height (Value : Size) is begin API.Pixel_Store (Enums.Pack_Image_Height, Value); Raise_Exception_On_OpenGL_Error; end Set_Pack_Image_Height; procedure Set_Pack_Skip_Pixels (Value : Size) is begin API.Pixel_Store (Enums.Pack_Skip_Pixels, Value); Raise_Exception_On_OpenGL_Error; end Set_Pack_Skip_Pixels; procedure Set_Pack_Skip_Rows (Value : Size) is begin API.Pixel_Store (Enums.Pack_Skip_Rows, Value); Raise_Exception_On_OpenGL_Error; end Set_Pack_Skip_Rows; procedure Set_Pack_Skip_Images (Value : Size) is begin API.Pixel_Store (Enums.Pack_Skip_Images, Value); Raise_Exception_On_OpenGL_Error; end Set_Pack_Skip_Images; procedure Set_Pack_Alignment (Value : Alignment) is begin API.Pixel_Store (Enums.Pack_Alignment, Value); Raise_Exception_On_OpenGL_Error; end Set_Pack_Alignment; function Pack_Swap_Bytes return Boolean is Ret : aliased Low_Level.Bool; begin API.Get_Boolean (Enums.Getter.Pack_Swap_Bytes, Ret'Access); Raise_Exception_On_OpenGL_Error; return Boolean (Ret); end Pack_Swap_Bytes; function Pack_LSB_First return Boolean is Ret : aliased Low_Level.Bool; begin API.Get_Boolean (Enums.Getter.Pack_Lsb_First, Ret'Access); Raise_Exception_On_OpenGL_Error; return Boolean (Ret); end Pack_LSB_First; function Pack_Row_Length return Size is Ret : aliased Types.Int; begin API.Get_Integer (Enums.Getter.Pack_Row_Length, Ret'Access); Raise_Exception_On_OpenGL_Error; return Size (Ret); end Pack_Row_Length; function Pack_Image_Height return Size is Ret : aliased Types.Int; begin API.Get_Integer (Enums.Getter.Pack_Image_Height, Ret'Access); Raise_Exception_On_OpenGL_Error; return Size (Ret); end Pack_Image_Height; function Pack_Skip_Pixels return Size is Ret : aliased Types.Int; begin API.Get_Integer (Enums.Getter.Pack_Skip_Pixels, Ret'Access); Raise_Exception_On_OpenGL_Error; return Size (Ret); end Pack_Skip_Pixels; function Pack_Skip_Rows return Size is Ret : aliased Types.Int; begin API.Get_Integer (Enums.Getter.Pack_Skip_Rows, Ret'Access); Raise_Exception_On_OpenGL_Error; return Size (Ret); end Pack_Skip_Rows; function Pack_Skip_Images return Size is Ret : aliased Types.Int; begin API.Get_Integer (Enums.Getter.Pack_Skip_Images, Ret'Access); Raise_Exception_On_OpenGL_Error; return Size (Ret); end Pack_Skip_Images; function Pack_Alignment return Alignment is Ret : aliased Alignment; begin API.Get_Alignment (Enums.Getter.Pack_Alignment, Ret'Access); Raise_Exception_On_OpenGL_Error; return Ret; end Pack_Alignment; procedure Set_Unpack_Swap_Bytes (Value : Boolean) is begin API.Pixel_Store (Enums.Unpack_Swap_Bytes, Low_Level.Bool (Value)); Raise_Exception_On_OpenGL_Error; end Set_Unpack_Swap_Bytes; procedure Set_Unpack_LSB_First (Value : Boolean) is begin API.Pixel_Store (Enums.Unpack_LSB_First, Low_Level.Bool (Value)); Raise_Exception_On_OpenGL_Error; end Set_Unpack_LSB_First; procedure Set_Unpack_Row_Length (Value : Size) is begin API.Pixel_Store (Enums.Unpack_Row_Length, Value); Raise_Exception_On_OpenGL_Error; end Set_Unpack_Row_Length; procedure Set_Unpack_Image_Height (Value : Size) is begin API.Pixel_Store (Enums.Unpack_Image_Height, Value); Raise_Exception_On_OpenGL_Error; end Set_Unpack_Image_Height; procedure Set_Unpack_Skip_Pixels (Value : Size) is begin API.Pixel_Store (Enums.Unpack_Skip_Pixels, Value); Raise_Exception_On_OpenGL_Error; end Set_Unpack_Skip_Pixels; procedure Set_Unpack_Skip_Rows (Value : Size) is begin API.Pixel_Store (Enums.Unpack_Skip_Rows, Value); Raise_Exception_On_OpenGL_Error; end Set_Unpack_Skip_Rows; procedure Set_Unpack_Skip_Images (Value : Size) is begin API.Pixel_Store (Enums.Unpack_Skip_Images, Value); Raise_Exception_On_OpenGL_Error; end Set_Unpack_Skip_Images; procedure Set_Unpack_Alignment (Value : Alignment) is begin API.Pixel_Store (Enums.Unpack_Alignment, Value); Raise_Exception_On_OpenGL_Error; end Set_Unpack_Alignment; function Unpack_Swap_Bytes return Boolean is Ret : aliased Low_Level.Bool; begin API.Get_Boolean (Enums.Getter.Unpack_Swap_Bytes, Ret'Access); Raise_Exception_On_OpenGL_Error; return Boolean (Ret); end Unpack_Swap_Bytes; function Unpack_LSB_First return Boolean is Ret : aliased Low_Level.Bool; begin API.Get_Boolean (Enums.Getter.Unpack_Lsb_First, Ret'Access); Raise_Exception_On_OpenGL_Error; return Boolean (Ret); end Unpack_LSB_First; function Unpack_Row_Length return Size is Ret : aliased Types.Int; begin API.Get_Integer (Enums.Getter.Unpack_Row_Length, Ret'Access); Raise_Exception_On_OpenGL_Error; return Size (Ret); end Unpack_Row_Length; function Unpack_Image_Height return Size is Ret : aliased Types.Int; begin API.Get_Integer (Enums.Getter.Unpack_Image_Height, Ret'Access); Raise_Exception_On_OpenGL_Error; return Size (Ret); end Unpack_Image_Height; function Unpack_Skip_Pixels return Size is Ret : aliased Types.Int; begin API.Get_Integer (Enums.Getter.Unpack_Skip_Pixels, Ret'Access); Raise_Exception_On_OpenGL_Error; return Size (Ret); end Unpack_Skip_Pixels; function Unpack_Skip_Rows return Size is Ret : aliased Types.Int; begin API.Get_Integer (Enums.Getter.Unpack_Skip_Rows, Ret'Access); Raise_Exception_On_OpenGL_Error; return Size (Ret); end Unpack_Skip_Rows; function Unpack_Skip_Images return Size is Ret : aliased Types.Int; begin API.Get_Integer (Enums.Getter.Unpack_Skip_Images, Ret'Access); Raise_Exception_On_OpenGL_Error; return Size (Ret); end Unpack_Skip_Images; function Unpack_Alignment return Alignment is Ret : aliased Alignment; begin API.Get_Alignment (Enums.Getter.Unpack_Alignment, Ret'Access); Raise_Exception_On_OpenGL_Error; return Ret; end Unpack_Alignment; end GL.Pixels;
arch/ARM/STM32/svd/stm32f46_79x/stm32_svd-usb_otg_fs.ads
rocher/Ada_Drivers_Library
192
16054
<reponame>rocher/Ada_Drivers_Library -- This spec has been automatically generated from STM32F46_79x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.USB_OTG_FS is pragma Preelaborate; --------------- -- Registers -- --------------- subtype FS_DCFG_DSPD_Field is HAL.UInt2; subtype FS_DCFG_DAD_Field is HAL.UInt7; subtype FS_DCFG_PFIVL_Field is HAL.UInt2; -- OTG_FS device configuration register (OTG_FS_DCFG) type FS_DCFG_Register is record -- Device speed DSPD : FS_DCFG_DSPD_Field := 16#0#; -- Non-zero-length status OUT handshake NZLSOHSK : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- Device address DAD : FS_DCFG_DAD_Field := 16#0#; -- Periodic frame interval PFIVL : FS_DCFG_PFIVL_Field := 16#0#; -- unspecified Reserved_13_31 : HAL.UInt19 := 16#1100#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DCFG_Register use record DSPD at 0 range 0 .. 1; NZLSOHSK at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; DAD at 0 range 4 .. 10; PFIVL at 0 range 11 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; subtype FS_DCTL_TCTL_Field is HAL.UInt3; -- OTG_FS device control register (OTG_FS_DCTL) type FS_DCTL_Register is record -- Remote wakeup signaling RWUSIG : Boolean := False; -- Soft disconnect SDIS : Boolean := False; -- Read-only. Global IN NAK status GINSTS : Boolean := False; -- Read-only. Global OUT NAK status GONSTS : Boolean := False; -- Test control TCTL : FS_DCTL_TCTL_Field := 16#0#; -- Set global IN NAK SGINAK : Boolean := False; -- Clear global IN NAK CGINAK : Boolean := False; -- Set global OUT NAK SGONAK : Boolean := False; -- Clear global OUT NAK CGONAK : Boolean := False; -- Power-on programming done POPRGDNE : Boolean := False; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DCTL_Register use record RWUSIG at 0 range 0 .. 0; SDIS at 0 range 1 .. 1; GINSTS at 0 range 2 .. 2; GONSTS at 0 range 3 .. 3; TCTL at 0 range 4 .. 6; SGINAK at 0 range 7 .. 7; CGINAK at 0 range 8 .. 8; SGONAK at 0 range 9 .. 9; CGONAK at 0 range 10 .. 10; POPRGDNE at 0 range 11 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype FS_DSTS_ENUMSPD_Field is HAL.UInt2; subtype FS_DSTS_FNSOF_Field is HAL.UInt14; -- OTG_FS device status register (OTG_FS_DSTS) type FS_DSTS_Register is record -- Read-only. Suspend status SUSPSTS : Boolean; -- Read-only. Enumerated speed ENUMSPD : FS_DSTS_ENUMSPD_Field; -- Read-only. Erratic error EERR : Boolean; -- unspecified Reserved_4_7 : HAL.UInt4; -- Read-only. Frame number of the received SOF FNSOF : FS_DSTS_FNSOF_Field; -- unspecified Reserved_22_31 : HAL.UInt10; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DSTS_Register use record SUSPSTS at 0 range 0 .. 0; ENUMSPD at 0 range 1 .. 2; EERR at 0 range 3 .. 3; Reserved_4_7 at 0 range 4 .. 7; FNSOF at 0 range 8 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; -- OTG_FS device IN endpoint common interrupt mask register -- (OTG_FS_DIEPMSK) type FS_DIEPMSK_Register is record -- Transfer completed interrupt mask XFRCM : Boolean := False; -- Endpoint disabled interrupt mask EPDM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- Timeout condition mask (Non-isochronous endpoints) TOM : Boolean := False; -- IN token received when TxFIFO empty mask ITTXFEMSK : Boolean := False; -- IN token received with EP mismatch mask INEPNMM : Boolean := False; -- IN endpoint NAK effective mask INEPNEM : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DIEPMSK_Register use record XFRCM at 0 range 0 .. 0; EPDM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; TOM at 0 range 3 .. 3; ITTXFEMSK at 0 range 4 .. 4; INEPNMM at 0 range 5 .. 5; INEPNEM at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- OTG_FS device OUT endpoint common interrupt mask register -- (OTG_FS_DOEPMSK) type FS_DOEPMSK_Register is record -- Transfer completed interrupt mask XFRCM : Boolean := False; -- Endpoint disabled interrupt mask EPDM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- SETUP phase done mask STUPM : Boolean := False; -- OUT token received when endpoint disabled mask OTEPDM : Boolean := False; -- unspecified Reserved_5_31 : HAL.UInt27 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DOEPMSK_Register use record XFRCM at 0 range 0 .. 0; EPDM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STUPM at 0 range 3 .. 3; OTEPDM at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype FS_DAINT_IEPINT_Field is HAL.UInt16; subtype FS_DAINT_OEPINT_Field is HAL.UInt16; -- OTG_FS device all endpoints interrupt register (OTG_FS_DAINT) type FS_DAINT_Register is record -- Read-only. IN endpoint interrupt bits IEPINT : FS_DAINT_IEPINT_Field; -- Read-only. OUT endpoint interrupt bits OEPINT : FS_DAINT_OEPINT_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DAINT_Register use record IEPINT at 0 range 0 .. 15; OEPINT at 0 range 16 .. 31; end record; subtype FS_DAINTMSK_IEPM_Field is HAL.UInt16; subtype FS_DAINTMSK_OEPM_Field is HAL.UInt16; -- OTG_FS all endpoints interrupt mask register (OTG_FS_DAINTMSK) type FS_DAINTMSK_Register is record -- IN EP interrupt mask bits IEPM : FS_DAINTMSK_IEPM_Field := 16#0#; -- OUT EP interrupt mask bits OEPM : FS_DAINTMSK_OEPM_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DAINTMSK_Register use record IEPM at 0 range 0 .. 15; OEPM at 0 range 16 .. 31; end record; subtype DVBUSDIS_VBUSDT_Field is HAL.UInt16; -- OTG_FS device VBUS discharge time register type DVBUSDIS_Register is record -- Device VBUS discharge time VBUSDT : DVBUSDIS_VBUSDT_Field := 16#17D7#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DVBUSDIS_Register use record VBUSDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DVBUSPULSE_DVBUSP_Field is HAL.UInt12; -- OTG_FS device VBUS pulsing time register type DVBUSPULSE_Register is record -- Device VBUS pulsing time DVBUSP : DVBUSPULSE_DVBUSP_Field := 16#5B8#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DVBUSPULSE_Register use record DVBUSP at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype DIEPEMPMSK_INEPTXFEM_Field is HAL.UInt16; -- OTG_FS device IN endpoint FIFO empty interrupt mask register type DIEPEMPMSK_Register is record -- IN EP Tx FIFO empty interrupt mask bits INEPTXFEM : DIEPEMPMSK_INEPTXFEM_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPEMPMSK_Register use record INEPTXFEM at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype FS_DIEPCTL0_MPSIZ_Field is HAL.UInt2; subtype FS_DIEPCTL0_EPTYP_Field is HAL.UInt2; subtype FS_DIEPCTL0_TXFNUM_Field is HAL.UInt4; -- OTG_FS device control IN endpoint 0 control register (OTG_FS_DIEPCTL0) type FS_DIEPCTL0_Register is record -- Maximum packet size MPSIZ : FS_DIEPCTL0_MPSIZ_Field := 16#0#; -- unspecified Reserved_2_14 : HAL.UInt13 := 16#0#; -- Read-only. USB active endpoint USBAEP : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Read-only. NAK status NAKSTS : Boolean := False; -- Read-only. Endpoint type EPTYP : FS_DIEPCTL0_EPTYP_Field := 16#0#; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- STALL handshake STALL : Boolean := False; -- TxFIFO number TXFNUM : FS_DIEPCTL0_TXFNUM_Field := 16#0#; -- Write-only. Clear NAK CNAK : Boolean := False; -- Write-only. Set NAK SNAK : Boolean := False; -- unspecified Reserved_28_29 : HAL.UInt2 := 16#0#; -- Read-only. Endpoint disable EPDIS : Boolean := False; -- Read-only. Endpoint enable EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DIEPCTL0_Register use record MPSIZ at 0 range 0 .. 1; Reserved_2_14 at 0 range 2 .. 14; USBAEP at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; Reserved_20_20 at 0 range 20 .. 20; STALL at 0 range 21 .. 21; TXFNUM at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; Reserved_28_29 at 0 range 28 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; -- device endpoint-x interrupt register type DIEPINT_Register is record -- XFRC XFRC : Boolean := False; -- EPDISD EPDISD : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- TOC TOC : Boolean := False; -- ITTXFE ITTXFE : Boolean := False; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- INEPNE INEPNE : Boolean := False; -- Read-only. TXFE TXFE : Boolean := True; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPINT_Register use record XFRC at 0 range 0 .. 0; EPDISD at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; TOC at 0 range 3 .. 3; ITTXFE at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; INEPNE at 0 range 6 .. 6; TXFE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype DIEPTSIZ0_XFRSIZ_Field is HAL.UInt7; subtype DIEPTSIZ0_PKTCNT_Field is HAL.UInt2; -- device endpoint-0 transfer size register type DIEPTSIZ0_Register is record -- Transfer size XFRSIZ : DIEPTSIZ0_XFRSIZ_Field := 16#0#; -- unspecified Reserved_7_18 : HAL.UInt12 := 16#0#; -- Packet count PKTCNT : DIEPTSIZ0_PKTCNT_Field := 16#0#; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPTSIZ0_Register use record XFRSIZ at 0 range 0 .. 6; Reserved_7_18 at 0 range 7 .. 18; PKTCNT at 0 range 19 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype DTXFSTS_INEPTFSAV_Field is HAL.UInt16; -- OTG_FS device IN endpoint transmit FIFO status register type DTXFSTS_Register is record -- Read-only. IN endpoint TxFIFO space available INEPTFSAV : DTXFSTS_INEPTFSAV_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DTXFSTS_Register use record INEPTFSAV at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DIEPCTL1_MPSIZ_Field is HAL.UInt11; subtype DIEPCTL1_EPTYP_Field is HAL.UInt2; subtype DIEPCTL1_TXFNUM_Field is HAL.UInt4; -- OTG device endpoint-1 control register type DIEPCTL1_Register is record -- MPSIZ MPSIZ : DIEPCTL1_MPSIZ_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- USBAEP USBAEP : Boolean := False; -- Read-only. EONUM/DPID EONUM_DPID : Boolean := False; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- EPTYP EPTYP : DIEPCTL1_EPTYP_Field := 16#0#; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- Stall Stall : Boolean := False; -- TXFNUM TXFNUM : DIEPCTL1_TXFNUM_Field := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- Write-only. SD0PID/SEVNFRM SD0PID_SEVNFRM : Boolean := False; -- Write-only. SODDFRM/SD1PID SODDFRM_SD1PID : Boolean := False; -- EPDIS EPDIS : Boolean := False; -- EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPCTL1_Register use record MPSIZ at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; USBAEP at 0 range 15 .. 15; EONUM_DPID at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; Reserved_20_20 at 0 range 20 .. 20; Stall at 0 range 21 .. 21; TXFNUM at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; SD0PID_SEVNFRM at 0 range 28 .. 28; SODDFRM_SD1PID at 0 range 29 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; subtype DIEPTSIZ_XFRSIZ_Field is HAL.UInt19; subtype DIEPTSIZ_PKTCNT_Field is HAL.UInt10; subtype DIEPTSIZ_MCNT_Field is HAL.UInt2; -- device endpoint-1 transfer size register type DIEPTSIZ_Register is record -- Transfer size XFRSIZ : DIEPTSIZ_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : DIEPTSIZ_PKTCNT_Field := 16#0#; -- Multi count MCNT : DIEPTSIZ_MCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; MCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype DIEPCTL_MPSIZ_Field is HAL.UInt11; subtype DIEPCTL_EPTYP_Field is HAL.UInt2; subtype DIEPCTL_TXFNUM_Field is HAL.UInt4; -- OTG device endpoint-2 control register type DIEPCTL_Register is record -- MPSIZ MPSIZ : DIEPCTL_MPSIZ_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- USBAEP USBAEP : Boolean := False; -- Read-only. EONUM/DPID EONUM_DPID : Boolean := False; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- EPTYP EPTYP : DIEPCTL_EPTYP_Field := 16#0#; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- Stall Stall : Boolean := False; -- TXFNUM TXFNUM : DIEPCTL_TXFNUM_Field := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- Write-only. SD0PID/SEVNFRM SD0PID_SEVNFRM : Boolean := False; -- Write-only. SODDFRM SODDFRM : Boolean := False; -- EPDIS EPDIS : Boolean := False; -- EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIEPCTL_Register use record MPSIZ at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; USBAEP at 0 range 15 .. 15; EONUM_DPID at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; Reserved_20_20 at 0 range 20 .. 20; Stall at 0 range 21 .. 21; TXFNUM at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; SD0PID_SEVNFRM at 0 range 28 .. 28; SODDFRM at 0 range 29 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; subtype DOEPCTL0_MPSIZ_Field is HAL.UInt2; subtype DOEPCTL0_EPTYP_Field is HAL.UInt2; -- device endpoint-0 control register type DOEPCTL0_Register is record -- Read-only. MPSIZ MPSIZ : DOEPCTL0_MPSIZ_Field := 16#0#; -- unspecified Reserved_2_14 : HAL.UInt13 := 16#0#; -- Read-only. USBAEP USBAEP : Boolean := True; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- Read-only. EPTYP EPTYP : DOEPCTL0_EPTYP_Field := 16#0#; -- SNPM SNPM : Boolean := False; -- Stall Stall : Boolean := False; -- unspecified Reserved_22_25 : HAL.UInt4 := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- unspecified Reserved_28_29 : HAL.UInt2 := 16#0#; -- Read-only. EPDIS EPDIS : Boolean := False; -- Write-only. EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOEPCTL0_Register use record MPSIZ at 0 range 0 .. 1; Reserved_2_14 at 0 range 2 .. 14; USBAEP at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; SNPM at 0 range 20 .. 20; Stall at 0 range 21 .. 21; Reserved_22_25 at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; Reserved_28_29 at 0 range 28 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; -- device endpoint-0 interrupt register type DOEPINT_Register is record -- XFRC XFRC : Boolean := False; -- EPDISD EPDISD : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- STUP STUP : Boolean := False; -- OTEPDIS OTEPDIS : Boolean := False; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- B2BSTUP B2BSTUP : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#1#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOEPINT_Register use record XFRC at 0 range 0 .. 0; EPDISD at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STUP at 0 range 3 .. 3; OTEPDIS at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; B2BSTUP at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; subtype DOEPTSIZ0_XFRSIZ_Field is HAL.UInt7; subtype DOEPTSIZ0_STUPCNT_Field is HAL.UInt2; -- device OUT endpoint-0 transfer size register type DOEPTSIZ0_Register is record -- Transfer size XFRSIZ : DOEPTSIZ0_XFRSIZ_Field := 16#0#; -- unspecified Reserved_7_18 : HAL.UInt12 := 16#0#; -- Packet count PKTCNT : Boolean := False; -- unspecified Reserved_20_28 : HAL.UInt9 := 16#0#; -- SETUP packet count STUPCNT : DOEPTSIZ0_STUPCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOEPTSIZ0_Register use record XFRSIZ at 0 range 0 .. 6; Reserved_7_18 at 0 range 7 .. 18; PKTCNT at 0 range 19 .. 19; Reserved_20_28 at 0 range 20 .. 28; STUPCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype DOEPCTL_MPSIZ_Field is HAL.UInt11; subtype DOEPCTL_EPTYP_Field is HAL.UInt2; -- device endpoint-1 control register type DOEPCTL_Register is record -- MPSIZ MPSIZ : DOEPCTL_MPSIZ_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- USBAEP USBAEP : Boolean := False; -- Read-only. EONUM/DPID EONUM_DPID : Boolean := False; -- Read-only. NAKSTS NAKSTS : Boolean := False; -- EPTYP EPTYP : DOEPCTL_EPTYP_Field := 16#0#; -- SNPM SNPM : Boolean := False; -- Stall Stall : Boolean := False; -- unspecified Reserved_22_25 : HAL.UInt4 := 16#0#; -- Write-only. CNAK CNAK : Boolean := False; -- Write-only. SNAK SNAK : Boolean := False; -- Write-only. SD0PID/SEVNFRM SD0PID_SEVNFRM : Boolean := False; -- Write-only. SODDFRM SODDFRM : Boolean := False; -- EPDIS EPDIS : Boolean := False; -- EPENA EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOEPCTL_Register use record MPSIZ at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; USBAEP at 0 range 15 .. 15; EONUM_DPID at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; SNPM at 0 range 20 .. 20; Stall at 0 range 21 .. 21; Reserved_22_25 at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; SD0PID_SEVNFRM at 0 range 28 .. 28; SODDFRM at 0 range 29 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; subtype DOEPTSIZ_XFRSIZ_Field is HAL.UInt19; subtype DOEPTSIZ_PKTCNT_Field is HAL.UInt10; subtype DOEPTSIZ_RXDPID_STUPCNT_Field is HAL.UInt2; -- device OUT endpoint-1 transfer size register type DOEPTSIZ_Register is record -- Transfer size XFRSIZ : DOEPTSIZ_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : DOEPTSIZ_PKTCNT_Field := 16#0#; -- Received data PID/SETUP packet count RXDPID_STUPCNT : DOEPTSIZ_RXDPID_STUPCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOEPTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; RXDPID_STUPCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- OTG_FS control and status register (OTG_FS_GOTGCTL) type FS_GOTGCTL_Register is record -- Read-only. Session request success SRQSCS : Boolean := False; -- Session request SRQ : Boolean := False; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- Read-only. Host negotiation success HNGSCS : Boolean := False; -- HNP request HNPRQ : Boolean := False; -- Host set HNP enable HSHNPEN : Boolean := False; -- Device HNP enabled DHNPEN : Boolean := True; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Read-only. Connector ID status CIDSTS : Boolean := False; -- Read-only. Long/short debounce time DBCT : Boolean := False; -- Read-only. A-session valid ASVLD : Boolean := False; -- Read-only. B-session valid BSVLD : Boolean := False; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GOTGCTL_Register use record SRQSCS at 0 range 0 .. 0; SRQ at 0 range 1 .. 1; Reserved_2_7 at 0 range 2 .. 7; HNGSCS at 0 range 8 .. 8; HNPRQ at 0 range 9 .. 9; HSHNPEN at 0 range 10 .. 10; DHNPEN at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; CIDSTS at 0 range 16 .. 16; DBCT at 0 range 17 .. 17; ASVLD at 0 range 18 .. 18; BSVLD at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; -- OTG_FS interrupt register (OTG_FS_GOTGINT) type FS_GOTGINT_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Session end detected SEDET : Boolean := False; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; -- Session request success status change SRSSCHG : Boolean := False; -- Host negotiation success status change HNSSCHG : Boolean := False; -- unspecified Reserved_10_16 : HAL.UInt7 := 16#0#; -- Host negotiation detected HNGDET : Boolean := False; -- A-device timeout change ADTOCHG : Boolean := False; -- Debounce done DBCDNE : Boolean := False; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GOTGINT_Register use record Reserved_0_1 at 0 range 0 .. 1; SEDET at 0 range 2 .. 2; Reserved_3_7 at 0 range 3 .. 7; SRSSCHG at 0 range 8 .. 8; HNSSCHG at 0 range 9 .. 9; Reserved_10_16 at 0 range 10 .. 16; HNGDET at 0 range 17 .. 17; ADTOCHG at 0 range 18 .. 18; DBCDNE at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; -- OTG_FS AHB configuration register (OTG_FS_GAHBCFG) type FS_GAHBCFG_Register is record -- Global interrupt mask GINT : Boolean := False; -- unspecified Reserved_1_6 : HAL.UInt6 := 16#0#; -- TxFIFO empty level TXFELVL : Boolean := False; -- Periodic TxFIFO empty level PTXFELVL : Boolean := False; -- unspecified Reserved_9_31 : HAL.UInt23 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GAHBCFG_Register use record GINT at 0 range 0 .. 0; Reserved_1_6 at 0 range 1 .. 6; TXFELVL at 0 range 7 .. 7; PTXFELVL at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; subtype FS_GUSBCFG_TOCAL_Field is HAL.UInt3; subtype FS_GUSBCFG_TRDT_Field is HAL.UInt4; -- OTG_FS USB configuration register (OTG_FS_GUSBCFG) type FS_GUSBCFG_Register is record -- FS timeout calibration TOCAL : FS_GUSBCFG_TOCAL_Field := 16#0#; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Write-only. Full Speed serial transceiver select PHYSEL : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- SRP-capable SRPCAP : Boolean := False; -- HNP-capable HNPCAP : Boolean := True; -- USB turnaround time TRDT : FS_GUSBCFG_TRDT_Field := 16#2#; -- unspecified Reserved_14_28 : HAL.UInt15 := 16#0#; -- Force host mode FHMOD : Boolean := False; -- Force device mode FDMOD : Boolean := False; -- Corrupt Tx packet CTXPKT : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GUSBCFG_Register use record TOCAL at 0 range 0 .. 2; Reserved_3_5 at 0 range 3 .. 5; PHYSEL at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; SRPCAP at 0 range 8 .. 8; HNPCAP at 0 range 9 .. 9; TRDT at 0 range 10 .. 13; Reserved_14_28 at 0 range 14 .. 28; FHMOD at 0 range 29 .. 29; FDMOD at 0 range 30 .. 30; CTXPKT at 0 range 31 .. 31; end record; subtype FS_GRSTCTL_TXFNUM_Field is HAL.UInt5; -- OTG_FS reset register (OTG_FS_GRSTCTL) type FS_GRSTCTL_Register is record -- Core soft reset CSRST : Boolean := False; -- HCLK soft reset HSRST : Boolean := False; -- Host frame counter reset FCRST : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- RxFIFO flush RXFFLSH : Boolean := False; -- TxFIFO flush TXFFLSH : Boolean := False; -- TxFIFO number TXFNUM : FS_GRSTCTL_TXFNUM_Field := 16#0#; -- unspecified Reserved_11_30 : HAL.UInt20 := 16#40000#; -- Read-only. AHB master idle AHBIDL : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GRSTCTL_Register use record CSRST at 0 range 0 .. 0; HSRST at 0 range 1 .. 1; FCRST at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; RXFFLSH at 0 range 4 .. 4; TXFFLSH at 0 range 5 .. 5; TXFNUM at 0 range 6 .. 10; Reserved_11_30 at 0 range 11 .. 30; AHBIDL at 0 range 31 .. 31; end record; -- OTG_FS core interrupt register (OTG_FS_GINTSTS) type FS_GINTSTS_Register is record -- Read-only. Current mode of operation CMOD : Boolean := False; -- Mode mismatch interrupt MMIS : Boolean := False; -- Read-only. OTG interrupt OTGINT : Boolean := False; -- Start of frame SOF : Boolean := False; -- Read-only. RxFIFO non-empty RXFLVL : Boolean := False; -- Read-only. Non-periodic TxFIFO empty NPTXFE : Boolean := True; -- Read-only. Global IN non-periodic NAK effective GINAKEFF : Boolean := False; -- Read-only. Global OUT NAK effective GOUTNAKEFF : Boolean := False; -- unspecified Reserved_8_9 : HAL.UInt2 := 16#0#; -- Early suspend ESUSP : Boolean := False; -- USB suspend USBSUSP : Boolean := False; -- USB reset USBRST : Boolean := False; -- Enumeration done ENUMDNE : Boolean := False; -- Isochronous OUT packet dropped interrupt ISOODRP : Boolean := False; -- End of periodic frame interrupt EOPF : Boolean := False; -- unspecified Reserved_16_17 : HAL.UInt2 := 16#0#; -- Read-only. IN endpoint interrupt IEPINT : Boolean := False; -- Read-only. OUT endpoint interrupt OEPINT : Boolean := False; -- Incomplete isochronous IN transfer IISOIXFR : Boolean := False; -- Incomplete periodic transfer(Host mode)/Incomplete isochronous OUT -- transfer(Device mode) IPXFR_INCOMPISOOUT : Boolean := False; -- unspecified Reserved_22_23 : HAL.UInt2 := 16#0#; -- Read-only. Host port interrupt HPRTINT : Boolean := False; -- Read-only. Host channels interrupt HCINT : Boolean := False; -- Read-only. Periodic TxFIFO empty PTXFE : Boolean := True; -- unspecified Reserved_27_27 : HAL.Bit := 16#0#; -- Connector ID status change CIDSCHG : Boolean := False; -- Disconnect detected interrupt DISCINT : Boolean := False; -- Session request/new session detected interrupt SRQINT : Boolean := False; -- Resume/remote wakeup detected interrupt WKUPINT : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GINTSTS_Register use record CMOD at 0 range 0 .. 0; MMIS at 0 range 1 .. 1; OTGINT at 0 range 2 .. 2; SOF at 0 range 3 .. 3; RXFLVL at 0 range 4 .. 4; NPTXFE at 0 range 5 .. 5; GINAKEFF at 0 range 6 .. 6; GOUTNAKEFF at 0 range 7 .. 7; Reserved_8_9 at 0 range 8 .. 9; ESUSP at 0 range 10 .. 10; USBSUSP at 0 range 11 .. 11; USBRST at 0 range 12 .. 12; ENUMDNE at 0 range 13 .. 13; ISOODRP at 0 range 14 .. 14; EOPF at 0 range 15 .. 15; Reserved_16_17 at 0 range 16 .. 17; IEPINT at 0 range 18 .. 18; OEPINT at 0 range 19 .. 19; IISOIXFR at 0 range 20 .. 20; IPXFR_INCOMPISOOUT at 0 range 21 .. 21; Reserved_22_23 at 0 range 22 .. 23; HPRTINT at 0 range 24 .. 24; HCINT at 0 range 25 .. 25; PTXFE at 0 range 26 .. 26; Reserved_27_27 at 0 range 27 .. 27; CIDSCHG at 0 range 28 .. 28; DISCINT at 0 range 29 .. 29; SRQINT at 0 range 30 .. 30; WKUPINT at 0 range 31 .. 31; end record; -- OTG_FS interrupt mask register (OTG_FS_GINTMSK) type FS_GINTMSK_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Mode mismatch interrupt mask MMISM : Boolean := False; -- OTG interrupt mask OTGINT : Boolean := False; -- Start of frame mask SOFM : Boolean := False; -- Receive FIFO non-empty mask RXFLVLM : Boolean := False; -- Non-periodic TxFIFO empty mask NPTXFEM : Boolean := False; -- Global non-periodic IN NAK effective mask GINAKEFFM : Boolean := False; -- Global OUT NAK effective mask GONAKEFFM : Boolean := False; -- unspecified Reserved_8_9 : HAL.UInt2 := 16#0#; -- Early suspend mask ESUSPM : Boolean := False; -- USB suspend mask USBSUSPM : Boolean := False; -- USB reset mask USBRST : Boolean := False; -- Enumeration done mask ENUMDNEM : Boolean := False; -- Isochronous OUT packet dropped interrupt mask ISOODRPM : Boolean := False; -- End of periodic frame interrupt mask EOPFM : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Endpoint mismatch interrupt mask EPMISM : Boolean := False; -- IN endpoints interrupt mask IEPINT : Boolean := False; -- OUT endpoints interrupt mask OEPINT : Boolean := False; -- Incomplete isochronous IN transfer mask IISOIXFRM : Boolean := False; -- Incomplete periodic transfer mask(Host mode)/Incomplete isochronous -- OUT transfer mask(Device mode) IPXFRM_IISOOXFRM : Boolean := False; -- unspecified Reserved_22_23 : HAL.UInt2 := 16#0#; -- Read-only. Host port interrupt mask PRTIM : Boolean := False; -- Host channels interrupt mask HCIM : Boolean := False; -- Periodic TxFIFO empty mask PTXFEM : Boolean := False; -- unspecified Reserved_27_27 : HAL.Bit := 16#0#; -- Connector ID status change mask CIDSCHGM : Boolean := False; -- Disconnect detected interrupt mask DISCINT : Boolean := False; -- Session request/new session detected interrupt mask SRQIM : Boolean := False; -- Resume/remote wakeup detected interrupt mask WUIM : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GINTMSK_Register use record Reserved_0_0 at 0 range 0 .. 0; MMISM at 0 range 1 .. 1; OTGINT at 0 range 2 .. 2; SOFM at 0 range 3 .. 3; RXFLVLM at 0 range 4 .. 4; NPTXFEM at 0 range 5 .. 5; GINAKEFFM at 0 range 6 .. 6; GONAKEFFM at 0 range 7 .. 7; Reserved_8_9 at 0 range 8 .. 9; ESUSPM at 0 range 10 .. 10; USBSUSPM at 0 range 11 .. 11; USBRST at 0 range 12 .. 12; ENUMDNEM at 0 range 13 .. 13; ISOODRPM at 0 range 14 .. 14; EOPFM at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; EPMISM at 0 range 17 .. 17; IEPINT at 0 range 18 .. 18; OEPINT at 0 range 19 .. 19; IISOIXFRM at 0 range 20 .. 20; IPXFRM_IISOOXFRM at 0 range 21 .. 21; Reserved_22_23 at 0 range 22 .. 23; PRTIM at 0 range 24 .. 24; HCIM at 0 range 25 .. 25; PTXFEM at 0 range 26 .. 26; Reserved_27_27 at 0 range 27 .. 27; CIDSCHGM at 0 range 28 .. 28; DISCINT at 0 range 29 .. 29; SRQIM at 0 range 30 .. 30; WUIM at 0 range 31 .. 31; end record; subtype FS_GRXSTSR_Device_EPNUM_Field is HAL.UInt4; subtype FS_GRXSTSR_Device_BCNT_Field is HAL.UInt11; subtype FS_GRXSTSR_Device_DPID_Field is HAL.UInt2; subtype FS_GRXSTSR_Device_PKTSTS_Field is HAL.UInt4; subtype FS_GRXSTSR_Device_FRMNUM_Field is HAL.UInt4; -- OTG_FS Receive status debug read(Device mode) type FS_GRXSTSR_Device_Register is record -- Read-only. Endpoint number EPNUM : FS_GRXSTSR_Device_EPNUM_Field; -- Read-only. Byte count BCNT : FS_GRXSTSR_Device_BCNT_Field; -- Read-only. Data PID DPID : FS_GRXSTSR_Device_DPID_Field; -- Read-only. Packet status PKTSTS : FS_GRXSTSR_Device_PKTSTS_Field; -- Read-only. Frame number FRMNUM : FS_GRXSTSR_Device_FRMNUM_Field; -- unspecified Reserved_25_31 : HAL.UInt7; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GRXSTSR_Device_Register use record EPNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; FRMNUM at 0 range 21 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype FS_GRXSTSR_Host_EPNUM_Field is HAL.UInt4; subtype FS_GRXSTSR_Host_BCNT_Field is HAL.UInt11; subtype FS_GRXSTSR_Host_DPID_Field is HAL.UInt2; subtype FS_GRXSTSR_Host_PKTSTS_Field is HAL.UInt4; subtype FS_GRXSTSR_Host_FRMNUM_Field is HAL.UInt4; -- OTG_FS Receive status debug read(Hostmode) type FS_GRXSTSR_Host_Register is record -- Read-only. Endpoint number EPNUM : FS_GRXSTSR_Host_EPNUM_Field; -- Read-only. Byte count BCNT : FS_GRXSTSR_Host_BCNT_Field; -- Read-only. Data PID DPID : FS_GRXSTSR_Host_DPID_Field; -- Read-only. Packet status PKTSTS : FS_GRXSTSR_Host_PKTSTS_Field; -- Read-only. Frame number FRMNUM : FS_GRXSTSR_Host_FRMNUM_Field; -- unspecified Reserved_25_31 : HAL.UInt7; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GRXSTSR_Host_Register use record EPNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; FRMNUM at 0 range 21 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype FS_GRXFSIZ_RXFD_Field is HAL.UInt16; -- OTG_FS Receive FIFO size register (OTG_FS_GRXFSIZ) type FS_GRXFSIZ_Register is record -- RxFIFO depth RXFD : FS_GRXFSIZ_RXFD_Field := 16#200#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GRXFSIZ_Register use record RXFD at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype FS_GNPTXFSIZ_Device_TX0FSA_Field is HAL.UInt16; subtype FS_GNPTXFSIZ_Device_TX0FD_Field is HAL.UInt16; -- OTG_FS non-periodic transmit FIFO size register (Device mode) type FS_GNPTXFSIZ_Device_Register is record -- Endpoint 0 transmit RAM start address TX0FSA : FS_GNPTXFSIZ_Device_TX0FSA_Field := 16#200#; -- Endpoint 0 TxFIFO depth TX0FD : FS_GNPTXFSIZ_Device_TX0FD_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GNPTXFSIZ_Device_Register use record TX0FSA at 0 range 0 .. 15; TX0FD at 0 range 16 .. 31; end record; subtype FS_GNPTXFSIZ_Host_NPTXFSA_Field is HAL.UInt16; subtype FS_GNPTXFSIZ_Host_NPTXFD_Field is HAL.UInt16; -- OTG_FS non-periodic transmit FIFO size register (Host mode) type FS_GNPTXFSIZ_Host_Register is record -- Non-periodic transmit RAM start address NPTXFSA : FS_GNPTXFSIZ_Host_NPTXFSA_Field := 16#200#; -- Non-periodic TxFIFO depth NPTXFD : FS_GNPTXFSIZ_Host_NPTXFD_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GNPTXFSIZ_Host_Register use record NPTXFSA at 0 range 0 .. 15; NPTXFD at 0 range 16 .. 31; end record; subtype FS_GNPTXSTS_NPTXFSAV_Field is HAL.UInt16; subtype FS_GNPTXSTS_NPTQXSAV_Field is HAL.UInt8; subtype FS_GNPTXSTS_NPTXQTOP_Field is HAL.UInt7; -- OTG_FS non-periodic transmit FIFO/queue status register -- (OTG_FS_GNPTXSTS) type FS_GNPTXSTS_Register is record -- Read-only. Non-periodic TxFIFO space available NPTXFSAV : FS_GNPTXSTS_NPTXFSAV_Field; -- Read-only. Non-periodic transmit request queue space available NPTQXSAV : FS_GNPTXSTS_NPTQXSAV_Field; -- Read-only. Top of the non-periodic transmit request queue NPTXQTOP : FS_GNPTXSTS_NPTXQTOP_Field; -- unspecified Reserved_31_31 : HAL.Bit; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GNPTXSTS_Register use record NPTXFSAV at 0 range 0 .. 15; NPTQXSAV at 0 range 16 .. 23; NPTXQTOP at 0 range 24 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- OTG_FS general core configuration register (OTG_FS_GCCFG) type FS_GCCFG_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- Power down PWRDWN : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Enable the VBUS sensing device VBUSASEN : Boolean := False; -- Enable the VBUS sensing device VBUSBSEN : Boolean := False; -- SOF output enable SOFOUTEN : Boolean := False; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_GCCFG_Register use record Reserved_0_15 at 0 range 0 .. 15; PWRDWN at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; VBUSASEN at 0 range 18 .. 18; VBUSBSEN at 0 range 19 .. 19; SOFOUTEN at 0 range 20 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype FS_HPTXFSIZ_PTXSA_Field is HAL.UInt16; subtype FS_HPTXFSIZ_PTXFSIZ_Field is HAL.UInt16; -- OTG_FS Host periodic transmit FIFO size register (OTG_FS_HPTXFSIZ) type FS_HPTXFSIZ_Register is record -- Host periodic TxFIFO start address PTXSA : FS_HPTXFSIZ_PTXSA_Field := 16#600#; -- Host periodic TxFIFO depth PTXFSIZ : FS_HPTXFSIZ_PTXFSIZ_Field := 16#200#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HPTXFSIZ_Register use record PTXSA at 0 range 0 .. 15; PTXFSIZ at 0 range 16 .. 31; end record; subtype FS_DIEPTXF_INEPTXSA_Field is HAL.UInt16; subtype FS_DIEPTXF_INEPTXFD_Field is HAL.UInt16; -- OTG_FS device IN endpoint transmit FIFO size register (OTG_FS_DIEPTXF1) type FS_DIEPTXF_Register is record -- IN endpoint FIFO2 transmit RAM start address INEPTXSA : FS_DIEPTXF_INEPTXSA_Field := 16#400#; -- IN endpoint TxFIFO depth INEPTXFD : FS_DIEPTXF_INEPTXFD_Field := 16#200#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_DIEPTXF_Register use record INEPTXSA at 0 range 0 .. 15; INEPTXFD at 0 range 16 .. 31; end record; subtype FS_HCFG_FSLSPCS_Field is HAL.UInt2; -- OTG_FS host configuration register (OTG_FS_HCFG) type FS_HCFG_Register is record -- FS/LS PHY clock select FSLSPCS : FS_HCFG_FSLSPCS_Field := 16#0#; -- Read-only. FS- and LS-only support FSLSS : Boolean := False; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HCFG_Register use record FSLSPCS at 0 range 0 .. 1; FSLSS at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype HFIR_FRIVL_Field is HAL.UInt16; -- OTG_FS Host frame interval register type HFIR_Register is record -- Frame interval FRIVL : HFIR_FRIVL_Field := 16#EA60#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HFIR_Register use record FRIVL at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype FS_HFNUM_FRNUM_Field is HAL.UInt16; subtype FS_HFNUM_FTREM_Field is HAL.UInt16; -- OTG_FS host frame number/frame time remaining register (OTG_FS_HFNUM) type FS_HFNUM_Register is record -- Read-only. Frame number FRNUM : FS_HFNUM_FRNUM_Field; -- Read-only. Frame time remaining FTREM : FS_HFNUM_FTREM_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HFNUM_Register use record FRNUM at 0 range 0 .. 15; FTREM at 0 range 16 .. 31; end record; subtype FS_HPTXSTS_PTXFSAVL_Field is HAL.UInt16; subtype FS_HPTXSTS_PTXQSAV_Field is HAL.UInt8; subtype FS_HPTXSTS_PTXQTOP_Field is HAL.UInt8; -- OTG_FS_Host periodic transmit FIFO/queue status register -- (OTG_FS_HPTXSTS) type FS_HPTXSTS_Register is record -- Periodic transmit data FIFO space available PTXFSAVL : FS_HPTXSTS_PTXFSAVL_Field := 16#100#; -- Read-only. Periodic transmit request queue space available PTXQSAV : FS_HPTXSTS_PTXQSAV_Field := 16#8#; -- Read-only. Top of the periodic transmit request queue PTXQTOP : FS_HPTXSTS_PTXQTOP_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HPTXSTS_Register use record PTXFSAVL at 0 range 0 .. 15; PTXQSAV at 0 range 16 .. 23; PTXQTOP at 0 range 24 .. 31; end record; subtype HAINT_HAINT_Field is HAL.UInt16; -- OTG_FS Host all channels interrupt register type HAINT_Register is record -- Read-only. Channel interrupts HAINT : HAINT_HAINT_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HAINT_Register use record HAINT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype HAINTMSK_HAINTM_Field is HAL.UInt16; -- OTG_FS host all channels interrupt mask register type HAINTMSK_Register is record -- Channel interrupt mask HAINTM : HAINTMSK_HAINTM_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HAINTMSK_Register use record HAINTM at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype FS_HPRT_PLSTS_Field is HAL.UInt2; subtype FS_HPRT_PTCTL_Field is HAL.UInt4; subtype FS_HPRT_PSPD_Field is HAL.UInt2; -- OTG_FS host port control and status register (OTG_FS_HPRT) type FS_HPRT_Register is record -- Read-only. Port connect status PCSTS : Boolean := False; -- Port connect detected PCDET : Boolean := False; -- Port enable PENA : Boolean := False; -- Port enable/disable change PENCHNG : Boolean := False; -- Read-only. Port overcurrent active POCA : Boolean := False; -- Port overcurrent change POCCHNG : Boolean := False; -- Port resume PRES : Boolean := False; -- Port suspend PSUSP : Boolean := False; -- Port reset PRST : Boolean := False; -- unspecified Reserved_9_9 : HAL.Bit := 16#0#; -- Read-only. Port line status PLSTS : FS_HPRT_PLSTS_Field := 16#0#; -- Port power PPWR : Boolean := False; -- Port test control PTCTL : FS_HPRT_PTCTL_Field := 16#0#; -- Read-only. Port speed PSPD : FS_HPRT_PSPD_Field := 16#0#; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HPRT_Register use record PCSTS at 0 range 0 .. 0; PCDET at 0 range 1 .. 1; PENA at 0 range 2 .. 2; PENCHNG at 0 range 3 .. 3; POCA at 0 range 4 .. 4; POCCHNG at 0 range 5 .. 5; PRES at 0 range 6 .. 6; PSUSP at 0 range 7 .. 7; PRST at 0 range 8 .. 8; Reserved_9_9 at 0 range 9 .. 9; PLSTS at 0 range 10 .. 11; PPWR at 0 range 12 .. 12; PTCTL at 0 range 13 .. 16; PSPD at 0 range 17 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; subtype FS_HCCHAR_MPSIZ_Field is HAL.UInt11; subtype FS_HCCHAR_EPNUM_Field is HAL.UInt4; subtype FS_HCCHAR_EPTYP_Field is HAL.UInt2; subtype FS_HCCHAR_MCNT_Field is HAL.UInt2; subtype FS_HCCHAR_DAD_Field is HAL.UInt7; -- OTG_FS host channel-0 characteristics register (OTG_FS_HCCHAR0) type FS_HCCHAR_Register is record -- Maximum packet size MPSIZ : FS_HCCHAR_MPSIZ_Field := 16#0#; -- Endpoint number EPNUM : FS_HCCHAR_EPNUM_Field := 16#0#; -- Endpoint direction EPDIR : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Low-speed device LSDEV : Boolean := False; -- Endpoint type EPTYP : FS_HCCHAR_EPTYP_Field := 16#0#; -- Multicount MCNT : FS_HCCHAR_MCNT_Field := 16#0#; -- Device address DAD : FS_HCCHAR_DAD_Field := 16#0#; -- Odd frame ODDFRM : Boolean := False; -- Channel disable CHDIS : Boolean := False; -- Channel enable CHENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HCCHAR_Register use record MPSIZ at 0 range 0 .. 10; EPNUM at 0 range 11 .. 14; EPDIR at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; LSDEV at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; MCNT at 0 range 20 .. 21; DAD at 0 range 22 .. 28; ODDFRM at 0 range 29 .. 29; CHDIS at 0 range 30 .. 30; CHENA at 0 range 31 .. 31; end record; -- OTG_FS host channel-0 interrupt register (OTG_FS_HCINT0) type FS_HCINT_Register is record -- Transfer completed XFRC : Boolean := False; -- Channel halted CHH : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- STALL response received interrupt STALL : Boolean := False; -- NAK response received interrupt NAK : Boolean := False; -- ACK response received/transmitted interrupt ACK : Boolean := False; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- Transaction error TXERR : Boolean := False; -- Babble error BBERR : Boolean := False; -- Frame overrun FRMOR : Boolean := False; -- Data toggle error DTERR : Boolean := False; -- unspecified Reserved_11_31 : HAL.UInt21 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HCINT_Register use record XFRC at 0 range 0 .. 0; CHH at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STALL at 0 range 3 .. 3; NAK at 0 range 4 .. 4; ACK at 0 range 5 .. 5; Reserved_6_6 at 0 range 6 .. 6; TXERR at 0 range 7 .. 7; BBERR at 0 range 8 .. 8; FRMOR at 0 range 9 .. 9; DTERR at 0 range 10 .. 10; Reserved_11_31 at 0 range 11 .. 31; end record; -- OTG_FS host channel-0 mask register (OTG_FS_HCINTMSK0) type FS_HCINTMSK_Register is record -- Transfer completed mask XFRCM : Boolean := False; -- Channel halted mask CHHM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- STALL response received interrupt mask STALLM : Boolean := False; -- NAK response received interrupt mask NAKM : Boolean := False; -- ACK response received/transmitted interrupt mask ACKM : Boolean := False; -- response received interrupt mask NYET : Boolean := False; -- Transaction error mask TXERRM : Boolean := False; -- Babble error mask BBERRM : Boolean := False; -- Frame overrun mask FRMORM : Boolean := False; -- Data toggle error mask DTERRM : Boolean := False; -- unspecified Reserved_11_31 : HAL.UInt21 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HCINTMSK_Register use record XFRCM at 0 range 0 .. 0; CHHM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STALLM at 0 range 3 .. 3; NAKM at 0 range 4 .. 4; ACKM at 0 range 5 .. 5; NYET at 0 range 6 .. 6; TXERRM at 0 range 7 .. 7; BBERRM at 0 range 8 .. 8; FRMORM at 0 range 9 .. 9; DTERRM at 0 range 10 .. 10; Reserved_11_31 at 0 range 11 .. 31; end record; subtype FS_HCTSIZ_XFRSIZ_Field is HAL.UInt19; subtype FS_HCTSIZ_PKTCNT_Field is HAL.UInt10; subtype FS_HCTSIZ_DPID_Field is HAL.UInt2; -- OTG_FS host channel-0 transfer size register type FS_HCTSIZ_Register is record -- Transfer size XFRSIZ : FS_HCTSIZ_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : FS_HCTSIZ_PKTCNT_Field := 16#0#; -- Data PID DPID : FS_HCTSIZ_DPID_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_HCTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; DPID at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- OTG_FS power and clock gating control register (OTG_FS_PCGCCTL) type FS_PCGCCTL_Register is record -- Stop PHY clock STPPCLK : Boolean := False; -- Gate HCLK GATEHCLK : Boolean := False; -- unspecified Reserved_2_3 : HAL.UInt2 := 16#0#; -- PHY Suspended PHYSUSP : Boolean := False; -- unspecified Reserved_5_31 : HAL.UInt27 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FS_PCGCCTL_Register use record STPPCLK at 0 range 0 .. 0; GATEHCLK at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; PHYSUSP at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- USB on the go full speed type OTG_FS_DEVICE_Peripheral is record -- OTG_FS device configuration register (OTG_FS_DCFG) FS_DCFG : aliased FS_DCFG_Register; -- OTG_FS device control register (OTG_FS_DCTL) FS_DCTL : aliased FS_DCTL_Register; -- OTG_FS device status register (OTG_FS_DSTS) FS_DSTS : aliased FS_DSTS_Register; -- OTG_FS device IN endpoint common interrupt mask register -- (OTG_FS_DIEPMSK) FS_DIEPMSK : aliased FS_DIEPMSK_Register; -- OTG_FS device OUT endpoint common interrupt mask register -- (OTG_FS_DOEPMSK) FS_DOEPMSK : aliased FS_DOEPMSK_Register; -- OTG_FS device all endpoints interrupt register (OTG_FS_DAINT) FS_DAINT : aliased FS_DAINT_Register; -- OTG_FS all endpoints interrupt mask register (OTG_FS_DAINTMSK) FS_DAINTMSK : aliased FS_DAINTMSK_Register; -- OTG_FS device VBUS discharge time register DVBUSDIS : aliased DVBUSDIS_Register; -- OTG_FS device VBUS pulsing time register DVBUSPULSE : aliased DVBUSPULSE_Register; -- OTG_FS device IN endpoint FIFO empty interrupt mask register DIEPEMPMSK : aliased DIEPEMPMSK_Register; -- OTG_FS device control IN endpoint 0 control register -- (OTG_FS_DIEPCTL0) FS_DIEPCTL0 : aliased FS_DIEPCTL0_Register; -- device endpoint-x interrupt register DIEPINT0 : aliased DIEPINT_Register; -- device endpoint-0 transfer size register DIEPTSIZ0 : aliased DIEPTSIZ0_Register; -- OTG_FS device IN endpoint transmit FIFO status register DTXFSTS0 : aliased DTXFSTS_Register; -- OTG device endpoint-1 control register DIEPCTL1 : aliased DIEPCTL1_Register; -- device endpoint-1 interrupt register DIEPINT1 : aliased DIEPINT_Register; -- device endpoint-1 transfer size register DIEPTSIZ1 : aliased DIEPTSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO status register DTXFSTS1 : aliased DTXFSTS_Register; -- OTG device endpoint-2 control register DIEPCTL2 : aliased DIEPCTL_Register; -- device endpoint-2 interrupt register DIEPINT2 : aliased DIEPINT_Register; -- device endpoint-2 transfer size register DIEPTSIZ2 : aliased DIEPTSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO status register DTXFSTS2 : aliased DTXFSTS_Register; -- OTG device endpoint-3 control register DIEPCTL3 : aliased DIEPCTL_Register; -- device endpoint-3 interrupt register DIEPINT3 : aliased DIEPINT_Register; -- device endpoint-3 transfer size register DIEPTSIZ3 : aliased DIEPTSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO status register DTXFSTS3 : aliased DTXFSTS_Register; -- device endpoint-0 control register DOEPCTL0 : aliased DOEPCTL0_Register; -- device endpoint-0 interrupt register DOEPINT0 : aliased DOEPINT_Register; -- device OUT endpoint-0 transfer size register DOEPTSIZ0 : aliased DOEPTSIZ0_Register; -- device endpoint-1 control register DOEPCTL1 : aliased DOEPCTL_Register; -- device endpoint-1 interrupt register DOEPINT1 : aliased DOEPINT_Register; -- device OUT endpoint-1 transfer size register DOEPTSIZ1 : aliased DOEPTSIZ_Register; -- device endpoint-2 control register DOEPCTL2 : aliased DOEPCTL_Register; -- device endpoint-2 interrupt register DOEPINT2 : aliased DOEPINT_Register; -- device OUT endpoint-2 transfer size register DOEPTSIZ2 : aliased DOEPTSIZ_Register; -- device endpoint-3 control register DOEPCTL3 : aliased DOEPCTL_Register; -- device endpoint-3 interrupt register DOEPINT3 : aliased DOEPINT_Register; -- device OUT endpoint-3 transfer size register DOEPTSIZ3 : aliased DOEPTSIZ_Register; end record with Volatile; for OTG_FS_DEVICE_Peripheral use record FS_DCFG at 16#0# range 0 .. 31; FS_DCTL at 16#4# range 0 .. 31; FS_DSTS at 16#8# range 0 .. 31; FS_DIEPMSK at 16#10# range 0 .. 31; FS_DOEPMSK at 16#14# range 0 .. 31; FS_DAINT at 16#18# range 0 .. 31; FS_DAINTMSK at 16#1C# range 0 .. 31; DVBUSDIS at 16#28# range 0 .. 31; DVBUSPULSE at 16#2C# range 0 .. 31; DIEPEMPMSK at 16#34# range 0 .. 31; FS_DIEPCTL0 at 16#100# range 0 .. 31; DIEPINT0 at 16#108# range 0 .. 31; DIEPTSIZ0 at 16#110# range 0 .. 31; DTXFSTS0 at 16#118# range 0 .. 31; DIEPCTL1 at 16#120# range 0 .. 31; DIEPINT1 at 16#128# range 0 .. 31; DIEPTSIZ1 at 16#130# range 0 .. 31; DTXFSTS1 at 16#138# range 0 .. 31; DIEPCTL2 at 16#140# range 0 .. 31; DIEPINT2 at 16#148# range 0 .. 31; DIEPTSIZ2 at 16#150# range 0 .. 31; DTXFSTS2 at 16#158# range 0 .. 31; DIEPCTL3 at 16#160# range 0 .. 31; DIEPINT3 at 16#168# range 0 .. 31; DIEPTSIZ3 at 16#170# range 0 .. 31; DTXFSTS3 at 16#178# range 0 .. 31; DOEPCTL0 at 16#300# range 0 .. 31; DOEPINT0 at 16#308# range 0 .. 31; DOEPTSIZ0 at 16#310# range 0 .. 31; DOEPCTL1 at 16#320# range 0 .. 31; DOEPINT1 at 16#328# range 0 .. 31; DOEPTSIZ1 at 16#330# range 0 .. 31; DOEPCTL2 at 16#340# range 0 .. 31; DOEPINT2 at 16#348# range 0 .. 31; DOEPTSIZ2 at 16#350# range 0 .. 31; DOEPCTL3 at 16#360# range 0 .. 31; DOEPINT3 at 16#368# range 0 .. 31; DOEPTSIZ3 at 16#370# range 0 .. 31; end record; -- USB on the go full speed OTG_FS_DEVICE_Periph : aliased OTG_FS_DEVICE_Peripheral with Import, Address => System'To_Address (16#50000800#); type OTG_FS_GLOBAL_Disc is ( Device, Host); -- USB on the go full speed type OTG_FS_GLOBAL_Peripheral (Discriminent : OTG_FS_GLOBAL_Disc := Device) is record -- OTG_FS control and status register (OTG_FS_GOTGCTL) FS_GOTGCTL : aliased FS_GOTGCTL_Register; -- OTG_FS interrupt register (OTG_FS_GOTGINT) FS_GOTGINT : aliased FS_GOTGINT_Register; -- OTG_FS AHB configuration register (OTG_FS_GAHBCFG) FS_GAHBCFG : aliased FS_GAHBCFG_Register; -- OTG_FS USB configuration register (OTG_FS_GUSBCFG) FS_GUSBCFG : aliased FS_GUSBCFG_Register; -- OTG_FS reset register (OTG_FS_GRSTCTL) FS_GRSTCTL : aliased FS_GRSTCTL_Register; -- OTG_FS core interrupt register (OTG_FS_GINTSTS) FS_GINTSTS : aliased FS_GINTSTS_Register; -- OTG_FS interrupt mask register (OTG_FS_GINTMSK) FS_GINTMSK : aliased FS_GINTMSK_Register; -- OTG_FS Receive FIFO size register (OTG_FS_GRXFSIZ) FS_GRXFSIZ : aliased FS_GRXFSIZ_Register; -- OTG_FS non-periodic transmit FIFO/queue status register -- (OTG_FS_GNPTXSTS) FS_GNPTXSTS : aliased FS_GNPTXSTS_Register; -- OTG_FS general core configuration register (OTG_FS_GCCFG) FS_GCCFG : aliased FS_GCCFG_Register; -- core ID register FS_CID : aliased HAL.UInt32; -- OTG_FS Host periodic transmit FIFO size register (OTG_FS_HPTXFSIZ) FS_HPTXFSIZ : aliased FS_HPTXFSIZ_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF1) FS_DIEPTXF1 : aliased FS_DIEPTXF_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF2) FS_DIEPTXF2 : aliased FS_DIEPTXF_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF3) FS_DIEPTXF3 : aliased FS_DIEPTXF_Register; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF4) FS_DIEPTXF4 : aliased HAL.UInt32; -- OTG_FS device IN endpoint transmit FIFO size register -- (OTG_FS_DIEPTXF5) FS_DIEPTXF5 : aliased HAL.UInt32; case Discriminent is when Device => -- OTG_FS Receive status debug read(Device mode) FS_GRXSTSR_Device : aliased FS_GRXSTSR_Device_Register; -- OTG_FS non-periodic transmit FIFO size register (Device mode) FS_GNPTXFSIZ_Device : aliased FS_GNPTXFSIZ_Device_Register; when Host => -- OTG_FS Receive status debug read(Hostmode) FS_GRXSTSR_Host : aliased FS_GRXSTSR_Host_Register; -- OTG_FS non-periodic transmit FIFO size register (Host mode) FS_GNPTXFSIZ_Host : aliased FS_GNPTXFSIZ_Host_Register; end case; end record with Unchecked_Union, Volatile; for OTG_FS_GLOBAL_Peripheral use record FS_GOTGCTL at 16#0# range 0 .. 31; FS_GOTGINT at 16#4# range 0 .. 31; FS_GAHBCFG at 16#8# range 0 .. 31; FS_GUSBCFG at 16#C# range 0 .. 31; FS_GRSTCTL at 16#10# range 0 .. 31; FS_GINTSTS at 16#14# range 0 .. 31; FS_GINTMSK at 16#18# range 0 .. 31; FS_GRXFSIZ at 16#24# range 0 .. 31; FS_GNPTXSTS at 16#2C# range 0 .. 31; FS_GCCFG at 16#38# range 0 .. 31; FS_CID at 16#3C# range 0 .. 31; FS_HPTXFSIZ at 16#100# range 0 .. 31; FS_DIEPTXF1 at 16#104# range 0 .. 31; FS_DIEPTXF2 at 16#108# range 0 .. 31; FS_DIEPTXF3 at 16#10C# range 0 .. 31; FS_DIEPTXF4 at 16#110# range 0 .. 31; FS_DIEPTXF5 at 16#114# range 0 .. 31; FS_GRXSTSR_Device at 16#1C# range 0 .. 31; FS_GNPTXFSIZ_Device at 16#28# range 0 .. 31; FS_GRXSTSR_Host at 16#1C# range 0 .. 31; FS_GNPTXFSIZ_Host at 16#28# range 0 .. 31; end record; -- USB on the go full speed OTG_FS_GLOBAL_Periph : aliased OTG_FS_GLOBAL_Peripheral with Import, Address => System'To_Address (16#50000000#); -- USB on the go full speed type OTG_FS_HOST_Peripheral is record -- OTG_FS host configuration register (OTG_FS_HCFG) FS_HCFG : aliased FS_HCFG_Register; -- OTG_FS Host frame interval register HFIR : aliased HFIR_Register; -- OTG_FS host frame number/frame time remaining register (OTG_FS_HFNUM) FS_HFNUM : aliased FS_HFNUM_Register; -- OTG_FS_Host periodic transmit FIFO/queue status register -- (OTG_FS_HPTXSTS) FS_HPTXSTS : aliased FS_HPTXSTS_Register; -- OTG_FS Host all channels interrupt register HAINT : aliased HAINT_Register; -- OTG_FS host all channels interrupt mask register HAINTMSK : aliased HAINTMSK_Register; -- OTG_FS host port control and status register (OTG_FS_HPRT) FS_HPRT : aliased FS_HPRT_Register; -- OTG_FS host channel-0 characteristics register (OTG_FS_HCCHAR0) FS_HCCHAR0 : aliased FS_HCCHAR_Register; -- OTG_FS host channel-0 interrupt register (OTG_FS_HCINT0) FS_HCINT0 : aliased FS_HCINT_Register; -- OTG_FS host channel-0 mask register (OTG_FS_HCINTMSK0) FS_HCINTMSK0 : aliased FS_HCINTMSK_Register; -- OTG_FS host channel-0 transfer size register FS_HCTSIZ0 : aliased FS_HCTSIZ_Register; -- OTG_FS host channel-1 characteristics register (OTG_FS_HCCHAR1) FS_HCCHAR1 : aliased FS_HCCHAR_Register; -- OTG_FS host channel-1 interrupt register (OTG_FS_HCINT1) FS_HCINT1 : aliased FS_HCINT_Register; -- OTG_FS host channel-1 mask register (OTG_FS_HCINTMSK1) FS_HCINTMSK1 : aliased FS_HCINTMSK_Register; -- OTG_FS host channel-1 transfer size register FS_HCTSIZ1 : aliased FS_HCTSIZ_Register; -- OTG_FS host channel-2 characteristics register (OTG_FS_HCCHAR2) FS_HCCHAR2 : aliased FS_HCCHAR_Register; -- OTG_FS host channel-2 interrupt register (OTG_FS_HCINT2) FS_HCINT2 : aliased FS_HCINT_Register; -- OTG_FS host channel-2 mask register (OTG_FS_HCINTMSK2) FS_HCINTMSK2 : aliased FS_HCINTMSK_Register; -- OTG_FS host channel-2 transfer size register FS_HCTSIZ2 : aliased FS_HCTSIZ_Register; -- OTG_FS host channel-3 characteristics register (OTG_FS_HCCHAR3) FS_HCCHAR3 : aliased FS_HCCHAR_Register; -- OTG_FS host channel-3 interrupt register (OTG_FS_HCINT3) FS_HCINT3 : aliased FS_HCINT_Register; -- OTG_FS host channel-3 mask register (OTG_FS_HCINTMSK3) FS_HCINTMSK3 : aliased FS_HCINTMSK_Register; -- OTG_FS host channel-3 transfer size register FS_HCTSIZ3 : aliased FS_HCTSIZ_Register; -- OTG_FS host channel-4 characteristics register (OTG_FS_HCCHAR4) FS_HCCHAR4 : aliased FS_HCCHAR_Register; -- OTG_FS host channel-4 interrupt register (OTG_FS_HCINT4) FS_HCINT4 : aliased FS_HCINT_Register; -- OTG_FS host channel-4 mask register (OTG_FS_HCINTMSK4) FS_HCINTMSK4 : aliased FS_HCINTMSK_Register; -- OTG_FS host channel-x transfer size register FS_HCTSIZ4 : aliased FS_HCTSIZ_Register; -- OTG_FS host channel-5 characteristics register (OTG_FS_HCCHAR5) FS_HCCHAR5 : aliased FS_HCCHAR_Register; -- OTG_FS host channel-5 interrupt register (OTG_FS_HCINT5) FS_HCINT5 : aliased FS_HCINT_Register; -- OTG_FS host channel-5 mask register (OTG_FS_HCINTMSK5) FS_HCINTMSK5 : aliased FS_HCINTMSK_Register; -- OTG_FS host channel-5 transfer size register FS_HCTSIZ5 : aliased FS_HCTSIZ_Register; -- OTG_FS host channel-6 characteristics register (OTG_FS_HCCHAR6) FS_HCCHAR6 : aliased FS_HCCHAR_Register; -- OTG_FS host channel-6 interrupt register (OTG_FS_HCINT6) FS_HCINT6 : aliased FS_HCINT_Register; -- OTG_FS host channel-6 mask register (OTG_FS_HCINTMSK6) FS_HCINTMSK6 : aliased FS_HCINTMSK_Register; -- OTG_FS host channel-6 transfer size register FS_HCTSIZ6 : aliased FS_HCTSIZ_Register; -- OTG_FS host channel-7 characteristics register (OTG_FS_HCCHAR7) FS_HCCHAR7 : aliased FS_HCCHAR_Register; -- OTG_FS host channel-7 interrupt register (OTG_FS_HCINT7) FS_HCINT7 : aliased FS_HCINT_Register; -- OTG_FS host channel-7 mask register (OTG_FS_HCINTMSK7) FS_HCINTMSK7 : aliased FS_HCINTMSK_Register; -- OTG_FS host channel-7 transfer size register FS_HCTSIZ7 : aliased FS_HCTSIZ_Register; end record with Volatile; for OTG_FS_HOST_Peripheral use record FS_HCFG at 16#0# range 0 .. 31; HFIR at 16#4# range 0 .. 31; FS_HFNUM at 16#8# range 0 .. 31; FS_HPTXSTS at 16#10# range 0 .. 31; HAINT at 16#14# range 0 .. 31; HAINTMSK at 16#18# range 0 .. 31; FS_HPRT at 16#40# range 0 .. 31; FS_HCCHAR0 at 16#100# range 0 .. 31; FS_HCINT0 at 16#108# range 0 .. 31; FS_HCINTMSK0 at 16#10C# range 0 .. 31; FS_HCTSIZ0 at 16#110# range 0 .. 31; FS_HCCHAR1 at 16#120# range 0 .. 31; FS_HCINT1 at 16#128# range 0 .. 31; FS_HCINTMSK1 at 16#12C# range 0 .. 31; FS_HCTSIZ1 at 16#130# range 0 .. 31; FS_HCCHAR2 at 16#140# range 0 .. 31; FS_HCINT2 at 16#148# range 0 .. 31; FS_HCINTMSK2 at 16#14C# range 0 .. 31; FS_HCTSIZ2 at 16#150# range 0 .. 31; FS_HCCHAR3 at 16#160# range 0 .. 31; FS_HCINT3 at 16#168# range 0 .. 31; FS_HCINTMSK3 at 16#16C# range 0 .. 31; FS_HCTSIZ3 at 16#170# range 0 .. 31; FS_HCCHAR4 at 16#180# range 0 .. 31; FS_HCINT4 at 16#188# range 0 .. 31; FS_HCINTMSK4 at 16#18C# range 0 .. 31; FS_HCTSIZ4 at 16#190# range 0 .. 31; FS_HCCHAR5 at 16#1A0# range 0 .. 31; FS_HCINT5 at 16#1A8# range 0 .. 31; FS_HCINTMSK5 at 16#1AC# range 0 .. 31; FS_HCTSIZ5 at 16#1B0# range 0 .. 31; FS_HCCHAR6 at 16#1C0# range 0 .. 31; FS_HCINT6 at 16#1C8# range 0 .. 31; FS_HCINTMSK6 at 16#1CC# range 0 .. 31; FS_HCTSIZ6 at 16#1D0# range 0 .. 31; FS_HCCHAR7 at 16#1E0# range 0 .. 31; FS_HCINT7 at 16#1E8# range 0 .. 31; FS_HCINTMSK7 at 16#1EC# range 0 .. 31; FS_HCTSIZ7 at 16#1F0# range 0 .. 31; end record; -- USB on the go full speed OTG_FS_HOST_Periph : aliased OTG_FS_HOST_Peripheral with Import, Address => System'To_Address (16#50000400#); -- USB on the go full speed type OTG_FS_PWRCLK_Peripheral is record -- OTG_FS power and clock gating control register (OTG_FS_PCGCCTL) FS_PCGCCTL : aliased FS_PCGCCTL_Register; end record with Volatile; for OTG_FS_PWRCLK_Peripheral use record FS_PCGCCTL at 0 range 0 .. 31; end record; -- USB on the go full speed OTG_FS_PWRCLK_Periph : aliased OTG_FS_PWRCLK_Peripheral with Import, Address => System'To_Address (16#50000E00#); end STM32_SVD.USB_OTG_FS;
tag-mac/Library/Scripts/Applications/Finder/New File.scpt
stevenberg/dotfiles
2
892
tell application "Finder" try set _result to display dialog "Filename:" with icon note default answer "" buttons {"Cancel", "Create"} default button "Create" if button returned of _result is "Cancel" then return end if length of text returned of _result is 0 then return end set _filename to the text returned of _result set _current_folder to the target of the front window as alias make new file at _current_folder with properties {name: _filename, file type: "TEXT"} on error _error if _error is equal to "Finder got an error: User canceled." return else display dialog (_error) end end try end tell
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/bug_elaboration_code.ads
best08618/asylo
7
5894
package Bug_Elaboration_Code is pragma Elaborate_Body; I : Integer; J : Integer; end Bug_Elaboration_Code;
programs/oeis/079/A079977.asm
karttu/loda
0
80933
; A079977: Fibonacci numbers interspersed with zeros. ; 1,0,1,0,2,0,3,0,5,0,8,0,13,0,21,0,34,0,55,0,89,0,144,0,233,0,377,0,610,0,987,0,1597,0,2584,0,4181,0,6765,0,10946,0,17711,0,28657,0,46368,0,75025,0,121393,0,196418,0,317811,0,514229,0,832040,0,1346269 mov $3,2 mov $7,$0 lpb $3,1 mov $0,$7 sub $3,1 add $0,$3 sub $0,1 mov $2,2 mov $4,0 lpb $0,1 sub $0,2 mov $5,$4 mov $4,$2 add $5,2 add $2,$5 lpe mov $6,$3 mov $8,$2 lpb $6,1 mov $1,$8 sub $6,1 lpe lpe lpb $7,1 sub $1,$8 mov $7,0 lpe div $1,2
programs/oeis/053/A053738.asm
karttu/loda
0
247314
<gh_stars>0 ; A053738: If k is in sequence then 2*k and 2*k+1 are not (and 1 is in the sequence); numbers with an odd number of digits in binary. ; 1,4,5,6,7,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420 mov $1,1 mov $2,$0 lpb $0,1 add $0,$2 mul $1,2 add $1,$2 add $1,1 sub $0,$1 trn $0,1 sub $1,$0 mov $2,$0 lpe
src/main/antlr4/de/tracetronic/jenkins/plugins/ecutest/filter/RefFilter.g4
kunerd/ecutest-plugin
0
6312
<reponame>kunerd/ecutest-plugin<filename>src/main/antlr4/de/tracetronic/jenkins/plugins/ecutest/filter/RefFilter.g4 /* * Copyright (c) 2015 TraceTronic GmbH * 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. * * 3. Neither the name of TraceTronic GmbH 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. */ grammar RefFilter; options{ language = Java; } // PARSER filterExpression : filter (LOGICAL filter)*; filter : (expression (LOGICAL filter)* | LPAREN filter RPAREN); expression : ((equalExpression | relExpression | hasExpression) | (STRING | NUMBER | BOOLEAN)); equalExpression : (KEYWORD OPERATOR_EQUAL (STRING | NUMBER | BOOLEAN)); relExpression : (KEYWORD OPERATOR_REL NUMBER); hasExpression : (KEYWORD OPERATOR_HAS STRING); // LEXER LPAREN : '(' ; RPAREN : ')' ; KEYWORD : (KEYWORDS | SINGLE_QUOTED_KEYWORD | DOUBLE_QUOTED_KEYWORD); SINGLE_QUOTED_KEYWORD : '\'' (KEYWORDS | KEYWORDS_QUOTED) '\''; DOUBLE_QUOTED_KEYWORD : '"' (KEYWORDS | KEYWORDS_QUOTED) '"'; KEYWORDS : ('Designer'|'Name'|'Status'|'Testlevel'|'Tools'|'VersionCounter'); KEYWORDS_QUOTED : ('Design Contact'|'Design Department'|'Estimated Duration [min]'|'Execution Priority'|'Test Comment'); OPERATOR_EQUAL : ('='|'!='); OPERATOR_REL : ('<'|'>'|'<='|'>='); OPERATOR_HAS : ('has'|'hasnot'); STRING : (SINGLE_QUOTED_STRING | DOUBLE_QUOTED_STRING); SINGLE_QUOTED_STRING : '\'' ~('\t'|'\r'|'\n'|'\'')* '\''; DOUBLE_QUOTED_STRING : '"' ~('\t'|'\r'|'\n'|'"')* '"'; NUMBER : [0-9]+; BOOLEAN : ('True'|'False'); LOGICAL : ('and'|'or'); WS : [ \t\r\n]+ -> skip; // skip spaces, tabs, newlines
src/Categories/Category/Monoidal/Utilities.agda
MirceaS/agda-categories
0
798
{-# OPTIONS --without-K --safe #-} open import Categories.Category using (Category) open import Categories.Category.Monoidal.Core using (Monoidal) module Categories.Category.Monoidal.Utilities {o ℓ e} {C : Category o ℓ e} (M : Monoidal C) where open import Level open import Function using (_$_) open import Data.Product using (_×_; _,_; curry′) open import Categories.Category.Product open import Categories.Functor renaming (id to idF) open import Categories.Functor.Bifunctor using (Bifunctor; appˡ; appʳ) open import Categories.Functor.Properties using ([_]-resp-≅) open import Categories.NaturalTransformation renaming (id to idN) open import Categories.NaturalTransformation.NaturalIsomorphism hiding (unitorˡ; unitorʳ; associator; _≃_) infixr 10 _⊗ᵢ_ open import Categories.Morphism C using (_≅_; module ≅) open import Categories.Morphism.IsoEquiv C using (_≃_; ⌞_⌟) open import Categories.Morphism.Isomorphism C using (_∘ᵢ_; lift-triangle′; lift-pentagon′) open import Categories.Morphism.Reasoning C private module C = Category C open C hiding (id; identityˡ; identityʳ; assoc) open Commutation private variable X Y Z W A B : Obj f g h i a b : X ⇒ Y open Monoidal M module ⊗ = Functor ⊗ -- for exporting, it makes sense to use the above long names, but for -- internal consumption, the traditional (short!) categorical names are more -- convenient. However, they are not symmetric, even though the concepts are, so -- we'll use ⇒ and ⇐ arrows to indicate that module Shorthands where λ⇒ = unitorˡ.from λ⇐ = unitorˡ.to ρ⇒ = unitorʳ.from ρ⇐ = unitorʳ.to -- eta expansion fixes a problem in 2.6.1, will be reported α⇒ = λ {X} {Y} {Z} → associator.from {X} {Y} {Z} α⇐ = λ {X} {Y} {Z} → associator.to {X} {Y} {Z} open Shorthands private [x⊗y]⊗z : Bifunctor (Product C C) C C [x⊗y]⊗z = ⊗ ∘F (⊗ ⁂ idF) -- note how this one needs re-association to typecheck (i.e. be correct) x⊗[y⊗z] : Bifunctor (Product C C) C C x⊗[y⊗z] = ⊗ ∘F (idF ⁂ ⊗) ∘F assocˡ _ _ _ unitor-coherenceʳ : [ (A ⊗₀ unit) ⊗₀ unit ⇒ A ⊗₀ unit ]⟨ ρ⇒ ⊗₁ C.id ≈ ρ⇒ ⟩ unitor-coherenceʳ = cancel-fromˡ unitorʳ unitorʳ-commute-from unitor-coherenceˡ : [ unit ⊗₀ unit ⊗₀ A ⇒ unit ⊗₀ A ]⟨ C.id ⊗₁ λ⇒ ≈ λ⇒ ⟩ unitor-coherenceˡ = cancel-fromˡ unitorˡ unitorˡ-commute-from -- All the implicits below can be inferred, but being explicit is clearer unitorˡ-naturalIsomorphism : NaturalIsomorphism (unit ⊗-) idF unitorˡ-naturalIsomorphism = record { F⇒G = ntHelper record { η = λ X → λ⇒ {X} ; commute = λ f → unitorˡ-commute-from {f = f} } ; F⇐G = ntHelper record { η = λ X → λ⇐ {X} ; commute = λ f → unitorˡ-commute-to {f = f} } ; iso = λ X → unitorˡ.iso {X} } unitorʳ-naturalIsomorphism : NaturalIsomorphism (-⊗ unit) idF unitorʳ-naturalIsomorphism = record { F⇒G = ntHelper record { η = λ X → ρ⇒ {X} ; commute = λ f → unitorʳ-commute-from {f = f} } ; F⇐G = ntHelper record { η = λ X → ρ⇐ {X} ; commute = λ f → unitorʳ-commute-to {f = f} } ; iso = λ X → unitorʳ.iso {X} } -- skipping the explicit arguments here, it does not increase understandability associator-naturalIsomorphism : NaturalIsomorphism [x⊗y]⊗z x⊗[y⊗z] associator-naturalIsomorphism = record { F⇒G = ntHelper record { η = λ { ((X , Y) , Z) → α⇒ {X} {Y} {Z}} ; commute = λ _ → assoc-commute-from } ; F⇐G = ntHelper record { η = λ _ → α⇐ ; commute = λ _ → assoc-commute-to } ; iso = λ _ → associator.iso } module unitorˡ-natural = NaturalIsomorphism unitorˡ-naturalIsomorphism module unitorʳ-natural = NaturalIsomorphism unitorʳ-naturalIsomorphism module associator-natural = NaturalIsomorphism associator-naturalIsomorphism _⊗ᵢ_ : X ≅ Y → Z ≅ W → X ⊗₀ Z ≅ Y ⊗₀ W f ⊗ᵢ g = [ ⊗ ]-resp-≅ record { from = from f , from g ; to = to f , to g ; iso = record { isoˡ = isoˡ f , isoˡ g ; isoʳ = isoʳ f , isoʳ g } } where open _≅_ triangle-iso : ≅.refl ⊗ᵢ unitorˡ ∘ᵢ associator ≃ unitorʳ {X} ⊗ᵢ ≅.refl {Y} triangle-iso = lift-triangle′ triangle pentagon-iso : ≅.refl ⊗ᵢ associator ∘ᵢ associator ∘ᵢ associator {X} {Y} {Z} ⊗ᵢ ≅.refl {W} ≃ associator ∘ᵢ associator pentagon-iso = lift-pentagon′ pentagon refl⊗refl≃refl : ≅.refl {A} ⊗ᵢ ≅.refl {B} ≃ ≅.refl refl⊗refl≃refl = ⌞ ⊗.identity ⌟
libsrc/_DEVELOPMENT/l/sdcc/__rlslonglong.asm
jpoikela/z88dk
640
163939
<gh_stars>100-1000 SECTION code_clib SECTION code_l_sdcc PUBLIC __rlslonglong EXTERN __rlulonglong defc __rlslonglong = __rlulonglong
examples/hello.asm
x86128/pymesm
2
4433
<filename>examples/hello.asm # hello world using loop org 1 ptr prn0 32767 # loop setup vtm -15,2 lbl loop xta hello+15,2 atx prn0 vlm loop,2 stop 0o12345,6 dorg 0o2000 arr hello "Hello, world!!!\n"
programs/oeis/189/A189786.asm
karttu/loda
1
244713
; A189786: n+[nr/t]+[ns/t]; r=pi/2, s=arcsin(5/13), t=arcsin(12/13). ; 2,4,8,10,12,16,18,20,24,26,28,32,34,36,40,42,44,48,50,52,56,58,60,64,66,68,72,74,76,80,82,84,88,90,92,96,98,100,104,106,108,112,114,116,120,122,124,128,130,132,136,138,140,144,146,148,152,154,156,160,162,164,168,170,172,176,178,180,184,186,188,192,194,196,200,202,204 add $0,1 mul $0,4 div $0,3 mov $1,$0 mul $1,2
oeis/225/A225658.asm
neoneye/loda-programs
11
177424
<reponame>neoneye/loda-programs ; A225658: a(n) = n! + (n+1)! + 3*(n+2)!. ; Submitted by <NAME>(s4) ; 8,21,80,390,2304,15960,126720,1134000,11289600,123742080,1480550400,19199980800,268240896000,4016428416000,64163222323200,1089292748544000,19583731335168000,371693362360320000,7426753498644480000,155827373623713792000,3425526027512709120000,78731141886604247040000,1888321222666380902400000,47179930548465082368000000,1226006041824881132175360000,33085411022424993103872000000,925957194746686539300864000000,26841063195281238076293120000000,804905229774924591723970560000000 mov $1,1 mov $2,1 lpb $0 add $1,2 add $2,7 add $2,$1 mul $1,$0 sub $0,1 add $1,$2 add $2,$1 lpe mov $0,$1 add $0,7
alloy4fun_models/trainstlt/models/0/KavcJqrLP5bghEq4Y.als
Kaixi26/org.alloytools.alloy
0
1733
<filename>alloy4fun_models/trainstlt/models/0/KavcJqrLP5bghEq4Y.als open main pred idKavcJqrLP5bghEq4Y_prop1 { } pred __repair { idKavcJqrLP5bghEq4Y_prop1 } check __repair { idKavcJqrLP5bghEq4Y_prop1 <=> prop1o }
programs/oeis/028/A028290.asm
neoneye/loda
22
90584
; A028290: Expansion of 1/((1-x)(1-x^2)(1-x^3)(1-x^5)(1-x^8)). ; 1,1,2,3,4,6,8,10,14,17,22,27,33,40,48,57,68,79,93,107,124,142,162,184,209,235,265,296,331,368,409,452,500,550,605,663,726,792,864,939,1021,1106,1198,1294,1397,1505,1620,1740,1869,2002,2145,2293,2450,2614,2787,2967,3158,3355,3564,3780,4008,4244,4492,4749,5019,5298,5591,5893,6210,6537,6879,7232,7601,7981,8378,8787,9213,9652,10109,10579,11069,11572,12095,12633,13191,13765,14360,14971,15605,16255,16929,17620,18335,19069,19827,20605,21409,22232,23083,23954 lpb $0 mov $2,$0 seq $2,29040 ; Expansion of 1/((1-x)(1-x^3)(1-x^5)(1-x^8)). mov $3,$0 sub $3,2 mov $0,$3 add $1,$2 lpe add $1,1 mov $0,$1
alloy4fun_models/trashltl/models/19/Q36Yv4KzdESTaSW4S.als
Kaixi26/org.alloytools.alloy
0
2877
<reponame>Kaixi26/org.alloytools.alloy<filename>alloy4fun_models/trashltl/models/19/Q36Yv4KzdESTaSW4S.als open main pred idQ36Yv4KzdESTaSW4S_prop20 { always all t: File | t not in Protected since t in Protected } pred __repair { idQ36Yv4KzdESTaSW4S_prop20 } check __repair { idQ36Yv4KzdESTaSW4S_prop20 <=> prop20o }
src/util-log.ads
Letractively/ada-util
0
11249
<gh_stars>0 ----------------------------------------------------------------------- -- Logs -- Utility Log Package -- Copyright (C) 2001, 2002, 2003, 2006, 2008, 2009, 2010, 2011 <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. ----------------------------------------------------------------------- -- The <b>Util.Log</b> package provides a simple logging framework inspired -- from the Java Log4j library. package Util.Log is pragma Preelaborate; subtype Level_Type is Natural; FATAL_LEVEL : constant Level_Type := 0; ERROR_LEVEL : constant Level_Type := 5; WARN_LEVEL : constant Level_Type := 7; INFO_LEVEL : constant Level_Type := 10; DEBUG_LEVEL : constant Level_Type := 20; -- Get the log level name. function Get_Level_Name (Level : Level_Type) return String; -- Get the log level from the property value function Get_Level (Value : in String; Default : in Level_Type := INFO_LEVEL) return Level_Type; end Util.Log;
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/discr36_pkg.adb
best08618/asylo
7
18567
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/discr36_pkg.adb package body Discr36_Pkg is function Func return T is Ret : T; pragma Warnings (Off, Ret); begin return Ret; end; end Discr36_Pkg;
examples/simple-lib/Lib/Maybe.agda
shlevy/agda
1,989
3052
<gh_stars>1000+ module Lib.Maybe where data Maybe (A : Set) : Set where nothing : Maybe A just : A -> Maybe A {-# COMPILE GHC Maybe = data Maybe (Nothing | Just) #-}
oeis/280/A280220.asm
neoneye/loda-programs
11
168064
; A280220: a(1) = 1, a(n+1) is the numerator of n-th partial fraction of the continued fraction [1; 4, 16, 64, ..., 4^n]. ; Submitted by <NAME>(s4) ; 1,5,81,5189,1328465,1360353349,5572008645969,91291791015909445,5982898821590650033489,1568381028778351153394849861,1644566705638271237843748737881425,6897812711726991987001765057444407253061,115726093792191122162903443021235072225308939601,7766246689551405177050384729835800575763492430074976325,2084735971518221999868374552120032095583578659854796609299518801,2238468204616387747141842941059951506300838824515765462181773109783009349 mov $1,$0 add $1,1 mov $2,1 mov $3,1 lpb $1 mov $0,$4 sub $1,1 mov $4,$2 mul $2,3 add $2,$4 mul $4,$3 add $0,$4 gcd $4,$3 mov $3,$0 lpe
payload/Library/Application Support/spsu/spsu.applescript
aysiu/spsu
2
1853
<gh_stars>1-10 #!/usr/bin/osascript -- Open System Preferences and go to the Software Update prefPane tell application "System Preferences" activate set the current pane to pane id "com.apple.preferences.softwareupdate" end tell tell application "System Preferences" reveal pane id "com.apple.preferences.softwareupdate" end tell tell application "System Events" -- Wait a few seconds, just in case there's a delay in the UI delay 15 -- Look for an update button set update_now to a reference to (UI element "Update Now" of group 1 of window "Software Update" of application process "System Preferences") -- If the update button exists, click it if update_now exists then click update_now -- Wait a few seconds, just in case there's a delay in the UI delay 4 -- In the new window that appears, see if there's a Download & Restart button set download_now to a reference to (UI element "Download & Restart" of sheet 1 of window "Software Update" of application process "System Preferences" of application "System Events") -- If there is, click it. When this script runs again later, it may actually be able to install the already downloaded update if download_now exists then click download_now else -- See if the restart button to install the downloaded and pending update set restart_now to a reference to (UI element "Restart" of sheet 1 of window "Software Update" of application process "System Preferences" of application "System Events") if restart_now exists then click restart_now end if end if end if end tell
oeis/299/A299284.asm
neoneye/loda-programs
11
98955
<filename>oeis/299/A299284.asm ; A299284: Partial sums of A299283. ; 1,8,30,78,162,292,478,731,1061,1478,1992,2614,3354,4222,5228,6383,7697,9180,10842,12694,14746,17008,19490,22203,25157,28362,31828,35566,39586,43898,48512,53439,58689,64272,70198,76478,83122,90140,97542,105339,113541,122158,131200,140678,150602,160982,171828,183151,194961,207268,220082,233414,247274,261672,276618,292123,308197,324850,342092,359934,378386,397458,417160,437503,458497,480152,502478,525486,549186,573588,598702,624539,651109,678422,706488,735318,764922,795310,826492,858479,891281 lpb $0 mov $2,$0 sub $0,1 seq $2,299283 ; Coordination sequence for "svh" 3D uniform tiling. add $1,$2 lpe add $1,1 mov $0,$1
Task/Pascals-triangle-Puzzle/Ada/pascals-triangle-puzzle.ada
LaudateCorpus1/RosettaCodeData
1
9841
<gh_stars>1-10 with Ada.Text_IO; use Ada.Text_IO; procedure Pyramid_of_Numbers is B_X, B_Y, B_Z : Integer := 0; -- Unknown variables type Block_Value is record Known : Integer := 0; X, Y, Z : Integer := 0; end record; X : constant Block_Value := (0, 1, 0, 0); Y : constant Block_Value := (0, 0, 1, 0); Z : constant Block_Value := (0, 0, 0, 1); procedure Add (L : in out Block_Value; R : Block_Value) is begin -- Symbolically adds one block to another L.Known := L.Known + R.Known; L.X := L.X + R.X - R.Z; -- Z is excluded as n(Y - X - Z) = 0 L.Y := L.Y + R.Y + R.Z; end Add; procedure Add (L : in out Block_Value; R : Integer) is begin -- Symbolically adds a value to the block L.Known := L.Known + R; end Add; function Image (N : Block_Value) return String is begin -- The block value, when X,Y,Z are known return Integer'Image (N.Known + N.X * B_X + N.Y * B_Y + N.Z * B_Z); end Image; procedure Solve_2x2 (A11, A12, B1, A21, A22, B2 : Integer) is begin -- Don't care about things, supposing an integer solution exists if A22 = 0 then B_X := B2 / A21; B_Y := (B1 - A11*B_X) / A12; else B_X := (B1*A22 - B2*A12) / (A11*A22 - A21*A12); B_Y := (B1 - A11*B_X) / A12; end if; B_Z := B_Y - B_X; end Solve_2x2; B : array (1..5, 1..5) of Block_Value; -- The lower triangle contains blocks begin -- The bottom blocks Add (B(5,1),X); Add (B(5,2),11); Add (B(5,3),Y); Add (B(5,4),4); Add (B(5,5),Z); -- Upward run for Row in reverse 1..4 loop for Column in 1..Row loop Add (B (Row, Column), B (Row + 1, Column)); Add (B (Row, Column), B (Row + 1, Column + 1)); end loop; end loop; -- Now have known blocks 40=(3,1), 151=(1,1) and Y=X+Z to determine X,Y,Z Solve_2x2 ( B(1,1).X, B(1,1).Y, 151 - B(1,1).Known, B(3,1).X, B(3,1).Y, 40 - B(3,1).Known ); -- Print the results for Row in 1..5 loop New_Line; for Column in 1..Row loop Put (Image (B(Row,Column))); end loop; end loop; end Pyramid_of_Numbers;
DSTROUT.asm
CodexLink/8086_ASM_DOSBOX_Examples
0
25699
; Double String Output — DSTROUT.asm ; Copyright (c) 2021 <NAME> ; This code is licensed under MIT license. (see LICENSE for details) .MODEL TINY .DATA DDISP_PROMPT DB 0AH, 0DH, "Enter a string: $" DDISP_INPUT DB 16, ?, 16 DUP(?) ; We assume that the max input is 16 characters, since it's not indicated. .CODE MOV AX, @DATA ; Place All Data Segments to AX for awhile. MOV DS, AX ; Then move it to DS with respect to Data Segments. MOV AH, 09H ; Output String Mode. LEA DX, DDISP_PROMPT ; Refer to DDISP_PROMPT's Pointer to Print. INT 21H ; Print it. MOV AH, 0AH ; String Input Mode. LEA DX, DDISP_INPUT ; Place the String Input to DDISP_INPUT (By Reference) INT 21H ; Put it in. MOV BL, [DDISP_INPUT + 1] ; Get Length of Container by the First Byte. MOV [DDISP_INPUT + BX + 2], "$" ; Modify End String by Base Address + Length + 2 Bytes of Container. MOV AH, 02H ; Character Output Mode. MOV DL, 0AH ; Output NL before Outputting the Input String Twice. INT 21H ; We don't wanna complicate ourselves so just soft-append it. Print it btw. MOV AH, 09H ; Output String Mode. LEA DX, [DDISP_INPUT + 2] ; Refer to the Actual String Input Data. No need to overcomplicate. INT 21H ; Explicitly Print the Input String Once. INT 21H ; Make it two. MOV AX, 4C00H ; Perform Termination INT 21H ; Done. END
programs/oeis/166/A166521.asm
neoneye/loda
22
85255
; A166521: a(n) = (6*n + 7*(-1)^n + 3)/2. ; 1,11,7,17,13,23,19,29,25,35,31,41,37,47,43,53,49,59,55,65,61,71,67,77,73,83,79,89,85,95,91,101,97,107,103,113,109,119,115,125,121,131,127,137,133,143,139,149,145,155,151,161,157,167,163,173,169,179,175,185,181,191,187,197,193,203,199,209,205,215,211,221,217,227,223,233,229,239,235,245,241,251,247,257,253,263,259,269,265,275,271,281,277,287,283,293,289,299,295,305 mov $1,10 mul $1,$0 div $0,2 mul $0,14 add $1,1 sub $1,$0 mov $0,$1
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0_notsx.log_21829_1439.asm
ljhsiun2/medusa
9
80913
<reponame>ljhsiun2/medusa .global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %rax push %rcx push %rdi push %rsi lea addresses_normal_ht+0x1b2df, %r10 nop cmp $62436, %r11 mov (%r10), %r12d nop cmp $34522, %rax lea addresses_normal_ht+0x7177, %rsi lea addresses_D_ht+0x126df, %rdi nop nop nop nop and $56531, %rax mov $105, %rcx rep movsw nop nop nop nop nop inc %rcx pop %rsi pop %rdi pop %rcx pop %rax pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r8 push %rax push %rbp push %rcx push %rdi push %rdx push %rsi // Store lea addresses_D+0x13edf, %r12 clflush (%r12) nop cmp %r8, %r8 movw $0x5152, (%r12) nop sub $22662, %r14 // Load lea addresses_A+0x75df, %r12 nop nop nop nop xor %rbp, %rbp mov (%r12), %r11 nop nop sub %r11, %r11 // Store lea addresses_UC+0x1c6df, %rdx nop nop nop nop add $42455, %r11 mov $0x5152535455565758, %r14 movq %r14, %xmm7 movups %xmm7, (%rdx) nop add $58098, %rax // Store lea addresses_WC+0x82c7, %r12 nop nop nop nop nop xor $5065, %r11 mov $0x5152535455565758, %rdx movq %rdx, %xmm6 movups %xmm6, (%r12) nop nop xor $10258, %rbp // REPMOV lea addresses_WT+0x1f5fc, %rsi lea addresses_D+0x1c77f, %rdi nop nop nop inc %r8 mov $58, %rcx rep movsb nop nop nop xor $56053, %r14 // Store lea addresses_normal+0x1c2df, %r8 nop nop inc %rdi movw $0x5152, (%r8) xor %rdi, %rdi // Faulty Load lea addresses_A+0x1fedf, %rdx nop nop dec %r14 movups (%rdx), %xmm4 vpextrq $0, %xmm4, %r8 lea oracles, %rbp and $0xff, %r8 shlq $12, %r8 mov (%rbp,%r8,1), %r8 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r8 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_A', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 6}} {'src': {'type': 'addresses_A', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 7}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 10}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}} {'src': {'type': 'addresses_WT', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D', 'congruent': 5, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': True, 'size': 2, 'NT': False, 'same': False, 'congruent': 9}} [Faulty Load] {'src': {'type': 'addresses_A', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 10}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 10, 'same': False}} {'35': 21829} 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
src/Unbounded-space.agda
nad/definitional-interpreters
0
9529
------------------------------------------------------------------------ -- Definitional interpreters can model systems with unbounded space ------------------------------------------------------------------------ -- As a follow-up to the development in Bounded-space I asked Ancona, -- Dagnino and Zucca for further examples of properties for which it -- is not clear to them if definitional interpreters work well. They -- asked for a semantics that returns the largest heap size used by -- the program, or infinity if there is no bound on this size. They -- also asked how one can prove that a program transformation does not -- increase the maximum heap usage. -- It is impossible to write an Agda program that computes the maximum -- heap usage, but one can at least produce a potentially infinite -- list containing all heap sizes encountered in the execution of a -- program, and then reason about this list. This approach is taken -- below. module Unbounded-space where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude open import Tactic.By.Propositional open import Prelude.Size open import Colist equality-with-J as Colist open import Conat equality-with-J as Conat hiding (pred) renaming (_+_ to _⊕_) open import Function-universe equality-with-J as F hiding (_∘_) open import Nat equality-with-J as Nat using (_≤_; _≤↑_; pred) open import Omniscience equality-with-J open import Only-allocation open import Upper-bounds ------------------------------------------------------------------------ -- Definitional interpreter -- Modifies the heap size according to the given instruction. modify : Stmt → ℕ → ℕ modify alloc = suc modify dealloc = pred -- A definitional interpreter. It returns a trace of all heap sizes -- encountered during the program's run. The input is the initial heap -- size. mutual ⟦_⟧ : ∀ {i} → Program i → ℕ → Colist ℕ i ⟦ p ⟧ h = h ∷ ⟦ p ⟧′ h ⟦_⟧′ : ∀ {i} → Program i → ℕ → Colist′ ℕ i ⟦ [] ⟧′ h .force = [] ⟦ s ∷ p ⟧′ h .force = ⟦ p .force ⟧ (modify s h) ------------------------------------------------------------------------ -- The maximum heap usage predicate -- The smallest heap size that is required to run the given program -- when the initial heap is empty. Heap-usage : Program ∞ → Conat ∞ → Type Heap-usage p n = LUB (⟦ p ⟧ 0) n -- The smallest extra heap size that is required to run the given -- program, for arbitrary initial heaps. Heap-usage′ : Program ∞ → Conat ∞ → Type Heap-usage′ p n = (∀ h → [ ∞ ] ⟦ p ⟧ h ⊑ n ⊕ ⌜ h ⌝) × (∀ n′ → (∀ h → [ ∞ ] ⟦ p ⟧ h ⊑ n′ ⊕ ⌜ h ⌝) → [ ∞ ] n ≤ n′) -- The number n is an upper bound of the heap size required for a -- program when it is started with an empty heap iff, for any initial -- heap h, n plus the size of h is an upper bound. -- -- Note that this kind of property might not hold for a more -- complicated programming language, in which a program's actions -- could depend on the contents of the initial heap. ∀⟦⟧⊑⇔⟦⟧⊑ : ∀ {p n i} → [ i ] ⟦ p ⟧ 0 ⊑ n ⇔ (∀ h → [ i ] ⟦ p ⟧ h ⊑ n ⊕ ⌜ h ⌝) ∀⟦⟧⊑⇔⟦⟧⊑ {p} {n} {i} = record { to = to p ; from = (∀ h → [ i ] ⟦ p ⟧ h ⊑ n ⊕ ⌜ h ⌝) ↝⟨ _$ 0 ⟩ [ i ] ⟦ p ⟧ 0 ⊑ n ⊕ ⌜ 0 ⌝ ↝⟨ flip transitive-⊑≤ (∼→≤ (+-right-identity _)) ⟩□ [ i ] ⟦ p ⟧ 0 ⊑ n □ } where +⊕-cong : ∀ {m₁ m₂ n i} → [ i ] ⌜ m₁ ⌝ ≤ m₂ → [ i ] ⌜ m₁ + n ⌝ ≤ m₂ ⊕ ⌜ n ⌝ +⊕-cong {m₁} {m₂} {n} {i} = [ i ] ⌜ m₁ ⌝ ≤ m₂ ↝⟨ _+-mono reflexive-≤ _ ⟩ [ i ] ⌜ m₁ ⌝ ⊕ ⌜ n ⌝ ≤ m₂ ⊕ ⌜ n ⌝ ↝⟨ transitive-≤ (∼→≤ (⌜⌝-+ m₁)) ⟩□ [ i ] ⌜ m₁ + n ⌝ ≤ m₂ ⊕ ⌜ n ⌝ □ to : ∀ {m i} p → [ i ] ⟦ p ⟧ m ⊑ n → ∀ h → [ i ] ⟦ p ⟧ (m + h) ⊑ n ⊕ ⌜ h ⌝ to [] (m≤n ∷ _) _ = +⊕-cong m≤n ∷ λ { .force → [] } to (s ∷ p) (m≤n ∷ p⊑) h = +⊕-cong m≤n ∷ λ { .force → to′ _ s (force p⊑) } where to′ : ∀ {i} m s → [ i ] ⟦ force p ⟧ (modify s m) ⊑ n → [ i ] ⟦ force p ⟧ (modify s (m + h)) ⊑ n ⊕ ⌜ h ⌝ to′ _ alloc p⊑ = to (force p) p⊑ h to′ (suc m) dealloc p⊑ = to (force p) p⊑ h to′ zero dealloc p⊑ = transitive-⊑≤ (to (force p) p⊑ (pred h)) (reflexive-≤ n +-mono ⌜⌝-mono (Nat.pred≤ _)) -- Heap-usage p n holds iff Heap-usage′ p n holds. For this reason the -- former, less complicated definition will be used below. Heap-usage⇔Heap-usage′ : ∀ p n → Heap-usage p n ⇔ Heap-usage′ p n Heap-usage⇔Heap-usage′ p n = ([ ∞ ] ⟦ p ⟧ 0 ⊑ n ↝⟨ ∀⟦⟧⊑⇔⟦⟧⊑ ⟩□ (∀ h → [ ∞ ] ⟦ p ⟧ h ⊑ n ⊕ ⌜ h ⌝) □) ×-cong ((∀ n′ → [ ∞ ] ⟦ p ⟧ 0 ⊑ n′ → [ ∞ ] n ≤ n′) ↝⟨ ∀-cong _ (λ _ → →-cong _ ∀⟦⟧⊑⇔⟦⟧⊑ F.id) ⟩□ (∀ n′ → (∀ h → [ ∞ ] ⟦ p ⟧ h ⊑ n′ ⊕ ⌜ h ⌝) → [ ∞ ] n ≤ n′) □) -- The maximum heap usage is unique (up to bisimilarity). max-unique : ∀ {p m n i} → Heap-usage p m → Heap-usage p n → Conat.[ i ] m ∼ n max-unique = lub-unique -- Heap-usage p respects bisimilarity. max-respects-∼ : ∀ {p q m n} → Colist.[ ∞ ] ⟦ p ⟧ 0 ∼ ⟦ q ⟧ 0 → Conat.[ ∞ ] m ∼ n → Heap-usage p m → Heap-usage q n max-respects-∼ {p} {q} {m} {n} p∼q m∼n = Σ-map ([ ∞ ] ⟦ p ⟧ 0 ⊑ m ↝⟨ (λ hyp → transitive-⊑≤ (□-∼ p∼q hyp) (∼→≤ m∼n)) ⟩□ [ ∞ ] ⟦ q ⟧ 0 ⊑ n □) ((∀ o → [ ∞ ] ⟦ p ⟧ 0 ⊑ o → [ ∞ ] m ≤ o) ↝⟨ (λ hyp₁ o hyp₂ → transitive-≤ (∼→≤ (Conat.symmetric-∼ m∼n)) (hyp₁ o (□-∼ (Colist.symmetric-∼ p∼q) hyp₂))) ⟩□ (∀ o → [ ∞ ] ⟦ q ⟧ 0 ⊑ o → [ ∞ ] n ≤ o) □) -- If the semantics of a program started in the empty heap does not -- have a finite upper bound, then the maximum heap usage of the -- program is infinity. no-finite-max→infinite-max : ∀ p → (∀ n → ¬ [ ∞ ] ⟦ p ⟧ 0 ⊑ ⌜ n ⌝) → Heap-usage p infinity no-finite-max→infinite-max p hyp = (⟦ p ⟧ 0 ⊑infinity) , λ n′ → [ ∞ ] ⟦ p ⟧ 0 ⊑ n′ ↝⟨ no-finite→infinite hyp ⟩ Conat.[ ∞ ] n′ ∼ infinity ↝⟨ ∼→≤ ∘ Conat.symmetric-∼ ⟩□ [ ∞ ] infinity ≤ n′ □ -- If the maximum heap usage could always be determined (in a certain -- sense), then WLPO (which is a constructive taboo) would hold. max→wlpo : (∀ p → ∃ λ n → Heap-usage p n) → WLPO max→wlpo find-max = λ f → case find-max (p f) of λ where (zero , max-0) → inj₁ (_⇔_.to 0⇔≡false max-0) (suc _ , max-+) → inj₂ (+→≢false max-+) where -- If f takes the value true, then p f contains exactly one -- occurrence of alloc, at the first index for which f takes the -- value true. Otherwise p f contains zero occurrences of alloc. p : ∀ {i} → (ℕ → Bool) → Program i p f = helper (f 0) module P where helper : ∀ {i} → Bool → Program i helper = if_then alloc ∷′ [] else dealloc ∷ λ { .force → p (λ n → f (1 + n)) } -- The maximum heap usage of p f is zero iff f always takes the -- value false. 0⇔≡false : ∀ {f} → Heap-usage (p f) ⌜ 0 ⌝ ⇔ (∀ n → f n ≡ false) 0⇔≡false = record { to = →≡false _ ∘ proj₁ ; from = λ ≡false → ≡false→ _ ≡false Nat.≤-refl , (λ _ _ → zero) } where →≡false : ∀ f → [ ∞ ] ⟦ p f ⟧ 0 ⊑ ⌜ 0 ⌝ → ∀ n → f n ≡ false →≡false f ⟦pf⟧0⊑0 _ = helper _ _ refl ⟦pf⟧0⊑0 where helper : ∀ b n → f 0 ≡ b → [ ∞ ] ⟦ P.helper f b ⟧ 0 ⊑ ⌜ 0 ⌝ → f n ≡ false helper false zero f0≡false = λ _ → f0≡false helper false (suc n) _ = [ ∞ ] ⟦ P.helper f false ⟧ 0 ⊑ ⌜ 0 ⌝ ↝⟨ □-tail ⟩ [ ∞ ] ⟦ p (f ∘ suc) ⟧ 0 ⊑ ⌜ 0 ⌝ ↝⟨ (λ hyp → →≡false (f ∘ suc) hyp n) ⟩□ (f ∘ suc) n ≡ false □ helper true n _ = [ ∞ ] ⟦ P.helper f true ⟧ 0 ⊑ ⌜ 0 ⌝ ↝⟨ □-head ∘ □-tail ⟩ ([ ∞ ] ⌜ 1 ⌝ ≤ ⌜ 0 ⌝) ↝⟨ ⌜⌝-mono⁻¹ ⟩ 1 ≤ 0 ↝⟨ Nat.+≮ 0 ⟩ ⊥ ↝⟨ ⊥-elim ⟩□ f n ≡ false □ ≡false→ : ∀ {m n i} f → (∀ n → f n ≡ false) → m ≤ n → [ i ] ⟦ p f ⟧ m ⊑ ⌜ n ⌝ ≡false→ {m} {n} f ≡false m≤n with f 0 | ≡false 0 ... | true | () ... | false | _ = zero +-mono ⌜⌝-mono m≤n ∷ λ { .force → ≡false→ (f ∘ suc) (≡false ∘ suc) ( pred m Nat.≤⟨ Nat.pred≤ _ ⟩ m Nat.≤⟨ m≤n ⟩∎ n ∎≤) } -- If the maximum heap usage of p f is positive, then f does not -- always take the value false. +→≢false : ∀ {f n} → Heap-usage (p f) (suc n) → ¬ (∀ n → f n ≡ false) +→≢false {f} {n} = Heap-usage (p f) (suc n) ↝⟨ (λ max-+ → Heap-usage (p f) ⌜ 0 ⌝ ↝⟨ max-unique max-+ ⟩ Conat.[ ∞ ] suc n ∼ ⌜ 0 ⌝ ↝⟨ (λ ()) ⟩□ ⊥ □) ⟩ ¬ Heap-usage (p f) ⌜ 0 ⌝ ↝⟨ (λ hyp ≡false → hyp (_⇔_.from 0⇔≡false ≡false)) ⟩□ ¬ (∀ n → f n ≡ false) □ -- In fact, WLPO is logically equivalent to a certain formulation of -- "the maximum heap usage can always be determined". wlpo⇔max : WLPO ⇔ (∀ p → ∃ λ n → Heap-usage p n) wlpo⇔max = record { to = λ wlpo p → wlpo→lub wlpo (⟦ p ⟧ 0) ; from = max→wlpo } -- We also get that WLPO is logically equivalent to a certain -- formulation of "least upper bounds of colists of natural numbers -- can always be determined". wlpo⇔lub : WLPO ⇔ (∀ ms → ∃ λ n → LUB ms n) wlpo⇔lub = record { to = wlpo→lub ; from = λ find-lub → max→wlpo (λ p → find-lub (⟦ p ⟧ 0)) } ------------------------------------------------------------------------ -- Some examples -- When this semantics is used all three programs are non-terminating, -- in the sense that their traces are infinitely long. bounded-loops : ∀ {i n} → Conat.[ i ] length (⟦ bounded ⟧ n) ∼ infinity bounded-loops = suc λ { .force → suc λ { .force → bounded-loops }} bounded₂-loops : ∀ {i n} → Conat.[ i ] length (⟦ bounded₂ ⟧ n) ∼ infinity bounded₂-loops = suc λ { .force → suc λ { .force → suc λ { .force → suc λ { .force → bounded₂-loops }}}} unbounded-loops : ∀ {i n} → Conat.[ i ] length (⟦ unbounded ⟧ n) ∼ infinity unbounded-loops = suc λ { .force → unbounded-loops } -- Zero is not an upper bound of the semantics of bounded when it is -- started with an empty heap. ⟦bounded⟧⋢0 : ¬ [ ∞ ] ⟦ bounded ⟧ 0 ⊑ ⌜ 0 ⌝ ⟦bounded⟧⋢0 = [ ∞ ] ⟦ bounded ⟧ 0 ⊑ ⌜ 0 ⌝ ↝⟨ □-head ∘ □-tail ⟩ [ ∞ ] ⌜ 1 ⌝ ≤ ⌜ 0 ⌝ ↝⟨ ⌜⌝-mono⁻¹ ⟩ (1 ≤ 0) ↝⟨ Nat.+≮ 0 ⟩□ ⊥ □ -- However, one is. ⟦bounded⟧⊑1 : ∀ {i} → [ i ] ⟦ bounded ⟧ 0 ⊑ ⌜ 1 ⌝ ⟦bounded⟧⊑1 = ≤suc ∷ λ { .force → reflexive-≤ _ ∷ λ { .force → ⟦bounded⟧⊑1 }} -- The maximum heap usage of bounded is 1. max-bounded-1 : Heap-usage bounded ⌜ 1 ⌝ max-bounded-1 = ⟦bounded⟧⊑1 , λ n′ → [ ∞ ] ⟦ bounded ⟧ 0 ⊑ n′ ↝⟨ □-head ∘ □-tail ⟩□ [ ∞ ] ⌜ 1 ⌝ ≤ n′ □ -- Two is an upper bound of the semantics of bounded₂ when it is -- started in an empty heap. ⟦bounded₂⟧⊑2 : ∀ {i} → [ i ] ⟦ bounded₂ ⟧ 0 ⊑ ⌜ 2 ⌝ ⟦bounded₂⟧⊑2 = zero ∷ λ { .force → suc (λ { .force → zero }) ∷ λ { .force → reflexive-≤ _ ∷ λ { .force → suc (λ { .force → zero }) ∷ λ { .force → ⟦bounded₂⟧⊑2 }}}} -- The maximum heap usage of bounded₂ is 2. max-bounded₂-2 : Heap-usage bounded₂ ⌜ 2 ⌝ max-bounded₂-2 = ⟦bounded₂⟧⊑2 , λ n′ → [ ∞ ] ⟦ bounded₂ ⟧ 0 ⊑ n′ ↝⟨ □-head ∘ □-tail ∘ □-tail ⟩□ [ ∞ ] ⌜ 2 ⌝ ≤ n′ □ -- There is no finite upper bound of the semantics of unbounded. ⟦unbounded⟧⋢⌜⌝ : ∀ {n} → ¬ [ ∞ ] ⟦ unbounded ⟧ 0 ⊑ ⌜ n ⌝ ⟦unbounded⟧⋢⌜⌝ {n} = helper (Nat.≤→≤↑ (Nat.zero≤ _)) where helper : ∀ {h} → h ≤↑ 1 + n → ¬ [ ∞ ] ⟦ unbounded ⟧ h ⊑ ⌜ n ⌝ helper (Nat.≤↑-refl refl) = [ ∞ ] ⟦ unbounded ⟧ (1 + n) ⊑ ⌜ n ⌝ ↝⟨ □-head ⟩ [ ∞ ] ⌜ 1 + n ⌝ ≤ ⌜ n ⌝ ↝⟨ ⌜⌝-mono⁻¹ ⟩ (1 + n ≤ n) ↝⟨ Nat.+≮ 0 ⟩□ ⊥ □ helper {h} (Nat.≤↑-step 1+h≤1+n) = [ ∞ ] ⟦ unbounded ⟧ h ⊑ ⌜ n ⌝ ↝⟨ □-tail ⟩ [ ∞ ] ⟦ unbounded ⟧ (1 + h) ⊑ ⌜ n ⌝ ↝⟨ helper 1+h≤1+n ⟩□ ⊥ □ -- The maximum heap usage of unbounded is infinity. max-unbounded-∞ : Heap-usage unbounded infinity max-unbounded-∞ = no-finite-max→infinite-max unbounded λ _ → ⟦unbounded⟧⋢⌜⌝ ------------------------------------------------------------------------ -- A simple optimiser -- An optimiser that replaces subsequences of the form "alloc, alloc, -- dealloc" with "alloc". opt : ∀ {i} → Program ∞ → Program i opt [] = [] opt (dealloc ∷ p) = dealloc ∷ λ { .force → opt (p .force) } opt {i} (alloc ∷ p) = opt₁ (p .force) module Opt where default : Program i default = alloc ∷ λ { .force → opt (p .force) } opt₂ : Program ∞ → Program i opt₂ (dealloc ∷ p″) = alloc ∷ λ { .force → opt (p″ .force) } opt₂ _ = default opt₁ : Program ∞ → Program i opt₁ (alloc ∷ p′) = opt₂ (p′ .force) opt₁ _ = default -- The semantics of opt bounded₂ matches that of bounded. opt-bounded₂∼bounded : ∀ {i n} → Colist.[ i ] ⟦ opt bounded₂ ⟧ n ∼ ⟦ bounded ⟧ n opt-bounded₂∼bounded = refl ∷ λ { .force → refl ∷ λ { .force → opt-bounded₂∼bounded }} -- Sometimes the optimised program's maximum heap usage is less than -- that of the original program. opt-improves : ∃ λ p → Heap-usage p ⌜ 2 ⌝ × Heap-usage (opt p) ⌜ 1 ⌝ opt-improves = bounded₂ , max-bounded₂-2 , max-respects-∼ (Colist.symmetric-∼ opt-bounded₂∼bounded) (_ ∎∼) max-bounded-1 -- The optimised program's maximum heap usage is at most as large as -- that of the original program (assuming that these maximums exist). mutual opt-correct : ∀ {i m n} p → Heap-usage (opt p) m → Heap-usage p n → [ i ] m ≤ n opt-correct p max₁ max₂ = _⇔_.to (≲⇔least-upper-bounds-≤ max₁ max₂) (opt-correct-≲ p) opt-correct-≲ : ∀ {h i} p → [ i ] ⟦ opt p ⟧ h ≲ ⟦ p ⟧ h opt-correct-≲ {h} [] = ⟦ opt [] ⟧ h ∼⟨ ∷∼∷′ ⟩≲ h ∷′ [] ∼⟨ Colist.symmetric-∼ ∷∼∷′ ⟩□≲ ⟦ [] ⟧ h opt-correct-≲ {h} (dealloc ∷ p) = ⟦ opt (dealloc ∷ p) ⟧ h ∼⟨ ∷∼∷′ ⟩≲ h ∷′ ⟦ opt (p .force) ⟧ (pred h) ≲⟨ (cons′-≲ λ { hyp .force → opt-correct-≲ (p .force) hyp }) ⟩ h ∷′ ⟦ p .force ⟧ (pred h) ∼⟨ Colist.symmetric-∼ ∷∼∷′ ⟩□≲ ⟦ dealloc ∷ p ⟧ h opt-correct-≲ {h} (alloc ∷ p) = ⟦ opt (alloc ∷ p) ⟧ h ≡⟨⟩≲ ⟦ Opt.opt₁ p (p .force) ⟧ h ≲⟨ opt-correct₁ _ refl ⟩ h ∷′ ⟦ p .force ⟧ (1 + h) ∼⟨ Colist.symmetric-∼ ∷∼∷′ ⟩□≲ ⟦ alloc ∷ p ⟧ h where default-correct : ∀ {p′ i} → p′ ≡ p .force → [ i ] ⟦ Opt.default p ⟧ h ≲ h ∷′ ⟦ p′ ⟧ (1 + h) default-correct refl = ⟦ Opt.default p ⟧ h ∼⟨ ∷∼∷′ ⟩≲ h ∷′ ⟦ opt (p .force) ⟧ (1 + h) ≲⟨ (cons′-≲ λ { hyp .force → opt-correct-≲ (p .force) hyp }) ⟩□ h ∷′ ⟦ p .force ⟧ (1 + h) opt-correct₁ : ∀ {i} p′ → p′ ≡ p .force → [ i ] ⟦ Opt.opt₁ p p′ ⟧ h ≲ h ∷′ ⟦ p′ ⟧ (1 + h) opt-correct₁ [] []≡ = default-correct []≡ opt-correct₁ (dealloc ∷ p′) d∷≡ = default-correct d∷≡ opt-correct₁ (alloc ∷ p′) a∷≡ = ⟦ Opt.opt₂ p (p′ .force) ⟧ h ≲⟨ opt-correct₂ (p′ .force) refl ⟩ h ∷′ 1 + h ∷′ ⟦ p′ .force ⟧ (2 + h) ∼⟨ (refl ∷ λ { .force → Colist.symmetric-∼ ∷∼∷′ }) ⟩□≲ h ∷′ ⟦ alloc ∷ p′ ⟧ (1 + h) where default-correct′ : ∀ {i p″} → p″ ≡ p′ .force → [ i ] ⟦ Opt.default p ⟧ h ≲ h ∷′ 1 + h ∷′ ⟦ p″ ⟧ (2 + h) default-correct′ refl = ⟦ Opt.default p ⟧ h ≲⟨ default-correct refl ⟩ h ∷′ ⟦ p .force ⟧ (1 + h) ≡⟨ by a∷≡ ⟩≲ h ∷′ ⟦ alloc ∷ p′ ⟧ (1 + h) ∼⟨ (refl ∷ λ { .force → ∷∼∷′ }) ⟩□≲ h ∷′ 1 + h ∷′ ⟦ p′ .force ⟧ (2 + h) opt-correct₂ : ∀ {i} p″ → p″ ≡ p′ .force → [ i ] ⟦ Opt.opt₂ p p″ ⟧ h ≲ h ∷′ 1 + h ∷′ ⟦ p″ ⟧ (2 + h) opt-correct₂ [] []≡ = default-correct′ []≡ opt-correct₂ (alloc ∷ p″) a∷≡ = default-correct′ a∷≡ opt-correct₂ (dealloc ∷ p″) _ = ⟦ Opt.opt₂ p (dealloc ∷ p″) ⟧ h ∼⟨ ∷∼∷′ ⟩≲ h ∷′ ⟦ opt (p″ .force) ⟧ (1 + h) ≲⟨ (cons′-≲ λ { hyp .force → opt-correct-≲ (p″ .force) hyp }) ⟩ h ∷′ ⟦ p″ .force ⟧ (1 + h) ≲⟨ (cons′-≲ λ { hyp .force → consʳ-≲ (consʳ-≲ (_ □≲)) hyp }) ⟩ h ∷′ 1 + h ∷′ 2 + h ∷′ ⟦ p″ .force ⟧ (1 + h) ∼⟨ (refl ∷ λ { .force → refl ∷ λ { .force → Colist.symmetric-∼ ∷∼∷′ } }) ⟩□≲ h ∷′ 1 + h ∷′ ⟦ dealloc ∷ p″ ⟧ (2 + h)
src/test/ref/keyboard-glitch.asm
jbrandwood/kickc
2
85012
<reponame>jbrandwood/kickc // Exploring keyboard glitch that finds "C" press when pressing space // The glitch is caused by the "normal" C64 interrupt occuring just as the keyboard is read. // Press "I" to disable interrupts (red border) // Press "E" to enable interrupts (green border) // Press "C" to enter pressed state (increaded BG_COLOR) - and "SPACE" to leave presssed state again. // Holding SPACE will sometimes trigger the pressed state when normal interrupts are enabled (green border) // but never when they are disabled (red border) /// @file /// Simple Keyboard Input Library /// /// C64 Keyboard Matrix Reference - from http://codebase64.org/doku.php?id=base:reading_the_keyboard /// Keyboard Codes are %00rrrccc, where rrr is the row ID (0-7) and ccc is the column ID (0-7) /// +----+----------------------+-------------------------------------------------------------------------------------------------------+ /// | | Write | Read $dc01 (C64 screen code in parenthesis): | /// |row:| $dc00: row bits +------------+------------+------------+------------+------------+------------+------------+------------+ /// | | | BIT 7 | BIT 6 | BIT 5 | BIT 4 | BIT 3 | BIT 2 | BIT 1 | BIT 0 | /// +----+----------------------+------------+------------+------------+------------+------------+------------+------------+------------+ /// |0. | #%11111110 (254/$fe) | DOWN ($ )| F5 ($ )| F3 ($ )| F1 ($ )| F7 ($ )| RIGHT ($ )| RETURN($ )|DELETE ($ )| /// |1. | #%11111101 (253/$fd) |LEFT-SH($ )| e ($05)| s ($13)| z ($1a)| 4 ($34)| a ($01)| w ($17)| 3 ($33)| /// |2. | #%11111011 (251/$fb) | x ($18)| t ($14)| f ($06)| c ($03)| 6 ($36)| d ($04)| r ($12)| 5 ($35)| /// |3. | #%11110111 (247/$f7) | v ($16)| u ($15)| h ($08)| b ($02)| 8 ($38)| g ($07)| y ($19)| 7 ($37)| /// |4. | #%11101111 (239/$ef) | n ($0e)| o ($0f)| k ($0b)| m ($0d)| 0 ($30)| j ($0a)| i ($09)| 9 ($39)| /// |5. | #%11011111 (223/$df) | , ($2c)| @ ($00)| : ($3a)| . ($2e)| - ($2d)| l ($0c)| p ($10)| + ($2b)| /// |6. | #%10111111 (191/$bf) | / ($2f)| ^ ($1e)| = ($3d)|RGHT-SH($ )| HOME ($ )| ; ($3b)| * ($2a)| £ ($1c)| /// |7. | #%01111111 (127/$7f) | STOP ($ )| q ($11)|COMMODR($ )| SPACE ($20)| 2 ($32)|CONTROL($ )| <- ($1f)| 1 ($31)| /// +----+----------------------+------------+------------+------------+------------+------------+------------+------------+------------+ // Commodore 64 PRG executable file .file [name="keyboard-glitch.prg", type="prg", segments="Program"] .segmentdef Program [segments="Basic, Code, Data"] .segmentdef Basic [start=$0801] .segmentdef Code [start=$80d] .segmentdef Data [startAfter="Code"] .segment Basic :BasicUpstart(main) .const KEY_E = $e .const KEY_C = $14 .const KEY_I = $21 .const KEY_SPACE = $3c .const RED = 2 .const GREEN = 5 .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1 /// $D020 Border Color .label BORDER_COLOR = $d020 /// $D021 Background Color 0 .label BG_COLOR = $d021 /// The CIA#1: keyboard matrix, joystick #1/#2 .label CIA1 = $dc00 .label SCREEN = $400 .segment Code main: { // *BORDER_COLOR = GREEN lda #GREEN sta BORDER_COLOR __b1: // menu() jsr menu jmp __b1 } menu: { __b1: // keyboard_key_pressed(KEY_C) ldx #KEY_C jsr keyboard_key_pressed // keyboard_key_pressed(KEY_C) // if(keyboard_key_pressed(KEY_C)!=0) cmp #0 beq __b2 // pressed() jsr pressed // } rts __b2: // keyboard_key_pressed(KEY_I) ldx #KEY_I jsr keyboard_key_pressed // keyboard_key_pressed(KEY_I) // if(keyboard_key_pressed(KEY_I)!=0) cmp #0 beq __b3 // *BORDER_COLOR = RED lda #RED sta BORDER_COLOR // asm sei rts __b3: // keyboard_key_pressed(KEY_E) ldx #KEY_E jsr keyboard_key_pressed // keyboard_key_pressed(KEY_E) // if(keyboard_key_pressed(KEY_E)!=0) cmp #0 beq __b4 // *BORDER_COLOR = GREEN lda #GREEN sta BORDER_COLOR // asm cli rts __b4: // (*SCREEN)++; inc SCREEN jmp __b1 } // Determines whether a specific key is currently pressed by accessing the matrix directly // The key is a keyboard code defined from the keyboard matrix by %00rrrccc, where rrr is the row ID (0-7) and ccc is the column ID (0-7) // All keys exist as as KEY_XXX constants. // Returns zero if the key is not pressed and a non-zero value if the key is currently pressed // __register(A) char keyboard_key_pressed(__register(X) char key) keyboard_key_pressed: { // char colidx = key&7 txa and #7 tay // char rowidx = key>>3 txa lsr lsr lsr // keyboard_matrix_read(rowidx) tax jsr keyboard_matrix_read // keyboard_matrix_read(rowidx) & keyboard_matrix_col_bitmask[colidx] and keyboard_matrix_col_bitmask,y // } rts } pressed: { // (*BG_COLOR)++; inc BG_COLOR __b1: // keyboard_key_pressed(KEY_SPACE) ldx #KEY_SPACE jsr keyboard_key_pressed // keyboard_key_pressed(KEY_SPACE) // if(keyboard_key_pressed(KEY_SPACE)!=0) cmp #0 bne __breturn jmp __b1 __breturn: // } rts } // Read a single row of the keyboard matrix // The row ID (0-7) of the keyboard matrix row to read. See the C64 key matrix for row IDs. // Returns the keys pressed on the row as bits according to the C64 key matrix. // Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write // leading to erroneous readings. You must disable the normal interrupt or sei/cli around calls to the keyboard matrix reader. // __register(A) char keyboard_matrix_read(__register(X) char rowid) keyboard_matrix_read: { // CIA1->PORT_A = keyboard_matrix_row_bitmask[rowid] lda keyboard_matrix_row_bitmask,x sta CIA1 // char row_pressed_bits = ~CIA1->PORT_B lda CIA1+OFFSET_STRUCT_MOS6526_CIA_PORT_B eor #$ff // } rts } .segment Data // Keyboard row bitmask as expected by CIA#1 Port A when reading a specific keyboard matrix row (rows are numbered 0-7) keyboard_matrix_row_bitmask: .byte $fe, $fd, $fb, $f7, $ef, $df, $bf, $7f // Keyboard matrix column bitmasks for a specific keybooard matrix column when reading the keyboard. (columns are numbered 0-7) keyboard_matrix_col_bitmask: .byte 1, 2, 4, 8, $10, $20, $40, $80
exp/t41.asm
nishuiq/Assembly-Learning
0
177270
<reponame>nishuiq/Assembly-Learning assume cs:code code segment mov ax,0020h mov ds,ax mov cx,64 mov bx,0 s: mov [bx], bx ; ds:bx中不断置数bx,bx自增 inc bx loop s mov ax,4c00h int 21h code ends end
oeis/275/A275505.asm
neoneye/loda-programs
11
240180
<filename>oeis/275/A275505.asm ; A275505: Number of 5 X n 0..2 arrays with no element equal to any value at offset (-2,-1) (-2,0) or (-1,-1) and new values introduced in order 0..2. ; Submitted by <NAME> ; 12,56,232,988,4180,17712,75024,317812,1346268,5702888,24157816,102334156,433494436,1836311904,7778742048,32951280100,139583862444,591286729880,2504730781960,10610209857724,44945570212852,190392490709136,806515533049392,3416454622906708,14472334024676220,61305790721611592,259695496911122584,1100087778366101932,4660046610375530308,19740274219868223168,83621143489848422976,354224848179261915076,1500520536206896083276,6356306993006846248184,26925748508234281076008,114059301025943970552220 mul $0,3 add $0,6 seq $0,71 ; a(n) = Fibonacci(n) - 1. add $0,2 div $0,4 mul $0,4
Validation/pyFrame3DD-master/gcc-master/gcc/ada/exp_ch3.ads
djamal2727/Main-Bearing-Analytical-Model
0
15950
<filename>Validation/pyFrame3DD-master/gcc-master/gcc/ada/exp_ch3.ads ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ C H 3 -- -- -- -- S p e c -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- Expand routines for chapter 3 constructs with Types; use Types; with Elists; use Elists; with Uintp; use Uintp; package Exp_Ch3 is procedure Expand_N_Object_Declaration (N : Node_Id); procedure Expand_N_Subtype_Indication (N : Node_Id); procedure Expand_N_Variant_Part (N : Node_Id); procedure Expand_N_Full_Type_Declaration (N : Node_Id); procedure Expand_Previous_Access_Type (Def_Id : Entity_Id); -- For a full type declaration that contains tasks, or that is a task, -- check whether there exists an access type whose designated type is an -- incomplete declarations for the current composite type. If so, build the -- master for that access type, now that it is known to denote an object -- with tasks. procedure Expand_Record_Extension (T : Entity_Id; Def : Node_Id); -- Add a field _parent in the extension part of the record procedure Build_Access_Subprogram_Wrapper_Body (Decl : Node_Id; New_Decl : Node_Id); -- Build the wrapper body, which holds the indirect call through an access- -- to-subprogram, and whose expansion incorporates the contracts of the -- access type declaration. Called from Build_Access_Subprogram_Wrapper. -- Building the wrapper is done during analysis to perform proper semantic -- checks on the relevant aspects. The wrapper body could be simplified to -- a null body when expansion is disabled ??? procedure Build_Discr_Checking_Funcs (N : Node_Id); -- Builds function which checks whether the component name is consistent -- with the current discriminants. N is the full type declaration node, -- and the discriminant checking functions are inserted after this node. function Build_Initialization_Call (Loc : Source_Ptr; Id_Ref : Node_Id; Typ : Entity_Id; In_Init_Proc : Boolean := False; Enclos_Type : Entity_Id := Empty; Discr_Map : Elist_Id := New_Elmt_List; With_Default_Init : Boolean := False; Constructor_Ref : Node_Id := Empty) return List_Id; -- Builds a call to the initialization procedure for the base type of Typ, -- passing it the object denoted by Id_Ref, plus additional parameters as -- appropriate for the type (the _Master, for task types, for example). -- Loc is the source location for the constructed tree. In_Init_Proc has -- to be set to True when the call is itself in an init proc in order to -- enable the use of discriminals. Enclos_Type is the enclosing type when -- initializing a component in an outer init proc, and it is used for -- various expansion cases including the case where Typ is a task type -- which is an array component, the indexes of the enclosing type are -- used to build the string that identifies each task at runtime. -- -- Discr_Map is used to replace discriminants by their discriminals in -- expressions used to constrain record components. In the presence of -- entry families bounded by discriminants, protected type discriminants -- can appear within expressions in array bounds (not as stand-alone -- identifiers) and a general replacement is necessary. -- -- Ada 2005 (AI-287): With_Default_Init is used to indicate that the -- initialization call corresponds to a default initialized component -- of an aggregate. -- -- Constructor_Ref is a call to a constructor subprogram. It is currently -- used only to support C++ constructors. function Build_Variant_Record_Equality (Typ : Entity_Id; Body_Id : Entity_Id; Param_Specs : List_Id) return Node_Id; -- Build the body of the equality function Body_Id for the untagged variant -- record Typ with the given parameters specification list. procedure Ensure_Activation_Chain_And_Master (Obj_Decl : Node_Id); -- If tasks are being declared (or might be declared) by the given object -- declaration then ensure to have an activation chain defined for the -- tasks (has no effect if we already have one), and also that a Master -- variable is established (and that the appropriate enclosing construct -- is established as a task master). function Freeze_Type (N : Node_Id) return Boolean; -- This function executes the freezing actions associated with the given -- freeze type node N and returns True if the node is to be deleted. We -- delete the node if it is present just for front end purpose and we don't -- want Gigi to see the node. This function can't delete the node itself -- since it would confuse any remaining processing of the freeze node. function Get_Simple_Init_Val (Typ : Entity_Id; N : Node_Id; Size : Uint := No_Uint) return Node_Id; -- Build an expression that represents the required initial value of type -- Typ for which predicate Needs_Simple_Initialization is True. N is a node -- whose source location is used in the construction of the expression. -- Size is used as follows: -- -- * If the size of the object to be initialized it is known, it should -- be passed to the routine. -- -- * If the size is unknown or is zero, then the Esize of Typ is used as -- an estimate of the size. -- -- The object size is needed to prepare a known invalid value for use by -- Normalize_Scalars. A call to this routine where Typ denotes a scalar -- type is valid only when Normalize_Scalars or Initialize_Scalars is -- active, or if N is the node for a 'Invalid_Value attribute node. procedure Init_Secondary_Tags (Typ : Entity_Id; Target : Node_Id; Init_Tags_List : List_Id; Stmts_List : List_Id; Fixed_Comps : Boolean := True; Variable_Comps : Boolean := True); -- Ada 2005 (AI-251): Initialize the tags of the secondary dispatch tables -- of Typ. The generated code referencing tag fields of Target is appended -- to Init_Tags_List and the code required to complete the elaboration of -- the dispatch tables of Typ is appended to Stmts_List. If Fixed_Comps is -- True then the tag components located at fixed positions of Target are -- initialized; if Variable_Comps is True then tags components located at -- variable positions of Target are initialized. function Make_Tag_Assignment (N : Node_Id) return Node_Id; -- An object declaration that has an initialization for a tagged object -- requires a separate reassignment of the tag of the given type, because -- the expression may include an unchecked conversion. This tag assignment -- is inserted after the declaration, but if the object has an address -- clause the assignment is handled as part of the freezing of the object, -- see Check_Address_Clause. end Exp_Ch3;
tools-src/gnu/gcc/gcc/ada/exp_ch4.adb
enfoTek/tomato.linksys.e2000.nvram-mod
80
11121
<gh_stars>10-100 ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ C H 4 -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001, 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 2, 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 COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Checks; use Checks; with Einfo; use Einfo; with Elists; use Elists; with Errout; use Errout; with Exp_Aggr; use Exp_Aggr; with Exp_Ch3; use Exp_Ch3; with Exp_Ch7; use Exp_Ch7; with Exp_Ch9; use Exp_Ch9; with Exp_Disp; use Exp_Disp; with Exp_Fixd; use Exp_Fixd; with Exp_Pakd; use Exp_Pakd; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Exp_VFpt; use Exp_VFpt; with Hostparm; use Hostparm; with Inline; use Inline; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Cat; use Sem_Cat; with Sem_Ch13; use Sem_Ch13; with Sem_Eval; use Sem_Eval; with Sem_Res; use Sem_Res; with Sem_Type; use Sem_Type; with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Sinfo.CN; use Sinfo.CN; with Snames; use Snames; with Stand; use Stand; with Tbuild; use Tbuild; with Ttypes; use Ttypes; with Uintp; use Uintp; with Urealp; use Urealp; with Validsw; use Validsw; package body Exp_Ch4 is ------------------------ -- Local Subprograms -- ------------------------ procedure Binary_Op_Validity_Checks (N : Node_Id); pragma Inline (Binary_Op_Validity_Checks); -- Performs validity checks for a binary operator procedure Expand_Array_Comparison (N : Node_Id); -- This routine handles expansion of the comparison operators (N_Op_Lt, -- N_Op_Le, N_Op_Gt, N_Op_Ge) when operating on an array type. The basic -- code for these operators is similar, differing only in the details of -- the actual comparison call that is made. function Expand_Array_Equality (Nod : Node_Id; Typ : Entity_Id; A_Typ : Entity_Id; Lhs : Node_Id; Rhs : Node_Id; Bodies : List_Id) return Node_Id; -- Expand an array equality into a call to a function implementing this -- equality, and a call to it. Loc is the location for the generated -- nodes. Typ is the type of the array, and Lhs, Rhs are the array -- expressions to be compared. A_Typ is the type of the arguments, -- which may be a private type, in which case Typ is its full view. -- Bodies is a list on which to attach bodies of local functions that -- are created in the process. This is the responsability of the -- caller to insert those bodies at the right place. Nod provides -- the Sloc value for the generated code. procedure Expand_Boolean_Operator (N : Node_Id); -- Common expansion processing for Boolean operators (And, Or, Xor) -- for the case of array type arguments. function Expand_Composite_Equality (Nod : Node_Id; Typ : Entity_Id; Lhs : Node_Id; Rhs : Node_Id; Bodies : List_Id) return Node_Id; -- Local recursive function used to expand equality for nested -- composite types. Used by Expand_Record/Array_Equality, Bodies -- is a list on which to attach bodies of local functions that are -- created in the process. This is the responsability of the caller -- to insert those bodies at the right place. Nod provides the Sloc -- value for generated code. procedure Expand_Concatenate_Other (Cnode : Node_Id; Opnds : List_Id); -- This routine handles expansion of concatenation operations, where -- N is the N_Op_Concat node being expanded and Operands is the list -- of operands (at least two are present). The caller has dealt with -- converting any singleton operands into singleton aggregates. procedure Expand_Concatenate_String (Cnode : Node_Id; Opnds : List_Id); -- Routine to expand concatenation of 2-5 operands (in the list Operands) -- and replace node Cnode with the result of the contatenation. If there -- are two operands, they can be string or character. If there are more -- than two operands, then are always of type string (i.e. the caller has -- already converted character operands to strings in this case). procedure Fixup_Universal_Fixed_Operation (N : Node_Id); -- N is either an N_Op_Divide or N_Op_Multiply node whose result is -- universal fixed. We do not have such a type at runtime, so the -- purpose of this routine is to find the real type by looking up -- the tree. We also determine if the operation must be rounded. procedure Insert_Dereference_Action (N : Node_Id); -- N is an expression whose type is an access. When the type is derived -- from Checked_Pool, expands a call to the primitive 'dereference'. function Make_Array_Comparison_Op (Typ : Entity_Id; Nod : Node_Id) return Node_Id; -- Comparisons between arrays are expanded in line. This function -- produces the body of the implementation of (a > b), where a and b -- are one-dimensional arrays of some discrete type. The original -- node is then expanded into the appropriate call to this function. -- Nod provides the Sloc value for the generated code. function Make_Boolean_Array_Op (Typ : Entity_Id; N : Node_Id) return Node_Id; -- Boolean operations on boolean arrays are expanded in line. This -- function produce the body for the node N, which is (a and b), -- (a or b), or (a xor b). It is used only the normal case and not -- the packed case. The type involved, Typ, is the Boolean array type, -- and the logical operations in the body are simple boolean operations. -- Note that Typ is always a constrained type (the caller has ensured -- this by using Convert_To_Actual_Subtype if necessary). procedure Rewrite_Comparison (N : Node_Id); -- N is the node for a compile time comparison. If this outcome of this -- comparison can be determined at compile time, then the node N can be -- rewritten with True or False. If the outcome cannot be determined at -- compile time, the call has no effect. function Tagged_Membership (N : Node_Id) return Node_Id; -- Construct the expression corresponding to the tagged membership test. -- Deals with a second operand being (or not) a class-wide type. procedure Unary_Op_Validity_Checks (N : Node_Id); pragma Inline (Unary_Op_Validity_Checks); -- Performs validity checks for a unary operator ------------------------------- -- Binary_Op_Validity_Checks -- ------------------------------- procedure Binary_Op_Validity_Checks (N : Node_Id) is begin if Validity_Checks_On and Validity_Check_Operands then Ensure_Valid (Left_Opnd (N)); Ensure_Valid (Right_Opnd (N)); end if; end Binary_Op_Validity_Checks; ----------------------------- -- Expand_Array_Comparison -- ----------------------------- -- Expansion is only required in the case of array types. The form of -- the expansion is: -- [body for greater_nn; boolean_expression] -- The body is built by Make_Array_Comparison_Op, and the form of the -- Boolean expression depends on the operator involved. procedure Expand_Array_Comparison (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Op1 : Node_Id := Left_Opnd (N); Op2 : Node_Id := Right_Opnd (N); Typ1 : constant Entity_Id := Base_Type (Etype (Op1)); Expr : Node_Id; Func_Body : Node_Id; Func_Name : Entity_Id; begin -- For (a <= b) we convert to not (a > b) if Chars (N) = Name_Op_Le then Rewrite (N, Make_Op_Not (Loc, Right_Opnd => Make_Op_Gt (Loc, Left_Opnd => Op1, Right_Opnd => Op2))); Analyze_And_Resolve (N, Standard_Boolean); return; -- For < the Boolean expression is -- greater__nn (op2, op1) elsif Chars (N) = Name_Op_Lt then Func_Body := Make_Array_Comparison_Op (Typ1, N); -- Switch operands Op1 := Right_Opnd (N); Op2 := Left_Opnd (N); -- For (a >= b) we convert to not (a < b) elsif Chars (N) = Name_Op_Ge then Rewrite (N, Make_Op_Not (Loc, Right_Opnd => Make_Op_Lt (Loc, Left_Opnd => Op1, Right_Opnd => Op2))); Analyze_And_Resolve (N, Standard_Boolean); return; -- For > the Boolean expression is -- greater__nn (op1, op2) else pragma Assert (Chars (N) = Name_Op_Gt); Func_Body := Make_Array_Comparison_Op (Typ1, N); end if; Func_Name := Defining_Unit_Name (Specification (Func_Body)); Expr := Make_Function_Call (Loc, Name => New_Reference_To (Func_Name, Loc), Parameter_Associations => New_List (Op1, Op2)); Insert_Action (N, Func_Body); Rewrite (N, Expr); Analyze_And_Resolve (N, Standard_Boolean); end Expand_Array_Comparison; --------------------------- -- Expand_Array_Equality -- --------------------------- -- Expand an equality function for multi-dimensional arrays. Here is -- an example of such a function for Nb_Dimension = 2 -- function Enn (A : arr; B : arr) return boolean is -- J1 : integer; -- J2 : integer; -- -- begin -- if A'length (1) /= B'length (1) then -- return false; -- else -- J1 := B'first (1); -- for I1 in A'first (1) .. A'last (1) loop -- if A'length (2) /= B'length (2) then -- return false; -- else -- J2 := B'first (2); -- for I2 in A'first (2) .. A'last (2) loop -- if A (I1, I2) /= B (J1, J2) then -- return false; -- end if; -- J2 := Integer'succ (J2); -- end loop; -- end if; -- J1 := Integer'succ (J1); -- end loop; -- end if; -- return true; -- end Enn; function Expand_Array_Equality (Nod : Node_Id; Typ : Entity_Id; A_Typ : Entity_Id; Lhs : Node_Id; Rhs : Node_Id; Bodies : List_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (Nod); Actuals : List_Id; Decls : List_Id := New_List; Index_List1 : List_Id := New_List; Index_List2 : List_Id := New_List; Formals : List_Id; Stats : Node_Id; Func_Name : Entity_Id; Func_Body : Node_Id; A : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uA); B : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uB); function Component_Equality (Typ : Entity_Id) return Node_Id; -- Create one statement to compare corresponding components, designated -- by a full set of indices. function Loop_One_Dimension (N : Int; Index : Node_Id) return Node_Id; -- Loop over the n'th dimension of the arrays. The single statement -- in the body of the loop is a loop over the next dimension, or -- the comparison of corresponding components. ------------------------ -- Component_Equality -- ------------------------ function Component_Equality (Typ : Entity_Id) return Node_Id is Test : Node_Id; L, R : Node_Id; begin -- if a(i1...) /= b(j1...) then return false; end if; L := Make_Indexed_Component (Loc, Prefix => Make_Identifier (Loc, Chars (A)), Expressions => Index_List1); R := Make_Indexed_Component (Loc, Prefix => Make_Identifier (Loc, Chars (B)), Expressions => Index_List2); Test := Expand_Composite_Equality (Nod, Component_Type (Typ), L, R, Decls); return Make_Implicit_If_Statement (Nod, Condition => Make_Op_Not (Loc, Right_Opnd => Test), Then_Statements => New_List ( Make_Return_Statement (Loc, Expression => New_Occurrence_Of (Standard_False, Loc)))); end Component_Equality; ------------------------ -- Loop_One_Dimension -- ------------------------ function Loop_One_Dimension (N : Int; Index : Node_Id) return Node_Id is I : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('I')); J : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('J')); Index_Type : Entity_Id; Stats : Node_Id; begin if N > Number_Dimensions (Typ) then return Component_Equality (Typ); else -- Generate the following: -- j: index_type; -- ... -- if a'length (n) /= b'length (n) then -- return false; -- else -- j := b'first (n); -- for i in a'range (n) loop -- -- loop over remaining dimensions. -- j := index_type'succ (j); -- end loop; -- end if; -- retrieve index type for current dimension. Index_Type := Base_Type (Etype (Index)); Append (New_Reference_To (I, Loc), Index_List1); Append (New_Reference_To (J, Loc), Index_List2); -- Declare index for j as a local variable to the function. -- Index i is a loop variable. Append_To (Decls, Make_Object_Declaration (Loc, Defining_Identifier => J, Object_Definition => New_Reference_To (Index_Type, Loc))); Stats := Make_Implicit_If_Statement (Nod, Condition => Make_Op_Ne (Loc, Left_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (A, Loc), Attribute_Name => Name_Length, Expressions => New_List ( Make_Integer_Literal (Loc, N))), Right_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (B, Loc), Attribute_Name => Name_Length, Expressions => New_List ( Make_Integer_Literal (Loc, N)))), Then_Statements => New_List ( Make_Return_Statement (Loc, Expression => New_Occurrence_Of (Standard_False, Loc))), Else_Statements => New_List ( Make_Assignment_Statement (Loc, Name => New_Reference_To (J, Loc), Expression => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (B, Loc), Attribute_Name => Name_First, Expressions => New_List ( Make_Integer_Literal (Loc, N)))), Make_Implicit_Loop_Statement (Nod, Identifier => Empty, Iteration_Scheme => Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, Defining_Identifier => I, Discrete_Subtype_Definition => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (A, Loc), Attribute_Name => Name_Range, Expressions => New_List ( Make_Integer_Literal (Loc, N))))), Statements => New_List ( Loop_One_Dimension (N + 1, Next_Index (Index)), Make_Assignment_Statement (Loc, Name => New_Reference_To (J, Loc), Expression => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Index_Type, Loc), Attribute_Name => Name_Succ, Expressions => New_List ( New_Reference_To (J, Loc)))))))); return Stats; end if; end Loop_One_Dimension; -- Start of processing for Expand_Array_Equality begin Formals := New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => A, Parameter_Type => New_Reference_To (Typ, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => B, Parameter_Type => New_Reference_To (Typ, Loc))); Func_Name := Make_Defining_Identifier (Loc, New_Internal_Name ('E')); Stats := Loop_One_Dimension (1, First_Index (Typ)); Func_Body := Make_Subprogram_Body (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => Func_Name, Parameter_Specifications => Formals, Subtype_Mark => New_Reference_To (Standard_Boolean, Loc)), Declarations => Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Stats, Make_Return_Statement (Loc, Expression => New_Occurrence_Of (Standard_True, Loc))))); Set_Has_Completion (Func_Name, True); -- If the array type is distinct from the type of the arguments, -- it is the full view of a private type. Apply an unchecked -- conversion to insure that analysis of the call succeeds. if Base_Type (A_Typ) /= Base_Type (Typ) then Actuals := New_List ( OK_Convert_To (Typ, Lhs), OK_Convert_To (Typ, Rhs)); else Actuals := New_List (Lhs, Rhs); end if; Append_To (Bodies, Func_Body); return Make_Function_Call (Loc, Name => New_Reference_To (Func_Name, Loc), Parameter_Associations => Actuals); end Expand_Array_Equality; ----------------------------- -- Expand_Boolean_Operator -- ----------------------------- -- Note that we first get the actual subtypes of the operands, -- since we always want to deal with types that have bounds. procedure Expand_Boolean_Operator (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin if Is_Bit_Packed_Array (Typ) then Expand_Packed_Boolean_Operator (N); else -- For the normal non-packed case, the expansion is -- to build a function for carrying out the comparison -- (using Make_Boolean_Array_Op) and then inserting it -- into the tree. The original operator node is then -- rewritten as a call to this function. declare Loc : constant Source_Ptr := Sloc (N); L : constant Node_Id := Relocate_Node (Left_Opnd (N)); R : constant Node_Id := Relocate_Node (Right_Opnd (N)); Func_Body : Node_Id; Func_Name : Entity_Id; begin Convert_To_Actual_Subtype (L); Convert_To_Actual_Subtype (R); Ensure_Defined (Etype (L), N); Ensure_Defined (Etype (R), N); Apply_Length_Check (R, Etype (L)); Func_Body := Make_Boolean_Array_Op (Etype (L), N); Func_Name := Defining_Unit_Name (Specification (Func_Body)); Insert_Action (N, Func_Body); -- Now rewrite the expression with a call Rewrite (N, Make_Function_Call (Loc, Name => New_Reference_To (Func_Name, Loc), Parameter_Associations => New_List (L, Make_Type_Conversion (Loc, New_Reference_To (Etype (L), Loc), R)))); Analyze_And_Resolve (N, Typ); end; end if; end Expand_Boolean_Operator; ------------------------------- -- Expand_Composite_Equality -- ------------------------------- -- This function is only called for comparing internal fields of composite -- types when these fields are themselves composites. This is a special -- case because it is not possible to respect normal Ada visibility rules. function Expand_Composite_Equality (Nod : Node_Id; Typ : Entity_Id; Lhs : Node_Id; Rhs : Node_Id; Bodies : List_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (Nod); Full_Type : Entity_Id; Prim : Elmt_Id; Eq_Op : Entity_Id; begin if Is_Private_Type (Typ) then Full_Type := Underlying_Type (Typ); else Full_Type := Typ; end if; -- Defense against malformed private types with no completion -- the error will be diagnosed later by check_completion if No (Full_Type) then return New_Reference_To (Standard_False, Loc); end if; Full_Type := Base_Type (Full_Type); if Is_Array_Type (Full_Type) then -- If the operand is an elementary type other than a floating-point -- type, then we can simply use the built-in block bitwise equality, -- since the predefined equality operators always apply and bitwise -- equality is fine for all these cases. if Is_Elementary_Type (Component_Type (Full_Type)) and then not Is_Floating_Point_Type (Component_Type (Full_Type)) then return Make_Op_Eq (Loc, Left_Opnd => Lhs, Right_Opnd => Rhs); -- For composite component types, and floating-point types, use -- the expansion. This deals with tagged component types (where -- we use the applicable equality routine) and floating-point, -- (where we need to worry about negative zeroes), and also the -- case of any composite type recursively containing such fields. else return Expand_Array_Equality (Nod, Full_Type, Typ, Lhs, Rhs, Bodies); end if; elsif Is_Tagged_Type (Full_Type) then -- Call the primitive operation "=" of this type if Is_Class_Wide_Type (Full_Type) then Full_Type := Root_Type (Full_Type); end if; -- If this is derived from an untagged private type completed -- with a tagged type, it does not have a full view, so we -- use the primitive operations of the private type. -- This check should no longer be necessary when these -- types receive their full views ??? if Is_Private_Type (Typ) and then not Is_Tagged_Type (Typ) and then not Is_Controlled (Typ) and then Is_Derived_Type (Typ) and then No (Full_View (Typ)) then Prim := First_Elmt (Collect_Primitive_Operations (Typ)); else Prim := First_Elmt (Primitive_Operations (Full_Type)); end if; loop Eq_Op := Node (Prim); exit when Chars (Eq_Op) = Name_Op_Eq and then Etype (First_Formal (Eq_Op)) = Etype (Next_Formal (First_Formal (Eq_Op))); Next_Elmt (Prim); pragma Assert (Present (Prim)); end loop; Eq_Op := Node (Prim); return Make_Function_Call (Loc, Name => New_Reference_To (Eq_Op, Loc), Parameter_Associations => New_List (Unchecked_Convert_To (Etype (First_Formal (Eq_Op)), Lhs), Unchecked_Convert_To (Etype (First_Formal (Eq_Op)), Rhs))); elsif Is_Record_Type (Full_Type) then Eq_Op := TSS (Full_Type, Name_uEquality); if Present (Eq_Op) then if Etype (First_Formal (Eq_Op)) /= Full_Type then -- Inherited equality from parent type. Convert the actuals -- to match signature of operation. declare T : Entity_Id := Etype (First_Formal (Eq_Op)); begin return Make_Function_Call (Loc, Name => New_Reference_To (Eq_Op, Loc), Parameter_Associations => New_List (OK_Convert_To (T, Lhs), OK_Convert_To (T, Rhs))); end; else return Make_Function_Call (Loc, Name => New_Reference_To (Eq_Op, Loc), Parameter_Associations => New_List (Lhs, Rhs)); end if; else return Expand_Record_Equality (Nod, Full_Type, Lhs, Rhs, Bodies); end if; else -- It can be a simple record or the full view of a scalar private return Make_Op_Eq (Loc, Left_Opnd => Lhs, Right_Opnd => Rhs); end if; end Expand_Composite_Equality; ------------------------------ -- Expand_Concatenate_Other -- ------------------------------ -- Let n be the number of array operands to be concatenated, Base_Typ -- their base type, Ind_Typ their index type, and Arr_Typ the original -- array type to which the concatenantion operator applies, then the -- following subprogram is constructed: -- -- [function Cnn (S1 : Base_Typ; ...; Sn : Base_Typ) return Base_Typ is -- L : Ind_Typ; -- begin -- if S1'Length /= 0 then -- L := XXX; --> XXX = S1'First if Arr_Typ is unconstrained -- XXX = Arr_Typ'First otherwise -- elsif S2'Length /= 0 then -- L := YYY; --> YYY = S2'First if Arr_Typ is unconstrained -- YYY = Arr_Typ'First otherwise -- ... -- elsif Sn-1'Length /= 0 then -- L := ZZZ; --> ZZZ = Sn-1'First if Arr_Typ is unconstrained -- ZZZ = Arr_Typ'First otherwise -- else -- return Sn; -- end if; -- -- declare -- P : Ind_Typ; -- H : Ind_Typ := -- Ind_Typ'Val ((((S1'Length - 1) + S2'Length) + ... + Sn'Length) -- + Ind_Typ'Pos (L)); -- R : Base_Typ (L .. H); -- begin -- if S1'Length /= 0 then -- P := S1'First; -- loop -- R (L) := S1 (P); -- L := Ind_Typ'Succ (L); -- exit when P = S1'Last; -- P := Ind_Typ'Succ (P); -- end loop; -- end if; -- -- if S2'Length /= 0 then -- L := Ind_Typ'Succ (L); -- loop -- R (L) := S2 (P); -- L := Ind_Typ'Succ (L); -- exit when P = S2'Last; -- P := Ind_Typ'Succ (P); -- end loop; -- end if; -- -- ... -- -- if Sn'Length /= 0 then -- P := Sn'First; -- loop -- R (L) := Sn (P); -- L := Ind_Typ'Succ (L); -- exit when P = Sn'Last; -- P := Ind_Typ'Succ (P); -- end loop; -- end if; -- -- return R; -- end; -- end Cnn;] procedure Expand_Concatenate_Other (Cnode : Node_Id; Opnds : List_Id) is Loc : constant Source_Ptr := Sloc (Cnode); Nb_Opnds : constant Nat := List_Length (Opnds); Arr_Typ : constant Entity_Id := Etype (Entity (Cnode)); Base_Typ : constant Entity_Id := Base_Type (Etype (Cnode)); Ind_Typ : constant Entity_Id := Etype (First_Index (Base_Typ)); Func_Id : Node_Id; Func_Spec : Node_Id; Param_Specs : List_Id; Func_Body : Node_Id; Func_Decls : List_Id; Func_Stmts : List_Id; L_Decl : Node_Id; If_Stmt : Node_Id; Elsif_List : List_Id; Declare_Block : Node_Id; Declare_Decls : List_Id; Declare_Stmts : List_Id; H_Decl : Node_Id; H_Init : Node_Id; P_Decl : Node_Id; R_Decl : Node_Id; R_Constr : Node_Id; R_Range : Node_Id; Params : List_Id; Operand : Node_Id; function Copy_Into_R_S (I : Nat) return List_Id; -- Builds the sequence of statement: -- P := Si'First; -- loop -- R (L) := Si (P); -- L := Ind_Typ'Succ (L); -- exit when P = Si'Last; -- P := Ind_Typ'Succ (P); -- end loop; -- -- where i is the input parameter I given. function Init_L (I : Nat) return Node_Id; -- Builds the statement: -- L := Arr_Typ'First; If Arr_Typ is constrained -- L := Si'First; otherwise (where I is the input param given) function H return Node_Id; -- Builds reference to identifier H. function Ind_Val (E : Node_Id) return Node_Id; -- Builds expression Ind_Typ'Val (E); function L return Node_Id; -- Builds reference to identifier L. function L_Pos return Node_Id; -- Builds expression Ind_Typ'Pos (L). function L_Succ return Node_Id; -- Builds expression Ind_Typ'Succ (L). function One return Node_Id; -- Builds integer literal one. function P return Node_Id; -- Builds reference to identifier P. function P_Succ return Node_Id; -- Builds expression Ind_Typ'Succ (P). function R return Node_Id; -- Builds reference to identifier R. function S (I : Nat) return Node_Id; -- Builds reference to identifier Si, where I is the value given. function S_First (I : Nat) return Node_Id; -- Builds expression Si'First, where I is the value given. function S_Last (I : Nat) return Node_Id; -- Builds expression Si'Last, where I is the value given. function S_Length (I : Nat) return Node_Id; -- Builds expression Si'Length, where I is the value given. function S_Length_Test (I : Nat) return Node_Id; -- Builds expression Si'Length /= 0, where I is the value given. ------------------- -- Copy_Into_R_S -- ------------------- function Copy_Into_R_S (I : Nat) return List_Id is Stmts : List_Id := New_List; P_Start : Node_Id; Loop_Stmt : Node_Id; R_Copy : Node_Id; Exit_Stmt : Node_Id; L_Inc : Node_Id; P_Inc : Node_Id; begin -- First construct the initializations P_Start := Make_Assignment_Statement (Loc, Name => P, Expression => S_First (I)); Append_To (Stmts, P_Start); -- Then build the loop R_Copy := Make_Assignment_Statement (Loc, Name => Make_Indexed_Component (Loc, Prefix => R, Expressions => New_List (L)), Expression => Make_Indexed_Component (Loc, Prefix => S (I), Expressions => New_List (P))); L_Inc := Make_Assignment_Statement (Loc, Name => L, Expression => L_Succ); Exit_Stmt := Make_Exit_Statement (Loc, Condition => Make_Op_Eq (Loc, P, S_Last (I))); P_Inc := Make_Assignment_Statement (Loc, Name => P, Expression => P_Succ); Loop_Stmt := Make_Implicit_Loop_Statement (Cnode, Statements => New_List (R_Copy, L_Inc, Exit_Stmt, P_Inc)); Append_To (Stmts, Loop_Stmt); return Stmts; end Copy_Into_R_S; ------- -- H -- ------- function H return Node_Id is begin return Make_Identifier (Loc, Name_uH); end H; ------------- -- Ind_Val -- ------------- function Ind_Val (E : Node_Id) return Node_Id is begin return Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Ind_Typ, Loc), Attribute_Name => Name_Val, Expressions => New_List (E)); end Ind_Val; ------------ -- Init_L -- ------------ function Init_L (I : Nat) return Node_Id is E : Node_Id; begin if Is_Constrained (Arr_Typ) then E := Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Arr_Typ, Loc), Attribute_Name => Name_First); else E := S_First (I); end if; return Make_Assignment_Statement (Loc, Name => L, Expression => E); end Init_L; ------- -- L -- ------- function L return Node_Id is begin return Make_Identifier (Loc, Name_uL); end L; ----------- -- L_Pos -- ----------- function L_Pos return Node_Id is begin return Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Ind_Typ, Loc), Attribute_Name => Name_Pos, Expressions => New_List (L)); end L_Pos; ------------ -- L_Succ -- ------------ function L_Succ return Node_Id is begin return Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Ind_Typ, Loc), Attribute_Name => Name_Succ, Expressions => New_List (L)); end L_Succ; --------- -- One -- --------- function One return Node_Id is begin return Make_Integer_Literal (Loc, 1); end One; ------- -- P -- ------- function P return Node_Id is begin return Make_Identifier (Loc, Name_uP); end P; ------------ -- P_Succ -- ------------ function P_Succ return Node_Id is begin return Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Ind_Typ, Loc), Attribute_Name => Name_Succ, Expressions => New_List (P)); end P_Succ; ------- -- R -- ------- function R return Node_Id is begin return Make_Identifier (Loc, Name_uR); end R; ------- -- S -- ------- function S (I : Nat) return Node_Id is begin return Make_Identifier (Loc, New_External_Name ('S', I)); end S; ------------- -- S_First -- ------------- function S_First (I : Nat) return Node_Id is begin return Make_Attribute_Reference (Loc, Prefix => S (I), Attribute_Name => Name_First); end S_First; ------------ -- S_Last -- ------------ function S_Last (I : Nat) return Node_Id is begin return Make_Attribute_Reference (Loc, Prefix => S (I), Attribute_Name => Name_Last); end S_Last; -------------- -- S_Length -- -------------- function S_Length (I : Nat) return Node_Id is begin return Make_Attribute_Reference (Loc, Prefix => S (I), Attribute_Name => Name_Length); end S_Length; ------------------- -- S_Length_Test -- ------------------- function S_Length_Test (I : Nat) return Node_Id is begin return Make_Op_Ne (Loc, Left_Opnd => S_Length (I), Right_Opnd => Make_Integer_Literal (Loc, 0)); end S_Length_Test; -- Start of processing for Expand_Concatenate_Other begin -- Construct the parameter specs and the overall function spec Param_Specs := New_List; for I in 1 .. Nb_Opnds loop Append_To (Param_Specs, Make_Parameter_Specification (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, New_External_Name ('S', I)), Parameter_Type => New_Reference_To (Base_Typ, Loc))); end loop; Func_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('C')); Func_Spec := Make_Function_Specification (Loc, Defining_Unit_Name => Func_Id, Parameter_Specifications => Param_Specs, Subtype_Mark => New_Reference_To (Base_Typ, Loc)); -- Construct L's object declaration L_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uL), Object_Definition => New_Reference_To (Ind_Typ, Loc)); Func_Decls := New_List (L_Decl); -- Construct the if-then-elsif statements Elsif_List := New_List; for I in 2 .. Nb_Opnds - 1 loop Append_To (Elsif_List, Make_Elsif_Part (Loc, Condition => S_Length_Test (I), Then_Statements => New_List (Init_L (I)))); end loop; If_Stmt := Make_Implicit_If_Statement (Cnode, Condition => S_Length_Test (1), Then_Statements => New_List (Init_L (1)), Elsif_Parts => Elsif_List, Else_Statements => New_List (Make_Return_Statement (Loc, Expression => S (Nb_Opnds)))); -- Construct the declaration for H P_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uP), Object_Definition => New_Reference_To (Ind_Typ, Loc)); H_Init := Make_Op_Subtract (Loc, S_Length (1), One); for I in 2 .. Nb_Opnds loop H_Init := Make_Op_Add (Loc, H_Init, S_Length (I)); end loop; H_Init := Ind_Val (Make_Op_Add (Loc, H_Init, L_Pos)); H_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uH), Object_Definition => New_Reference_To (Ind_Typ, Loc), Expression => H_Init); -- Construct the declaration for R R_Range := Make_Range (Loc, Low_Bound => L, High_Bound => H); R_Constr := Make_Index_Or_Discriminant_Constraint (Loc, Constraints => New_List (R_Range)); R_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Make_Defining_Identifier (Loc, Name_uR), Object_Definition => Make_Subtype_Indication (Loc, Subtype_Mark => New_Reference_To (Base_Typ, Loc), Constraint => R_Constr)); -- Construct the declarations for the declare block Declare_Decls := New_List (P_Decl, H_Decl, R_Decl); -- Construct list of statements for the declare block Declare_Stmts := New_List; for I in 1 .. Nb_Opnds loop Append_To (Declare_Stmts, Make_Implicit_If_Statement (Cnode, Condition => S_Length_Test (I), Then_Statements => Copy_Into_R_S (I))); end loop; Append_To (Declare_Stmts, Make_Return_Statement (Loc, Expression => R)); -- Construct the declare block Declare_Block := Make_Block_Statement (Loc, Declarations => Declare_Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Declare_Stmts)); -- Construct the list of function statements Func_Stmts := New_List (If_Stmt, Declare_Block); -- Construct the function body Func_Body := Make_Subprogram_Body (Loc, Specification => Func_Spec, Declarations => Func_Decls, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Func_Stmts)); -- Insert the newly generated function in the code. This is analyzed -- with all checks off, since we have completed all the checks. -- Note that this does *not* fix the array concatenation bug when the -- low bound is Integer'first sibce that bug comes from the pointer -- dereferencing an unconstrained array. An there we need a constraint -- check to make sure the length of the concatenated array is ok. ??? Insert_Action (Cnode, Func_Body, Suppress => All_Checks); -- Construct list of arguments for the function call Params := New_List; Operand := First (Opnds); for I in 1 .. Nb_Opnds loop Append_To (Params, Relocate_Node (Operand)); Next (Operand); end loop; -- Insert the function call Rewrite (Cnode, Make_Function_Call (Loc, New_Reference_To (Func_Id, Loc), Params)); Analyze_And_Resolve (Cnode, Base_Typ); Set_Is_Inlined (Func_Id); end Expand_Concatenate_Other; ------------------------------- -- Expand_Concatenate_String -- ------------------------------- procedure Expand_Concatenate_String (Cnode : Node_Id; Opnds : List_Id) is Loc : constant Source_Ptr := Sloc (Cnode); Opnd1 : constant Node_Id := First (Opnds); Opnd2 : constant Node_Id := Next (Opnd1); Typ1 : constant Entity_Id := Base_Type (Etype (Opnd1)); Typ2 : constant Entity_Id := Base_Type (Etype (Opnd2)); R : RE_Id; -- RE_Id value for function to be called begin -- In all cases, we build a call to a routine giving the list of -- arguments as the parameter list to the routine. case List_Length (Opnds) is when 2 => if Typ1 = Standard_Character then if Typ2 = Standard_Character then R := RE_Str_Concat_CC; else pragma Assert (Typ2 = Standard_String); R := RE_Str_Concat_CS; end if; elsif Typ1 = Standard_String then if Typ2 = Standard_Character then R := RE_Str_Concat_SC; else pragma Assert (Typ2 = Standard_String); R := RE_Str_Concat; end if; -- If we have anything other than Standard_Character or -- Standard_String, then we must have had an error earlier. -- So we just abandon the attempt at expansion. else pragma Assert (Errors_Detected > 0); return; end if; when 3 => R := RE_Str_Concat_3; when 4 => R := RE_Str_Concat_4; when 5 => R := RE_Str_Concat_5; when others => R := RE_Null; raise Program_Error; end case; -- Now generate the appropriate call Rewrite (Cnode, Make_Function_Call (Sloc (Cnode), Name => New_Occurrence_Of (RTE (R), Loc), Parameter_Associations => Opnds)); Analyze_And_Resolve (Cnode, Standard_String); end Expand_Concatenate_String; ------------------------ -- Expand_N_Allocator -- ------------------------ procedure Expand_N_Allocator (N : Node_Id) is PtrT : constant Entity_Id := Etype (N); Desig : Entity_Id; Loc : constant Source_Ptr := Sloc (N); Temp : Entity_Id; Node : Node_Id; begin -- RM E.2.3(22). We enforce that the expected type of an allocator -- shall not be a remote access-to-class-wide-limited-private type -- Why is this being done at expansion time, seems clearly wrong ??? Validate_Remote_Access_To_Class_Wide_Type (N); -- Set the Storage Pool Set_Storage_Pool (N, Associated_Storage_Pool (Root_Type (PtrT))); if Present (Storage_Pool (N)) then if Is_RTE (Storage_Pool (N), RE_SS_Pool) then if not Java_VM then Set_Procedure_To_Call (N, RTE (RE_SS_Allocate)); end if; else Set_Procedure_To_Call (N, Find_Prim_Op (Etype (Storage_Pool (N)), Name_Allocate)); end if; end if; -- Under certain circumstances we can replace an allocator by an -- access to statically allocated storage. The conditions, as noted -- in AARM 3.10 (10c) are as follows: -- Size and initial value is known at compile time -- Access type is access-to-constant if Is_Access_Constant (PtrT) and then Nkind (Expression (N)) = N_Qualified_Expression and then Compile_Time_Known_Value (Expression (Expression (N))) and then Size_Known_At_Compile_Time (Etype (Expression (Expression (N)))) then -- Here we can do the optimization. For the allocator -- new x'(y) -- We insert an object declaration -- Tnn : aliased x := y; -- and replace the allocator by Tnn'Unrestricted_Access. -- Tnn is marked as requiring static allocation. Temp := Make_Defining_Identifier (Loc, New_Internal_Name ('T')); Desig := Subtype_Mark (Expression (N)); -- If context is constrained, use constrained subtype directly, -- so that the constant is not labelled as having a nomimally -- unconstrained subtype. if Entity (Desig) = Base_Type (Designated_Type (PtrT)) then Desig := New_Occurrence_Of (Designated_Type (PtrT), Loc); end if; Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Temp, Aliased_Present => True, Constant_Present => Is_Access_Constant (PtrT), Object_Definition => Desig, Expression => Expression (Expression (N)))); Rewrite (N, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Temp, Loc), Attribute_Name => Name_Unrestricted_Access)); Analyze_And_Resolve (N, PtrT); -- We set the variable as statically allocated, since we don't -- want it going on the stack of the current procedure! Set_Is_Statically_Allocated (Temp); return; end if; -- If the allocator is for a type which requires initialization, and -- there is no initial value (i.e. the operand is a subtype indication -- rather than a qualifed expression), then we must generate a call to -- the initialization routine. This is done using an expression actions -- node: -- -- [Pnnn : constant ptr_T := new (T); Init (Pnnn.all,...); Pnnn] -- -- Here ptr_T is the pointer type for the allocator, and T is the -- subtype of the allocator. A special case arises if the designated -- type of the access type is a task or contains tasks. In this case -- the call to Init (Temp.all ...) is replaced by code that ensures -- that the tasks get activated (see Exp_Ch9.Build_Task_Allocate_Block -- for details). In addition, if the type T is a task T, then the first -- argument to Init must be converted to the task record type. if Nkind (Expression (N)) = N_Qualified_Expression then declare Indic : constant Node_Id := Subtype_Mark (Expression (N)); T : constant Entity_Id := Entity (Indic); Exp : constant Node_Id := Expression (Expression (N)); Aggr_In_Place : constant Boolean := Is_Delayed_Aggregate (Exp); Tag_Assign : Node_Id; Tmp_Node : Node_Id; begin if Is_Tagged_Type (T) or else Controlled_Type (T) then -- Actions inserted before: -- Temp : constant ptr_T := new T'(Expression); -- <no CW> Temp._tag := T'tag; -- <CTRL> Adjust (Finalizable (Temp.all)); -- <CTRL> Attach_To_Final_List (Finalizable (Temp.all)); -- We analyze by hand the new internal allocator to avoid -- any recursion and inappropriate call to Initialize if not Aggr_In_Place then Remove_Side_Effects (Exp); end if; Temp := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); -- For a class wide allocation generate the following code: -- type Equiv_Record is record ... end record; -- implicit subtype CW is <Class_Wide_Subytpe>; -- temp : PtrT := new CW'(CW!(expr)); if Is_Class_Wide_Type (T) then Expand_Subtype_From_Expr (Empty, T, Indic, Exp); Set_Expression (Expression (N), Unchecked_Convert_To (Entity (Indic), Exp)); Analyze_And_Resolve (Expression (N), Entity (Indic)); end if; if Aggr_In_Place then Tmp_Node := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Object_Definition => New_Reference_To (PtrT, Loc), Expression => Make_Allocator (Loc, New_Reference_To (Etype (Exp), Loc))); Set_No_Initialization (Expression (Tmp_Node)); Insert_Action (N, Tmp_Node); Convert_Aggr_In_Allocator (Tmp_Node, Exp); else Node := Relocate_Node (N); Set_Analyzed (Node); Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Temp, Constant_Present => True, Object_Definition => New_Reference_To (PtrT, Loc), Expression => Node)); end if; -- Suppress the tag assignment when Java_VM because JVM tags -- are represented implicitly in objects. if Is_Tagged_Type (T) and then not Is_Class_Wide_Type (T) and then not Java_VM then Tag_Assign := Make_Assignment_Statement (Loc, Name => Make_Selected_Component (Loc, Prefix => New_Reference_To (Temp, Loc), Selector_Name => New_Reference_To (Tag_Component (T), Loc)), Expression => Unchecked_Convert_To (RTE (RE_Tag), New_Reference_To (Access_Disp_Table (T), Loc))); -- The previous assignment has to be done in any case Set_Assignment_OK (Name (Tag_Assign)); Insert_Action (N, Tag_Assign); elsif Is_Private_Type (T) and then Is_Tagged_Type (Underlying_Type (T)) and then not Java_VM then declare Utyp : constant Entity_Id := Underlying_Type (T); Ref : constant Node_Id := Unchecked_Convert_To (Utyp, Make_Explicit_Dereference (Loc, New_Reference_To (Temp, Loc))); begin Tag_Assign := Make_Assignment_Statement (Loc, Name => Make_Selected_Component (Loc, Prefix => Ref, Selector_Name => New_Reference_To (Tag_Component (Utyp), Loc)), Expression => Unchecked_Convert_To (RTE (RE_Tag), New_Reference_To ( Access_Disp_Table (Utyp), Loc))); Set_Assignment_OK (Name (Tag_Assign)); Insert_Action (N, Tag_Assign); end; end if; if Controlled_Type (Designated_Type (PtrT)) and then Controlled_Type (T) then declare Flist : Node_Id; Attach : Node_Id; Apool : constant Entity_Id := Associated_Storage_Pool (PtrT); begin -- If it is an allocation on the secondary stack -- (i.e. a value returned from a function), the object -- is attached on the caller side as soon as the call -- is completed (see Expand_Ctrl_Function_Call) if Is_RTE (Apool, RE_SS_Pool) then declare F : constant Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('F')); begin Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => F, Object_Definition => New_Reference_To (RTE (RE_Finalizable_Ptr), Loc))); Flist := New_Reference_To (F, Loc); Attach := Make_Integer_Literal (Loc, 1); end; -- Normal case, not a secondary stack allocation else Flist := Find_Final_List (PtrT); Attach := Make_Integer_Literal (Loc, 2); end if; if not Aggr_In_Place then Insert_Actions (N, Make_Adjust_Call ( Ref => -- An unchecked conversion is needed in the -- classwide case because the designated type -- can be an ancestor of the subtype mark of -- the allocator. Unchecked_Convert_To (T, Make_Explicit_Dereference (Loc, New_Reference_To (Temp, Loc))), Typ => T, Flist_Ref => Flist, With_Attach => Attach)); end if; end; end if; Rewrite (N, New_Reference_To (Temp, Loc)); Analyze_And_Resolve (N, PtrT); elsif Aggr_In_Place then Temp := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); Tmp_Node := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Object_Definition => New_Reference_To (PtrT, Loc), Expression => Make_Allocator (Loc, New_Reference_To (Etype (Exp), Loc))); Set_No_Initialization (Expression (Tmp_Node)); Insert_Action (N, Tmp_Node); Convert_Aggr_In_Allocator (Tmp_Node, Exp); Rewrite (N, New_Reference_To (Temp, Loc)); Analyze_And_Resolve (N, PtrT); elsif Is_Access_Type (Designated_Type (PtrT)) and then Nkind (Exp) = N_Allocator and then Nkind (Expression (Exp)) /= N_Qualified_Expression then -- Apply constraint to designated subtype indication. Apply_Constraint_Check (Expression (Exp), Designated_Type (Designated_Type (PtrT)), No_Sliding => True); if Nkind (Expression (Exp)) = N_Raise_Constraint_Error then -- Propagate constraint_error to enclosing allocator. Rewrite (Exp, New_Copy (Expression (Exp))); end if; else -- First check against the type of the qualified expression -- -- NOTE: The commented call should be correct, but for -- some reason causes the compiler to bomb (sigsegv) on -- ACVC test c34007g, so for now we just perform the old -- (incorrect) test against the designated subtype with -- no sliding in the else part of the if statement below. -- ??? -- -- Apply_Constraint_Check (Exp, T, No_Sliding => True); -- A check is also needed in cases where the designated -- subtype is constrained and differs from the subtype -- given in the qualified expression. Note that the check -- on the qualified expression does not allow sliding, -- but this check does (a relaxation from Ada 83). if Is_Constrained (Designated_Type (PtrT)) and then not Subtypes_Statically_Match (T, Designated_Type (PtrT)) then Apply_Constraint_Check (Exp, Designated_Type (PtrT), No_Sliding => False); -- The nonsliding check should really be performed -- (unconditionally) against the subtype of the -- qualified expression, but that causes a problem -- with c34007g (see above), so for now we retain this. else Apply_Constraint_Check (Exp, Designated_Type (PtrT), No_Sliding => True); end if; end if; end; -- Here if not qualified expression case. -- In this case, an initialization routine may be required else declare T : constant Entity_Id := Entity (Expression (N)); Init : Entity_Id; Arg1 : Node_Id; Args : List_Id; Decls : List_Id; Decl : Node_Id; Discr : Elmt_Id; Flist : Node_Id; Temp_Decl : Node_Id; Temp_Type : Entity_Id; begin if No_Initialization (N) then null; -- Case of no initialization procedure present elsif not Has_Non_Null_Base_Init_Proc (T) then -- Case of simple initialization required if Needs_Simple_Initialization (T) then Rewrite (Expression (N), Make_Qualified_Expression (Loc, Subtype_Mark => New_Occurrence_Of (T, Loc), Expression => Get_Simple_Init_Val (T, Loc))); Analyze_And_Resolve (Expression (Expression (N)), T); Analyze_And_Resolve (Expression (N), T); Set_Paren_Count (Expression (Expression (N)), 1); Expand_N_Allocator (N); -- No initialization required else null; end if; -- Case of initialization procedure present, must be called else Init := Base_Init_Proc (T); Node := N; Temp := Make_Defining_Identifier (Loc, New_Internal_Name ('P')); -- Construct argument list for the initialization routine call -- The CPP constructor needs the address directly if Is_CPP_Class (T) then Arg1 := New_Reference_To (Temp, Loc); Temp_Type := T; else Arg1 := Make_Explicit_Dereference (Loc, Prefix => New_Reference_To (Temp, Loc)); Set_Assignment_OK (Arg1); Temp_Type := PtrT; -- The initialization procedure expects a specific type. -- if the context is access to class wide, indicate that -- the object being allocated has the right specific type. if Is_Class_Wide_Type (Designated_Type (PtrT)) then Arg1 := Unchecked_Convert_To (T, Arg1); end if; end if; -- If designated type is a concurrent type or if it is a -- private type whose definition is a concurrent type, -- the first argument in the Init routine has to be -- unchecked conversion to the corresponding record type. -- If the designated type is a derived type, we also -- convert the argument to its root type. if Is_Concurrent_Type (T) then Arg1 := Unchecked_Convert_To (Corresponding_Record_Type (T), Arg1); elsif Is_Private_Type (T) and then Present (Full_View (T)) and then Is_Concurrent_Type (Full_View (T)) then Arg1 := Unchecked_Convert_To (Corresponding_Record_Type (Full_View (T)), Arg1); elsif Etype (First_Formal (Init)) /= Base_Type (T) then declare Ftyp : constant Entity_Id := Etype (First_Formal (Init)); begin Arg1 := OK_Convert_To (Etype (Ftyp), Arg1); Set_Etype (Arg1, Ftyp); end; end if; Args := New_List (Arg1); -- For the task case, pass the Master_Id of the access type -- as the value of the _Master parameter, and _Chain as the -- value of the _Chain parameter (_Chain will be defined as -- part of the generated code for the allocator). if Has_Task (T) then if No (Master_Id (Base_Type (PtrT))) then -- The designated type was an incomplete type, and -- the access type did not get expanded. Salvage -- it now. Expand_N_Full_Type_Declaration (Parent (Base_Type (PtrT))); end if; -- If the context of the allocator is a declaration or -- an assignment, we can generate a meaningful image for -- it, even though subsequent assignments might remove -- the connection between task and entity. We build this -- image when the left-hand side is a simple variable, -- a simple indexed assignment or a simple selected -- component. if Nkind (Parent (N)) = N_Assignment_Statement then declare Nam : constant Node_Id := Name (Parent (N)); begin if Is_Entity_Name (Nam) then Decls := Build_Task_Image_Decls ( Loc, New_Occurrence_Of (Entity (Nam), Sloc (Nam)), T); elsif (Nkind (Nam) = N_Indexed_Component or else Nkind (Nam) = N_Selected_Component) and then Is_Entity_Name (Prefix (Nam)) then Decls := Build_Task_Image_Decls (Loc, Nam, Etype (Prefix (Nam))); else Decls := Build_Task_Image_Decls (Loc, T, T); end if; end; elsif Nkind (Parent (N)) = N_Object_Declaration then Decls := Build_Task_Image_Decls ( Loc, Defining_Identifier (Parent (N)), T); else Decls := Build_Task_Image_Decls (Loc, T, T); end if; Append_To (Args, New_Reference_To (Master_Id (Base_Type (Root_Type (PtrT))), Loc)); Append_To (Args, Make_Identifier (Loc, Name_uChain)); Decl := Last (Decls); Append_To (Args, New_Occurrence_Of (Defining_Identifier (Decl), Loc)); -- Has_Task is false, Decls not used else Decls := No_List; end if; -- Add discriminants if discriminated type if Has_Discriminants (T) then Discr := First_Elmt (Discriminant_Constraint (T)); while Present (Discr) loop Append (New_Copy (Elists.Node (Discr)), Args); Next_Elmt (Discr); end loop; elsif Is_Private_Type (T) and then Present (Full_View (T)) and then Has_Discriminants (Full_View (T)) then Discr := First_Elmt (Discriminant_Constraint (Full_View (T))); while Present (Discr) loop Append (New_Copy (Elists.Node (Discr)), Args); Next_Elmt (Discr); end loop; end if; -- We set the allocator as analyzed so that when we analyze the -- expression actions node, we do not get an unwanted recursive -- expansion of the allocator expression. Set_Analyzed (N, True); Node := Relocate_Node (N); -- Here is the transformation: -- input: new T -- output: Temp : constant ptr_T := new T; -- Init (Temp.all, ...); -- <CTRL> Attach_To_Final_List (Finalizable (Temp.all)); -- <CTRL> Initialize (Finalizable (Temp.all)); -- Here ptr_T is the pointer type for the allocator, and T -- is the subtype of the allocator. Temp_Decl := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Constant_Present => True, Object_Definition => New_Reference_To (Temp_Type, Loc), Expression => Node); Set_Assignment_OK (Temp_Decl); if Is_CPP_Class (T) then Set_Aliased_Present (Temp_Decl); end if; Insert_Action (N, Temp_Decl, Suppress => All_Checks); -- Case of designated type is task or contains task -- Create block to activate created tasks, and insert -- declaration for Task_Image variable ahead of call. if Has_Task (T) then declare L : List_Id := New_List; Blk : Node_Id; begin Build_Task_Allocate_Block (L, Node, Args); Blk := Last (L); Insert_List_Before (First (Declarations (Blk)), Decls); Insert_Actions (N, L); end; else Insert_Action (N, Make_Procedure_Call_Statement (Loc, Name => New_Reference_To (Init, Loc), Parameter_Associations => Args)); end if; if Controlled_Type (T) then -- If the context is an access parameter, we need to create -- a non-anonymous access type in order to have a usable -- final list, because there is otherwise no pool to which -- the allocated object can belong. We create both the type -- and the finalization chain here, because freezing an -- internal type does not create such a chain. if Ekind (PtrT) = E_Anonymous_Access_Type then declare Acc : Entity_Id := Make_Defining_Identifier (Loc, New_Internal_Name ('I')); begin Insert_Action (N, Make_Full_Type_Declaration (Loc, Defining_Identifier => Acc, Type_Definition => Make_Access_To_Object_Definition (Loc, Subtype_Indication => New_Occurrence_Of (T, Loc)))); Build_Final_List (N, Acc); Flist := Find_Final_List (Acc); end; else Flist := Find_Final_List (PtrT); end if; Insert_Actions (N, Make_Init_Call ( Ref => New_Copy_Tree (Arg1), Typ => T, Flist_Ref => Flist, With_Attach => Make_Integer_Literal (Loc, 2))); end if; if Is_CPP_Class (T) then Rewrite (N, Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Temp, Loc), Attribute_Name => Name_Unchecked_Access)); else Rewrite (N, New_Reference_To (Temp, Loc)); end if; Analyze_And_Resolve (N, PtrT); end if; end; end if; end Expand_N_Allocator; ----------------------- -- Expand_N_And_Then -- ----------------------- -- Expand into conditional expression if Actions present, and also -- deal with optimizing case of arguments being True or False. procedure Expand_N_And_Then (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Left : constant Node_Id := Left_Opnd (N); Right : constant Node_Id := Right_Opnd (N); Actlist : List_Id; begin -- Deal with non-standard booleans if Is_Boolean_Type (Typ) then Adjust_Condition (Left); Adjust_Condition (Right); Set_Etype (N, Standard_Boolean); end if; -- Check for cases of left argument is True or False if Nkind (Left) = N_Identifier then -- If left argument is True, change (True and then Right) to Right. -- Any actions associated with Right will be executed unconditionally -- and can thus be inserted into the tree unconditionally. if Entity (Left) = Standard_True then if Present (Actions (N)) then Insert_Actions (N, Actions (N)); end if; Rewrite (N, Right); Adjust_Result_Type (N, Typ); return; -- If left argument is False, change (False and then Right) to -- False. In this case we can forget the actions associated with -- Right, since they will never be executed. elsif Entity (Left) = Standard_False then Kill_Dead_Code (Right); Kill_Dead_Code (Actions (N)); Rewrite (N, New_Occurrence_Of (Standard_False, Loc)); Adjust_Result_Type (N, Typ); return; end if; end if; -- If Actions are present, we expand -- left and then right -- into -- if left then right else false end -- with the actions becoming the Then_Actions of the conditional -- expression. This conditional expression is then further expanded -- (and will eventually disappear) if Present (Actions (N)) then Actlist := Actions (N); Rewrite (N, Make_Conditional_Expression (Loc, Expressions => New_List ( Left, Right, New_Occurrence_Of (Standard_False, Loc)))); Set_Then_Actions (N, Actlist); Analyze_And_Resolve (N, Standard_Boolean); Adjust_Result_Type (N, Typ); return; end if; -- No actions present, check for cases of right argument True/False if Nkind (Right) = N_Identifier then -- Change (Left and then True) to Left. Note that we know there -- are no actions associated with the True operand, since we -- just checked for this case above. if Entity (Right) = Standard_True then Rewrite (N, Left); -- Change (Left and then False) to False, making sure to preserve -- any side effects associated with the Left operand. elsif Entity (Right) = Standard_False then Remove_Side_Effects (Left); Rewrite (N, New_Occurrence_Of (Standard_False, Loc)); end if; end if; Adjust_Result_Type (N, Typ); end Expand_N_And_Then; ------------------------------------- -- Expand_N_Conditional_Expression -- ------------------------------------- -- Expand into expression actions if then/else actions present procedure Expand_N_Conditional_Expression (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Cond : constant Node_Id := First (Expressions (N)); Thenx : constant Node_Id := Next (Cond); Elsex : constant Node_Id := Next (Thenx); Typ : constant Entity_Id := Etype (N); Cnn : Entity_Id; New_If : Node_Id; begin -- If either then or else actions are present, then given: -- if cond then then-expr else else-expr end -- we insert the following sequence of actions (using Insert_Actions): -- Cnn : typ; -- if cond then -- <<then actions>> -- Cnn := then-expr; -- else -- <<else actions>> -- Cnn := else-expr -- end if; -- and replace the conditional expression by a reference to Cnn. if Present (Then_Actions (N)) or else Present (Else_Actions (N)) then Cnn := Make_Defining_Identifier (Loc, New_Internal_Name ('C')); New_If := Make_Implicit_If_Statement (N, Condition => Relocate_Node (Cond), Then_Statements => New_List ( Make_Assignment_Statement (Sloc (Thenx), Name => New_Occurrence_Of (Cnn, Sloc (Thenx)), Expression => Relocate_Node (Thenx))), Else_Statements => New_List ( Make_Assignment_Statement (Sloc (Elsex), Name => New_Occurrence_Of (Cnn, Sloc (Elsex)), Expression => Relocate_Node (Elsex)))); if Present (Then_Actions (N)) then Insert_List_Before (First (Then_Statements (New_If)), Then_Actions (N)); end if; if Present (Else_Actions (N)) then Insert_List_Before (First (Else_Statements (New_If)), Else_Actions (N)); end if; Rewrite (N, New_Occurrence_Of (Cnn, Loc)); Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Cnn, Object_Definition => New_Occurrence_Of (Typ, Loc))); Insert_Action (N, New_If); Analyze_And_Resolve (N, Typ); end if; end Expand_N_Conditional_Expression; ----------------------------------- -- Expand_N_Explicit_Dereference -- ----------------------------------- procedure Expand_N_Explicit_Dereference (N : Node_Id) is begin -- The only processing required is an insertion of an explicit -- dereference call for the checked storage pool case. Insert_Dereference_Action (Prefix (N)); end Expand_N_Explicit_Dereference; ----------------- -- Expand_N_In -- ----------------- procedure Expand_N_In (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Rtyp : constant Entity_Id := Etype (N); begin -- No expansion is required if we have an explicit range if Nkind (Right_Opnd (N)) = N_Range then return; -- Here right operand is a subtype mark else declare Typ : Entity_Id := Etype (Right_Opnd (N)); Obj : Node_Id := Left_Opnd (N); Cond : Node_Id := Empty; Is_Acc : Boolean := Is_Access_Type (Typ); begin Remove_Side_Effects (Obj); -- For tagged type, do tagged membership operation if Is_Tagged_Type (Typ) then -- No expansion will be performed when Java_VM, as the -- JVM back end will handle the membership tests directly -- (tags are not explicitly represented in Java objects, -- so the normal tagged membership expansion is not what -- we want). if not Java_VM then Rewrite (N, Tagged_Membership (N)); Analyze_And_Resolve (N, Rtyp); end if; return; -- If type is scalar type, rewrite as x in t'first .. t'last -- This reason we do this is that the bounds may have the wrong -- type if they come from the original type definition. elsif Is_Scalar_Type (Typ) then Rewrite (Right_Opnd (N), Make_Range (Loc, Low_Bound => Make_Attribute_Reference (Loc, Attribute_Name => Name_First, Prefix => New_Reference_To (Typ, Loc)), High_Bound => Make_Attribute_Reference (Loc, Attribute_Name => Name_Last, Prefix => New_Reference_To (Typ, Loc)))); Analyze_And_Resolve (N, Rtyp); return; end if; if Is_Acc then Typ := Designated_Type (Typ); end if; if not Is_Constrained (Typ) then Rewrite (N, New_Reference_To (Standard_True, Loc)); Analyze_And_Resolve (N, Rtyp); -- For the constrained array case, we have to check the -- subscripts for an exact match if the lengths are -- non-zero (the lengths must match in any case). elsif Is_Array_Type (Typ) then declare function Construct_Attribute_Reference (E : Node_Id; Nam : Name_Id; Dim : Nat) return Node_Id; -- Build attribute reference E'Nam(Dim) function Construct_Attribute_Reference (E : Node_Id; Nam : Name_Id; Dim : Nat) return Node_Id is begin return Make_Attribute_Reference (Loc, Prefix => E, Attribute_Name => Nam, Expressions => New_List ( Make_Integer_Literal (Loc, Dim))); end Construct_Attribute_Reference; begin for J in 1 .. Number_Dimensions (Typ) loop Evolve_And_Then (Cond, Make_Op_Eq (Loc, Left_Opnd => Construct_Attribute_Reference (Duplicate_Subexpr (Obj), Name_First, J), Right_Opnd => Construct_Attribute_Reference (New_Occurrence_Of (Typ, Loc), Name_First, J))); Evolve_And_Then (Cond, Make_Op_Eq (Loc, Left_Opnd => Construct_Attribute_Reference (Duplicate_Subexpr (Obj), Name_Last, J), Right_Opnd => Construct_Attribute_Reference (New_Occurrence_Of (Typ, Loc), Name_Last, J))); end loop; if Is_Acc then Cond := Make_Or_Else (Loc, Left_Opnd => Make_Op_Eq (Loc, Left_Opnd => Obj, Right_Opnd => Make_Null (Loc)), Right_Opnd => Cond); end if; Rewrite (N, Cond); Analyze_And_Resolve (N, Rtyp); end; -- These are the cases where constraint checks may be -- required, e.g. records with possible discriminants else -- Expand the test into a series of discriminant comparisons. -- The expression that is built is the negation of the one -- that is used for checking discriminant constraints. Obj := Relocate_Node (Left_Opnd (N)); if Has_Discriminants (Typ) then Cond := Make_Op_Not (Loc, Right_Opnd => Build_Discriminant_Checks (Obj, Typ)); if Is_Acc then Cond := Make_Or_Else (Loc, Left_Opnd => Make_Op_Eq (Loc, Left_Opnd => Obj, Right_Opnd => Make_Null (Loc)), Right_Opnd => Cond); end if; else Cond := New_Occurrence_Of (Standard_True, Loc); end if; Rewrite (N, Cond); Analyze_And_Resolve (N, Rtyp); end if; end; end if; end Expand_N_In; -------------------------------- -- Expand_N_Indexed_Component -- -------------------------------- procedure Expand_N_Indexed_Component (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); P : constant Node_Id := Prefix (N); T : constant Entity_Id := Etype (P); begin -- A special optimization, if we have an indexed component that -- is selecting from a slice, then we can eliminate the slice, -- since, for example, x (i .. j)(k) is identical to x(k). The -- only difference is the range check required by the slice. The -- range check for the slice itself has already been generated. -- The range check for the subscripting operation is ensured -- by converting the subject to the subtype of the slice. -- This optimization not only generates better code, avoiding -- slice messing especially in the packed case, but more importantly -- bypasses some problems in handling this peculiar case, for -- example, the issue of dealing specially with object renamings. if Nkind (P) = N_Slice then Rewrite (N, Make_Indexed_Component (Loc, Prefix => Prefix (P), Expressions => New_List ( Convert_To (Etype (First_Index (Etype (P))), First (Expressions (N)))))); Analyze_And_Resolve (N, Typ); return; end if; -- If the prefix is an access type, then we unconditionally rewrite -- if as an explicit deference. This simplifies processing for several -- cases, including packed array cases and certain cases in which -- checks must be generated. We used to try to do this only when it -- was necessary, but it cleans up the code to do it all the time. if Is_Access_Type (T) then Rewrite (P, Make_Explicit_Dereference (Sloc (N), Prefix => Relocate_Node (P))); Analyze_And_Resolve (P, Designated_Type (T)); end if; if Validity_Checks_On and then Validity_Check_Subscripts then Apply_Subscript_Validity_Checks (N); end if; -- All done for the non-packed case if not Is_Packed (Etype (Prefix (N))) then return; end if; -- For packed arrays that are not bit-packed (i.e. the case of an array -- with one or more index types with a non-coniguous enumeration type), -- we can always use the normal packed element get circuit. if not Is_Bit_Packed_Array (Etype (Prefix (N))) then Expand_Packed_Element_Reference (N); return; end if; -- For a reference to a component of a bit packed array, we have to -- convert it to a reference to the corresponding Packed_Array_Type. -- We only want to do this for simple references, and not for: -- Left side of assignment (or prefix of left side of assignment) -- This case is handled in Exp_Ch5.Expand_N_Assignment_Statement -- Renaming objects in renaming associations -- This case is handled when a use of the renamed variable occurs -- Actual parameters for a procedure call -- This case is handled in Exp_Ch6.Expand_Actuals -- The second expression in a 'Read attribute reference -- The prefix of an address or size attribute reference -- The following circuit detects these exceptions declare Child : Node_Id := N; Parnt : Node_Id := Parent (N); begin loop if Nkind (Parnt) = N_Unchecked_Expression then null; elsif Nkind (Parnt) = N_Object_Renaming_Declaration or else Nkind (Parnt) = N_Procedure_Call_Statement or else (Nkind (Parnt) = N_Parameter_Association and then Nkind (Parent (Parnt)) = N_Procedure_Call_Statement) then return; elsif Nkind (Parnt) = N_Attribute_Reference and then (Attribute_Name (Parnt) = Name_Address or else Attribute_Name (Parnt) = Name_Size) and then Prefix (Parnt) = Child then return; elsif Nkind (Parnt) = N_Assignment_Statement and then Name (Parnt) = Child then return; elsif Nkind (Parnt) = N_Attribute_Reference and then Attribute_Name (Parnt) = Name_Read and then Next (First (Expressions (Parnt))) = Child then return; elsif (Nkind (Parnt) = N_Indexed_Component or else Nkind (Parnt) = N_Selected_Component) and then Prefix (Parnt) = Child then null; else Expand_Packed_Element_Reference (N); return; end if; -- Keep looking up tree for unchecked expression, or if we are -- the prefix of a possible assignment left side. Child := Parnt; Parnt := Parent (Child); end loop; end; end Expand_N_Indexed_Component; --------------------- -- Expand_N_Not_In -- --------------------- -- Replace a not in b by not (a in b) so that the expansions for (a in b) -- can be done. This avoids needing to duplicate this expansion code. procedure Expand_N_Not_In (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); begin Rewrite (N, Make_Op_Not (Loc, Right_Opnd => Make_In (Loc, Left_Opnd => Left_Opnd (N), Right_Opnd => Right_Opnd (N)))); Analyze_And_Resolve (N, Typ); end Expand_N_Not_In; ------------------- -- Expand_N_Null -- ------------------- -- The only replacement required is for the case of a null of type -- that is an access to protected subprogram. We represent such -- access values as a record, and so we must replace the occurrence -- of null by the equivalent record (with a null address and a null -- pointer in it), so that the backend creates the proper value. procedure Expand_N_Null (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Agg : Node_Id; begin if Ekind (Typ) = E_Access_Protected_Subprogram_Type then Agg := Make_Aggregate (Loc, Expressions => New_List ( New_Occurrence_Of (RTE (RE_Null_Address), Loc), Make_Null (Loc))); Rewrite (N, Agg); Analyze_And_Resolve (N, Equivalent_Type (Typ)); -- For subsequent semantic analysis, the node must retain its -- type. Gigi in any case replaces this type by the corresponding -- record type before processing the node. Set_Etype (N, Typ); end if; end Expand_N_Null; --------------------- -- Expand_N_Op_Abs -- --------------------- procedure Expand_N_Op_Abs (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Expr : constant Node_Id := Right_Opnd (N); begin Unary_Op_Validity_Checks (N); -- Deal with software overflow checking if Software_Overflow_Checking and then Is_Signed_Integer_Type (Etype (N)) and then Do_Overflow_Check (N) then -- Software overflow checking expands abs (expr) into -- (if expr >= 0 then expr else -expr) -- with the usual Duplicate_Subexpr use coding for expr Rewrite (N, Make_Conditional_Expression (Loc, Expressions => New_List ( Make_Op_Ge (Loc, Left_Opnd => Duplicate_Subexpr (Expr), Right_Opnd => Make_Integer_Literal (Loc, 0)), Duplicate_Subexpr (Expr), Make_Op_Minus (Loc, Right_Opnd => Duplicate_Subexpr (Expr))))); Analyze_And_Resolve (N); -- Vax floating-point types case elsif Vax_Float (Etype (N)) then Expand_Vax_Arith (N); end if; end Expand_N_Op_Abs; --------------------- -- Expand_N_Op_Add -- --------------------- procedure Expand_N_Op_Add (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); -- N + 0 = 0 + N = N for integer types if Is_Integer_Type (Typ) then if Compile_Time_Known_Value (Right_Opnd (N)) and then Expr_Value (Right_Opnd (N)) = Uint_0 then Rewrite (N, Left_Opnd (N)); return; elsif Compile_Time_Known_Value (Left_Opnd (N)) and then Expr_Value (Left_Opnd (N)) = Uint_0 then Rewrite (N, Right_Opnd (N)); return; end if; end if; -- Arithemtic overflow checks for signed integer/fixed point types if Is_Signed_Integer_Type (Typ) or else Is_Fixed_Point_Type (Typ) then Apply_Arithmetic_Overflow_Check (N); return; -- Vax floating-point types case elsif Vax_Float (Typ) then Expand_Vax_Arith (N); end if; end Expand_N_Op_Add; --------------------- -- Expand_N_Op_And -- --------------------- procedure Expand_N_Op_And (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); if Is_Array_Type (Etype (N)) then Expand_Boolean_Operator (N); elsif Is_Boolean_Type (Etype (N)) then Adjust_Condition (Left_Opnd (N)); Adjust_Condition (Right_Opnd (N)); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; end Expand_N_Op_And; ------------------------ -- Expand_N_Op_Concat -- ------------------------ procedure Expand_N_Op_Concat (N : Node_Id) is Opnds : List_Id; -- List of operands to be concatenated Opnd : Node_Id; -- Single operand for concatenation Cnode : Node_Id; -- Node which is to be replaced by the result of concatenating -- the nodes in the list Opnds. Atyp : Entity_Id; -- Array type of concatenation result type Ctyp : Entity_Id; -- Component type of concatenation represented by Cnode begin Binary_Op_Validity_Checks (N); -- If we are the left operand of a concatenation higher up the -- tree, then do nothing for now, since we want to deal with a -- series of concatenations as a unit. if Nkind (Parent (N)) = N_Op_Concat and then N = Left_Opnd (Parent (N)) then return; end if; -- We get here with a concatenation whose left operand may be a -- concatenation itself with a consistent type. We need to process -- these concatenation operands from left to right, which means -- from the deepest node in the tree to the highest node. Cnode := N; while Nkind (Left_Opnd (Cnode)) = N_Op_Concat loop Cnode := Left_Opnd (Cnode); end loop; -- Now Opnd is the deepest Opnd, and its parents are the concatenation -- nodes above, so now we process bottom up, doing the operations. We -- gather a string that is as long as possible up to five operands -- The outer loop runs more than once if there are more than five -- concatenations of type Standard.String, the most we handle for -- this case, or if more than one concatenation type is involved. Outer : loop Opnds := New_List (Left_Opnd (Cnode), Right_Opnd (Cnode)); Set_Parent (Opnds, N); -- The inner loop gathers concatenation operands Inner : while Cnode /= N and then (Base_Type (Etype (Cnode)) /= Standard_String or else List_Length (Opnds) < 5) and then Base_Type (Etype (Cnode)) = Base_Type (Etype (Parent (Cnode))) loop Cnode := Parent (Cnode); Append (Right_Opnd (Cnode), Opnds); end loop Inner; -- Here we process the collected operands. First we convert -- singleton operands to singleton aggregates. This is skipped -- however for the case of two operands of type String, since -- we have special routines for these cases. Atyp := Base_Type (Etype (Cnode)); Ctyp := Base_Type (Component_Type (Etype (Cnode))); if List_Length (Opnds) > 2 or else Atyp /= Standard_String then Opnd := First (Opnds); loop if Base_Type (Etype (Opnd)) = Ctyp then Rewrite (Opnd, Make_Aggregate (Sloc (Cnode), Expressions => New_List (Relocate_Node (Opnd)))); Analyze_And_Resolve (Opnd, Atyp); end if; Next (Opnd); exit when No (Opnd); end loop; end if; -- Now call appropriate continuation routine if Atyp = Standard_String then Expand_Concatenate_String (Cnode, Opnds); else Expand_Concatenate_Other (Cnode, Opnds); end if; exit Outer when Cnode = N; Cnode := Parent (Cnode); end loop Outer; end Expand_N_Op_Concat; ------------------------ -- Expand_N_Op_Divide -- ------------------------ procedure Expand_N_Op_Divide (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Ltyp : constant Entity_Id := Etype (Left_Opnd (N)); Rtyp : constant Entity_Id := Etype (Right_Opnd (N)); Typ : Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); -- Vax_Float is a special case if Vax_Float (Typ) then Expand_Vax_Arith (N); return; end if; -- N / 1 = N for integer types if Is_Integer_Type (Typ) and then Compile_Time_Known_Value (Right_Opnd (N)) and then Expr_Value (Right_Opnd (N)) = Uint_1 then Rewrite (N, Left_Opnd (N)); return; end if; -- Convert x / 2 ** y to Shift_Right (x, y). Note that the fact that -- Is_Power_Of_2_For_Shift is set means that we know that our left -- operand is an unsigned integer, as required for this to work. if Nkind (Right_Opnd (N)) = N_Op_Expon and then Is_Power_Of_2_For_Shift (Right_Opnd (N)) then Rewrite (N, Make_Op_Shift_Right (Loc, Left_Opnd => Left_Opnd (N), Right_Opnd => Convert_To (Standard_Natural, Right_Opnd (Right_Opnd (N))))); Analyze_And_Resolve (N, Typ); return; end if; -- Do required fixup of universal fixed operation if Typ = Universal_Fixed then Fixup_Universal_Fixed_Operation (N); Typ := Etype (N); end if; -- Divisions with fixed-point results if Is_Fixed_Point_Type (Typ) then -- No special processing if Treat_Fixed_As_Integer is set, -- since from a semantic point of view such operations are -- simply integer operations and will be treated that way. if not Treat_Fixed_As_Integer (N) then if Is_Integer_Type (Rtyp) then Expand_Divide_Fixed_By_Integer_Giving_Fixed (N); else Expand_Divide_Fixed_By_Fixed_Giving_Fixed (N); end if; end if; -- Other cases of division of fixed-point operands. Again we -- exclude the case where Treat_Fixed_As_Integer is set. elsif (Is_Fixed_Point_Type (Ltyp) or else Is_Fixed_Point_Type (Rtyp)) and then not Treat_Fixed_As_Integer (N) then if Is_Integer_Type (Typ) then Expand_Divide_Fixed_By_Fixed_Giving_Integer (N); else pragma Assert (Is_Floating_Point_Type (Typ)); Expand_Divide_Fixed_By_Fixed_Giving_Float (N); end if; -- Mixed-mode operations can appear in a non-static universal -- context, in which case the integer argument must be converted -- explicitly. elsif Typ = Universal_Real and then Is_Integer_Type (Rtyp) then Rewrite (Right_Opnd (N), Convert_To (Universal_Real, Relocate_Node (Right_Opnd (N)))); Analyze_And_Resolve (Right_Opnd (N), Universal_Real); elsif Typ = Universal_Real and then Is_Integer_Type (Ltyp) then Rewrite (Left_Opnd (N), Convert_To (Universal_Real, Relocate_Node (Left_Opnd (N)))); Analyze_And_Resolve (Left_Opnd (N), Universal_Real); -- Non-fixed point cases, do zero divide and overflow checks elsif Is_Integer_Type (Typ) then Apply_Divide_Check (N); end if; end Expand_N_Op_Divide; -------------------- -- Expand_N_Op_Eq -- -------------------- procedure Expand_N_Op_Eq (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Lhs : constant Node_Id := Left_Opnd (N); Rhs : constant Node_Id := Right_Opnd (N); A_Typ : Entity_Id := Etype (Lhs); Typl : Entity_Id := A_Typ; Op_Name : Entity_Id; Prim : Elmt_Id; Bodies : List_Id := New_List; procedure Build_Equality_Call (Eq : Entity_Id); -- If a constructed equality exists for the type or for its parent, -- build and analyze call, adding conversions if the operation is -- inherited. ------------------------- -- Build_Equality_Call -- ------------------------- procedure Build_Equality_Call (Eq : Entity_Id) is Op_Type : constant Entity_Id := Etype (First_Formal (Eq)); L_Exp : Node_Id := Relocate_Node (Lhs); R_Exp : Node_Id := Relocate_Node (Rhs); begin if Base_Type (Op_Type) /= Base_Type (A_Typ) and then not Is_Class_Wide_Type (A_Typ) then L_Exp := OK_Convert_To (Op_Type, L_Exp); R_Exp := OK_Convert_To (Op_Type, R_Exp); end if; Rewrite (N, Make_Function_Call (Loc, Name => New_Reference_To (Eq, Loc), Parameter_Associations => New_List (L_Exp, R_Exp))); Analyze_And_Resolve (N, Standard_Boolean, Suppress => All_Checks); end Build_Equality_Call; -- Start of processing for Expand_N_Op_Eq begin Binary_Op_Validity_Checks (N); if Ekind (Typl) = E_Private_Type then Typl := Underlying_Type (Typl); elsif Ekind (Typl) = E_Private_Subtype then Typl := Underlying_Type (Base_Type (Typl)); end if; -- It may happen in error situations that the underlying type is not -- set. The error will be detected later, here we just defend the -- expander code. if No (Typl) then return; end if; Typl := Base_Type (Typl); -- Vax float types if Vax_Float (Typl) then Expand_Vax_Comparison (N); return; -- Boolean types (requiring handling of non-standard case) elsif Is_Boolean_Type (Typl) then Adjust_Condition (Left_Opnd (N)); Adjust_Condition (Right_Opnd (N)); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); -- Array types elsif Is_Array_Type (Typl) then -- Packed case if Is_Bit_Packed_Array (Typl) then Expand_Packed_Eq (N); -- For non-floating-point elementary types, the primitive equality -- always applies, and block-bit comparison is fine. Floating-point -- is an exception because of negative zeroes. -- However, we never use block bit comparison in No_Run_Time mode, -- since this may result in a call to a run time routine elsif Is_Elementary_Type (Component_Type (Typl)) and then not Is_Floating_Point_Type (Component_Type (Typl)) and then not No_Run_Time then null; -- For composite and floating-point cases, expand equality loop -- to make sure of using proper comparisons for tagged types, -- and correctly handling the floating-point case. else Rewrite (N, Expand_Array_Equality (N, Typl, A_Typ, Relocate_Node (Lhs), Relocate_Node (Rhs), Bodies)); Insert_Actions (N, Bodies, Suppress => All_Checks); Analyze_And_Resolve (N, Standard_Boolean, Suppress => All_Checks); end if; -- Record Types elsif Is_Record_Type (Typl) then -- For tagged types, use the primitive "=" if Is_Tagged_Type (Typl) then -- If this is derived from an untagged private type completed -- with a tagged type, it does not have a full view, so we -- use the primitive operations of the private type. -- This check should no longer be necessary when these -- types receive their full views ??? if Is_Private_Type (A_Typ) and then not Is_Tagged_Type (A_Typ) and then Is_Derived_Type (A_Typ) and then No (Full_View (A_Typ)) then Prim := First_Elmt (Collect_Primitive_Operations (A_Typ)); while Chars (Node (Prim)) /= Name_Op_Eq loop Next_Elmt (Prim); pragma Assert (Present (Prim)); end loop; Op_Name := Node (Prim); else Op_Name := Find_Prim_Op (Typl, Name_Op_Eq); end if; Build_Equality_Call (Op_Name); -- If a type support function is present (for complex cases), use it elsif Present (TSS (Root_Type (Typl), Name_uEquality)) then Build_Equality_Call (TSS (Root_Type (Typl), Name_uEquality)); -- Otherwise expand the component by component equality. Note that -- we never use block-bit coparisons for records, because of the -- problems with gaps. The backend will often be able to recombine -- the separate comparisons that we generate here. else Remove_Side_Effects (Lhs); Remove_Side_Effects (Rhs); Rewrite (N, Expand_Record_Equality (N, Typl, Lhs, Rhs, Bodies)); Insert_Actions (N, Bodies, Suppress => All_Checks); Analyze_And_Resolve (N, Standard_Boolean, Suppress => All_Checks); end if; end if; -- If we still have an equality comparison (i.e. it was not rewritten -- in some way), then we can test if result is needed at compile time). if Nkind (N) = N_Op_Eq then Rewrite_Comparison (N); end if; end Expand_N_Op_Eq; ----------------------- -- Expand_N_Op_Expon -- ----------------------- procedure Expand_N_Op_Expon (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Rtyp : constant Entity_Id := Root_Type (Typ); Base : constant Node_Id := Relocate_Node (Left_Opnd (N)); Exp : constant Node_Id := Relocate_Node (Right_Opnd (N)); Exptyp : constant Entity_Id := Etype (Exp); Ovflo : constant Boolean := Do_Overflow_Check (N); Expv : Uint; Xnode : Node_Id; Temp : Node_Id; Rent : RE_Id; Ent : Entity_Id; begin Binary_Op_Validity_Checks (N); -- At this point the exponentiation must be dynamic since the static -- case has already been folded after Resolve by Eval_Op_Expon. -- Test for case of literal right argument if Compile_Time_Known_Value (Exp) then Expv := Expr_Value (Exp); -- We only fold small non-negative exponents. You might think we -- could fold small negative exponents for the real case, but we -- can't because we are required to raise Constraint_Error for -- the case of 0.0 ** (negative) even if Machine_Overflows = False. -- See ACVC test C4A012B. if Expv >= 0 and then Expv <= 4 then -- X ** 0 = 1 (or 1.0) if Expv = 0 then if Ekind (Typ) in Integer_Kind then Xnode := Make_Integer_Literal (Loc, Intval => 1); else Xnode := Make_Real_Literal (Loc, Ureal_1); end if; -- X ** 1 = X elsif Expv = 1 then Xnode := Base; -- X ** 2 = X * X elsif Expv = 2 then Xnode := Make_Op_Multiply (Loc, Left_Opnd => Duplicate_Subexpr (Base), Right_Opnd => Duplicate_Subexpr (Base)); -- X ** 3 = X * X * X elsif Expv = 3 then Xnode := Make_Op_Multiply (Loc, Left_Opnd => Make_Op_Multiply (Loc, Left_Opnd => Duplicate_Subexpr (Base), Right_Opnd => Duplicate_Subexpr (Base)), Right_Opnd => Duplicate_Subexpr (Base)); -- X ** 4 -> -- En : constant base'type := base * base; -- ... -- En * En else -- Expv = 4 Temp := Make_Defining_Identifier (Loc, New_Internal_Name ('E')); Insert_Actions (N, New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Temp, Constant_Present => True, Object_Definition => New_Reference_To (Typ, Loc), Expression => Make_Op_Multiply (Loc, Left_Opnd => Duplicate_Subexpr (Base), Right_Opnd => Duplicate_Subexpr (Base))))); Xnode := Make_Op_Multiply (Loc, Left_Opnd => New_Reference_To (Temp, Loc), Right_Opnd => New_Reference_To (Temp, Loc)); end if; Rewrite (N, Xnode); Analyze_And_Resolve (N, Typ); return; end if; end if; -- Case of (2 ** expression) appearing as an argument of an integer -- multiplication, or as the right argument of a division of a non- -- negative integer. In such cases we lave the node untouched, setting -- the flag Is_Natural_Power_Of_2_for_Shift set, then the expansion -- of the higher level node converts it into a shift. if Nkind (Base) = N_Integer_Literal and then Intval (Base) = 2 and then Is_Integer_Type (Root_Type (Exptyp)) and then Esize (Root_Type (Exptyp)) <= Esize (Standard_Integer) and then Is_Unsigned_Type (Exptyp) and then not Ovflo and then Nkind (Parent (N)) in N_Binary_Op then declare P : constant Node_Id := Parent (N); L : constant Node_Id := Left_Opnd (P); R : constant Node_Id := Right_Opnd (P); begin if (Nkind (P) = N_Op_Multiply and then ((Is_Integer_Type (Etype (L)) and then R = N) or else (Is_Integer_Type (Etype (R)) and then L = N)) and then not Do_Overflow_Check (P)) or else (Nkind (P) = N_Op_Divide and then Is_Integer_Type (Etype (L)) and then Is_Unsigned_Type (Etype (L)) and then R = N and then not Do_Overflow_Check (P)) then Set_Is_Power_Of_2_For_Shift (N); return; end if; end; end if; -- Fall through if exponentiation must be done using a runtime routine. -- First deal with modular case. if Is_Modular_Integer_Type (Rtyp) then -- Non-binary case, we call the special exponentiation routine for -- the non-binary case, converting the argument to Long_Long_Integer -- and passing the modulus value. Then the result is converted back -- to the base type. if Non_Binary_Modulus (Rtyp) then Rewrite (N, Convert_To (Typ, Make_Function_Call (Loc, Name => New_Reference_To (RTE (RE_Exp_Modular), Loc), Parameter_Associations => New_List ( Convert_To (Standard_Integer, Base), Make_Integer_Literal (Loc, Modulus (Rtyp)), Exp)))); -- Binary case, in this case, we call one of two routines, either -- the unsigned integer case, or the unsigned long long integer -- case, with a final "and" operation to do the required mod. else if UI_To_Int (Esize (Rtyp)) <= Standard_Integer_Size then Ent := RTE (RE_Exp_Unsigned); else Ent := RTE (RE_Exp_Long_Long_Unsigned); end if; Rewrite (N, Convert_To (Typ, Make_Op_And (Loc, Left_Opnd => Make_Function_Call (Loc, Name => New_Reference_To (Ent, Loc), Parameter_Associations => New_List ( Convert_To (Etype (First_Formal (Ent)), Base), Exp)), Right_Opnd => Make_Integer_Literal (Loc, Modulus (Rtyp) - 1)))); end if; -- Common exit point for modular type case Analyze_And_Resolve (N, Typ); return; -- Signed integer cases elsif Rtyp = Base_Type (Standard_Integer) then if Ovflo then Rent := RE_Exp_Integer; else Rent := RE_Exn_Integer; end if; elsif Rtyp = Base_Type (Standard_Short_Integer) then if Ovflo then Rent := RE_Exp_Short_Integer; else Rent := RE_Exn_Short_Integer; end if; elsif Rtyp = Base_Type (Standard_Short_Short_Integer) then if Ovflo then Rent := RE_Exp_Short_Short_Integer; else Rent := RE_Exn_Short_Short_Integer; end if; elsif Rtyp = Base_Type (Standard_Long_Integer) then if Ovflo then Rent := RE_Exp_Long_Integer; else Rent := RE_Exn_Long_Integer; end if; elsif (Rtyp = Base_Type (Standard_Long_Long_Integer) or else Rtyp = Universal_Integer) then if Ovflo then Rent := RE_Exp_Long_Long_Integer; else Rent := RE_Exn_Long_Long_Integer; end if; -- Floating-point cases elsif Rtyp = Standard_Float then if Ovflo then Rent := RE_Exp_Float; else Rent := RE_Exn_Float; end if; elsif Rtyp = Standard_Short_Float then if Ovflo then Rent := RE_Exp_Short_Float; else Rent := RE_Exn_Short_Float; end if; elsif Rtyp = Standard_Long_Float then if Ovflo then Rent := RE_Exp_Long_Float; else Rent := RE_Exn_Long_Float; end if; else pragma Assert (Rtyp = Standard_Long_Long_Float or else Rtyp = Universal_Real); if Ovflo then Rent := RE_Exp_Long_Long_Float; else Rent := RE_Exn_Long_Long_Float; end if; end if; -- Common processing for integer cases and floating-point cases. -- If we are in the base type, we can call runtime routine directly if Typ = Rtyp and then Rtyp /= Universal_Integer and then Rtyp /= Universal_Real then Rewrite (N, Make_Function_Call (Loc, Name => New_Reference_To (RTE (Rent), Loc), Parameter_Associations => New_List (Base, Exp))); -- Otherwise we have to introduce conversions (conversions are also -- required in the universal cases, since the runtime routine was -- typed using the largest integer or real case. else Rewrite (N, Convert_To (Typ, Make_Function_Call (Loc, Name => New_Reference_To (RTE (Rent), Loc), Parameter_Associations => New_List ( Convert_To (Rtyp, Base), Exp)))); end if; Analyze_And_Resolve (N, Typ); return; end Expand_N_Op_Expon; -------------------- -- Expand_N_Op_Ge -- -------------------- procedure Expand_N_Op_Ge (N : Node_Id) is Typ : constant Entity_Id := Etype (N); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); Typ1 : constant Entity_Id := Base_Type (Etype (Op1)); begin Binary_Op_Validity_Checks (N); if Vax_Float (Typ1) then Expand_Vax_Comparison (N); return; elsif Is_Array_Type (Typ1) then Expand_Array_Comparison (N); return; end if; if Is_Boolean_Type (Typ1) then Adjust_Condition (Op1); Adjust_Condition (Op2); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; Rewrite_Comparison (N); end Expand_N_Op_Ge; -------------------- -- Expand_N_Op_Gt -- -------------------- procedure Expand_N_Op_Gt (N : Node_Id) is Typ : constant Entity_Id := Etype (N); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); Typ1 : constant Entity_Id := Base_Type (Etype (Op1)); begin Binary_Op_Validity_Checks (N); if Vax_Float (Typ1) then Expand_Vax_Comparison (N); return; elsif Is_Array_Type (Typ1) then Expand_Array_Comparison (N); return; end if; if Is_Boolean_Type (Typ1) then Adjust_Condition (Op1); Adjust_Condition (Op2); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; Rewrite_Comparison (N); end Expand_N_Op_Gt; -------------------- -- Expand_N_Op_Le -- -------------------- procedure Expand_N_Op_Le (N : Node_Id) is Typ : constant Entity_Id := Etype (N); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); Typ1 : constant Entity_Id := Base_Type (Etype (Op1)); begin Binary_Op_Validity_Checks (N); if Vax_Float (Typ1) then Expand_Vax_Comparison (N); return; elsif Is_Array_Type (Typ1) then Expand_Array_Comparison (N); return; end if; if Is_Boolean_Type (Typ1) then Adjust_Condition (Op1); Adjust_Condition (Op2); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; Rewrite_Comparison (N); end Expand_N_Op_Le; -------------------- -- Expand_N_Op_Lt -- -------------------- procedure Expand_N_Op_Lt (N : Node_Id) is Typ : constant Entity_Id := Etype (N); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); Typ1 : constant Entity_Id := Base_Type (Etype (Op1)); begin Binary_Op_Validity_Checks (N); if Vax_Float (Typ1) then Expand_Vax_Comparison (N); return; elsif Is_Array_Type (Typ1) then Expand_Array_Comparison (N); return; end if; if Is_Boolean_Type (Typ1) then Adjust_Condition (Op1); Adjust_Condition (Op2); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; Rewrite_Comparison (N); end Expand_N_Op_Lt; ----------------------- -- Expand_N_Op_Minus -- ----------------------- procedure Expand_N_Op_Minus (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); begin Unary_Op_Validity_Checks (N); if Software_Overflow_Checking and then Is_Signed_Integer_Type (Etype (N)) and then Do_Overflow_Check (N) then -- Software overflow checking expands -expr into (0 - expr) Rewrite (N, Make_Op_Subtract (Loc, Left_Opnd => Make_Integer_Literal (Loc, 0), Right_Opnd => Right_Opnd (N))); Analyze_And_Resolve (N, Typ); -- Vax floating-point types case elsif Vax_Float (Etype (N)) then Expand_Vax_Arith (N); end if; end Expand_N_Op_Minus; --------------------- -- Expand_N_Op_Mod -- --------------------- procedure Expand_N_Op_Mod (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); T : constant Entity_Id := Etype (N); Left : constant Node_Id := Left_Opnd (N); Right : constant Node_Id := Right_Opnd (N); DOC : constant Boolean := Do_Overflow_Check (N); DDC : constant Boolean := Do_Division_Check (N); LLB : Uint; Llo : Uint; Lhi : Uint; LOK : Boolean; Rlo : Uint; Rhi : Uint; ROK : Boolean; begin Binary_Op_Validity_Checks (N); Determine_Range (Right, ROK, Rlo, Rhi); Determine_Range (Left, LOK, Llo, Lhi); -- Convert mod to rem if operands are known non-negative. We do this -- since it is quite likely that this will improve the quality of code, -- (the operation now corresponds to the hardware remainder), and it -- does not seem likely that it could be harmful. if LOK and then Llo >= 0 and then ROK and then Rlo >= 0 then Rewrite (N, Make_Op_Rem (Sloc (N), Left_Opnd => Left_Opnd (N), Right_Opnd => Right_Opnd (N))); -- Instead of reanalyzing the node we do the analysis manually. -- This avoids anomalies when the replacement is done in an -- instance and is epsilon more efficient. Set_Entity (N, Standard_Entity (S_Op_Rem)); Set_Etype (N, T); Set_Do_Overflow_Check (N, DOC); Set_Do_Division_Check (N, DDC); Expand_N_Op_Rem (N); Set_Analyzed (N); -- Otherwise, normal mod processing else if Is_Integer_Type (Etype (N)) then Apply_Divide_Check (N); end if; -- Deal with annoying case of largest negative number remainder -- minus one. Gigi does not handle this case correctly, because -- it generates a divide instruction which may trap in this case. -- In fact the check is quite easy, if the right operand is -1, -- then the mod value is always 0, and we can just ignore the -- left operand completely in this case. LLB := Expr_Value (Type_Low_Bound (Base_Type (Etype (Left)))); if ((not ROK) or else (Rlo <= (-1) and then (-1) <= Rhi)) and then ((not LOK) or else (Llo = LLB)) then Rewrite (N, Make_Conditional_Expression (Loc, Expressions => New_List ( Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr (Right), Right_Opnd => Make_Integer_Literal (Loc, -1)), Make_Integer_Literal (Loc, Uint_0), Relocate_Node (N)))); Set_Analyzed (Next (Next (First (Expressions (N))))); Analyze_And_Resolve (N, T); end if; end if; end Expand_N_Op_Mod; -------------------------- -- Expand_N_Op_Multiply -- -------------------------- procedure Expand_N_Op_Multiply (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Lop : constant Node_Id := Left_Opnd (N); Rop : constant Node_Id := Right_Opnd (N); Ltyp : constant Entity_Id := Etype (Lop); Rtyp : constant Entity_Id := Etype (Rop); Typ : Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); -- Special optimizations for integer types if Is_Integer_Type (Typ) then -- N * 0 = 0 * N = 0 for integer types if (Compile_Time_Known_Value (Right_Opnd (N)) and then Expr_Value (Right_Opnd (N)) = Uint_0) or else (Compile_Time_Known_Value (Left_Opnd (N)) and then Expr_Value (Left_Opnd (N)) = Uint_0) then Rewrite (N, Make_Integer_Literal (Loc, Uint_0)); Analyze_And_Resolve (N, Typ); return; end if; -- N * 1 = 1 * N = N for integer types if Compile_Time_Known_Value (Right_Opnd (N)) and then Expr_Value (Right_Opnd (N)) = Uint_1 then Rewrite (N, Left_Opnd (N)); return; elsif Compile_Time_Known_Value (Left_Opnd (N)) and then Expr_Value (Left_Opnd (N)) = Uint_1 then Rewrite (N, Right_Opnd (N)); return; end if; end if; -- Deal with VAX float case if Vax_Float (Typ) then Expand_Vax_Arith (N); return; end if; -- Convert x * 2 ** y to Shift_Left (x, y). Note that the fact that -- Is_Power_Of_2_For_Shift is set means that we know that our left -- operand is an integer, as required for this to work. if Nkind (Rop) = N_Op_Expon and then Is_Power_Of_2_For_Shift (Rop) then if Nkind (Lop) = N_Op_Expon and then Is_Power_Of_2_For_Shift (Lop) then -- convert 2 ** A * 2 ** B into 2 ** (A + B) Rewrite (N, Make_Op_Expon (Loc, Left_Opnd => Make_Integer_Literal (Loc, 2), Right_Opnd => Make_Op_Add (Loc, Left_Opnd => Right_Opnd (Lop), Right_Opnd => Right_Opnd (Rop)))); Analyze_And_Resolve (N, Typ); return; else Rewrite (N, Make_Op_Shift_Left (Loc, Left_Opnd => Lop, Right_Opnd => Convert_To (Standard_Natural, Right_Opnd (Rop)))); Analyze_And_Resolve (N, Typ); return; end if; -- Same processing for the operands the other way round elsif Nkind (Lop) = N_Op_Expon and then Is_Power_Of_2_For_Shift (Lop) then Rewrite (N, Make_Op_Shift_Left (Loc, Left_Opnd => Rop, Right_Opnd => Convert_To (Standard_Natural, Right_Opnd (Lop)))); Analyze_And_Resolve (N, Typ); return; end if; -- Do required fixup of universal fixed operation if Typ = Universal_Fixed then Fixup_Universal_Fixed_Operation (N); Typ := Etype (N); end if; -- Multiplications with fixed-point results if Is_Fixed_Point_Type (Typ) then -- No special processing if Treat_Fixed_As_Integer is set, -- since from a semantic point of view such operations are -- simply integer operations and will be treated that way. if not Treat_Fixed_As_Integer (N) then -- Case of fixed * integer => fixed if Is_Integer_Type (Rtyp) then Expand_Multiply_Fixed_By_Integer_Giving_Fixed (N); -- Case of integer * fixed => fixed elsif Is_Integer_Type (Ltyp) then Expand_Multiply_Integer_By_Fixed_Giving_Fixed (N); -- Case of fixed * fixed => fixed else Expand_Multiply_Fixed_By_Fixed_Giving_Fixed (N); end if; end if; -- Other cases of multiplication of fixed-point operands. Again -- we exclude the cases where Treat_Fixed_As_Integer flag is set. elsif (Is_Fixed_Point_Type (Ltyp) or else Is_Fixed_Point_Type (Rtyp)) and then not Treat_Fixed_As_Integer (N) then if Is_Integer_Type (Typ) then Expand_Multiply_Fixed_By_Fixed_Giving_Integer (N); else pragma Assert (Is_Floating_Point_Type (Typ)); Expand_Multiply_Fixed_By_Fixed_Giving_Float (N); end if; -- Mixed-mode operations can appear in a non-static universal -- context, in which case the integer argument must be converted -- explicitly. elsif Typ = Universal_Real and then Is_Integer_Type (Rtyp) then Rewrite (Rop, Convert_To (Universal_Real, Relocate_Node (Rop))); Analyze_And_Resolve (Rop, Universal_Real); elsif Typ = Universal_Real and then Is_Integer_Type (Ltyp) then Rewrite (Lop, Convert_To (Universal_Real, Relocate_Node (Lop))); Analyze_And_Resolve (Lop, Universal_Real); -- Non-fixed point cases, check software overflow checking required elsif Is_Signed_Integer_Type (Etype (N)) then Apply_Arithmetic_Overflow_Check (N); end if; end Expand_N_Op_Multiply; -------------------- -- Expand_N_Op_Ne -- -------------------- -- Rewrite node as the negation of an equality operation, and reanalyze. -- The equality to be used is defined in the same scope and has the same -- signature. It must be set explicitly because in an instance it may not -- have the same visibility as in the generic unit. procedure Expand_N_Op_Ne (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Neg : Node_Id; Ne : constant Entity_Id := Entity (N); begin Binary_Op_Validity_Checks (N); Neg := Make_Op_Not (Loc, Right_Opnd => Make_Op_Eq (Loc, Left_Opnd => Left_Opnd (N), Right_Opnd => Right_Opnd (N))); Set_Paren_Count (Right_Opnd (Neg), 1); if Scope (Ne) /= Standard_Standard then Set_Entity (Right_Opnd (Neg), Corresponding_Equality (Ne)); end if; Rewrite (N, Neg); Analyze_And_Resolve (N, Standard_Boolean); end Expand_N_Op_Ne; --------------------- -- Expand_N_Op_Not -- --------------------- -- If the argument is other than a Boolean array type, there is no -- special expansion required. -- For the packed case, we call the special routine in Exp_Pakd, except -- that if the component size is greater than one, we use the standard -- routine generating a gruesome loop (it is so peculiar to have packed -- arrays with non-standard Boolean representations anyway, so it does -- not matter that we do not handle this case efficiently). -- For the unpacked case (and for the special packed case where we have -- non standard Booleans, as discussed above), we generate and insert -- into the tree the following function definition: -- function Nnnn (A : arr) is -- B : arr; -- begin -- for J in a'range loop -- B (J) := not A (J); -- end loop; -- return B; -- end Nnnn; -- Here arr is the actual subtype of the parameter (and hence always -- constrained). Then we replace the not with a call to this function. procedure Expand_N_Op_Not (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Opnd : Node_Id; Arr : Entity_Id; A : Entity_Id; B : Entity_Id; J : Entity_Id; A_J : Node_Id; B_J : Node_Id; Func_Name : Entity_Id; Loop_Statement : Node_Id; begin Unary_Op_Validity_Checks (N); -- For boolean operand, deal with non-standard booleans if Is_Boolean_Type (Typ) then Adjust_Condition (Right_Opnd (N)); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); return; end if; -- Only array types need any other processing if not Is_Array_Type (Typ) then return; end if; -- Case of array operand. If bit packed, handle it in Exp_Pakd if Is_Bit_Packed_Array (Typ) and then Component_Size (Typ) = 1 then Expand_Packed_Not (N); return; end if; -- Case of array operand which is not bit-packed Opnd := Relocate_Node (Right_Opnd (N)); Convert_To_Actual_Subtype (Opnd); Arr := Etype (Opnd); Ensure_Defined (Arr, N); A := Make_Defining_Identifier (Loc, Name_uA); B := Make_Defining_Identifier (Loc, Name_uB); J := Make_Defining_Identifier (Loc, Name_uJ); A_J := Make_Indexed_Component (Loc, Prefix => New_Reference_To (A, Loc), Expressions => New_List (New_Reference_To (J, Loc))); B_J := Make_Indexed_Component (Loc, Prefix => New_Reference_To (B, Loc), Expressions => New_List (New_Reference_To (J, Loc))); Loop_Statement := Make_Implicit_Loop_Statement (N, Identifier => Empty, Iteration_Scheme => Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, Defining_Identifier => J, Discrete_Subtype_Definition => Make_Attribute_Reference (Loc, Prefix => Make_Identifier (Loc, Chars (A)), Attribute_Name => Name_Range))), Statements => New_List ( Make_Assignment_Statement (Loc, Name => B_J, Expression => Make_Op_Not (Loc, A_J)))); Func_Name := Make_Defining_Identifier (Loc, New_Internal_Name ('N')); Set_Is_Inlined (Func_Name); Insert_Action (N, Make_Subprogram_Body (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => Func_Name, Parameter_Specifications => New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => A, Parameter_Type => New_Reference_To (Typ, Loc))), Subtype_Mark => New_Reference_To (Typ, Loc)), Declarations => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => B, Object_Definition => New_Reference_To (Arr, Loc))), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Loop_Statement, Make_Return_Statement (Loc, Expression => Make_Identifier (Loc, Chars (B))))))); Rewrite (N, Make_Function_Call (Loc, Name => New_Reference_To (Func_Name, Loc), Parameter_Associations => New_List (Opnd))); Analyze_And_Resolve (N, Typ); end Expand_N_Op_Not; -------------------- -- Expand_N_Op_Or -- -------------------- procedure Expand_N_Op_Or (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); if Is_Array_Type (Etype (N)) then Expand_Boolean_Operator (N); elsif Is_Boolean_Type (Etype (N)) then Adjust_Condition (Left_Opnd (N)); Adjust_Condition (Right_Opnd (N)); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; end Expand_N_Op_Or; ---------------------- -- Expand_N_Op_Plus -- ---------------------- procedure Expand_N_Op_Plus (N : Node_Id) is begin Unary_Op_Validity_Checks (N); end Expand_N_Op_Plus; --------------------- -- Expand_N_Op_Rem -- --------------------- procedure Expand_N_Op_Rem (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Left : constant Node_Id := Left_Opnd (N); Right : constant Node_Id := Right_Opnd (N); LLB : Uint; Llo : Uint; Lhi : Uint; LOK : Boolean; Rlo : Uint; Rhi : Uint; ROK : Boolean; Typ : Entity_Id; begin Binary_Op_Validity_Checks (N); if Is_Integer_Type (Etype (N)) then Apply_Divide_Check (N); end if; -- Deal with annoying case of largest negative number remainder -- minus one. Gigi does not handle this case correctly, because -- it generates a divide instruction which may trap in this case. -- In fact the check is quite easy, if the right operand is -1, -- then the remainder is always 0, and we can just ignore the -- left operand completely in this case. Determine_Range (Right, ROK, Rlo, Rhi); Determine_Range (Left, LOK, Llo, Lhi); LLB := Expr_Value (Type_Low_Bound (Base_Type (Etype (Left)))); Typ := Etype (N); if ((not ROK) or else (Rlo <= (-1) and then (-1) <= Rhi)) and then ((not LOK) or else (Llo = LLB)) then Rewrite (N, Make_Conditional_Expression (Loc, Expressions => New_List ( Make_Op_Eq (Loc, Left_Opnd => Duplicate_Subexpr (Right), Right_Opnd => Make_Integer_Literal (Loc, -1)), Make_Integer_Literal (Loc, Uint_0), Relocate_Node (N)))); Set_Analyzed (Next (Next (First (Expressions (N))))); Analyze_And_Resolve (N, Typ); end if; end Expand_N_Op_Rem; ----------------------------- -- Expand_N_Op_Rotate_Left -- ----------------------------- procedure Expand_N_Op_Rotate_Left (N : Node_Id) is begin Binary_Op_Validity_Checks (N); end Expand_N_Op_Rotate_Left; ------------------------------ -- Expand_N_Op_Rotate_Right -- ------------------------------ procedure Expand_N_Op_Rotate_Right (N : Node_Id) is begin Binary_Op_Validity_Checks (N); end Expand_N_Op_Rotate_Right; ---------------------------- -- Expand_N_Op_Shift_Left -- ---------------------------- procedure Expand_N_Op_Shift_Left (N : Node_Id) is begin Binary_Op_Validity_Checks (N); end Expand_N_Op_Shift_Left; ----------------------------- -- Expand_N_Op_Shift_Right -- ----------------------------- procedure Expand_N_Op_Shift_Right (N : Node_Id) is begin Binary_Op_Validity_Checks (N); end Expand_N_Op_Shift_Right; ---------------------------------------- -- Expand_N_Op_Shift_Right_Arithmetic -- ---------------------------------------- procedure Expand_N_Op_Shift_Right_Arithmetic (N : Node_Id) is begin Binary_Op_Validity_Checks (N); end Expand_N_Op_Shift_Right_Arithmetic; -------------------------- -- Expand_N_Op_Subtract -- -------------------------- procedure Expand_N_Op_Subtract (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); -- N - 0 = N for integer types if Is_Integer_Type (Typ) and then Compile_Time_Known_Value (Right_Opnd (N)) and then Expr_Value (Right_Opnd (N)) = 0 then Rewrite (N, Left_Opnd (N)); return; end if; -- Arithemtic overflow checks for signed integer/fixed point types if Is_Signed_Integer_Type (Typ) or else Is_Fixed_Point_Type (Typ) then Apply_Arithmetic_Overflow_Check (N); -- Vax floating-point types case elsif Vax_Float (Typ) then Expand_Vax_Arith (N); end if; end Expand_N_Op_Subtract; --------------------- -- Expand_N_Op_Xor -- --------------------- procedure Expand_N_Op_Xor (N : Node_Id) is Typ : constant Entity_Id := Etype (N); begin Binary_Op_Validity_Checks (N); if Is_Array_Type (Etype (N)) then Expand_Boolean_Operator (N); elsif Is_Boolean_Type (Etype (N)) then Adjust_Condition (Left_Opnd (N)); Adjust_Condition (Right_Opnd (N)); Set_Etype (N, Standard_Boolean); Adjust_Result_Type (N, Typ); end if; end Expand_N_Op_Xor; ---------------------- -- Expand_N_Or_Else -- ---------------------- -- Expand into conditional expression if Actions present, and also -- deal with optimizing case of arguments being True or False. procedure Expand_N_Or_Else (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Left : constant Node_Id := Left_Opnd (N); Right : constant Node_Id := Right_Opnd (N); Actlist : List_Id; begin -- Deal with non-standard booleans if Is_Boolean_Type (Typ) then Adjust_Condition (Left); Adjust_Condition (Right); Set_Etype (N, Standard_Boolean); -- Check for cases of left argument is True or False elsif Nkind (Left) = N_Identifier then -- If left argument is False, change (False or else Right) to Right. -- Any actions associated with Right will be executed unconditionally -- and can thus be inserted into the tree unconditionally. if Entity (Left) = Standard_False then if Present (Actions (N)) then Insert_Actions (N, Actions (N)); end if; Rewrite (N, Right); Adjust_Result_Type (N, Typ); return; -- If left argument is True, change (True and then Right) to -- True. In this case we can forget the actions associated with -- Right, since they will never be executed. elsif Entity (Left) = Standard_True then Kill_Dead_Code (Right); Kill_Dead_Code (Actions (N)); Rewrite (N, New_Occurrence_Of (Standard_True, Loc)); Adjust_Result_Type (N, Typ); return; end if; end if; -- If Actions are present, we expand -- left or else right -- into -- if left then True else right end -- with the actions becoming the Else_Actions of the conditional -- expression. This conditional expression is then further expanded -- (and will eventually disappear) if Present (Actions (N)) then Actlist := Actions (N); Rewrite (N, Make_Conditional_Expression (Loc, Expressions => New_List ( Left, New_Occurrence_Of (Standard_True, Loc), Right))); Set_Else_Actions (N, Actlist); Analyze_And_Resolve (N, Standard_Boolean); Adjust_Result_Type (N, Typ); return; end if; -- No actions present, check for cases of right argument True/False if Nkind (Right) = N_Identifier then -- Change (Left or else False) to Left. Note that we know there -- are no actions associated with the True operand, since we -- just checked for this case above. if Entity (Right) = Standard_False then Rewrite (N, Left); -- Change (Left or else True) to True, making sure to preserve -- any side effects associated with the Left operand. elsif Entity (Right) = Standard_True then Remove_Side_Effects (Left); Rewrite (N, New_Occurrence_Of (Standard_True, Loc)); end if; end if; Adjust_Result_Type (N, Typ); end Expand_N_Or_Else; ----------------------------------- -- Expand_N_Qualified_Expression -- ----------------------------------- procedure Expand_N_Qualified_Expression (N : Node_Id) is Operand : constant Node_Id := Expression (N); Target_Type : constant Entity_Id := Entity (Subtype_Mark (N)); begin Apply_Constraint_Check (Operand, Target_Type, No_Sliding => True); end Expand_N_Qualified_Expression; --------------------------------- -- Expand_N_Selected_Component -- --------------------------------- -- If the selector is a discriminant of a concurrent object, rewrite the -- prefix to denote the corresponding record type. procedure Expand_N_Selected_Component (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Par : constant Node_Id := Parent (N); P : constant Node_Id := Prefix (N); Disc : Entity_Id; Ptyp : Entity_Id := Underlying_Type (Etype (P)); New_N : Node_Id; function In_Left_Hand_Side (Comp : Node_Id) return Boolean; -- Gigi needs a temporary for prefixes that depend on a discriminant, -- unless the context of an assignment can provide size information. function In_Left_Hand_Side (Comp : Node_Id) return Boolean is begin return (Nkind (Parent (Comp)) = N_Assignment_Statement and then Comp = Name (Parent (Comp))) or else (Present (Parent (Comp)) and then Nkind (Parent (Comp)) in N_Subexpr and then In_Left_Hand_Side (Parent (Comp))); end In_Left_Hand_Side; begin if Do_Discriminant_Check (N) then -- Present the discrminant checking function to the backend, -- so that it can inline the call to the function. Add_Inlined_Body (Discriminant_Checking_Func (Original_Record_Component (Entity (Selector_Name (N))))); end if; -- Insert explicit dereference call for the checked storage pool case if Is_Access_Type (Ptyp) then Insert_Dereference_Action (P); return; end if; -- Gigi cannot handle unchecked conversions that are the prefix of -- a selected component with discriminants. This must be checked -- during expansion, because during analysis the type of the selector -- is not known at the point the prefix is analyzed. If the conversion -- is the target of an assignment, we cannot force the evaluation, of -- course. if Nkind (Prefix (N)) = N_Unchecked_Type_Conversion and then Has_Discriminants (Etype (N)) and then not In_Left_Hand_Side (N) then Force_Evaluation (Prefix (N)); end if; -- Remaining processing applies only if selector is a discriminant if Ekind (Entity (Selector_Name (N))) = E_Discriminant then -- If the selector is a discriminant of a constrained record type, -- rewrite the expression with the actual value of the discriminant. -- Don't do this on the left hand of an assignment statement (this -- happens in generated code, and means we really want to set it!) -- We also only do this optimization for discrete types, and not -- for access types (access discriminants get us into trouble!) -- We also do not expand the prefix of an attribute or the -- operand of an object renaming declaration. if Is_Record_Type (Ptyp) and then Has_Discriminants (Ptyp) and then Is_Constrained (Ptyp) and then Is_Discrete_Type (Etype (N)) and then (Nkind (Par) /= N_Assignment_Statement or else Name (Par) /= N) and then (Nkind (Par) /= N_Attribute_Reference or else Prefix (Par) /= N) and then not Is_Renamed_Object (N) then declare D : Entity_Id; E : Elmt_Id; begin D := First_Discriminant (Ptyp); E := First_Elmt (Discriminant_Constraint (Ptyp)); while Present (E) loop if D = Entity (Selector_Name (N)) then -- In the context of a case statement, the expression -- may have the base type of the discriminant, and we -- need to preserve the constraint to avoid spurious -- errors on missing cases. if Nkind (Parent (N)) = N_Case_Statement and then Etype (Node (E)) /= Etype (D) then Rewrite (N, Make_Qualified_Expression (Loc, Subtype_Mark => New_Occurrence_Of (Etype (D), Loc), Expression => New_Copy (Node (E)))); Analyze (N); else Rewrite (N, New_Copy (Node (E))); end if; Set_Is_Static_Expression (N, False); return; end if; Next_Elmt (E); Next_Discriminant (D); end loop; -- Note: the above loop should always terminate, but if -- it does not, we just missed an optimization due to -- some glitch (perhaps a previous error), so ignore! end; end if; -- The only remaining processing is in the case of a discriminant of -- a concurrent object, where we rewrite the prefix to denote the -- corresponding record type. If the type is derived and has renamed -- discriminants, use corresponding discriminant, which is the one -- that appears in the corresponding record. if not Is_Concurrent_Type (Ptyp) then return; end if; Disc := Entity (Selector_Name (N)); if Is_Derived_Type (Ptyp) and then Present (Corresponding_Discriminant (Disc)) then Disc := Corresponding_Discriminant (Disc); end if; New_N := Make_Selected_Component (Loc, Prefix => Unchecked_Convert_To (Corresponding_Record_Type (Ptyp), New_Copy_Tree (P)), Selector_Name => Make_Identifier (Loc, Chars (Disc))); Rewrite (N, New_N); Analyze (N); end if; end Expand_N_Selected_Component; -------------------- -- Expand_N_Slice -- -------------------- procedure Expand_N_Slice (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Pfx : constant Node_Id := Prefix (N); Ptp : Entity_Id := Etype (Pfx); Ent : Entity_Id; Decl : Node_Id; begin -- Special handling for access types if Is_Access_Type (Ptp) then -- Check for explicit dereference required for checked pool Insert_Dereference_Action (Pfx); -- If we have an access to a packed array type, then put in an -- explicit dereference. We do this in case the slice must be -- expanded, and we want to make sure we get an access check. Ptp := Designated_Type (Ptp); if Is_Array_Type (Ptp) and then Is_Packed (Ptp) then Rewrite (Pfx, Make_Explicit_Dereference (Sloc (N), Prefix => Relocate_Node (Pfx))); Analyze_And_Resolve (Pfx, Ptp); -- The prefix will now carry the Access_Check flag for the back -- end, remove it from slice itself. Set_Do_Access_Check (N, False); end if; end if; -- Range checks are potentially also needed for cases involving -- a slice indexed by a subtype indication, but Do_Range_Check -- can currently only be set for expressions ??? if not Index_Checks_Suppressed (Ptp) and then (not Is_Entity_Name (Pfx) or else not Index_Checks_Suppressed (Entity (Pfx))) and then Nkind (Discrete_Range (N)) /= N_Subtype_Indication then Enable_Range_Check (Discrete_Range (N)); end if; -- The remaining case to be handled is packed slices. We can leave -- packed slices as they are in the following situations: -- 1. Right or left side of an assignment (we can handle this -- situation correctly in the assignment statement expansion). -- 2. Prefix of indexed component (the slide is optimized away -- in this case, see the start of Expand_N_Slice. -- 3. Object renaming declaration, since we want the name of -- the slice, not the value. -- 4. Argument to procedure call, since copy-in/copy-out handling -- may be required, and this is handled in the expansion of -- call itself. -- 5. Prefix of an address attribute (this is an error which -- is caught elsewhere, and the expansion would intefere -- with generating the error message). if Is_Packed (Typ) and then Nkind (Parent (N)) /= N_Assignment_Statement and then Nkind (Parent (N)) /= N_Indexed_Component and then not Is_Renamed_Object (N) and then Nkind (Parent (N)) /= N_Procedure_Call_Statement and then (Nkind (Parent (N)) /= N_Attribute_Reference or else Attribute_Name (Parent (N)) /= Name_Address) then Ent := Make_Defining_Identifier (Loc, New_Internal_Name ('T')); Decl := Make_Object_Declaration (Loc, Defining_Identifier => Ent, Object_Definition => New_Occurrence_Of (Typ, Loc)); Set_No_Initialization (Decl); Insert_Actions (N, New_List ( Decl, Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Ent, Loc), Expression => Relocate_Node (N)))); Rewrite (N, New_Occurrence_Of (Ent, Loc)); Analyze_And_Resolve (N, Typ); end if; end Expand_N_Slice; ------------------------------ -- Expand_N_Type_Conversion -- ------------------------------ procedure Expand_N_Type_Conversion (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Operand : constant Node_Id := Expression (N); Target_Type : constant Entity_Id := Etype (N); Operand_Type : Entity_Id := Etype (Operand); procedure Handle_Changed_Representation; -- This is called in the case of record and array type conversions -- to see if there is a change of representation to be handled. -- Change of representation is actually handled at the assignment -- statement level, and what this procedure does is rewrite node N -- conversion as an assignment to temporary. If there is no change -- of representation, then the conversion node is unchanged. procedure Real_Range_Check; -- Handles generation of range check for real target value ----------------------------------- -- Handle_Changed_Representation -- ----------------------------------- procedure Handle_Changed_Representation is Temp : Entity_Id; Decl : Node_Id; Odef : Node_Id; Disc : Node_Id; N_Ix : Node_Id; Cons : List_Id; begin -- Nothing to do if no change of representation if Same_Representation (Operand_Type, Target_Type) then return; -- The real change of representation work is done by the assignment -- statement processing. So if this type conversion is appearing as -- the expression of an assignment statement, nothing needs to be -- done to the conversion. elsif Nkind (Parent (N)) = N_Assignment_Statement then return; -- Otherwise we need to generate a temporary variable, and do the -- change of representation assignment into that temporary variable. -- The conversion is then replaced by a reference to this variable. else Cons := No_List; -- If type is unconstrained we have to add a constraint, -- copied from the actual value of the left hand side. if not Is_Constrained (Target_Type) then if Has_Discriminants (Operand_Type) then Disc := First_Discriminant (Operand_Type); Cons := New_List; while Present (Disc) loop Append_To (Cons, Make_Selected_Component (Loc, Prefix => Duplicate_Subexpr (Operand), Selector_Name => Make_Identifier (Loc, Chars (Disc)))); Next_Discriminant (Disc); end loop; elsif Is_Array_Type (Operand_Type) then N_Ix := First_Index (Target_Type); Cons := New_List; for J in 1 .. Number_Dimensions (Operand_Type) loop -- We convert the bounds explicitly. We use an unchecked -- conversion because bounds checks are done elsewhere. Append_To (Cons, Make_Range (Loc, Low_Bound => Unchecked_Convert_To (Etype (N_Ix), Make_Attribute_Reference (Loc, Prefix => Duplicate_Subexpr (Operand, Name_Req => True), Attribute_Name => Name_First, Expressions => New_List ( Make_Integer_Literal (Loc, J)))), High_Bound => Unchecked_Convert_To (Etype (N_Ix), Make_Attribute_Reference (Loc, Prefix => Duplicate_Subexpr (Operand, Name_Req => True), Attribute_Name => Name_Last, Expressions => New_List ( Make_Integer_Literal (Loc, J)))))); Next_Index (N_Ix); end loop; end if; end if; Odef := New_Occurrence_Of (Target_Type, Loc); if Present (Cons) then Odef := Make_Subtype_Indication (Loc, Subtype_Mark => Odef, Constraint => Make_Index_Or_Discriminant_Constraint (Loc, Constraints => Cons)); end if; Temp := Make_Defining_Identifier (Loc, New_Internal_Name ('C')); Decl := Make_Object_Declaration (Loc, Defining_Identifier => Temp, Object_Definition => Odef); Set_No_Initialization (Decl, True); -- Insert required actions. It is essential to suppress checks -- since we have suppressed default initialization, which means -- that the variable we create may have no discriminants. Insert_Actions (N, New_List ( Decl, Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Temp, Loc), Expression => Relocate_Node (N))), Suppress => All_Checks); Rewrite (N, New_Occurrence_Of (Temp, Loc)); return; end if; end Handle_Changed_Representation; ---------------------- -- Real_Range_Check -- ---------------------- -- Case of conversions to floating-point or fixed-point. If range -- checks are enabled and the target type has a range constraint, -- we convert: -- typ (x) -- to -- Tnn : typ'Base := typ'Base (x); -- [constraint_error when Tnn < typ'First or else Tnn > typ'Last] -- Tnn procedure Real_Range_Check is Btyp : constant Entity_Id := Base_Type (Target_Type); Lo : constant Node_Id := Type_Low_Bound (Target_Type); Hi : constant Node_Id := Type_High_Bound (Target_Type); Conv : Node_Id; Tnn : Entity_Id; begin -- Nothing to do if conversion was rewritten if Nkind (N) /= N_Type_Conversion then return; end if; -- Nothing to do if range checks suppressed, or target has the -- same range as the base type (or is the base type). if Range_Checks_Suppressed (Target_Type) or else (Lo = Type_Low_Bound (Btyp) and then Hi = Type_High_Bound (Btyp)) then return; end if; -- Nothing to do if expression is an entity on which checks -- have been suppressed. if Is_Entity_Name (Expression (N)) and then Range_Checks_Suppressed (Entity (Expression (N))) then return; end if; -- Here we rewrite the conversion as described above Conv := Relocate_Node (N); Rewrite (Subtype_Mark (Conv), New_Occurrence_Of (Btyp, Loc)); Set_Etype (Conv, Btyp); -- Skip overflow check for integer to float conversions, -- since it is not needed, and in any case gigi generates -- incorrect code for such overflow checks ??? if not Is_Integer_Type (Etype (Expression (N))) then Set_Do_Overflow_Check (Conv, True); end if; Tnn := Make_Defining_Identifier (Loc, Chars => New_Internal_Name ('T')); Insert_Actions (N, New_List ( Make_Object_Declaration (Loc, Defining_Identifier => Tnn, Object_Definition => New_Occurrence_Of (Btyp, Loc), Expression => Conv), Make_Raise_Constraint_Error (Loc, Condition => Make_Or_Else (Loc, Left_Opnd => Make_Op_Lt (Loc, Left_Opnd => New_Occurrence_Of (Tnn, Loc), Right_Opnd => Make_Attribute_Reference (Loc, Attribute_Name => Name_First, Prefix => New_Occurrence_Of (Target_Type, Loc))), Right_Opnd => Make_Op_Gt (Loc, Left_Opnd => New_Occurrence_Of (Tnn, Loc), Right_Opnd => Make_Attribute_Reference (Loc, Attribute_Name => Name_Last, Prefix => New_Occurrence_Of (Target_Type, Loc))))))); Rewrite (N, New_Occurrence_Of (Tnn, Loc)); Analyze_And_Resolve (N, Btyp); end Real_Range_Check; -- Start of processing for Expand_N_Type_Conversion begin -- Nothing at all to do if conversion is to the identical type -- so remove the conversion completely, it is useless. if Operand_Type = Target_Type then Rewrite (N, Relocate_Node (Expression (N))); return; end if; -- Deal with Vax floating-point cases if Vax_Float (Operand_Type) or else Vax_Float (Target_Type) then Expand_Vax_Conversion (N); return; end if; -- Nothing to do if this is the second argument of read. This -- is a "backwards" conversion that will be handled by the -- specialized code in attribute processing. if Nkind (Parent (N)) = N_Attribute_Reference and then Attribute_Name (Parent (N)) = Name_Read and then Next (First (Expressions (Parent (N)))) = N then return; end if; -- Here if we may need to expand conversion -- Special case of converting from non-standard boolean type if Is_Boolean_Type (Operand_Type) and then (Nonzero_Is_True (Operand_Type)) then Adjust_Condition (Operand); Set_Etype (Operand, Standard_Boolean); Operand_Type := Standard_Boolean; end if; -- Case of converting to an access type if Is_Access_Type (Target_Type) then -- Apply an accessibility check if the operand is an -- access parameter. Note that other checks may still -- need to be applied below (such as tagged type checks). if Is_Entity_Name (Operand) and then Ekind (Entity (Operand)) in Formal_Kind and then Ekind (Etype (Operand)) = E_Anonymous_Access_Type then Apply_Accessibility_Check (Operand, Target_Type); -- If the level of the operand type is statically deeper -- then the level of the target type, then force Program_Error. -- Note that this can only occur for cases where the attribute -- is within the body of an instantiation (otherwise the -- conversion will already have been rejected as illegal). -- Note: warnings are issued by the analyzer for the instance -- cases. elsif In_Instance_Body and then Type_Access_Level (Operand_Type) > Type_Access_Level (Target_Type) then Rewrite (N, Make_Raise_Program_Error (Sloc (N))); Set_Etype (N, Target_Type); -- When the operand is a selected access discriminant -- the check needs to be made against the level of the -- object denoted by the prefix of the selected name. -- Force Program_Error for this case as well (this -- accessibility violation can only happen if within -- the body of an instantiation). elsif In_Instance_Body and then Ekind (Operand_Type) = E_Anonymous_Access_Type and then Nkind (Operand) = N_Selected_Component and then Object_Access_Level (Operand) > Type_Access_Level (Target_Type) then Rewrite (N, Make_Raise_Program_Error (Sloc (N))); Set_Etype (N, Target_Type); end if; end if; -- Case of conversions of tagged types and access to tagged types -- When needed, that is to say when the expression is class-wide, -- Add runtime a tag check for (strict) downward conversion by using -- the membership test, generating: -- [constraint_error when Operand not in Target_Type'Class] -- or in the access type case -- [constraint_error -- when Operand /= null -- and then Operand.all not in -- Designated_Type (Target_Type)'Class] if (Is_Access_Type (Target_Type) and then Is_Tagged_Type (Designated_Type (Target_Type))) or else Is_Tagged_Type (Target_Type) then -- Do not do any expansion in the access type case if the -- parent is a renaming, since this is an error situation -- which will be caught by Sem_Ch8, and the expansion can -- intefere with this error check. if Is_Access_Type (Target_Type) and then Is_Renamed_Object (N) then return; end if; -- Oherwise, proceed with processing tagged conversion declare Actual_Operand_Type : Entity_Id; Actual_Target_Type : Entity_Id; Cond : Node_Id; begin if Is_Access_Type (Target_Type) then Actual_Operand_Type := Designated_Type (Operand_Type); Actual_Target_Type := Designated_Type (Target_Type); else Actual_Operand_Type := Operand_Type; Actual_Target_Type := Target_Type; end if; if Is_Class_Wide_Type (Actual_Operand_Type) and then Root_Type (Actual_Operand_Type) /= Actual_Target_Type and then Is_Ancestor (Root_Type (Actual_Operand_Type), Actual_Target_Type) and then not Tag_Checks_Suppressed (Actual_Target_Type) then -- The conversion is valid for any descendant of the -- target type Actual_Target_Type := Class_Wide_Type (Actual_Target_Type); if Is_Access_Type (Target_Type) then Cond := Make_And_Then (Loc, Left_Opnd => Make_Op_Ne (Loc, Left_Opnd => Duplicate_Subexpr (Operand), Right_Opnd => Make_Null (Loc)), Right_Opnd => Make_Not_In (Loc, Left_Opnd => Make_Explicit_Dereference (Loc, Prefix => Duplicate_Subexpr (Operand)), Right_Opnd => New_Reference_To (Actual_Target_Type, Loc))); else Cond := Make_Not_In (Loc, Left_Opnd => Duplicate_Subexpr (Operand), Right_Opnd => New_Reference_To (Actual_Target_Type, Loc)); end if; Insert_Action (N, Make_Raise_Constraint_Error (Loc, Condition => Cond)); Change_Conversion_To_Unchecked (N); Analyze_And_Resolve (N, Target_Type); end if; end; -- Case of other access type conversions elsif Is_Access_Type (Target_Type) then Apply_Constraint_Check (Operand, Target_Type); -- Case of conversions from a fixed-point type -- These conversions require special expansion and processing, found -- in the Exp_Fixd package. We ignore cases where Conversion_OK is -- set, since from a semantic point of view, these are simple integer -- conversions, which do not need further processing. elsif Is_Fixed_Point_Type (Operand_Type) and then not Conversion_OK (N) then -- We should never see universal fixed at this case, since the -- expansion of the constituent divide or multiply should have -- eliminated the explicit mention of universal fixed. pragma Assert (Operand_Type /= Universal_Fixed); -- Check for special case of the conversion to universal real -- that occurs as a result of the use of a round attribute. -- In this case, the real type for the conversion is taken -- from the target type of the Round attribute and the -- result must be marked as rounded. if Target_Type = Universal_Real and then Nkind (Parent (N)) = N_Attribute_Reference and then Attribute_Name (Parent (N)) = Name_Round then Set_Rounded_Result (N); Set_Etype (N, Etype (Parent (N))); end if; -- Otherwise do correct fixed-conversion, but skip these if the -- Conversion_OK flag is set, because from a semantic point of -- view these are simple integer conversions needing no further -- processing (the backend will simply treat them as integers) if not Conversion_OK (N) then if Is_Fixed_Point_Type (Etype (N)) then Expand_Convert_Fixed_To_Fixed (N); Real_Range_Check; elsif Is_Integer_Type (Etype (N)) then Expand_Convert_Fixed_To_Integer (N); else pragma Assert (Is_Floating_Point_Type (Etype (N))); Expand_Convert_Fixed_To_Float (N); Real_Range_Check; end if; end if; -- Case of conversions to a fixed-point type -- These conversions require special expansion and processing, found -- in the Exp_Fixd package. Again, ignore cases where Conversion_OK -- is set, since from a semantic point of view, these are simple -- integer conversions, which do not need further processing. elsif Is_Fixed_Point_Type (Target_Type) and then not Conversion_OK (N) then if Is_Integer_Type (Operand_Type) then Expand_Convert_Integer_To_Fixed (N); Real_Range_Check; else pragma Assert (Is_Floating_Point_Type (Operand_Type)); Expand_Convert_Float_To_Fixed (N); Real_Range_Check; end if; -- Case of float-to-integer conversions -- We also handle float-to-fixed conversions with Conversion_OK set -- since semantically the fixed-point target is treated as though it -- were an integer in such cases. elsif Is_Floating_Point_Type (Operand_Type) and then (Is_Integer_Type (Target_Type) or else (Is_Fixed_Point_Type (Target_Type) and then Conversion_OK (N))) then -- Special processing required if the conversion is the expression -- of a Truncation attribute reference. In this case we replace: -- ityp (ftyp'Truncation (x)) -- by -- ityp (x) -- with the Float_Truncate flag set. This is clearly more efficient. if Nkind (Operand) = N_Attribute_Reference and then Attribute_Name (Operand) = Name_Truncation then Rewrite (Operand, Relocate_Node (First (Expressions (Operand)))); Set_Float_Truncate (N, True); end if; -- One more check here, gcc is still not able to do conversions of -- this type with proper overflow checking, and so gigi is doing an -- approximation of what is required by doing floating-point compares -- with the end-point. But that can lose precision in some cases, and -- give a wrong result. Converting the operand to Long_Long_Float is -- helpful, but still does not catch all cases with 64-bit integers -- on targets with only 64-bit floats ??? if Do_Range_Check (Expression (N)) then Rewrite (Expression (N), Make_Type_Conversion (Loc, Subtype_Mark => New_Occurrence_Of (Standard_Long_Long_Float, Loc), Expression => Relocate_Node (Expression (N)))); Set_Etype (Expression (N), Standard_Long_Long_Float); Enable_Range_Check (Expression (N)); Set_Do_Range_Check (Expression (Expression (N)), False); end if; -- Case of array conversions -- Expansion of array conversions, add required length/range checks -- but only do this if there is no change of representation. For -- handling of this case, see Handle_Changed_Representation. elsif Is_Array_Type (Target_Type) then if Is_Constrained (Target_Type) then Apply_Length_Check (Operand, Target_Type); else Apply_Range_Check (Operand, Target_Type); end if; Handle_Changed_Representation; -- Case of conversions of discriminated types -- Add required discriminant checks if target is constrained. Again -- this change is skipped if we have a change of representation. elsif Has_Discriminants (Target_Type) and then Is_Constrained (Target_Type) then Apply_Discriminant_Check (Operand, Target_Type); Handle_Changed_Representation; -- Case of all other record conversions. The only processing required -- is to check for a change of representation requiring the special -- assignment processing. elsif Is_Record_Type (Target_Type) then Handle_Changed_Representation; -- Case of conversions of enumeration types elsif Is_Enumeration_Type (Target_Type) then -- Special processing is required if there is a change of -- representation (from enumeration representation clauses) if not Same_Representation (Target_Type, Operand_Type) then -- Convert: x(y) to x'val (ytyp'val (y)) Rewrite (N, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Target_Type, Loc), Attribute_Name => Name_Val, Expressions => New_List ( Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Operand_Type, Loc), Attribute_Name => Name_Pos, Expressions => New_List (Operand))))); Analyze_And_Resolve (N, Target_Type); end if; -- Case of conversions to floating-point elsif Is_Floating_Point_Type (Target_Type) then Real_Range_Check; -- The remaining cases require no front end processing else null; end if; -- At this stage, either the conversion node has been transformed -- into some other equivalent expression, or left as a conversion -- that can be handled by Gigi. The conversions that Gigi can handle -- are the following: -- Conversions with no change of representation or type -- Numeric conversions involving integer values, floating-point -- values, and fixed-point values. Fixed-point values are allowed -- only if Conversion_OK is set, i.e. if the fixed-point values -- are to be treated as integers. -- No other conversions should be passed to Gigi. end Expand_N_Type_Conversion; ----------------------------------- -- Expand_N_Unchecked_Expression -- ----------------------------------- -- Remove the unchecked expression node from the tree. It's job was simply -- to make sure that its constituent expression was handled with checks -- off, and now that that is done, we can remove it from the tree, and -- indeed must, since gigi does not expect to see these nodes. procedure Expand_N_Unchecked_Expression (N : Node_Id) is Exp : constant Node_Id := Expression (N); begin Set_Assignment_OK (Exp, Assignment_OK (N) or Assignment_OK (Exp)); Rewrite (N, Exp); end Expand_N_Unchecked_Expression; ---------------------------------------- -- Expand_N_Unchecked_Type_Conversion -- ---------------------------------------- -- If this cannot be handled by Gigi and we haven't already made -- a temporary for it, do it now. procedure Expand_N_Unchecked_Type_Conversion (N : Node_Id) is Target_Type : constant Entity_Id := Etype (N); Operand : constant Node_Id := Expression (N); Operand_Type : constant Entity_Id := Etype (Operand); begin -- If we have a conversion of a compile time known value to a target -- type and the value is in range of the target type, then we can simply -- replace the construct by an integer literal of the correct type. We -- only apply this to integer types being converted. Possibly it may -- apply in other cases, but it is too much trouble to worry about. -- Note that we do not do this transformation if the Kill_Range_Check -- flag is set, since then the value may be outside the expected range. -- This happens in the Normalize_Scalars case. if Is_Integer_Type (Target_Type) and then Is_Integer_Type (Operand_Type) and then Compile_Time_Known_Value (Operand) and then not Kill_Range_Check (N) then declare Val : constant Uint := Expr_Value (Operand); begin if Compile_Time_Known_Value (Type_Low_Bound (Target_Type)) and then Compile_Time_Known_Value (Type_High_Bound (Target_Type)) and then Val >= Expr_Value (Type_Low_Bound (Target_Type)) and then Val <= Expr_Value (Type_High_Bound (Target_Type)) then Rewrite (N, Make_Integer_Literal (Sloc (N), Val)); Analyze_And_Resolve (N, Target_Type); return; end if; end; end if; -- Nothing to do if conversion is safe if Safe_Unchecked_Type_Conversion (N) then return; end if; -- Otherwise force evaluation unless Assignment_OK flag is set (this -- flag indicates ??? -- more comments needed here) if Assignment_OK (N) then null; else Force_Evaluation (N); end if; end Expand_N_Unchecked_Type_Conversion; ---------------------------- -- Expand_Record_Equality -- ---------------------------- -- For non-variant records, Equality is expanded when needed into: -- and then Lhs.Discr1 = Rhs.Discr1 -- and then ... -- and then Lhs.Discrn = Rhs.Discrn -- and then Lhs.Cmp1 = Rhs.Cmp1 -- and then ... -- and then Lhs.Cmpn = Rhs.Cmpn -- The expression is folded by the back-end for adjacent fields. This -- function is called for tagged record in only one occasion: for imple- -- menting predefined primitive equality (see Predefined_Primitives_Bodies) -- otherwise the primitive "=" is used directly. function Expand_Record_Equality (Nod : Node_Id; Typ : Entity_Id; Lhs : Node_Id; Rhs : Node_Id; Bodies : List_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (Nod); function Suitable_Element (C : Entity_Id) return Entity_Id; -- Return the first field to compare beginning with C, skipping the -- inherited components function Suitable_Element (C : Entity_Id) return Entity_Id is begin if No (C) then return Empty; elsif Ekind (C) /= E_Discriminant and then Ekind (C) /= E_Component then return Suitable_Element (Next_Entity (C)); elsif Is_Tagged_Type (Typ) and then C /= Original_Record_Component (C) then return Suitable_Element (Next_Entity (C)); elsif Chars (C) = Name_uController or else Chars (C) = Name_uTag then return Suitable_Element (Next_Entity (C)); else return C; end if; end Suitable_Element; Result : Node_Id; C : Entity_Id; First_Time : Boolean := True; -- Start of processing for Expand_Record_Equality begin -- Special processing for the unchecked union case, which will occur -- only in the context of tagged types and dynamic dispatching, since -- other cases are handled statically. We return True, but insert a -- raise Program_Error statement. if Is_Unchecked_Union (Typ) then -- If this is a component of an enclosing record, return the Raise -- statement directly. if No (Parent (Lhs)) then Result := Make_Raise_Program_Error (Loc); Set_Etype (Result, Standard_Boolean); return Result; else Insert_Action (Lhs, Make_Raise_Program_Error (Loc)); return New_Occurrence_Of (Standard_True, Loc); end if; end if; -- Generates the following code: (assuming that Typ has one Discr and -- component C2 is also a record) -- True -- and then Lhs.Discr1 = Rhs.Discr1 -- and then Lhs.C1 = Rhs.C1 -- and then Lhs.C2.C1=Rhs.C2.C1 and then ... Lhs.C2.Cn=Rhs.C2.Cn -- and then ... -- and then Lhs.Cmpn = Rhs.Cmpn Result := New_Reference_To (Standard_True, Loc); C := Suitable_Element (First_Entity (Typ)); while Present (C) loop declare New_Lhs : Node_Id; New_Rhs : Node_Id; begin if First_Time then First_Time := False; New_Lhs := Lhs; New_Rhs := Rhs; else New_Lhs := New_Copy_Tree (Lhs); New_Rhs := New_Copy_Tree (Rhs); end if; Result := Make_And_Then (Loc, Left_Opnd => Result, Right_Opnd => Expand_Composite_Equality (Nod, Etype (C), Lhs => Make_Selected_Component (Loc, Prefix => New_Lhs, Selector_Name => New_Reference_To (C, Loc)), Rhs => Make_Selected_Component (Loc, Prefix => New_Rhs, Selector_Name => New_Reference_To (C, Loc)), Bodies => Bodies)); end; C := Suitable_Element (Next_Entity (C)); end loop; return Result; end Expand_Record_Equality; ------------------------------------- -- Fixup_Universal_Fixed_Operation -- ------------------------------------- procedure Fixup_Universal_Fixed_Operation (N : Node_Id) is Conv : constant Node_Id := Parent (N); begin -- We must have a type conversion immediately above us pragma Assert (Nkind (Conv) = N_Type_Conversion); -- Normally the type conversion gives our target type. The exception -- occurs in the case of the Round attribute, where the conversion -- will be to universal real, and our real type comes from the Round -- attribute (as well as an indication that we must round the result) if Nkind (Parent (Conv)) = N_Attribute_Reference and then Attribute_Name (Parent (Conv)) = Name_Round then Set_Etype (N, Etype (Parent (Conv))); Set_Rounded_Result (N); -- Normal case where type comes from conversion above us else Set_Etype (N, Etype (Conv)); end if; end Fixup_Universal_Fixed_Operation; ------------------------------- -- Insert_Dereference_Action -- ------------------------------- procedure Insert_Dereference_Action (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Typ : constant Entity_Id := Etype (N); Pool : constant Entity_Id := Associated_Storage_Pool (Typ); function Is_Checked_Storage_Pool (P : Entity_Id) return Boolean; -- return true if type of P is derived from Checked_Pool; function Is_Checked_Storage_Pool (P : Entity_Id) return Boolean is T : Entity_Id; begin if No (P) then return False; end if; T := Etype (P); while T /= Etype (T) loop if Is_RTE (T, RE_Checked_Pool) then return True; else T := Etype (T); end if; end loop; return False; end Is_Checked_Storage_Pool; -- Start of processing for Insert_Dereference_Action begin if not Comes_From_Source (Parent (N)) then return; elsif not Is_Checked_Storage_Pool (Pool) then return; end if; Insert_Action (N, Make_Procedure_Call_Statement (Loc, Name => New_Reference_To ( Find_Prim_Op (Etype (Pool), Name_Dereference), Loc), Parameter_Associations => New_List ( -- Pool New_Reference_To (Pool, Loc), -- Storage_Address Make_Attribute_Reference (Loc, Prefix => Make_Explicit_Dereference (Loc, Duplicate_Subexpr (N)), Attribute_Name => Name_Address), -- Size_In_Storage_Elements Make_Op_Divide (Loc, Left_Opnd => Make_Attribute_Reference (Loc, Prefix => Make_Explicit_Dereference (Loc, Duplicate_Subexpr (N)), Attribute_Name => Name_Size), Right_Opnd => Make_Integer_Literal (Loc, System_Storage_Unit)), -- Alignment Make_Attribute_Reference (Loc, Prefix => Make_Explicit_Dereference (Loc, Duplicate_Subexpr (N)), Attribute_Name => Name_Alignment)))); end Insert_Dereference_Action; ------------------------------ -- Make_Array_Comparison_Op -- ------------------------------ -- This is a hand-coded expansion of the following generic function: -- generic -- type elem is (<>); -- type index is (<>); -- type a is array (index range <>) of elem; -- -- function Gnnn (X : a; Y: a) return boolean is -- J : index := Y'first; -- -- begin -- if X'length = 0 then -- return false; -- -- elsif Y'length = 0 then -- return true; -- -- else -- for I in X'range loop -- if X (I) = Y (J) then -- if J = Y'last then -- exit; -- else -- J := index'succ (J); -- end if; -- -- else -- return X (I) > Y (J); -- end if; -- end loop; -- -- return X'length > Y'length; -- end if; -- end Gnnn; -- Note that since we are essentially doing this expansion by hand, we -- do not need to generate an actual or formal generic part, just the -- instantiated function itself. function Make_Array_Comparison_Op (Typ : Entity_Id; Nod : Node_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (Nod); X : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uX); Y : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uY); I : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uI); J : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uJ); Index : constant Entity_Id := Base_Type (Etype (First_Index (Typ))); Loop_Statement : Node_Id; Loop_Body : Node_Id; If_Stat : Node_Id; Inner_If : Node_Id; Final_Expr : Node_Id; Func_Body : Node_Id; Func_Name : Entity_Id; Formals : List_Id; Length1 : Node_Id; Length2 : Node_Id; begin -- if J = Y'last then -- exit; -- else -- J := index'succ (J); -- end if; Inner_If := Make_Implicit_If_Statement (Nod, Condition => Make_Op_Eq (Loc, Left_Opnd => New_Reference_To (J, Loc), Right_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Y, Loc), Attribute_Name => Name_Last)), Then_Statements => New_List ( Make_Exit_Statement (Loc)), Else_Statements => New_List ( Make_Assignment_Statement (Loc, Name => New_Reference_To (J, Loc), Expression => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Index, Loc), Attribute_Name => Name_Succ, Expressions => New_List (New_Reference_To (J, Loc)))))); -- if X (I) = Y (J) then -- if ... end if; -- else -- return X (I) > Y (J); -- end if; Loop_Body := Make_Implicit_If_Statement (Nod, Condition => Make_Op_Eq (Loc, Left_Opnd => Make_Indexed_Component (Loc, Prefix => New_Reference_To (X, Loc), Expressions => New_List (New_Reference_To (I, Loc))), Right_Opnd => Make_Indexed_Component (Loc, Prefix => New_Reference_To (Y, Loc), Expressions => New_List (New_Reference_To (J, Loc)))), Then_Statements => New_List (Inner_If), Else_Statements => New_List ( Make_Return_Statement (Loc, Expression => Make_Op_Gt (Loc, Left_Opnd => Make_Indexed_Component (Loc, Prefix => New_Reference_To (X, Loc), Expressions => New_List (New_Reference_To (I, Loc))), Right_Opnd => Make_Indexed_Component (Loc, Prefix => New_Reference_To (Y, Loc), Expressions => New_List ( New_Reference_To (J, Loc))))))); -- for I in X'range loop -- if ... end if; -- end loop; Loop_Statement := Make_Implicit_Loop_Statement (Nod, Identifier => Empty, Iteration_Scheme => Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, Defining_Identifier => I, Discrete_Subtype_Definition => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (X, Loc), Attribute_Name => Name_Range))), Statements => New_List (Loop_Body)); -- if X'length = 0 then -- return false; -- elsif Y'length = 0 then -- return true; -- else -- for ... loop ... end loop; -- return X'length > Y'length; -- end if; Length1 := Make_Attribute_Reference (Loc, Prefix => New_Reference_To (X, Loc), Attribute_Name => Name_Length); Length2 := Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Y, Loc), Attribute_Name => Name_Length); Final_Expr := Make_Op_Gt (Loc, Left_Opnd => Length1, Right_Opnd => Length2); If_Stat := Make_Implicit_If_Statement (Nod, Condition => Make_Op_Eq (Loc, Left_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (X, Loc), Attribute_Name => Name_Length), Right_Opnd => Make_Integer_Literal (Loc, 0)), Then_Statements => New_List ( Make_Return_Statement (Loc, Expression => New_Reference_To (Standard_False, Loc))), Elsif_Parts => New_List ( Make_Elsif_Part (Loc, Condition => Make_Op_Eq (Loc, Left_Opnd => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Y, Loc), Attribute_Name => Name_Length), Right_Opnd => Make_Integer_Literal (Loc, 0)), Then_Statements => New_List ( Make_Return_Statement (Loc, Expression => New_Reference_To (Standard_True, Loc))))), Else_Statements => New_List ( Loop_Statement, Make_Return_Statement (Loc, Expression => Final_Expr))); -- (X : a; Y: a) Formals := New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => X, Parameter_Type => New_Reference_To (Typ, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => Y, Parameter_Type => New_Reference_To (Typ, Loc))); -- function Gnnn (...) return boolean is -- J : index := Y'first; -- begin -- if ... end if; -- end Gnnn; Func_Name := Make_Defining_Identifier (Loc, New_Internal_Name ('G')); Func_Body := Make_Subprogram_Body (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => Func_Name, Parameter_Specifications => Formals, Subtype_Mark => New_Reference_To (Standard_Boolean, Loc)), Declarations => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => J, Object_Definition => New_Reference_To (Index, Loc), Expression => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (Y, Loc), Attribute_Name => Name_First))), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (If_Stat))); return Func_Body; end Make_Array_Comparison_Op; --------------------------- -- Make_Boolean_Array_Op -- --------------------------- -- For logical operations on boolean arrays, expand in line the -- following, replacing 'and' with 'or' or 'xor' where needed: -- function Annn (A : typ; B: typ) return typ is -- C : typ; -- begin -- for J in A'range loop -- C (J) := A (J) op B (J); -- end loop; -- return C; -- end Annn; -- Here typ is the boolean array type function Make_Boolean_Array_Op (Typ : Entity_Id; N : Node_Id) return Node_Id is Loc : constant Source_Ptr := Sloc (N); A : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uA); B : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uB); C : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uC); J : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uJ); A_J : Node_Id; B_J : Node_Id; C_J : Node_Id; Op : Node_Id; Formals : List_Id; Func_Name : Entity_Id; Func_Body : Node_Id; Loop_Statement : Node_Id; begin A_J := Make_Indexed_Component (Loc, Prefix => New_Reference_To (A, Loc), Expressions => New_List (New_Reference_To (J, Loc))); B_J := Make_Indexed_Component (Loc, Prefix => New_Reference_To (B, Loc), Expressions => New_List (New_Reference_To (J, Loc))); C_J := Make_Indexed_Component (Loc, Prefix => New_Reference_To (C, Loc), Expressions => New_List (New_Reference_To (J, Loc))); if Nkind (N) = N_Op_And then Op := Make_Op_And (Loc, Left_Opnd => A_J, Right_Opnd => B_J); elsif Nkind (N) = N_Op_Or then Op := Make_Op_Or (Loc, Left_Opnd => A_J, Right_Opnd => B_J); else Op := Make_Op_Xor (Loc, Left_Opnd => A_J, Right_Opnd => B_J); end if; Loop_Statement := Make_Implicit_Loop_Statement (N, Identifier => Empty, Iteration_Scheme => Make_Iteration_Scheme (Loc, Loop_Parameter_Specification => Make_Loop_Parameter_Specification (Loc, Defining_Identifier => J, Discrete_Subtype_Definition => Make_Attribute_Reference (Loc, Prefix => New_Reference_To (A, Loc), Attribute_Name => Name_Range))), Statements => New_List ( Make_Assignment_Statement (Loc, Name => C_J, Expression => Op))); Formals := New_List ( Make_Parameter_Specification (Loc, Defining_Identifier => A, Parameter_Type => New_Reference_To (Typ, Loc)), Make_Parameter_Specification (Loc, Defining_Identifier => B, Parameter_Type => New_Reference_To (Typ, Loc))); Func_Name := Make_Defining_Identifier (Loc, New_Internal_Name ('A')); Set_Is_Inlined (Func_Name); Func_Body := Make_Subprogram_Body (Loc, Specification => Make_Function_Specification (Loc, Defining_Unit_Name => Func_Name, Parameter_Specifications => Formals, Subtype_Mark => New_Reference_To (Typ, Loc)), Declarations => New_List ( Make_Object_Declaration (Loc, Defining_Identifier => C, Object_Definition => New_Reference_To (Typ, Loc))), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List ( Loop_Statement, Make_Return_Statement (Loc, Expression => New_Reference_To (C, Loc))))); return Func_Body; end Make_Boolean_Array_Op; ------------------------ -- Rewrite_Comparison -- ------------------------ procedure Rewrite_Comparison (N : Node_Id) is Typ : constant Entity_Id := Etype (N); Op1 : constant Node_Id := Left_Opnd (N); Op2 : constant Node_Id := Right_Opnd (N); Res : constant Compare_Result := Compile_Time_Compare (Op1, Op2); -- Res indicates if compare outcome can be determined at compile time True_Result : Boolean; False_Result : Boolean; begin case N_Op_Compare (Nkind (N)) is when N_Op_Eq => True_Result := Res = EQ; False_Result := Res = LT or else Res = GT or else Res = NE; when N_Op_Ge => True_Result := Res in Compare_GE; False_Result := Res = LT; when N_Op_Gt => True_Result := Res = GT; False_Result := Res in Compare_LE; when N_Op_Lt => True_Result := Res = LT; False_Result := Res in Compare_GE; when N_Op_Le => True_Result := Res in Compare_LE; False_Result := Res = GT; when N_Op_Ne => True_Result := Res = NE; False_Result := Res = LT or else Res = GT or else Res = EQ; end case; if True_Result then Rewrite (N, Convert_To (Typ, New_Occurrence_Of (Standard_True, Sloc (N)))); Analyze_And_Resolve (N, Typ); elsif False_Result then Rewrite (N, Convert_To (Typ, New_Occurrence_Of (Standard_False, Sloc (N)))); Analyze_And_Resolve (N, Typ); end if; end Rewrite_Comparison; ----------------------- -- Tagged_Membership -- ----------------------- -- There are two different cases to consider depending on whether -- the right operand is a class-wide type or not. If not we just -- compare the actual tag of the left expr to the target type tag: -- -- Left_Expr.Tag = Right_Type'Tag; -- -- If it is a class-wide type we use the RT function CW_Membership which -- is usually implemented by looking in the ancestor tables contained in -- the dispatch table pointed by Left_Expr.Tag for Typ'Tag function Tagged_Membership (N : Node_Id) return Node_Id is Left : constant Node_Id := Left_Opnd (N); Right : constant Node_Id := Right_Opnd (N); Loc : constant Source_Ptr := Sloc (N); Left_Type : Entity_Id; Right_Type : Entity_Id; Obj_Tag : Node_Id; begin Left_Type := Etype (Left); Right_Type := Etype (Right); if Is_Class_Wide_Type (Left_Type) then Left_Type := Root_Type (Left_Type); end if; Obj_Tag := Make_Selected_Component (Loc, Prefix => Relocate_Node (Left), Selector_Name => New_Reference_To (Tag_Component (Left_Type), Loc)); if Is_Class_Wide_Type (Right_Type) then return Make_DT_Access_Action (Left_Type, Action => CW_Membership, Args => New_List ( Obj_Tag, New_Reference_To ( Access_Disp_Table (Root_Type (Right_Type)), Loc))); else return Make_Op_Eq (Loc, Left_Opnd => Obj_Tag, Right_Opnd => New_Reference_To (Access_Disp_Table (Right_Type), Loc)); end if; end Tagged_Membership; ------------------------------ -- Unary_Op_Validity_Checks -- ------------------------------ procedure Unary_Op_Validity_Checks (N : Node_Id) is begin if Validity_Checks_On and Validity_Check_Operands then Ensure_Valid (Right_Opnd (N)); end if; end Unary_Op_Validity_Checks; end Exp_Ch4;
BitEpicness/AbsTest.asm
davidov541/BitEpicness
0
23061
//abs: funcdecl , , abs:// Words: 0 addi $sp, 5 // Words: 1 move $sp, $rr // Words: 2 addi $0, -1 // Words: 3 swn $ra, $sp, $rr // Words: 4 addi $rr, -1 // Words: 5 swn $s0, $sp, $rr // Words: 6 addi $rr, -1 // Words: 7 swn $s1, $sp, $rr //: formal i, , // Words: 8 addi $0, -3 // Words: 9 swn $a0, $sp, $rr //: load tmp, , i // Words: 10 // Words: 11 ldi $k0, -3 // Words: 12 lwn $t0, $sp, $k0 //: loadi tmp2, , 0 // Words: 13 // Words: 14 ldi $t1, 0 //: > tmp, tmp2, tmp // Words: 15 // Words: 16 la $k0, L5 // Words: 17 bgt $t0, $t1, $k0 // Words: 18 // Words: 19 ldi $t0, 0 // Words: 20 j L6 // Words: 21 // Words: 22 L5:ldi $t0, 1 // Words: 23 L6: //: if tmp, , // Words: 24 // Words: 25 la $k0, L2 // Words: 26 beq $t0, $0, $k0 //: load tmp, , i L1:// Words: 27 // Words: 28 ldi $k0, -3 // Words: 29 lwn $t0, $sp, $k0 //: store n, , tmp // Words: 30 // Words: 31 ldi $k0, -4 // Words: 32 swn $t0, $sp, $k0 j L3 //: load tmp, , i L2:// Words: 33 // Words: 34 ldi $k0, -3 // Words: 35 lwn $t0, $sp, $k0 //: u- tmp, , tmp // Words: 36 neg $t0, $t0 //: store n, , tmp // Words: 37 // Words: 38 ldi $k0, -4 // Words: 39 swn $t0, $sp, $k0 //: load tmp, , n L3:// Words: 40 // Words: 41 ldi $k0, -4 // Words: 42 lwn $t0, $sp, $k0 //: jr , tmp, // Words: 43 move $v, $t0 // Words: 44 addi $0, -1 // Words: 45 lwn $ra, $sp, $rr // Words: 46 addi $rr, -1 // Words: 47 lwn $s0, $sp, $rr // Words: 48 addi $rr, -1 // Words: 49 lwn $s1, $sp, $rr // Words: 50 addi $sp -5 // Words: 51 move $sp, $rr // Words: 52 jr $ra //: funcend , , // Words: 53 addi $0, -1 // Words: 54 lwn $ra, $sp, $rr // Words: 55 addi $rr, -1 // Words: 56 lwn $s0, $sp, $rr // Words: 57 addi $rr, -1 // Words: 58 lwn $s1, $sp, $rr // Words: 59 addi $sp -5 // Words: 60 move $sp, $rr // Words: 61 jr $ra //main: funcdecl , , main:// Words: 62 addi $sp, 6 // Words: 63 move $sp, $rr // Words: 64 addi $0, -1 // Words: 65 swn $ra, $sp, $rr // Words: 66 addi $rr, -1 // Words: 67 swn $s0, $sp, $rr // Words: 68 addi $rr, -1 // Words: 69 swn $s1, $sp, $rr //: loadi tmp, , 7 // Words: 70 // Words: 71 ldi $t0, 7 //: param tmp, , // Words: 72 move $a0, $t0 //: funccall tmp, , abs // Words: 73 jal abs // Words: 74 move $t0, $v //: store a, , tmp // Words: 75 // Words: 76 ldi $k0, -3 // Words: 77 swn $t0, $sp, $k0 //: loadi tmp, , -9001 // Words: 78 // Words: 79 ldi $t0, -9001 //: param tmp, , // Words: 80 move $a0, $t0 //: funccall tmp, , abs // Words: 81 jal abs // Words: 82 move $t0, $v //: store b, , tmp // Words: 83 // Words: 84 ldi $k0, -4 // Words: 85 swn $t0, $sp, $k0 //: loadi tmp, , 42 // Words: 86 // Words: 87 ldi $t0, 42 //: param tmp, , // Words: 88 move $a0, $t0 //: funccall tmp, , abs // Words: 89 jal abs // Words: 90 move $t0, $v //: store c, , tmp // Words: 91 // Words: 92 ldi $k0, -5 // Words: 93 swn $t0, $sp, $k0 //: load tmp, , c // Words: 94 // Words: 95 ldi $k0, -5 // Words: 96 lwn $t0, $sp, $k0 //: print tmp, , // Words: 97 wp $t0, 0 //: loadi tmp, , 0 // Words: 98 // Words: 99 ldi $t0, 0 //: jr , tmp, // Words: 100 move $v, $t0 // Words: 101 addi $0, -1 // Words: 102 lwn $ra, $sp, $rr // Words: 103 addi $rr, -1 // Words: 104 lwn $s0, $sp, $rr // Words: 105 addi $rr, -1 // Words: 106 lwn $s1, $sp, $rr // Words: 107 addi $sp -6 // Words: 108 move $sp, $rr // Words: 109 jr $ra //: funcend , , // Words: 110 addi $0, -1 // Words: 111 lwn $ra, $sp, $rr // Words: 112 addi $rr, -1 // Words: 113 lwn $s0, $sp, $rr // Words: 114 addi $rr, -1 // Words: 115 lwn $s1, $sp, $rr // Words: 116 addi $sp -6 // Words: 117 move $sp, $rr // Words: 118 jr $ra
oeis/215/A215061.asm
neoneye/loda-programs
11
81367
; A215061: Triangle read by rows, e.g.f. exp(x*(z-1/2))*((exp(3*x/2)+2*cos(sqrt(3)*x/2))/3). ; Submitted by <NAME>(w4) ; 1,0,1,0,0,1,1,0,0,1,0,4,0,0,1,0,0,10,0,0,1,1,0,0,20,0,0,1,0,7,0,0,35,0,0,1,0,0,28,0,0,56,0,0,1,1,0,0,84,0,0,84,0,0,1,0,10,0,0,210,0,0,120,0,0,1,0,0,55,0,0,462,0,0,165,0,0,1,1,0,0 lpb $0 add $1,1 sub $0,$1 mov $2,$1 sub $2,$0 lpe bin $1,$0 mov $0,-1 gcd $2,3 add $0,$2 pow $0,$2 mul $1,$0 mov $0,$1 div $0,8
oeis/204/A204030.asm
neoneye/loda-programs
11
15840
; A204030: Symmetric matrix based on f(i,j) = gcd(i+1, j+1), by antidiagonals. ; Submitted by <NAME> ; 2,1,1,2,3,2,1,1,1,1,2,1,4,1,2,1,3,1,1,3,1,2,1,2,5,2,1,2,1,1,1,1,1,1,1,1,2,3,4,1,6,1,4,3,2,1,1,1,1,1,1,1,1,1,1,2,1,2,1,2,7,2,1,2,1,2,1,3,1,5,3,1,1,3,5,1,3,1,2,1,4,1,2,1,8,1,2,1,4,1,2,1,1,1,1,1,1,1,1 lpb $0 add $1,1 sub $0,$1 mov $2,2 sub $2,$0 lpe add $0,2 add $2,$1 gcd $2,$0 mov $0,$2
programs/oeis/258/A258835.asm
neoneye/loda
22
170898
; A258835: Expansion of psi(x)^3 * psi(x^4) in powers of x where psi() is a Ramanujan theta function. ; 1,3,3,4,7,6,9,13,9,10,15,15,13,19,18,16,30,21,19,27,21,31,31,24,25,39,33,28,48,30,35,54,33,34,52,42,45,51,39,45,55,51,50,70,45,46,78,48,54,80,57,63,78,54,55,75,84,58,79,60,61,117,63,74,87,72,81,91,75,77,121,93,81,99,75,76,126,90,79,117,81,99,126,93,98,115,105,95,130,90,91,171,93,94,144,105,124,150,114,108 mul $0,8 add $0,6 seq $0,203 ; a(n) = sigma(n), the sum of the divisors of n. Also called sigma_1(n). div $0,8
src/kernel/arch/x86_64/asm/isr.asm
aryanmaurya1/ArvernOS
77
165094
%macro def_exception_handler 1 global exc%1 exc%1: cli push dword 0 push dword %1 jmp int_common_stub %endmacro ; See: https://github.com/littleosbook/littleosbook/blob/e90faeb24c5c9fed8cde9a35974893706e81cbbf/interrupts.md ; ; +------------+ ; +40 | %SS | ; +32 | %RSP | ; +24 | %CPU FLAGS | ; +16 | %CS | ; +8 | %IP | ; 0 | ERROR CODE | <-- %RSP ; +------------+ ; %macro def_exception_handler_err 1 global exc%1 exc%1: cli push dword %1 jmp int_common_stub %endmacro %macro def_irq_handler 1 global irq%1 irq%1: cli push dword 0 push dword (32 + %1) jmp irq_common_stub %endmacro %macro def_int_handler 1 global int%1 int%1: cli push dword 0 push dword %1 jmp int_common_stub %endmacro %macro save_registers 0 push rax push rbx push rcx push rdx push rsi push rdi push rbp push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 %endmacro %macro restore_registers 0 pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rbp pop rdi pop rsi pop rdx pop rcx pop rbx pop rax %endmacro int_common_stub: save_registers extern isr_int_handler call isr_int_handler restore_registers add rsp, 16 sti iretq irq_common_stub: save_registers extern isr_irq_handler call isr_irq_handler restore_registers add rsp, 16 sti iretq ; define exceptions ; should be keep in sync with src/arch/x86_64/core/isr.h def_exception_handler 0 def_exception_handler 1 def_exception_handler 2 def_exception_handler 3 def_exception_handler 4 def_exception_handler 5 def_exception_handler 6 def_exception_handler 7 def_exception_handler_err 8 def_exception_handler 9 def_exception_handler_err 10 def_exception_handler_err 11 def_exception_handler_err 12 def_exception_handler_err 13 def_exception_handler_err 14 def_exception_handler 15 def_exception_handler 16 def_exception_handler_err 17 def_exception_handler 18 def_exception_handler 19 def_exception_handler 20 def_exception_handler 21 def_exception_handler 22 def_exception_handler 23 def_exception_handler 24 def_exception_handler 25 def_exception_handler 26 def_exception_handler 27 def_exception_handler 28 def_exception_handler 29 def_exception_handler 30 def_exception_handler 31 ; define hardware interrupts ; should be keep in sync with src/arch/x86_64/core/isr.h def_irq_handler 0 def_irq_handler 1 def_irq_handler 2 def_irq_handler 3 def_irq_handler 4 def_irq_handler 5 def_irq_handler 6 def_irq_handler 7 def_irq_handler 8 def_irq_handler 9 def_irq_handler 10 def_irq_handler 11 def_irq_handler 12
src/Lib/Sassy/tests/movx.asm
pnkfelix/larceny
212
83393
BITS 32 section .text foo: movsx ebp, ax movzx ebp, word [edi] movsx ebp, al movzx ebp, byte [edi] movsx bp, ah movzx bp, [edi]
src/extraction-renamings.ads
TNO/Dependency_Graph_Extractor-Ada
1
9155
<reponame>TNO/Dependency_Graph_Extractor-Ada with Extraction.Graph_Operations; private package Extraction.Renamings is procedure Extract_Edges (Node : LAL.Ada_Node'Class; Graph : Graph_Operations.Graph_Context); end Extraction.Renamings;
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/noreturn4.adb
best08618/asylo
7
14519
<reponame>best08618/asylo -- { dg-do compile } with Noreturn4_Pkg; use Noreturn4_Pkg; package body Noreturn4 is procedure P1 (Msg : String) is begin P1 (Msg, 0); end; procedure P1 (Msg : String; Val : Integer) is begin Fatal_Error (Value (It)); end; procedure Fatal_Error (X : Integer) is begin raise PRogram_Error; end; end Noreturn4;
oeis/160/A160131.asm
neoneye/loda-programs
11
87794
; A160131: Numerator of Hermite(n, 8/27). ; Submitted by <NAME> ; 1,16,-1202,-65888,4203340,451512256,-23418152504,-4324519655552,169813349966992,53158210861830400,-1377759404477582624,-797090864837128553984,9343051491617413259968,14095390595056279792663552,48438051548784025753183360,-286940104001508238715797489664,-5650381851396038462674879917824,6603332636524847577359325760196608,245703686753099770573608785806331392,-169366602724908503491040404677698478080,-9516349174032905900286757059250167870464,4786468548673805467394150087453684934885376 add $0,1 mov $3,1 lpb $0 sub $0,1 mul $2,2 mul $3,9 add $2,$3 mov $3,$1 mov $1,$2 mul $2,8 add $1,$2 mul $3,-9 mul $3,$0 mul $3,2 lpe mov $0,$1 div $0,81
controlFlow/for_statement.asm
DanerSound/MIPS-from-scratch
2
27695
<reponame>DanerSound/MIPS-from-scratch<gh_stars>1-10 # simple workflow to understand the for statement # for(index=0; index<= n; i++) # .data .text main: move $t0, $zero # force index to zero li $t1, 5 # load the max size for: blt $t1, $t0, exit # branch less than <= si fermerà a uno in più add $t0, $t0, 1 j for exit: li $v0,10 syscall
src/tfdisk/hdbt32.asm
neri/osz
7
4756
<reponame>neri/osz ;; ;; MEG-OS Boot Sector for FAT32 (beta) ;; ;; Copyright (c) 1998-2013, MEG-OS project ;; 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. ;; ;; 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. ;; ;; TODO: Fragmented [bits 16] [org 0x7C00] _HEAD: jmp short main nop db "FAT32MEG" _BPB_BYTES_PAR_SECTOR dw 0x0200 _BPB_SECTORS_PAR_CLUSTER db 0x00 _BPB_RESERVED_SECTORS dw 0x0000 db 0x00 dw 0x0000 dw 0x0000 db 0xF8 dw 0x0000 dw 0x0000 dw 0x0000 _BPB_HIDDEN_SECTORS dd 0x00000000 _BPB_TOTAL_SECTORS dd 0x00000000 _BPB_SECTORS_PAR_FAT dd 0x00000000 dw 0x0000 dw 0x0000 _BPB_ROOT_DIR_RECORD dd 0x00000002 _BPB_FSINFO_SECTOR dw 0x0001 _BPB_IPL_COPY_SECTOR dw 0x0006 resw 6 current_drive db 0x80 db 0x00 db 0x29 dd 0xFFFFFFFF ;; 123456789AB db "NO NAME " db "FAT32 " main: xor di, di mov ds, di mov es, di mov ss, di mov sp, 0x7C00 mov [current_drive], dl movzx eax, word [_BPB_RESERVED_SECTORS] mov ecx, [_BPB_SECTORS_PAR_FAT] lea ecx, [eax+ecx*2] mov [fat2], ecx ;; Read next part %if 0 movzx eax, word [_BPB_IPL_COPY_SECTOR] add eax, eax mov ebx, _next push ebx call read_sector retf %endif ;; Read a Root DIR mov eax, [_BPB_ROOT_DIR_RECORD] mov bx, 0x8000 mov di, bx call read_record ;; Find the system movzx ecx, word [_BPB_BYTES_PAR_SECTOR] movzx edx, byte [_BPB_SECTORS_PAR_CLUSTER] imul ecx, edx shr ecx, 5 .loop: cmp byte [di], 0 jz short .not_found push cx mov cx, 11 mov si, sysname rep cmpsb pop cx jz short .found or di, byte 0x001F inc di loop .loop .not_found: mov si, nosystem_msg jmp errhalt ;; Load the system .found: and di, byte 0xE0 mov eax, [di+0x1C] movzx ecx, word [_BPB_BYTES_PAR_SECTOR] movzx edx, byte [_BPB_SECTORS_PAR_CLUSTER] imul ecx, edx lea edx, [ecx-1] add eax, edx xor edx, edx div ecx xchg eax, ecx push word [di+0x14] push word [di+0x1A] pop eax push word 0x1000 pop es xor bx, bx push es push bx call read_multi_record ;; Jump to the system mov ax, 0x1eaf ; IPL signature mov ch, [current_drive] mov cl, 0x01 _retf: retf diskioerr: mov si, diskioerr_msg errhalt: lodsb or al, al jz ehle mov ah, 0x0E int 0x10 jmp errhalt ehle: xor ax, ax int 0x16 int 0x19 read_record: mov cx, 1 read_multi_record: sub eax, byte 2 movzx edx, byte [_BPB_SECTORS_PAR_CLUSTER] imul eax, edx add eax, [fat2] imul cx, dx jmp short read_multi_sector read_sector: mov cx, 1 read_multi_sector: push esi add eax, [_BPB_HIDDEN_SECTORS] push ss push ss push eax push es push bx push byte 0x0001 push byte 0x0010 mov si, sp .loop: push cx mov ah, 0x42 mov dl, [current_drive] int 0x13 pop cx jc short diskioerr mov bx, [_BPB_BYTES_PAR_SECTOR] shr bx, 4 add [si+0x06], bx inc dword [si+0x08] loop .loop add sp, byte 0x10 pop esi ret ;; Variables alignb 4 fat2 dd 0x0000 ;; FILENAMEEXT sysname db "KERNEL SYS" nosystem_msg db "MISSING OS", 13, 10, 0 diskioerr_msg db "I/O ERROR", 13, 10, 0 times 001FEh-($-$$) db 0 db 055h, 0AAh
oeis/052/A052849.asm
neoneye/loda-programs
11
11897
<reponame>neoneye/loda-programs<filename>oeis/052/A052849.asm ; A052849: a(0) = 0; a(n+1) = 2*n! (n >= 0). ; 0,2,4,12,48,240,1440,10080,80640,725760,7257600,79833600,958003200,12454041600,174356582400,2615348736000,41845579776000,711374856192000,12804747411456000,243290200817664000,4865804016353280000,102181884343418880000,2248001455555215360000,51704033477769953280000,1240896803466478878720000,31022420086661971968000000,806582922253211271168000000,21777738900836704321536000000,609776689223427721003008000000,17683523987479403909087232000000,530505719624382117272616960000000 mov $2,$0 sub $0,1 mov $3,$0 lpb $3 mul $2,$3 sub $3,1 lpe mov $0,$2 mul $0,2
proglangs-learning/Agda/sv20/assign2/SetTheory/ZAxioms.agda
helq/old_code
0
16847
<reponame>helq/old_code<filename>proglangs-learning/Agda/sv20/assign2/SetTheory/ZAxioms.agda ------------------------------------------------- -- Formalisation of the Z axioms of set theory. ------------------------------------------------- module sv20.assign2.SetTheory.ZAxioms where open import sv20.assign2.SetTheory.Logic infix 1 ∃ infix 5 _⊆_ _⊂_ infix 5 _∈_ _∉_ infix 4 _≡_ -- The universe of discourse (pure sets) and the membership -- relationship. (The letter 𝓢 is type by "\MCS") postulate 𝓢 : Set _∈_ : 𝓢 → 𝓢 → Set -- Existential quantifier data ∃ (A : 𝓢 → Set) : Set where _,_ : (t : 𝓢) → A t → ∃ A -- Sugar syntax for the existential quantifier. syntax ∃ (λ x → e) = ∃[ x ] e -- Existential projections. proj₁ : {A : 𝓢 → Set} → ∃ A → 𝓢 proj₁ (t , _) = t proj₂ : (A : 𝓢 → Set) → (foo : ∃ A) → A (proj₁ foo) proj₂ A (_ , Ax) = Ax -- Equivalence and non equivalence with some useful properties data _≡_ (x : 𝓢) : 𝓢 → Set where refl : x ≡ x _≢_ : 𝓢 → 𝓢 → Set x ≢ y = ¬ x ≡ y sym : (x y : 𝓢) → x ≡ y → y ≡ x sym x .x refl = refl cong : (f :  𝓢 → 𝓢) {x y : 𝓢} → x ≡ y → f x ≡ f y cong f refl = refl subs : (P : 𝓢 → Set) {x y : 𝓢} (p : x ≡ y) (h : P x) → P y subs P {x} {.x} refl h = h trans : {x y z : 𝓢} → x ≡ y → y ≡ z → x ≡ z trans refl refl = refl -- Property concerning bi-implication, needed in a proof. ⇔-p₂ : (z : 𝓢) → {A B C : Set} → A ⇔ (B ∧ C) → (C → B) → A ⇔ C ⇔-p₂ z (h₁ , h₂) h₃ = (λ a → ∧-proj₂ (h₁ a)) , (λ c → h₂ ((h₃ c) , c)) -- Definitions of subset and not-membership. _⊆_ : 𝓢 → 𝓢 → Set x ⊆ y = (t : 𝓢) → t ∈ x → t ∈ y _∉_ : 𝓢 → 𝓢 → Set x ∉ y = ¬ (x ∈ y) -- {-# ATP definition _∉_ #-} _⊂_ : 𝓢 → 𝓢 → Set x ⊂ y = x ⊆ y ∧ x ≢ y _⊂'_ : 𝓢 → 𝓢 → Set x ⊂' y = x ⊆ y ∧ ∃ (λ z → z ∈ y ∧ z ∉ x) ------------------------------------------- -- ZFC's axioms -- From (Suppes 1960, p. 56) -- ext (Extensionality) : If two sets have exactly the same members, -- they are equal. -- empt (Empty Set Axiom) : There is a set having no -- members. Allows us to define the empty set. -- pair (Pairing Axiom) : For any sets y and z, there is a set having -- as members just y and z. Allows to define a set which is just -- the pair of any two sets. -- pow (Power Set Axiom): For any x there is a set whose members are -- exactly the subsets of x. Allows us to define the power set -- operation. -- sub (Subset Axiom, or Specification Axiom): This axiom asserts the -- existence of a set B whose members are exactly those sets x in y -- such that they satisfy certain property. Allows us to define -- many operations like cartesian products and difference of sets. -- uni (Union Axiom) : For any set x, there exists a set A whose -- elements are exactly the members of x. Allows us to define the -- union of two sets. -- pem (Principle of the excluded middle) : To prove some things -- not valid in intuitionistic logic and valid in classical logic. Taken -- from the Standford Encyclopedia entry on Intuitionistic Logic. -- (https://plato.stanford.edu/entries/logic-intuitionistic/). -- The sum axioms allow us to define the union operation -- over a family of sets. postulate empt : ∃ (λ B → ∀ x → x ∉ B) ext : (x y : 𝓢) → ∀ {z} → z ∈ x ⇔ z ∈ y → x ≡ y union : (x y : 𝓢) → ∃ (λ B → {z : 𝓢} → z ∈ B ⇔ z ∈ x ∨ z ∈ y) pair : (x y : 𝓢) → ∃ (λ B → {z : 𝓢} → z ∈ B ⇔ (z ≡ x ∨ z ≡ y)) pow : (x : 𝓢) → ∃ (λ B → ∀ {y} → y ∈ B ⇔ y ⊆ x) sub : (A : 𝓢 → Set) → (y : 𝓢) → ∃ (λ B → {z : 𝓢} → (z ∈ B ⇔ (z ∈ y ∧ A z))) pem : (A : Set) → A ∨ ¬ A sum : (A : 𝓢) → ∃ (λ C → (x : 𝓢) → x ∈ C ⇔ ∃ (λ B → x ∈ B ∧ B ∈ A)) -- {-# ATP axioms empt ext union pair pow #-} -- sub not given to apia since it is an axiom schema and ATPs don't deal -- with that. -- pem isn't given either since ATP's use classical logic so it uses -- this principle by default. ∅ : 𝓢 ∅ = proj₁ empt -- {-# ATP definition ∅ #-} -- Axiom of regularity: Axiom that have two very intuitive consequences: -- ∀ A (A ∉ A) and ¬ ∀ A,B (A∈B ∧ B∈A). From Suppes, p. 56 (1960). postulate reg : (A : 𝓢) → A ≢ ∅ → ∃ (λ x → x ∈ A ∧ ∀ y → y ∈ x → y ∉ A) -- References -- -- Suppes, Patrick (1960). Axiomatic Set Theory. -- The University Series in Undergraduate Mathematics. -- <NAME>, inc. -- -- Enderton, <NAME>. (1977). Elements of Set Theory. -- Academic Press Inc.
src/PJ/flic386p/libsrc/8514/mmmmblto.asm
AnimatorPro/Animator-Pro
119
163213
<reponame>AnimatorPro/Animator-Pro ;mmmmblto.asm - move rectangular 8 bit image to RamRast from 8514. ; include a8514.i include raster.i CGROUP group code code segment dword 'CODE' assume cs:CGROUP,ds:CGROUP ;void pj_8514_t_blitrect(Vscreen *source, Coor sx, Coor sy, ; RamRast *dest, Coor dx, Coor dy, ; Coor width, Coor height); pj_8514_t_blitrect proc near public pj_8514_t_blitrect mbtp struc mbt_ebp dd ? mbt_ret dd ? mbt_source dd ? mbt_sx dd ? mbt_sy dd ? mbt_dest dd ? mbt_dx dd ? mbt_dy dd ? mbt_width dd ? mbt_height dd ? mbtp ends push ebp mov ebp,esp push ebx push ecx push edx push esi push edi ;Grab the parameters we need from bytemap structure mov esi,[ebp].mbt_dest mov ebx,[esi].bym_bpr mov esi,[esi].bym_p ;and calculate starting address for bytemap dest in esi. mov eax,[ebp].mbt_dy mul ebx add eax,[ebp].mbt_dx add esi,eax ;add x/y offsets of this particular screen in card to source position mov edi,[ebp].mbt_source mov eax,[edi].vm_xcard add [ebp].mbt_sx,eax mov eax,[edi].vm_ycard add [ebp].mbt_sy,eax ;make sure GP is free CLRCMD ; v1.00 ;Transfer lines using stroke line horizontal command of the GP. ;Most of transfer is done 2 bytes at a time with an ins on the Pixel Transfer ;port. If width is odd do last pixel separately. ; ;Set up loop invariant registers in 8514 ;width mov eax,[ebp].mbt_width dec eax mov dx,MAJ_AXIS_PCNT out dx,ax ;use stroke line command to transfer data 1 line at a time. mbt_line: mov eax,[ebp].mbt_sx mov dx,CUR_X_POS out dx,ax mov eax,[ebp].mbt_sy mov dx,CUR_Y_POS out dx,ax inc eax mov [ebp].mbt_sy,eax mov ax,DRAWCMD+PC_TRANS+BIT16+BYTE_SWAP+STROKE_ALG+LINE_DRAW mov dx,COMMAND out dx,ax mov dx,PIX_TRANS mov edi,esi mov eax,[ebp].mbt_width mov ecx,eax shr ecx,1 rep insw test eax,1 ;check for odd length jz mbt_nolast in ax,dx ;fetch last word stosb ;store last byte mbt_nolast: add esi,ebx ;go to next line of dest dec [ebp].mbt_height jnz mbt_line mov DX, SUBSYS_CNTL ; v1.00 mov AX, 4 ; Clear the "Data register read" flag. out DX, AX pop edi pop esi pop edx pop ecx pop ebx pop ebp ret pj_8514_t_blitrect endp code ends end
src/main/antlr4/ALM.g4
Topology/ALM-Sys-Desc-Compiler
0
57
/** * This Grammar Follows the BNF for ALM as described in Appendix A of "Modular Action Language ALM" * by <NAME> and <NAME>. * * This document was created by <NAME> * Date: 7/2/2015 * Copyright: Texas Tech University * */ grammar ALM; /* ABOUT THE GRAMMAR RULES THAT FOLLOW: * 1) Lexer Rules and TOKEN names start with capitol letters. * 2) parser rules start with lowercase letters * * Parser rules are clustered based on their "rank", * "rank" is the maximum distance from lexer tokens in the BNF grammer * The top-level rule will be the last rule in the grammar. */ /* * LEXER RULES */ //ORDER OF RULES IN FILE (TOP TO BOTTOM) matters //ORDER OF DEFINITIONS (LEFT TO RIGHT) within NON-TERMINAL and TOKENS matters COMMENT: '%' ~[\r\n]* ('\r'? '\n' | EOF) -> skip; WhiteSpace: (' '|'\t'|'\r'|'\n') -> skip; //SKIP WHITESPACE //EAGERLY CREATE THESE SPECIFIC TOKENS AHEAD OF MORE GENERAL CLASS MOD: 'mod'; EQ: '=';// Describes <eq> NEQ: '!='; //Describes <neq> ARITH_OP: '+' | '-' | '*' | '/' | 'mod' | '^'; //Describes <arithmetic_op> COMP_REL: '>' | '<' | '<=' | '>='; //Describes <comparison_rel> RIGHT_ARROW: '->'; //Used in describing Function sorts. OCCURS: 'occurs'; //prevents the word 'occurs' from being recognized as an identifier INSTANCE: 'instance'; //prevents the word 'instance' from being recognized as an identifier IS_A: 'is_a'; //prevents the word 'is_a' from being recognized as an identifier HAS_CHILD: 'has_child'; //prevents the word 'has_child' from being recognized as an identifier HAS_PARENT: 'has_parent'; //prevents the word 'has_parent' from being recognized as an identifier LINK: 'link'; //prevents the word 'link' from being recognized as an identifier SOURCE: 'source'; //prevents the word 'source' from being recognized as an identifier SINK: 'sink'; //prevents the word 'sink' from being recognized as an identifier SUBSORT: 'subsort'; //prevents the word 'subsort' from being recognized as an identifier DOM: 'DOM'; //prevents the word 'DOM' from being recognized as an identifier SORT: 'sort'; STATE: 'state'; CONSTRAINTS: 'constraints'; FUNCTION: 'function'; DECLARATIONS: 'declarations'; DEFINITIONS: 'definitions'; SYSTEM: 'system'; DESCRIPTION: 'description'; THEORY: 'theory'; MODULE: 'module'; IMPORT: 'import'; FROM: 'from'; DEPENDS: 'depends'; ON: 'on'; ATTRIBUTES: 'attributes'; OBJECT: 'object'; CONSTANT: 'constant'; STATICS: 'statics'; FLUENTS: 'fluents'; BASIC: 'basic'; DEFINED: 'defined'; TOTAL: 'total'; AXIOMS: 'axioms'; DYNAMIC: 'dynamic'; CAUSAL: 'causal'; LAWS: 'laws'; EXECUTABILITY: 'executability'; CONDITIONS: 'conditions'; CAUSES: 'causes'; IMPOSSIBLE: 'impossible'; IF: 'if'; FALSE: 'false'; TRUE: 'true'; STRUCTURE: 'structure'; IN: 'in'; WHERE: 'where'; VALUE: 'value'; OF: 'of'; INSTANCES: 'instances'; TEMPORAL : 'temporal'; PROJECTION : 'projection'; MAX: 'max'; STEPS: 'steps'; HISTORY : 'history'; OBSERVED: 'observed'; HAPPENED: 'happened'; PLANNING: 'planning'; PROBLEM: 'problem'; DIAGNOSTIC: 'diagnostic'; GOAL : 'goal'; SITUATION : 'situation'; WHEN : 'when'; NORMAL: 'normal'; ACTION: 'action'; ADDITIONAL: 'additional'; RESTRICTIONS : 'restrictions'; PERMISSIONS : 'permissions'; POSSIBLE: 'possible'; AVOID: 'avoid'; BOOLEANS: 'booleans'; INTEGERS: 'integers'; UNIVERSE: 'universe'; ACTIONS: 'actions'; CURRENT: 'current'; TIME: 'time'; // THESE TOKENS ARE MORE GENERAL AND LESS EAGERLY DETERMINED ID: [a-z]([a-zA-Z0-9_\-])*; //Describes <identifier> in the ALM BNF, includes <lowercase_letter>, <uppercase_letter> VAR: [A-Z]([a-zA-Z0-9_\-])*; //Describes <variable> in the ALM BNF. POSINT: [1-9][0-9]*; //Describes <positive_integer>, includes <non_zero_digit>, <digit> NEGINT: '-'[1-9][0-9]*;//not explicitly modeled in ALM BNF, used in 'integer' rule ZERO: [0]+; //TOKEN For ZERO, not a non-terminal in ALM BNF, used in 'integer' rule /* * ALM BNF RULES subsumed by LEXER rules * ---------------------------- * <boolean> -> BOOL * <non_zero_digit> -> POSINT and NEGINT * <digit> -> POSINT and NEGINT and ID and VAR * <lowercase_letter> -> ID and VAR * <uppercase_letter> -> ID and VAR * <letter> -> ID and VAR * <identifier> -> ID * <variable> -> VAR * <positive_integer> -> POSINT * <integer> -> ZERO and POSINT and NEGINT * <arithmetic_op> -> ARITH_OP * <comparison_rel> -> COMP_REL */ /* * BASIC PARSER RULES BUILT OUT OF SPECIAL LEXER TOKENS */ bool : TRUE | FALSE; nat_num : ZERO | POSINT; //<natural_number> integer : ZERO | POSINT | NEGINT; //<integer> relation: EQ | NEQ | COMP_REL; //<arithmetic_rel> // RECOVER KEYWORDS && INTEGERS INTO IDENTIFIER id : OCCURS | INSTANCE | IS_A | HAS_CHILD | HAS_PARENT | LINK | SOURCE | SINK | SUBSORT | DOM | ID | MOD | SORT | STATE | CONSTRAINTS | FUNCTION | DECLARATIONS | DEFINITIONS | SYSTEM | DESCRIPTION | THEORY | MODULE | IMPORT | FROM | DEPENDS | ON | ATTRIBUTES | OBJECT | CONSTANT | STATICS | FLUENTS | BASIC | DEFINED | TOTAL | AXIOMS | DYNAMIC | CAUSAL | LAWS | EXECUTABILITY | CONDITIONS | CAUSES | IMPOSSIBLE | IF | FALSE | TRUE | STRUCTURE | IN | WHERE | VALUE | OF | INSTANCES | TEMPORAL | PROJECTION | MAX | STEPS | HISTORY | OBSERVED | HAPPENED | PLANNING | PROBLEM | DIAGNOSTIC | GOAL | SITUATION | WHEN | NORMAL | ACTION | ADDITIONAL | RESTRICTIONS | PERMISSIONS | POSSIBLE | AVOID | BOOLEANS | INTEGERS | UNIVERSE | ACTIONS | CURRENT | TIME | integer; alm_name : id | VAR; /* TERMS * denote objects which populate sorts * integers are terms * true and false are terms. * variables are terms. * and f(t1, ..., tn) is a term where all ti are terms and f is an identifier. * * */ object_constant: (id ( '(' term (',' term)* ')')? | integer); //Pattern for any object instance of any sort. function_term: object_constant; // the distinction here is that function_terms denote functions even though they have the same syntactic structure as object_constants. term: bool | VAR | id | integer | function_term | expression; //terms can appear on either side of EQ operators and denote values of sorts. var_or_obj: (object_constant | VAR); /* EXPRESSIONS * An expression is a mathematical entity which denotes an integer. * addition/subtraction * multiplication/division/modulus/exponent * factors are individual units which participate in the above operations. */ expression: expression '+' arithmetic_term | expression '-' arithmetic_term | arithmetic_term; arithmetic_term: arithmetic_term '*' factor | arithmetic_term '/' factor | arithmetic_term MOD factor | factor '^' factor | factor; factor: VAR | '-' VAR | integer | function_term | '-' function_term | '(' expression ')' | '-' '(' expression ')'; // ('-' integer) is not a factor because integer include NEGINT /* LITERALS */ //These these literals are parsed distinctly so that they may be handled per occurrence. occurs_atom: OCCURS '(' var_or_obj ')'; instance_atom: INSTANCE '(' var_or_obj ',' sort_name ')'; is_a_atom: IS_A '(' var_or_obj ',' sort_name ')'; link_atom: LINK '(' sort_name ',' sort_name ')'; subsort_atom: SUBSORT '(' sort_name ',' sort_name ')'; has_child_atom: HAS_CHILD '(' sort_name ')'; has_parent_atom: HAS_PARENT '(' sort_name ')'; sink_atom: SINK '(' sort_name ')'; source_atom: SOURCE '(' sort_name ')'; //Pattern for any atom (positive occurrence of a predicate), including special atoms. atom: instance_atom | is_a_atom | link_atom | subsort_atom | has_child_atom | has_parent_atom | sink_atom | source_atom | function_term ; literal: atom | '-' atom | term relation term ;//<literal> not including special literals occurs_literal: occurs_atom | '-' occurs_atom; /* ALM FILE */ alm_file : (system_description | theory | module) EOF; /* ALM SYSTEM DESCRIPTION */ library_name: alm_name; sys_desc_name: alm_name; system_description : SYSTEM DESCRIPTION sys_desc_name theory (structure solver_mode?)? EOF; //<system_description> /* ALM THEORY */ theory_name: alm_name; theory: (THEORY theory_name sequence_of_modules) | (IMPORT theory_name FROM library_name);//<theory> /* ALM MODULE */ module_name: alm_name; sequence_of_modules: (module)+;//<set_of_modules><remainder_modules> module: (MODULE module_name module_body) | (IMPORT theory_name ('.' module_name)? FROM library_name); //<module> module_body: module_dependencies? sort_declarations? constant_declarations? function_declarations? axioms?;//<axioms>,<remainder_axioms> /* ALM MODULE DEPENDENCIES */ module_dependencies: DEPENDS ON one_dependency (',' one_dependency)*; one_dependency: (theory_name '.')? module_name; /* ALM SORT DECLARATIONS */ integer_range: integer '..' integer ; predefined_sorts: BOOLEANS | INTEGERS | integer_range; sort_name: predefined_sorts | UNIVERSE | ACTIONS | id ; new_sort_name : id | integer_range; sort_declarations: SORT DECLARATIONS (one_sort_decl)+ ;//<sort_declaration><remainder_sort_declaration> one_sort_decl: new_sort_name (',' new_sort_name)* '::' sort_name (',' sort_name)* attributes?; //<one_sort_decl>,<sort_name>,<remainder_sort_names>,<remainder_sorts> attributes: ATTRIBUTES (one_attribute_decl)+;//<attributes><remainder_attribute_declarations> one_attribute_decl: id ':' (sort_name (',' sort_name )* RIGHT_ARROW)? sort_name;//<one_attribue_decl>,<arguments>,<remainder_args> /* ALM CONSTANT DECLARATIONS */ constant_declarations: CONSTANT DECLARATIONS (one_constant_decl)+;//<constant_declaraions><remainder_constant_declarations> one_constant_decl: object_constant (',' object_constant)* ':' sort_name (',' sort_name)* attribute_defs?;//<one_constant_decl>,<const_params>,<remainder_const_params> /* ALM FUNCTION DECLARATIONS */ function_name:id; function_declarations: FUNCTION DECLARATIONS static_declarations? fluent_declarations?;// static_declarations: STATICS basic_function_declarations? defined_function_declarations?;//<static_declarations> fluent_declarations: FLUENTS basic_function_declarations? defined_function_declarations?;//<static_declarations> basic_function_declarations: BASIC (one_function_decl)+;//<basic_function_declarations>,<remainder_function_declarations> defined_function_declarations: DEFINED (one_function_decl)+;//<defined_function_declarations>,<remainder_function_declarations> one_function_decl: (TOTAL)? function_name ':' sort_name (('*' sort_name )* RIGHT_ARROW sort_name)?;//<one_function_decl><total_partial><one_f_decl> <remainder_args> pos_fun_def: function_term EQ term | function_term | '-' function_term; neg_fun_def: function_term NEQ term; fun_def : (pos_fun_def | neg_fun_def); /* ALM AXIOMS */ axioms: AXIOMS (dynamic_causal_laws | executability_conditions | state_constraints | function_definitions)+ ;//<axioms>,<remainder_axioms> dynamic_causal_laws: DYNAMIC CAUSAL LAWS (one_dynamic_causal_law)*; executability_conditions: EXECUTABILITY CONDITIONS (one_executability_condition)*; state_constraints: STATE CONSTRAINTS (one_state_constraint)*; function_definitions: FUNCTION DEFINITIONS (one_definition)*; /* DYNAMIC CAUSAL LAW */ one_dynamic_causal_law: occurs_atom CAUSES pos_fun_def IF instance_atom (',' literal)* '.'; //<dynamic_causal_law><body> /* EXECUTABILITY CONDITION */ one_executability_condition: IMPOSSIBLE occurs_atom IF instance_atom ( ',' ( occurs_literal| literal))* '.'; //<executability_condition>, <extended body> /* STATE CONSTRAINT */ one_state_constraint: fun_def '.' | (FALSE | fun_def) IF literal (',' literal)* '.'; // /* DEFINITION */ one_definition: function_term '.' | function_term IF literal (',' literal)* '.'; /* ALM STRUCTURE */ structure_name: alm_name; structure: STRUCTURE structure_name (constant_defs | instance_defs | statics_defs)*;//<structure> /* CONSTANT DEFINITIONS */ constant_defs: CONSTANT DEFINITIONS (one_constant_def)+;//<constant_defs><remainder_constant_defs> one_constant_def: object_constant '=' term;//<one_constant_def> /* INSTANCE DEFINITIONS */ instance_defs: INSTANCES (one_instance_def)+;//<instance_defs><remainder_instance_defs> one_instance_def: var_or_obj (',' var_or_obj)* IN sort_name (',' sort_name)* (WHERE literal (',' literal)* )? attribute_defs;//<one_instance_def> attribute_defs: (one_attribute_def)*; one_attribute_def: function_term EQ term; /* STATICS DEFINITIONS */ statics_defs: VALUE OF STATICS (one_static_def)+ ; one_static_def: fun_def (IF literal (',' literal)*)? '.'; //<one_static_literal><body> /* SOLVER MODES */ solver_mode : (temporal_projection | planning_problem | diagnostic_problem) added_constraints? action_conditions?; /* SOLVER MODE COMMON PARTS */ max_steps : MAX STEPS POSINT; current_time: CURRENT TIME nat_num; history : HISTORY (observed | happened)+; observed : OBSERVED '(' function_term ',' term ',' nat_num ')' '.' ; happened : HAPPENED '(' object_constant ',' nat_num ')' '.'; /* SOLVER MODE ADDITIONAL CONSTRAINTS */ added_constraints: ADDITIONAL CONSTRAINTS (one_added_constraint)+; one_added_constraint: (IMPOSSIBLE | AVOID) literal (',' literal)* '.'; action_conditions: ACTION (RESTRICTIONS | PERMISSIONS) (one_action_condition)+; one_action_condition: (POSSIBLE | IMPOSSIBLE | AVOID) function_term WHEN literal (',' literal)* '.'; /* TEMPORAL PROJECTION SPECIFIC */ temporal_projection : TEMPORAL PROJECTION max_steps history; /* PLANNING PROBLEM SPECIFIC */ planning_problem : PLANNING PROBLEM max_steps current_time? history goal_state; goal_state: GOAL EQ '{' literal (',' literal)* '}'; /* DIAGNOSTIC PROBLEM SPECIFIC */ diagnostic_problem : DIAGNOSTIC PROBLEM max_steps current_time? history normal_conditions? current_state; normal_conditions: NORMAL CONDITIONS (one_normal_condition)+; one_normal_condition : id ':' literal ('when' literal (',' literal)*)?'.'; current_state: SITUATION EQ '{' literal (',' literal)* '}' '.';
talk1.asm
kanpapa/cosmac
2
246312
<filename>talk1.asm<gh_stars>1-10 * * AquesTalkPico Sample program 1 for COSMAC * SB-Assembler * .CR 1802 .OR $0000 * START LDI #IOR ;#IOR -> D PLO 5 ;D -> R(5).0 SEX 5 ;5 -> X * LDI #0 ;0 -> D STR 5 ;D -> M(R(5)) OUT 4 ;M(R(5)) -> BUS; R(5)+1 -> R(5) DEC 5 ;R(5)-1 -> R(N) * LOOP1 LDI #1 ;1 -> D ADD ;M(R(X))+D -> DF,D STR 5 ;D -> M(R(5)) BN4 LOOP1 ;IF EF4=0 MAIN OUT 4 ;M(R(5)) -> BUS; R(5)+1 -> R(5) DEC 5 ;R(5)-- BR LOOP1 ;Branch to LOOP1 * IOR .DB 0 ;IO Register .EN
smsq/java/ip/io.asm
olifink/smsqe
0
177651
<filename>smsq/java/ip/io.asm ; IP IO routines V1.00  2004 <NAME> ; 1.02 check for UDP (wl) ; 1.01 adapted for java wl section ip xdef ip_io xref udp_name xref udd_name include 'dev8_keys_err' include 'dev8_keys_socket' include 'dev8_keys_java' include 'dev8_smsq_java_ip_data' ip_io move.l a0,-(sp) ip_doio move.l d0,-(sp) ; will be popped up in java moveq #-jt9.io,d0 move.l udp_name,d4 cmp.l chn_typ(a0),d4 beq.s cont move.l udd_name,d4 cmp.l chn_typ(a0),d4 beq.s cont moveq #jt9.io,d0 cont move.l chn_data(a0),a0 ; Internal data dc.w jva.trp9 ip_exit move.l (sp)+,a0 rts end
WeakArrows.agda
jmchapman/Relative-Monads
21
8099
<filename>WeakArrows.agda module WeakArrows where open import Library open import Categories record Arrow {l m}(J : Cat {l}{m}) : Set (lsuc (l ⊔ m)) where constructor arrow open Cat J field R : Obj → Obj → Set m pure : ∀{X Y} -> Hom X Y -> R X Y _<<<_ : ∀{X Y Z} → R Y Z -> R X Y -> R X Z alaw1 : ∀{X Y Z}(g : Hom Y Z)(f : Hom X Y) -> pure (comp g f) ≅ pure g <<< pure f alaw2 : ∀{X Y}(s : R X Y) -> s <<< pure iden ≅ s alaw3 : ∀{X Y}(r : R X Y) -> pure iden <<< r ≅ r alaw4 : ∀{W X Y Z}(t : R Y Z)(s : R X Y)(r : R W X) -> t <<< (s <<< r) ≅ (t <<< s) <<< r open import Functors open import Naturals open import Categories.Sets open import YonedaLemma open import RMonads module Arrow2RMonad {l m}(C : Cat {l}{m})(A : Arrow C) where open Cat C open Arrow A T : Cat.Obj C -> Fun (C Op) (Sets {m}) T X = functor (λ Y -> R Y X) (λ f s -> s <<< pure f) (ext alaw2) (ext (λ s -> trans (cong (s <<<_) (alaw1 _ _)) (alaw4 _ _ _))) η : {X : Obj} -> NatT HomF[-, X ] (T X) η = natural pure (ext λ _ -> sym (alaw1 _ _)) bind : {X Y : Obj} -> NatT HomF[-, X ] (T Y) -> NatT (T X) (T Y) bind α = natural (λ s -> cmp iden <<< s) (ext λ _ -> sym (alaw4 _ _ _)) where open NatT α -- cmp iden is one direction of the yoneda lemma law1 : {X : Obj} → bind (η {X}) ≅ idNat {F = T X} law1 = NatTEq (iext (\ _ -> ext alaw3)) law2 : {X Y : Obj}{f : NatT HomF[-, X ] (T Y)} → compNat (bind f) η ≅ f law2 {f = f} = NatTEq (iext \ _ -> ext \ s -> trans (fcong iden (nat {f = s})) (cong cmp idl)) where open NatT f law3 : {X Y Z : Obj} {f : NatT HomF[-, X ] (T Y)} → {g : NatT HomF[-, Y ] (T Z)} → bind (compNat (bind g) f) ≅ compNat (bind g) (bind f) law3 = NatTEq (iext \ W -> ext (\ s -> sym (alaw4 _ _ s))) ArrowRMonad : RMonad (y C) ArrowRMonad = rmonad T η bind law1 law2 (λ {_ _ _ f g} -> law3 {f = f}{g = g}) module RMonad2Arrow {l m}(C : Cat {l}{m})(M : RMonad (y C)) where open Cat C open RMonad M open Fun open NatT R : Obj → Obj → Set m R X Y = OMap (T Y) X pure : {X Y : Obj} → Hom X Y → R X Y pure f = cmp η f _<<<_ : ∀{X Y Z} → R Y Z → R X Y → R X Z s <<< t = cmp (bind (ylem C (T _) _ s)) t alaw1 : ∀{X Y Z}(g : Hom Y Z)(f : Hom X Y) → pure (comp g f) ≅ (pure g <<< pure f) alaw1 g f = trans (sym (fcong g (nat η))) (sym (fcong f (ifcong _ (cong cmp law2)))) alaw2 : ∀{X Y} -> (s : R X Y) → (s <<< pure iden) ≅ s alaw2 s = trans (fcong iden (ifcong _ (cong cmp law2))) (fcong s (fid (T _))) alaw3 : ∀{X Y}(r : R X Y) → (pure iden <<< r) ≅ r alaw3 r = trans (cong (\ α -> cmp (bind α) r) (NatTEq (iext \ Z -> ext \ f -> trans (fcong iden (nat η)) (cong (cmp η) idl)))) (fcong r (ifcong _ (cong cmp law1))) alaw4 : ∀{W X Y Z}(t : R Y Z)(s : R X Y)(r : R W X) → (t <<< (s <<< r)) ≅ ((t <<< s) <<< r) alaw4 t s r = trans (sym (fcong r (ifcong _ (cong cmp law3)))) (cong (\ α -> cmp (bind α) r) (NatTEq (iext \ _ -> ext \ _ -> sym (fcong s (nat (bind (ylem C (T _) _ t))))))) RMonadArrow : Arrow C RMonadArrow = arrow R pure _<<<_ alaw1 alaw2 alaw3 alaw4
oeis/049/A049858.asm
neoneye/loda-programs
11
172573
<gh_stars>10-100 ; A049858: a(n) = Sum{a(k): k=0,1,2,...,n-4,n-2,n-1}; a(n-3) is not a summand; 3 initial terms required. ; Submitted by <NAME> ; 0,1,2,3,5,9,17,32,60,112,209,390,728,1359,2537,4736,8841,16504,30809,57513,107363,200421,374138,698426,1303794,2433871,4543454,8481540,15833003,29556423,55174760,102998057,192272694,358927051 add $0,3 mov $2,1 mov $4,1 lpb $0 sub $0,1 sub $3,$4 add $1,$3 mov $3,$4 mov $4,$2 mov $2,$3 add $2,$1 add $5,$4 mov $3,$5 lpe mov $0,$1
samples/Agda/NatCat.agda
alexgracianoarj/detect-languages
2
4954
module NatCat where open import Relation.Binary.PropositionalEquality -- If you can show that a relation only ever has one inhabitant -- you get the category laws for free module EasyCategory (obj : Set) (_⟶_ : obj → obj → Set) (_∘_ : ∀ {x y z} → x ⟶ y → y ⟶ z → x ⟶ z) (id : ∀ x → x ⟶ x) (single-inhabitant : (x y : obj) (r s : x ⟶ y) → r ≡ s) where idʳ : ∀ x y (r : x ⟶ y) → r ∘ id y ≡ r idʳ x y r = single-inhabitant x y (r ∘ id y) r idˡ : ∀ x y (r : x ⟶ y) → id x ∘ r ≡ r idˡ x y r = single-inhabitant x y (id x ∘ r) r ∘-assoc : ∀ w x y z (r : w ⟶ x) (s : x ⟶ y) (t : y ⟶ z) → (r ∘ s) ∘ t ≡ r ∘ (s ∘ t) ∘-assoc w x y z r s t = single-inhabitant w z ((r ∘ s) ∘ t) (r ∘ (s ∘ t)) open import Data.Nat same : (x y : ℕ) (r s : x ≤ y) → r ≡ s same .0 y z≤n z≤n = refl same .(suc m) .(suc n) (s≤s {m} {n} r) (s≤s s) = cong s≤s (same m n r s) ≤-trans : ∀ x y z → x ≤ y → y ≤ z → x ≤ z ≤-trans .0 y z z≤n s = z≤n ≤-trans .(suc m) .(suc n) .(suc n₁) (s≤s {m} {n} r) (s≤s {.n} {n₁} s) = s≤s (≤-trans m n n₁ r s) ≤-refl : ∀ x → x ≤ x ≤-refl zero = z≤n ≤-refl (suc x) = s≤s (≤-refl x) module Nat-EasyCategory = EasyCategory ℕ _≤_ (λ {x}{y}{z} → ≤-trans x y z) ≤-refl same
Chapter 1/1.6 - Paging/real_mode/print_hex.asm
gmarino2048/64bit-os-tutorial
87
87069
; ; paging ; ; print_hex.asm ; [bits 16] ; Define Function print_hex_bios ; Input in bx print_hex_bios: ; Save state push ax push bx push cx ; Enable print mode mov ah, 0x0E ; Print prefix mov al, '0' int 0x10 mov al, 'x' int 0x10 ; Initialize cx as counter ; 4 nibbles in 16-bits mov cx, 4 ; Begin loop print_hex_bios_loop: ; If cx==0 goto end cmp cx, 0 je print_hex_bios_end ; Save bx again push bx ; Shift so upper four bits are lower 4 bits shr bx, 12 ; Check to see if ge 10 cmp bx, 10 jge print_hex_bios_alpha ; Byte in bx now < 10 ; Set the zero char in al, add bl mov al, '0' add al, bl ; Jump to end of loop jmp print_hex_bios_loop_end print_hex_bios_alpha: ; Bit is now greater than or equal to 10 ; Subtract 10 from bl to get add amount sub bl, 10 ; Move 'A' to al and add bl mov al, 'A' add al, bl print_hex_bios_loop_end: ; Print character int 0x10 ; Restore bx ; Shift to next 4 bits pop bx shl bx, 4 ; Decrement cx counter dec cx ; Jump to beginning of loop jmp print_hex_bios_loop print_hex_bios_end: ; Restore state pop cx pop bx pop ax ; Jump to calling point ret
bb-runtimes/runtimes/ravenscar-full-stm32g474/gnat/s-valflt.ads
JCGobbi/Nucleo-STM32G474RE
0
5183
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . V A L _ F L T -- -- -- -- S p e c -- -- -- -- Copyright (C) 2020-2021, 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. -- -- -- -- -- -- -- -- -- -- -- -- 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 was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains routines for scanning real values for floating point -- type Float, for use in Text_IO.Float_IO and the Value attribute. with System.Powten_Flt; with System.Unsigned_Types; with System.Val_Real; package System.Val_Flt is pragma Preelaborate; package Impl is new Val_Real (Float, System.Powten_Flt.Maxpow, System.Powten_Flt.Powten'Address, Unsigned_Types.Unsigned); function Scan_Float (Str : String; Ptr : not null access Integer; Max : Integer) return Float renames Impl.Scan_Real; function Value_Float (Str : String) return Float renames Impl.Value_Real; end System.Val_Flt;
oeis/021/A021665.asm
neoneye/loda-programs
11
105443
<reponame>neoneye/loda-programs ; A021665: Decimal expansion of 1/661. ; Submitted by Jon Maiga ; 0,0,1,5,1,2,8,5,9,3,0,4,0,8,4,7,2,0,1,2,1,0,2,8,7,4,4,3,2,6,7,7,7,6,0,9,6,8,2,2,9,9,5,4,6,1,4,2,2,0,8,7,7,4,5,8,3,9,6,3,6,9,1,3,7,6,7,0,1,9,6,6,7,1,7,0,9,5,3,1,0,1,3,6,1,5,7,3,3,7,3,6,7,6,2,4,8,1,0 mov $2,10 pow $2,$0 mul $2,10 div $2,661 mov $0,$2 mod $0,10
resources/asm/test04-basic-input.asm
aa-dav/SimpX
0
17691
<gh_stars>0 ; ******************************************************************* ; * test04.asm - ввод символов с клавиатуры с мгновенной их печатью * ; ******************************************************************* #include "simple_lib.inc" ; Строка с приветствием str dw "Press keys..." 13 0 start ; Вводим символы с клавиатуры и печатаем их на экране... r0 <- str call zstrPrint ; печатаем строку с приветствием loop call inputChar ; вводим (блокирующе) символ с клавиатуры call printSpChar ; тут же печатаем его (со спец-символами) pc <- loop ; и зацикливаемся...
test/Succeed/Issue1770.agda
cruhland/agda
1,989
9152
{-# OPTIONS -v scope.import:10 #-} import Common.Level import Common.Level
generated/natools-static_maps-s_expressions-conditionals-strings.adb
faelys/natools
0
17630
<reponame>faelys/natools -- Generated at 2015-03-31 18:55:08 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-conditionals-strings-maps.sx with Natools.Static_Maps.S_Expressions.Conditionals.Strings.P; with Natools.Static_Maps.S_Expressions.Conditionals.Strings.S; package body Natools.Static_Maps.S_Expressions.Conditionals.Strings is function To_Parametric (Key : String) return Parametric_Condition is N : constant Natural := Natools.Static_Maps.S_Expressions.Conditionals.Strings.P.Hash (Key); begin if Map_1_Keys (N).all = Key then return Map_1_Elements (N); else return Unknown_Parametric_Condition; end if; end To_Parametric; function To_Simple (Key : String) return Simple_Condition is N : constant Natural := Natools.Static_Maps.S_Expressions.Conditionals.Strings.S.Hash (Key); begin if Map_2_Keys (N).all = Key then return Map_2_Elements (N); else return Unknown_Simple_Condition; end if; end To_Simple; end Natools.Static_Maps.S_Expressions.Conditionals.Strings;
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0xca_notsx.log_21829_1475.asm
ljhsiun2/medusa
9
80302
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r15 push %r8 push %r9 push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x1e4dd, %r11 nop nop nop nop nop and %r8, %r8 mov $0x6162636465666768, %rbx movq %rbx, %xmm2 and $0xffffffffffffffc0, %r11 vmovntdq %ymm2, (%r11) nop nop and $36996, %r9 lea addresses_UC_ht+0x18c97, %r15 nop xor $43442, %r8 movl $0x61626364, (%r15) nop nop nop xor $56193, %r8 lea addresses_WT_ht+0x1dad9, %rsi lea addresses_D_ht+0x1e4c9, %rdi nop nop add %r9, %r9 mov $123, %rcx rep movsl nop nop nop nop nop cmp %rsi, %rsi lea addresses_UC_ht+0x5059, %r15 nop nop and $34773, %r8 movb $0x61, (%r15) nop nop add %r11, %r11 lea addresses_A_ht+0x17d99, %r8 nop nop nop nop xor %rdi, %rdi movb $0x61, (%r8) nop nop nop nop cmp %rdi, %rdi lea addresses_D_ht+0x1df5d, %r15 and $49558, %rcx mov $0x6162636465666768, %rdi movq %rdi, (%r15) nop nop nop nop xor $59964, %rdi lea addresses_WT_ht+0xb469, %rsi nop nop add $16934, %r13 mov $0x6162636465666768, %r8 movq %r8, %xmm3 movups %xmm3, (%rsi) nop cmp %rbx, %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %r9 pop %r8 pop %r15 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r13 push %r8 push %r9 push %rax push %rbx push %rsi // Store lea addresses_normal+0x14bc9, %r13 clflush (%r13) nop nop nop cmp $6906, %r8 mov $0x5152535455565758, %rax movq %rax, %xmm5 movups %xmm5, (%r13) nop nop nop nop xor %rsi, %rsi // Load mov $0x41, %rax inc %r13 movb (%rax), %r8b nop nop nop xor %r9, %r9 // Faulty Load lea addresses_RW+0x45c9, %rax nop nop nop nop nop inc %r9 mov (%rax), %r8d lea oracles, %rbx and $0xff, %r8 shlq $12, %r8 mov (%rbx,%r8,1), %r8 pop %rsi pop %rbx pop %rax pop %r9 pop %r8 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_normal', 'size': 16, 'AVXalign': False}} {'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_P', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': True, 'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': True, 'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': True, 'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}} {'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 */
programs/oeis/210/A210357.asm
karttu/loda
0
98407
; A210357: Location of the maximum modulus in the inverse of Hilbert's matrix. ; 1,2,2,3,4,5,5,6,7,7,8,9,10,10,11,12,12,13,14,15,15,16,17,17,18,19,19,20,21,22,22,23,24,24,25,26,27,27,28,29,29,30,31,31,32,33,34,34,35,36,36,37,38,39,39,40,41,41,42,43,44,44,45,46,46,47,48,48,49,50,51,51,52,53,53,54,55,56,56,57,58,58,59,60,60,61,62,63,63,64,65,65,66,67,68,68,69,70,70,71,72,72,73,74,75,75,76,77,77,78,79,80,80,81,82,82,83,84,85,85,86,87,87,88,89,89,90,91,92,92,93,94,94,95,96,97,97,98,99,99,100,101,101,102,103,104,104,105,106,106,107,108,109,109,110,111,111,112,113,114,114,115,116,116,117,118,118,119,120,121,121,122,123,123,124,125,126,126,127,128,128,129,130,130,131,132,133,133,134,135,135,136,137,138,138,139,140,140,141,142,143,143,144,145,145,146,147,147,148,149,150,150,151,152,152,153,154,155,155,156,157,157,158,159,159,160,161,162,162,163,164,164,165,166,167,167,168,169,169,170,171,171,172,173,174,174,175,176,176,177 add $0,1 pow $0,2 mul $0,2 mov $2,7 lpb $0,1 sub $0,1 sub $0,$1 add $1,8 lpe mul $1,$2 mul $1,4 sub $1,223 div $1,224 add $1,1
oeis/315/A315748.asm
neoneye/loda-programs
11
14528
; A315748: Coordination sequence Gal.5.294.4 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; Submitted by <NAME>(s2) ; 1,6,12,18,23,29,34,40,46,52,58,64,70,75,81,86,92,98,104,110,116,122,127,133,138,144,150,156,162,168,174,179,185,190,196,202,208,214,220,226,231,237,242,248,254,260,266,272,278,283 mul $0,26 mov $2,$0 add $0,3 div $0,9 add $0,1 sub $2,4 div $2,9 add $2,$0 mov $0,$2
src/Bf/Ip.agda
mietek/formal-logic
26
5468
-- Intuitionistic propositional logic, de Bruijn approach, final encoding module Bf.Ip where open import Lib using (List; _,_; LMem; lzero; lsuc) -- Types infixl 2 _&&_ infixl 1 _||_ infixr 0 _=>_ data Ty : Set where UNIT : Ty _=>_ : Ty -> Ty -> Ty _&&_ : Ty -> Ty -> Ty _||_ : Ty -> Ty -> Ty FALSE : Ty infixr 0 _<=>_ _<=>_ : Ty -> Ty -> Ty a <=> b = (a => b) && (b => a) NOT : Ty -> Ty NOT a = a => FALSE TRUE : Ty TRUE = FALSE => FALSE -- Context and truth judgement Cx : Set Cx = List Ty isTrue : Ty -> Cx -> Set isTrue a tc = LMem a tc -- Terms TmRepr : Set1 TmRepr = Cx -> Ty -> Set module ArrMp where record Tm (tr : TmRepr) : Set1 where infixl 1 _$_ infixr 0 lam=>_ field var : forall {tc a} -> isTrue a tc -> tr tc a lam=>_ : forall {tc a b} -> tr (tc , a) b -> tr tc (a => b) _$_ : forall {tc a b} -> tr tc (a => b) -> tr tc a -> tr tc b v0 : forall {tc a} -> tr (tc , a) a v0 = var lzero v1 : forall {tc a b} -> tr (tc , a , b) a v1 = var (lsuc lzero) v2 : forall {tc a b c} -> tr (tc , a , b , c) a v2 = var (lsuc (lsuc lzero)) open Tm {{...}} public module Mp where record Tm (tr : TmRepr) : Set1 where field pair' : forall {tc a b} -> tr tc a -> tr tc b -> tr tc (a && b) fst : forall {tc a b} -> tr tc (a && b) -> tr tc a snd : forall {tc a b} -> tr tc (a && b) -> tr tc b left : forall {tc a b} -> tr tc a -> tr tc (a || b) right : forall {tc a b} -> tr tc b -> tr tc (a || b) case' : forall {tc a b c} -> tr tc (a || b) -> tr (tc , a) c -> tr (tc , b) c -> tr tc c isArrMp : ArrMp.Tm tr open ArrMp.Tm isArrMp public syntax pair' x y = [ x , y ] syntax case' xy x y = case xy => x => y open Tm {{...}} public module Ip where record Tm (tr : TmRepr) : Set1 where field abort : forall {tc a} -> tr tc FALSE -> tr tc a isMp : Mp.Tm tr open Mp.Tm isMp public open Tm {{...}} public Thm : Ty -> Set1 Thm a = forall {tr tc} {{_ : Tm tr}} -> tr tc a open Ip public -- Example theorems t1 : forall {a b} -> Thm (a => NOT a => b) t1 = lam=> lam=> abort (v0 $ v1) t2 : forall {a b} -> Thm (NOT a => a => b) t2 = lam=> lam=> abort (v1 $ v0) t3 : forall {a} -> Thm (a => NOT (NOT a)) t3 = lam=> lam=> v0 $ v1 t4 : forall {a} -> Thm (NOT a <=> NOT (NOT (NOT a))) t4 = [ lam=> lam=> v0 $ v1 , lam=> lam=> v1 $ (lam=> v0 $ v1) ]
data/phone/text/huey_overworld.asm
Dev727/ancientplatinum
28
90600
HueyAskNumber1Text: text "Cool! That's the" line "first time I've" cont "lost in a while!" para "Hey, give me your" line "phone number." para "You'd be fun to" line "battle, so I'll" para "call you when I" line "get stronger!" done HueyAskNumber2Text: text "Hey, give me your" line "phone number." para "You'd be fun to" line "battle, so I'll" para "call you when I" line "get stronger!" done HueyNumberAcceptedText: text "Hey, let's battle" line "again!" done HueyNumberDeclinedText: text "Looks like you're" line "a wimp…" done HueyPhoneFullText: text "Hey! Your phone's" line "already full!" done HueyRematchText: text "Hey! I'm tired of" line "waiting for you!" done HueyPackFullText: text "Oh… Your PACK's" line "full. I'll give it" cont "to you later." done HueyRematchGiftText: text "Man! You're as" line "tough as ever!" para "I've battled you" line "over and over, but" para "<PLAYER>, I haven't" line "won once." para "I bought tons of" line "items to toughen" para "up my #MON, but" line "to no avail…" para "Items alone aren't" line "the answer." para "That must be what" line "it is…" para "Here, take this," line "<PLAYER>." para "I won't be needing" line "it anymore…" done