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
libmikeos/src.os/__lsll.asm
mynameispyo/InpyoOS
0
7322
section .text use16 ; (signed, unsigned) bx:ax <<= di; global lsll global lslul lsll: lslul: mov cx, di cmp cx, 32 jb lsl_main sub ax, ax mov bx, ax ret lsl_main: push bx push ax pop eax shl eax, cl push eax pop ax pop bx ret
src/FOmegaInt/Kinding/Declarative.agda
Blaisorblade/f-omega-int-agda
0
4416
------------------------------------------------------------------------ -- A variant of declarative kinding in Fω with interval kinds ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module FOmegaInt.Kinding.Declarative where open import Data.Context.WellFormed open import Data.Fin using (Fin; zero) open import Data.Fin.Substitution open import Data.Fin.Substitution.Lemmas open import Data.Fin.Substitution.ExtraLemmas open import Data.Fin.Substitution.Typed open import Data.Fin.Substitution.TypedRelation open import Data.Nat using (ℕ) open import Data.Product using (_,_; _×_; proj₁) import Data.Vec as Vec open import Function using (_∘_) import Level open import Relation.Binary.PropositionalEquality as PropEq hiding ([_]) open import FOmegaInt.Syntax ------------------------------------------------------------------------ -- Declarative (sub)kinding, subtyping and kind/type equality. -- -- This module contains variants of the declarative kinding and -- subtyping judgments which differ slightly from those given in the -- Typing module. Some of the rules in this module have additional -- premises which we call "validity conditions". These validity -- conditions are redundant in the sense that they follow (more or -- less) directly from so-called "validity" properties of the -- corresponding judgments. For example, the kinding rule (∈-Π-e) -- below concludes that `Γ ⊢ a · b ∈ k Kind[ b ]' and has, among -- others, the validity condition `Γ ⊢ k Kind[ b ] kd' as one of its -- premises. But this is a direct consequence of "kinding validity" -- which states that the kinds of well-kinded types are themselves -- well-formed, i.e. that `Γ ⊢ k kd' whenever `Γ ⊢Tp a ∈ k' (see the -- Kinding.Declarative.Validity module for the full set of validity -- lemmas). Since all the validity conditions follow from -- corresponding validity lemmas, they are, in principle, redundant. -- Indeed, this is why they do not appear in the kinding and subtyping -- rules of the Typing module. The reason for including the validity -- conditions as premises in the rules below is that the proofs of -- some lemmas (notably the validity lemmas themselves) are done by -- induction on kinding and subtyping derivations and require the -- proofs of these conditions to be proper sub-derivations of the -- derivations on which the induction is performed. -- -- To proof the validity lemmas for both variants of the kinding and -- subtyping judgments, we use the following strategy: -- -- 1. prove the validity lemmas for the judgments containing the -- additional validity conditions as premises, -- -- 2. prove that the two variants of the judgments are -- equivalent, i.e. -- -- a) the extended judgments are sound w.r.t to the original -- judgments: we can drop the validity conditions without -- affecting the conclusion of the derivations, and -- -- b) the extended judgments are complete w.r.t. to the original -- judgments: crucially, the additional validity conditions -- follow from the *remaining premises* of the extended rules -- via the validity lemmas proved in step 1, -- -- 3. prove that validity holds for the original judgments via the -- equivalence: convert to the extended judgment (via -- completeness), apply the lemma in question, convert the -- conclusion back (via soundness). -- -- See the Kinding.Declarative.Equivalence module for the full proof -- of equivalence (point 2) and the `Tp∈-valid' lemma in the -- Typing.Inversion module for an example of point 3. module Kinding where open TermCtx open Syntax open Substitution using (_[_]; _Kind[_]; weaken) infix 4 _ctx _⊢_kd _⊢_wf infix 4 _⊢Tp_∈_ _⊢_∈_ infix 4 _⊢_<:_∈_ _⊢_<∷_ infix 4 _⊢_≃_∈_ _⊢_≅_ _⊢_≃⊎≡_∈_ mutual -- Well-formed typing contexts. _ctx : ∀ {n} → Ctx n → Set _ctx = ContextFormation._wf _⊢_wf -- Well-formed type/kind ascriptions in typing contexts. data _⊢_wf {n} (Γ : Ctx n) : TermAsc n → Set where wf-kd : ∀ {a} → Γ ⊢ a kd → Γ ⊢ (kd a) wf wf-tp : ∀ {a} → Γ ⊢Tp a ∈ * → Γ ⊢ (tp a) wf -- Well-formed kinds. data _⊢_kd {n} (Γ : Ctx n) : Kind Term n → Set where kd-⋯ : ∀ {a b} → Γ ⊢Tp a ∈ * → Γ ⊢Tp b ∈ * → Γ ⊢ a ⋯ b kd kd-Π : ∀ {j k} → Γ ⊢ j kd → kd j ∷ Γ ⊢ k kd → Γ ⊢ Π j k kd -- Kinding derivations. data _⊢Tp_∈_ {n} (Γ : Ctx n) : Term n → Kind Term n → Set where ∈-var : ∀ {k} x → Γ ctx → lookup Γ x ≡ kd k → Γ ⊢Tp var x ∈ k ∈-⊥-f : Γ ctx → Γ ⊢Tp ⊥ ∈ * ∈-⊤-f : Γ ctx → Γ ⊢Tp ⊤ ∈ * ∈-∀-f : ∀ {k a} → Γ ⊢ k kd → kd k ∷ Γ ⊢Tp a ∈ * → Γ ⊢Tp Π k a ∈ * ∈-→-f : ∀ {a b} → Γ ⊢Tp a ∈ * → Γ ⊢Tp b ∈ * → Γ ⊢Tp a ⇒ b ∈ * ∈-Π-i : ∀ {j a k} → Γ ⊢ j kd → kd j ∷ Γ ⊢Tp a ∈ k → -- Validity condition: kd j ∷ Γ ⊢ k kd → Γ ⊢Tp Λ j a ∈ Π j k ∈-Π-e : ∀ {a b j k} → Γ ⊢Tp a ∈ Π j k → Γ ⊢Tp b ∈ j → -- Validity conditions: kd j ∷ Γ ⊢ k kd → Γ ⊢ k Kind[ b ] kd → Γ ⊢Tp a · b ∈ k Kind[ b ] ∈-s-i : ∀ {a b c} → Γ ⊢Tp a ∈ b ⋯ c → Γ ⊢Tp a ∈ a ⋯ a ∈-⇑ : ∀ {a j k} → Γ ⊢Tp a ∈ j → Γ ⊢ j <∷ k → Γ ⊢Tp a ∈ k -- Subkinding derivations. data _⊢_<∷_ {n} (Γ : Ctx n) : Kind Term n → Kind Term n → Set where <∷-⋯ : ∀ {a₁ a₂ b₁ b₂} → Γ ⊢ a₂ <: a₁ ∈ * → Γ ⊢ b₁ <: b₂ ∈ * → Γ ⊢ a₁ ⋯ b₁ <∷ a₂ ⋯ b₂ <∷-Π : ∀ {j₁ j₂ k₁ k₂} → Γ ⊢ j₂ <∷ j₁ → kd j₂ ∷ Γ ⊢ k₁ <∷ k₂ → Γ ⊢ Π j₁ k₁ kd → Γ ⊢ Π j₁ k₁ <∷ Π j₂ k₂ -- Subtyping derivations. data _⊢_<:_∈_ {n} (Γ : Ctx n) : Term n → Term n → Kind Term n → Set where <:-refl : ∀ {a k} → Γ ⊢Tp a ∈ k → Γ ⊢ a <: a ∈ k <:-trans : ∀ {a b c k} → Γ ⊢ a <: b ∈ k → Γ ⊢ b <: c ∈ k → Γ ⊢ a <: c ∈ k <:-β₁ : ∀ {j a k b} → kd j ∷ Γ ⊢Tp a ∈ k → Γ ⊢Tp b ∈ j → -- Validity conditions: Γ ⊢Tp a [ b ] ∈ k Kind[ b ] → kd j ∷ Γ ⊢ k kd → Γ ⊢ k Kind[ b ] kd → Γ ⊢ (Λ j a) · b <: a [ b ] ∈ k Kind[ b ] <:-β₂ : ∀ {j a k b} → kd j ∷ Γ ⊢Tp a ∈ k → Γ ⊢Tp b ∈ j → -- Validity conditions: Γ ⊢Tp a [ b ] ∈ k Kind[ b ] → kd j ∷ Γ ⊢ k kd → Γ ⊢ k Kind[ b ] kd → Γ ⊢ a [ b ] <: (Λ j a) · b ∈ k Kind[ b ] <:-η₁ : ∀ {a j k} → Γ ⊢Tp a ∈ Π j k → Γ ⊢ Λ j (weaken a · var zero) <: a ∈ Π j k <:-η₂ : ∀ {a j k} → Γ ⊢Tp a ∈ Π j k → Γ ⊢ a <: Λ j (weaken a · var zero) ∈ Π j k <:-⊥ : ∀ {a b c} → Γ ⊢Tp a ∈ b ⋯ c → Γ ⊢ ⊥ <: a ∈ * <:-⊤ : ∀ {a b c} → Γ ⊢Tp a ∈ b ⋯ c → Γ ⊢ a <: ⊤ ∈ * <:-∀ : ∀ {k₁ k₂ a₁ a₂} → Γ ⊢ k₂ <∷ k₁ → kd k₂ ∷ Γ ⊢ a₁ <: a₂ ∈ * → Γ ⊢Tp Π k₁ a₁ ∈ * → Γ ⊢ Π k₁ a₁ <: Π k₂ a₂ ∈ * <:-→ : ∀ {a₁ a₂ b₁ b₂} → Γ ⊢ a₂ <: a₁ ∈ * → Γ ⊢ b₁ <: b₂ ∈ * → Γ ⊢ a₁ ⇒ b₁ <: a₂ ⇒ b₂ ∈ * <:-λ : ∀ {j₁ j₂ a₁ a₂ j k} → kd j ∷ Γ ⊢ a₁ <: a₂ ∈ k → Γ ⊢Tp Λ j₁ a₁ ∈ Π j k → Γ ⊢Tp Λ j₂ a₂ ∈ Π j k → Γ ⊢ Λ j₁ a₁ <: Λ j₂ a₂ ∈ Π j k <:-· : ∀ {a₁ a₂ b₁ b₂ j k} → Γ ⊢ a₁ <: a₂ ∈ Π j k → Γ ⊢ b₁ ≃ b₂ ∈ j → -- Validity conditions: Γ ⊢Tp b₁ ∈ j → kd j ∷ Γ ⊢ k kd → Γ ⊢ k Kind[ b₁ ] kd → Γ ⊢ a₁ · b₁ <: a₂ · b₂ ∈ k Kind[ b₁ ] <:-⟨| : ∀ {a b c} → Γ ⊢Tp a ∈ b ⋯ c → Γ ⊢ b <: a ∈ * <:-|⟩ : ∀ {a b c} → Γ ⊢Tp a ∈ b ⋯ c → Γ ⊢ a <: c ∈ * <:-⋯-i : ∀ {a b c d} → Γ ⊢ a <: b ∈ c ⋯ d → Γ ⊢ a <: b ∈ a ⋯ b <:-⇑ : ∀ {a b j k} → Γ ⊢ a <: b ∈ j → Γ ⊢ j <∷ k → Γ ⊢ a <: b ∈ k -- Type equality. data _⊢_≃_∈_ {n} (Γ : Ctx n) : Term n → Term n → Kind Term n → Set where <:-antisym : ∀ {a b k} → Γ ⊢ a <: b ∈ k → Γ ⊢ b <: a ∈ k → Γ ⊢ a ≃ b ∈ k -- Kind equality. data _⊢_≅_ {n} (Γ : Ctx n) : Kind Term n → Kind Term n → Set where <∷-antisym : ∀ {j k} → Γ ⊢ j <∷ k → Γ ⊢ k <∷ j → Γ ⊢ j ≅ k -- Combined kinding of types and term variable typing. data _⊢_∈_ {n} (Γ : Ctx n) : Term n → TermAsc n → Set where ∈-tp : ∀ {a k} → Γ ⊢Tp a ∈ k → Γ ⊢ a ∈ kd k ∈-var : ∀ x {a} → Γ ctx → lookup Γ x ≡ tp a → Γ ⊢ var x ∈ tp a -- Combined type equality and syntactic term variable equality (used -- for well-formed equality lifted to substitutions). data _⊢_≃⊎≡_∈_ {n} (Γ : Ctx n) : Term n → Term n → TermAsc n → Set where ≃-tp : ∀ {a b k} → Γ ⊢ a ≃ b ∈ k → Γ ⊢ a ≃⊎≡ b ∈ kd k ≃-var : ∀ x {a} → Γ ctx → lookup Γ x ≡ tp a → Γ ⊢ var x ≃⊎≡ var x ∈ tp a open PropEq using ([_]) -- Derived variable rules. ∈-var′ : ∀ {n} {Γ : Ctx n} x → Γ ctx → Γ ⊢ var x ∈ lookup Γ x ∈-var′ {Γ = Γ} x Γ-ctx with lookup Γ x | inspect (lookup Γ) x ∈-var′ x Γ-ctx | kd k | [ Γ[x]≡kd-k ] = ∈-tp (∈-var x Γ-ctx Γ[x]≡kd-k) ∈-var′ x Γ-ctx | tp a | [ Γ[x]≡tp-a ] = ∈-var x Γ-ctx Γ[x]≡tp-a ≃⊎≡-var : ∀ {n} {Γ : Ctx n} x → Γ ctx → Γ ⊢ var x ≃⊎≡ var x ∈ lookup Γ x ≃⊎≡-var {Γ = Γ} x Γ-ctx with lookup Γ x | inspect (lookup Γ) x ≃⊎≡-var x Γ-ctx | kd k | [ Γ[x]≡kd-k ] = let x∈a = ∈-var x Γ-ctx Γ[x]≡kd-k in ≃-tp (<:-antisym (<:-refl x∈a) (<:-refl x∈a)) ≃⊎≡-var x Γ-ctx | tp a | [ Γ[x]≡tp-a ] = ≃-var x Γ-ctx Γ[x]≡tp-a open ContextFormation _⊢_wf public hiding (_wf) renaming (_⊢_wfExt to _⊢_ext) ------------------------------------------------------------------------ -- Properties of typings open Syntax open TermCtx open Kinding -- An inversion lemma for _⊢_wf. wf-kd-inv : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ kd k wf → Γ ⊢ k kd wf-kd-inv (wf-kd k-kd) = k-kd -- Subkinds have the same shape. <∷-⌊⌋ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j <∷ k → ⌊ j ⌋ ≡ ⌊ k ⌋ <∷-⌊⌋ (<∷-⋯ _ _) = refl <∷-⌊⌋ (<∷-Π j₂<∷j₁ k₁<∷k₂ _) = cong₂ _⇒_ (sym (<∷-⌊⌋ j₂<∷j₁)) (<∷-⌊⌋ k₁<∷k₂) -- Equal kinds have the same shape. ≅-⌊⌋ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → ⌊ j ⌋ ≡ ⌊ k ⌋ ≅-⌊⌋ (<∷-antisym j<∷k k<∷j) = <∷-⌊⌋ j<∷k -- Kind and type equality imply subkinding and subtyping, respectively. ≅⇒<∷ : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → Γ ⊢ j <∷ k ≅⇒<∷ (<∷-antisym j<∷k k<∷j) = j<∷k ≃⇒<: : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a ≃ b ∈ k → Γ ⊢ a <: b ∈ k ≃⇒<: (<:-antisym a<:b b<:a) = a<:b -- Reflexivity of subkinding. <∷-refl : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ k kd → Γ ⊢ k <∷ k <∷-refl (kd-⋯ a∈* b∈*) = <∷-⋯ (<:-refl a∈*) (<:-refl b∈*) <∷-refl (kd-Π j-kd k-kd) = <∷-Π (<∷-refl j-kd) (<∷-refl k-kd) (kd-Π j-kd k-kd) -- Reflexivity of kind equality. ≅-refl : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ k kd → Γ ⊢ k ≅ k ≅-refl k-kd = <∷-antisym (<∷-refl k-kd) (<∷-refl k-kd) -- Symmetry of kind equality. ≅-sym : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → Γ ⊢ k ≅ j ≅-sym (<∷-antisym j<∷k k<∷j) = <∷-antisym k<∷j j<∷k -- An admissible kind equality rule for interval kinds. ≅-⋯ : ∀ {n} {Γ : Ctx n} {a₁ a₂ b₁ b₂} → Γ ⊢ a₁ ≃ a₂ ∈ * → Γ ⊢ b₁ ≃ b₂ ∈ * → Γ ⊢ a₁ ⋯ b₁ ≅ a₂ ⋯ b₂ ≅-⋯ (<:-antisym a₁<:a₂ a₂<:a₁) (<:-antisym b₁<:b₂ b₂<:b₁) = <∷-antisym (<∷-⋯ a₂<:a₁ b₁<:b₂) (<∷-⋯ a₁<:a₂ b₂<:b₁) -- Type equality is reflexive. ≃-refl : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Tp a ∈ k → Γ ⊢ a ≃ a ∈ k ≃-refl a∈k = <:-antisym (<:-refl a∈k) (<:-refl a∈k) -- Type equality is transitive. ≃-trans : ∀ {n} {Γ : Ctx n} {a b c k} → Γ ⊢ a ≃ b ∈ k → Γ ⊢ b ≃ c ∈ k → Γ ⊢ a ≃ c ∈ k ≃-trans (<:-antisym a<:b b<:a) (<:-antisym b<:c c<:b) = <:-antisym (<:-trans a<:b b<:c) (<:-trans c<:b b<:a) -- Type equality is symmetric. ≃-sym : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a ≃ b ∈ k → Γ ⊢ b ≃ a ∈ k ≃-sym (<:-antisym a<:b b<:a) = <:-antisym b<:a a<:b -- Reflexivity of the combined type and term variable equality. ≃⊎≡-refl : ∀ {n} {Γ : Ctx n} {a b} → Γ ⊢ a ∈ b → Γ ⊢ a ≃⊎≡ a ∈ b ≃⊎≡-refl (∈-tp a∈k) = ≃-tp (≃-refl a∈k) ≃⊎≡-refl (∈-var x Γ-ctx Γ[x]≡tp-a) = ≃-var x Γ-ctx Γ[x]≡tp-a -- Types inhabiting interval kinds are proper Types. Tp∈-⋯-* : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢Tp a ∈ b ⋯ c → Γ ⊢Tp a ∈ * Tp∈-⋯-* a∈b⋯c = ∈-⇑ (∈-s-i a∈b⋯c) (<∷-⋯ (<:-⊥ a∈b⋯c) (<:-⊤ a∈b⋯c)) -- Well-formedness of the * kind. *-kd : ∀ {n} {Γ : Ctx n} → Γ ctx → Γ ⊢ * kd *-kd Γ-ctx = kd-⋯ (∈-⊥-f Γ-ctx) (∈-⊤-f Γ-ctx) module _ where open Substitution -- An admissible β-rule for type equality. ≃-β : ∀ {n} {Γ : Ctx n} {j a k b} → kd j ∷ Γ ⊢Tp a ∈ k → Γ ⊢Tp b ∈ j → -- Validity conditions: Γ ⊢Tp a [ b ] ∈ k Kind[ b ] → kd j ∷ Γ ⊢ k kd → Γ ⊢ k Kind[ b ] kd → Γ ⊢ (Λ j a) · b ≃ a [ b ] ∈ k Kind[ b ] ≃-β a∈k b∈j a[b]∈k[b] k-kd k[b]-kd = <:-antisym (<:-β₁ a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) (<:-β₂ a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) -- An admissible η-rule for type equality. ≃-η : ∀ {n} {Γ : Ctx n} {a j k} → Γ ⊢Tp a ∈ Π j k → Γ ⊢ Λ j (weaken a · var zero) ≃ a ∈ Π j k ≃-η a∈Πjk = <:-antisym (<:-η₁ a∈Πjk) (<:-η₂ a∈Πjk) -- An admissible congruence rule for type equality w.r.t. formation of -- arrow types. ≃-→ : ∀ {n} {Γ : Ctx n} {a₁ a₂ b₁ b₂} → Γ ⊢ a₁ ≃ a₂ ∈ * → Γ ⊢ b₁ ≃ b₂ ∈ * → Γ ⊢ a₁ ⇒ b₁ ≃ a₂ ⇒ b₂ ∈ * ≃-→ (<:-antisym a₁<:a₂∈* a₂<:a₁∈*) (<:-antisym b₁<:b₂∈* b₂<:b₁∈*) = <:-antisym (<:-→ a₂<:a₁∈* b₁<:b₂∈*) (<:-→ a₁<:a₂∈* b₂<:b₁∈*) -- An admissible congruence rule for type equality w.r.t. operator -- abstraction. ≃-λ : ∀ {n} {Γ : Ctx n} {j₁ j₂ a₁ a₂ j k} → kd j ∷ Γ ⊢ a₁ ≃ a₂ ∈ k → Γ ⊢Tp Λ j₁ a₁ ∈ Π j k → Γ ⊢Tp Λ j₂ a₂ ∈ Π j k → Γ ⊢ Λ j₁ a₁ ≃ Λ j₂ a₂ ∈ Π j k ≃-λ (<:-antisym a₁<:a₂∈k a₂<:a₁∈k) Λj₁a₁∈Πjk Λj₂a₂∈Πjk = <:-antisym (<:-λ a₁<:a₂∈k Λj₁a₁∈Πjk Λj₂a₂∈Πjk) (<:-λ a₂<:a₁∈k Λj₂a₂∈Πjk Λj₁a₁∈Πjk) -- An admissible subsumption rule for type equality. ≃-⇑ : ∀ {n} {Γ : Ctx n} {a b j k} → Γ ⊢ a ≃ b ∈ j → Γ ⊢ j <∷ k → Γ ⊢ a ≃ b ∈ k ≃-⇑ (<:-antisym a<:b b<:a) j<∷k = <:-antisym (<:-⇑ a<:b j<∷k) (<:-⇑ b<:a j<∷k) -- The contexts of all the above judgments are well-formed. mutual kd-ctx : ∀ {n} {Γ : Ctx n} {k} → Γ ⊢ k kd → Γ ctx kd-ctx (kd-⋯ a∈* b∈*) = Tp∈-ctx a∈* kd-ctx (kd-Π j-kd k-kd) = kd-ctx j-kd Tp∈-ctx : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Tp a ∈ k → Γ ctx Tp∈-ctx (∈-var x Γ-ctx Γ[x]≡kd-k) = Γ-ctx Tp∈-ctx (∈-⊥-f Γ-ctx) = Γ-ctx Tp∈-ctx (∈-⊤-f Γ-ctx) = Γ-ctx Tp∈-ctx (∈-∀-f k-kd a∈*) = kd-ctx k-kd Tp∈-ctx (∈-→-f a∈* b∈*) = Tp∈-ctx a∈* Tp∈-ctx (∈-Π-i j-kd a∈k k-kd) = kd-ctx j-kd Tp∈-ctx (∈-Π-e a∈Πjk b∈j k-kd k[b]-kd) = Tp∈-ctx a∈Πjk Tp∈-ctx (∈-s-i a∈b⋯c) = Tp∈-ctx a∈b⋯c Tp∈-ctx (∈-⇑ a∈j j<∷k) = Tp∈-ctx a∈j wf-ctx : ∀ {n} {Γ : Ctx n} {a} → Γ ⊢ a wf → Γ ctx wf-ctx (wf-kd k-kd) = kd-ctx k-kd wf-ctx (wf-tp a∈*) = Tp∈-ctx a∈* <:-ctx : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a <: b ∈ k → Γ ctx <:-ctx (<:-refl a∈k) = Tp∈-ctx a∈k <:-ctx (<:-trans a<:b∈k b<:c∈k) = <:-ctx a<:b∈k <:-ctx (<:-β₁ a∈j b∈k a[b]∈k[b] k-kd k[b]-kd) = Tp∈-ctx b∈k <:-ctx (<:-β₂ a∈j b∈k a[b]∈k[b] k-kd k[b]-kd) = Tp∈-ctx b∈k <:-ctx (<:-η₁ a∈Πjk) = Tp∈-ctx a∈Πjk <:-ctx (<:-η₂ a∈Πjk) = Tp∈-ctx a∈Πjk <:-ctx (<:-⊥ a∈b⋯c) = Tp∈-ctx a∈b⋯c <:-ctx (<:-⊤ a∈b⋯c) = Tp∈-ctx a∈b⋯c <:-ctx (<:-∀ k₂<∷k₁ a₁<:a₂ ∀k₁a₁∈*) = Tp∈-ctx ∀k₁a₁∈* <:-ctx (<:-→ a₂<:a₁ b₁<:b₂) = <:-ctx a₂<:a₁ <:-ctx (<:-λ a₂<:a₁∈Πjk Λa₁k₁∈Πjk Λa₂k₂∈Πjk) = Tp∈-ctx Λa₁k₁∈Πjk <:-ctx (<:-· a₂<:a₁∈Πjk b₂≃b₁∈j b₁∈j k-kd k[b₁]-kd) = <:-ctx a₂<:a₁∈Πjk <:-ctx (<:-⟨| a∈b⋯c) = Tp∈-ctx a∈b⋯c <:-ctx (<:-|⟩ a∈b⋯c) = Tp∈-ctx a∈b⋯c <:-ctx (<:-⋯-i a<:b∈c⋯d) = <:-ctx a<:b∈c⋯d <:-ctx (<:-⇑ a<:b∈j j<∷k) = <:-ctx a<:b∈j <∷-ctx : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j <∷ k → Γ ctx <∷-ctx (<∷-⋯ a₂<:a₁ b₁<:b₂) = <:-ctx a₂<:a₁ <∷-ctx (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) = <∷-ctx j₂<∷j₁ ≅-ctx : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j ≅ k → Γ ctx ≅-ctx (<∷-antisym j<∷k k<∷j) = <∷-ctx j<∷k ≃-ctx : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a ≃ b ∈ k → Γ ctx ≃-ctx (<:-antisym a<:b∈k b<:a∈k) = <:-ctx a<:b∈k ∈-ctx : ∀ {n} {Γ : Ctx n} {a b} → Γ ⊢ a ∈ b → Γ ctx ∈-ctx (∈-tp a∈k) = Tp∈-ctx a∈k ∈-ctx (∈-var x Γ-ctx Γ[x]≡tp-a) = Γ-ctx ≃⊎≡-ctx : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢ a ≃⊎≡ b ∈ c → Γ ctx ≃⊎≡-ctx (≃-tp a≃b∈k) = ≃-ctx a≃b∈k ≃⊎≡-ctx (≃-var x Γ-ctx Γ[x]≡tp-a) = Γ-ctx ---------------------------------------------------------------------- -- Well-kinded/typed substitutions (i.e. substitution lemmas) -- A shorthand for kindings and typings of Ts by kind or type -- ascriptions. TermAscTyping : (ℕ → Set) → Set₁ TermAscTyping T = Typing TermAsc T TermAsc Level.zero -- Liftings from well-typed Ts to well-typed/kinded terms/types. LiftTo-∈ : ∀ {T} → TermAscTyping T → Set₁ LiftTo-∈ _⊢T_∈_ = LiftTyped Substitution.termAscTermSubst _⊢_wf _⊢T_∈_ _⊢_∈_ -- Helper lemmas about untyped T-substitutions in raw terms and kinds. record TypedSubstAppHelpers {T} (rawLift : Lift T Term) : Set where open Substitution using (weaken; _[_]; _Kind[_]) module A = SubstApp rawLift module L = Lift rawLift field -- Substitutions in kinds and types commute. Kind/-sub-↑ : ∀ {m n} k a (σ : Sub T m n) → k Kind[ a ] A.Kind/ σ ≡ (k A.Kind/ σ L.↑) Kind[ a A./ σ ] /-sub-↑ : ∀ {m n} b a (σ : Sub T m n) → b [ a ] A./ σ ≡ (b A./ σ L.↑) [ a A./ σ ] -- Weakening of terms commutes with substitution in terms. weaken-/ : ∀ {m n} {σ : Sub T m n} a → weaken (a A./ σ) ≡ weaken a A./ σ L.↑ -- Application of generic well-typed T-substitutions to all the judgments. module TypedSubstApp {T : ℕ → Set} (_⊢T_∈_ : TermAscTyping T) (liftTyped : LiftTo-∈ _⊢T_∈_) (helpers : TypedSubstAppHelpers (LiftTyped.rawLift liftTyped)) where open LiftTyped liftTyped renaming (lookup to /∈-lookup) open TypedSubstAppHelpers helpers -- Lift well-kinded Ts to well-kinded types. liftTp : ∀ {n} {Γ : Ctx n} {a k kd-k} → kd-k ≡ kd k → Γ ⊢T a ∈ kd-k → Γ ⊢Tp L.lift a ∈ k liftTp refl a∈kd-k with ∈-lift a∈kd-k liftTp refl a∈kd-k | ∈-tp a∈k = a∈k mutual -- Substitutions preserve well-formedness of kinds and -- well-kindedness of types. kd-/ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {k σ} → Γ ⊢ k kd → Δ ⊢/ σ ∈ Γ → Δ ⊢ k A.Kind/ σ kd kd-/ (kd-⋯ a∈* b∈*) σ∈Γ = kd-⋯ (Tp∈-/ a∈* σ∈Γ) (Tp∈-/ b∈* σ∈Γ) kd-/ (kd-Π j-kd k-kd) σ∈Γ = kd-Π j/σ-kd (kd-/ k-kd (∈-↑ (wf-kd j/σ-kd) σ∈Γ)) where j/σ-kd = kd-/ j-kd σ∈Γ Tp∈-/ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a k σ} → Γ ⊢Tp a ∈ k → Δ ⊢/ σ ∈ Γ → Δ ⊢Tp a A./ σ ∈ k A.Kind/ σ Tp∈-/ (∈-var x Γ-ctx Γ[x]≡kd-k) σ∈Γ = liftTp (cong (_/ _) Γ[x]≡kd-k) (/∈-lookup σ∈Γ x) Tp∈-/ (∈-⊥-f Γ-ctx) σ∈Γ = ∈-⊥-f (/∈-wf σ∈Γ) Tp∈-/ (∈-⊤-f Γ-ctx) σ∈Γ = ∈-⊤-f (/∈-wf σ∈Γ) Tp∈-/ (∈-∀-f k-kd a∈*) σ∈Γ = ∈-∀-f k/σ-kd (Tp∈-/ a∈* (∈-↑ (wf-kd k/σ-kd) σ∈Γ)) where k/σ-kd = kd-/ k-kd σ∈Γ Tp∈-/ (∈-→-f a∈* b∈*) σ∈Γ = ∈-→-f (Tp∈-/ a∈* σ∈Γ) (Tp∈-/ b∈* σ∈Γ) Tp∈-/ (∈-Π-i j-kd a∈k k-kd) σ∈Γ = ∈-Π-i j/σ-kd (Tp∈-/ a∈k σ↑∈j∷Γ) (kd-/ k-kd σ↑∈j∷Γ) where j/σ-kd = kd-/ j-kd σ∈Γ σ↑∈j∷Γ = ∈-↑ (wf-kd j/σ-kd) σ∈Γ Tp∈-/ (∈-Π-e {_} {b} {_} {k} a∈Πjk b∈j k-kd k[b]-kd) σ∈Γ = subst (_ ⊢Tp _ ∈_) (sym k[b]/σ≡k/σ[b/σ]) (∈-Π-e (Tp∈-/ a∈Πjk σ∈Γ) (Tp∈-/ b∈j σ∈Γ) (kd-/ k-kd (∈-↑ (kd-/-wf k-kd σ∈Γ) σ∈Γ)) (subst (_ ⊢_kd) k[b]/σ≡k/σ[b/σ] (kd-/ k[b]-kd σ∈Γ))) where k[b]/σ≡k/σ[b/σ] = Kind/-sub-↑ k b _ Tp∈-/ (∈-s-i a∈b⋯c) σ∈Γ = ∈-s-i (Tp∈-/ a∈b⋯c σ∈Γ) Tp∈-/ (∈-⇑ a∈j j<∷k) σ∈Γ = ∈-⇑ (Tp∈-/ a∈j σ∈Γ) (<∷-/ j<∷k σ∈Γ) -- Substitutions commute with subkinding, subtyping and type -- equality. <∷-/ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {j k σ} → Γ ⊢ j <∷ k → Δ ⊢/ σ ∈ Γ → Δ ⊢ j A.Kind/ σ <∷ k A.Kind/ σ <∷-/ (<∷-⋯ a₂<:a₁ b₁<:b₂) σ∈Γ = <∷-⋯ (<:-/ a₂<:a₁ σ∈Γ) (<:-/ b₁<:b₂ σ∈Γ) <∷-/ (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) σ∈Γ = <∷-Π (<∷-/ j₂<∷j₁ σ∈Γ) (<∷-/ k₁<∷k₂ (∈-↑ (<∷-/-wf k₁<∷k₂ σ∈Γ) σ∈Γ)) (kd-/ Πj₁k₁-kd σ∈Γ) <:-/ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a b k σ} → Γ ⊢ a <: b ∈ k → Δ ⊢/ σ ∈ Γ → Δ ⊢ a A./ σ <: b A./ σ ∈ k A.Kind/ σ <:-/ (<:-refl a∈k) σ∈Γ = <:-refl (Tp∈-/ a∈k σ∈Γ) <:-/ (<:-trans a<:b∈k b<:c∈k) σ∈Γ = <:-trans (<:-/ a<:b∈k σ∈Γ) (<:-/ b<:c∈k σ∈Γ) <:-/ (<:-β₁ {j} {a} {k} {b} a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) σ∈Γ = subst₂ (_ ⊢ (Λ j a) · b A./ _ <:_∈_) (sym a[b]/σ≡a/σ[b/σ]) (sym k[b]/σ≡k/σ[b/σ]) (<:-β₁ (Tp∈-/ a∈k σ↑∈j∷Γ) (Tp∈-/ b∈j σ∈Γ) (subst₂ (_ ⊢Tp_∈_) a[b]/σ≡a/σ[b/σ] k[b]/σ≡k/σ[b/σ] (Tp∈-/ a[b]∈k[b] σ∈Γ)) (kd-/ k-kd σ↑∈j∷Γ) (subst (_ ⊢_kd) k[b]/σ≡k/σ[b/σ] (kd-/ k[b]-kd σ∈Γ))) where σ↑∈j∷Γ = ∈-↑ (Tp∈-/-wf a∈k σ∈Γ) σ∈Γ k[b]/σ≡k/σ[b/σ] = Kind/-sub-↑ k b _ a[b]/σ≡a/σ[b/σ] = /-sub-↑ a b _ <:-/ (<:-β₂ {j} {a} {k} {b} a∈k b∈j a[b]∈k[b] k-kd k[b]-kd) σ∈Γ = subst₂ (_ ⊢_<: (Λ j a) · b A./ _ ∈_) (sym a[b]/σ≡a/σ[b/σ]) (sym k[b]/σ≡k/σ[b/σ]) (<:-β₂ (Tp∈-/ a∈k σ↑∈j∷Γ) (Tp∈-/ b∈j σ∈Γ) (subst₂ (_ ⊢Tp_∈_) a[b]/σ≡a/σ[b/σ] k[b]/σ≡k/σ[b/σ] (Tp∈-/ a[b]∈k[b] σ∈Γ)) (kd-/ k-kd σ↑∈j∷Γ) (subst (_ ⊢_kd) k[b]/σ≡k/σ[b/σ] (kd-/ k[b]-kd σ∈Γ))) where σ↑∈j∷Γ = ∈-↑ (Tp∈-/-wf a∈k σ∈Γ) σ∈Γ k[b]/σ≡k/σ[b/σ] = Kind/-sub-↑ k b _ a[b]/σ≡a/σ[b/σ] = /-sub-↑ a b _ <:-/ {Δ = Δ} {σ = σ} (<:-η₁ {a} {j} {k} a∈Πjk) σ∈Γ = subst (Δ ⊢_<: a A./ σ ∈ Π j k A.Kind/ σ) (cong (Λ _) (cong₂ _·_ (weaken-/ a) (sym (lift-var zero)))) (<:-η₁ (Tp∈-/ a∈Πjk σ∈Γ)) <:-/ {Δ = Δ} {σ = σ} (<:-η₂ {a} {j} {k} a∈Πjk) σ∈Γ = subst (Δ ⊢ a A./ σ <:_∈ Π j k A.Kind/ σ) (cong (Λ _) (cong₂ _·_ (weaken-/ a) (sym (lift-var zero)))) (<:-η₂ (Tp∈-/ a∈Πjk σ∈Γ)) <:-/ (<:-⊥ a∈b⋯c) σ∈Γ = <:-⊥ (Tp∈-/ a∈b⋯c σ∈Γ) <:-/ (<:-⊤ a∈b⋯c) σ∈Γ = <:-⊤ (Tp∈-/ a∈b⋯c σ∈Γ) <:-/ (<:-∀ k₂<∷k₁ a₁<:a₂∈* ∀j₁k₁∈*) σ∈Γ = <:-∀ (<∷-/ k₂<∷k₁ σ∈Γ) (<:-/ a₁<:a₂∈* (∈-↑ (<:-/-wf a₁<:a₂∈* σ∈Γ) σ∈Γ)) (Tp∈-/ ∀j₁k₁∈* σ∈Γ) <:-/ (<:-→ a₂<:a₁∈* b₁<:b₂∈*) σ∈Γ = <:-→ (<:-/ a₂<:a₁∈* σ∈Γ) (<:-/ b₁<:b₂∈* σ∈Γ) <:-/ (<:-λ a₁<:a₂∈k Λj₁a₁∈Πjk Λj₂a₂∈Πjk) σ∈Γ = <:-λ (<:-/ a₁<:a₂∈k (∈-↑ (<:-/-wf a₁<:a₂∈k σ∈Γ) σ∈Γ)) (Tp∈-/ Λj₁a₁∈Πjk σ∈Γ) (Tp∈-/ Λj₂a₂∈Πjk σ∈Γ) <:-/ (<:-· {k = k} a₁<:a₂∈Πjk b₁≃b₂∈j b₁∈j k-kd k[b₁]-kd) σ∈Γ = subst (_ ⊢ _ <: _ ∈_) (sym k[b₁]/σ≡k/σ[b₁/σ]) (<:-· (<:-/ a₁<:a₂∈Πjk σ∈Γ) (≃-/ b₁≃b₂∈j σ∈Γ) (Tp∈-/ b₁∈j σ∈Γ) (kd-/ k-kd (∈-↑ (kd-/-wf k-kd σ∈Γ) σ∈Γ)) (subst (_ ⊢_kd) k[b₁]/σ≡k/σ[b₁/σ] (kd-/ k[b₁]-kd σ∈Γ))) where k[b₁]/σ≡k/σ[b₁/σ] = Kind/-sub-↑ k _ _ <:-/ (<:-⟨| a∈b⋯c) σ∈Γ = <:-⟨| (Tp∈-/ a∈b⋯c σ∈Γ) <:-/ (<:-|⟩ a∈b⋯c) σ∈Γ = <:-|⟩ (Tp∈-/ a∈b⋯c σ∈Γ) <:-/ (<:-⋯-i a<:b∈c⋯d) σ∈Γ = <:-⋯-i (<:-/ a<:b∈c⋯d σ∈Γ) <:-/ (<:-⇑ a<:b∈j j<∷k) σ∈Γ = <:-⇑ (<:-/ a<:b∈j σ∈Γ) (<∷-/ j<∷k σ∈Γ) ≃-/ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a b k σ} → Γ ⊢ a ≃ b ∈ k → Δ ⊢/ σ ∈ Γ → Δ ⊢ a A./ σ ≃ b A./ σ ∈ k A.Kind/ σ ≃-/ (<:-antisym a<:b∈k b<:a∈k) σ∈Γ = <:-antisym (<:-/ a<:b∈k σ∈Γ) (<:-/ b<:a∈k σ∈Γ) -- Helpers (to satisfy the termination checker). kd-/-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {j k σ} → kd j ∷ Γ ⊢ k kd → Δ ⊢/ σ ∈ Γ → Δ ⊢ kd (j A.Kind/ σ) wf kd-/-wf (kd-⋯ a∈* _) σ∈Γ = Tp∈-/-wf a∈* σ∈Γ kd-/-wf (kd-Π j-kd _) σ∈Γ = kd-/-wf j-kd σ∈Γ Tp∈-/-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a j k σ} → kd j ∷ Γ ⊢Tp a ∈ k → Δ ⊢/ σ ∈ Γ → Δ ⊢ kd (j A.Kind/ σ) wf Tp∈-/-wf (∈-var x (wf-kd k-kd ∷ Γ-ctx) _) σ∈Γ = wf-kd (kd-/ k-kd σ∈Γ) Tp∈-/-wf (∈-⊥-f (wf-kd j-kd ∷ Γ-ctx)) σ∈Γ = wf-kd (kd-/ j-kd σ∈Γ) Tp∈-/-wf (∈-⊤-f (wf-kd j-kd ∷ Γ-ctx)) σ∈Γ = wf-kd (kd-/ j-kd σ∈Γ) Tp∈-/-wf (∈-∀-f k-kd _) σ∈Γ = kd-/-wf k-kd σ∈Γ Tp∈-/-wf (∈-→-f a∈* _) σ∈Γ = Tp∈-/-wf a∈* σ∈Γ Tp∈-/-wf (∈-Π-i j-kd _ _) σ∈Γ = kd-/-wf j-kd σ∈Γ Tp∈-/-wf (∈-Π-e a∈Πjk _ _ _) σ∈Γ = Tp∈-/-wf a∈Πjk σ∈Γ Tp∈-/-wf (∈-s-i a∈b⋯c) σ∈Γ = Tp∈-/-wf a∈b⋯c σ∈Γ Tp∈-/-wf (∈-⇑ a∈b _) σ∈Γ = Tp∈-/-wf a∈b σ∈Γ <:-/-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a b j k σ} → kd j ∷ Γ ⊢ a <: b ∈ k → Δ ⊢/ σ ∈ Γ → Δ ⊢ kd (j A.Kind/ σ) wf <:-/-wf (<:-refl a∈k) σ∈Γ = Tp∈-/-wf a∈k σ∈Γ <:-/-wf (<:-trans a<:b _) σ∈Γ = <:-/-wf a<:b σ∈Γ <:-/-wf (<:-β₁ _ b∈j _ _ _) σ∈Γ = Tp∈-/-wf b∈j σ∈Γ <:-/-wf (<:-β₂ _ b∈j _ _ _) σ∈Γ = Tp∈-/-wf b∈j σ∈Γ <:-/-wf (<:-η₁ a∈Πjk) σ∈Γ = Tp∈-/-wf a∈Πjk σ∈Γ <:-/-wf (<:-η₂ a∈Πjk) σ∈Γ = Tp∈-/-wf a∈Πjk σ∈Γ <:-/-wf (<:-⊥ a∈b⋯c) σ∈Γ = Tp∈-/-wf a∈b⋯c σ∈Γ <:-/-wf (<:-⊤ a∈b⋯c) σ∈Γ = Tp∈-/-wf a∈b⋯c σ∈Γ <:-/-wf (<:-∀ j₂<∷j₁ _ _) σ∈Γ = <∷-/-wf j₂<∷j₁ σ∈Γ <:-/-wf (<:-→ a₂<:a₁∈* _) σ∈Γ = <:-/-wf a₂<:a₁∈* σ∈Γ <:-/-wf (<:-λ _ Λj₁a₂∈Πjk _) σ∈Γ = Tp∈-/-wf Λj₁a₂∈Πjk σ∈Γ <:-/-wf (<:-· a₁<:a₂∈Πjk _ _ _ _) σ∈Γ = <:-/-wf a₁<:a₂∈Πjk σ∈Γ <:-/-wf (<:-⟨| a∈b⋯c) σ∈Γ = Tp∈-/-wf a∈b⋯c σ∈Γ <:-/-wf (<:-|⟩ a∈b⋯c) σ∈Γ = Tp∈-/-wf a∈b⋯c σ∈Γ <:-/-wf (<:-⋯-i a<:b∈c⋯d) σ∈Γ = <:-/-wf a<:b∈c⋯d σ∈Γ <:-/-wf (<:-⇑ a<:b∈k _) σ∈Γ = <:-/-wf a<:b∈k σ∈Γ <∷-/-wf : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {j k l σ} → kd j ∷ Γ ⊢ k <∷ l → Δ ⊢/ σ ∈ Γ → Δ ⊢ kd (j A.Kind/ σ) wf <∷-/-wf (<∷-⋯ j₂<:j₁ _) σ∈Γ = <:-/-wf j₂<:j₁ σ∈Γ <∷-/-wf (<∷-Π j₂<∷j₁ _ _) σ∈Γ = <∷-/-wf j₂<∷j₁ σ∈Γ -- Substitutions preserve well-formedness of ascriptions. wf-/ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a σ} → Γ ⊢ a wf → Δ ⊢/ σ ∈ Γ → Δ ⊢ a A.TermAsc/ σ wf wf-/ (wf-kd k-kd) σ∈Γ = wf-kd (kd-/ k-kd σ∈Γ) wf-/ (wf-tp a∈b) σ∈Γ = wf-tp (Tp∈-/ a∈b σ∈Γ) -- Substitutions commute with kind equality. ≅-/ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {j k σ} → Γ ⊢ j ≅ k → Δ ⊢/ σ ∈ Γ → Δ ⊢ j A.Kind/ σ ≅ k A.Kind/ σ ≅-/ (<∷-antisym j<∷k k<∷j) σ∈Γ = <∷-antisym (<∷-/ j<∷k σ∈Γ) (<∷-/ k<∷j σ∈Γ) -- Substitutions preserve well-kindedness and well-typedness. ∈-/ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a b σ} → Γ ⊢ a ∈ b → Δ ⊢/ σ ∈ Γ → Δ ⊢ a A./ σ ∈ b A.TermAsc/ σ ∈-/ (∈-tp a∈b) σ∈Γ = ∈-tp (Tp∈-/ a∈b σ∈Γ) ∈-/ (∈-var x Γ-ctx Γ[x]≡tp-a) σ∈Γ = subst (_ ⊢ _ ∈_) (cong (A._TermAsc/ _) Γ[x]≡tp-a) (∈-lift (/∈-lookup σ∈Γ x)) -- Substitutions preserve type and syntactic term equality. ≃⊎≡-/ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a b c σ} → Γ ⊢ a ≃⊎≡ b ∈ c → Δ ⊢/ σ ∈ Γ → Δ ⊢ a A./ σ ≃⊎≡ b A./ σ ∈ c A.TermAsc/ σ ≃⊎≡-/ (≃-tp a≃b∈k) σ∈Γ = ≃-tp (≃-/ a≃b∈k σ∈Γ) ≃⊎≡-/ (≃-var x Γ-ctx Γ[x]≡tp-a) σ∈Γ = let x/σ∈tp-a/σ = subst (_ ⊢ _ ∈_) (cong (A._TermAsc/ _) Γ[x]≡tp-a) (∈-lift (/∈-lookup σ∈Γ x)) in ≃⊎≡-refl x/σ∈tp-a/σ -- Well-kinded type substitutions. module KindedSubstitution where open Substitution using (simple; termSubst) open SimpleExt simple using (extension) open TermSubst termSubst using (varLift; termLift) private module S = Substitution module KL = TermLikeLemmas S.termLikeLemmasKind -- Helper lemmas about untyped renamings and substitutions in terms -- and kinds. varHelpers : TypedSubstAppHelpers varLift varHelpers = record { Kind/-sub-↑ = KL./-sub-↑ ; /-sub-↑ = LiftSubLemmas./-sub-↑ S.varLiftSubLemmas ; weaken-/ = LiftAppLemmas.wk-commutes S.varLiftAppLemmas } termHelpers : TypedSubstAppHelpers termLift termHelpers = record { Kind/-sub-↑ = λ k _ _ → KL.sub-commutes k ; /-sub-↑ = λ a _ _ → S.sub-commutes a ; weaken-/ = S.weaken-/ } -- Kinded type substitutions. typedTermSubst : TypedTermSubst TermAsc Term Level.zero TypedSubstAppHelpers typedTermSubst = record { _⊢_wf = _⊢_wf ; _⊢_∈_ = _⊢_∈_ ; termLikeLemmas = S.termLikeLemmasTermAsc ; varHelpers = varHelpers ; termHelpers = termHelpers ; wf-wf = wf-ctx ; ∈-wf = ∈-ctx ; ∈-var = ∈-var′ ; typedApp = TypedSubstApp.∈-/ } open TypedTermSubst typedTermSubst public hiding (_⊢_wf; _⊢_∈_; varHelpers; termHelpers; ∈-var; ∈-/Var; ∈-/) renaming (lookup to /∈-lookup) open TypedSubstApp _⊢Var_∈_ varLiftTyped varHelpers public using () renaming ( wf-/ to wf-/Var ; kd-/ to kd-/Var ; Tp∈-/ to Tp∈-/Var ; <∷-/ to <∷-/Var ; <:-/ to <:-/Var ; ∈-/ to ∈-/Var ; ≃⊎≡-/ to ≃⊎≡-/Var ) open Substitution using (weaken; weakenKind; weakenTermAsc) -- Weakening preserves the various judgments. wf-weaken : ∀ {n} {Γ : Ctx n} {a b} → Γ ⊢ a wf → Γ ⊢ b wf → (a ∷ Γ) ⊢ weakenTermAsc b wf wf-weaken a-wf b-wf = wf-/Var b-wf (Var∈-wk a-wf) kd-weaken : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢ a wf → Γ ⊢ k kd → (a ∷ Γ) ⊢ weakenKind k kd kd-weaken a-wf k-kd = kd-/Var k-kd (Var∈-wk a-wf) Tp∈-weaken : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a wf → Γ ⊢Tp b ∈ k → (a ∷ Γ) ⊢Tp weaken b ∈ weakenKind k Tp∈-weaken a-wf b∈k = Tp∈-/Var b∈k (Var∈-wk a-wf) <∷-weaken : ∀ {n} {Γ : Ctx n} {a j k} → Γ ⊢ a wf → Γ ⊢ j <∷ k → (a ∷ Γ) ⊢ weakenKind j <∷ weakenKind k <∷-weaken a-wf j<∷k = <∷-/Var j<∷k (Var∈-wk a-wf) <:-weaken : ∀ {n} {Γ : Ctx n} {a b c k} → Γ ⊢ a wf → Γ ⊢ b <: c ∈ k → (a ∷ Γ) ⊢ weaken b <: weaken c ∈ weakenKind k <:-weaken a-wf b<:c∈k = <:-/Var b<:c∈k (Var∈-wk a-wf) ∈-weaken : ∀ {n} {Γ : Ctx n} {a b c} → Γ ⊢ a wf → Γ ⊢ b ∈ c → (a ∷ Γ) ⊢ weaken b ∈ weakenTermAsc c ∈-weaken a-wf b∈c = ∈-/Var b∈c (Var∈-wk a-wf) -- Weakening preserves type and syntactic term equality. ≃⊎≡-weaken : ∀ {n} {Γ : Ctx n} {a b c d} → Γ ⊢ a wf → Γ ⊢ b ≃⊎≡ c ∈ d → (a ∷ Γ) ⊢ weaken b ≃⊎≡ weaken c ∈ weakenTermAsc d ≃⊎≡-weaken a-wf b≃⊎≡c∈d = ≃⊎≡-/Var b≃⊎≡c∈d (Var∈-wk a-wf) open TypedSubstApp _⊢_∈_ termLiftTyped termHelpers public open Substitution using (_/_; _Kind/_; id; sub; _↑⋆_; _[_]; _Kind[_]) -- Substitution of a single well-typed term or well-kinded type -- preserves the various judgments. kd-[] : ∀ {n} {Γ : Ctx n} {a b k} → b ∷ Γ ⊢ k kd → Γ ⊢ a ∈ b → Γ ⊢ k Kind[ a ] kd kd-[] k-kd a∈b = kd-/ k-kd (∈-sub a∈b) ≅-[] : ∀ {n} {Γ : Ctx n} {j k a b} → b ∷ Γ ⊢ j ≅ k → Γ ⊢ a ∈ b → Γ ⊢ j Kind[ a ] ≅ k Kind[ a ] ≅-[] j≅k a∈b = ≅-/ j≅k (∈-sub a∈b) Tp∈-[] : ∀ {n} {Γ : Ctx n} {a b k c} → c ∷ Γ ⊢Tp a ∈ k → Γ ⊢ b ∈ c → Γ ⊢Tp a [ b ] ∈ k Kind[ b ] Tp∈-[] a∈k b∈c = Tp∈-/ a∈k (∈-sub b∈c) -- Context narrowing. -- A typed substitution that narrows the kind of the first type -- variable. ∈-<∷-sub : ∀ {n} {Γ : Ctx n} {j k} → Γ ⊢ j kd → Γ ⊢ j <∷ k → kd j ∷ Γ ⊢/ id ∈ kd k ∷ Γ ∈-<∷-sub j-kd j<∷k = ∈-tsub (∈-tp (∈-⇑ (∈-var zero (j-wf ∷ Γ-ctx) refl) (<∷-weaken j-wf j<∷k))) where j-wf = wf-kd j-kd Γ-ctx = kd-ctx j-kd -- Narrowing the kind of the first type variable preserves -- well-formedness of kinds. ⇓-kd : ∀ {n} {Γ : Ctx n} {j₁ j₂ k} → Γ ⊢ j₁ kd → Γ ⊢ j₁ <∷ j₂ → kd j₂ ∷ Γ ⊢ k kd → kd j₁ ∷ Γ ⊢ k kd ⇓-kd j₁-kd j₁<∷j₂ k-kd = subst (_ ⊢_kd) (KL.id-vanishes _) (kd-/ k-kd (∈-<∷-sub j₁-kd j₁<∷j₂)) -- Narrowing the kind of the first type variable preserves -- well-kindedness. ⇓-Tp∈ : ∀ {n} {Γ : Ctx n} {j₁ j₂ a k} → Γ ⊢ j₁ kd → Γ ⊢ j₁ <∷ j₂ → kd j₂ ∷ Γ ⊢Tp a ∈ k → kd j₁ ∷ Γ ⊢Tp a ∈ k ⇓-Tp∈ j₁-kd j₁<∷j₂ a∈k = subst₂ (_ ⊢Tp_∈_) (S.id-vanishes _) (KL.id-vanishes _) (Tp∈-/ a∈k (∈-<∷-sub j₁-kd j₁<∷j₂)) -- Narrowing the kind of the first type variable preserves -- subkinding and subtyping. ⇓-<∷ : ∀ {n} {Γ : Ctx n} {j₁ j₂ k₁ k₂} → Γ ⊢ j₁ kd → Γ ⊢ j₁ <∷ j₂ → kd j₂ ∷ Γ ⊢ k₁ <∷ k₂ → kd j₁ ∷ Γ ⊢ k₁ <∷ k₂ ⇓-<∷ j₁-kd j₁<∷j₂ k₁<∷k₂ = subst₂ (_ ⊢_<∷_) (KL.id-vanishes _) (KL.id-vanishes _) (<∷-/ k₁<∷k₂ (∈-<∷-sub j₁-kd j₁<∷j₂)) ⇓-<: : ∀ {n} {Γ : Ctx n} {j₁ j₂ a₁ a₂ k} → Γ ⊢ j₁ kd → Γ ⊢ j₁ <∷ j₂ → kd j₂ ∷ Γ ⊢ a₁ <: a₂ ∈ k → kd j₁ ∷ Γ ⊢ a₁ <: a₂ ∈ k ⇓-<: j₁-kd j₁<∷j₂ a₁<:a₂∈k = subst (_ ⊢ _ <: _ ∈_) (KL.id-vanishes _) (subst₂ (_ ⊢_<:_∈ _) (S.id-vanishes _) (S.id-vanishes _) (<:-/ a₁<:a₂∈k (∈-<∷-sub j₁-kd j₁<∷j₂))) -- Operations on well-formed contexts that require weakening of -- well-formedness judgments. module WfCtxOps where wfWeakenOps : WellFormedWeakenOps weakenOps wfWeakenOps = record { wf-weaken = KindedSubstitution.wf-weaken } open WellFormedWeakenOps wfWeakenOps public renaming (lookup to lookup-wf) -- Lookup the kind of a type variable in a well-formed context. lookup-kd : ∀ {m} {Γ : Ctx m} {k} x → Γ ctx → TermCtx.lookup Γ x ≡ kd k → Γ ⊢ k kd lookup-kd x Γ-ctx Γ[x]≡kd-k = wf-kd-inv (subst (_ ⊢_wf) Γ[x]≡kd-k (lookup-wf Γ-ctx x)) open KindedSubstitution open WfCtxOps -- Transitivity of subkinding. <∷-trans : ∀ {n} {Γ : Ctx n} {j k l} → Γ ⊢ j <∷ k → Γ ⊢ k <∷ l → Γ ⊢ j <∷ l <∷-trans (<∷-⋯ a₂<:a₁ b₁<:b₂) (<∷-⋯ a₃<:a₂ b₂<:b₃) = <∷-⋯ (<:-trans a₃<:a₂ a₂<:a₁) (<:-trans b₁<:b₂ b₂<:b₃) <∷-trans (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) (<∷-Π j₃<∷j₂ k₂<∷k₃ Πj₂k₂-kd) = <∷-Π (<∷-trans j₃<∷j₂ j₂<∷j₁) (<∷-trans (⇓-<∷ (wf-kd-inv (wf-∷₁ (<∷-ctx k₂<∷k₃))) j₃<∷j₂ k₁<∷k₂) k₂<∷k₃) Πj₁k₁-kd -- Transitivity of kind equality. ≅-trans : ∀ {n} {Γ : Ctx n} {j k l} → Γ ⊢ j ≅ k → Γ ⊢ k ≅ l → Γ ⊢ j ≅ l ≅-trans (<∷-antisym k₁<∷k₂ k₂<∷k₁) (<∷-antisym k₂<∷k₃ k₃<∷k₂) = <∷-antisym (<∷-trans k₁<∷k₂ k₂<∷k₃) (<∷-trans k₃<∷k₂ k₂<∷k₁) ---------------------------------------------------------------------- -- Well-formed equality lifted to substitutions module WfSubstitutionEquality where open Substitution hiding (subst) open TermSubst termSubst using (termLift) open ZipUnzipSimple simple simple open TypedSubstAppHelpers KindedSubstitution.termHelpers private module KL = TermLikeLemmas termLikeLemmasKind module AL = TermLikeLemmas termLikeLemmasTermAsc module S = SimpleExt simple module Z = SimpleExt zippedSimple -- Well-formed equal substitutions: pairs of substitutions that are -- point-wise equal. wfEqSub : TypedSubRel TermAsc Term Level.zero wfEqSub = record { typedRelation = record { _⊢_wf = _⊢_wf ; _⊢_∼_∈_ = _⊢_≃⊎≡_∈_ } ; typeExtension = TermCtx.weakenOps ; typeTermApplication = record { _/_ = λ a ρσ → a TermAsc/ (π₁ ρσ) } ; termSimple = simple } open TypedSubRel wfEqSub public using () renaming (_⊢/_∼_∈_ to _⊢/_≃_∈_) -- Simple substitutions of well-formed equal terms and types. wfEqWeakenOps : TypedRelWeakenOps wfEqSub wfEqWeakenOps = record { ∼∈-weaken = ≃⊎≡-weaken ; ∼∈-wf = ≃⊎≡-ctx ; /-wk = /-wk-π₁ ; /-weaken = λ {m} {n} {στ} a → /-weaken-π₁ {m} {n} {στ} a ; weaken-/-∷ = AL.weaken-/-∷ } where open ≡-Reasoning /-wk-π₁ : ∀ {n} {a : TermAsc n} → a TermAsc/ π₁ Z.wk ≡ weakenTermAsc a /-wk-π₁ {_} {a} = begin a TermAsc/ π₁ Z.wk ≡⟨ cong ((a TermAsc/_) ∘ proj₁) (sym wk-unzip) ⟩ a TermAsc/ wk ≡⟨ AL./-wk ⟩ weakenTermAsc a ∎ /-weaken-π₁ : ∀ {m n} {στ : Sub (Term ⊗ Term) m n} a → a TermAsc/ π₁ (Vec.map Z.weaken στ) ≡ a TermAsc/ π₁ στ TermAsc/ π₁ Z.wk /-weaken-π₁ {_} {_} {στ} a = begin a TermAsc/ π₁ (Vec.map Z.weaken στ) ≡˘⟨ cong ((a TermAsc/_) ∘ proj₁) (map-weaken-unzip στ) ⟩ a TermAsc/ Vec.map S.weaken (π₁ στ) ≡⟨ AL./-weaken a ⟩ a TermAsc/ π₁ στ TermAsc/ S.wk ≡⟨ cong ((a TermAsc/ π₁ στ TermAsc/_) ∘ proj₁) wk-unzip ⟩ a TermAsc/ π₁ στ TermAsc/ π₁ Z.wk ∎ wfEqSimple : TypedRelSimple wfEqSub wfEqSimple = record { typedRelWeakenOps = wfEqWeakenOps ; ∼∈-var = ≃⊎≡-var ; wf-wf = wf-ctx ; id-vanishes = id-vanishes-π₁ } where open TypedRelWeakenOps wfEqWeakenOps open ≡-Reasoning id-vanishes-π₁ : ∀ {n} (a : TermAsc n) → a TermAsc/ π₁ Z.id ≡ a id-vanishes-π₁ a = begin a TermAsc/ π₁ Z.id ≡⟨ cong ((a TermAsc/_) ∘ proj₁) (sym id-unzip) ⟩ a TermAsc/ id ≡⟨ AL.id-vanishes a ⟩ a ∎ open TypedRelSimple wfEqSimple public hiding (typedRelWeakenOps; ∼∈-var; ∼∈-weaken; ∼∈-wf; wf-wf) renaming (lookup to ≃-lookup) infixl 4 _⊢/_≃′_∈_ -- An inversion lemma for the generic term/type equality. ≃⊎≡-kd-inv : ∀ {n} {Γ : Ctx n} {a b k kd-k} → kd-k ≡ kd k → Γ ⊢ a ≃⊎≡ b ∈ kd-k → Γ ⊢ a ≃ b ∈ k ≃⊎≡-kd-inv refl (≃-tp a≃b∈k) = a≃b∈k -- A shorthand. -- -- TODO: explain why we use this particular representation of equal -- substitutions here. _⊢/_≃′_∈_ : ∀ {m n} → Ctx n → Sub Term m n → Sub Term m n → Ctx m → Set Δ ⊢/ σ ≃′ ρ ∈ Γ = Δ ⊢/ σ ∈ Γ × Δ ⊢/ ρ ∈ Γ × Δ ⊢/ σ ≃ ρ ∈ Γ × Δ ⊢/ ρ ≃ σ ∈ Γ -- Symmetry of substitution equality. ≃′-sym : ∀ {m n Δ Γ} {ρ σ : Sub Term m n} → Δ ⊢/ ρ ≃′ σ ∈ Γ → Δ ⊢/ σ ≃′ ρ ∈ Γ ≃′-sym (ρ∈Γ , σ∈Γ , ρ≃σ∈Γ , σ≃ρ∈Γ) = σ∈Γ , ρ∈Γ , σ≃ρ∈Γ , ρ≃σ∈Γ -- Lift a pair of equal substitutions over an additional type -- variable. ≃′-↑ : ∀ {m n Γ Δ} {ρ σ : Sub Term m n} {j k} → Δ ⊢ j kd → Δ ⊢ j ≅ k Kind/ ρ → Δ ⊢ j ≅ k Kind/ σ → Δ ⊢/ ρ ≃′ σ ∈ Γ → kd j ∷ Δ ⊢/ ρ ↑ ≃′ σ ↑ ∈ kd k ∷ Γ ≃′-↑ j-kd j≅k/ρ j≅k/σ (ρ∈Γ , σ∈Γ , ρ≃σ∈ , σ≃ρ∈) = ∈-/∷ (∈-tp z∈k/ρ) ρ∈Γ , ∈-/∷ (∈-tp z∈k/σ) σ∈Γ , ∼∈-/∷ (≃-tp (≃-refl z∈k/ρ′)) ρ≃σ∈ , ∼∈-/∷ (≃-tp (≃-refl z∈k/σ′)) σ≃ρ∈ where j-wf = wf-kd j-kd j∷Δ-ctx = j-wf ∷ kd-ctx j-kd z∈k/ρ = ∈-⇑ (∈-var zero j∷Δ-ctx refl) (<∷-weaken j-wf (≅⇒<∷ j≅k/ρ)) z∈k/σ = ∈-⇑ (∈-var zero j∷Δ-ctx refl) (<∷-weaken j-wf (≅⇒<∷ j≅k/σ)) z∈k/ρ′ = subst (_ ⊢Tp _ ∈_) (cong (weakenKind ∘ (_ Kind/_)) (sym (π₁-zip _ _))) z∈k/ρ z∈k/σ′ = subst (_ ⊢Tp _ ∈_) (cong (weakenKind ∘ (_ Kind/_)) (sym (π₁-zip _ _))) z∈k/σ -- Lemmas about equal substitutions (weak versions). mutual -- Equal substitutions map well-formed kinds to kind equations. kd-/≃ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {k ρ σ} → Γ ⊢ k kd → Δ ⊢/ ρ ≃′ σ ∈ Γ → Δ ⊢ k Kind/ ρ ≅ k Kind/ σ kd-/≃ (kd-⋯ a∈* b∈*) ρ≃σ∈Γ = ≅-⋯ (Tp∈-/≃ a∈* ρ≃σ∈Γ) (Tp∈-/≃ b∈* ρ≃σ∈Γ) kd-/≃ (kd-Π j-kd k-kd) ρ≃σ∈Γ = let ρ∈Γ , σ∈Γ , _ = ρ≃σ∈Γ j/ρ-kd = kd-/ j-kd ρ∈Γ j/σ-kd = kd-/ j-kd σ∈Γ j/ρ≅j/σ = kd-/≃ j-kd ρ≃σ∈Γ k/ρ≅k/σ = kd-/≃ k-kd (≃′-↑ j/σ-kd (≅-sym j/ρ≅j/σ) (≅-refl j/σ-kd) ρ≃σ∈Γ) k/σ≅k/ρ = kd-/≃ k-kd (≃′-↑ j/ρ-kd j/ρ≅j/σ (≅-refl j/ρ-kd) (≃′-sym ρ≃σ∈Γ)) Πjk/ρ-kd = kd-/ (kd-Π j-kd k-kd) ρ∈Γ Πjk/σ-kd = kd-/ (kd-Π j-kd k-kd) σ∈Γ in <∷-antisym (<∷-Π (≅⇒<∷ (≅-sym j/ρ≅j/σ)) (≅⇒<∷ k/ρ≅k/σ) Πjk/ρ-kd) (<∷-Π (≅⇒<∷ j/ρ≅j/σ) (≅⇒<∷ k/σ≅k/ρ) Πjk/σ-kd) -- Equal substitutions map well-kinded types to type equations. Tp∈-/≃ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a k ρ σ} → Γ ⊢Tp a ∈ k → Δ ⊢/ ρ ≃′ σ ∈ Γ → Δ ⊢ a / ρ ≃ a / σ ∈ k Kind/ ρ Tp∈-/≃ {ρ = ρ} {σ} (∈-var x Γ-ctx Γ[x]≡kd-k) (_ , _ , ρ≃σ∈Γ , _) = (≃⊎≡-kd-inv (cong (_TermAsc/ ρ) Γ[x]≡kd-k) (subst (_ ⊢ _ ≃⊎≡ _ ∈_) (cong (_ TermAsc/_) (π₁-zip ρ σ)) (≃-lookup ρ≃σ∈Γ x))) Tp∈-/≃ (∈-⊥-f Γ-ctx) (ρ∈Γ , _) = ≃-refl (∈-⊥-f (/∈-wf ρ∈Γ)) Tp∈-/≃ (∈-⊤-f Γ-ctx) (ρ∈Γ , _) = ≃-refl (∈-⊤-f (/∈-wf ρ∈Γ)) Tp∈-/≃ (∈-∀-f k-kd a∈*) ρ≃σ∈Γ = let ρ∈Γ , σ∈Γ , _ = ρ≃σ∈Γ k/ρ-kd = kd-/ k-kd ρ∈Γ k/σ-kd = kd-/ k-kd σ∈Γ k/ρ≅k/σ = kd-/≃ k-kd ρ≃σ∈Γ a/ρ≃a/σ∈* = Tp∈-/≃ a∈* (≃′-↑ k/σ-kd (≅-sym k/ρ≅k/σ) (≅-refl k/σ-kd) ρ≃σ∈Γ) a/σ≃a/ρ∈* = Tp∈-/≃ a∈* (≃′-↑ k/ρ-kd k/ρ≅k/σ (≅-refl k/ρ-kd) (≃′-sym ρ≃σ∈Γ)) ∀ka/ρ∈* = Tp∈-/ (∈-∀-f k-kd a∈*) ρ∈Γ ∀ka/σ∈* = Tp∈-/ (∈-∀-f k-kd a∈*) σ∈Γ in <:-antisym (<:-∀ (≅⇒<∷ (≅-sym k/ρ≅k/σ)) (≃⇒<: a/ρ≃a/σ∈*) ∀ka/ρ∈*) (<:-∀ (≅⇒<∷ k/ρ≅k/σ) (≃⇒<: a/σ≃a/ρ∈*) ∀ka/σ∈*) Tp∈-/≃ (∈-→-f a∈* b∈*) ρ≃σ∈Γ = ≃-→ (Tp∈-/≃ a∈* ρ≃σ∈Γ) (Tp∈-/≃ b∈* ρ≃σ∈Γ) Tp∈-/≃ (∈-Π-i j-kd a∈k k-kd) ρ≃σ∈Γ = let ρ∈Γ , σ∈Γ , _ = ρ≃σ∈Γ j/ρ-kd = kd-/ j-kd ρ∈Γ j/σ-kd = kd-/ j-kd σ∈Γ j/ρ≅j/σ = kd-/≃ j-kd ρ≃σ∈Γ ρ↑∈j∷Γ = ∈-↑ (wf-kd j/ρ-kd) ρ∈Γ σ↑∈j∷Γ = ∈-↑ (wf-kd j/σ-kd) σ∈Γ ρ↑≃σ↑∈j∷Γ = ≃′-↑ j/ρ-kd (≅-refl j/ρ-kd) j/ρ≅j/σ ρ≃σ∈Γ a/ρ∈k/ρ = Tp∈-/ a∈k ρ↑∈j∷Γ a/σ∈k/σ = Tp∈-/ a∈k σ↑∈j∷Γ a/ρ≃a/σ∈k/ρ = Tp∈-/≃ a∈k ρ↑≃σ↑∈j∷Γ k/ρ-kd = kd-/ k-kd ρ↑∈j∷Γ k/σ-kd = kd-/ k-kd σ↑∈j∷Γ k/ρ≅k/σ = kd-/≃ k-kd ρ↑≃σ↑∈j∷Γ Λja/ρ∈Πjk/ρ = ∈-Π-i j/ρ-kd a/ρ∈k/ρ k/ρ-kd Πjk/σ<∷Πjk/ρ = <∷-Π (≅⇒<∷ j/ρ≅j/σ) (≅⇒<∷ (≅-sym k/ρ≅k/σ)) (kd-Π j/σ-kd k/σ-kd) Λja/σ∈Πjk/ρ = ∈-⇑ (∈-Π-i j/σ-kd a/σ∈k/σ k/σ-kd) Πjk/σ<∷Πjk/ρ in ≃-λ a/ρ≃a/σ∈k/ρ Λja/ρ∈Πjk/ρ Λja/σ∈Πjk/ρ Tp∈-/≃ (∈-Π-e {k = k} a∈Πjk b∈j k-kd k[b]-kd) ρ≃σ∈Γ = let k[b]/ρ≡k/ρ[b/ρ] = Kind/-sub-↑ k _ _ k[b]/σ≡k/σ[b/σ] = Kind/-sub-↑ k _ _ ρ∈Γ , σ∈Γ , _ = ρ≃σ∈Γ j-wf = wf-∷₁ (kd-ctx k-kd) j-kd = wf-kd-inv j-wf j/σ≅j/ρ = kd-/≃-≅ k-kd (≃′-sym ρ≃σ∈Γ) j/σ-kd = kd-/ j-kd σ∈Γ ρ↑≃σ↑∈j∷Γ = ≃′-↑ j/σ-kd j/σ≅j/ρ (≅-refl j/σ-kd) ρ≃σ∈Γ ρ↑∈j∷Γ = (∈-↑ (wf-/ j-wf ρ∈Γ) ρ∈Γ) a/ρ≃a/σ∈Πjk/ρ = Tp∈-/≃ a∈Πjk ρ≃σ∈Γ b/ρ≃b/σ∈j/ρ = Tp∈-/≃ b∈j ρ≃σ∈Γ k[b]/ρ≅k[b]/σ = kd-/≃ k[b]-kd ρ≃σ∈Γ k/ρ≅k/σ = kd-/≃ k-kd ρ↑≃σ↑∈j∷Γ b/ρ∈j/ρ = Tp∈-/ b∈j ρ∈Γ b/σ∈j/σ = Tp∈-/ b∈j σ∈Γ b/σ∈j/ρ = ∈-⇑ b/σ∈j/σ (≅⇒<∷ j/σ≅j/ρ) k/ρ-kd = kd-/ k-kd ρ↑∈j∷Γ k/ρ[b/ρ]-kd = subst (_ ⊢_kd) k[b]/ρ≡k/ρ[b/ρ] (kd-/ k[b]-kd ρ∈Γ) k/ρ[b/σ]-kd = kd-[] k/ρ-kd (∈-tp b/σ∈j/ρ) k/ρ[b/σ]≅k[b]/σ = subst (_ ⊢ (k Kind/ _) Kind[ _ ] ≅_) (sym k[b]/σ≡k/σ[b/σ]) (≅-[] k/ρ≅k/σ (∈-tp b/σ∈j/σ)) k[b]/σ≅k/ρ[b/ρ] = subst (_ ⊢ _ ≅_) k[b]/ρ≡k/ρ[b/ρ] (≅-sym k[b]/ρ≅k[b]/σ) k/ρ[b/σ]≅k/ρ[b/ρ] = ≅-trans k/ρ[b/σ]≅k[b]/σ k[b]/σ≅k/ρ[b/ρ] in (subst (_ ⊢ _ ≃ _ ∈_) (sym k[b]/ρ≡k/ρ[b/ρ]) (<:-antisym (<:-· (≃⇒<: a/ρ≃a/σ∈Πjk/ρ) b/ρ≃b/σ∈j/ρ b/ρ∈j/ρ k/ρ-kd k/ρ[b/ρ]-kd) (<:-⇑ (<:-· (≃⇒<: (≃-sym a/ρ≃a/σ∈Πjk/ρ)) (≃-sym b/ρ≃b/σ∈j/ρ) b/σ∈j/ρ k/ρ-kd k/ρ[b/σ]-kd) (≅⇒<∷ k/ρ[b/σ]≅k/ρ[b/ρ])))) Tp∈-/≃ (∈-s-i a∈b⋯d) ρ≃σ∈Γ = let ρ∈Γ , σ∈Γ , _ = ρ≃σ∈Γ a/ρ∈* = Tp∈-⋯-* (Tp∈-/ a∈b⋯d ρ∈Γ) a/σ∈* = Tp∈-⋯-* (Tp∈-/ a∈b⋯d σ∈Γ) a/ρ≃a/σ∈b/ρ⋯d/ρ = Tp∈-/≃ a∈b⋯d ρ≃σ∈Γ a/ρ<:a/σ∈a/ρ⋯a/σ = <:-⋯-i (≃⇒<: a/ρ≃a/σ∈b/ρ⋯d/ρ) a/σ<:a/ρ∈a/σ⋯a/ρ = <:-⋯-i (≃⇒<: (≃-sym a/ρ≃a/σ∈b/ρ⋯d/ρ)) a/ρ<:a/σ∈* = <:-⇑ a/ρ<:a/σ∈a/ρ⋯a/σ (<∷-⋯ (<:-⊥ a/ρ∈*) (<:-⊤ a/σ∈*)) a/σ<:a/ρ∈* = <:-⇑ a/σ<:a/ρ∈a/σ⋯a/ρ (<∷-⋯ (<:-⊥ a/σ∈*) (<:-⊤ a/ρ∈*)) a/ρ<:a/σ∈a/ρ⋯a/ρ = <:-⇑ a/ρ<:a/σ∈a/ρ⋯a/σ (<∷-⋯ (<:-refl a/ρ∈*) a/σ<:a/ρ∈*) a/σ<:a/ρ∈a/ρ⋯a/ρ = <:-⇑ a/σ<:a/ρ∈a/σ⋯a/ρ (<∷-⋯ a/ρ<:a/σ∈* (<:-refl a/ρ∈*)) in <:-antisym a/ρ<:a/σ∈a/ρ⋯a/ρ a/σ<:a/ρ∈a/ρ⋯a/ρ Tp∈-/≃ (∈-⇑ a∈j j<∷k) ρ≃σ∈Γ = ≃-⇑ (Tp∈-/≃ a∈j ρ≃σ∈Γ) (<∷-/ j<∷k (proj₁ ρ≃σ∈Γ)) -- Helpers (to satisfy the termination checker). kd-/≃-≅ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {j k ρ σ} → kd j ∷ Γ ⊢ k kd → Δ ⊢/ ρ ≃′ σ ∈ Γ → Δ ⊢ j Kind/ ρ ≅ j Kind/ σ kd-/≃-≅ (kd-⋯ a∈* _) ρ≃σ∈Γ = Tp∈-/≃-≅ a∈* ρ≃σ∈Γ kd-/≃-≅ (kd-Π j-kd _) ρ≃σ∈Γ = kd-/≃-≅ j-kd ρ≃σ∈Γ Tp∈-/≃-≅ : ∀ {m n} {Γ : Ctx m} {Δ : Ctx n} {a j k ρ σ} → kd j ∷ Γ ⊢Tp a ∈ k → Δ ⊢/ ρ ≃′ σ ∈ Γ → Δ ⊢ j Kind/ ρ ≅ j Kind/ σ Tp∈-/≃-≅ (∈-var x (wf-kd k-kd ∷ Γ-ctx) _) ρ≃σ∈Γ = kd-/≃ k-kd ρ≃σ∈Γ Tp∈-/≃-≅ (∈-⊥-f (wf-kd k-kd ∷ Γ-ctx)) ρ≃σ∈Γ = kd-/≃ k-kd ρ≃σ∈Γ Tp∈-/≃-≅ (∈-⊤-f (wf-kd k-kd ∷ Γ-ctx)) ρ≃σ∈Γ = kd-/≃ k-kd ρ≃σ∈Γ Tp∈-/≃-≅ (∈-∀-f k-kd _) ρ≃σ∈Γ = kd-/≃-≅ k-kd ρ≃σ∈Γ Tp∈-/≃-≅ (∈-→-f a∈* _) ρ≃σ∈Γ = Tp∈-/≃-≅ a∈* ρ≃σ∈Γ Tp∈-/≃-≅ (∈-Π-i j-kd _ _) ρ≃σ∈Γ = kd-/≃-≅ j-kd ρ≃σ∈Γ Tp∈-/≃-≅ (∈-Π-e a∈Πjk _ _ _) ρ≃σ∈Γ = Tp∈-/≃-≅ a∈Πjk ρ≃σ∈Γ Tp∈-/≃-≅ (∈-s-i a∈b⋯c) ρ≃σ∈Γ = Tp∈-/≃-≅ a∈b⋯c ρ≃σ∈Γ Tp∈-/≃-≅ (∈-⇑ a∈k _) ρ≃σ∈Γ = Tp∈-/≃-≅ a∈k ρ≃σ∈Γ -- Functionality of kind formation and kinding. -- Equal single-variable substitutions map well-formed kinds to kind -- equations (weak version). kd-[≃′] : ∀ {n} {Γ : Ctx n} {a b j k} → kd j ∷ Γ ⊢ k kd → Γ ⊢Tp a ∈ j → Γ ⊢Tp b ∈ j → Γ ⊢ a ≃ b ∈ j → Γ ⊢ k Kind[ a ] ≅ k Kind[ b ] kd-[≃′] k-kd a∈j b∈j a≃b∈j = kd-/≃ k-kd (∈-sub (∈-tp a∈j) , ∈-sub (∈-tp b∈j) , ∼∈-sub (≃-tp a≃b∈j) , ∼∈-sub (≃-tp (≃-sym (a≃b∈j)))) -- Equal single-variable substitutions map well-kinded types to type -- equations (weak version). Tp∈-[≃′] : ∀ {n} {Γ : Ctx n} {a b c j k} → kd j ∷ Γ ⊢Tp a ∈ k → Γ ⊢Tp b ∈ j → Γ ⊢Tp c ∈ j → Γ ⊢ b ≃ c ∈ j → Γ ⊢ a [ b ] ≃ a [ c ] ∈ k Kind[ b ] Tp∈-[≃′] a∈k b∈j c∈j b≃c∈j = Tp∈-/≃ a∈k (∈-sub (∈-tp b∈j) , ∈-sub (∈-tp c∈j) , ∼∈-sub (≃-tp b≃c∈j) , ∼∈-sub (≃-tp (≃-sym (b≃c∈j))))
Mockingbird/Problems/Chapter11.agda
splintah/combinatory-logic
1
8292
open import Mockingbird.Forest using (Forest) -- Birds Galore module Mockingbird.Problems.Chapter11 {b ℓ} (forest : Forest {b} {ℓ}) where open import Data.Product using (_×_; _,_; proj₁; proj₂; ∃-syntax) open import Data.Unit using (⊤; tt) open import Function using (_$_) import Mockingbird.Problems.Chapter09 forest as Chapter₉ open Forest forest module Parentheses where private variable u v w x y z A A₁ A₂ B : Bird -- A variant of _∙_ that is not parsed as a right-associative operator, to -- make sure that the parentheses in the right-hand side of the exercises -- below are fully restored. infix 6 _∙′_ _∙′_ = _∙_ exercise-a : x ∙ y ∙ (z ∙ w ∙ y) ∙ v ≈ ((x ∙′ y) ∙′ ((z ∙′ w) ∙′ y)) ∙′ v exercise-a = refl exercise-b : (x ∙ y ∙ z) ∙ (w ∙ v ∙ x) ≈ ((x ∙′ y) ∙′ z) ∙′ ((w ∙′ v) ∙′ x) exercise-b = refl exercise-c : x ∙ y ∙ (z ∙ w ∙ v) ∙ (x ∙ z) ≈ ((x ∙′ y) ∙′ ((z ∙′ w) ∙′ v)) ∙′ (x ∙′ z) exercise-c = refl exercise-d : x ∙ y ∙ (z ∙ w ∙ v) ∙ x ∙ z ≈ (((x ∙′ y) ∙′ ((z ∙′ w) ∙′ v)) ∙′ x) ∙′ z exercise-d = refl exercise-e : x ∙ (y ∙ (z ∙ w ∙ v)) ∙ x ∙ z ≈ ((x ∙′ (y ∙′ ((z ∙′ w) ∙′ v))) ∙′ x) ∙′ z exercise-e = refl exercise-f : x ∙ y ∙ z ∙ (A ∙ B) ≈ (x ∙ y ∙ z) ∙ (A ∙ B) exercise-f = refl exercise-g : A₁ ≈ A₂ → B ∙ A₁ ≈ B ∙ A₂ × A₁ ∙ B ≈ A₂ ∙ B exercise-g A₁≈A₂ = (congˡ A₁≈A₂ , congʳ A₁≈A₂) exercise-h : x ∙ y ≈ z → x ∙ y ∙ w ≈ z ∙ w exercise-h {x} {y} {z} {w} xy≈z = begin x ∙ y ∙ w ≈⟨⟩ (x ∙′ y) ∙′ w ≈⟨ congʳ xy≈z ⟩ z ∙ w ∎ -- The other part of exercise h, wxy ≈ wz, does not follow in general. open import Mockingbird.Forest.Birds forest problem₁ : ⦃ _ : HasBluebird ⦄ → HasComposition problem₁ = record { _∘_ = λ C D → B ∙ C ∙ D ; isComposition = λ C D x → begin B ∙ C ∙ D ∙ x ≈⟨ isBluebird C D x ⟩ C ∙ (D ∙ x) ∎ } private instance hasComposition : ⦃ HasBluebird ⦄ → HasComposition hasComposition = problem₁ module _ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ where problem₂ : ∀ x → ∃[ y ] x IsFondOf y problem₂ x = let (_ , isFond) = Chapter₉.problem₁ x shorten : M ∙ (B ∙ x ∙ M) ≈ B ∙ x ∙ M ∙ (B ∙ x ∙ M) shorten = isMockingbird (B ∙ x ∙ M) in (M ∙ (B ∙ x ∙ M) , trans (congˡ shorten) (trans isFond (sym shorten))) problem₃ : ∃[ x ] IsEgocentric x problem₃ = let (_ , isEgocentric) = Chapter₉.problem₂ in (B ∙ M ∙ M ∙ (B ∙ M ∙ M) , isEgocentric) module _ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasMockingbird ⦄ ⦃ _ : HasKestrel ⦄ where problem₄ : ∃[ x ] IsHopelesslyEgocentric x problem₄ = let (_ , isHopelesslyEgocentric) = Chapter₉.problem₉ in (B ∙ K ∙ M ∙ (B ∙ K ∙ M) , isHopelesslyEgocentric) module _ ⦃ _ : HasBluebird ⦄ where problem₅ : HasDove problem₅ = record { D = B ∙ B ; isDove = λ x y z w → begin B ∙ B ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ isBluebird B x y ⟩ B ∙ (x ∙ y) ∙ z ∙ w ≈⟨ isBluebird (x ∙ y) z w ⟩ x ∙ y ∙ (z ∙ w) ∎ } private instance hasDove = problem₅ problem₆ : HasBlackbird problem₆ = record { B₁ = B ∙ B ∙ B ; isBlackbird = λ x y z w → begin B ∙ B ∙ B ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ congʳ (isBluebird B B x) ⟩ B ∙ (B ∙ x) ∙ y ∙ z ∙ w ≈⟨ congʳ (isBluebird (B ∙ x) y z) ⟩ B ∙ x ∙ (y ∙ z) ∙ w ≈⟨ isBluebird x (y ∙ z) w ⟩ x ∙ (y ∙ z ∙ w) ∎ } private instance hasBlackbird = problem₆ problem₇ : HasEagle problem₇ = record { E = B ∙ B₁ ; isEagle = λ x y z w v → begin B ∙ B₁ ∙ x ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird B₁ x y ⟩ B₁ ∙ (x ∙ y) ∙ z ∙ w ∙ v ≈⟨ isBlackbird (x ∙ y) z w v ⟩ x ∙ y ∙ (z ∙ w ∙ v) ∎ } private instance hasEagle = problem₇ problem₈ : HasBunting problem₈ = record { B₂ = B ∙ B ∙ B₁ ; isBunting = λ x y z w v → begin B ∙ B ∙ B₁ ∙ x ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ congʳ $ congʳ $ isBluebird B B₁ x ⟩ B ∙ (B₁ ∙ x) ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ isBluebird (B₁ ∙ x) y z ⟩ B₁ ∙ x ∙ (y ∙ z) ∙ w ∙ v ≈⟨ isBlackbird x (y ∙ z) w v ⟩ x ∙ (y ∙ z ∙ w ∙ v) ∎ } private instance hasBunting = problem₈ problem₉ : HasDickcissel problem₉ = record { D₁ = B ∙ D ; isDickcissel = λ x y z w v → begin B ∙ D ∙ x ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird D x y ⟩ D ∙ (x ∙ y) ∙ z ∙ w ∙ v ≈⟨ isDove (x ∙ y) z w v ⟩ x ∙ y ∙ z ∙ (w ∙ v) ∎ } private instance hasDickcissel = problem₉ problem₁₀ : HasBecard problem₁₀ = record { B₃ = B ∙ D ∙ B ; isBecard = λ x y z w → begin B ∙ D ∙ B ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird D B x ⟩ D ∙ (B ∙ x) ∙ y ∙ z ∙ w ≈⟨ isDove (B ∙ x) y z w ⟩ B ∙ x ∙ y ∙ (z ∙ w) ≈⟨ isBluebird x y (z ∙ w) ⟩ x ∙ (y ∙ (z ∙ w)) ∎ } private instance hasBecard = problem₁₀ problem₁₁ : HasDovekie problem₁₁ = record { D₂ = D ∙ D ; isDovekie = λ x y z w v → begin D ∙ D ∙ x ∙ y ∙ z ∙ w ∙ v ≈⟨ congʳ $ congʳ $ isDove D x y z ⟩ D ∙ x ∙ (y ∙ z) ∙ w ∙ v ≈⟨ isDove x (y ∙ z) w v ⟩ x ∙ (y ∙ z) ∙ (w ∙ v) ∎ } private instance hasDovekie = problem₁₁ problem₁₂ : HasBaldEagle problem₁₂ = record { Ê = E ∙ E ; isBaldEagle = λ x y₁ y₂ y₃ z₁ z₂ z₃ → begin E ∙ E ∙ x ∙ y₁ ∙ y₂ ∙ y₃ ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ congʳ $ congʳ $ congʳ $ isEagle E x y₁ y₂ y₃ ⟩ E ∙ x ∙ (y₁ ∙ y₂ ∙ y₃) ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ isEagle x (y₁ ∙ y₂ ∙ y₃) z₁ z₂ z₃ ⟩ x ∙ (y₁ ∙ y₂ ∙ y₃) ∙ (z₁ ∙ z₂ ∙ z₃) ∎ } private instance hasBaldEagle = problem₁₂ problem₁₄ : ⦃ _ : HasWarbler ⦄ ⦃ _ : HasIdentity ⦄ → HasMockingbird problem₁₄ = record { M = W ∙ I ; isMockingbird = λ x → begin W ∙ I ∙ x ≈⟨ isWarbler I x ⟩ I ∙ x ∙ x ≈⟨ congʳ $ isIdentity x ⟩ x ∙ x ∎ } problem₁₅ : ⦃ _ : HasWarbler ⦄ ⦃ _ : HasKestrel ⦄ → HasIdentity problem₁₅ = record { I = W ∙ K ; isIdentity = λ x → begin W ∙ K ∙ x ≈⟨ isWarbler K x ⟩ K ∙ x ∙ x ≈⟨ isKestrel x x ⟩ x ∎ } problem₁₃ : ⦃ _ : HasWarbler ⦄ ⦃ _ : HasKestrel ⦄ → HasMockingbird problem₁₃ = problem₁₄ where instance _ = problem₁₅ problem₁₆ : ⦃ _ : HasCardinal ⦄ ⦃ _ : HasKestrel ⦄ → HasIdentity problem₁₆ = record { I = C ∙ K ∙ K ; isIdentity = λ x → begin C ∙ K ∙ K ∙ x ≈⟨ isCardinal K K x ⟩ K ∙ x ∙ K ≈⟨ isKestrel x K ⟩ x ∎ } problem₁₇ : ⦃ _ : HasCardinal ⦄ ⦃ _ : HasIdentity ⦄ → HasThrush problem₁₇ = record { T = C ∙ I ; isThrush = λ x y → begin C ∙ I ∙ x ∙ y ≈⟨ isCardinal I x y ⟩ I ∙ y ∙ x ≈⟨ congʳ $ isIdentity y ⟩ y ∙ x ∎ } problem₁₈ : ⦃ _ : HasThrush ⦄ → (∀ x → IsNormal x) → ∃[ A ] (∀ x → Commute A x) problem₁₈ isNormal = let (A , isFond) = isNormal T commute : ∀ x → Commute A x commute x = begin A ∙ x ≈˘⟨ (congʳ $ isFond) ⟩ T ∙ A ∙ x ≈⟨ isThrush A x ⟩ x ∙ A ∎ in (A , commute) problem₁₉ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ ⦃ _ : HasMockingbird ⦄ → ∃[ x ] (∀ y → Commute x y) problem₁₉ = problem₁₈ problem₂ problem₂₀ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → HasRobin problem₂₀ = record { R = B ∙ B ∙ T ; isRobin = λ x y z → begin B ∙ B ∙ T ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isBluebird B T x ⟩ B ∙ (T ∙ x) ∙ y ∙ z ≈⟨ isBluebird (T ∙ x) y z ⟩ T ∙ x ∙ (y ∙ z) ≈⟨ isThrush x (y ∙ z) ⟩ (y ∙ z) ∙ x ≈⟨⟩ y ∙ z ∙ x ∎ } problem₂₁ : ⦃ _ : HasRobin ⦄ → HasCardinal problem₂₁ = record { C = R ∙ R ∙ R ; isCardinal = λ x y z → begin R ∙ R ∙ R ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isRobin R R x ⟩ R ∙ x ∙ R ∙ y ∙ z ≈⟨ congʳ $ isRobin x R y ⟩ R ∙ y ∙ x ∙ z ≈⟨ isRobin y x z ⟩ x ∙ z ∙ y ∎ } problem₂₁′ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → HasCardinal problem₂₁′ = problem₂₁ ⦃ problem₂₀ ⦄ problem₂₁-bonus : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → HasCardinal problem₂₁-bonus = record { C = B ∙ (T ∙ (B ∙ B ∙ T)) ∙ (B ∙ B ∙ T) ; isCardinal = λ x y z → begin B ∙ (T ∙ (B ∙ B ∙ T)) ∙ (B ∙ B ∙ T) ∙ x ∙ y ∙ z ≈˘⟨ congʳ $ congʳ $ congʳ $ congʳ $ isBluebird B T (B ∙ B ∙ T) ⟩ B ∙ B ∙ T ∙ (B ∙ B ∙ T) ∙ (B ∙ B ∙ T) ∙ x ∙ y ∙ z ≈⟨ isCardinal x y z ⟩ x ∙ z ∙ y ∎ } where instance hasCardinal = problem₂₁′ module _ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ where private instance hasRobin = problem₂₀ instance hasCardinal = problem₂₁′ problem₂₂-a : ∀ x → C ∙ x ≈ R ∙ x ∙ R problem₂₂-a x = begin C ∙ x ≈⟨⟩ R ∙ R ∙ R ∙ x ≈⟨ isRobin R R x ⟩ R ∙ x ∙ R ∎ problem₂₂-b : ∀ x → C ∙ x ≈ B ∙ (T ∙ x) ∙ R problem₂₂-b x = begin C ∙ x ≈⟨ problem₂₂-a x ⟩ R ∙ x ∙ R ≈⟨⟩ B ∙ B ∙ T ∙ x ∙ R ≈⟨ congʳ $ isBluebird B T x ⟩ B ∙ (T ∙ x) ∙ R ∎ problem₂₃ : ⦃ _ : HasCardinal ⦄ → HasRobin problem₂₃ = record { R = C ∙ C ; isRobin = λ x y z → begin C ∙ C ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal C x y ⟩ C ∙ y ∙ x ∙ z ≈⟨ isCardinal y x z ⟩ y ∙ z ∙ x ∎ } problem₂₄ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasRobin ⦄ ⦃ _ : HasCardinal ⦄ → HasFinch problem₂₄ = record { F = B ∙ C ∙ R ; isFinch = λ x y z → begin B ∙ C ∙ R ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isBluebird C R x ⟩ C ∙ (R ∙ x) ∙ y ∙ z ≈⟨ isCardinal (R ∙ x) y z ⟩ R ∙ x ∙ z ∙ y ≈⟨ isRobin x z y ⟩ z ∙ y ∙ x ∎ } problem₂₅ : ⦃ _ : HasThrush ⦄ ⦃ _ : HasEagle ⦄ → HasFinch problem₂₅ = record { F = E ∙ T ∙ T ∙ E ∙ T ; isFinch = λ x y z → begin E ∙ T ∙ T ∙ E ∙ T ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isEagle T T E T x ⟩ T ∙ T ∙ (E ∙ T ∙ x) ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isThrush T (E ∙ T ∙ x) ⟩ E ∙ T ∙ x ∙ T ∙ y ∙ z ≈⟨ isEagle T x T y z ⟩ T ∙ x ∙ (T ∙ y ∙ z) ≈⟨ isThrush x (T ∙ y ∙ z) ⟩ T ∙ y ∙ z ∙ x ≈⟨ congʳ $ isThrush y z ⟩ z ∙ y ∙ x ∎ } problem₂₆ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → HasFinch problem₂₆ = record { F = short ; isFinch = shortIsFinch } where instance hasRobin = problem₂₀ hasCardinal = problem₂₁-bonus hasEagle = problem₇ long : Bird long = (B ∙ (B ∙ (T ∙ (B ∙ B ∙ T)) ∙ (B ∙ B ∙ T)) ∙ (B ∙ B ∙ T)) longIsFinch : IsFinch long longIsFinch = HasFinch.isFinch problem₂₄ short : Bird short = B ∙ (T ∙ T) ∙ (B ∙ (B ∙ B ∙ B) ∙ T) short≈ETTET : short ≈ E ∙ T ∙ T ∙ E ∙ T short≈ETTET = begin short ≈⟨⟩ B ∙ (T ∙ T) ∙ (B ∙ (B ∙ B ∙ B) ∙ T) ≈˘⟨ isBluebird (B ∙ (T ∙ T)) (B ∙ (B ∙ B ∙ B)) T ⟩ B ∙ (B ∙ (T ∙ T)) ∙ (B ∙ (B ∙ B ∙ B)) ∙ T ≈˘⟨ congʳ $ congʳ $ isBluebird B B (T ∙ T) ⟩ B ∙ B ∙ B ∙ (T ∙ T) ∙ (B ∙ (B ∙ B ∙ B)) ∙ T ≈˘⟨ congʳ $ congʳ $ isBluebird (B ∙ B ∙ B) T T ⟩ B ∙ (B ∙ B ∙ B) ∙ T ∙ T ∙ (B ∙ (B ∙ B ∙ B)) ∙ T ≈⟨⟩ E ∙ T ∙ T ∙ E ∙ T ∎ shortIsFinch : IsFinch short shortIsFinch x y z = begin short ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ congʳ $ short≈ETTET ⟩ E ∙ T ∙ T ∙ E ∙ T ∙ x ∙ y ∙ z ≈⟨ HasFinch.isFinch problem₂₅ x y z ⟩ z ∙ y ∙ x ∎ problem₂₇ : ⦃ _ : HasCardinal ⦄ ⦃ _ : HasFinch ⦄ → HasVireo problem₂₇ = record { V = C ∙ F ; isVireo = λ x y z → begin C ∙ F ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal F x y ⟩ F ∙ y ∙ x ∙ z ≈⟨ isFinch y x z ⟩ z ∙ x ∙ y ∎ } problem₂₈ : ⦃ _ : HasFinch ⦄ ⦃ _ : HasRobin ⦄ → HasVireo problem₂₈ = record { V = R ∙ F ∙ R ; isVireo = λ x y z → begin R ∙ F ∙ R ∙ x ∙ y ∙ z ≈˘⟨ congʳ $ congʳ $ congʳ $ isRobin R R F ⟩ R ∙ R ∙ R ∙ F ∙ x ∙ y ∙ z ≈⟨ congʳ $ HasCardinal.isCardinal problem₂₁ F x y ⟩ F ∙ y ∙ x ∙ z ≈⟨ isFinch y x z ⟩ z ∙ x ∙ y ∎ } problem₂₉ : ⦃ _ : HasCardinal ⦄ ⦃ _ : HasVireo ⦄ → HasFinch problem₂₉ = record { F = C ∙ V ; isFinch = λ x y z → begin C ∙ V ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal V x y ⟩ V ∙ y ∙ x ∙ z ≈⟨ isVireo y x z ⟩ z ∙ y ∙ x ∎ } problem₃₀ : ⦃ _ : HasRobin ⦄ ⦃ _ : HasKestrel ⦄ → HasIdentity problem₃₀ = problem₁₆ where instance hasCardinal = problem₂₁ module _ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasCardinal ⦄ where problem₃₁ : HasCardinalOnceRemoved problem₃₁ = record { C* = B ∙ C ; isCardinalOnceRemoved = λ x y z w → begin B ∙ C ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ isBluebird C x y ⟩ C ∙ (x ∙ y) ∙ z ∙ w ≈⟨ isCardinal (x ∙ y) z w ⟩ x ∙ y ∙ w ∙ z ∎ } private instance hasCardinalOnceRemoved = problem₃₁ problem₃₂ : HasRobinOnceRemoved problem₃₂ = record { R* = C* ∙ C* ; isRobinOnceRemoved = λ x y z w → begin C* ∙ C* ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ isCardinalOnceRemoved C* x y z ⟩ C* ∙ x ∙ z ∙ y ∙ w ≈⟨ isCardinalOnceRemoved x z y w ⟩ x ∙ z ∙ w ∙ y ∎ } private instance hasRobinOnceRemoved = problem₃₂ problem₃₃ : HasFinchOnceRemoved problem₃₃ = record { F* = B ∙ C* ∙ R* ; isFinchOnceRemoved = λ x y z w → begin B ∙ C* ∙ R* ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird C* R* x ⟩ C* ∙ (R* ∙ x) ∙ y ∙ z ∙ w ≈⟨ isCardinalOnceRemoved (R* ∙ x) y z w ⟩ R* ∙ x ∙ y ∙ w ∙ z ≈⟨ isRobinOnceRemoved x y w z ⟩ x ∙ w ∙ z ∙ y ∎ } private instance hasFinchOnceRemoved = problem₃₃ problem₃₄ : HasVireoOnceRemoved problem₃₄ = record { V* = C* ∙ F* ; isVireoOnceRemoved = λ x y z w → begin C* ∙ F* ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ isCardinalOnceRemoved F* x y z ⟩ F* ∙ x ∙ z ∙ y ∙ w ≈⟨ isFinchOnceRemoved x z y w ⟩ x ∙ w ∙ y ∙ z ∎ } private instance hasVireoOnceRemoved = problem₃₄ problem₃₅-C** : HasCardinalTwiceRemoved problem₃₅-C** = record { C** = B ∙ C* ; isCardinalTwiceRemoved = λ x y z₁ z₂ z₃ → begin B ∙ C* ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird C* x y ⟩ C* ∙ (x ∙ y) ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ isCardinalOnceRemoved (x ∙ y) z₁ z₂ z₃ ⟩ x ∙ y ∙ z₁ ∙ z₃ ∙ z₂ ∎ } problem₃₅-R** : HasRobinTwiceRemoved problem₃₅-R** = record { R** = B ∙ R* ; isRobinTwiceRemoved = λ x y z₁ z₂ z₃ → begin B ∙ R* ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird R* x y ⟩ R* ∙ (x ∙ y) ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ isRobinOnceRemoved (x ∙ y) z₁ z₂ z₃ ⟩ x ∙ y ∙ z₂ ∙ z₃ ∙ z₁ ∎ } problem₃₅-F** : HasFinchTwiceRemoved problem₃₅-F** = record { F** = B ∙ F* ; isFinchTwiceRemoved = λ x y z₁ z₂ z₃ → begin B ∙ F* ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird F* x y ⟩ F* ∙ (x ∙ y) ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ isFinchOnceRemoved (x ∙ y) z₁ z₂ z₃ ⟩ x ∙ y ∙ z₃ ∙ z₂ ∙ z₁ ∎ } problem₃₅-V** : HasVireoTwiceRemoved problem₃₅-V** = record { V** = B ∙ V* ; isVireoTwiceRemoved = λ x y z₁ z₂ z₃ → begin B ∙ V* ∙ x ∙ y ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ congʳ $ congʳ $ congʳ $ isBluebird V* x y ⟩ V* ∙ (x ∙ y) ∙ z₁ ∙ z₂ ∙ z₃ ≈⟨ isVireoOnceRemoved (x ∙ y) z₁ z₂ z₃ ⟩ x ∙ y ∙ z₃ ∙ z₁ ∙ z₂ ∎ } problem₃₆ : ⦃ _ : HasCardinalOnceRemoved ⦄ ⦃ _ : HasThrush ⦄ → HasVireo problem₃₆ = record { V = C* ∙ T ; isVireo = λ x y z → begin C* ∙ T ∙ x ∙ y ∙ z ≈⟨ isCardinalOnceRemoved T x y z ⟩ T ∙ x ∙ z ∙ y ≈⟨ congʳ $ isThrush x z ⟩ z ∙ x ∙ y ∎ } problem₃₇′ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasCardinal ⦄ → HasQueerBird problem₃₇′ = record { Q = C ∙ B ; isQueerBird = λ x y z → begin C ∙ B ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal B x y ⟩ B ∙ y ∙ x ∙ z ≈⟨ isBluebird y x z ⟩ y ∙ (x ∙ z) ∎ } problem₃₈′ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasCardinalOnceRemoved ⦄ → HasQuixoticBird problem₃₈′ = record { Q₁ = C* ∙ B ; isQuixoticBird = λ x y z → begin C* ∙ B ∙ x ∙ y ∙ z ≈⟨ isCardinalOnceRemoved B x y z ⟩ B ∙ x ∙ z ∙ y ≈⟨ isBluebird x z y ⟩ x ∙ (z ∙ y) ∎ } problem₃₉′-F* : ⦃ _ : HasFinchOnceRemoved ⦄ ⦃ _ : HasQueerBird ⦄ → HasQuizzicalBird problem₃₉′-F* = record { Q₂ = F* ∙ Q ; isQuizzicalBird = λ x y z → begin F* ∙ Q ∙ x ∙ y ∙ z ≈⟨ isFinchOnceRemoved Q x y z ⟩ Q ∙ z ∙ y ∙ x ≈⟨ isQueerBird z y x ⟩ y ∙ (z ∙ x) ∎ } problem₃₉′-R* : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasRobinOnceRemoved ⦄ → HasQuizzicalBird problem₃₉′-R* = record { Q₂ = R* ∙ B ; isQuizzicalBird = λ x y z → begin R* ∙ B ∙ x ∙ y ∙ z ≈⟨ isRobinOnceRemoved B x y z ⟩ B ∙ y ∙ z ∙ x ≈⟨ isBluebird y z x ⟩ y ∙ (z ∙ x) ∎ } problem₄₁′ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasVireoOnceRemoved ⦄ → HasQuirkyBird problem₄₁′ = record { Q₃ = V* ∙ B ; isQuirkyBird = λ x y z → begin V* ∙ B ∙ x ∙ y ∙ z ≈⟨ isVireoOnceRemoved B x y z ⟩ B ∙ z ∙ x ∙ y ≈⟨ isBluebird z x y ⟩ z ∙ (x ∙ y) ∎ } problem₄₂′ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasFinchOnceRemoved ⦄ → HasQuackyBird problem₄₂′ = record { Q₄ = F* ∙ B ; isQuackyBird = λ x y z → begin F* ∙ B ∙ x ∙ y ∙ z ≈⟨ isFinchOnceRemoved B x y z ⟩ B ∙ z ∙ y ∙ x ≈⟨ isBluebird z y x ⟩ z ∙ (y ∙ x) ∎ } module _ ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ where private instance hasCardinal = problem₂₁-bonus hasCardinalOnceRemoved = problem₃₁ hasRobinOnceRemoved = problem₃₂ hasFinchOnceRemoved = problem₃₃ hasVireoOnceRemoved = problem₃₄ problem₃₇ : HasQueerBird problem₃₇ = problem₃₇′ private instance hasQueerBird = problem₃₇ problem₃₈ : HasQuixoticBird problem₃₈ = problem₃₈′ private instance hasQuixoticBird = problem₃₈ problem₃₉-F* : HasQuizzicalBird problem₃₉-F* = problem₃₉′-F* problem₃₉-R* : HasQuizzicalBird problem₃₉-R* = problem₃₉′-R* private instance hasQuizzicalBird = problem₃₉-F* problem₄₁ : HasQuirkyBird problem₄₁ = problem₄₁′ problem₄₂ : HasQuackyBird problem₄₂ = problem₄₂′ module _ ⦃ _ : HasCardinal ⦄ where problem₄₀-Q₁ : ⦃ _ : HasQuizzicalBird ⦄ → HasQuixoticBird problem₄₀-Q₁ = record { Q₁ = C ∙ Q₂ ; isQuixoticBird = λ x y z → begin C ∙ Q₂ ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal Q₂ x y ⟩ Q₂ ∙ y ∙ x ∙ z ≈⟨ isQuizzicalBird y x z ⟩ x ∙ (z ∙ y) ∎ } problem₄₀-Q₂ : ⦃ _ : HasQuixoticBird ⦄ → HasQuizzicalBird problem₄₀-Q₂ = record { Q₂ = C ∙ Q₁ ; isQuizzicalBird = λ x y z → begin C ∙ Q₁ ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal Q₁ x y ⟩ Q₁ ∙ y ∙ x ∙ z ≈⟨ isQuixoticBird y x z ⟩ y ∙ (z ∙ x) ∎ } problem₄₃-Q₃ : ⦃ _ : HasQuackyBird ⦄ → HasQuirkyBird problem₄₃-Q₃ = record { Q₃ = C ∙ Q₄ ; isQuirkyBird = λ x y z → begin C ∙ Q₄ ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal Q₄ x y ⟩ Q₄ ∙ y ∙ x ∙ z ≈⟨ isQuackyBird y x z ⟩ z ∙ (x ∙ y) ∎ } problem₄₃-Q₄ : ⦃ _ : HasQuirkyBird ⦄ → HasQuackyBird problem₄₃-Q₄ = record { Q₄ = C ∙ Q₃ ; isQuackyBird = λ x y z → begin C ∙ Q₃ ∙ x ∙ y ∙ z ≈⟨ congʳ $ isCardinal Q₃ x y ⟩ Q₃ ∙ y ∙ x ∙ z ≈⟨ isQuirkyBird y x z ⟩ z ∙ (y ∙ x) ∎ } problem₄₄ : ⦃ _ : HasQuixoticBird ⦄ ⦃ _ : HasThrush ⦄ → HasQuackyBird problem₄₄ = record { Q₄ = Q₁ ∙ T ; isQuackyBird = λ x y z → begin Q₁ ∙ T ∙ x ∙ y ∙ z ≈⟨ congʳ $ isQuixoticBird T x y ⟩ T ∙ (y ∙ x) ∙ z ≈⟨ isThrush (y ∙ x) z ⟩ z ∙ (y ∙ x) ∎ } problem₄₅ : ⦃ _ : HasQueerBird ⦄ ⦃ _ : HasThrush ⦄ → HasBluebird problem₄₅ = record { B = Q ∙ T ∙ (Q ∙ Q) ; isBluebird = λ x y z → begin Q ∙ T ∙ (Q ∙ Q) ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isQueerBird T (Q ∙ Q) x ⟩ Q ∙ Q ∙ (T ∙ x) ∙ y ∙ z ≈⟨ congʳ $ isQueerBird Q (T ∙ x) y ⟩ T ∙ x ∙ (Q ∙ y) ∙ z ≈⟨ congʳ $ isThrush x (Q ∙ y) ⟩ Q ∙ y ∙ x ∙ z ≈⟨ isQueerBird y x z ⟩ x ∙ (y ∙ z) ∎ } problem₄₆ : ⦃ _ : HasQueerBird ⦄ ⦃ _ : HasThrush ⦄ → HasCardinal problem₄₆ = record { C = Q ∙ Q ∙ (Q ∙ T) ; isCardinal = λ x y z → begin Q ∙ Q ∙ (Q ∙ T) ∙ x ∙ y ∙ z ≈⟨ congʳ $ congʳ $ isQueerBird Q (Q ∙ T) x ⟩ Q ∙ T ∙ (Q ∙ x) ∙ y ∙ z ≈⟨ congʳ $ isQueerBird T (Q ∙ x) y ⟩ Q ∙ x ∙ (T ∙ y) ∙ z ≈⟨ isQueerBird x (T ∙ y) z ⟩ T ∙ y ∙ (x ∙ z) ≈⟨ isThrush y (x ∙ z) ⟩ x ∙ z ∙ y ∎ } problem₄₇ : ⦃ _ : HasBluebird ⦄ ⦃ _ : HasThrush ⦄ → HasGoldfinch problem₄₇ = record { G = D ∙ C ; isGoldfinch = λ x y z w → begin D ∙ C ∙ x ∙ y ∙ z ∙ w ≈⟨ congʳ $ isDove C x y z ⟩ C ∙ x ∙ (y ∙ z) ∙ w ≈⟨ isCardinal x (y ∙ z) w ⟩ x ∙ w ∙ (y ∙ z) ∎ } where instance hasCardinal = problem₂₁-bonus hasDove = problem₅
AppleScript/Make Bags 2017.applescript
aaronpriven/actium
1
236
set BagListFileSpec to choose file of type {"public.text"} without invisibles set BagListFileSpec to BagListFileSpec as string set TemporaryPath to (POSIX path of (path to temporary items)) set theMasterPage to "G-AC Go" --set theMasterPage to "F-Flex" set AppleScript's text item delimiters to ":" set BagFileName to last text item of BagListFileSpec set AppleScript's text item delimiters to "." set BagIDFileName to (((reverse of rest of reverse of text items of BagFileName) as string) & ".indd") global OriginalIDFile global NewIDFile set OriginalIDFile to POSIX file "/Users/Shared/Dropbox (AC_PubInfSys)/AC_PubInfSys Team Folder/Flags/Bags/Generated_bag_template_2016.indd" set NewIDFile to "Bireme:Actium:flagart:bags:" & BagIDFileName set BagListFile to open for access file BagListFileSpec set BagListLines to read BagListFile for (get eof BagListFile) using delimiter ASCII character 10 -- LF close access BagListFile set BagListLines to rest of BagListLines -- skip header line tell application "Adobe InDesign CC 2017" set myDocument to open OriginalIDFile without showing window set myDocument to save myDocument to NewIDFile with force save try -- only used to show InDesign document window in the event of an error set FirstSpreadAlreadyPresent to true set thecount to 0 repeat with theLineItem in BagListLines set theLine to contents of theLineItem set theLineFields to my tabfields(theLine) set action to item 1 of theLineFields set phoneID to item 2 of theLineFields set mainbox to item 3 of theLineFields set instruction to item 4 of theLineFields set thecount to thecount + 1 log thecount & ") " & phoneID if FirstSpreadAlreadyPresent then set FirstSpreadAlreadyPresent to false else tell myDocument to make page end if set thePage to page -1 of myDocument set myMaster to master spread named (theMasterPage) of myDocument set applied master of thePage to myMaster my overridetext("StopID", thePage, phoneID) my overridetext("InstructionBox", thePage, instruction) set TemporaryFile to (TemporaryPath & phoneID & ".txt") tell me try set OutFH to open for access TemporaryFile with write permission on error display dialog "Can't open file for output" error s number i partial result p from f to t end try set eof OutFH to 0 write "<ASCII-MAC>" & return & "<Version:6><FeatureSet:InDesign-Roman>" to OutFH write mainbox to OutFH close access OutFH end tell set myMasterItem to (item 1 of (all page items of applied master of thePage) whose label is "MainBox") tell myMasterItem set thisframe to override destination page thePage end tell tell thisframe to place POSIX file TemporaryFile repeat while overflows of thisframe set myStory to parent story of thisframe repeat with thisParagraphNum from 1 to (count of paragraphs of myStory) set myLeading to (leading of (paragraph thisParagraphNum of myStory)) set mySize to (point size of (paragraph thisParagraphNum of myStory)) set mySpaceAfter to (space after of (paragraph thisParagraphNum of myStory)) set myParaShadingTop to (paragraph shading top offset of (paragraph thisParagraphNum of myStory)) set myParaShadingBottom to (paragraph shading bottom offset of (paragraph thisParagraphNum of myStory)) set myLeading to 0.98 * myLeading set mySize to 0.98 * mySize set mySpaceAfter to 0.98 * mySpaceAfter set myParaShadingTop to 0.98 * myParaShadingTop set myParaShadingBottom to 0.98 * myParaShadingBottom set leading of (paragraph thisParagraphNum of myStory) to myLeading set (point size of (paragraph thisParagraphNum of myStory)) to mySize set space after of (paragraph thisParagraphNum of myStory) to mySpaceAfter set (paragraph shading top offset of (paragraph thisParagraphNum of myStory)) to myParaShadingTop set (paragraph shading bottom offset of (paragraph thisParagraphNum of myStory)) to myParaShadingBottom end repeat end repeat if (action is equal to "RS") then set myMasterItem to (item 1 of (all page items of applied master of thePage) whose label is "RemoveBox") tell myMasterItem set myItem to override destination page thePage end tell set fill color of myItem to color "Pink" of myDocument end if end repeat close myDocument saving yes on error s number i partial result p from f to t try tell myDocument to make window end try error s number i partial result p from f to t end try end tell beep display alert "Finished making bags." on overridetext(myLabel, myPage, myText) tell application "Adobe InDesign CC 2017" --set myMasterItem to page item myLabel of all page items of applied master of myPage set myMasterItem to item 1 of (all page items of applied master of myPage) whose label is myLabel tell myMasterItem set myItem to override destination page myPage end tell set contents of myItem to myText end tell return end overridetext on tabfields(myLine) tell AppleScript to set the text item delimiters to tab set myFields to text items of myLine return myFields end tabfields (* =head1 NAME <name> - <brief description> =head1 VERSION This documentation refers to version 0.003 =head1 DESCRIPTION A full description of the module and its features. =head1 DIAGNOSTICS A list of every error and warning message that the application can generate (even the ones that will "never happen"), with a full explanation of each problem, one or more likely causes, and any suggested remedies. If the application generates exit status codes, then list the exit status associated with each error. =head1 CONFIGURATION AND ENVIRONMENT A full explanation of any configuration system(s) used by the application, including the names and locations of any configuration files, and the meaning of any environment variables or properties that can be se. These descriptions must also include details of any configuration language used. =head1 DEPENDENCIES List its dependencies. =head1 AUTHOR <NAME> <<EMAIL>> =head1 COPYRIGHT & LICENSE Copyright 2017 This program is free software; you can redistribute it and/or modify it under the terms of either: =over 4 =item * the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or =item * the Artistic License version 2.0. =back This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *)
disass.asm
ChartreuseK/z80monitor
5
22668
<reponame>ChartreuseK/z80monitor<filename>disass.asm ; Minimal z80 diassesembler written in z80 assembly ;--------------------------------------------------- ; z80 opcode decoding based on: ; http://www.z80.info/decoding.htm ; ; TODO: Try and optimize to < 2048 bytes (Personal goal) ; #local ; RAM Variables #data _RAM DISLINE:: DS 22 ; Buffer for outputted line ; Longest possible line is of the form: 'LD A, SET 1, (IX+$AB)' ; 22 bytes including null terminator DISLINECUR: DS 2 ; Cur index PREFIX: DS 1 ; Current prefix SVDISP: DS 1 ; Saved displacement for DDCB and FDCB #code _ROM ; (HL) points to first byte of instruction ; Returns HL as pointing to next byte after instruction ; (Assumes HL is STADDR for instruction) DISINST:: #local LD BC, DISLINE LD (DISLINECUR), BC ; Reset string index LD A, 0 LD (DISLINE), A ; Start with null LD (PREFIX), A ; Reset prefix START: LD A, (HL) CP $CB ; Check for prefixes JP Z, CB_PRE CP $DD JP Z, DD_PRE CP $ED JP Z, ED_PRE CP $FD JR Z, FD_PRE ; No prefix AND $C0 ; Grab x (1st octal) JR Z, X0 ; 00 ... ... JP P, X1 ; 01 ... ... CP $80 JR Z, X2 ; 10 ... ... ; Fall into X3 ; 11 ... ... X3: LD A, (HL) ; Reload instruction CALL EXTRACT_Z ADD A ; Double for index LD DE, HL ; Save pointer LD HL, X3_ZJMP LD B, 0 LD C, A ADD HL, BC LD BC, (HL) ; Read in address PUSH BC ; Push address of handler (for RET) LD HL, DE ; Restore pointer LD A, (HL) ; Reload instruction RET ; Jump to handler (indirect Jump) ;------------------------ X2: ; ALU[y], r[z] ALU + register LD A, (HL) CALL EXTRACT_Y LD BC, ALU CALL PUSHINDEXED ; Seperator is part of the string, since some need OSEP and some space LD A, (HL) CALL EXTRACT_Z LD BC, REG8 CALL PUSHINDEXED JR DONE ;------------------------ X1: ; 8-bit loading. (Exception LD (HL), (HL) = HALT) LD A, (HL) CP $76 ; 0166 - HALT JR Z, HALT LD BC, SLD CALL PUSHSTROSEP CALL EXTRACT_Y LD BC, REG8 CALL PUSHINDEXED CALL PUSHCOMMA LD A, (HL) CALL EXTRACT_Z LD BC, REG8 CALL PUSHINDEXED JR DONE ;------------------------ X0: LD A, (HL) ; Reload instruction CALL EXTRACT_Z ADD A ; Double for index LD DE, HL LD HL, X0_ZJMP LD B, 0 LD C, A ADD HL, BC LD BC, (HL) ; Read in address PUSH BC ; Push address of handler (for RET) LD HL, DE ; Restore pointer LD A, (HL) ; Reload instruction RET ; Jump to handler ;------------------------ DD_PRE: FD_PRE: PUSH AF LD A, (PREFIX) AND A JR Z, ADDPREFIX ; Double prefix, mark first as a NONI and return LD BC, SNONI CALL PUSHSTR POP AF LD (PREFIX), A ; Store new prefix ; Need to terminate ourselves since we don't want PREFIXADJUST to run XOR A CALL PUSHCH ; Null terminate string RET ; Actual return ADDPREFIX: POP AF LD (PREFIX), A ; Store new prefix INC HL ; Re-start on next byte JP START #endlocal DONE: INC HL DONE_NOINC: XOR A ; Null terminate string CALL PUSHCH CALL PREFIXADJUST ; Handle any $DD/$FD prefix changes RET ; Actual return HALT: LD BC, SHALT PUSHDONE: ; Push string and be done CALL PUSHSTR JR DONE DISP8: INC HL LD A, (HL) ; Read in signed displacement LD C, A RLA ; Rotate 'sign bit' into Carry SBC A, A ; 0 if no carry, 0xFF if carry LD B, A ; B is now sign extended C PUSH HL ; Save current addr INC HL ; Displacents start from next inst ADD HL, BC ; Add displacement to get target addr LD BC, HL ; Swap into BC POP HL ; Restore curaddr CALL PUSHHEX16 ; Push target addr JR DONE IMM16: INC HL LD C, (HL) INC HL LD B, (HL) CALL PUSHHEX16 JR DONE IMM8: INC HL LD B, (HL) CALL PUSHHEX8 JR DONE IMM8P: ; Imm8 with post string in BC PUSH BC INC HL LD B, (HL) CALL PUSHHEX8 POP BC CALL PUSHSTR JR DONE IMM16P: ; Imm16 with post string in BC PUSH BC INC HL LD C, (HL) INC HL LD B, (HL) CALL PUSHHEX16 POP BC CALL PUSHSTR JR DONE ;-------- ; Replace HL/H/L/(HL) with IX/IXH/IXL/(IX+d) or IY/IYH/IYL/(IY+d) if the ; prefix byte calls for it ; PREFIXADJUST: #local LD A, (PREFIX) AND A RET Z ; If no prefix, then no change CP $DD JR Z, XPRE ; Replace prefix byte with letter representation YPRE: LD A, 'Y' JR PRE XPRE: LD A, 'X' PRE: LD (PREFIX), A PUSH HL ; Save next byte ; Re-walk disline, skip to operands LD HL, DISLINE WALK: LD A, (HL) INC HL CP OSEP ; Look for operand seperator JR NZ, WALK ; Now need to find occurances of HL/H/L/(HL) WALK2: LD A, (HL) CP 'H' JR Z, FOUNDH CP 'L' JR Z, FOUNDL CP '(' JR Z, INDIR AND A ; Null terminator JR Z, END NEXT: INC HL JR WALK2 FOUNDH: ; Peek if this is HL INC HL LD A, (HL) DEC HL CP 'L' JR Z, FOUNDHL FOUNDL: ; Replace H/L with IXH/IYH or IXL/IYL CALL PUSHGAP ; Moves H/L forward LD A, (PREFIX) ; Get prefix letter X/Y LD (HL), A ; Store prefix now XH/YH or XL/YL CALL PUSHGAP LD A, 'I' LD (HL), A ; Now IXH/IYH or IXL/IYL JR END FOUNDHL: ; Replace HL with IX or IY LD A, 'I' LD (HL), A ; Now IL INC HL LD A, (PREFIX) LD (HL), A ; Now IX/IY JR END INDIR: INC HL LD A, (HL) CP 'H' ; Only care about (HL) JR NZ, NEXT ; Something else, skip ; We found (H, must be (HL) ; Need to replace with (IX+d) LD A, 'I' LD (HL), A ; Now (IL) INC HL LD A, (PREFIX) LD (HL), A ; Now (IX) or (IY) INC HL CALL PUSHGAP ; (IX ) CALL PUSHGAP ; (IX ) CALL PUSHGAP ; (IX ) CALL PUSHGAP ; (IX ) Enough to fit (IX+$20) or (IX-$10) LD (DISLINECUR), HL; Save pointer (byte after X/Y) POP HL ; Restore byte pointer (we need a displacement LD B, (HL) ; Displacement byte INC HL PUSH HL ; Save byte CALL PUSHSIGNHEX8 ; Push signed displacement ; Fall into END END: POP HL ; Restore next byte RET #endlocal ;-------- ; Insert space into disline ; HL - current spot, make space here, move forward till null PUSHGAP: #local PUSH HL LD A, (HL) ; Current spot NEXT: INC HL ; Next spot LD B, (HL) ; Save next spot LD (HL), A ; Save cur into next AND A ; Check if we wrote the null JR Z, FOUNDNULL LD A, B ; Make values from next the new cur JR NEXT FOUNDNULL: POP HL ; Restore back to starting spot RET #endlocal ;------- ; Extract p field from A EXTRACT_P: ; xx.PPx.xxx RRA ; xx.xPP.xxx RRA ; xx.xxP.Pxx RRA ; xx.xxx.PPx RRA ; xx.xxx.xPP AND $03 ; 00.000.0PP RET ;------- ; Extract y field from A EXTRACT_Y: ; xx.YYY.xxx RRA ; xx.xYY.Yxx RRA ; xx.xxY.YYx RRA ; xx.xxx.YYY AND $07 ; 00.000.YYY RET ;-------- ; Extract z field from A EXTRACT_Z: AND $07 RET ;-------- ; Pushes a string indexed from a string table ; BC - String table ; A - index PUSHINDEXED: #local PUSH HL LD HL, BC CHECK: AND A ; Check for end JR Z, FOUND ; Iterate to next string ITEM: BIT 7, (HL) ; Check if end of string JR NZ, ENDITEM INC HL ; Iterate throught string JR ITEM ENDITEM: INC HL DEC A JR CHECK FOUND: LD BC, HL POP HL JP PUSHSTR ; Tail call #endlocal ;-------- ; Push a high bit terminated string to buffer with operand seperator ; BC - String PUSHSTROSEP: CALL PUSHSTR PUSH AF LD A, OSEP CALL PUSHCH POP AF RET ;-------- ; Push a high bit terminated string to buffer with space after ; BC - String PUSHSTRSP: CALL PUSHSTR PUSH AF CALL PUSHSP POP AF RET ; Push a space to the buffer PUSHSP: LD A, ' ' ; Fall into PUSHCH ;-------- ; Push individual char (A) into buffer PUSHCH: PUSH HL LD HL, (DISLINECUR) LD (HL), A ; Store character INC HL LD (DISLINECUR), HL POP HL RET ;------- ; Push a high bit terminated string to buffer ; BC - String PUSHSTR: #local PUSH AF PUSH HL LD HL, (DISLINECUR); Pointer to current char SLOOP: LD A, (BC) ; Read in character AND $7F ; Mask off high bit LD (HL), A ; Store to line INC HL LD A, (BC) ; Reread character AND $80 ; Test high bit of string JR NZ, DONE INC BC ; Next character of string JR SLOOP DONE: LD (DISLINECUR), HL POP HL POP AF RET #endlocal ;-------- ; Push argument seperator PUSHCOMMA: LD BC, SCOMMA JP PUSHSTRSP ;------- ; Print a single digit decimal 0-9 PUSHDEC1: PUSH HL ADD '0' LD HL, (DISLINECUR) LD (HL), A INC HL LD (DISLINECUR), HL POP HL RET ;-------- ; Print a 1-byte hex number as signed with sign prefix + or - PUSHSIGNHEX8: #local LD A, B AND A JP P, POS NEG: LD A, '-' CALL PUSHCH LD A, B NEG ; Convert from negative to positive LD B, A JR PUSHHEX8 ; Tail call push number POS: LD A, '+' CALL PUSHCH JR PUSHHEX8 ; Tail call, push number #endlocal ;-------- ; Print a 1-byte hex number ; B - number PUSHHEX8: LD A, '$' CALL PUSHCH PUSHHEX8_NP: LD A, B SRL A SRL A SRL A SRL A ; Extract high nybble CALL PUSHNYB LD A, B AND $0F ; Fall into PUSHNYB (Tail call) ;-------- ; Push a nybble from A (low 4-bits, high must be 0) PUSHNYB: #local ADD '0' CP '9'+1 ; Check if A-F JR C, NOFIX ADD 'A'-('9'+1) ; Diff between 'A' and ':' NOFIX: JP PUSHCH ; Tail call #endlocal ;-------- ; Print a 2-byte hex number ; BC - number PUSHHEX16: CALL PUSHHEX8 LD B, C JP PUSHHEX8_NP ; Tail call ;--------------------------------------- ; X0 decodes ;--------------------------------------- ;---------- ; Relative jumps and assorted 00.xxx.000 RELASS: #local AND $38 ; Grab y (2nd octal) JR Z, NOP ; 00.000.000 = NOP CP $08 JR Z, EXAFAF ; 00.001.000 = EX AF, AF' CP $10 JR Z, DJNZ ; 00.010.000 = DJNZ CP $18 JR Z, JRUN ; 00.011.000 = JR d ; 00.1xx.000 = JR cc[xx], d JRCC: LD BC, SJR CALL PUSHSTROSEP LD A, (HL) CALL EXTRACT_Y AND $03 ; y-4 LD BC, CC ; Condition codes CALL PUSHINDEXED CALL PUSHCOMMA JP DISP8 NOP: LD BC, SNOP JP PUSHDONE ; No operands EXAFAF: LD BC, SEXAFAF JP PUSHDONE DJNZ: LD BC, SDJNZ CALL PUSHSTROSEP JP DISP8 ; 8 bit displacement JRUN: LD BC, SJR CALL PUSHSTROSEP JP DISP8 ; 8 bit displacement #endlocal ;-------- ; 16-bit load imm. / add to HL LD16ADD: #local CALL EXTRACT_P ; Extract P field BIT 3, (HL) ; Test q 00.xxq.001 JR Z, LD16 ; Fall into ADD HL ADDHL: ; Add to HL LD BC, SADDHL CALL PUSHSTRSP LD BC, REG16 CALL PUSHINDEXED JP DONE LD16: ; 16-bit load immediate LD BC, SLD CALL PUSHSTROSEP LD BC, REG16 CALL PUSHINDEXED CALL PUSHCOMMA JP IMM16 #endlocal ;-------- ; Indirect loading INDIR: #local BIT 3, A ; Test q JR NZ, FROMMEM ; To MEM LD BC, SLDIN CALL PUSHSTR CALL EXTRACT_P CP 2 JR C, TOREG ; To indirect mem CP 3 JR Z, FROMHL ; From A LD BC, SEA ; q=0 p=3 JP IMM16P ;------------------- FROMHL: LD BC, SEHL ; q=0 p=2 JP IMM16P ;------------------- TOREG: AND $01 ; q=0 p=0/1 LD BC, REG16 CALL PUSHINDEXED ; LD (BC), A and LD (DE), A LD BC, SEA CALL PUSHSTR JP DONE ;------------------- FROMMEM: ; q=1 CALL EXTRACT_P CP 2 JP Z, TOHL LD BC, SLDAIN CALL PUSHSTRSP CP 2 JP C, FROMREG ; LD A, (nn) LD BC, SEBKT JP IMM16P ;------------------- TOHL: ; LD HL, (nn) LD BC, SLDHLIN CALL PUSHSTR LD BC, SEBKT JP IMM16P ;------------------- FROMREG: AND $01 LD BC, REG16 CALL PUSHINDEXED LD BC, SEBKT CALL PUSHSTR JP DONE ;------------------- #endlocal ;-------- ; INC and DEC 16-bit regs INCDEC16: #local BIT 3, A ; Test q JR NZ, DEC16 INC16: LD BC, SINC CALL PUSHSTROSEP JR REG DEC16: LD BC, SDEC CALL PUSHSTROSEP REG: CALL EXTRACT_P ; Extract reg # LD BC, REG16 ; RP CALL PUSHINDEXED JP DONE #endlocal ;-------- ; INC 8-bit regs INC8: LD BC, SINC JR IDCOMMON ;-------- ; DEC 8-bit regs DEC8: LD BC, SDEC IDCOMMON: CALL PUSHSTROSEP CALL EXTRACT_Y LD BC, REG8 CALL PUSHINDEXED JP DONE ;-------- ; LD 8-bit immediate LDI8: LD BC, SLD CALL PUSHSTROSEP CALL EXTRACT_Y LD BC, REG8 CALL PUSHINDEXED CALL PUSHCOMMA JP IMM8 ;-------- ; Assorted Accumulator and Flags ASSAF: CALL EXTRACT_Y LD BC, AAF CALL PUSHINDEXED JP DONE ;--------------------------------------- ; X3 decodes ;--------------------------------------- ;-------- ; Return with condition RETCC: LD BC, SRET CALL PUSHSTROSEP CALL EXTRACT_Y LD BC, CC CALL PUSHINDEXED JP DONE ;-------- ; POP and various POPVAR: #local BIT 3, A ; Test Q JR NZ, VARIOUS ; POP rp2[p] LD BC, SPOP CALL PUSHSTROSEP CALL EXTRACT_P LD BC, REG16_2 CALL PUSHINDEXED JP DONE VARIOUS: CALL EXTRACT_P LD BC, VARIOUSTBL CALL PUSHINDEXED JP DONE #endlocal ;-------- ; Conditional Jump JPCC: LD BC, SJP CALL PUSHSTROSEP CALL EXTRACT_Y LD BC, CC CALL PUSHINDEXED CALL PUSHCOMMA JP IMM16 ;-------- ; Assorted X3ASS: #local CALL EXTRACT_Y AND A JR Z, JPIMM CP 2 JR Z, OUT8 CP 3 JR Z, IN8 ; 1 is $CB prefix, ignored. 4-7 are simple CP 5 ; EX DE, HL is special in that DD/FD doesn't affect JR NZ, NOADJ PUSH AF XOR A LD (PREFIX), A ; Pretend like we had no prefix byte if we're EX DE, HL POP AF NOADJ: AND 3 ; Turn 4-7 to 0-3 LD BC, X3ASSTBL CALL PUSHINDEXED JP DONE JPIMM: LD BC, SJP CALL PUSHSTROSEP JP IMM16 OUT8: LD BC, SOUT CALL PUSHSTR LD BC, SEOUT JP IMM8P IN8: LD BC, SIN CALL PUSHSTR LD BC, SEBKT JP IMM8P #endlocal ;-------- ; Call with CC CCCALL: CALL EXTRACT_Y LD BC, SCALL CALL PUSHSTROSEP LD BC, CC CALL PUSHINDEXED CALL PUSHCOMMA JP IMM16 ;-------- ; Push and Call/various PUSHVAR: #local BIT 3, A ; Test Q JP Z, PUSH ; p = 0. (1-3 are DD, ED, and FD prefixes) LD BC, SCALL CALL PUSHSTROSEP JP IMM16 PUSH: LD BC, SPUSH CALL PUSHSTROSEP CALL EXTRACT_P LD BC, REG16_2 CALL PUSHINDEXED JP DONE #endlocal ;-------- ; ALU immediate with A ALUIMM: CALL EXTRACT_Y LD BC, ALU CALL PUSHINDEXED ; Seperator part of ALU string JP IMM8 ;-------- ; Restart opcodes RESTART: CALL EXTRACT_Y LD BC, SRESET CALL PUSHSTROSEP ADD A ; Y*2 ADD A ; Y*4 ADD A ; Y*8 LD B, A CALL PUSHHEX8 JP DONE ;--------------------------------------- ;-------- ; CB prefixed opcodes CB_PRE: #local LD A, (PREFIX) AND A JR NZ, PRE_CB_PRE INC HL ; Read in opcode LD A, (HL) AND $C0 ; Test X only JR Z, X0 CP $40 JR Z, X1 CP $80 JR Z, X2 ; Fall into X3 X3: LD BC, SBIT COMMON: CALL PUSHSTROSEP LD A, (HL) CALL EXTRACT_Y CALL PUSHDEC1 CALL PUSHCOMMA COMMON2: LD A, (HL) CALL EXTRACT_Z LD BC, REG8 CALL PUSHINDEXED JP DONE X2: LD BC, SRES JR COMMON X1: LD BC, SSET JR COMMON X0: LD A, (HL) CALL EXTRACT_Y LD BC, ROT CALL PUSHINDEXED JR COMMON2 #endlocal ;--------------------------------------- ;-------- ; Prefixed CB - Order is now PRE.CB.DISP.OP ; instead of CB.OP ; Includes oddball illegal opcodes, doesn't use standard DONE termination PRE_CB_PRE: #local INC HL LD A, (HL) ; Read in displacement LD (SVDISP), A ; Save displacement INC HL LD A, (HL) ; Read in opcode AND $C0 ; Test X only JR Z, X0 CP $40 JR Z, X1 CP $80 JR Z, X2 ; Fall into X3 X3: ; SET opcodes CALL EXTESTZ6 JR Z, X3_6 ; Opcodes of form LD r[z], SET y, (IX+d) CALL PUSHLDRZ X3_6: ; No side-effect load LD BC, SSET X2X3COM: CALL PUSHSTROSEP LD A, (HL) ; Reload opcode CALL EXTRACT_Y CALL PUSHDEC1 ; Bit # CALL PUSHCOMMA JR INDEX_D ;-------- X2: ; RES opcodes CALL EXTESTZ6 JR Z, X2_6 ; Opcodes of form LD r[z], RES y, (IX+d) CALL PUSHLDRZ X2_6: ; No side-effect load LD BC, SRES JR X2X3COM ;-------- X1: ; BIT opcodes LD BC, SBIT CALL PUSHSTROSEP LD A, (HL) ; Reload opcode CALL EXTRACT_Y CALL PUSHDEC1 ; Bit # CALL PUSHCOMMA CALL EXTESTZ6 JR Z, INDEX_D ; If would be (HL), push (IX/IY+d) instead LD BC, REG8 CALL PUSHINDEXED ; r[z] JR EXIT ;-------- X0: ; Rotate opcodes CALL EXTESTZ6 JR Z, X0_6 ; Opcodes of form LD r[z], rot[y] (IX+d) CALL PUSHLDRZ X0_6: ; No side-effect load LD A, (HL) CALL EXTRACT_Y LD BC, ROT ; rot[y] CALL PUSHINDEXED ; Fall into INDEX_D ;-------- INDEX_D: ; Push (IX/IY+d) LD BC, SBKTI CALL PUSHSTR LD A, (PREFIX) CP $DD JR Z, IXPRE IYPRE: LD A, 'Y' JR INDEXCOM IXPRE: LD A, 'X' INDEXCOM: CALL PUSHCH LD A, (SVDISP) LD B, A CALL PUSHSIGNHEX8 LD A, ')' CALL PUSHCH EXIT: INC HL ; Next byte LD A, 0 CALL PUSHCH ; Push null terminator RET ; Exit DISINST ;-------- ; Z in A already, helper subroutine PUSHLDRZ: LD BC, SLD CALL PUSHSTRSP ; SP here since real op has OSEP LD BC, REG8 ; r[z] CALL PUSHINDEXED JP PUSHCOMMA ; Tail call ;-------- EXTESTZ6: LD A, (HL) ; Reload opcode CALL EXTRACT_Z CP 6 ; 6 would have been (HL), normal 'legal' opcode RET #endlocal ;--------------------------------------- ;-------- ; ED prefixed opcodes ED_PRE: #local ; Check for invalid prefix combo LD A, (PREFIX) AND A JR Z, NOPRE ; Otherwise push out NONI for the invalid prefix ; Next entry will re-read the ED with no prefix LD BC, SNONI CALL PUSHSTR LD A, 0 ; Null terminate string CALL PUSHCH RET ; Ret from DISINST NOPRE: INC HL ; Read in opcode LD A, (HL) AND $C0 ; Test X only JR Z, X0 CP $40 JR Z, X1 CP $80 JR Z, X2 ; Fall into X3 X3: ; Invalid (NONI+NOP) X0: ; Invalid (NONI+NOP) X2INVAL:; Invalid (NONI+NOP) LD BC, SINVAL CALL PUSHSTR JP DONE X1: LD A, (HL) CALL EXTRACT_Z ADD A ; Double for index LD DE, HL LD HL, EDX1_ZJMP LD B, 0 LD C, A ADD HL, BC LD BC, (HL) ; Read in address PUSH BC ; Push address of handler (for RET) LD HL, DE ; Restore pointer LD A, (HL) ; Reload instruction RET ; Jump to handler X2: ; Block instructions LD A, (HL) CALL EXTRACT_Y CP 4 JR C, X2INVAL ; y < 4 invalid AND 3 ; y-4 ADD A ; Y*2 ADD A ; Y*4 LD B, A ; Save LD A, (HL) CALL EXTRACT_Z ADD B ; z + y*4 LD BC, BLI CALL PUSHINDEXED JP DONE #endlocal ;-------- ; In port from 16-addr INP16: #local CALL EXTRACT_Y CP 6 JR Z, NOREG ; IN r[y], (C) LD BC, SINP CALL PUSHSTROSEP LD BC, REG8 CALL PUSHINDEXED CALL PUSHCOMMA LD BC, SINDC CALL PUSHSTR JP DONE NOREG: LD BC, SINNOC CALL PUSHSTR JP DONE #endlocal ;-------- ; Output port 16-bit addr OUTP16: #local CALL EXTRACT_Y CP 6 JR Z, NOREG ; OUT (C), r[y] LD BC, SOUTC CALL PUSHSTRSP LD BC, REG8 CALL PUSHINDEXED JP DONE NOREG: LD BC, SOUTNOC CALL PUSHSTR JP DONE #endlocal ;-------- ; Add/sub with carry 16-bit ADCSBC16: #local BIT 3, A ; Extract q JR NZ, ADC16 SBC16: LD BC, SSBCHL CALL PUSHSTRSP JR COMMON ADC16: LD BC, SADCHL CALL PUSHSTRSP COMMON: CALL EXTRACT_P LD BC, REG16 CALL PUSHINDEXED JP DONE #endlocal ;-------- ; Load/Store register pair to imm16 RPIMM: #local BIT 3, A ; Extract q JR NZ, LOAD STORE: LD BC, SLDIN CALL PUSHSTR ; Special case, we're going to have to grab ; the immediate 16-bit value ourselves since ; the IMM16P helper can't handle a calculated suffix PUSH AF INC HL LD C, (HL) INC HL LD B, (HL) CALL PUSHHEX16 POP AF LD BC, SBKTC CALL PUSHSTR CALL EXTRACT_P LD BC, REG16 CALL PUSHINDEXED JP DONE LOAD: LD BC, SLD CALL PUSHSTROSEP CALL EXTRACT_P LD BC, REG16 CALL PUSHINDEXED LD BC, SCOMBKT CALL PUSHSTR LD BC, SEBKT JP IMM16P #endlocal ;-------- ; Negate A NEGA: LD BC, SNEG CALL PUSHSTR JP DONE ;-------- ; Return from interrupt RETINT: #local CALL EXTRACT_Y CP 1 JP Z, RETI RETN: LD BC, SRETN JR COMMON RETI: LD BC, SRETI COMMON: CALL PUSHSTR JP DONE #endlocal ;-------- ; Set interrupt mode SETI: LD BC, SIM CALL PUSHSTROSEP CALL EXTRACT_Y LD BC, IM CALL PUSHINDEXED JP DONE ;-------- ; ED assorted EDASSORT: #local CALL EXTRACT_Y CP 4 JR NC, NOLD LD BC, SLD CALL PUSHSTROSEP NOLD: LD BC, EDASSTBL CALL PUSHINDEXED JP DONE #endlocal ;--------------------------------------- OSEP equ $09 ;TAB X0_ZJMP: DW RELASS ; 00 ... 000 DW LD16ADD ; 00 ... 001 DW INDIR ; 00 ... 010 DW INCDEC16 ; 00 ... 011 DW INC8 ; 00 ... 100 DW DEC8 ; 00 ... 101 DW LDI8 ; 00 ... 110 DW ASSAF ; 00 ... 111 X3_ZJMP: DW RETCC ; 11 ... 000 DW POPVAR ; 11 ... 001 DW JPCC ; 11 ... 010 DW X3ASS ; 11 ... 011 DW CCCALL ; 11 ... 100 DW PUSHVAR ; 11 ... 101 DW ALUIMM ; 11 ... 110 DW RESTART ; 11 ... 111 EDX1_ZJMP: DW INP16 DW OUTP16 DW ADCSBC16 DW RPIMM DW NEGA DW RETINT DW SETI DW EDASSORT X3ASSTBL: DM "EX",OSEP,"(SP), HL"+$80 DM "EX",OSEP,"DE, HL"+$80 DM "DI"+$80 DM "EI"+$80 VARIOUSTBL: SRET: DM "RET"+$80 DM "EXX"+$80 DM "JP",OSEP,"HL"+$80 DM "LD",OSEP,"SP, HL"+$80 EDASSTBL: DM "I, A"+$80 ; Already prefixed by LD DM "R, A"+$80 ; " DM "A, I"+$80 ; " DM "A, R"+$80 ; " DM "RRD"+$80 DM "RLD"+$80 DM "NOP"+$80 DM "NOP"+$80 SLD: DM "LD"+$80 SHALT: DM "HALT"+$80 SNOP: DM "NOP"+$80 SDJNZ: DM "DJNZ"+$80 SEXAFAF:DM "EX",OSEP,"AF, AF'"+$80 SJR: DM "JR"+$80 SJP: DM "JP"+$80 SADDHL: DM "ADD",OSEP,"HL,"+$80 SINC: DM "INC"+$80 SDEC: DM "DEC"+$80 SPOP: DM "POP"+$80 SOUT: DM "OUT",OSEP,"("+$80 SEOUT: DM "), A"+$80 SIN: DM "IN",OSEP,"A, ("+$80 SINP: DM "IN"+$80 SEBKT: DM ")"+$80 SCALL: DM "CALL"+$80 SPUSH: DM "PUSH"+$80 SNEG: DM "NEG"+$80 SRETI: DM "RETI"+$80 SRETN: DM "RETN"+$80 SIM: DM "IM"+$80 SBIT: DM "BIT"+$80 SRES: DM "RES"+$80 SSET: DM "SET"+$80 SINVAL: DM "INVALID"+$80 SNONI: DM "NONI"+$80 SBKTC: DM ")" ; Fall into SCOMMA SCOMMA: DM ","+$80 SRESET: DM "RST"+$80 SLDIN: DM "LD",OSEP,"("+$80 SLDHLIN:DM "LD",OSEP,"HL, ("+$80 SLDAIN: DM "LD",OSEP,"A" ; Fall into SCOMBKT SCOMBKT:DM ", ("+$80 SEHL: DM "), HL"+$80 SEA: DM "), A"+$80 SINNOC: DM "IN",OSEP,"(C)"+$80 SINDC: DM "(C)"+$80 SOUTNOC:DM "OUT",OSEP,"(C), 0"+$80 SOUTC: DM "OUT",OSEP,"(C),"+$80 SSBCHL: DM "SBC",OSEP,"HL,"+$80 SADCHL: DM "ADC",OSEP,"HL,"+$80 SBKTI: DM "(I"+$80 AAF: DM "RLCA"+$80 DM "RRCA"+$80 DM "RLA"+$80 DM "RRA"+$80 DM "DAA"+$80 DM "CPL"+$80 DM "SCF"+$80 DM "CCF"+$80 REG8: DM "B"+$80 DM "C"+$80 DM "D"+$80 DM "E"+$80 DM "H"+$80 DM "L"+$80 DM "(HL)"+$80 DM "A"+$80 REG16: SBC: DM "BC"+$80 SDE: DM "DE"+$80 DM "HL"+$80 DM "SP"+$80 REG16_2: DM "BC"+$80 DM "DE"+$80 DM "HL"+$80 DM "AF"+$80 CC: DM "NZ"+$80 DM "Z"+$80 DM "NC"+$80 DM "C"+$80 DM "PO"+$80 DM "PE"+$80 DM "P"+$80 DM "M"+$80 ALU: DM "ADD",OSEP,"A, "+$80 DM "ADC",OSEP,"A, "+$80 DM "SUB",OSEP+$80 DM "SBC",OSEP,"A, "+$80 DM "AND",OSEP+$80 DM "XOR",OSEP+$80 DM "OR",OSEP+$80 DM "CP",OSEP+$80 ROT: DM "RLC",OSEP+$80 DM "RRC",OSEP+$80 DM "RL",OSEP+$80 DM "RR",OSEP+$80 DM "SLA",OSEP+$80 DM "SRA",OSEP+$80 DM "SLL",OSEP+$80 DM "SRL",OSEP+$80 IM: DM "0"+$80 DM "0/1"+$80 DM "1"+$80 DM "2"+$80 DM "0"+$80 DM "0/1"+$80 DM "1"+$80 DM "2"+$80 BLI: DM "LDI"+$80 ; Y = 4 DM "CPI"+$80 DM "INI"+$80 DM "OUTI"+$80 DM "LDD"+$80 ; Y = 5 DM "CPD"+$80 DM "IND"+$80 DM "OUTD"+$80 DM "LDIR"+$80 ; Y = 6 DM "CPIR"+$80 DM "INIR"+$80 DM "OTIR"+$80 DM "LDDR"+$80 ; Y = 7 DM "CPDR"+$80 DM "INDR"+$80 DM "OTDR"+$80 #endlocal DISASSLEN equ . - DISINST
elan520-programmable_address_region.ads
Jellix/elan520
0
21142
------------------------------------------------------------------------ -- Copyright (C) 2004-2020 by <<EMAIL>> -- -- -- -- This work is free. You can redistribute it and/or modify it under -- -- the terms of the Do What The Fuck You Want To Public License, -- -- Version 2, as published by Sam Hocevar. See the LICENSE file for -- -- more details. -- ------------------------------------------------------------------------ pragma License (Unrestricted); ------------------------------------------------------------------------ -- AMD Élan(tm) SC 520 embedded microprocessor -- -- MMCR -> Programmable Address Region Registers (PAR) -- ------------------------------------------------------------------------ with Elan520.Basic_Types; package Elan520.Programmable_Address_Region is -- type for Target of definition in a programmable address region type Window_Target is (Window_Disabled, -- no memory window GP_Bus_IO, -- GP bus I/O access GP_Bus_Memory, -- GP bus memory access PCI_Bus, -- access to PCI bus Boot_CS, -- Boot ROM ChipSelect Rom_CS_1, -- Rom Area 1 Chipselect Rom_CS_2, -- Rom Area 2 Chipselect SD_Ram); -- SDRAM type access -- its hardware representation for Window_Target use (Window_Disabled => 2#000#, GP_Bus_IO => 2#001#, GP_Bus_Memory => 2#010#, PCI_Bus => 2#011#, Boot_CS => 2#100#, Rom_CS_1 => 2#101#, Rom_CS_2 => 2#110#, SD_Ram => 2#111#); for Window_Target'Size use 3; -- the ATTR bits in the PAR register when type is memory type Memory_Attribute is record Write_Protected : Basic_Types.Positive_Bit; Cacheable : Basic_Types.Negative_Bit; Executable : Basic_Types.Negative_Bit; end record; -- its hardware representation for Memory_Attribute use record Write_Protected at 0 range 0 .. 0; Cacheable at 0 range 1 .. 1; Executable at 0 range 2 .. 2; end record; for Memory_Attribute'Size use 3; -- the ATTR bits in the PAR register when type is I/O -- just raises the GP_IO_CS signals 0 through 7 type Chip_Select_Signal is range 0 .. 7; for Chip_Select_Signal'Size use 3; type Page_Size is (Four_Ki_Byte, Sixty_Four_Ki_Byte); for Page_Size use (Four_Ki_Byte => 0, Sixty_Four_Ki_Byte => 1); for Page_Size'Size use 1; -- IO pages, granularity is 1 byte, size max. 512 bytes type IO_Page_Start_Address is range 0 .. 2**16 - 1; type IO_Page_Region_Size is range 1 .. 2**9; type IO_Page is record Start_Address : IO_Page_Start_Address; Region_Size : IO_Page_Region_Size; end record; -- its hardware representation for IO_Page use record Start_Address at 0 range 0 .. 15; Region_Size at 0 range 16 .. 24; end record; for IO_Page'Size use 25; -- "small" memory pages (128 * 4 Ki => 512 KiBytes) type Mem_Page_4Ki_Start_Address is range 0 .. 2**18 - 1; type Mem_Page_4Ki_Region_Size is range 1 .. 2**7; type Mem_Page_4Ki is record -- start address in 4 Ki blocks (means, the value here reflects -- address lines A12 - A29 (18 bits)) Start_Address : Mem_Page_4Ki_Start_Address; -- size of region in 4K blocks (7 bits => 128 max.) Region_Size : Mem_Page_4Ki_Region_Size; end record; -- its hardware representation for Mem_Page_4Ki use record Start_Address at 0 range 0 .. 17; Region_Size at 0 range 18 .. 24; end record; for Mem_Page_4Ki'Size use 25; -- "large" memory pages (2048 * 64 Ki => max. 128 MiBytes) type Mem_Page_64Ki_Start_Address is range 0 .. 2**14 - 1; type Mem_Page_64Ki_Region_Size is range 1 .. 2**11; type Mem_Page_64Ki is record -- start address in 64 Ki blocks (means, the value here reflects -- A16 - A29 (14 bits)) Start_Address : Mem_Page_64Ki_Start_Address; Region_Size : Mem_Page_64Ki_Region_Size; end record; -- its hardware representation for Mem_Page_64Ki use record Start_Address at 0 range 0 .. 13; Region_Size at 0 range 14 .. 24; end record; for Mem_Page_64Ki'Size use 25; -- type for a programmable address region register type Programmable_Address_Region ( Target : Window_Target := Window_Disabled; Pg_Sz : Page_Size := Four_Ki_Byte) is record case Target is when Window_Disabled => null; when GP_Bus_IO | PCI_Bus => IO_Attr : Chip_Select_Signal; Sz_St_Addr_IO : IO_Page; when GP_Bus_Memory | Boot_CS | Rom_CS_1 | Rom_CS_2 | SD_Ram => Mem_Attr : Memory_Attribute; case Pg_Sz is when Four_Ki_Byte => Sz_St_Addr_4Ki : Mem_Page_4Ki; when Sixty_Four_Ki_Byte => Sz_St_Addr_64Ki : Mem_Page_64Ki; end case; end case; end record; -- its hardware representation PROGRAMMABLE_ADDRESS_REGION_SIZE : constant := 32; for Programmable_Address_Region use record -- discriminants Target at 0 range 29 .. 31; Pg_Sz at 0 range 25 .. 25; -- variable parts depending on discriminants -- I/O type memory regions IO_Attr at 0 range 26 .. 28; Sz_St_Addr_IO at 0 range 0 .. 24; -- memory type memory regions Mem_Attr at 0 range 26 .. 28; Sz_St_Addr_4Ki at 0 range 0 .. 24; Sz_St_Addr_64Ki at 0 range 0 .. 24; end record; for Programmable_Address_Region'Size use PROGRAMMABLE_ADDRESS_REGION_SIZE; pragma Atomic (Programmable_Address_Region); PAR_ENTRIES : constant := 16; PAR_INFO_SIZE : constant := PAR_ENTRIES * PROGRAMMABLE_ADDRESS_REGION_SIZE; MMCR_OFFSET_PAR_INFO : constant := 16#88#; type PAR_Info is array (0 .. PAR_ENTRIES - 1) of Programmable_Address_Region; for PAR_Info'Size use PAR_INFO_SIZE; end Elan520.Programmable_Address_Region;
libsrc/_DEVELOPMENT/adt/w_vector/c/sccz80/w_vector_back.asm
teknoplop/z88dk
8
21422
; void *w_vector_back(b_vector_t *v) SECTION code_clib SECTION code_adt_w_vector PUBLIC w_vector_back EXTERN asm_w_vector_back defc w_vector_back = asm_w_vector_back
libsrc/_DEVELOPMENT/arch/ts2068/misc/z80/asm_tshc_scroll_wc_up_pix.asm
jpoikela/z88dk
640
29073
; =============================================================== ; 2017 ; =============================================================== ; ; void tshc_scroll_wc_up_pix(struct r_Rect8 *r, uchar rows, uchar pix) ; ; Scroll the rectangular area upward by rows characters. ; Clear the vacated area. ; ; =============================================================== SECTION code_clib SECTION code_arch PUBLIC asm_tshc_scroll_wc_up_pix PUBLIC asm0_tshc_scroll_wc_up_pix EXTERN asm_zx_scroll_wc_up_pix EXTERN asm0_zx_scroll_wc_up_pix defc asm_tshc_scroll_wc_up_pix = asm_zx_scroll_wc_up_pix defc asm0_tshc_scroll_wc_up_pix = asm0_zx_scroll_wc_up_pix ; enter : de = number of rows to scroll upward by ; l = screen byte ; ix = rect * ; ; uses : af, bc, de, hl
src/halfbox_info.ads
SKNZ/BoiteMaker
0
28283
<filename>src/halfbox_info.ads package halfbox_info is type halfbox_info_t is record -- longueur de la demi boite length : integer; -- largeur de la demi boite width : integer; -- hauteur de la demi boite height : integer; -- epaisseur des planches thickness : integer; -- longueur des queues queue_length : integer; end record; function to_string (halfbox_info : halfbox_info_t) return string; end halfbox_info;
data/pokemon/base_stats/gyarados.asm
AtmaBuster/pokeplat-gen2
6
91874
<filename>data/pokemon/base_stats/gyarados.asm db 0 ; species ID placeholder db 95, 125, 79, 81, 60, 100 ; hp atk def spd sat sdf db WATER, FLYING ; type db 45 ; catch rate db 214 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 5 ; step cycles to hatch INCBIN "gfx/pokemon/gyarados/front.dimensions" db GROWTH_SLOW ; growth rate dn EGG_WATER_2, EGG_DRAGON ; egg groups db 70 ; happiness ; tm/hm learnset tmhm WATER_PULSE, ROAR, TOXIC, HAIL, HIDDEN_POWER, TAUNT, ICE_BEAM, BLIZZARD, HYPER_BEAM, PROTECT, RAIN_DANCE, FRUSTRATION, THUNDERBOLT, THUNDER, EARTHQUAKE, RETURN, DOUBLE_TEAM, FLAMETHROWER, SANDSTORM, FIRE_BLAST, TORMENT, FACADE, SECRET_POWER, REST, ATTRACT, BRINE, ENDURE, DRAGON_PULSE, PAYBACK, GIGA_IMPACT, STONE_EDGE, AVALANCHE, THUNDER_WAVE, CAPTIVATE, DARK_PULSE, SLEEP_TALK, NATURAL_GIFT, SWAGGER, SUBSTITUTE, SURF, STRENGTH, ROCK_SMASH, WATERFALL, AQUA_TAIL, BOUNCE, DIVE, ICY_WIND, IRON_HEAD, OUTRAGE, SNORE, SPITE, TWISTER, UPROAR ; end
libsrc/_DEVELOPMENT/math/float/math48/z80/am48_dconst_0.asm
meesokim/z88dk
0
20183
SECTION code_fp_math48 PUBLIC am48_dconst_0 EXTERN mm48__zero_no ; set AC = 0 ; ; uses : bc, de, hl defc am48_dconst_0 = mm48__zero_no
sharding-core/src/main/antlr4/imports/SQLServerTableBase.g4
chuanandongxu/sharding-sphere
0
5848
grammar SQLServerTableBase; import SQLServerKeyword,Keyword,Symbol,SQLServerBase,BaseRule,DataType; columnDefinition : columnName dataType columnDefinitionOption* (columnConstraint(COMMA columnConstraint)*)? columnIndex? ; columnDefinitionOption : FILESTREAM | COLLATE collationName | SPARSE | MASKED WITH LP_ FUNCTION EQ_ STRING RP_ | (CONSTRAINT constraintName)? DEFAULT expr | IDENTITY (LP_ NUMBER COMMA NUMBER RP_ )? | NOT FOR REPLICATION | GENERATED ALWAYS AS ROW (START | END) HIDDEN_? | NOT? NULL | ROWGUIDCOL | ENCRYPTED WITH LP_ COLUMN_ENCRYPTION_KEY EQ_ keyName COMMA ENCRYPTION_TYPE EQ_ ( DETERMINISTIC | RANDOMIZED ) COMMA ALGORITHM EQ_ STRING RP_ | columnConstraint (COMMA columnConstraint)* | columnIndex ; columnConstraint : (CONSTRAINT constraintName)? ( primaryKeyConstraint | columnForeignKeyConstraint | checkConstraint ) ; primaryKeyConstraint : (primaryKey | UNIQUE) (diskTablePrimaryKeyConstraintOption | memoryTablePrimaryKeyConstraintOption) ; diskTablePrimaryKeyConstraintOption : (CLUSTERED | NONCLUSTERED)? primaryKeyWithClause? primaryKeyOnClause? ; columnForeignKeyConstraint : (FOREIGN KEY)? REFERENCES tableName LP_ columnName RP_ foreignKeyOnAction* ; foreignKeyOnAction : ON DELETE foreignKeyOn | ON UPDATE foreignKeyOn | NOT FOR REPLICATION ; foreignKeyOn : NO ACTION | CASCADE | SET NULL | SET DEFAULT ; memoryTablePrimaryKeyConstraintOption : CLUSTERED withBucket? ; hashWithBucket : HASH columnList withBucket ; withBucket : WITH LP_ BUCKET_COUNT EQ_ NUMBER RP_ ; primaryKeyWithClause : WITH ((FILLFACTOR EQ_ NUMBER) | (LP_ indexOption (COMMA indexOption)* RP_) ) ; primaryKeyOnClause : onSchemaColumn | onFileGroup | onString ; onSchemaColumn : ON schemaName LP_ columnName RP_ ; onFileGroup : ON fileGroup ; onString : ON STRING ; checkConstraint: CHECK(NOT FOR REPLICATION)? LP_ expr RP_ ; columnIndex : INDEX indexName ( CLUSTERED | NONCLUSTERED )? ( WITH LP_ indexOption (COMMA indexOption)* RP_ )? indexOnClause? ( FILESTREAM_ON ( fileGroup | schemaName | STRING ) )? ; indexOnClause : onSchemaColumn | onFileGroup | onDefault ; onDefault : ON DEFAULT ; tableConstraint : (CONSTRAINT constraintName)? ( tablePrimaryConstraint | tableForeignKeyConstraint | checkConstraint ) ; tablePrimaryConstraint : primaryKeyUnique (diskTablePrimaryConstraintOption | memoryTablePrimaryConstraintOption) ; primaryKeyUnique : primaryKey | UNIQUE ; diskTablePrimaryConstraintOption : (CLUSTERED | NONCLUSTERED)? columnList primaryKeyWithClause? primaryKeyOnClause? ; memoryTablePrimaryConstraintOption : NONCLUSTERED (columnList | hashWithBucket) ; tableForeignKeyConstraint : (FOREIGN KEY)? columnList REFERENCES tableName columnList foreignKeyOnAction* ; computedColumnDefinition : columnName AS expr (PERSISTED( NOT NULL )?)? columnConstraint? ; columnSetDefinition : columnSetName ID COLUMN_SET FOR ALL_SPARSE_COLUMNS ;
proofs/AKS/Modular/Quotient.agda
mckeankylej/thesis
1
5889
<reponame>mckeankylej/thesis module AKS.Modular.Quotient where open import AKS.Modular.Quotient.Base public open import AKS.Modular.Quotient.Properties public
programs/oeis/157/A157142.asm
neoneye/loda
22
104114
; A157142: Signed denominators of Leibniz series for Pi/4. ; 1,-3,5,-7,9,-11,13,-15,17,-19,21,-23,25,-27,29,-31,33,-35,37,-39,41,-43,45,-47,49,-51,53,-55,57,-59,61,-63,65,-67,69,-71,73,-75,77,-79,81,-83,85,-87,89,-91,93,-95,97,-99,101,-103,105,-107,109,-111,113,-115,117,-119,121,-123,125,-127,129,-131,133,-135,137,-139,141,-143,145,-147,149,-151,153,-155,157,-159,161,-163,165,-167,169,-171,173,-175,177,-179,181,-183,185,-187,189,-191,193,-195,197,-199 mov $1,-2 bin $1,$0 div $1,2 mul $1,4 add $1,1 mov $0,$1
data/pokemon/base_stats/hoenn/illumise.asm
Dev727/ancientplatinum
0
12320
db 0 ; 314 DEX NO db 65, 47, 55, 85, 73, 75 ; hp atk def spd sat sdf db BUG, BUG ; type db 150 ; catch rate db 146 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F100 ; gender ratio db 100 ; unknown 1 db 15 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/hoenn/illumise/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_FLUCTUATING ; growth rate dn EGG_BUG, EGG_HUMANSHAPE ; egg groups ; tm/hm learnset tmhm ; end
programs/oeis/318/A318935.asm
karttu/loda
1
1632
; A318935: a(n) = Sum_{2^m divides n} 2^(3*m). ; 1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,4681,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,37449,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,4681,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,299593,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,4681,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,37449,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,4681,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,2396745,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,4681,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,37449,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,4681,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,299593,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,4681,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,37449,1,9,1,73,1,9,1,585,1,9,1,73,1,9,1,4681,1,9,1,73,1,9,1,585,1,9 add $0,1 mul $0,2 gcd $0,1073741824 pow $0,3 mov $1,$0 div $1,7
oeis/100/A100165.asm
neoneye/loda-programs
11
8140
<reponame>neoneye/loda-programs ; A100165: Structured rhombic triacontahedral numbers (vertex structure 7). ; 1,32,147,400,845,1536,2527,3872,5625,7840,10571,13872,17797,22400,27735,33856,40817,48672,57475,67280,78141,90112,103247,117600,133225,150176,168507,188272,209525,232320,256711,282752,310497,340000,371315,404496,439597,476672,515775,556960,600281,645792,693547,743600,796005,850816,908087,967872,1030225,1095200,1162851,1233232,1306397,1382400,1461295,1543136,1627977,1715872,1806875,1901040,1998421,2099072,2203047,2310400,2421185,2535456,2653267,2774672,2899725,3028480,3160991,3297312,3437497 mul $0,6 add $0,2 mov $2,$0 mov $3,$0 add $0,4 mul $2,$3 mul $0,$2 div $0,24
fluidcore/samples/tri-v4.asm
bushy555/ZX-Spectrum-1-Bit-Routines
59
247645
db 0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 4,4,4,4,4,4,4,4 db 4,4,4,4,4,4,4,4 db 4,4,4,4,4,4,4,4 db 4,4,4,4,4,4,4,4 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1
programs/oeis/122/A122471.asm
jmorken/loda
1
93366
<gh_stars>1-10 ; A122471: a(n)=7*a(n-1)-n for n> 0, a(0)=1. ; 1,6,40,277,1935,13540,94774,663411,4643869,32507074,227549508,1592846545,11149925803,78049480608,546346364242,3824424549679,26770971847737,187396802934142,1311777620538976,9182443343772813 mov $2,$0 mov $0,10 mov $1,10 lpb $2 add $1,$0 mul $0,7 sub $0,2 sub $2,1 lpe sub $1,10 div $1,2 add $1,1
Library/SpecUI/ISUI/Win/winDraw.asm
steakknife/pcgeos
504
7470
COMMENT @---------------------------------------------------------------------- Copyright (c) GeoWorks 1988 -- All Rights Reserved PROJECT: PC GEOS MODULE: ISUI/Win FILE: winDraw.asm ROUTINES: Name Description ---- ----------- WinDrawBoxFrame draw 2 color LT/RB frame OpenWinCheckIfBordered test if window has a border OpenWinGetBounds gets bounds for object OpenWinGetInsideBorderBounds gets bounds inside the border OpenWinGetHeaderBounds gets bounds of header OpenWinInitGState sets up font, etc. info in GState OpenWinDraw MSG_VIS_DRAW handler for OLWinClass OpenWinDrawWindowBorder draws window border OpenWinDrawHeaderTitleBackground draws background behind title OpenWinDrawHeaderTitle draws title text REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 8/89 Initial version Eric 9/89 moved from CommonUI/CWin since 90% of file is specific-ui dependent. DESCRIPTION: This file contains procedures for the DRAW method of OLWinClass. $Id: winDraw.asm,v 1.2 98/05/04 06:15:03 joon Exp $ ------------------------------------------------------------------------------@ WinCommon segment resource COMMENT @---------------------------------------------------------------------- FUNCTION: WinDrawBoxFrame DESCRIPTION: Draws a frame at the bounds passed. If the display type is B&W, then it will just draw a frame. If it's a color display, then it will draw a "shadowed" frame in 2 colors. PASS: ax, bx, cx, dx - GrFillRect-style bounds of the rectangle di - GState to use bp-low - <rightBottom color><topLeft color> bp-high - display type RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- Chris 4/91 Updated for new graphics, bounds conventions ------------------------------------------------------------------------------@ WinDrawBoxFrame proc near uses ax, bx, bp .enter xchg ax, bp ;put colors in al cmp ah, DC_GRAY_1 ;is this a B@W display? jnz color ;skip if not... mov ax, (C_BLACK shl 8) or C_BLACK ;else use all black for frame jmp draw color: mov ah, al andnf al, mask CS_darkColor ;al <- dark color andnf ah, mask CS_lightColor ;ah <- light color shr ah, 1 shr ah, 1 shr ah, 1 shr ah, 1 draw: xchg bp, ax ;back in bp call OpenDrawRect ;draw a framed rectangle .leave ret WinDrawBoxFrame endp COMMENT @---------------------------------------------------------------------- FUNCTION: OpenWinCheckIfBordered DESCRIPTION: Check if window is bordered PASS: *ds:si = OLWinClass object ds:bp = OLWinClass instance data RETURN: carry set if bordered DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- Gene 2/15/02 Initial version ------------------------------------------------------------------------------@ OpenWinCheckIfBordered proc near ; If window is maximized, then no border test ds:[bp].OLWI_specState, mask OLWSS_MAXIMIZED jnz done ; exit with carry clear ; If custom window, then no border test ds:[bp].OLWI_moreFixedAttr, mask OWMFA_CUSTOM_WINDOW jnz done ; exit with carry clear stc ; window has border done: ret OpenWinCheckIfBordered endp COMMENT @---------------------------------------------------------------------- FUNCTION: OpenWinGetBounds OpenWinGetInsideBorderBounds DESCRIPTION: These procedures return the bounds for an aspect of the window. PASS: *ds:si = instance data for object ds:bp = instance data for object RETURN: (ax, bx) - (cx, dx) = bounds ds, si, di, bp = same DESTROYED: NOTHING PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- Eric 1/90 initial version Chris 4/91 Updated for new graphics, bounds conventions ------------------------------------------------------------------------------@ ;This procedure gets the boundary coordinates of the window, relative to itself OpenWinGetBounds proc near ;we cannot use VisGetBounds because this object is a WINDOWED object. call VisGetSize clr ax clr bx ret OpenWinGetBounds endp ;CUAS: the bounds returned do not include the border area. OpenWinGetInsideBorderBounds proc near class OLWinClass call OpenWinGetBounds call OpenWinCheckIfBordered jnc done ; 4 pixel border for all other windows add ax, 4 add bx, 4 sub cx, 4 sub dx, 4 done: ret OpenWinGetInsideBorderBounds endp COMMENT @---------------------------------------------------------------------- FUNCTION: OpenWinGetHeaderBounds DESCRIPTION: This procedure returns the bounds of the header area of an OLWinClass object. Note that in CUA and Motif we place the header ON the frame line of the window. CALLED BY: utility PASS: ds:*si - handle of instance data ds:bp - pointer to instance data RETURN: (ax, bx, cx, dx) = bounds DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- Eric 9/89 split from OpenLook code. Chris 4/91 Updated for new graphics, bounds conventions ------------------------------------------------------------------------------@ OpenWinGetHeaderBounds proc near class OLWinClass call OpenWinGetInsideBorderBounds push ds segmov ds, <segment dgroup>, dx mov dx, ds:[specDisplayScheme].DS_pointSize pop ds ;Header is on top of window frame line, so don't change left, right, ;or top coordinates here if _GCM test ds:[bp].OLWI_fixedAttr, mask OWFA_GCM_TITLED jnz 50$ endif clr dh add dx, bx ;add top add dx, CUAS_WIN_HEADER_Y_SPACING ;add margin ; ; If it's a CGA display, use a smaller header height call OpenWinCheckIfSquished jnc done sub dx, (CUAS_WIN_HEADER_Y_SPACING - CUAS_CGA_WIN_HEADER_Y_SPACING) ret if _GCM 50$: ;for GCM headers: ignore font size (for now) mov dx, CUAS_GCM_HEADER_HEIGHT call OpenWinCheckIfSquished jnc done mov dx, CUAS_GCM_CGA_HEADER_HEIGHT endif done: ret OpenWinGetHeaderBounds endp COMMENT @---------------------------------------------------------------------- METHOD: OpenWinDraw -- MSG_VIS_DRAW for OLWinClass DESCRIPTION: This procedure is called when PASS: ds:*si - instance data es - segment of zzzClass ax - MSG_ cx, dx - ? bp - handle of GState RETURN: cl - DrawFlags: DF_EXPOSED set if updating ch - ? dx - ? bp - GState to use DESTROYED: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 3/89 Initial version Eric 7/89 more documentation, Motif extensions ------------------------------------------------------------------------------@ OpenWinDraw method dynamic OLWinClass, MSG_VIS_DRAW mov di, bp ;di = GState call OpenWinInitGState ;(al = color scheme, ah = display type, cl = DrawFlags) call OpenWinDrawWindowBorder ;draw the header area ; ds:bp = specific instance data for object ; di = gstate test ds:[bp].OLWI_attrs, mask OWA_TITLED jz OWD_noHeader if not NORMAL_HEADERS_ON_DISABLED_WINDOWS ; only 50% if disabling headers test ds:[bp].VI_attrs, mask VA_FULLY_ENABLED jnz OWD_drawHeader mov al, SDM_50 ; else draw everything 50% call GrSetTextMask call GrSetLineMask OWD_drawHeader: endif call OpenWinDrawHeaderTitleBackground call OpenWinDrawHeaderTitle ;Draw window title mov al, SDM_100 ; else draw everything 100% call GrSetTextMask call GrSetLineMask OWD_noHeader: mov bp, di ;bp = GState ;Then call parent class, to do children push bp, cx mov ax, MSG_VIS_DRAW mov di, segment VisCompClass mov es, di mov di, offset VisCompClass call ObjCallClassNoLock pop di, cx ; If we didn't draw children, at least draw title bar children test cl, mask DF_DONT_DRAW_CHILDREN jz gotChildren call DrawTitleChildren gotChildren: ; Darken background if necessary mov bp, ds:[si] add bp, ds:[bp].Vis_offset test ds:[bp].OLWI_moreFixedAttr, mask OMWFA_DRAW_DISABLED jz done call OpenWinDarkenWindow done: ret OpenWinDraw endp OpenWinDarkenWindow proc far uses si .enter mov si, WIT_COLOR call WinGetInfo ornf ah, mask WCF_DRAW_MASK or mask WCF_MASKED call WinSetInfo push ax, bx mov ax, C_BLACK call GrSetAreaColor call GrGetMaskBounds call GrFillRect pop ax, bx andnf ah, not mask WCF_DRAW_MASK call WinSetInfo done: .leave ret OpenWinDarkenWindow endp ; ; stripped down version of VisCompClass MSG_VIS_DRAW ; DTC_frame struct DTC_theBottom word DTC_frame ends DTC_vars equ <ss:[bp-(size DTC_frame)]> DTC_bottom equ <DTC_vars.DTC_theBottom> DrawTitleChildren proc near class VisCompClass uses bx, cx, si, di, es .enter mov bp, di ; bp = gstate andnf cl, not mask DF_DONT_DRAW_CHILDREN mov di, ds:[si] ; get offset to composite in si add di, ds:[di].Vis_offset ;ds:di = VisInstance ; make sure composite is drawable test ds:[di][VI_attrs], mask VA_DRAWABLE jz VCD_done ; if it isn't, skip drawing altogether test cl, mask DF_PRINT jnz 10$ ; make sure composite is realized test ds:[di][VI_attrs], mask VA_REALIZED jz VCD_done ; if it isn't, skip drawing altogether test ds:[di].VCI_geoAttrs, mask VCGA_ONLY_DRAWS_IN_MARGINS jnz 10$ ; IMAGE_INVALID only covers margins, must ; continue -cbh 12/17/91 test ds:[di].VI_optFlags, mask VOF_IMAGE_INVALID jnz VCD_done ; if not, skip drawing it 10$: ; allocate frame on the stack to hold update bounds push bp ;save gstate mov di,bp ;di = gstate mov bp,sp sub sp, size DTC_frame push cx call OpenWinGetHeaderTitleBounds ; dx = title bottom mov DTC_bottom,dx pop cx mov dx,di ; pass gstate in dx clr bx ; initial child (first push bx ; child of push bx ; composite) mov bx,offset VI_link ;pass offset to LinkPart push bx NOFXIP < push cs ;pass callback routine > FXIP < mov bx, SEGMENT_CS > FXIP < push bx > mov bx,offset DTC_callBack push bx mov di,offset VCI_comp mov bx,offset Vis_offset mov ax, MSG_VIS_DRAW call ObjCompProcessChildren ;must use a call (no GOTO) since ;parameters are passed on the stack VCD_noDraw: mov sp,bp pop bp ;gstate VCD_done: .leave ret DrawTitleChildren endp DTC_callBack proc far class VisCompClass ; Tell Esp we're a friend of VisComp ; so we can use its instance data. mov di, ds:[si] add di, ds:[di].Vis_offset test ds:[di].VI_attrs, mask VA_DRAWABLE jz done test ds:[di].VI_attrs, mask VA_REALIZED jz done test ds:[di].VI_typeFlags, mask VTF_IS_COMPOSITE jz 5$ ; not a composite, check invalid test ds:[di].VCI_geoAttrs, mask VCGA_ONLY_DRAWS_IN_MARGINS jnz 10$ ; must skip invalid check in case one or ; more of our children are valid. 5$: ; make sure that image is valid test ds:[di].VI_optFlags, mask VOF_IMAGE_INVALID jnz done ; if not, skip drawing it 10$: ; make sure child isn't a window ; (makes no sense. removed.cbh 12/13/91) ; test ds:[di].VI_typeFlags, mask VTF_IS_WINDOW ; jnz noDraw ; if it is, skip sending draw to it ; IF bounds still in initial state, & haven't been set, don't draw mov ax, ds:[di].VI_bounds.R_left mov bx, ds:[di].VI_bounds.R_right cmp ax,bx jge done ; skip if width 0 or less ; test the bounds mov ax, ds:[di].VI_bounds.R_bottom cmp ax, DTC_bottom ; if obj.bottom > title.bottom jg done push cx ; preserve DrawFlags push dx ; preserve GState handle push bp mov bp,dx ; pass gstate in bp mov ax, MSG_VIS_DRAW call ObjCallInstanceNoLockES ; send DRAW pop bp pop dx pop cx done: clc ret DTC_callBack endp COMMENT @---------------------------------------------------------------------- FUNCTION: OpenWinInitGState DESCRIPTION: Initialize the current GState before using it to draw CALLED BY: OpenWinDraw, OLBaseWinDrawHeaderIcons PASS: *ds:si - object di - gstate RETURN: bp - offset to Spec data in object al = color scheme, ah = display type bx, dx - private info DESTROYED: REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 11/89 Initial version ------------------------------------------------------------------------------@ OpenWinInitGState proc near mov bp, ds:[si] ;ds:bp = instance add bp, ds:[bp].Vis_offset ;ds:bp = SpecificInstance ;get display scheme data push cx mov ax, GIT_PRIVATE_DATA call GrGetInfo ;ax = <display scheme><display type> ;cx = font to use ;ah:dx = point size push ax clr ah ;no fractional pointsize call GrSetFont pop ax ;get display info pop cx and ah, mask DF_DISPLAY_TYPE cmp ah, DC_GRAY_1 ;is this a B&W display? jnz color ;skip if not... mov al, (C_WHITE shl 4) or C_BLACK ;use black and white color: ret OpenWinInitGState endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% OpenWinDrawWindowBorder %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw a border around window CALLED BY: OpenWinDraw PASS: ds:*si - instance data ds:bp - pointer to instance data es - segment of OLWinClass ax - color scheme, display type cx - draw flags di - handle of GState RETURN: nothing DESTROYED: bx, dx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Gene 2/15/02 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ OpenWinDrawWindowBorder proc near class OLWinClass uses ax, cx, si, bp ;preserve color scheme, draw flags .enter ; Nothing to draw if window doesn't have a border call OpenWinCheckIfBordered jnc done ; Determine the color scheme to use mov bx, ax mov al, ColorScheme <C_BLACK, C_LIGHT_GRAY> mov bl, ColorScheme <C_DARK_GRAY, C_WHITE> push bx ;Save display type/inner border color push ax ;save display type/outer border color call OpenWinGetBounds pop bp ;restore outer border color call WinDrawBoxFrame ;draw outer border inc ax ;adjust bounds for inner border inc bx ;adjust bounds for inner border dec cx ;adjust bounds for inner border dec dx ;adjust bounds for inner border pop bp ;restore inner border color call WinDrawBoxFrame ;draw inner border mov ax, C_BLACK call GrSetLineColor done: .leave ret OpenWinDrawWindowBorder endp COMMENT @---------------------------------------------------------------------- FUNCTION: OpenWinDrawHeaderTitleBackground DESCRIPTION: This procedure draws the background for the header area. CALLED BY: OpenWinDraw PASS: ds:*si - instance data ds:bp - pointer to instance data es - segment of OLWinClass ax - color scheme, display type cx - draw flags dx - ? di - handle of GState RETURN: nothing DESTROYED: bx, dx PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- Eric 10/89 initial version Chris 4/91 Updated for new graphics, bounds conventions ------------------------------------------------------------------------------@ OpenWinDrawHeaderTitleBackground proc near class OLWinClass uses bp, ax, cx, bp .enter ; ; Code added 2/ 6/92 to get rid of title on maximized windows. ; call OpenWinCheckMenusInHeader jc done ;menus in header, don't draw title ;reset some invalid flags for this window, to indicate that draw ;has occurred. mov cl, mask OLWHS_HEADER_AREA_INVALID or \ mask OLWHS_FOCUS_AREA_INVALID or \ mask OLWHS_TITLE_AREA_INVALID call OpenWinHeaderResetInvalid ;see if this window has a title test ds:[bp].OLWI_attrs, mask OWA_TITLED jz done ;skip if not... ;depending upon whether this window has the focus, choose one ;of two TitleBarBackground colors push ds ;save segment of object block mov bx, segment idata ;get segment of core blk mov ds, bx mov bh, ds:[moCS_inactiveTitleBar] mov bl, ds:[moCS_activeTitleBar] pop ds call OpenWinTestForFocusAndTarget test ax, mask HGF_SYS_EXCL pushf mov al, bl jnz haveColor mov al, bh haveColor: clr ah call GrSetAreaColor call OpenWinGetBounds call OpenWinCheckIfBordered jnc 10$ add ax, 4 ;4 pixel offset sub cx, 4 ;4 pixel offset 10$: push ax, cx call OpenWinGetHeaderTitleBounds pop ax, cx ; ; see if we should draw a gradient or not ; push ax, ds mov ax, segment idata mov ds, ax mov al, ds:[moCS_activeTitleBar] cmp al, ds:[moCS_titleBar2] pop ax, ds jne drawGradient normalDraw:: call GrFillRect afterDraw: popf jnz done call OpenCheckIfBW jnc done dec cx dec dx call GrDrawRect ;draw rect for BW if not target done: .leave ret drawGradient: popf pushf push si, ax call DrawGradientTitle pop si, ax jmp afterDraw OpenWinDrawHeaderTitleBackground endp DrawGradientTitle proc near uses bx, cx, dx, ds locs local GradientLocals mov_tr si, ax ;si <- left bound lahf ;ah <- flags .enter mov ss:locs.GL_bounds.R_left, si mov ss:locs.GL_bounds.R_top, bx mov ss:locs.GL_bounds.R_right, cx mov ss:locs.GL_bounds.R_bottom, dx sahf mov ax, segment idata mov ds, ax mov al, ds:[moCS_activeTitleBar] jnz haveColor mov al, ds:[moCS_inactiveTitleBar] haveColor: mov dh, ds:[moCS_titleBar2] call DrawGradient .leave ret DrawGradientTitle endp COMMENT @---------------------------------------------------------------------- FUNCTION: OpenWinDrawHeaderTitle DESCRIPTION: This procedure draws the title for an OLWinClass object. CALLED BY: OpenWinDraw PASS: ds:*si - instance data ds:bp - pointer to instance data es - segment of OLWinClass ax - color scheme, display type cx - draw flags dx - ? di - handle of GState RETURN: nothing DESTROYED: bx, dx PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- Eric 10/89 initial version Chris 4/91 Updated for new graphics, bounds conventions ------------------------------------------------------------------------------@ CGA_TITLE_TEXT_Y_OFFSET = -1 GCM_CGA_TITLE_TEXT_Y_OFFSET = -1 TITLE_TEXT_Y_OFFSET = 2 GCM_TITLE_TEXT_Y_OFFSET = 6 ;for non CGA only OpenWinDrawHeaderTitle proc near class OLWinClass ; ; Code added 2/ 6/92 to get rid of title on maximized windows. ; call OpenWinCheckMenusInHeader LONG jc exit ;menus in header, don't draw title push ax, cx, bp, es ;preserve color scheme, draw flags ;and pointer to instance data EC < call GenCheckGenAssumption ;Make sure gen data exists > ;reset some invalid flags for this window, to indicate that draw ;has occurred. mov cl, mask OLWHS_TITLE_IMAGE_INVALID or \ mask OLWHS_FOCUS_AREA_INVALID call OpenWinHeaderResetInvalid test ds:[bp].OLWI_attrs, mask OWA_TITLED LONG jz done ;skip if not titled... ;CUA/Motif: grab color values from color scheme variables in idata call OpenWinTestForFocusAndTarget test ax, mask HGF_SYS_EXCL push ds mov ax, segment idata ;get segment of core blk mov ds, ax mov al, ds:[moCS_titleBarText] jnz 10$ mov al, C_LIGHT_GREY 10$: clr ah call GrSetTextColor pop ds xchg bp, di ;bp = GState, di = inst. data ;zFix; call OpenWinGCMSetTitleFontSize xchg bp, di ;di = GState, bp = inst. data call OpenWinGetHeaderTitleBounds ;get title bounds from ;instance data inc bx ;move inside top and bottom dec dx ;C_BLACK lines ;(ax, bx), (cx, dx) = coordinates for title area. ;Calculate size of text moniker. add ax, CUAS_TITLE_TEXT_MARGIN ;leave margin on left side sub cx, CUAS_TITLE_TEXT_MARGIN ;leave margin on right side sub cx, ax ;width of title area jns 20$ clr cx ;HACK 20$: test ds:[bp].OLWI_fixedAttr, mask OWFA_GCM_TITLED jz 30$ ;If not GCM, branch mov bx, GCM_TITLE_TEXT_Y_OFFSET-TITLE_TEXT_Y_OFFSET call OpenCheckIfCGA ;see if on CGA jnc 30$ ;not CGA, branch mov bx, GCM_CGA_TITLE_TEXT_Y_OFFSET-CGA_TITLE_TEXT_Y_OFFSET ;END HACK 30$: add bx, TITLE_TEXT_Y_OFFSET ; ; If it's a CGA display, compensate for a smaller header height push ax call OpenMinimizeIfCGA ;zeroes ax, sets CF if CGA pop ax jnc notCGA sub bx, (TITLE_TEXT_Y_OFFSET - CGA_TITLE_TEXT_Y_OFFSET) - 1 notCGA: sub sp, size DrawMonikerArgs ;make room for args mov bp, sp ;pass pointer in bp mov ss:[bp].DMA_gState, di ;pass gstate push di ;save it mov ss:[bp].DMA_xInset, ax ;pass x inset mov ss:[bp].DMA_yInset, bx ;and y inset mov ss:[bp].DMA_xMaximum, cx ;titlearea is max width mov ss:[bp].DMA_yMaximum, MAX_COORD ;don't clip Y mov cl, (J_LEFT shl offset DMF_X_JUST) or \ (J_LEFT shl offset DMF_Y_JUST) or \ mask DMF_CLIP_TO_MAX_WIDTH or \ mask DMF_TEXT_ONLY call OpenWinDrawMoniker ;draw it pop di ;restore gstate add sp, size DrawMonikerArgs ;dump args mov ax, C_BLACK ;reset text color call GrSetTextColor ;restore original point size mov bp, di ;zFix; call OpenWinGCMResetTitleFontSize done: pop ax, cx, bp, es ;get color scheme, draw flags exit: ;and pointer to instance data ret OpenWinDrawHeaderTitle endp WinCommon ends
out/aaa_04loop.adb
FardaleM/metalang
22
12604
<filename>out/aaa_04loop.adb with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C; use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C; procedure aaa_04loop is type stringptr is access all char_array; procedure PString(s : stringptr) is begin String'Write (Text_Streams.Stream (Current_Output), To_Ada(s.all)); end; procedure PInt(i : in Integer) is begin String'Write (Text_Streams.Stream (Current_Output), Trim(Integer'Image(i), Left)); end; function h(i : in Integer) return Boolean is j : Integer; begin -- for j = i - 2 to i + 2 do -- if i % j == 5 then return true end -- end j := i - 2; while j <= i + 2 loop if i rem j = 5 then return TRUE; end if; j := j + 1; end loop; return FALSE; end; j : Integer; i : Integer; begin j := 0; for k in integer range 0..10 loop j := j + k; PInt(j); PString(new char_array'( To_C("" & Character'Val(10)))); end loop; i := 4; while i < 10 loop PInt(i); i := i + 1; j := j + i; end loop; PInt(j); PInt(i); PString(new char_array'( To_C("FIN TEST" & Character'Val(10)))); end;
wof/lcs/base/1BC.asm
zengfr/arcade_game_romhacking_sourcecode_top_secret_data
6
98726
copyright zengfr site:http://github.com/zengfr/romhack 012A50 move.w #$140, ($1bc,A5) [base+1BA] 012A56 move.b #$3, ($1c7,A5) [base+1BC] 012AD2 move.w #$140, ($1bc,A5) [base+1BA] 012AD8 clr.b ($1c1,A5) [base+1BC] 012BE8 move.w #$140, ($1bc,A5) [base+1BA] 012BEE bra $12d8e [base+1BC] 012C0E bpl $12d8e [base+1BC] 012C7C clr.b ($1c3,A5) [base+1BC] 01A610 dbra D1, $1a60e copyright zengfr site:http://github.com/zengfr/romhack
Task/Literals-String/Ada/literals-string-1.ada
LaudateCorpus1/RosettaCodeData
1
29049
ch : character := 'a';
src/Categories/Category/Instance/Span.agda
Trebor-Huang/agda-categories
279
4550
<reponame>Trebor-Huang/agda-categories {-# OPTIONS --without-K --safe #-} -- https://ncatlab.org/nlab/show/span -- The colimit of a functor from this category is a pushout in the target category. module Categories.Category.Instance.Span where open import Level open import Categories.Category open import Relation.Binary.PropositionalEquality data SpanObj : Set where center : SpanObj left : SpanObj right : SpanObj data SpanArr : SpanObj → SpanObj → Set where span-id : ∀ {o} → SpanArr o o span-arrˡ : SpanArr center left span-arrʳ : SpanArr center right span-compose : ∀ {x y z} → SpanArr y z → SpanArr x y → SpanArr x z span-compose span-id span-id = span-id span-compose span-id span-arrˡ = span-arrˡ span-compose span-id span-arrʳ = span-arrʳ span-compose span-arrˡ span-id = span-arrˡ span-compose span-arrʳ span-id = span-arrʳ Span : Category 0ℓ 0ℓ 0ℓ Span = record { Obj = SpanObj ; _⇒_ = SpanArr ; _≈_ = _≡_ ; id = span-id ; _∘_ = span-compose ; assoc = assoc ; sym-assoc = sym assoc ; identityˡ = identityˡ ; identityʳ = identityʳ ; identity² = λ {x} → identity² {x} ; equiv = isEquivalence ; ∘-resp-≈ = λ { refl refl → refl } } where assoc : ∀ {x y z w} {f : SpanArr x y} {g : SpanArr y z} {h : SpanArr z w} → span-compose (span-compose h g) f ≡ span-compose h (span-compose g f) assoc {_} {_} {_} {_} {span-id} {span-id} {span-id} = refl assoc {_} {_} {_} {_} {span-id} {span-id} {span-arrˡ} = refl assoc {_} {_} {_} {_} {span-id} {span-id} {span-arrʳ} = refl assoc {_} {_} {_} {_} {span-id} {span-arrˡ} {span-id} = refl assoc {_} {_} {_} {_} {span-id} {span-arrʳ} {span-id} = refl assoc {_} {_} {_} {_} {span-arrˡ} {span-id} {span-id} = refl assoc {_} {_} {_} {_} {span-arrʳ} {span-id} {span-id} = refl identityˡ : ∀ {x y} {f : SpanArr x y} → span-compose span-id f ≡ f identityˡ {_} {_} {span-id} = refl identityˡ {_} {_} {span-arrˡ} = refl identityˡ {_} {_} {span-arrʳ} = refl identityʳ : ∀ {x y} {f : SpanArr x y} → span-compose f span-id ≡ f identityʳ {_} {_} {span-id} = refl identityʳ {_} {_} {span-arrˡ} = refl identityʳ {_} {_} {span-arrʳ} = refl identity² : {x : SpanObj} → span-compose span-id span-id ≡ span-id identity² = refl
src/fltk-devices-surfaces-paged.adb
micahwelf/FLTK-Ada
1
10577
<filename>src/fltk-devices-surfaces-paged.adb with Interfaces.C, System; use type Interfaces.C.int, System.Address; package body FLTK.Devices.Surfaces.Paged is function new_fl_paged_device return System.Address; pragma Import (C, new_fl_paged_device, "new_fl_paged_device"); pragma Inline (new_fl_paged_device); procedure free_fl_paged_device (D : in System.Address); pragma Import (C, free_fl_paged_device, "free_fl_paged_device"); pragma Inline (free_fl_paged_device); function fl_paged_device_start_job (D : in System.Address; C : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_paged_device_start_job, "fl_paged_device_start_job"); pragma Inline (fl_paged_device_start_job); function fl_paged_device_start_job2 (D : in System.Address; C, F, T : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_paged_device_start_job2, "fl_paged_device_start_job2"); pragma Inline (fl_paged_device_start_job2); procedure fl_paged_device_end_job (D : in System.Address); pragma Import (C, fl_paged_device_end_job, "fl_paged_device_end_job"); pragma Inline (fl_paged_device_end_job); function fl_paged_device_start_page (D : in System.Address) return Interfaces.C.int; pragma Import (C, fl_paged_device_start_page, "fl_paged_device_start_page"); pragma Inline (fl_paged_device_start_page); function fl_paged_device_end_page (D : in System.Address) return Interfaces.C.int; pragma Import (C, fl_paged_device_end_page, "fl_paged_device_end_page"); pragma Inline (fl_paged_device_end_page); procedure fl_paged_device_margins (D : in System.Address; L, T, R, B : out Interfaces.C.int); pragma Import (C, fl_paged_device_margins, "fl_paged_device_margins"); pragma Inline (fl_paged_device_margins); function fl_paged_device_printable_rect (D : in System.Address; W, H : out Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_paged_device_printable_rect, "fl_paged_device_printable_rect"); pragma Inline (fl_paged_device_printable_rect); procedure fl_paged_device_get_origin (D : in System.Address; X, Y : out Interfaces.C.int); pragma Import (C, fl_paged_device_get_origin, "fl_paged_device_get_origin"); pragma Inline (fl_paged_device_get_origin); procedure fl_paged_device_set_origin (D : in System.Address; X, Y : in Interfaces.C.int); pragma Import (C, fl_paged_device_set_origin, "fl_paged_device_set_origin"); pragma Inline (fl_paged_device_set_origin); procedure fl_paged_device_rotate (D : in System.Address; R : in Interfaces.C.C_float); pragma Import (C, fl_paged_device_rotate, "fl_paged_device_rotate"); pragma Inline (fl_paged_device_rotate); procedure fl_paged_device_scale (D : in System.Address; X, Y : in Interfaces.C.C_float); pragma Import (C, fl_paged_device_scale, "fl_paged_device_scale"); pragma Inline (fl_paged_device_scale); procedure fl_paged_device_translate (D : in System.Address; X, Y : in Interfaces.C.int); pragma Import (C, fl_paged_device_translate, "fl_paged_device_translate"); pragma Inline (fl_paged_device_translate); procedure fl_paged_device_untranslate (D : in System.Address); pragma Import (C, fl_paged_device_untranslate, "fl_paged_device_untranslate"); pragma Inline (fl_paged_device_untranslate); procedure fl_paged_device_print_widget (D, I : in System.Address; DX, DY : in Interfaces.C.int); pragma Import (C, fl_paged_device_print_widget, "fl_paged_device_print_widget"); pragma Inline (fl_paged_device_print_widget); procedure fl_paged_device_print_window (D, I : in System.Address; DX, DY : in Interfaces.C.int); pragma Import (C, fl_paged_device_print_window, "fl_paged_device_print_window"); pragma Inline (fl_paged_device_print_window); procedure fl_paged_device_print_window_part (D, I : in System.Address; X, Y, W, H, DX, DY : in Interfaces.C.int); pragma Import (C, fl_paged_device_print_window_part, "fl_paged_device_print_window_part"); pragma Inline (fl_paged_device_print_window_part); procedure Finalize (This : in out Paged_Surface) is begin if This.Void_Ptr /= System.Null_Address and then This in Paged_Surface'Class then free_fl_paged_device (This.Void_Ptr); This.Void_Ptr := System.Null_Address; end if; Finalize (Surface_Device (This)); end Finalize; package body Forge is function Create return Paged_Surface is begin return This : Paged_Surface do This.Void_Ptr := new_fl_paged_device; end return; end Create; pragma Inline (Create); end Forge; procedure Start_Job (This : in out Paged_Surface; Count : in Natural) is begin if fl_paged_device_start_job (This.Void_Ptr, Interfaces.C.int (Count)) /= 0 then raise Page_Error; end if; end Start_Job; procedure Start_Job (This : in out Paged_Surface; Count : in Natural; From, To : in Positive) is begin if fl_paged_device_start_job2 (This.Void_Ptr, Interfaces.C.int (Count), Interfaces.C.int (From), Interfaces.C.int (To)) /= 0 then raise Page_Error; end if; end Start_Job; procedure End_Job (This : in out Paged_Surface) is begin fl_paged_device_end_job (This.Void_Ptr); end End_Job; procedure Start_Page (This : in out Paged_Surface) is begin if fl_paged_device_start_page (This.Void_Ptr) /= 0 then raise Page_Error; end if; end Start_Page; procedure End_Page (This : in out Paged_Surface) is begin if fl_paged_device_end_page (This.Void_Ptr) /= 0 then raise Page_Error; end if; end End_Page; procedure Get_Margins (This : in Paged_Surface; Left, Top, Right, Bottom : out Integer) is begin fl_paged_device_margins (This.Void_Ptr, Interfaces.C.int (Left), Interfaces.C.int (Top), Interfaces.C.int (Right), Interfaces.C.int (Bottom)); end Get_Margins; procedure Get_Printable_Rect (This : in Paged_Surface; W, H : out Integer) is begin if fl_paged_device_printable_rect (This.Void_Ptr, Interfaces.C.int (W), Interfaces.C.int (H)) /= 0 then raise Page_Error; end if; end Get_Printable_Rect; procedure Get_Origin (This : in Paged_Surface; X, Y : out Integer) is begin fl_paged_device_get_origin (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y)); end Get_Origin; procedure Set_Origin (This : in out Paged_Surface; X, Y : in Integer) is begin fl_paged_device_set_origin (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y)); end Set_Origin; procedure Rotate (This : in out Paged_Surface; Degrees : in Float) is begin fl_paged_device_rotate (This.Void_Ptr, Interfaces.C.C_float (Degrees)); end Rotate; procedure Scale (This : in out Paged_Surface; Factor : in Float) is begin fl_paged_device_scale (This.Void_Ptr, Interfaces.C.C_float (Factor), 0.0); end Scale; procedure Scale (This : in out Paged_Surface; Factor_X, Factor_Y : in Float) is begin fl_paged_device_scale (This.Void_Ptr, Interfaces.C.C_float (Factor_X), Interfaces.C.C_float (Factor_Y)); end Scale; procedure Translate (This : in out Paged_Surface; Delta_X, Delta_Y : in Integer) is begin fl_paged_device_translate (This.Void_Ptr, Interfaces.C.int (Delta_X), Interfaces.C.int (Delta_Y)); end Translate; procedure Untranslate (This : in out Paged_Surface) is begin fl_paged_device_untranslate (This.Void_Ptr); end Untranslate; procedure Print_Widget (This : in out Paged_Surface; Item : in FLTK.Widgets.Widget'Class; Offset_X, Offset_Y : in Integer := 0) is begin fl_paged_device_print_widget (This.Void_Ptr, Wrapper (Item).Void_Ptr, Interfaces.C.int (Offset_X), Interfaces.C.int (Offset_Y)); end Print_Widget; procedure Print_Window (This : in out Paged_Surface; Item : in FLTK.Widgets.Groups.Windows.Window'Class; Offset_X, Offset_Y : in Integer := 0) is begin fl_paged_device_print_window (This.Void_Ptr, Wrapper (Item).Void_Ptr, Interfaces.C.int (Offset_X), Interfaces.C.int (Offset_Y)); end Print_Window; procedure Print_Window_Part (This : in out Paged_Surface; Item : in FLTK.Widgets.Groups.Windows.Window'Class; X, Y, W, H : in Integer; Offset_X, Offset_Y : in Integer := 0) is begin fl_paged_device_print_window_part (This.Void_Ptr, Wrapper (Item).Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H), Interfaces.C.int (Offset_X), Interfaces.C.int (Offset_Y)); end Print_Window_Part; end FLTK.Devices.Surfaces.Paged;
programs/oeis/116/A116404.asm
karttu/loda
0
240097
; A116404: Expansion of (1-x)/((1-x)^2 - x^2(1+x)^2). ; 1,1,2,6,15,35,84,204,493,1189,2870,6930,16731,40391,97512,235416,568345,1372105,3312554,7997214,19306983,46611179,112529340,271669860,655869061,1583407981,3822685022,9228778026,22280241075,53789260175,129858761424,313506783024,756872327473,1827251437969,4411375203410,10650001844790,25711378892991,62072759630771,149856898154532,361786555939836,873430010034205,2108646576008245,5090723162050694 mov $3,2 mov $5,$0 lpb $3,1 mov $0,$5 sub $3,1 add $0,$3 sub $0,1 cal $0,48739 ; Expansion of 1/((1 - x)*(1 - 2*x - x^2)). sub $0,1 div $0,2 add $0,10 mov $2,$3 mov $4,$0 sub $4,9 lpb $2,1 mov $1,$4 sub $2,1 lpe lpe lpb $5,1 sub $1,$4 mov $5,0 lpe
other.7z/SFC.7z/SFC/ソースデータ/MarioKart/kart-calc.asm
prismotizm/gigaleak
0
87983
Name: kart-calc.asm Type: file Size: 24560 Last-Modified: '1992-08-30T15:00:00Z' SHA-1: E3124243BE5EA2D7001FB3DAAD52EB0EB95FE395 Description: null
libsrc/_DEVELOPMENT/stdio/c/sccz80/getline_callee.asm
teknoplop/z88dk
0
3756
<gh_stars>0 ; size_t getline(char **lineptr, size_t *n, FILE *stream) INCLUDE "clib_cfg.asm" SECTION code_clib SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC getline_callee EXTERN asm_getline getline_callee: pop hl pop ix pop de ex (sp),hl jp asm_getline ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC getline_callee EXTERN getline_unlocked_callee defc getline_callee = getline_unlocked_callee ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
u7-common/patch-eop-selectAndUseKey.asm
JohnGlassmyer/UltimaHacks
68
104045
<filename>u7-common/patch-eop-selectAndUseKey.asm<gh_stars>10-100 ; Uses a keyring, if the party has one; otherwise, allows the player to select ; a target and then automatically finds and uses a party-held key for that ; target. ; Removes the hassle associated with managing keys in U7BG in particular, but ; also in the part of U7SI before acquiring the keyring. [bits 16] startPatch EXE_LENGTH, eop-selectAndUseKey startBlockAt addr_eop_selectAndUseKey push bp mov bp, sp ; bp-based stack frame: %assign ____callerIp 0x02 %assign ____callerBp 0x00 %assign var_dontCare -0x02 %assign var_selectedIbo -0x04 %assign var_quality -0x06 %assign var_keyIbo -0x08 add sp, var_keyIbo push si push di ; if game has a keyring type, and party has a keyring, then use that %ifnum ItemType_KEYRING push word 0xFF ; frame push word 0xFF ; quality push word ItemType_KEYRING callVarArgsEopFromOverlay findPartyItem, 3 add sp, 6 test ax, ax jz afterTryingKeyring mov [bp+var_keyIbo], ax jmp useItem afterTryingKeyring: %endif ; otherwise, have the player select a target ; and try to find a matching key lea ax, [bp+var_dontCare] push ax lea ax, [bp+var_dontCare] ; coordinateY push ax lea ax, [bp+var_dontCare] ; coordinateX push ax lea ax, [bp+var_selectedIbo] ; ibo push ax callFromOverlay havePlayerSelect add sp, 8 cmp word [bp+var_selectedIbo], 0 jz short nothingSelected lea ax, [bp+var_selectedIbo] push ax callFromOverlay Item_getQuality pop cx and ax, 0xFF test ax, ax jz qualityZero push word 0xFF ; frame push ax ; key quality push word 641 ; key itemType callVarArgsEopFromOverlay findPartyItem, 3 add sp, 6 mov [bp+var_keyIbo], ax test ax, ax jz noKey push USE_KEY_SOUND callFromOverlay playSoundSimple pop cx useItem: ; enable Hack Mover temporarily so use doesn't get blocked movzx si, byte [dseg_isHackMoverEnabled] mov byte [dseg_isHackMoverEnabled], 1 push word 0 ; flags push word 0 ; y coordinate push word 0 ; x coordinate lea ax, [bp+var_keyIbo] push ax callFromOverlay use add sp, 8 ; restore state of Hack Mover mov ax, si mov byte [dseg_isHackMoverEnabled], al jmp procEnd nothingSelected: qualityZero: noKey: push NO_KEY_SOUND callFromOverlay playSoundSimple pop cx procEnd: pop di pop si mov sp, bp pop bp retn endBlockAt off_eop_selectAndUseKey_end endPatch
tests/src/sp-strings-tests.adb
jquorning/septum
236
6018
with Ada.Characters.Latin_1; with Ada.Strings.Unbounded; with Trendy_Test.Assertions.Integer_Assertions; package body SP.Strings.Tests is package ASU renames Ada.Strings.Unbounded; use Trendy_Test.Assertions; use Trendy_Test.Assertions.Integer_Assertions; function "+" (S : String) return ASU.Unbounded_String renames ASU.To_Unbounded_String; procedure Test_String_Split (Op : in out Trendy_Test.Operation'Class) is E : Exploded_Line; begin Op.Register; E := Make (" this is an exploded line with--content "); Assert_EQ (Op, Num_Words (E), 6); Assert_EQ (Op, Get_Word (E, 1), "this"); Assert_EQ (Op, Get_Word (E, 2), "is"); Assert_EQ (Op, Get_Word (E, 3), "an"); Assert_EQ (Op, Get_Word (E, 4), "exploded"); Assert_EQ (Op, Get_Word (E, 5), "line"); Assert_EQ (Op, Get_Word (E, 6), "with--content"); end Test_String_Split; procedure Test_Is_Quoted (Op : in out Trendy_Test.Operation'Class) is use Ada.Characters.Latin_1; begin Op.Register; Assert (Op, not Is_Quoted("")); Assert (Op, not Is_Quoted ("not quoted")); -- Unbalanced " Assert (Op, not Is_Quoted (Quotation & "some text")); Assert (Op, not Is_Quoted ("some text" & Quotation)); -- Unbalanced ' Assert (Op, not Is_Quoted (Apostrophe & "some text")); Assert (Op, not Is_Quoted ("some text" & Apostrophe)); -- Mismatched ' and " Assert (Op, not Is_Quoted (Quotation & "some text" & Apostrophe)); Assert (Op, not Is_Quoted (Apostrophe & "some text" & Quotation)); -- Matched " and ' Assert (Op, Is_Quoted (Apostrophe & "some text" & Apostrophe)); Assert (Op, Is_Quoted (Quotation & "some text" & Quotation)); -- Internal " or ' Assert (Op, Is_Quoted (Apostrophe & Quotation & "some text" & Quotation & Apostrophe)); Assert (Op, Is_Quoted (Apostrophe & Quotation & "some text" & Quotation & Apostrophe)); end Test_Is_Quoted; procedure Test_Common_Prefix_Length (Op : in out Trendy_Test.Operation'Class) is package Trendy_TestI renames Trendy_Test.Assertions.Integer_Assertions; begin Op.Register; Trendy_TestI.Assert_EQ (Op, Common_Prefix_Length(+"", +"SP.Strings"), 0); Assert_EQ (Op, Common_Prefix_Length(+"SP.Strings", +""), 0); Assert_EQ (Op, Common_Prefix_Length(+"", +""), 0); Assert_EQ (Op, Common_Prefix_Length(+"SP.Searches", +"SP.Strings"), 4); Assert_EQ (Op, Common_Prefix_Length(+"SP.Strings", +"SP.Strings"), ASU.Length (+"SP.Strings")); end Test_Common_Prefix_Length; --------------------------------------------------------------------------- -- Test Registry --------------------------------------------------------------------------- function All_Tests return Trendy_Test.Test_Group is ( Test_String_Split'Access, Test_Is_Quoted'Access, Test_Common_Prefix_Length'Access ); end SP.Strings.Tests;
out/Inception/Syntax.agda
JoeyEremondi/agda-soas
39
3417
<reponame>JoeyEremondi/agda-soas {- This second-order term syntax was created from the following second-order syntax description: syntax Inception | IA type L : 0-ary P : 0-ary A : 0-ary term rec : L P -> A inc : L.A P.A -> A theory (S) p : P a : P.A |> inc (l. rec (l, p[]), x. a[x]) = a[p[]] (E) a : L.A |> k : L |- inc (l. a[l], x. rec(k, x)) = a[k] (W) m : A a : P.A |> inc (l. m[], x. a[x]) = m[] (A) p : (L,L).A a : (L,P).A b : P.A |> inc (l. inc (k. p[l, k], x. a[l,x]), y. b[y]) = inc (k. inc(l. p[l,k], y.b[y]), x. inc(l. a[l,x], y.b[y])) -} module Inception.Syntax where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Construction.Structure open import SOAS.ContextMaps.Inductive open import SOAS.Metatheory.Syntax open import Inception.Signature private variable Γ Δ Π : Ctx α : IAT 𝔛 : Familyₛ -- Inductive term declaration module IA:Terms (𝔛 : Familyₛ) where data IA : Familyₛ where var : ℐ ⇾̣ IA mvar : 𝔛 α Π → Sub IA Π Γ → IA α Γ rec : IA L Γ → IA P Γ → IA A Γ inc : IA A (L ∙ Γ) → IA A (P ∙ Γ) → IA A Γ open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛 IAᵃ : MetaAlg IA IAᵃ = record { 𝑎𝑙𝑔 = λ where (recₒ ⋮ a , b) → rec a b (incₒ ⋮ a , b) → inc a b ; 𝑣𝑎𝑟 = var ; 𝑚𝑣𝑎𝑟 = λ 𝔪 mε → mvar 𝔪 (tabulate mε) } module IAᵃ = MetaAlg IAᵃ module _ {𝒜 : Familyₛ}(𝒜ᵃ : MetaAlg 𝒜) where open MetaAlg 𝒜ᵃ 𝕤𝕖𝕞 : IA ⇾̣ 𝒜 𝕊 : Sub IA Π Γ → Π ~[ 𝒜 ]↝ Γ 𝕊 (t ◂ σ) new = 𝕤𝕖𝕞 t 𝕊 (t ◂ σ) (old v) = 𝕊 σ v 𝕤𝕖𝕞 (mvar 𝔪 mε) = 𝑚𝑣𝑎𝑟 𝔪 (𝕊 mε) 𝕤𝕖𝕞 (var v) = 𝑣𝑎𝑟 v 𝕤𝕖𝕞 (rec a b) = 𝑎𝑙𝑔 (recₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b) 𝕤𝕖𝕞 (inc a b) = 𝑎𝑙𝑔 (incₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b) 𝕤𝕖𝕞ᵃ⇒ : MetaAlg⇒ IAᵃ 𝒜ᵃ 𝕤𝕖𝕞 𝕤𝕖𝕞ᵃ⇒ = record { ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → ⟨𝑎𝑙𝑔⟩ t } ; ⟨𝑣𝑎𝑟⟩ = refl ; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{mε} → cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-tab mε)) } } where open ≡-Reasoning ⟨𝑎𝑙𝑔⟩ : (t : ⅀ IA α Γ) → 𝕤𝕖𝕞 (IAᵃ.𝑎𝑙𝑔 t) ≡ 𝑎𝑙𝑔 (⅀₁ 𝕤𝕖𝕞 t) ⟨𝑎𝑙𝑔⟩ (recₒ ⋮ _) = refl ⟨𝑎𝑙𝑔⟩ (incₒ ⋮ _) = refl 𝕊-tab : (mε : Π ~[ IA ]↝ Γ)(v : ℐ α Π) → 𝕊 (tabulate mε) v ≡ 𝕤𝕖𝕞 (mε v) 𝕊-tab mε new = refl 𝕊-tab mε (old v) = 𝕊-tab (mε ∘ old) v module _ (g : IA ⇾̣ 𝒜)(gᵃ⇒ : MetaAlg⇒ IAᵃ 𝒜ᵃ g) where open MetaAlg⇒ gᵃ⇒ 𝕤𝕖𝕞! : (t : IA α Γ) → 𝕤𝕖𝕞 t ≡ g t 𝕊-ix : (mε : Sub IA Π Γ)(v : ℐ α Π) → 𝕊 mε v ≡ g (index mε v) 𝕊-ix (x ◂ mε) new = 𝕤𝕖𝕞! x 𝕊-ix (x ◂ mε) (old v) = 𝕊-ix mε v 𝕤𝕖𝕞! (mvar 𝔪 mε) rewrite cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-ix mε)) = trans (sym ⟨𝑚𝑣𝑎𝑟⟩) (cong (g ∘ mvar 𝔪) (tab∘ix≈id mε)) 𝕤𝕖𝕞! (var v) = sym ⟨𝑣𝑎𝑟⟩ 𝕤𝕖𝕞! (rec a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩ 𝕤𝕖𝕞! (inc a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩ -- Syntax instance for the signature IA:Syn : Syntax IA:Syn = record { ⅀F = ⅀F ; ⅀:CS = ⅀:CompatStr ; mvarᵢ = IA:Terms.mvar ; 𝕋:Init = λ 𝔛 → let open IA:Terms 𝔛 in record { ⊥ = IA ⋉ IAᵃ ; ⊥-is-initial = record { ! = λ{ {𝒜 ⋉ 𝒜ᵃ} → 𝕤𝕖𝕞 𝒜ᵃ ⋉ 𝕤𝕖𝕞ᵃ⇒ 𝒜ᵃ } ; !-unique = λ{ {𝒜 ⋉ 𝒜ᵃ} (f ⋉ fᵃ⇒) {x = t} → 𝕤𝕖𝕞! 𝒜ᵃ f fᵃ⇒ t } } } } -- Instantiation of the syntax and metatheory open Syntax IA:Syn public open IA:Terms public open import SOAS.Families.Build public open import SOAS.Syntax.Shorthands IAᵃ public open import SOAS.Metatheory IA:Syn public
3-mid/impact/source/3d/collision/narrowphase/impact-d3-collision-gjk_epa.adb
charlie5/lace
20
21663
<reponame>charlie5/lace<filename>3-mid/impact/source/3d/collision/narrowphase/impact-d3-collision-gjk_epa.adb with impact.d3.Shape.convex.internal.sphere; with Interfaces.C; with impact.d3.Transform; with impact.d3.Quaternions; with impact.d3.Matrix; with Interfaces; with impact.d3.Vector; with impact.d3.collision.gjk_epa; with impact.d3.Scalar; -- #include "BulletCollision/CollisionShapes/impact.d3.Shape.convex.internal.h" -- #include "BulletCollision/CollisionShapes/impact.d3.Shape.convex.internal.sphere.h" package body impact.d3.collision.gjk_epa is package gjkepa2_impl is ----------- --- Config -- --- GJK -- GJK_MAX_ITERATIONS : constant := 128; GJK_ACCURARY : constant := 0.0001; GJK_MIN_DISTANCE : constant := 0.0001; GJK_DUPLICATED_EPS : constant := 0.0001; GJK_SIMPLEX2_EPS : constant := 0.0; GJK_SIMPLEX3_EPS : constant := 0.0; GJK_SIMPLEX4_EPS : constant := 0.0; --- EPA -- EPA_MAX_VERTICES : constant := 64; EPA_MAX_FACES : constant := EPA_MAX_VERTICES * 2; EPA_MAX_ITERATIONS : constant := 255; EPA_ACCURACY : constant := 0.0001; EPA_FALLBACK : constant := 10 * EPA_ACCURACY; EPA_PLANE_EPS : constant := 0.00001; EPA_INSIDE_EPS : constant := 0.01; --- Shorthands -- subtype U is interfaces.Unsigned_64; subtype U1 is interfaces.c.unsigned_char; type u1_array is array (Positive range <>) of U1; --- MinkowskiDiff -- type convex_shape_Pair is array (1 .. 2) of impact.d3.Shape.convex.view; type Ls_function is access function (Self : impact.d3.Shape.convex.item'Class; vec : in math.Vector_3) return math.Vector_3; type MinkowskiDiff is tagged record m_shapes : convex_shape_Pair; m_toshape1 : math.Matrix_3x3; m_toshape0 : Transform_3d; Ls : Ls_function; -- impact.d3.Vector (impact.d3.Shape.convex::*Ls)(const impact.d3.Vector&) const; end record; procedure EnableMargin (Self : in out MinkowskiDiff; enable : in Boolean); function Support0 (Self : in MinkowskiDiff; d : in math.Vector_3) return math.Vector_3; function Support1 (Self : in MinkowskiDiff; d : in math.Vector_3) return math.Vector_3; function Support (Self : in MinkowskiDiff; d : in math.Vector_3) return math.Vector_3; function Support (Self : in MinkowskiDiff; d : in math.Vector_3; index : in U ) return math.Vector_3; subtype tShape is MinkowskiDiff; --- GJK -- type sSV is record d, w : aliased math.Vector_3; end record; type sSV_array is array (Positive range <>) of aliased sSV; type sSV_view is access all sSV; type sSV_views is array (Positive range <>) of sSV_view; type sSimplex is record c : sSV_array (1 .. 4); p : math.Vector_4; rank : U; end record; type sSimplex_array is array (Positive range <>) of aliased sSimplex; type eStatus is (Valid, Inside, Failed); type GJK is tagged record m_shape : tShape; m_ray : math.Vector_3; m_distance : math.Real; m_simplices : sSimplex_array (1 .. 2); m_store : sSV_array (1 .. 4); m_free : sSV_views (1 .. 4); m_nfree : U; m_current : U; m_simplex : access sSimplex; m_status : eStatus; end record; function to_GJK return GJK; procedure Initialize (Self : in out GJK); function EncloseOrigin (Self : access GJK) return Boolean; function Evaluate (Self : access GJK; shapearg : in tShape'Class; guess : in math.Vector_3) return eStatus; procedure appendvertice (Self : in out GJK; simplex : access sSimplex; v : in math.Vector_3); procedure removevertice (Self : in out GJK; simplex : access sSimplex); -------- --- EPA -- -- Types -- type sFace; type sFace_view is access all sFace; type sFace_views is array (Positive range <>) of sFace_view; type sFace is record n : math.Vector_3; d, p : math.Real; c : sSV_views (1 .. 3); f : sFace_views (1 .. 3); l : sFace_views (1 .. 2); e : U1_array (1 .. 3); pass : U1; end record; type sFace_array is array (Positive range <>) of aliased sFace; type sList is record root : sFace_view; count : U := 0; end record; type sHorizon is record cf, ff : sFace_view; nf : U := 0; end record; type eStatus_EPA is (Valid, Touching, Degenerated, NonConvex, InvalidHull, OutOfFaces, OutOfVertices, AccuraryReached, FallBack, Failed); pragma Unreferenced (Touching); type EPA is tagged record m_status : eStatus_EPA; m_result : sSimplex; m_normal : math.Vector_3; m_depth : math.Real; m_sv_store : sSV_array (1 .. EPA_MAX_VERTICES); m_fc_store : sFace_array (1 .. EPA_MAX_FACES); m_nextsv : U; m_hull : sList; m_stock : sList; end record; function to_EPA return EPA; procedure Initialize (Self : access EPA); function Evaluate (Self : in out EPA; gjk : in out gjkepa2_impl.GJK'Class; guess : in math.Vector_3) return eStatus_EPA; function newface (Self : access EPA; a, b, c : in sSV_view; forced : in Boolean) return sFace_view; function findbest (Self : access EPA) return sFace_view; function expand (Self : access EPA; pass : in U; w : in sSV_view; f : in sFace_view; e : in U; horizon : access sHorizon) return Boolean; --- Utility -- procedure Initialize (shape0 : in impact.d3.Shape.convex.view; wtrs0 : in Transform_3d; shape1 : in impact.d3.Shape.convex.view; wtrs1 : in Transform_3d; results : out impact.d3.collision.gjk_epa.btGjkEpaSolver2.sResults; shape : in out tShape; withmargins : in Boolean); end gjkepa2_impl; package body gjkepa2_impl is ------------------ --- MinkowskiDiff -- procedure EnableMargin (Self : in out MinkowskiDiff; enable : in Boolean) is begin if enable then Self.Ls := impact.d3.Shape.convex.localGetSupportVertexNonVirtual'Access; else Self.Ls := impact.d3.Shape.convex.localGetSupportVertexWithoutMarginNonVirtual'Access; end if; end EnableMargin; function Support0 (Self : in MinkowskiDiff; d : in math.Vector_3) return math.Vector_3 is begin return Self.Ls (Self.m_shapes (1).all, d); end Support0; function Support1 (Self : in MinkowskiDiff; d : in math.Vector_3) return math.Vector_3 is use linear_Algebra_3d, impact.d3.Transform, math.Vectors; begin return Self.m_toshape0 * Self.Ls (Self.m_shapes (2).all, Self.m_toshape1 * d); end Support1; function Support (Self : in MinkowskiDiff; d : in math.Vector_3) return math.Vector_3 is begin return Self.Support0 (d) - Self.Support1 (-d); end Support; function Support (Self : in MinkowskiDiff; d : in math.Vector_3; index : in U ) return math.Vector_3 is use type Interfaces.Unsigned_64; begin if index /= 0 then -- tbd: '0' or '1' ? return Self.Support1 (d); else return Self.Support0 (d); end if; end Support; -------- --- GJK -- function projectorigin (a, b : access math.Vector_3; w : access math.Vector; m : access U) return math.Real; function projectorigin (a, b, c : access math.Vector_3; w : access math.Vector; m : access U) return math.Real; function projectorigin (a, b, c, d : access math.Vector_3; w : access math.Vector; m : access U) return math.Real; -- Internals -- procedure getsupport (Self : in GJK'Class; d : in math.Vector_3; sv : out sSV) is use impact.d3.Vector, math.Vectors; begin sv.d := d / length (d); sv.w := Self.m_shape.Support (sv.d); end getsupport; function det (a, b, c : in math.Vector_3) return math.Real is begin return a (2) * b (3) * c (1) + a (3) * b (1) * c (2) - a (1) * b (3) * c (2) - a (2) * b (1) * c (3) + a (1) * b (2) * c (3) - a (3) * b (2) * c (1); end det; procedure Initialize (Self : in out GJK) is begin Self.m_ray := (0.0, 0.0, 0.0); Self.m_nfree := 1; -- or 0 ? Self.m_status := Failed; Self.m_current := 1; -- or 0 ? Self.m_distance := 0.0; end Initialize; function to_GJK return GJK is Self : GJK; begin Self.Initialize; return Self; end to_GJK; function Evaluate (Self : access GJK; shapearg : in tShape'Class; guess : in math.Vector_3) return eStatus is use impact.d3.Vector; use type U; iterations : U := 0; sqdist : math.Real := 0.0; alpha : math.Real := 0.0; lastw : Vector_3_array (1 .. 4); clastw : U := 0; sqrl : math.Real; begin -- Initialize solver -- Self.m_free (1) := Self.m_store (1)'Unchecked_Access; Self.m_free (2) := Self.m_store (2)'Unchecked_Access; Self.m_free (3) := Self.m_store (3)'Unchecked_Access; Self.m_free (4) := Self.m_store (4)'Unchecked_Access; Self.m_nfree := 5; -- or 4 ? Self.m_current := 1; -- or 0 ? Self.m_status := Valid; Self.m_shape := tShape (shapearg); Self.m_distance := 0.0; -- Initialize simplex -- Self.m_simplices (1).rank := 1; -- or 0 ? Self.m_ray := guess; sqrl := length2 (Self.m_ray); Self.appendvertice (Self.m_simplices (1)'Access, (if sqrl > 0.0 then -Self.m_ray else (1.0, 0.0, 0.0))); Self.m_simplices (1).p (1) := 1.0; Self.m_ray := Self.m_simplices (1).c (1).w; sqdist := sqrl; lastw (1) := Self.m_ray; lastw (2) := Self.m_ray; lastw (3) := Self.m_ray; lastw (4) := Self.m_ray; -- Loop loop declare next : constant U := 3 - Self.m_current; -- or 1 - m_current ? cs : access sSimplex := Self.m_simplices (Integer (Self.m_current))'Access; -- or m_current+1 ? ns : constant access sSimplex := Self.m_simplices (Integer (next ))'Access; -- or next+1 ? -- Check zero rl : constant math.Real := length (Self.m_ray); w : math.Vector_3; found : Boolean; omega : math.Real; -- weights : aliased math.Vector_4; weights : aliased math.Vector := (1 .. 4 => <>); mask : aliased U; begin if rl < GJK_MIN_DISTANCE then -- Touching or inside Self.m_status := Inside; exit; end if; -- Append new vertice in -'v' direction -- Self.appendvertice (cs, -Self.m_ray); w := cs.c (Integer (cs.rank - 1)).w; -- or -0 ? found := False; for i in U'(1) .. 4 loop if length2 (w - lastw (Integer (i))) < GJK_DUPLICATED_EPS then found := True; exit; end if; end loop; if found then -- Return old simplex Self.removevertice (Self.m_simplices (Integer (Self.m_current))'Access); -- or m_current+1 ? exit; else -- Update lastw clastw := (clastw + 1) and 3; lastw (Integer (clastw) + 1) := w; end if; -- Check for termination -- omega := dot (Self.m_ray, w) / rl; alpha := math.Real'Max (omega, alpha); if ((rl - alpha) - (GJK_ACCURARY * rl)) <= 0.0 then -- Return old simplex Self.removevertice (Self.m_simplices (Integer (Self.m_current))'Access); exit; end if; -- Reduce simplex -- mask := 0; case cs.rank is when 3 => sqdist := projectorigin (cs.c (1).w'Access, cs.c (2).w'Access, weights'Access, mask'Access); when 4 => sqdist := projectorigin (cs.c (1).w'Access, cs.c (2).w'Access, cs.c (3).w'Access, weights'Access, mask'Access); when 5 => sqdist := projectorigin (cs.c (1).w'Access, cs.c (2).w'Access, cs.c (3).w'Access, cs.c (4).w'Access, weights'Access, mask'Access); when others => null; end case; if sqdist >= 0.0 then -- Valid ns.rank := 1; Self.m_ray := (0.0, 0.0, 0.0); Self.m_current := next; for i in 1 .. Integer (cs.rank - 1) loop if (mask and (2**(i - 1))) /= 0 then ns.c (Integer (ns.rank)) := cs.c (i); ns.p (Integer (ns.rank)) := weights (i); ns.rank := ns.rank + 1; Self.m_ray := Self.m_ray + cs.c (i).w * weights (i); else Self.m_free (Integer (Self.m_nfree)) := cs.c (i)'Access; Self.m_nfree := Self.m_nfree + 1; end if; end loop; if mask = 15 then Self.m_status := Inside; end if; else -- Return old simplex Self.removevertice (Self.m_simplices (Integer (Self.m_current))'Access); exit; end if; iterations := iterations + 1; Self.m_status := (if iterations <= GJK_MAX_ITERATIONS then Self.m_status else Failed); exit when Self.m_status /= Valid; end; end loop; Self.m_simplex := Self.m_simplices (Integer (Self.m_current))'Unchecked_Access; case Self.m_status is when Valid => Self.m_distance := length (Self.m_ray); when Inside => Self.m_distance := 0.0; when others => null; end case; return Self.m_status; end Evaluate; -- /* Loop */ -- do { -- const U next=1-m_current; -- sSimplex& cs=m_simplices[m_current]; -- sSimplex& ns=m_simplices[next]; -- /* Check zero */ -- const btScalar rl=m_ray.length(); -- if(rl<GJK_MIN_DISTANCE) -- {/* Touching or inside */ -- m_status=eStatus::Inside; -- break; -- } -- /* Append new vertice in -'v' direction */ -- appendvertice(cs,-m_ray); -- const btVector3& w=cs.c[cs.rank-1]->w; -- bool found=false; -- for(U i=0;i<4;++i) -- { -- if((w-lastw[i]).length2()<GJK_DUPLICATED_EPS) -- { found=true;break; } -- } -- if(found) -- {/* Return old simplex */ -- removevertice(m_simplices[m_current]); -- break; -- } -- else -- {/* Update lastw */ -- lastw[clastw=(clastw+1)&3]=w; -- } -- /* Check for termination */ -- const btScalar omega=btDot(m_ray,w)/rl; -- alpha=btMax(omega,alpha); -- if(((rl-alpha)-(GJK_ACCURARY*rl))<=0) -- {/* Return old simplex */ -- removevertice(m_simplices[m_current]); -- break; -- } -- /* Reduce simplex */ -- btScalar weights[4]; -- U mask=0; -- switch(cs.rank) -- { -- case 2: sqdist=projectorigin( cs.c[0]->w, -- cs.c[1]->w, -- weights,mask);break; -- case 3: sqdist=projectorigin( cs.c[0]->w, -- cs.c[1]->w, -- cs.c[2]->w, -- weights,mask);break; -- case 4: sqdist=projectorigin( cs.c[0]->w, -- cs.c[1]->w, -- cs.c[2]->w, -- cs.c[3]->w, -- weights,mask);break; -- } -- if(sqdist>=0) -- {/* Valid */ -- ns.rank = 0; -- m_ray = btVector3(0,0,0); -- m_current = next; -- for(U i=0,ni=cs.rank;i<ni;++i) -- { -- if(mask&(1<<i)) -- { -- ns.c[ns.rank] = cs.c[i]; -- ns.p[ns.rank++] = weights[i]; -- m_ray += cs.c[i]->w*weights[i]; -- } -- else -- { -- m_free[m_nfree++] = cs.c[i]; -- } -- } -- if(mask==15) m_status=eStatus::Inside; -- } -- else -- {/* Return old simplex */ -- removevertice(m_simplices[m_current]); -- break; -- } -- m_status=((++iterations)<GJK_MAX_ITERATIONS)?m_status:eStatus::Failed; -- } while(m_status==eStatus::Valid); -- m_simplex=&m_simplices[m_current]; -- switch(m_status) -- { -- case eStatus::Valid: m_distance=m_ray.length();break; -- case eStatus::Inside: m_distance=0;break; -- default: -- { -- } -- } -- return(m_status); ------ TBD: Check this whole file against C equiv. procedure appendvertice (Self : in out GJK; simplex : access sSimplex; v : in math.Vector_3) is use type interfaces.Unsigned_64; begin simplex.p (Integer (simplex.rank)) := 0.0; Self.m_nfree := Self.m_nfree - 1; simplex.c (Integer (simplex.rank)) := Self.m_free (Integer (Self.m_nfree)).all; getsupport (Self, v, simplex.c (Integer (simplex.rank))); simplex.rank := simplex.rank + 1; end appendvertice; -- void appendvertice(sSimplex& simplex,const btVector3& v) -- { -- simplex.p[simplex.rank]=0; -- simplex.c[simplex.rank]=m_free[--m_nfree]; -- getsupport(v,*simplex.c[simplex.rank++]); -- } procedure removevertice (Self : in out GJK; simplex : access sSimplex) is use type U; begin simplex.rank := simplex.rank - 1; Self.m_free (Integer (Self.m_nfree)) := simplex.c (Integer (simplex.rank))'Access; Self.m_nfree := Self.m_nfree + 1; end removevertice; -- void removevertice(sSimplex& simplex) -- { -- m_free[m_nfree++] = simplex.c[--simplex.rank]; -- } function projectorigin (a, b : access math.Vector_3; w : access math.Vector; m : access U) return math.Real is use impact.d3.Vector; d : constant math.Vector_3 := b.all - a.all; l : constant math.Real := length2 (d); t : math.Real; begin if l > GJK_SIMPLEX2_EPS then t := (if l > 0.0 then -dot (a.all, d) / l else 0.0); if t >= 1.0 then w (1) := 0.0; w (2) := 1.0; m.all := 2; return length2 (b.all); elsif t <= 0.0 then w (1) := 1.0; w (2) := 0.0; m.all := 1; return length2 (a.all); else w (2) := t; w (1) := 1.0 - w (2); m.all := 3; return length2 (a.all + d*t); end if; end if; return -1.0; end projectorigin; function projectorigin (a, b, c : access math.Vector_3; w : access math.Vector; m : access U) return math.Real is use impact.d3.Vector, math.Vectors; use type U; imd3 : constant array (1 .. 3) of U := (1, 2, 0); vt : constant array (1 .. 3) of access math.Vector_3 := (a, b, c); dl : constant array (1 .. 3) of math.Vector_3 := (a.all - b.all, b.all - c.all, c.all - a.all); n : constant math.Vector_3 := cross (dl (1), dl (2)); l : constant math.Real := length2 (n); begin if l > GJK_SIMPLEX3_EPS then declare mindist : math.Real := -1.0; subw : aliased math.Vector := (1 .. 2 => 0.0); subm : aliased U := 0; begin for i in U'(1) .. 3 loop if dot (vt (Integer (i)).all, cross (dl (Integer (i)), n)) > 0.0 then declare j : constant U := imd3 (Integer (i)); subd : constant math.Real := projectorigin (vt (Integer (i)), vt (Integer (j + 1)), subw'Access, subm'Access); begin if mindist < 0.0 or else subd < mindist then mindist := subd; m.all := U ( (if (subm and 1) /= 0 then 2**Integer (i - 1) else 0) + (if (subm and 2) /= 0 then 2**Integer (j) else 0)); w (Integer (i)) := subw (1); w (Integer (j + 1)) := subw (2); w (Integer (imd3 (Integer (j + 1)) + 1)) := 0.0; end if; end; end if; end loop; if mindist < 0.0 then declare use math.Functions; d : constant math.Real := dot (a.all, n); s : constant math.Real := sqRt (l); p : constant math.Vector_3 := n * (d / l); begin mindist := length2 (p); m.all := 7; -- tbd: 7'7 or '8' ? w (1) := length (cross (dl (2), b.all - p)) / s; w (2) := length (cross (dl (3), c.all - p)) / s; w (3) := 1.0 - (w (1) + w (2)); end; end if; return mindist; end; end if; return -1.0; end projectorigin; function projectorigin (a, b, c, d : access math.Vector_3; w : access math.Vector; m : access U) return math.Real is use impact.d3.Vector; use type U; imd3 : constant array (1 .. 3) of U := (1, 2, 0); vt : constant array (1 .. 4) of access math.Vector_3 := (a, b, c, d); dl : constant array (1 .. 3) of math.Vector_3 := (a.all - d.all, b.all - d.all, c.all - d.all); vl : math.Real := det (dl (1), dl (2), dl (3)); ng : constant Boolean := (vl * dot (a.all, cross (b.all - c.all, a.all - b.all))) <= 0.0; mindist : math.Real; subw : aliased math.Vector := (1 .. 3 => <>); subm : aliased U; begin if ng and then abs (vl) > GJK_SIMPLEX4_EPS then mindist := -1.0; subw := (0.0, 0.0, 0.0); subm := 0; for i in U'(1) .. 3 loop declare use math.Vectors; j : constant U := imd3 (Integer (i)) + 1; s : constant math.Real := vl * dot (d.all, cross (dl (Integer (i)), dl (Integer (j)))); subd : aliased math.Real; begin if s > 0.0 then subd := projectorigin (vt (Integer (i)), vt (Integer (j)), d, subw'Access, subm'Access); if mindist < 0.0 or else subd < mindist then mindist := subd; m.all := U ((if (subm and 1) /= 0 then 2**Natural (i) else 0) + (if (subm and 2) /= 0 then 2**Natural (j) else 0) + (if (subm and 4) /= 0 then 8 else 0)); w (Integer (i)) := subw (1); w (Integer (j)) := subw (2); w (Integer (imd3 (Integer (j)) + 1)) := 0.0; w (4) := subw (3); end if; end if; end; end loop; if mindist < 0.0 then mindist := 0.0; m.all := 15; w (1) := det (c.all, b.all, d.all) / vl; w (2) := det (a.all, c.all, d.all) / vl; w (3) := det (b.all, a.all, d.all) / vl; w (4) := 1.0 - (w (1) + w (2) + w (3)); end if; return mindist; end if; return -1.0; end projectorigin; function EncloseOrigin (Self : access GJK) return Boolean is use impact.d3.Vector; axis, d, p, n : math.Vector_3; begin case Self.m_simplex.rank is when 2 => for i in U'(1) .. 3 loop axis := (0.0, 0.0, 0.0); axis (Integer (i)) := 1.0; Self.appendvertice (Self.m_simplex, axis); if Self.EncloseOrigin then return True; end if; Self.removevertice (Self.m_simplex); Self.appendvertice (Self.m_simplex, -axis); if Self.EncloseOrigin then return True; end if; Self.removevertice (Self.m_simplex); end loop; when 3 => d := Self.m_simplex.c (2).w - Self.m_simplex.c (1).w; for i in U'(1) .. 3 loop axis := (0.0, 0.0, 0.0); axis (Integer (i)) := 1.0; p := cross (d, axis); if length2 (p) > 0.0 then Self.appendvertice (Self.m_simplex, p); if Self.EncloseOrigin then return True; end if; Self.removevertice (Self.m_simplex); Self.appendvertice (Self.m_simplex, -p); if Self.EncloseOrigin then return True; end if; Self.removevertice (Self.m_simplex); end if; end loop; when 4 => n := cross (Self.m_simplex.c (2).w - Self.m_simplex.c (1).w, Self.m_simplex.c (3).w - Self.m_simplex.c (1).w); if length2 (n) > 0.0 then Self.appendvertice (Self.m_simplex, n); if Self.EncloseOrigin then return True; end if; Self.removevertice (Self.m_simplex); Self.appendvertice (Self.m_simplex, -n); if Self.EncloseOrigin then return True; end if; Self.removevertice (Self.m_simplex); end if; when 5 => if abs (det (Self.m_simplex.c (1).w - Self.m_simplex.c (4).w, Self.m_simplex.c (2).w - Self.m_simplex.c (4).w, Self.m_simplex.c (3).w - Self.m_simplex.c (4).w)) > 0.0 then return True; end if; when others => raise Program_Error; end case; return False; end EncloseOrigin; -------- --- EPA -- function to_EPA return EPA is Self : aliased EPA; begin Self.Initialize; return Self; end to_EPA; procedure bind (fa : in sFace_view; ea : in U; fb : in sFace_view; eb : in U) is use type U; begin fa.e (Integer (ea) + 1) := U1 (eb + 1); fa.f (Integer (ea) + 1) := fb; fb.e (Integer (eb) + 1) := U1 (ea + 1); fb.f (Integer (eb) + 1) := fa; end bind; procedure append (list : in out sList; face : in sFace_view) is use type U; begin face.l (1) := null; face.l (2) := list.root; if list.root /= null then list.root.l (1) := face; end if; list.root := face; list.count := list.count + 1; end append; procedure remove (list : in out sList; face : in sFace_view) is use type U; begin if face.l (2) /= null then face.l (2).l (1) := face.l (1); end if; if face.l (1) /= null then face.l (1).l (2) := face.l (2); end if; if face = list.root then list.root := face.l (2); end if; list.count := list.count - 1; end remove; function newface (Self : access EPA; a, b, c : in sSV_view; forced : in Boolean) return sFace_view is use impact.d3.Vector; face : sFace_view; l : math.Real; v : Boolean; begin if Self.m_stock.root /= null then face := Self.m_stock.root; remove (Self.m_stock, face); append (Self.m_hull, face); face.pass := 0; face.c (1) := a; face.c (2) := b; face.c (3) := c; face.n := cross (b.w - a.w, c.w - a.w); l := length (face.n); v := l > EPA_ACCURACY; face.p := math.Real'Min (math.Real'Min (dot (a.w, cross (face.n, a.w - b.w)), dot (b.w, cross (face.n, b.w - c.w))), dot (c.w, cross (face.n, c.w - a.w))) / (if v then l else 1.0); face.p := (if face.p >= -EPA_INSIDE_EPS then 0.0 else face.p); if v then face.d := dot (a.w, face.n) / l; face.n := face.n / l; if forced or else (face.d >= -EPA_PLANE_EPS) then return face; else Self.m_status := NonConvex; end if; else Self.m_status := Degenerated; end if; remove (Self.m_hull, face); append (Self.m_stock, face); return null; end if; Self.m_status := (if Self.m_stock.root /= null then OutOfVertices else OutOfFaces); return null; end newface; function findbest (Self : access EPA) return sFace_view is -- use impact.d3.Vector, math.Vectors; minf : sFace_view := Self.m_hull.root; mind : math.Real := minf.d * minf.d; maxp : math.Real := minf.p; f : sFace_view := minf.l (2); sqd : math.Real; begin while f /= null loop sqd := f.d * f.d; if f.p >= maxp and then sqd < mind then minf := f; mind := sqd; maxp := f.p; end if; f := f.l (2); end loop; return minf; end findbest; function expand (Self : access EPA; pass : in U; w : in sSV_view; f : in sFace_view; e : in U; horizon : access sHorizon) return Boolean is use impact.d3.Vector; use type U, U1; i1m3 : constant array (1 .. 3) of U := (1, 2, 0); i2m3 : constant array (1 .. 3) of U := (2, 0, 1); e1, e2 : U; nf : sFace_view; begin if f.pass /= U1 (pass) then e1 := i1m3 (Integer (e)) + 1; if dot (f.n, w.w) - f.d < -EPA_PLANE_EPS then nf := Self.newface (f.c (Integer (e1)), f.c (Integer (e)), w, False); if nf /= null then bind (nf, 0, f, e - 1); if horizon.cf /= null then bind (horizon.cf, 1, nf, 2); else horizon.ff := nf; end if; horizon.cf := nf; horizon.nf := horizon.nf + 1; return True; end if; else e2 := i2m3 (Integer (e)) + 1; f.pass := U1 (pass); if Self.expand (pass, w, f.f (Integer (e1)), U (f.e (Integer (e1))), horizon) and then Self.expand (pass, w, f.f (Integer (e2)), U (f.e (Integer (e2))), horizon) then remove (Self.m_hull, f); append (Self.m_stock, f); return True; end if; end if; end if; return False; end expand; procedure Initialize (Self : access EPA) is begin Self.m_status := Failed; Self.m_normal := (0.0, 0.0, 0.0); Self.m_depth := 0.0; Self.m_nextsv := 0; for i in 1 .. EPA_MAX_FACES loop append (Self.m_stock, Self.m_fc_store (EPA_MAX_FACES - (i - 1))'Unchecked_Access); end loop; end Initialize; function Evaluate (Self : in out EPA; gjk : in out gjkepa2_impl.GJK'Class; guess : in math.Vector_3) return eStatus_EPA is use type U; simplex : sSimplex renames gjk.m_simplex.all; tetra : sFace_views (1 .. 4); begin if simplex.rank > 1 and then gjk.EncloseOrigin then -- Clean up -- while Self.m_hull.root /= null loop declare f : constant sFace_view := Self.m_hull.root; begin remove (Self.m_hull, f); append (Self.m_stock, f); end; end loop; Self.m_status := Valid; Self.m_nextsv := 0; -- Orient simplex -- if det (simplex.c (1).w - simplex.c (4).w, simplex.c (2).w - simplex.c (4).w, simplex.c (3).w - simplex.c (4).w) < 0.0 then declare Pad1 : constant sSV := simplex.c (1); Pad2 : math.Real; begin simplex.c (1) := simplex.c (2); -- swap simplex.c (2) := Pad1; Pad2 := simplex.p (1); -- swap simplex.p (1) := simplex.p (2); simplex.p (2) := Pad2; end; end if; -- Build initial hull -- tetra := (Self.newface (simplex.c (1)'Access, simplex.c (2)'Access, simplex.c (3)'Access, True), Self.newface (simplex.c (2)'Access, simplex.c (1)'Access, simplex.c (4)'Access, True), Self.newface (simplex.c (3)'Access, simplex.c (2)'Access, simplex.c (4)'Access, True), Self.newface (simplex.c (1)'Access, simplex.c (3)'Access, simplex.c (4)'Access, True)); if Self.m_hull.count = 4 then declare use impact.d3.Vector; best : sFace_view := Self.findbest; outer : sFace := best.all; pass : U := 0; iterations : U := 0; projection : math.Vector_3; sum : math.Real; begin bind (tetra (1), 0, tetra (2), 0); bind (tetra (1), 1, tetra (3), 0); bind (tetra (1), 2, tetra (4), 0); bind (tetra (2), 1, tetra (4), 2); bind (tetra (2), 2, tetra (3), 1); bind (tetra (3), 2, tetra (4), 1); Self.m_status := Valid; while iterations < EPA_MAX_ITERATIONS loop if Self.m_nextsv < EPA_MAX_VERTICES then declare horizon : aliased sHorizon; w : constant sSV_view := Self.m_sv_store (Integer (Self.m_nextsv) + 1)'Unchecked_Access; valid : Boolean := True; wdist : math.Real; begin Self.m_nextsv := Self.m_nextsv + 1; pass := pass + 1; best.pass := U1 (pass); getsupport (gjk, best.n, w.all); wdist := dot (best.n, w.w) - best.d; if wdist > EPA_ACCURACY then for j in U'(1) .. 3 loop valid := valid and Self.expand (pass, w, best.f (Integer (j)), U (best.e (Integer (j))), horizon'Access); exit when not Valid; end loop; if valid and then horizon.nf >= 3 then bind (horizon.cf, 1, horizon.ff, 2); remove (Self.m_hull, best); append (Self.m_stock, best); best := Self.findbest; if best.p >= outer.p then outer := best.all; end if; else Self.m_status := InvalidHull; exit; end if; else Self.m_status := AccuraryReached; exit; end if; end; else Self.m_status := OutOfVertices; exit; end if; iterations := iterations + 1; end loop; projection := outer.n * outer.d; Self.m_normal := outer.n; Self.m_depth := outer.d; Self.m_result.rank := 3; Self.m_result.c (1) := outer.c (1).all; Self.m_result.c (2) := outer.c (2).all; Self.m_result.c (3) := outer.c (3).all; Self.m_result.p (1) := length (cross (outer.c (2).w - projection, outer.c (3).w - projection)); Self.m_result.p (2) := length (cross (outer.c (3).w - projection, outer.c (1).w - projection)); Self.m_result.p (3) := length (cross (outer.c (1).w - projection, outer.c (2).w - projection)); sum := Self.m_result.p (1) + Self.m_result.p (2) + Self.m_result.p (3); Self.m_result.p (1) := Self.m_result.p (1) / sum; Self.m_result.p (2) := Self.m_result.p (2) / sum; Self.m_result.p (3) := Self.m_result.p (3) / sum; return Self.m_status; end; end if; end if; -- Fallback -- Self.m_status := FallBack; Self.m_normal := -guess; declare use impact.d3.Vector; nl : constant math.Real := length (Self.m_normal); begin if nl > 0.0 then Self.m_normal := Self.m_normal / nl; else Self.m_normal := (1.0, 0.0, 0.0); end if; end; Self.m_depth := 0.0; Self.m_result.rank := 1; Self.m_result.c (1) := simplex.c (1); Self.m_result.p (1) := 1.0; return Self.m_status; end Evaluate; procedure Initialize (shape0 : in impact.d3.Shape.convex.view; wtrs0 : in Transform_3d; shape1 : in impact.d3.Shape.convex.view; wtrs1 : in Transform_3d; results : out impact.d3.collision.gjk_epa.btGjkEpaSolver2.sResults; shape : in out tShape; withmargins : in Boolean) is use impact.d3.Transform, impact.d3.Matrix; begin -- Results -- results.witnesses (1) := (0.0, 0.0, 0.0); results.witnesses (2) := (0.0, 0.0, 0.0); results.status := impact.d3.collision.gjk_epa.btGjkEpaSolver2.Separated; -- Shape -- shape.m_shapes (1) := shape0; shape.m_shapes (2) := shape1; shape.m_toshape1 := transposeTimes (getBasis (wtrs1), getBasis (wtrs0)); shape.m_toshape0 := inverseTimes (wtrs0, wtrs1); shape.EnableMargin (withmargins); end Initialize; end gjkepa2_impl; package body btGjkEpaSolver2 is use gjkepa2_impl; function StackSizeRequirement return Integer is begin return (GJK'Size + EPA'Size) / 8; end StackSizeRequirement; function Distance (shape0 : in impact.d3.Shape.convex.view; wtrs0 : in Transform_3d; shape1 : in impact.d3.Shape.convex.view; wtrs1 : in Transform_3d; guess : in math.Vector_3; results : access sResults) return Boolean is shape : tShape; begin gjkepa2_impl.Initialize (shape0, wtrs0, shape1, wtrs1, results.all, shape, False); declare use linear_Algebra_3d, impact.d3.Vector, impact.d3.Transform; gjk : aliased gjkepa2_impl.GJK; gjk_status : constant gjkepa2_impl.eStatus := gjk.Evaluate (shape, guess); w0, w1 : math.Vector_3; p : math.Real; begin if gjk_status = Valid then w0 := (0.0, 0.0, 0.0); w1 := (0.0, 0.0, 0.0); for i in U'(1) .. gjk.m_simplex.rank loop p := gjk.m_simplex.p (Integer (i)); w0 := w0 + shape.Support (gjk.m_simplex.c (Integer (i)).d, 0) * p; w1 := w1 + shape.Support (-gjk.m_simplex.c (Integer (i)).d, 1) * p; end loop; results.witnesses (1) := wtrs0 * w0; results.witnesses (2) := wtrs0 * w1; results.normal := w0 - w1; results.distance := length (results.normal); results.normal := results.normal / (if results.distance > GJK_MIN_DISTANCE then results.distance else 1.0); return True; else results.status := (if gjk_status = Inside then Penetrating else GJK_Failed); return False; end if; end; end Distance; function Penetration (shape0 : in impact.d3.Shape.convex.view; wtrs0 : in Transform_3d; shape1 : in impact.d3.Shape.convex.view; wtrs1 : in Transform_3d; guess : in math.Vector_3; results : access sResults; usemargins : in Boolean := True) return Boolean is shape : tShape; begin gjkepa2_impl.Initialize (shape0, wtrs0, shape1, wtrs1, results.all, shape, usemargins); declare gjk : aliased gjkepa2_impl.GJK; gjk_status : constant gjkepa2_impl.eStatus := gjk.Evaluate (shape, -guess); begin case gjk_status is when Inside => declare use impact.d3.Transform, linear_Algebra_3d; epa : gjkepa2_impl.EPA := to_EPA; epa_status : constant eStatus_EPA := epa.Evaluate (gjk, -guess); w0 : math.Vector_3; begin if epa_status /= Failed then w0 := (0.0, 0.0, 0.0); for i in U'(1) .. epa.m_result.rank loop w0 := w0 + shape.Support (epa.m_result.c (Integer (i)).d, 0) * epa.m_result.p (Integer (i)); end loop; results.status := Penetrating; results.witnesses (1) := wtrs0 * w0; results.witnesses (2) := wtrs0 * (w0 - epa.m_normal*epa.m_depth); results.normal := -epa.m_normal; results.distance := -epa.m_depth; return True; else results.status := EPA_Failed; end if; end; when Failed => results.status := GJK_Failed; when others => null; end case; return False; end; end Penetration; function SignedDistance (position : in math.Vector_3; margin : in math.Real; shape0 : in impact.d3.Shape.convex.view; wtrs0 : in Transform_3d; results : access sResults) return math.Real is shape : tShape; shape1 : aliased impact.d3.Shape.convex.internal.sphere.item := impact.d3.Shape.convex.internal.sphere.to_sphere_Shape (margin); wtrs1 : constant Transform_3d := impact.d3.Transform.to_Transform (impact.d3.Quaternions.to_Quaternion (0.0, 0.0, 0.0, 1.0), position); begin Initialize (shape0, wtrs0, shape1'Unchecked_Access, wtrs1, results.all, shape, False); declare use linear_Algebra_3d, impact.d3.Transform, impact.d3.Vector; gjk : aliased gjkepa2_impl.GJK; gjk_status : constant gjkepa2_impl.eStatus := gjk.Evaluate (shape, (1.0, 1.0, 1.0)); w0, w1 : math.Vector_3; the_delta : math.Vector_3; margin, length, p : math.Real; begin if gjk_status = Valid then w0 := (0.0, 0.0, 0.0); w1 := (0.0, 0.0, 0.0); for i in U'(1) .. gjk.m_simplex.rank loop p := gjk.m_simplex.p (Integer (i)); w0 := w0 + shape.Support (gjk.m_simplex.c (Integer (i)).d, 0) * p; w1 := w1 + shape.Support (-gjk.m_simplex.c (Integer (i)).d, 1) * p; end loop; results.witnesses (1) := wtrs0 * w0; results.witnesses (2) := wtrs0 * w1; the_delta := results.witnesses (2) - results.witnesses (1); margin := shape0.getMarginNonVirtual + shape1.getMarginNonVirtual; length := impact.d3.Vector.length (the_delta); results.normal := the_delta / length; results.witnesses (1) := results.witnesses (1) + results.normal * margin; return length - margin; else if gjk_status = Inside then if Penetration (shape0, wtrs0, shape1'Unchecked_Access, wtrs1, gjk.m_ray, results) then the_delta := results.witnesses (1) - results.witnesses (2); length := impact.d3.Vector.length (the_delta); if length >= impact.d3.Scalar.SIMD_EPSILON then results.normal := the_delta / length; end if; return -length; end if; end if; end if; return impact.d3.Scalar.SIMD_INFINITY; end; end SignedDistance; function SignedDistance (shape0 : in impact.d3.Shape.convex.view; wtrs0 : in Transform_3d; shape1 : in impact.d3.Shape.convex.view; wtrs1 : in Transform_3d; guess : in math.Vector_3; results : access sResults) return Boolean is begin if not Distance (shape0, wtrs0, shape1, wtrs1, guess, results) then return Penetration (shape0, wtrs0, shape1, wtrs1, guess, results, False); else return True; end if; end SignedDistance; end btGjkEpaSolver2; end impact.d3.collision.gjk_epa;
macro.asm
Sahilsinggh/MPL
0
97931
<reponame>Sahilsinggh/MPL<filename>macro.asm %macro print 2 mov rax,01 mov rdi,01 mov rsi,%1 mov rdx,%2 syscall %endmacro %macro read 2 mov rax,00 mov rdi,00 mov rsi,%1 mov rdx,%2 syscall %endmacro
arch/ARM/RP/svd/rp2040/rp_svd-watchdog.ads
morbos/Ada_Drivers_Library
2
5973
<gh_stars>1-10 -- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. -- -- SPDX-License-Identifier: BSD-3-Clause -- This spec has been automatically generated from rp2040.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package RP_SVD.WATCHDOG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CTRL_TIME_Field is HAL.UInt24; -- CTRL_PAUSE_DBG array type CTRL_PAUSE_DBG_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for CTRL_PAUSE_DBG type CTRL_PAUSE_DBG_Field (As_Array : Boolean := False) is record case As_Array is when False => -- PAUSE_DBG as a value Val : HAL.UInt2; when True => -- PAUSE_DBG as an array Arr : CTRL_PAUSE_DBG_Field_Array; end case; end record with Unchecked_Union, Size => 2; for CTRL_PAUSE_DBG_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Watchdog control\n The rst_wdsel register determines which subsystems -- are reset when the watchdog is triggered.\n The watchdog can be -- triggered in software. type CTRL_Register is record -- Read-only. Indicates the number of ticks / 2 (see errata RP2040-E1) -- before a watchdog reset will be triggered TIME : CTRL_TIME_Field := 16#0#; -- Pause the watchdog timer when JTAG is accessing the bus fabric PAUSE_JTAG : Boolean := True; -- Pause the watchdog timer when processor 0 is in debug mode PAUSE_DBG : CTRL_PAUSE_DBG_Field := (As_Array => False, Val => 16#1#); -- unspecified Reserved_27_29 : HAL.UInt3 := 16#0#; -- When not enabled the watchdog timer is paused ENABLE : Boolean := False; -- After a write operation all bits in the field are cleared (set to -- zero). Trigger a watchdog reset TRIGGER : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CTRL_Register use record TIME at 0 range 0 .. 23; PAUSE_JTAG at 0 range 24 .. 24; PAUSE_DBG at 0 range 25 .. 26; Reserved_27_29 at 0 range 27 .. 29; ENABLE at 0 range 30 .. 30; TRIGGER at 0 range 31 .. 31; end record; subtype LOAD_LOAD_Field is HAL.UInt24; -- Load the watchdog timer. The maximum setting is 0xffffff which -- corresponds to 0xffffff / 2 ticks before triggering a watchdog reset -- (see errata RP2040-E1). type LOAD_Register is record -- Write-only. LOAD : LOAD_LOAD_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for LOAD_Register use record LOAD at 0 range 0 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; -- Logs the reason for the last reset. Both bits are zero for the case of a -- hardware reset. type REASON_Register is record -- Read-only. TIMER : Boolean; -- Read-only. FORCE : Boolean; -- unspecified Reserved_2_31 : HAL.UInt30; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for REASON_Register use record TIMER at 0 range 0 .. 0; FORCE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; subtype TICK_CYCLES_Field is HAL.UInt9; subtype TICK_COUNT_Field is HAL.UInt9; -- Controls the tick generator type TICK_Register is record -- Total number of clk_tick cycles before the next tick. CYCLES : TICK_CYCLES_Field := 16#0#; -- start / stop tick generation ENABLE : Boolean := True; -- Read-only. Is the tick generator running? RUNNING : Boolean := False; -- Read-only. Count down timer: the remaining number clk_tick cycles -- before the next tick is generated. COUNT : TICK_COUNT_Field := 16#0#; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TICK_Register use record CYCLES at 0 range 0 .. 8; ENABLE at 0 range 9 .. 9; RUNNING at 0 range 10 .. 10; COUNT at 0 range 11 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; ----------------- -- Peripherals -- ----------------- type WATCHDOG_Peripheral is record -- Watchdog control\n The rst_wdsel register determines which subsystems -- are reset when the watchdog is triggered.\n The watchdog can be -- triggered in software. CTRL : aliased CTRL_Register; -- Load the watchdog timer. The maximum setting is 0xffffff which -- corresponds to 0xffffff / 2 ticks before triggering a watchdog reset -- (see errata RP2040-E1). LOAD : aliased LOAD_Register; -- Logs the reason for the last reset. Both bits are zero for the case -- of a hardware reset. REASON : aliased REASON_Register; -- Scratch register. Information persists through soft reset of the -- chip. SCRATCH0 : aliased HAL.UInt32; -- Scratch register. Information persists through soft reset of the -- chip. SCRATCH1 : aliased HAL.UInt32; -- Scratch register. Information persists through soft reset of the -- chip. SCRATCH2 : aliased HAL.UInt32; -- Scratch register. Information persists through soft reset of the -- chip. SCRATCH3 : aliased HAL.UInt32; -- Scratch register. Information persists through soft reset of the -- chip. SCRATCH4 : aliased HAL.UInt32; -- Scratch register. Information persists through soft reset of the -- chip. SCRATCH5 : aliased HAL.UInt32; -- Scratch register. Information persists through soft reset of the -- chip. SCRATCH6 : aliased HAL.UInt32; -- Scratch register. Information persists through soft reset of the -- chip. SCRATCH7 : aliased HAL.UInt32; -- Controls the tick generator TICK : aliased TICK_Register; end record with Volatile; for WATCHDOG_Peripheral use record CTRL at 16#0# range 0 .. 31; LOAD at 16#4# range 0 .. 31; REASON at 16#8# range 0 .. 31; SCRATCH0 at 16#C# range 0 .. 31; SCRATCH1 at 16#10# range 0 .. 31; SCRATCH2 at 16#14# range 0 .. 31; SCRATCH3 at 16#18# range 0 .. 31; SCRATCH4 at 16#1C# range 0 .. 31; SCRATCH5 at 16#20# range 0 .. 31; SCRATCH6 at 16#24# range 0 .. 31; SCRATCH7 at 16#28# range 0 .. 31; TICK at 16#2C# range 0 .. 31; end record; WATCHDOG_Periph : aliased WATCHDOG_Peripheral with Import, Address => WATCHDOG_Base; end RP_SVD.WATCHDOG;
arch/x86/kernel/entry.asm
stlankes/hermitux-kernel
0
85531
<reponame>stlankes/hermitux-kernel ; Copyright (c) 2010-2015, <NAME>, RWTH Aachen University ; 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 University 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 REGENTS 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. ; This is the kernel's entry point. We could either call main here, ; or we can use this to setup the stack or other nice stuff, like ; perhaps setting up the GDT and segments. Please note that interrupts ; are disabled at this point: More on interrupts later! %include "hermit/config.asm" [BITS 64] extern kernel_start ; defined in linker script MSR_FS_BASE equ 0xc0000100 MSR_GS_BASE equ 0xc0000101 MSR_KERNEL_GS_BASE equ 0xc0000102 ; We use a special name to map this section at the begin of our kernel ; => Multiboot expects its magic number at the beginning of the kernel. SECTION .mboot global _start _start: jmp start64 align 4 global base global limit global cpu_freq global boot_processor global cpu_online global possible_cpus global current_boot_id global isle global possible_isles global phy_rcce_internals global phy_isle_locks global heap_phy_start_address global header_phy_start_address global heap_start_address global header_start_address global heap_size global header_size global disable_x2apic global mb_info global hbmem_base global hbmem_size global uhyve global image_size global uartport global cmdline global cmdsize global hcip global hcgateway global hcmask global tux_entry global tux_size global tux_gdb global tux_prof_samples global tux_prof_samples_num global minifs_enabled global tux_start_address global tux_ehdr_phoff global tux_ehdr_phnum global tux_ehdr_phentsize base dq 0 limit dq 0 cpu_freq dd 0 boot_processor dd -1 cpu_online dd 0 possible_cpus dd 0 phy_rcce_internals dq 0 current_boot_id dd 0 isle dd -1 image_size dq 0 phy_isle_locks dq 0 heap_phy_start_address dq 0 header_phy_start_address dq 0 heap_size dd 0 header_size dd 0 possible_isles dd 1 heap_start_address dq 0 header_start_address dq 0 disable_x2apic dd 1 single_kernel dd 1 mb_info dq 0 hbmem_base dq 0 hbmem_size dq 0 uhyve dd 0 uartport dq 0 cmdline dq 0 cmdsize dq 0 hcip db 10,0,5,2 hcgateway db 10,0,5,1 hcmask db 255,255,255,0 align 8 tux_entry dq 0 tux_size dq 0 tux_gdb db 0 tux_prof_samples dq 0 tux_prof_samples_num dq 0 minifs_enabled db 0 tux_start_address dq 0 tux_ehdr_phoff dq 0 tux_ehdr_phnum dq 0 tux_ehdr_phentsize dq 0 ; Bootstrap page tables are used during the initialization. align 4096 boot_pml4: DQ boot_pdpt + 0x27 ; PG_PRESENT | PG_RW | PG_USER | PG_ACCESSED times 510 DQ 0 ; PAGE_MAP_ENTRIES - 2 DQ boot_pml4 + 0x223 ; PG_PRESENT | PG_RW | PG_ACCESSED | PG_SELF (self-reference) boot_pdpt: DQ boot_pgd + 0x23 ; PG_PRESENT | PG_RW | PG_ACCESSED times 510 DQ 0 ; PAGE_MAP_ENTRIES - 2 DQ boot_pml4 + 0x223 ; PG_PRESENT | PG_RW | PG_ACCESSED | PG_SELF (self-reference) boot_pgd: DQ boot_pgt + 0x23 ; PG_PRESENT | PG_RW | PG_ACCESSED times 510 DQ 0 ; PAGE_MAP_ENTRIES - 2 DQ boot_pml4 + 0x223 ; PG_PRESENT | PG_RW | PG_ACCESSED | PG_SELF (self-reference) boot_pgt: times 512 DQ 0 SECTION .ktext align 4 start64: ; reset registers to kill any stale realmode selectors mov eax, 0x10 mov ds, eax mov ss, eax mov es, eax xor eax, eax mov fs, eax mov gs, eax ; clear DF flag => default value by entering a function ; => see ABI cld xor rax, rax mov eax, DWORD [cpu_online] cmp eax, 0 jne Lno_pml4_init ; store pointer to the multiboot information mov [mb_info], QWORD rdx ; relocate page tables mov rdi, boot_pml4 mov rax, QWORD [rdi] sub rax, kernel_start add rax, [base] mov QWORD [rdi], rax mov rax, QWORD [rdi+511*8] sub rax, kernel_start add rax, [base] mov QWORD [rdi+511*8], rax mov rdi, boot_pdpt mov rax, QWORD [rdi] sub rax, kernel_start add rax, [base] mov QWORD [rdi], rax mov rax, QWORD [rdi+511*8] sub rax, kernel_start add rax, [base] mov QWORD [rdi+511*8], rax mov rdi, boot_pgd mov rax, QWORD [rdi] sub rax, kernel_start add rax, [base] mov QWORD [rdi], rax mov rax, QWORD [rdi+511*8] sub rax, kernel_start add rax, [base] mov QWORD [rdi+511*8], rax ; map multiboot info mov rax, QWORD [mb_info] and rax, ~0xFFF ; page align lower half cmp rax, 0 je Lno_mbinfo mov rdi, rax shr rdi, 9 ; (edi >> 12) * 8 (index for boot_pgt) add rdi, boot_pgt or rax, 0x23 ; set present, accessed and writable bits mov QWORD [rdi], rax Lno_mbinfo: ; remap kernel mov rdi, kernel_start shr rdi, 18 ; (edi >> 21) * 8 (index for boot_pgd) add rdi, boot_pgd mov rax, [base] or rax, 0xA3 ; PG_GLOBAL isn't required because HermitCore is a single-address space OS xor rcx, rcx mov rsi, 510*0x200000 sub rsi, kernel_start mov r11, QWORD [image_size] Lremap: mov QWORD [rdi], rax add rax, 0x200000 add rcx, 0x200000 add rdi, 8 ; note: the whole code segement has to fit in the first pgd cmp rcx, rsi jnl Lno_pml4_init cmp rcx, r11 jl Lremap Lno_pml4_init: ; Set CR3 mov rax, boot_pml4 sub rax, kernel_start add rax, [base] or rax, (1 << 0) ; set present bit mov cr3, rax %if MAX_CORES > 1 mov eax, DWORD [cpu_online] cmp eax, 0 jne Lsmp_main %endif ; set default stack pointer mov rsp, boot_stack add rsp, KERNEL_STACK_SIZE-16 xor rax, rax mov eax, [boot_processor] cmp eax, -1 je L1 imul eax, KERNEL_STACK_SIZE add rsp, rax L1: mov rbp, rsp ; jump to the boot processors's C code extern hermit_main call hermit_main jmp $ %if MAX_CORES > 1 ALIGN 64 Lsmp_main: xor rax, rax mov eax, DWORD [current_boot_id] ; set default stack pointer imul rax, KERNEL_STACK_SIZE add rax, boot_stack add rax, KERNEL_STACK_SIZE-16 mov rsp, rax mov rbp, rsp extern smp_start call smp_start jmp $ %endif ALIGN 64 global gdt_flush extern gp ; This will set up our new segment registers and is declared in ; C as 'extern void gdt_flush();' gdt_flush: lgdt [gp] ; reload the segment descriptors mov eax, 0x10 mov ds, eax mov es, eax mov ss, eax xor eax, eax mov fs, eax mov gs, eax ; create pseudo interrupt to set cs push QWORD 0x10 ; SS push rsp ; RSP add QWORD [rsp], 0x08 ; => value of rsp before the creation of a pseudo interrupt pushfq ; RFLAGS push QWORD 0x08 ; CS push QWORD rollback ; RIP iretq ; The first 32 interrupt service routines (ISR) entries correspond to exceptions. ; Some exceptions will push an error code onto the stack which is specific to ; the exception caused. To decrease the complexity, we handle this by pushing a ; Dummy error code of 0 onto the stack for any ISR that doesn't push an error ; code already. ; ; ISRs are registered as "Interrupt Gate". ; Therefore, the interrupt flag (IF) is already cleared. ; NASM macro which pushs also an pseudo error code %macro isrstub_pseudo_error 1 global isr%1 align 64 isr%1: push byte 0 ; pseudo error code push byte %1 jmp common_stub %endmacro ; Similar to isrstub_pseudo_error, but without pushing ; a pseudo error code => The error code is already ; on the stack. %macro isrstub 1 global isr%1 align 64 isr%1: push byte %1 jmp common_stub %endmacro ; Create isr entries, where the number after the ; pseudo error code represents following interrupts: ; 0: Divide By Zero Exception ; 1: Debug Exception ; 2: Non Maskable Interrupt Exception ; 3: Int 3 Exception ; 4: INTO Exception ; 5: Out of Bounds Exception ; 6: Invalid Opcode Exception ; 7: Coprocessor Not Available Exception %assign i 0 %rep 8 isrstub_pseudo_error i %assign i i+1 %endrep ; 8: Double Fault Exception (With Error Code!) isrstub 8 ; 9: Coprocessor Segment Overrun Exception isrstub_pseudo_error 9 ; 10: Bad TSS Exception (With Error Code!) ; 11: Segment Not Present Exception (With Error Code!) ; 12: Stack Fault Exception (With Error Code!) ; 13: General Protection Fault Exception (With Error Code!) ; 14: Page Fault Exception (With Error Code!) %assign i 10 %rep 5 isrstub i %assign i i+1 %endrep ; 15: Reserved Exception ; 16: Floating Point Exception ; 17: Alignment Check Exception ; 18: Machine Check Exception ; 19-31: Reserved %assign i 15 %rep 17 isrstub_pseudo_error i %assign i i+1 %endrep ; NASM macro for asynchronous interrupts (no exceptions) %macro irqstub 1 global irq%1 align 64 irq%1: push byte 0 ; pseudo error code push byte 32+%1 jmp common_stub %endmacro ; Create entries for the interrupts 0 to 23 %assign i 0 %rep 24 irqstub i %assign i i+1 %endrep ; Create entries for the interrupts 80 to 82 %assign i 80 %rep 3 irqstub i %assign i i+1 %endrep global wakeup align 64 wakeup: push byte 0 ; pseudo error code push byte 121 jmp common_stub global mmnif_irq align 64 mmnif_irq: push byte 0 ; pseudo error code push byte 122 jmp common_stub global apic_timer align 64 apic_timer: push byte 0 ; pseudo error code push byte 123 jmp common_stub global apic_lint0 align 64 apic_lint0: push byte 0 ; pseudo error code push byte 124 jmp common_stub global apic_lint1 align 64 apic_lint1: push byte 0 ; pseudo error code push byte 125 jmp common_stub global apic_error align 64 apic_error: push byte 0 ; pseudo error code push byte 126 jmp common_stub global apic_svr align 64 apic_svr: push byte 0 ; pseudo error code push byte 127 jmp common_stub extern irq_handler extern get_current_stack extern finish_task_switch extern syscall_handler global isyscall isyscall: cli push rax push rcx push rdx push rbx sub rsp, 8 push rbp push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 push 0 ; dummy fs push 0 ; dummy gs ;swapgs ; Pierre: I believe this is not needed (it actually causes issues ; with SMP and threads created through clone task as gs becomes 0 ; on the first syscall when entering the kerne) ; set pointer at "struct state" as first argument mov rdi, rsp sti extern syscall_handler call syscall_handler cli ;swapgs ; Pierre: I think this is not needed add rsp, 16 pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rdi pop rsi pop rbp add rsp, 8 pop rbx pop rdx pop rcx pop rax push r11 popfq sti jmp rcx ;o64 sysret global getcontext align 64 getcontext: cli ; save general purpose regsiters mov QWORD [rdi + 0x00], r15 mov QWORD [rdi + 0x08], r14 mov QWORD [rdi + 0x10], r13 mov QWORD [rdi + 0x18], r12 mov QWORD [rdi + 0x20], r9 mov QWORD [rdi + 0x28], r8 mov QWORD [rdi + 0x30], rdi mov QWORD [rdi + 0x38], rsi mov QWORD [rdi + 0x40], rbp mov QWORD [rdi + 0x48], rbx mov QWORD [rdi + 0x50], rdx mov QWORD [rdi + 0x58], rcx lea rax, [rsp + 0x08] mov QWORD [rdi + 0x60], rax mov rax, QWORD [rsp] mov QWORD [rdi + 0x68], rax ; save FPU state fnstenv [rdi + 0x74] lea rax, [rdi + 0x70] stmxcsr [rax] xor rax, rax sti ret global setcontext align 64 setcontext: cli ; restore FPU state fldenv [rdi + 0x74] lea rax, [rdi + 0x70] ldmxcsr [rax] ; restore general purpose registers mov r15, QWORD [rdi + 0x00] mov r14, QWORD [rdi + 0x08] mov r13, QWORD [rdi + 0x10] mov r12, QWORD [rdi + 0x18] mov r9, QWORD [rdi + 0x20] mov r8, QWORD [rdi + 0x28] mov rdi, QWORD [rdi + 0x30] mov rsi, QWORD [rdi + 0x38] mov rbp, QWORD [rdi + 0x40] mov rbx, QWORD [rdi + 0x48] mov rdx, QWORD [rdi + 0x50] mov rcx, QWORD [rdi + 0x58] mov rsp, QWORD [rdi + 0x60] push QWORD [rdi + 0x68] xor rax, rax sti ret global __startcontext align 64 __startcontext: mov rsp, rbx pop rdi cmp rdi, 0 je Lno_context call setcontext Lno_context: extern exit call exit jmp $ global switch_context align 64 switch_context: ; by entering a function the DF flag has to be cleared => see ABI cld ; create on the stack a pseudo interrupt ; afterwards, we switch to the task with iret push QWORD 0x10 ; SS push rsp ; RSP add QWORD [rsp], 0x08 ; => value of rsp before the creation of a pseudo interrupt pushfq ; RFLAGS push QWORD 0x08 ; CS push QWORD rollback ; RIP push QWORD 0x00edbabe ; Error code push QWORD 0x00 ; Interrupt number push rax push rcx push rdx push rbx push QWORD [rsp+9*8] push rbp push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 ; push fs and gs registers global Lpatch0 Lpatch0: jmp short Lrdfsgs1 ; we patch later this jump to enable rdfsbase/rdgsbase rdfsbase rax rdgsbase rdx push rax push rdx jmp short Lgo1 Lrdfsgs1: mov ecx, MSR_FS_BASE rdmsr sub rsp, 8 mov DWORD [rsp+4], edx mov DWORD [rsp], eax mov ecx, MSR_GS_BASE rdmsr sub rsp, 8 mov DWORD [rsp+4], edx mov DWORD [rsp], eax Lgo1: mov rax, rdi ; rdi contains the address to store the old rsp jmp common_switch align 64 rollback: ret align 64 common_stub: push rax push rcx push rdx push rbx push QWORD [rsp+9*8] ; push user-space rsp, which is already on the stack push rbp push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 ; push fs and gs registers global Lpatch1 Lpatch1: jmp short Lrdfsgs2 ; we patch later this jump to enable rdfsbase/rdgsbase rdfsbase rax rdgsbase rdx push rax push rdx jmp short Lgo2 Lrdfsgs2: mov ecx, MSR_FS_BASE rdmsr sub rsp, 8 mov DWORD [rsp+4], edx mov DWORD [rsp], eax mov ecx, MSR_GS_BASE rdmsr sub rsp, 8 mov DWORD [rsp+4], edx mov DWORD [rsp], eax Lgo2: ; do we interrupt user-level code? cmp QWORD [rsp+24+18*8], 0x08 je short kernel_space1 swapgs ; set GS to the kernel selector kernel_space1: ; use the same handler for interrupts and exceptions mov rdi, rsp call irq_handler cmp rax, 0 je no_context_switch common_switch: mov QWORD [rax], rsp ; store old rsp call get_current_stack ; get new rsp mov rsp, rax %ifidn SAVE_FPU,ON ; set task switched flag mov rax, cr0 or rax, 8 mov cr0, rax %endif ; call cleanup code call finish_task_switch no_context_switch: ; do we interrupt user-level code? cmp QWORD [rsp+24+18*8], 0x08 je short kernel_space2 swapgs ; set GS to the user-level selector kernel_space2: ; restore fs / gs register global Lpatch2 Lpatch2: jmp short Lwrfsgs ; we patch later this jump to enable wrfsbase/wrgsbase pop r15 ; wrgsbase r15 ; currently, we don't use the gs register pop r15 wrfsbase r15 jmp short Lgo3 Lwrfsgs: ;mov ecx, MSR_GS_BASE ;mov edx, DWORD [rsp+4] ;mov eax, DWORD [rsp] add rsp, 8 ;wrmsr ; currently, we don't use the gs register mov ecx, MSR_FS_BASE mov edx, DWORD [rsp+4] mov eax, DWORD [rsp] ; TODO implement skip restore FS here add rsp, 8 wrmsr Lgo3: pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rdi pop rsi pop rbp add rsp, 8 pop rbx pop rdx pop rcx pop rax add rsp, 16 iretq global is_uhyve align 64 is_uhyve: mov eax, DWORD [uhyve] ret global is_single_kernel align 64 is_single_kernel: mov eax, DWORD [single_kernel] ret global sighandler_epilog sighandler_epilog: ; restore only those registers that might have changed between returning ; from IRQ and execution of signal handler add rsp, 2 * 8 ; ignore fs, gs pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rdi pop rsi pop rbp add rsp, 8 ; ignore rsp pop rbx pop rdx pop rcx pop rax add rsp, 4 * 8 ; ignore int_no, error, rip, cs popfq add rsp, 2 * 8 ; ignore userrsp, ss jmp [rsp - 5 * 8] ; jump to rip from saved state SECTION .data align 4096 global boot_stack boot_stack: TIMES (MAX_CORES*KERNEL_STACK_SIZE) DB 0xcd global boot_ist boot_ist: TIMES KERNEL_STACK_SIZE DB 0xcd ; add some hints to the ELF file SECTION .note.GNU-stack noalloc noexec nowrite progbits
alloy4fun_models/trashltl/models/4/WDa5x2Y9pNtszhaMa.als
Kaixi26/org.alloytools.alloy
0
4586
open main pred idWDa5x2Y9pNtszhaMa_prop5 { (some f:File | eventually f not in File) } pred __repair { idWDa5x2Y9pNtszhaMa_prop5 } check __repair { idWDa5x2Y9pNtszhaMa_prop5 <=> prop5o }
src/firmware-tests/Platform/Motor/EnableDisable/EnableDisableAdcTest.asm
pete-restall/Cluck2Sesame-Prototype
1
93018
<reponame>pete-restall/Cluck2Sesame-Prototype #include "Platform.inc" #include "FarCalls.inc" #include "Motor.inc" #include "../../Adc/EnableDisableAdcMocks.inc" #include "TestFixture.inc" radix decimal udata global numberOfEnableCalls global numberOfDisableCalls global expectedCalledEnableAdcCount global expectedCalledDisableAdcCount numberOfEnableCalls res 1 numberOfDisableCalls res 1 expectedCalledEnableAdcCount res 1 expectedCalledDisableAdcCount res 1 EnableDisableAdcTest code global testArrange testArrange: fcall initialiseEnableAndDisableAdcMocks fcall initialiseMotor testAct: banksel numberOfEnableCalls movf numberOfEnableCalls btfsc STATUS, Z goto callDisableMotorVdd callEnableMotorVdd: fcall enableMotorVdd banksel numberOfEnableCalls decfsz numberOfEnableCalls goto testAct callDisableMotorVdd: banksel numberOfDisableCalls movf numberOfDisableCalls btfsc STATUS, Z goto testAssert callDisableMotorVddInLoop: fcall disableMotorVdd banksel numberOfDisableCalls decfsz numberOfDisableCalls goto callDisableMotorVddInLoop testAssert: .aliasForAssert calledEnableAdcCount, _a .aliasForAssert expectedCalledEnableAdcCount, _b .assert "_a == _b, 'Expected calls to enableAdc() did not match expectation.'" .aliasForAssert calledDisableAdcCount, _a .aliasForAssert expectedCalledDisableAdcCount, _b .assert "_a == _b, 'Expected calls to disableAdc() did not match expectation.'" return end
Transynther/x86/_processed/NONE/_xt_/i9-9900K_12_0xa0.log_21829_373.asm
ljhsiun2/medusa
9
83900
<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r15 push %r8 push %rax push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x13eef, %rsi lea addresses_WT_ht+0xd9df, %rdi nop nop nop nop nop cmp %rdx, %rdx mov $9, %rcx rep movsl nop and %r8, %r8 lea addresses_normal_ht+0x10e6f, %rax xor $61451, %rbp movw $0x6162, (%rax) nop nop nop nop nop xor %rcx, %rcx lea addresses_A_ht+0xa62f, %rsi lea addresses_normal_ht+0xe5ef, %rdi nop sub %r8, %r8 mov $73, %rcx rep movsb nop nop nop nop xor $33871, %rcx lea addresses_UC_ht+0xbfef, %rsi lea addresses_D_ht+0x606f, %rdi clflush (%rdi) nop nop nop nop nop dec %r15 mov $43, %rcx rep movsl nop nop nop sub $40663, %rsi lea addresses_UC_ht+0xb0ef, %rcx clflush (%rcx) nop nop nop dec %rbp movups (%rcx), %xmm3 vpextrq $1, %xmm3, %rax xor $61346, %rcx lea addresses_D_ht+0x14faf, %r15 nop nop nop nop nop cmp $31151, %rbp movups (%r15), %xmm5 vpextrq $1, %xmm5, %rsi nop nop nop nop xor %rdi, %rdi lea addresses_UC_ht+0xa18f, %rcx nop nop and $62871, %r8 movb (%rcx), %r15b nop nop nop and %rdi, %rdi lea addresses_WT_ht+0x3eaf, %rsi lea addresses_WC_ht+0x66ef, %rdi sub $49676, %rbp mov $18, %rcx rep movsq nop nop nop nop nop cmp %r8, %r8 lea addresses_normal_ht+0x150ef, %rsi nop nop nop nop sub $32395, %rdi movw $0x6162, (%rsi) nop nop cmp $30894, %rcx lea addresses_WT_ht+0x122e8, %rsi nop nop nop nop nop xor %rbp, %rbp and $0xffffffffffffffc0, %rsi vmovaps (%rsi), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $1, %xmm1, %r15 nop nop nop nop cmp %rdx, %rdx lea addresses_WT_ht+0x13aef, %rsi clflush (%rsi) nop nop nop nop inc %r8 mov (%rsi), %rdx nop nop nop nop nop add $51262, %rdx lea addresses_A_ht+0x11e0f, %rdx clflush (%rdx) xor %rdi, %rdi movups (%rdx), %xmm1 vpextrq $1, %xmm1, %r8 nop nop nop nop add %rdx, %rdx lea addresses_WC_ht+0x12a8b, %rcx cmp $5987, %r8 movw $0x6162, (%rcx) nop add $44748, %rdi lea addresses_WC_ht+0x1a8ef, %rsi nop nop add $5930, %r15 mov (%rsi), %ebp nop nop nop nop nop dec %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r8 pop %r15 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r15 push %rbp push %rsi // Faulty Load lea addresses_PSE+0x178ef, %rbp nop nop nop xor %r15, %r15 mov (%rbp), %r10d lea oracles, %r12 and $0xff, %r10 shlq $12, %r10 mov (%r12,%r10,1), %r10 pop %rsi pop %rbp pop %r15 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 2}} {'src': {'same': False, 'congruent': 5, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_normal_ht'}} {'src': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 2}} {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_WT_ht', 'AVXalign': True, 'size': 32}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2}} {'src': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'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 */
test/Succeed/Issue4079.agda
shlevy/agda
1,989
9656
open import Agda.Builtin.Bool open import Agda.Builtin.List data Singleton : List Bool → Set where singleton : ∀ b → Singleton (b ∷ []) Works : (bs : List Bool) → Singleton bs → Set₁ Works bs s with s ... | singleton b with Set Works .(b ∷ []) s | singleton b | _ = Set Fails : (bs : List Bool) → Singleton bs → Set₁ Fails bs s with singleton b ← s with Set Fails .(b ∷ []) s | _ = Set
libsrc/graphics/w_stencil_add_side.asm
meesokim/z88dk
0
90508
; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; Compute the line coordinates and put into a vector ; Basic concept by <NAME> (calculate_side) ; ; <NAME> - 13/3/2009 ; ; ; $Id: w_stencil_add_side.asm,v 1.2 2015/01/19 01:32:46 pauloscustodio Exp $ ; ;; void stencil_add_side(int x1, int y1, int x2, int y2, unsigned char *stencil) PUBLIC stencil_add_side EXTERN w_line EXTERN stencil_add_pixel EXTERN swapgfxbk EXTERN swapgfxbk1 EXTERN stencil_ptr .stencil_add_side ld ix,0 add ix,sp ld l,(ix+2) ;pointer to stencil ld h,(ix+3) ld (stencil_ptr),hl ld l,(ix+10) ld h,(ix+11) ld e,(ix+8) ld d,(ix+9) call swapgfxbk call stencil_add_pixel ld l,(ix+6) ld h,(ix+7) ld e,(ix+4) ld d,(ix+5) ld ix,stencil_add_pixel call w_line jp swapgfxbk1
kernel/src/entry.asm
Tangent-Project/Tangent-OS
6
102007
bits 32 dd 0x1BADB002 dd 0x0 dd - 0x1BADB002 extern kmain global _start _start: mov esp,stack_end call kmain jmp $ SECTION .bss stack_begin: RESB 0x2000 stack_end:
test/asset/agda-stdlib-1.0/Algebra/Properties/Semilattice.agda
omega12345/agda-mode
0
8148
<gh_stars>0 ------------------------------------------------------------------------ -- The Agda standard library -- -- Some derivable properties ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Algebra module Algebra.Properties.Semilattice {l₁ l₂} (L : Semilattice l₁ l₂) where open Semilattice L open import Algebra.Structures open import Relation.Binary import Relation.Binary.Construct.NaturalOrder.Left as LeftNaturalOrder import Relation.Binary.Lattice as R import Relation.Binary.Properties.Poset as R open import Relation.Binary.EqReasoning setoid open import Function open import Data.Product ------------------------------------------------------------------------ -- Every semilattice can be turned into a poset via the left natural -- order. poset : Poset _ _ _ poset = LeftNaturalOrder.poset _≈_ _∧_ isSemilattice open Poset poset using (_≤_; isPartialOrder) ------------------------------------------------------------------------ -- Every algebraic semilattice can be turned into an order-theoretic one. isOrderTheoreticMeetSemilattice : R.IsMeetSemilattice _≈_ _≤_ _∧_ isOrderTheoreticMeetSemilattice = record { isPartialOrder = isPartialOrder ; infimum = LeftNaturalOrder.infimum _≈_ _∧_ isSemilattice } orderTheoreticMeetSemilattice : R.MeetSemilattice _ _ _ orderTheoreticMeetSemilattice = record { isMeetSemilattice = isOrderTheoreticMeetSemilattice } isOrderTheoreticJoinSemilattice : R.IsJoinSemilattice _≈_ (flip _≤_) _∧_ isOrderTheoreticJoinSemilattice = record { isPartialOrder = R.invIsPartialOrder poset ; supremum = R.IsMeetSemilattice.infimum isOrderTheoreticMeetSemilattice } orderTheoreticJoinSemilattice : R.JoinSemilattice _ _ _ orderTheoreticJoinSemilattice = record { isJoinSemilattice = isOrderTheoreticJoinSemilattice }
src/case/add.asm
dberkerdem/Assebmler
0
164227
LOAD 0002 STORE B LOAD 0064 STORE C LOAD 0003 STORE [C] LOAD 0004 STORE [0384] LOAD 0001 ADD 0001 ADD B ADD [C] ADD [0384] HALT
src/lib/Utilities/string_sets.adb
fintatarta/protypo
0
15334
<reponame>fintatarta/protypo<filename>src/lib/Utilities/string_sets.adb pragma Ada_2012; package body String_Sets is ------------------- -- To_Set_String -- ------------------- function To_Set_String (X : String) return Set_String is Result : Set_String (X'Range); begin for K in X'Range loop Result (K) := To_Set (X (K)); end loop; return Result; end To_Set_String; ----------- -- Match -- ----------- function Match (X : String; Pattern : Set_String) return Boolean is begin if X'Length < Pattern'Length then return False; end if; for K in Pattern'Range loop if not Is_In (X (K - Pattern'First + X'First), Pattern (K)) then return False; end if; end loop; return True; end Match; end String_Sets;
demo/std.asm
slcz/hummingbird
0
12030
#define H(x) (((((x) & 0x8) >> 3) + ((x) >> 4)) & 0xf) #define L(x) ((x) & 0xf) #define JMPWORD(x) (0x60 | ((x) >> 8)) #define li(x) lh H(x) addi L(x) #define ge #define not nori 0 #define ori(x) nori x nori ~0 #define or(x) nor x nori ~0 #define clrz setz ne #define save clrz call #define ret clrz ne call #define hlt last_instruction: jmp last_instruction #define saveframe(rtn) save JMPWORD(rtn) save rtn #define prolog .=0 start: li(0x2) st start jmp main odata = 0xff0 ctrl = 0xff1 idata = 0xff1
msp430-gcc-tics/msp430-gcc-7.3.1.24-source-full/gcc/gcc/testsuite/gnat.dg/opt41_pkg.adb
TUDSSL/TICS
7
8178
<gh_stars>1-10 with Ada.Streams; use Ada.Streams; package body Opt41_Pkg is type Wstream is new Root_Stream_Type with record S : Unbounded_String; end record; procedure Read (Stream : in out Wstream; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is null; procedure Write (Stream : in out Wstream; Item : Stream_Element_Array) is begin for J in Item'Range loop Append (Stream.S, Character'Val (Item (J))); end loop; end Write; function Rec_Write (R : Rec) return Unbounded_String is S : aliased Wstream; begin Rec'Output (S'Access, R); return S.S; end Rec_Write; type Rstream is new Root_Stream_Type with record S : String_Access; Idx : Integer := 1; end record; procedure Write (Stream : in out Rstream; Item : Stream_Element_Array) is null; procedure Read (Stream : in out Rstream; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin Last := Stream_Element_Offset'Min (Item'Last, Item'First + Stream_Element_Offset (Stream.S'Last - Stream.Idx)); for I in Item'First .. Last loop Item (I) := Stream_Element (Character'Pos (Stream.S (Stream.Idx))); Stream.Idx := Stream.Idx + 1; end loop; end Read; function Rec_Read (Str : String_Access) return Rec is S : aliased Rstream; begin S.S := Str; return Rec'Input (S'Access); end Rec_Read; end Opt41_Pkg;
C5515_Support_Files/C5515_Lib/dsplib_2.40.00/55x_src/unpack.asm
HeroSizy/Sizy
0
83705
<reponame>HeroSizy/Sizy ;*********************************************************** ; Version 2.40.00 ;*********************************************************** ; Function UNPACK ; Processor: C55xx ; Decription: Unpacks the output of a Radix-2 DIF complex FFT using bit-reversed input ; data and bit-reversed twiddle table (length N/2, cosine/sine format). ; ; Usage: void unpack(DATA *xy, ushort nx); ; ; Copyright Texas instruments Inc, 2000 ; History; ; - 07/17/2003 <NAME> changed the way the twiddle table is included ;**************************************************************** .mmregs .cpl_on .arms_off .ref twiddle ;//----------------------------------------------------------------------------- ;// Program section ;//----------------------------------------------------------------------------- .sect ".fftcode" .global _unpack _unpack: ;//----------------------------------------------------------------------------- ;// Context save / get arguments ;//----------------------------------------------------------------------------- PSH mmap(ST0_55) PSH mmap(ST1_55) PSH mmap(ST2_55) PSH mmap(ST3_55) AADD #-2,SP ; create local frame MOV pair(T2),dbl(*SP(#00h)) ; save on entry ;//----------------------------------------------------------------------------- ;// Initialization code ;//----------------------------------------------------------------------------- Initialize: AND #0FF00h,mmap(ST2_55) ; linear addr for CDP,AR2,AR3,AR0, AR1 BSET #6,ST1_55 ; set FRCT BSET #8,ST1_55 ; set SXMD BSET #9,ST1_55 ; set SATD BCLR #15,ST2_55 ; reset ARMS BCLR #10,ST1_55 ; reset M40 ;//----------------------------------------------------------------------------- ;// Unpack for RFFT ;//----------------------------------------------------------------------------- MOV XAR0,XAR1 ; AR1 = pointer to input data = rm[0] ADD T0,AR1 ; AR1 = pointer to input data = rm[N] SFTS T0,#-1 ; T0 = RFFT size/2 (req. for loop) MOV T0,T1 ; T1 = T0 = RFFT size/2 SFTS T1,#-1 ; T1 = RFFT size/4 (req. for loop) SUB #2,AR1 ; element in the data buffer SUB #2,T1 ; loop = N/4 - 2 MOV T1,BRC0 ; and store in repeat counter MOV #-1,T2 AMOV #twiddle,XAR2 ; pointer to sin and cos tables AMOV #(twiddle+1),XAR3 ; AMAR *(AR2+T0B) ; set to 2nd entry of bit reversed AMAR *(AR3+T0B) ; sin/cos table ;-------------------------------------------------------------------------------- ; process yre[0] (DC) and yre[0] (Nyquist) ; yre[0] = xre[0] + xim[0] store in yre[0] ; yre[N] = xre[0] - xim[0] store in yim[0] ; ;Scaling by 2 added to avoid overflow ;-------------------------------------------------------------------------------- MOV *AR0+ << #16,AC1 ; AC1=xre[0] ADD *AR0 << #16,AC1,AC0 ; AC0 = xre[0] + xim[0] SUB *AR0- << #16,AC1,AC1 ; AC1 = xre[0] - xim[0] MOV HI(AC0 << #-1), *AR0+ ; yre[0]=0.5*xre[0]+xim[0] MOV HI(AC1 << #-1), *AR0+ ; yim[0]=0.5*xre[0]-xim[0] ;-------------------------------------------------------------------------------- ; process y1re[1]/im[1] ... ; ;Scaling by 2 added to avoid overflow ;-------------------------------------------------------------------------------- RPTB unpack_end ; setup loopcounter (RFFT-size)/4 - 2 ADD *AR0,*AR1,AC0 ; rp = AC0 = x1Re + x2Re SUB *AR0+,*AR1+,AC3 ; im = AC3 = x1Re - x2Re SUB *AR1,*AR0,AC1 ; ip = AC1 = x2Im - x1Im ADD *AR0-,*AR1-,AC2 ; rm = AC2 = x1Im + x2Im SFTS AC2,#-1,AC2 ; rm = 0.5*AC2 = 0.5*(x1Im+x2Im) SFTS AC3,#-1,AC3 ; im = 0.5*AC3 = 0.5*(x1Re-x2Re) SFTS AC0,#-1,AC0 ; rp = 0.5*AC0 = 0.5*(x1Re+x2Re) SFTS AC1,#-1,AC1 ; ip = 0.5*AC1 = 0.5*(x2Im-x1Im) MOV HI(AC2),T1 ; save rm to T1 MOV HI(AC3),T3 ; save im to T3 ;----------------------------------------------------------------------- MASM *AR2,T1,AC0,AC2 ; y2re=AC2=rp-cos*rm MASM *AR2,T3,AC1,AC3 ; y2im=AC3=ip-cos*im MACM *AR2,T1,AC0,AC0 ; y1re=AC0=rp+cos*rm NEG AC1,AC1 MASM *(AR2+T0B),T3,AC1,AC1 ; y1im=AC1=-ip-cos*im ;----------------------------------------------------------------------- ; y1re=rp+cos*rm-sin*im MASM *AR3,T3,AC0,AC0 ; y1im=-ip-cos*im-sin*rm MASM *AR3,T1,AC1,AC1 :: MOV HI(AC0<<T2),*AR0+ ; y2re=rp-cos*rm+sin*im MACM *AR3,T3,AC2,AC2 :: MOV HI(AC1<<T2),*AR0+ ; y2im=ip-cos*im-sin*rm MASM *(AR3+T0B),T1,AC3,AC3 MOV HI(AC2<<T2),*AR1+ MOV HI(AC3<<T2),*AR1 unpack_end: SUB #3,AR1 ; adjust to next rm ;//----------------------------------------------------------------------------- ; yre(N/2) = yre(N/2) ; yim(N/2) = - yim(N/2) ; ; Scaling by 2 added to avoid overflow ;//----------------------------------------------------------------------------- MOV dbl(*AR0),pair(HI(AC0)) NEG AC1,AC1 SFTS AC0,#-1,AC0 SFTS AC1,#-1,AC1 MOV pair(HI(AC0)),dbl(*AR0) ;//----------------------------------------------------------------------------- ;// Context restore ;//----------------------------------------------------------------------------- MOV dbl(*SP(#00h)),pair(T2) AADD #2,SP ; destroy local frame ;//----------------------------------------------------------------------------- ;// Return ;//----------------------------------------------------------------------------- POP mmap(ST3_55) POP mmap(ST2_55) POP mmap(ST1_55) POP mmap(ST0_55) RET .end
programs/oeis/006/A006463.asm
jmorken/loda
1
90820
; A006463: Convolve natural numbers with characteristic function of triangular numbers. ; 0,0,1,2,4,6,8,11,14,17,20,24,28,32,36,40,45,50,55,60,65,70,76,82,88,94,100,106,112,119,126,133,140,147,154,161,168,176,184,192,200,208,216,224,232,240,249,258,267,276,285,294,303,312,321,330,340,350,360,370,380,390,400,410,420,430,440,451,462,473,484,495,506,517,528,539,550,561,572,584,596,608,620,632,644,656,668,680,692,704,716,728,741,754,767,780,793,806,819,832,845,858,871,884,897,910,924,938,952,966,980,994,1008,1022,1036,1050,1064,1078,1092,1106,1120,1135,1150,1165,1180,1195,1210,1225,1240,1255,1270,1285,1300,1315,1330,1345,1360,1376,1392,1408,1424,1440,1456,1472,1488,1504,1520,1536,1552,1568,1584,1600,1616,1632,1649,1666,1683,1700,1717,1734,1751,1768,1785,1802,1819,1836,1853,1870,1887,1904,1921,1938,1956,1974,1992,2010,2028,2046,2064,2082,2100,2118,2136,2154,2172,2190,2208,2226,2244,2262,2280,2299,2318,2337,2356,2375,2394,2413,2432,2451,2470,2489,2508,2527,2546,2565,2584,2603,2622,2641,2660,2680,2700,2720,2740,2760,2780,2800,2820,2840,2860,2880,2900,2920,2940,2960,2980,3000,3020,3040,3060,3080,3101,3122,3143,3164,3185,3206,3227,3248,3269,3290,3311,3332,3353,3374,3395,3416,3437,3458 lpb $0 add $2,1 trn $0,$2 add $1,$0 lpe
Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_21829_1614.asm
ljhsiun2/medusa
9
240691
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r13 push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x759d, %rsi lea addresses_normal_ht+0xf7dd, %rdi nop nop nop and $15941, %r11 mov $93, %rcx rep movsl sub $11141, %rcx lea addresses_normal_ht+0x1c00f, %rdx nop and $46830, %r13 mov (%rdx), %edi cmp %rsi, %rsi lea addresses_UC_ht+0xa63d, %rcx nop nop nop nop xor $1406, %r10 mov (%rcx), %r13w nop nop and %r10, %r10 lea addresses_UC_ht+0x9ae9, %rcx nop nop and $51140, %r10 mov $0x6162636465666768, %rdi movq %rdi, %xmm2 vmovups %ymm2, (%rcx) nop nop nop nop and $29413, %r10 lea addresses_UC_ht+0x523d, %rcx clflush (%rcx) nop nop dec %rsi movb (%rcx), %dl nop nop nop inc %rdx lea addresses_UC_ht+0x11a3d, %r13 xor %rcx, %rcx vmovups (%r13), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $1, %xmm3, %rsi nop add $15153, %rdi lea addresses_WT_ht+0x1423d, %rdx nop xor $26225, %r13 mov $0x6162636465666768, %r10 movq %r10, (%rdx) cmp $51202, %r10 lea addresses_normal_ht+0x12efd, %r10 nop nop nop nop nop and $46379, %r13 mov $0x6162636465666768, %rdi movq %rdi, %xmm4 vmovups %ymm4, (%r10) cmp $64232, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %r13 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r8 push %rbp push %rbx push %rsi // Faulty Load lea addresses_PSE+0x423d, %rbx nop nop nop nop nop sub $21071, %rsi mov (%rbx), %r8w lea oracles, %rbx and $0xff, %r8 shlq $12, %r8 mov (%rbx,%r8,1), %r8 pop %rsi pop %rbx pop %rbp pop %r8 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'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 */
awa/plugins/awa-wikis/src/model/awa-wikis-models.adb
twdroeger/ada-awa
0
15204
<filename>awa/plugins/awa-wikis/src/model/awa-wikis-models.adb ----------------------------------------------------------------------- -- AWA.Wikis.Models -- AWA.Wikis.Models ----------------------------------------------------------------------- -- File generated by ada-gen DO NOT MODIFY -- Template used: templates/model/package-body.xhtml -- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095 ----------------------------------------------------------------------- -- Copyright (C) 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 Ada.Unchecked_Deallocation; with Util.Beans.Objects.Time; with ASF.Events.Faces.Actions; package body AWA.Wikis.Models is use type ADO.Objects.Object_Record_Access; use type ADO.Objects.Object_Ref; pragma Warnings (Off, "formal parameter * is not referenced"); function Wiki_Content_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WIKI_CONTENT_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Wiki_Content_Key; function Wiki_Content_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WIKI_CONTENT_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Wiki_Content_Key; function "=" (Left, Right : Wiki_Content_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Wiki_Content_Ref'Class; Impl : out Wiki_Content_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Wiki_Content_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Wiki_Content_Ref) is Impl : Wiki_Content_Access; begin Impl := new Wiki_Content_Impl; Impl.Create_Date := ADO.DEFAULT_TIME; Impl.Format := AWA.Wikis.Models.Format_Type'First; Impl.Version := 0; Impl.Page_Version := 0; Impl.Page_Id := ADO.NO_IDENTIFIER; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Wiki_Content -- ---------------------------------------- procedure Set_Id (Object : in out Wiki_Content_Ref; Value : in ADO.Identifier) is Impl : Wiki_Content_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Wiki_Content_Ref) return ADO.Identifier is Impl : constant Wiki_Content_Access := Wiki_Content_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Create_Date (Object : in out Wiki_Content_Ref; Value : in Ada.Calendar.Time) is Impl : Wiki_Content_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 2, Impl.Create_Date, Value); end Set_Create_Date; function Get_Create_Date (Object : in Wiki_Content_Ref) return Ada.Calendar.Time is Impl : constant Wiki_Content_Access := Wiki_Content_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Create_Date; end Get_Create_Date; procedure Set_Content (Object : in out Wiki_Content_Ref; Value : in String) is Impl : Wiki_Content_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Content, Value); end Set_Content; procedure Set_Content (Object : in out Wiki_Content_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Wiki_Content_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Content, Value); end Set_Content; function Get_Content (Object : in Wiki_Content_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Content); end Get_Content; function Get_Content (Object : in Wiki_Content_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Wiki_Content_Access := Wiki_Content_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Content; end Get_Content; procedure Set_Format (Object : in out Wiki_Content_Ref; Value : in AWA.Wikis.Models.Format_Type) is procedure Set_Field_Enum is new ADO.Objects.Set_Field_Operation (Format_Type); Impl : Wiki_Content_Access; begin Set_Field (Object, Impl); Set_Field_Enum (Impl.all, 4, Impl.Format, Value); end Set_Format; function Get_Format (Object : in Wiki_Content_Ref) return AWA.Wikis.Models.Format_Type is Impl : constant Wiki_Content_Access := Wiki_Content_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Format; end Get_Format; procedure Set_Save_Comment (Object : in out Wiki_Content_Ref; Value : in String) is Impl : Wiki_Content_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 5, Impl.Save_Comment, Value); end Set_Save_Comment; procedure Set_Save_Comment (Object : in out Wiki_Content_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Wiki_Content_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 5, Impl.Save_Comment, Value); end Set_Save_Comment; function Get_Save_Comment (Object : in Wiki_Content_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Save_Comment); end Get_Save_Comment; function Get_Save_Comment (Object : in Wiki_Content_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Wiki_Content_Access := Wiki_Content_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Save_Comment; end Get_Save_Comment; function Get_Version (Object : in Wiki_Content_Ref) return Integer is Impl : constant Wiki_Content_Access := Wiki_Content_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Page_Version (Object : in out Wiki_Content_Ref; Value : in Integer) is Impl : Wiki_Content_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 7, Impl.Page_Version, Value); end Set_Page_Version; function Get_Page_Version (Object : in Wiki_Content_Ref) return Integer is Impl : constant Wiki_Content_Access := Wiki_Content_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Page_Version; end Get_Page_Version; procedure Set_Page_Id (Object : in out Wiki_Content_Ref; Value : in ADO.Identifier) is Impl : Wiki_Content_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Identifier (Impl.all, 8, Impl.Page_Id, Value); end Set_Page_Id; function Get_Page_Id (Object : in Wiki_Content_Ref) return ADO.Identifier is Impl : constant Wiki_Content_Access := Wiki_Content_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Page_Id; end Get_Page_Id; procedure Set_Author (Object : in out Wiki_Content_Ref; Value : in AWA.Users.Models.User_Ref'Class) is Impl : Wiki_Content_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.Author, Value); end Set_Author; function Get_Author (Object : in Wiki_Content_Ref) return AWA.Users.Models.User_Ref'Class is Impl : constant Wiki_Content_Access := Wiki_Content_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Author; end Get_Author; -- Copy of the object. procedure Copy (Object : in Wiki_Content_Ref; Into : in out Wiki_Content_Ref) is Result : Wiki_Content_Ref; begin if not Object.Is_Null then declare Impl : constant Wiki_Content_Access := Wiki_Content_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Wiki_Content_Access := new Wiki_Content_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Create_Date := Impl.Create_Date; Copy.Content := Impl.Content; Copy.Format := Impl.Format; Copy.Save_Comment := Impl.Save_Comment; Copy.Version := Impl.Version; Copy.Page_Version := Impl.Page_Version; Copy.Page_Id := Impl.Page_Id; Copy.Author := Impl.Author; end; end if; Into := Result; end Copy; procedure Find (Object : in out Wiki_Content_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Wiki_Content_Access := new Wiki_Content_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Wiki_Content_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Wiki_Content_Access := new Wiki_Content_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Wiki_Content_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Wiki_Content_Access := new Wiki_Content_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Wiki_Content_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Wiki_Content_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Wiki_Content_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Wiki_Content_Impl) is type Wiki_Content_Impl_Ptr is access all Wiki_Content_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Wiki_Content_Impl, Wiki_Content_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Wiki_Content_Impl_Ptr := Wiki_Content_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Wiki_Content_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, WIKI_CONTENT_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Wiki_Content_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Wiki_Content_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (WIKI_CONTENT_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (7) then Stmt.Save_Field (Name => COL_6_1_NAME, -- page_version Value => Object.Page_Version); Object.Clear_Modified (7); end if; if Object.Is_Modified (8) then Stmt.Save_Field (Name => COL_7_1_NAME, -- page_id Value => Object.Page_Id); Object.Clear_Modified (8); end if; if Object.Is_Modified (9) then Stmt.Save_Field (Name => COL_8_1_NAME, -- author_id Value => Object.Author); Object.Clear_Modified (9); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; end; end if; end Save; procedure Create (Object : in out Wiki_Content_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (WIKI_CONTENT_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_1_NAME, -- create_date Value => Object.Create_Date); Query.Save_Field (Name => COL_2_1_NAME, -- content Value => Object.Content); Query.Save_Field (Name => COL_3_1_NAME, -- format Value => Integer (Format_Type'Pos (Object.Format))); Query.Save_Field (Name => COL_4_1_NAME, -- save_comment Value => Object.Save_Comment); Query.Save_Field (Name => COL_5_1_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_6_1_NAME, -- page_version Value => Object.Page_Version); Query.Save_Field (Name => COL_7_1_NAME, -- page_id Value => Object.Page_Id); Query.Save_Field (Name => COL_8_1_NAME, -- author_id Value => Object.Author); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Wiki_Content_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (WIKI_CONTENT_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_Content_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Wiki_Content_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Wiki_Content_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (Impl.Create_Date); elsif Name = "content" then return Util.Beans.Objects.To_Object (Impl.Content); elsif Name = "format" then return AWA.Wikis.Models.Format_Type_Objects.To_Object (Impl.Format); elsif Name = "save_comment" then return Util.Beans.Objects.To_Object (Impl.Save_Comment); elsif Name = "page_version" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Page_Version)); elsif Name = "page_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Page_Id)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Wiki_Content_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Create_Date := Stmt.Get_Time (1); Object.Content := Stmt.Get_Unbounded_String (2); Object.Format := Format_Type'Val (Stmt.Get_Integer (3)); Object.Save_Comment := Stmt.Get_Unbounded_String (4); Object.Page_Version := Stmt.Get_Integer (6); Object.Page_Id := Stmt.Get_Identifier (7); if not Stmt.Is_Null (8) then Object.Author.Set_Key_Value (Stmt.Get_Identifier (8), Session); end if; Object.Version := Stmt.Get_Integer (5); ADO.Objects.Set_Created (Object); end Load; function Wiki_Space_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WIKI_SPACE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Wiki_Space_Key; function Wiki_Space_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WIKI_SPACE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Wiki_Space_Key; function "=" (Left, Right : Wiki_Space_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Wiki_Space_Ref'Class; Impl : out Wiki_Space_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Wiki_Space_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Wiki_Space_Ref) is Impl : Wiki_Space_Access; begin Impl := new Wiki_Space_Impl; Impl.Is_Public := False; Impl.Version := 0; Impl.Create_Date := ADO.DEFAULT_TIME; Impl.Format := AWA.Wikis.Models.Format_Type'First; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Wiki_Space -- ---------------------------------------- procedure Set_Id (Object : in out Wiki_Space_Ref; Value : in ADO.Identifier) is Impl : Wiki_Space_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Wiki_Space_Ref) return ADO.Identifier is Impl : constant Wiki_Space_Access := Wiki_Space_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Name (Object : in out Wiki_Space_Ref; Value : in String) is Impl : Wiki_Space_Access; begin Set_Field (Object, Impl); ADO.Audits.Set_Field_String (Impl.all, 2, Impl.Name, Value); end Set_Name; procedure Set_Name (Object : in out Wiki_Space_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Wiki_Space_Access; begin Set_Field (Object, Impl); ADO.Audits.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value); end Set_Name; function Get_Name (Object : in Wiki_Space_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Name); end Get_Name; function Get_Name (Object : in Wiki_Space_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Wiki_Space_Access := Wiki_Space_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Name; end Get_Name; procedure Set_Is_Public (Object : in out Wiki_Space_Ref; Value : in Boolean) is Impl : Wiki_Space_Access; begin Set_Field (Object, Impl); ADO.Audits.Set_Field_Boolean (Impl.all, 3, Impl.Is_Public, Value); end Set_Is_Public; function Get_Is_Public (Object : in Wiki_Space_Ref) return Boolean is Impl : constant Wiki_Space_Access := Wiki_Space_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Is_Public; end Get_Is_Public; function Get_Version (Object : in Wiki_Space_Ref) return Integer is Impl : constant Wiki_Space_Access := Wiki_Space_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Create_Date (Object : in out Wiki_Space_Ref; Value : in Ada.Calendar.Time) is Impl : Wiki_Space_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 5, Impl.Create_Date, Value); end Set_Create_Date; function Get_Create_Date (Object : in Wiki_Space_Ref) return Ada.Calendar.Time is Impl : constant Wiki_Space_Access := Wiki_Space_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Create_Date; end Get_Create_Date; procedure Set_Left_Side (Object : in out Wiki_Space_Ref; Value : in String) is Impl : Wiki_Space_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 6, Impl.Left_Side, Value); end Set_Left_Side; procedure Set_Left_Side (Object : in out Wiki_Space_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Wiki_Space_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 6, Impl.Left_Side, Value); end Set_Left_Side; function Get_Left_Side (Object : in Wiki_Space_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Left_Side); end Get_Left_Side; function Get_Left_Side (Object : in Wiki_Space_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Wiki_Space_Access := Wiki_Space_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Left_Side; end Get_Left_Side; procedure Set_Right_Side (Object : in out Wiki_Space_Ref; Value : in String) is Impl : Wiki_Space_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 7, Impl.Right_Side, Value); end Set_Right_Side; procedure Set_Right_Side (Object : in out Wiki_Space_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Wiki_Space_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 7, Impl.Right_Side, Value); end Set_Right_Side; function Get_Right_Side (Object : in Wiki_Space_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Right_Side); end Get_Right_Side; function Get_Right_Side (Object : in Wiki_Space_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Wiki_Space_Access := Wiki_Space_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Right_Side; end Get_Right_Side; procedure Set_Format (Object : in out Wiki_Space_Ref; Value : in AWA.Wikis.Models.Format_Type) is procedure Set_Field_Enum is new ADO.Audits.Set_Field_Operation (Format_Type, Format_Type_Objects.To_Object); Impl : Wiki_Space_Access; begin Set_Field (Object, Impl); Set_Field_Enum (Impl.all, 8, Impl.Format, Value); end Set_Format; function Get_Format (Object : in Wiki_Space_Ref) return AWA.Wikis.Models.Format_Type is Impl : constant Wiki_Space_Access := Wiki_Space_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Format; end Get_Format; procedure Set_Workspace (Object : in out Wiki_Space_Ref; Value : in AWA.Workspaces.Models.Workspace_Ref'Class) is Impl : Wiki_Space_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.Workspace, Value); end Set_Workspace; function Get_Workspace (Object : in Wiki_Space_Ref) return AWA.Workspaces.Models.Workspace_Ref'Class is Impl : constant Wiki_Space_Access := Wiki_Space_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Workspace; end Get_Workspace; -- Copy of the object. procedure Copy (Object : in Wiki_Space_Ref; Into : in out Wiki_Space_Ref) is Result : Wiki_Space_Ref; begin if not Object.Is_Null then declare Impl : constant Wiki_Space_Access := Wiki_Space_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Wiki_Space_Access := new Wiki_Space_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Name := Impl.Name; Copy.Is_Public := Impl.Is_Public; Copy.Version := Impl.Version; Copy.Create_Date := Impl.Create_Date; Copy.Left_Side := Impl.Left_Side; Copy.Right_Side := Impl.Right_Side; Copy.Format := Impl.Format; Copy.Workspace := Impl.Workspace; end; end if; Into := Result; end Copy; procedure Find (Object : in out Wiki_Space_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Wiki_Space_Access := new Wiki_Space_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Wiki_Space_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Wiki_Space_Access := new Wiki_Space_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Wiki_Space_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Wiki_Space_Access := new Wiki_Space_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Wiki_Space_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Wiki_Space_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Wiki_Space_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Wiki_Space_Impl) is type Wiki_Space_Impl_Ptr is access all Wiki_Space_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Wiki_Space_Impl, Wiki_Space_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Wiki_Space_Impl_Ptr := Wiki_Space_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Wiki_Space_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, WIKI_SPACE_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Wiki_Space_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Wiki_Space_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (WIKI_SPACE_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_2_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_2_NAME, -- name Value => Object.Name); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_2_NAME, -- is_public Value => Object.Is_Public); Object.Clear_Modified (3); end if; if Object.Is_Modified (5) then Stmt.Save_Field (Name => COL_4_2_NAME, -- create_date Value => Object.Create_Date); Object.Clear_Modified (5); end if; if Object.Is_Modified (6) then Stmt.Save_Field (Name => COL_5_2_NAME, -- left_side Value => Object.Left_Side); Object.Clear_Modified (6); end if; if Object.Is_Modified (7) then Stmt.Save_Field (Name => COL_6_2_NAME, -- right_side Value => Object.Right_Side); Object.Clear_Modified (7); end if; if Object.Is_Modified (8) then Stmt.Save_Field (Name => COL_7_2_NAME, -- format Value => Integer (Format_Type'Pos (Object.Format))); Object.Clear_Modified (8); end if; if Object.Is_Modified (9) then Stmt.Save_Field (Name => COL_8_2_NAME, -- workspace_id Value => Object.Workspace); Object.Clear_Modified (9); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; ADO.Audits.Save (Object, Session); end; end if; end Save; procedure Create (Object : in out Wiki_Space_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (WIKI_SPACE_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_2_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_2_NAME, -- name Value => Object.Name); Query.Save_Field (Name => COL_2_2_NAME, -- is_public Value => Object.Is_Public); Query.Save_Field (Name => COL_3_2_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_4_2_NAME, -- create_date Value => Object.Create_Date); Query.Save_Field (Name => COL_5_2_NAME, -- left_side Value => Object.Left_Side); Query.Save_Field (Name => COL_6_2_NAME, -- right_side Value => Object.Right_Side); Query.Save_Field (Name => COL_7_2_NAME, -- format Value => Integer (Format_Type'Pos (Object.Format))); Query.Save_Field (Name => COL_8_2_NAME, -- workspace_id Value => Object.Workspace); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); ADO.Audits.Save (Object, Session); end Create; procedure Delete (Object : in out Wiki_Space_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (WIKI_SPACE_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_Space_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Wiki_Space_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Wiki_Space_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "name" then return Util.Beans.Objects.To_Object (Impl.Name); elsif Name = "is_public" then return Util.Beans.Objects.To_Object (Impl.Is_Public); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (Impl.Create_Date); elsif Name = "left_side" then return Util.Beans.Objects.To_Object (Impl.Left_Side); elsif Name = "right_side" then return Util.Beans.Objects.To_Object (Impl.Right_Side); elsif Name = "format" then return AWA.Wikis.Models.Format_Type_Objects.To_Object (Impl.Format); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Wiki_Space_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Name := Stmt.Get_Unbounded_String (1); Object.Is_Public := Stmt.Get_Boolean (2); Object.Create_Date := Stmt.Get_Time (4); Object.Left_Side := Stmt.Get_Unbounded_String (5); Object.Right_Side := Stmt.Get_Unbounded_String (6); Object.Format := Format_Type'Val (Stmt.Get_Integer (7)); if not Stmt.Is_Null (8) then Object.Workspace.Set_Key_Value (Stmt.Get_Identifier (8), Session); end if; Object.Version := Stmt.Get_Integer (3); ADO.Objects.Set_Created (Object); end Load; function Wiki_Page_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WIKI_PAGE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Wiki_Page_Key; function Wiki_Page_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => WIKI_PAGE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Wiki_Page_Key; function "=" (Left, Right : Wiki_Page_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Wiki_Page_Ref'Class; Impl : out Wiki_Page_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Wiki_Page_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Wiki_Page_Ref) is Impl : Wiki_Page_Access; begin Impl := new Wiki_Page_Impl; Impl.Last_Version := 0; Impl.Is_Public := False; Impl.Version := 0; Impl.Read_Count := 0; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Wiki_Page -- ---------------------------------------- procedure Set_Id (Object : in out Wiki_Page_Ref; Value : in ADO.Identifier) is Impl : Wiki_Page_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Wiki_Page_Ref) return ADO.Identifier is Impl : constant Wiki_Page_Access := Wiki_Page_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Name (Object : in out Wiki_Page_Ref; Value : in String) is Impl : Wiki_Page_Access; begin Set_Field (Object, Impl); ADO.Audits.Set_Field_String (Impl.all, 2, Impl.Name, Value); end Set_Name; procedure Set_Name (Object : in out Wiki_Page_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Wiki_Page_Access; begin Set_Field (Object, Impl); ADO.Audits.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value); end Set_Name; function Get_Name (Object : in Wiki_Page_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Name); end Get_Name; function Get_Name (Object : in Wiki_Page_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Wiki_Page_Access := Wiki_Page_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Name; end Get_Name; procedure Set_Last_Version (Object : in out Wiki_Page_Ref; Value : in Integer) is Impl : Wiki_Page_Access; begin Set_Field (Object, Impl); ADO.Audits.Set_Field_Integer (Impl.all, 3, Impl.Last_Version, Value); end Set_Last_Version; function Get_Last_Version (Object : in Wiki_Page_Ref) return Integer is Impl : constant Wiki_Page_Access := Wiki_Page_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Last_Version; end Get_Last_Version; procedure Set_Is_Public (Object : in out Wiki_Page_Ref; Value : in Boolean) is Impl : Wiki_Page_Access; begin Set_Field (Object, Impl); ADO.Audits.Set_Field_Boolean (Impl.all, 4, Impl.Is_Public, Value); end Set_Is_Public; function Get_Is_Public (Object : in Wiki_Page_Ref) return Boolean is Impl : constant Wiki_Page_Access := Wiki_Page_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Is_Public; end Get_Is_Public; procedure Set_Title (Object : in out Wiki_Page_Ref; Value : in String) is Impl : Wiki_Page_Access; begin Set_Field (Object, Impl); ADO.Audits.Set_Field_String (Impl.all, 5, Impl.Title, Value); end Set_Title; procedure Set_Title (Object : in out Wiki_Page_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Wiki_Page_Access; begin Set_Field (Object, Impl); ADO.Audits.Set_Field_Unbounded_String (Impl.all, 5, Impl.Title, Value); end Set_Title; function Get_Title (Object : in Wiki_Page_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Title); end Get_Title; function Get_Title (Object : in Wiki_Page_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Wiki_Page_Access := Wiki_Page_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Title; end Get_Title; function Get_Version (Object : in Wiki_Page_Ref) return Integer is Impl : constant Wiki_Page_Access := Wiki_Page_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Read_Count (Object : in out Wiki_Page_Ref; Value : in Integer) is Impl : Wiki_Page_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 7, Impl.Read_Count, Value); end Set_Read_Count; function Get_Read_Count (Object : in Wiki_Page_Ref) return Integer is Impl : constant Wiki_Page_Access := Wiki_Page_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Read_Count; end Get_Read_Count; procedure Set_Preview (Object : in out Wiki_Page_Ref; Value : in AWA.Images.Models.Image_Ref'Class) is Impl : Wiki_Page_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 8, Impl.Preview, Value); end Set_Preview; function Get_Preview (Object : in Wiki_Page_Ref) return AWA.Images.Models.Image_Ref'Class is Impl : constant Wiki_Page_Access := Wiki_Page_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Preview; end Get_Preview; procedure Set_Wiki (Object : in out Wiki_Page_Ref; Value : in AWA.Wikis.Models.Wiki_Space_Ref'Class) is Impl : Wiki_Page_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.Wiki, Value); end Set_Wiki; function Get_Wiki (Object : in Wiki_Page_Ref) return AWA.Wikis.Models.Wiki_Space_Ref'Class is Impl : constant Wiki_Page_Access := Wiki_Page_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Wiki; end Get_Wiki; procedure Set_Content (Object : in out Wiki_Page_Ref; Value : in AWA.Wikis.Models.Wiki_Content_Ref'Class) is Impl : Wiki_Page_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 10, Impl.Content, Value); end Set_Content; function Get_Content (Object : in Wiki_Page_Ref) return AWA.Wikis.Models.Wiki_Content_Ref'Class is Impl : constant Wiki_Page_Access := Wiki_Page_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Content; end Get_Content; -- Copy of the object. procedure Copy (Object : in Wiki_Page_Ref; Into : in out Wiki_Page_Ref) is Result : Wiki_Page_Ref; begin if not Object.Is_Null then declare Impl : constant Wiki_Page_Access := Wiki_Page_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Wiki_Page_Access := new Wiki_Page_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Name := Impl.Name; Copy.Last_Version := Impl.Last_Version; Copy.Is_Public := Impl.Is_Public; Copy.Title := Impl.Title; Copy.Version := Impl.Version; Copy.Read_Count := Impl.Read_Count; Copy.Preview := Impl.Preview; Copy.Wiki := Impl.Wiki; Copy.Content := Impl.Content; end; end if; Into := Result; end Copy; procedure Find (Object : in out Wiki_Page_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Wiki_Page_Access := new Wiki_Page_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Wiki_Page_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Wiki_Page_Access := new Wiki_Page_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Wiki_Page_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Wiki_Page_Access := new Wiki_Page_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Wiki_Page_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Wiki_Page_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Wiki_Page_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Wiki_Page_Impl) is type Wiki_Page_Impl_Ptr is access all Wiki_Page_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Wiki_Page_Impl, Wiki_Page_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Wiki_Page_Impl_Ptr := Wiki_Page_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Wiki_Page_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, WIKI_PAGE_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Wiki_Page_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Wiki_Page_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (WIKI_PAGE_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_3_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_3_NAME, -- name Value => Object.Name); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_3_NAME, -- last_version Value => Object.Last_Version); Object.Clear_Modified (3); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_3_NAME, -- is_public Value => Object.Is_Public); Object.Clear_Modified (4); end if; if Object.Is_Modified (5) then Stmt.Save_Field (Name => COL_4_3_NAME, -- title Value => Object.Title); Object.Clear_Modified (5); end if; if Object.Is_Modified (7) then Stmt.Save_Field (Name => COL_6_3_NAME, -- read_count Value => Object.Read_Count); Object.Clear_Modified (7); end if; if Object.Is_Modified (8) then Stmt.Save_Field (Name => COL_7_3_NAME, -- preview_id Value => Object.Preview); Object.Clear_Modified (8); end if; if Object.Is_Modified (9) then Stmt.Save_Field (Name => COL_8_3_NAME, -- wiki_id Value => Object.Wiki); Object.Clear_Modified (9); end if; if Object.Is_Modified (10) then Stmt.Save_Field (Name => COL_9_3_NAME, -- content_id Value => Object.Content); Object.Clear_Modified (10); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; ADO.Audits.Save (Object, Session); end; end if; end Save; procedure Create (Object : in out Wiki_Page_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (WIKI_PAGE_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_3_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_3_NAME, -- name Value => Object.Name); Query.Save_Field (Name => COL_2_3_NAME, -- last_version Value => Object.Last_Version); Query.Save_Field (Name => COL_3_3_NAME, -- is_public Value => Object.Is_Public); Query.Save_Field (Name => COL_4_3_NAME, -- title Value => Object.Title); Query.Save_Field (Name => COL_5_3_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_6_3_NAME, -- read_count Value => Object.Read_Count); Query.Save_Field (Name => COL_7_3_NAME, -- preview_id Value => Object.Preview); Query.Save_Field (Name => COL_8_3_NAME, -- wiki_id Value => Object.Wiki); Query.Save_Field (Name => COL_9_3_NAME, -- content_id Value => Object.Content); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); ADO.Audits.Save (Object, Session); end Create; procedure Delete (Object : in out Wiki_Page_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (WIKI_PAGE_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_Page_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Wiki_Page_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Wiki_Page_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "name" then return Util.Beans.Objects.To_Object (Impl.Name); elsif Name = "last_version" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Last_Version)); elsif Name = "is_public" then return Util.Beans.Objects.To_Object (Impl.Is_Public); elsif Name = "title" then return Util.Beans.Objects.To_Object (Impl.Title); elsif Name = "read_count" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Read_Count)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Wiki_Page_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Name := Stmt.Get_Unbounded_String (1); Object.Last_Version := Stmt.Get_Integer (2); Object.Is_Public := Stmt.Get_Boolean (3); Object.Title := Stmt.Get_Unbounded_String (4); Object.Read_Count := Stmt.Get_Integer (6); if not Stmt.Is_Null (7) then Object.Preview.Set_Key_Value (Stmt.Get_Identifier (7), Session); end if; if not Stmt.Is_Null (8) then Object.Wiki.Set_Key_Value (Stmt.Get_Identifier (8), Session); end if; if not Stmt.Is_Null (9) then Object.Content.Set_Key_Value (Stmt.Get_Identifier (9), Session); end if; Object.Version := Stmt.Get_Integer (5); ADO.Objects.Set_Created (Object); end Load; procedure Op_Load (Bean : in out Wiki_Image_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Load (Bean : in out Wiki_Image_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Wiki_Image_Bean'Class (Bean).Load (Outcome); end Op_Load; package Binding_Wiki_Image_Bean_1 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Image_Bean, Method => Op_Load, Name => "load"); Binding_Wiki_Image_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Binding_Wiki_Image_Bean_1.Proxy'Access ); -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression. -- ------------------------------ overriding function Get_Method_Bindings (From : in Wiki_Image_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Wiki_Image_Bean_Array'Access; end Get_Method_Bindings; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_Image_Bean; Name : in String) return Util.Beans.Objects.Object is begin if Name = "folder_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Folder_Id)); elsif Name = "id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id)); elsif Name = "create_date" then if From.Create_Date.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.Time.To_Object (From.Create_Date.Value); end if; elsif Name = "uri" then if From.Uri.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (From.Uri.Value); end if; elsif Name = "storage" then return AWA.Storages.Models.Storage_Type_Objects.To_Object (From.Storage); elsif Name = "mime_type" then if From.Mime_Type.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (From.Mime_Type.Value); end if; elsif Name = "file_size" then if From.File_Size.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Long_Long_Integer (From.File_Size.Value)); end if; elsif Name = "width" then if From.Width.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Width.Value)); end if; elsif Name = "height" then if From.Height.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Height.Value)); end if; end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Wiki_Image_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "folder_id" then Item.Folder_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "id" then Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "create_date" then Item.Create_Date.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Create_Date.Is_Null then Item.Create_Date.Value := Util.Beans.Objects.Time.To_Time (Value); end if; elsif Name = "uri" then Item.Uri.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Uri.Is_Null then Item.Uri.Value := Util.Beans.Objects.To_Unbounded_String (Value); end if; elsif Name = "storage" then Item.Storage := AWA.Storages.Models.Storage_Type_Objects.To_Value (Value); elsif Name = "mime_type" then Item.Mime_Type.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Mime_Type.Is_Null then Item.Mime_Type.Value := Util.Beans.Objects.To_Unbounded_String (Value); end if; elsif Name = "file_size" then Item.File_Size.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.File_Size.Is_Null then Item.File_Size.Value := Util.Beans.Objects.To_Integer (Value); end if; elsif Name = "width" then Item.Width.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Width.Is_Null then Item.Width.Value := Util.Beans.Objects.To_Integer (Value); end if; elsif Name = "height" then Item.Height.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Height.Is_Null then Item.Height.Value := Util.Beans.Objects.To_Integer (Value); end if; end if; end Set_Value; -- -------------------- -- Read in the object the data from the query result and prepare to read the next row. -- If there is no row, raise the ADO.NOT_FOUND exception. -- -------------------- procedure Read (Into : in out Wiki_Image_Bean; Stmt : in out ADO.Statements.Query_Statement'Class) is begin if not Stmt.Has_Elements then raise ADO.Objects.NOT_FOUND; end if; Into.Folder_Id := Stmt.Get_Identifier (0); Into.Id := Stmt.Get_Identifier (1); Into.Create_Date := Stmt.Get_Nullable_Time (2); Into.Uri := Stmt.Get_Nullable_String (3); Into.Storage := AWA.Storages.Models.Storage_Type'Val (Stmt.Get_Integer (4)); Into.Mime_Type := Stmt.Get_Nullable_String (5); Into.File_Size := Stmt.Get_Nullable_Integer (6); Into.Width := Stmt.Get_Nullable_Integer (7); Into.Height := Stmt.Get_Nullable_Integer (8); Stmt.Next; end Read; -- -------------------- -- Run the query controlled by <b>Context</b> and load the result in <b>Object</b>. -- -------------------- procedure Load (Object : in out Wiki_Image_Bean'Class; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context); begin Stmt.Execute; Read (Object, Stmt); if Stmt.Has_Elements then raise ADO.Objects.NOT_FOUND; end if; end Load; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_Image_Info; Name : in String) return Util.Beans.Objects.Object is begin if Name = "folder_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Folder_Id)); elsif Name = "id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id)); elsif Name = "create_date" then if From.Create_Date.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.Time.To_Object (From.Create_Date.Value); end if; elsif Name = "uri" then if From.Uri.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (From.Uri.Value); end if; elsif Name = "storage" then return AWA.Storages.Models.Storage_Type_Objects.To_Object (From.Storage); elsif Name = "mime_type" then if From.Mime_Type.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (From.Mime_Type.Value); end if; elsif Name = "file_size" then if From.File_Size.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Long_Long_Integer (From.File_Size.Value)); end if; elsif Name = "width" then if From.Width.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Width.Value)); end if; elsif Name = "height" then if From.Height.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Height.Value)); end if; end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Wiki_Image_Info; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "folder_id" then Item.Folder_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "id" then Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "create_date" then Item.Create_Date.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Create_Date.Is_Null then Item.Create_Date.Value := Util.Beans.Objects.Time.To_Time (Value); end if; elsif Name = "uri" then Item.Uri.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Uri.Is_Null then Item.Uri.Value := Util.Beans.Objects.To_Unbounded_String (Value); end if; elsif Name = "storage" then Item.Storage := AWA.Storages.Models.Storage_Type_Objects.To_Value (Value); elsif Name = "mime_type" then Item.Mime_Type.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Mime_Type.Is_Null then Item.Mime_Type.Value := Util.Beans.Objects.To_Unbounded_String (Value); end if; elsif Name = "file_size" then Item.File_Size.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.File_Size.Is_Null then Item.File_Size.Value := Util.Beans.Objects.To_Integer (Value); end if; elsif Name = "width" then Item.Width.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Width.Is_Null then Item.Width.Value := Util.Beans.Objects.To_Integer (Value); end if; elsif Name = "height" then Item.Height.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Height.Is_Null then Item.Height.Value := Util.Beans.Objects.To_Integer (Value); end if; end if; end Set_Value; -- -------------------- -- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>. -- -------------------- procedure List (Object : in out Wiki_Image_Info_List_Bean'Class; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is begin List (Object.List, Session, Context); end List; -- -------------------- -- The information about an image used in a wiki page. -- -------------------- procedure List (Object : in out Wiki_Image_Info_Vector; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is procedure Read (Into : in out Wiki_Image_Info); Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context); Pos : Positive := 1; procedure Read (Into : in out Wiki_Image_Info) is begin Into.Folder_Id := Stmt.Get_Identifier (0); Into.Id := Stmt.Get_Identifier (1); Into.Create_Date := Stmt.Get_Nullable_Time (2); Into.Uri := Stmt.Get_Nullable_String (3); Into.Storage := AWA.Storages.Models.Storage_Type'Val (Stmt.Get_Integer (4)); Into.Mime_Type := Stmt.Get_Nullable_String (5); Into.File_Size := Stmt.Get_Nullable_Integer (6); Into.Width := Stmt.Get_Nullable_Integer (7); Into.Height := Stmt.Get_Nullable_Integer (8); end Read; begin Stmt.Execute; Wiki_Image_Info_Vectors.Clear (Object); while Stmt.Has_Elements loop Object.Insert_Space (Before => Pos); Object.Update_Element (Index => Pos, Process => Read'Access); Pos := Pos + 1; Stmt.Next; end loop; end List; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_Info; Name : in String) return Util.Beans.Objects.Object is begin if Name = "id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id)); elsif Name = "name" then return Util.Beans.Objects.To_Object (From.Name); elsif Name = "is_public" then return Util.Beans.Objects.To_Object (From.Is_Public); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (From.Create_Date); elsif Name = "page_count" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Count)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Wiki_Info; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "id" then Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "name" then Item.Name := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "is_public" then Item.Is_Public := Util.Beans.Objects.To_Boolean (Value); elsif Name = "create_date" then Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value); elsif Name = "page_count" then Item.Page_Count := Util.Beans.Objects.To_Integer (Value); end if; end Set_Value; -- -------------------- -- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>. -- -------------------- procedure List (Object : in out Wiki_Info_List_Bean'Class; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is begin List (Object.List, Session, Context); end List; -- -------------------- -- The list of wikis. -- -------------------- procedure List (Object : in out Wiki_Info_Vector; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is procedure Read (Into : in out Wiki_Info); Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context); Pos : Positive := 1; procedure Read (Into : in out Wiki_Info) is begin Into.Id := Stmt.Get_Identifier (0); Into.Name := Stmt.Get_Unbounded_String (1); Into.Is_Public := Stmt.Get_Boolean (2); Into.Create_Date := Stmt.Get_Time (3); Into.Page_Count := Stmt.Get_Integer (4); end Read; begin Stmt.Execute; Wiki_Info_Vectors.Clear (Object); while Stmt.Has_Elements loop Object.Insert_Space (Before => Pos); Object.Update_Element (Index => Pos, Process => Read'Access); Pos := Pos + 1; Stmt.Next; end loop; end List; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_Page_Info; Name : in String) return Util.Beans.Objects.Object is begin if Name = "id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id)); elsif Name = "name" then return Util.Beans.Objects.To_Object (From.Name); elsif Name = "title" then return Util.Beans.Objects.To_Object (From.Title); elsif Name = "is_public" then return Util.Beans.Objects.To_Object (From.Is_Public); elsif Name = "last_version" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Last_Version)); elsif Name = "read_count" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Read_Count)); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (From.Create_Date); elsif Name = "author" then return Util.Beans.Objects.To_Object (From.Author); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Wiki_Page_Info; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "id" then Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "name" then Item.Name := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "title" then Item.Title := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "is_public" then Item.Is_Public := Util.Beans.Objects.To_Boolean (Value); elsif Name = "last_version" then Item.Last_Version := Util.Beans.Objects.To_Integer (Value); elsif Name = "read_count" then Item.Read_Count := Util.Beans.Objects.To_Integer (Value); elsif Name = "create_date" then Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value); elsif Name = "author" then Item.Author := Util.Beans.Objects.To_Unbounded_String (Value); end if; end Set_Value; -- -------------------- -- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>. -- -------------------- procedure List (Object : in out Wiki_Page_Info_List_Bean'Class; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is begin List (Object.List, Session, Context); end List; -- -------------------- -- The information about a wiki page. -- -------------------- procedure List (Object : in out Wiki_Page_Info_Vector; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is procedure Read (Into : in out Wiki_Page_Info); Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context); Pos : Positive := 1; procedure Read (Into : in out Wiki_Page_Info) is begin Into.Id := Stmt.Get_Identifier (0); Into.Name := Stmt.Get_Unbounded_String (1); Into.Title := Stmt.Get_Unbounded_String (2); Into.Is_Public := Stmt.Get_Boolean (3); Into.Last_Version := Stmt.Get_Integer (4); Into.Read_Count := Stmt.Get_Integer (5); Into.Create_Date := Stmt.Get_Time (6); Into.Author := Stmt.Get_Unbounded_String (7); end Read; begin Stmt.Execute; Wiki_Page_Info_Vectors.Clear (Object); while Stmt.Has_Elements loop Object.Insert_Space (Before => Pos); Object.Update_Element (Index => Pos, Process => Read'Access); Pos := Pos + 1; Stmt.Next; end loop; end List; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_Version_Info; Name : in String) return Util.Beans.Objects.Object is begin if Name = "id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id)); elsif Name = "comment" then return Util.Beans.Objects.To_Object (From.Comment); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (From.Create_Date); elsif Name = "page_version" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Version)); elsif Name = "author" then return Util.Beans.Objects.To_Object (From.Author); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Wiki_Version_Info; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "id" then Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "comment" then Item.Comment := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "create_date" then Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value); elsif Name = "page_version" then Item.Page_Version := Util.Beans.Objects.To_Integer (Value); elsif Name = "author" then Item.Author := Util.Beans.Objects.To_Unbounded_String (Value); end if; end Set_Value; -- -------------------- -- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>. -- -------------------- procedure List (Object : in out Wiki_Version_Info_List_Bean'Class; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is begin List (Object.List, Session, Context); end List; -- -------------------- -- The information about a wiki page version. -- -------------------- procedure List (Object : in out Wiki_Version_Info_Vector; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is procedure Read (Into : in out Wiki_Version_Info); Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context); Pos : Positive := 1; procedure Read (Into : in out Wiki_Version_Info) is begin Into.Id := Stmt.Get_Identifier (0); Into.Comment := Stmt.Get_Unbounded_String (1); Into.Create_Date := Stmt.Get_Time (2); Into.Page_Version := Stmt.Get_Integer (3); Into.Author := Stmt.Get_Unbounded_String (4); end Read; begin Stmt.Execute; Wiki_Version_Info_Vectors.Clear (Object); while Stmt.Has_Elements loop Object.Insert_Space (Before => Pos); Object.Update_Element (Index => Pos, Process => Read'Access); Pos := Pos + 1; Stmt.Next; end loop; end List; procedure Op_Load (Bean : in out Wiki_View_Info; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Load (Bean : in out Wiki_View_Info; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Wiki_View_Info'Class (Bean).Load (Outcome); end Op_Load; package Binding_Wiki_View_Info_1 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_View_Info, Method => Op_Load, Name => "load"); Binding_Wiki_View_Info_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Binding_Wiki_View_Info_1.Proxy'Access ); -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression. -- ------------------------------ overriding function Get_Method_Bindings (From : in Wiki_View_Info) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Wiki_View_Info_Array'Access; end Get_Method_Bindings; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_View_Info; Name : in String) return Util.Beans.Objects.Object is begin if Name = "id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id)); elsif Name = "name" then if From.Name.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (From.Name.Value); end if; elsif Name = "title" then if From.Title.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (From.Title.Value); end if; elsif Name = "is_public" then if From.Is_Public.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (From.Is_Public.Value); end if; elsif Name = "version" then if From.Version.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Version.Value)); end if; elsif Name = "read_count" then if From.Read_Count.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Read_Count.Value)); end if; elsif Name = "date" then if From.Date.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.Time.To_Object (From.Date.Value); end if; elsif Name = "format" then if From.Format.Is_Null then return Util.Beans.Objects.Null_Object; else return Format_Type_Objects.To_Object (From.Format.Value); end if; elsif Name = "content" then if From.Content.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (From.Content.Value); end if; elsif Name = "save_comment" then if From.Save_Comment.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (From.Save_Comment.Value); end if; elsif Name = "left_side" then return Util.Beans.Objects.To_Object (From.Left_Side); elsif Name = "right_side" then return Util.Beans.Objects.To_Object (From.Right_Side); elsif Name = "side_format" then return AWA.Wikis.Models.Format_Type_Objects.To_Object (From.Side_Format); elsif Name = "author" then if From.Author.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (From.Author.Value); end if; elsif Name = "acl_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Acl_Id)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Wiki_View_Info; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "id" then Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "name" then Item.Name.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Name.Is_Null then Item.Name.Value := Util.Beans.Objects.To_Unbounded_String (Value); end if; elsif Name = "title" then Item.Title.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Title.Is_Null then Item.Title.Value := Util.Beans.Objects.To_Unbounded_String (Value); end if; elsif Name = "is_public" then Item.Is_Public.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Is_Public.Is_Null then Item.Is_Public.Value := Util.Beans.Objects.To_Boolean (Value); end if; elsif Name = "version" then Item.Version.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Version.Is_Null then Item.Version.Value := Util.Beans.Objects.To_Integer (Value); end if; elsif Name = "read_count" then Item.Read_Count.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Read_Count.Is_Null then Item.Read_Count.Value := Util.Beans.Objects.To_Integer (Value); end if; elsif Name = "date" then Item.Date.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Date.Is_Null then Item.Date.Value := Util.Beans.Objects.Time.To_Time (Value); end if; elsif Name = "format" then Item.Format.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Format.Is_Null then Item.Format.Value := Format_Type_Objects.To_Value (Value); end if; elsif Name = "content" then Item.Content.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Content.Is_Null then Item.Content.Value := Util.Beans.Objects.To_Unbounded_String (Value); end if; elsif Name = "save_comment" then Item.Save_Comment.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Save_Comment.Is_Null then Item.Save_Comment.Value := Util.Beans.Objects.To_Unbounded_String (Value); end if; elsif Name = "left_side" then Item.Left_Side := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "right_side" then Item.Right_Side := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "side_format" then Item.Side_Format := AWA.Wikis.Models.Format_Type_Objects.To_Value (Value); elsif Name = "author" then Item.Author.Is_Null := Util.Beans.Objects.Is_Null (Value); if not Item.Author.Is_Null then Item.Author.Value := Util.Beans.Objects.To_Unbounded_String (Value); end if; elsif Name = "acl_id" then Item.Acl_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); end if; end Set_Value; -- -------------------- -- Read in the object the data from the query result and prepare to read the next row. -- If there is no row, raise the ADO.NOT_FOUND exception. -- -------------------- procedure Read (Into : in out Wiki_View_Info; Stmt : in out ADO.Statements.Query_Statement'Class) is begin if not Stmt.Has_Elements then raise ADO.Objects.NOT_FOUND; end if; Into.Id := Stmt.Get_Identifier (0); Into.Name := Stmt.Get_Nullable_String (1); Into.Title := Stmt.Get_Nullable_String (2); Into.Is_Public := Stmt.Get_Nullable_Boolean (3); Into.Version := Stmt.Get_Nullable_Integer (4); Into.Read_Count := Stmt.Get_Nullable_Integer (5); Into.Date := Stmt.Get_Nullable_Time (6); Into.Format.Is_Null := Stmt.Is_Null (7); if not Into.Format.Is_Null then Into.Format.Value := AWA.Wikis.Models.Format_Type'Val (Stmt.Get_Integer (7)); end if; Into.Content := Stmt.Get_Nullable_String (8); Into.Save_Comment := Stmt.Get_Nullable_String (9); Into.Left_Side := Stmt.Get_Unbounded_String (10); Into.Right_Side := Stmt.Get_Unbounded_String (11); Into.Side_Format := AWA.Wikis.Models.Format_Type'Val (Stmt.Get_Integer (12)); Into.Author := Stmt.Get_Nullable_String (13); Into.Acl_Id := Stmt.Get_Identifier (14); Stmt.Next; end Read; -- -------------------- -- Run the query controlled by <b>Context</b> and load the result in <b>Object</b>. -- -------------------- procedure Load (Object : in out Wiki_View_Info'Class; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context); begin Stmt.Execute; Read (Object, Stmt); if Stmt.Has_Elements then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Op_Save (Bean : in out Wiki_Space_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Save (Bean : in out Wiki_Space_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Wiki_Space_Bean'Class (Bean).Save (Outcome); end Op_Save; package Binding_Wiki_Space_Bean_1 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Space_Bean, Method => Op_Save, Name => "save"); procedure Op_Load (Bean : in out Wiki_Space_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Load (Bean : in out Wiki_Space_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Wiki_Space_Bean'Class (Bean).Load (Outcome); end Op_Load; package Binding_Wiki_Space_Bean_2 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Space_Bean, Method => Op_Load, Name => "load"); Binding_Wiki_Space_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Binding_Wiki_Space_Bean_1.Proxy'Access, 2 => Binding_Wiki_Space_Bean_2.Proxy'Access ); -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression. -- ------------------------------ overriding function Get_Method_Bindings (From : in Wiki_Space_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Wiki_Space_Bean_Array'Access; end Get_Method_Bindings; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Wiki_Space_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "name" then Item.Set_Name (Util.Beans.Objects.To_String (Value)); elsif Name = "is_public" then Item.Set_Is_Public (Util.Beans.Objects.To_Boolean (Value)); elsif Name = "create_date" then Item.Set_Create_Date (Util.Beans.Objects.Time.To_Time (Value)); elsif Name = "left_side" then Item.Set_Left_Side (Util.Beans.Objects.To_String (Value)); elsif Name = "right_side" then Item.Set_Right_Side (Util.Beans.Objects.To_String (Value)); elsif Name = "format" then Item.Set_Format (Format_Type_Objects.To_Value (Value)); end if; end Set_Value; procedure Op_Save (Bean : in out Wiki_Page_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Save (Bean : in out Wiki_Page_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Wiki_Page_Bean'Class (Bean).Save (Outcome); end Op_Save; package Binding_Wiki_Page_Bean_1 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_Bean, Method => Op_Save, Name => "save"); procedure Op_Delete (Bean : in out Wiki_Page_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Delete (Bean : in out Wiki_Page_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Wiki_Page_Bean'Class (Bean).Delete (Outcome); end Op_Delete; package Binding_Wiki_Page_Bean_2 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_Bean, Method => Op_Delete, Name => "delete"); procedure Op_Load (Bean : in out Wiki_Page_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Load (Bean : in out Wiki_Page_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Wiki_Page_Bean'Class (Bean).Load (Outcome); end Op_Load; package Binding_Wiki_Page_Bean_3 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_Bean, Method => Op_Load, Name => "load"); procedure Op_Setup (Bean : in out Wiki_Page_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Setup (Bean : in out Wiki_Page_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Wiki_Page_Bean'Class (Bean).Setup (Outcome); end Op_Setup; package Binding_Wiki_Page_Bean_4 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_Bean, Method => Op_Setup, Name => "setup"); Binding_Wiki_Page_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Binding_Wiki_Page_Bean_1.Proxy'Access, 2 => Binding_Wiki_Page_Bean_2.Proxy'Access, 3 => Binding_Wiki_Page_Bean_3.Proxy'Access, 4 => Binding_Wiki_Page_Bean_4.Proxy'Access ); -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression. -- ------------------------------ overriding function Get_Method_Bindings (From : in Wiki_Page_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Wiki_Page_Bean_Array'Access; end Get_Method_Bindings; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Wiki_Page_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "name" then Item.Set_Name (Util.Beans.Objects.To_String (Value)); elsif Name = "last_version" then Item.Set_Last_Version (Util.Beans.Objects.To_Integer (Value)); elsif Name = "is_public" then Item.Set_Is_Public (Util.Beans.Objects.To_Boolean (Value)); elsif Name = "title" then Item.Set_Title (Util.Beans.Objects.To_String (Value)); elsif Name = "read_count" then Item.Set_Read_Count (Util.Beans.Objects.To_Integer (Value)); end if; end Set_Value; procedure Op_Load (Bean : in out Wiki_Page_List_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Load (Bean : in out Wiki_Page_List_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Wiki_Page_List_Bean'Class (Bean).Load (Outcome); end Op_Load; package Binding_Wiki_Page_List_Bean_1 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_List_Bean, Method => Op_Load, Name => "load"); Binding_Wiki_Page_List_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Binding_Wiki_Page_List_Bean_1.Proxy'Access ); -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression. -- ------------------------------ overriding function Get_Method_Bindings (From : in Wiki_Page_List_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Wiki_Page_List_Bean_Array'Access; end Get_Method_Bindings; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_Page_List_Bean; Name : in String) return Util.Beans.Objects.Object is begin if Name = "page" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page)); elsif Name = "count" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count)); elsif Name = "page_size" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Size)); elsif Name = "tag" then return Util.Beans.Objects.To_Object (From.Tag); elsif Name = "wiki_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Wiki_Id)); elsif Name = "sort" then return Util.Beans.Objects.To_Object (From.Sort); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Wiki_Page_List_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "page" then Item.Page := Util.Beans.Objects.To_Integer (Value); elsif Name = "count" then Item.Count := Util.Beans.Objects.To_Integer (Value); elsif Name = "page_size" then Item.Page_Size := Util.Beans.Objects.To_Integer (Value); elsif Name = "tag" then Item.Tag := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "wiki_id" then Item.Wiki_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "sort" then Item.Sort := Util.Beans.Objects.To_Unbounded_String (Value); end if; end Set_Value; procedure Op_Load (Bean : in out Wiki_Version_List_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Load (Bean : in out Wiki_Version_List_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Wiki_Version_List_Bean'Class (Bean).Load (Outcome); end Op_Load; package Binding_Wiki_Version_List_Bean_1 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Version_List_Bean, Method => Op_Load, Name => "load"); Binding_Wiki_Version_List_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Binding_Wiki_Version_List_Bean_1.Proxy'Access ); -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression. -- ------------------------------ overriding function Get_Method_Bindings (From : in Wiki_Version_List_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Wiki_Version_List_Bean_Array'Access; end Get_Method_Bindings; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_Version_List_Bean; Name : in String) return Util.Beans.Objects.Object is begin if Name = "page" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page)); elsif Name = "count" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count)); elsif Name = "page_size" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Size)); elsif Name = "wiki_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Wiki_Id)); elsif Name = "page_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Id)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Wiki_Version_List_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "page" then Item.Page := Util.Beans.Objects.To_Integer (Value); elsif Name = "count" then Item.Count := Util.Beans.Objects.To_Integer (Value); elsif Name = "page_size" then Item.Page_Size := Util.Beans.Objects.To_Integer (Value); elsif Name = "wiki_id" then Item.Wiki_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "page_id" then Item.Page_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); end if; end Set_Value; procedure Op_Load (Bean : in out Wiki_Page_Info_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Load (Bean : in out Wiki_Page_Info_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Wiki_Page_Info_Bean'Class (Bean).Load (Outcome); end Op_Load; package Binding_Wiki_Page_Info_Bean_1 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_Info_Bean, Method => Op_Load, Name => "load"); Binding_Wiki_Page_Info_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Binding_Wiki_Page_Info_Bean_1.Proxy'Access ); -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression. -- ------------------------------ overriding function Get_Method_Bindings (From : in Wiki_Page_Info_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Wiki_Page_Info_Bean_Array'Access; end Get_Method_Bindings; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Wiki_Page_Info_Bean; Name : in String) return Util.Beans.Objects.Object is begin if Name = "wiki_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Wiki_Id)); elsif Name = "page_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Id)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Wiki_Page_Info_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "wiki_id" then Item.Wiki_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "page_id" then Item.Page_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); end if; end Set_Value; end AWA.Wikis.Models;
Task/Loops-For-with-a-specified-step/Ada/loops-for-with-a-specified-step.ada
LaudateCorpus1/RosettaCodeData
1
14774
<reponame>LaudateCorpus1/RosettaCodeData with Loopers; use Loopers; procedure For_Main is begin Looper_1; Looper_2; Looper_3; end For_Main; package Loopers is procedure Looper_1; procedure Looper_2; procedure Looper_3; end Loopers; with Ada.Text_IO, Ada.Integer_Text_IO; use Ada.Text_IO, Ada.Integer_Text_IO; package body Loopers is procedure Looper_1 is Values : array(1..5) of Integer := (2,4,6,8,10); begin for I in Values'Range loop Put(Values(I),0); if I = Values'Last then Put_Line("."); else Put(","); end if; end loop; end Looper_1; procedure Looper_2 is E : Integer := 5; begin for I in 1..E loop Put(I*2,0); if I = E then Put_Line("."); else Put(","); end if; end loop; end Looper_2; procedure Looper_3 is Values : array(1..10) of Integer := (1,2,3,4,5,6,7,8,9,10); Indices : array(1..5) of Integer := (2,4,6,8,10); begin for I in Indices'Range loop Put(Values(Indices(I)),0); if I = Indices'Last then Put_Line("."); else Put(","); end if; end loop; end Looper_3; end Loopers;
source/system/interface.asm
mega65dev/rom-assembler
0
3093
<filename>source/system/interface.asm ; ******************************************************************************************** ; ******************************************************************************************** ; ; Name : interface.asm ; Purpose : .. ; Created : 15th Nov 1991 ; Updated : 4th Jan 2021 ; Authors : <NAME> ; ; ******************************************************************************************** ; ******************************************************************************************** ready_1 lda #%10000000 jsr _setmsg ; turn Kernel messages on lda #%11000000 trb runmod ; turn run modes off, leave trace mode on???? ready_2 bbs4 runmod,l24_1 ; print appropriate system prompt jsr _primm ; Program mode: print 'ready.' !text cr,"READY.",cr,0 bra main l24_1 jsr _primm ; Edit mode: print 'ok.' !text cr,"OK.",cr,0 main jmp (imain) ; MAIN INPUT LOOP nmain ldx #$ff ; set direct mode flag stx curlin+1 jsr InputLine ; get a line of input & buffer it ; ******************************************************************************************** ; ; Date Changes ; ==== ======= ; ; ********************************************************************************************
test/Fail/Issue464.agda
cruhland/agda
1,989
1499
<filename>test/Fail/Issue464.agda {-# OPTIONS --universe-polymorphism #-} module Issue464 where open import Common.Level data _×_ {a b}(A : Set a)(B : Set b) : Set (a ⊔ b) where _,_ : A → B → A × B data ⊥ : Set where record ⊤ : Set where ----------------------------------- data nonSP : Set1 where ι : nonSP δ : (A : Set) -> nonSP -> nonSP ⟦_⟧ : nonSP -> (Set × ⊤) -> Set ⟦ ι ⟧ UT = ⊤ ⟦ (δ A γ) ⟧ (U , T) = (U -> A) × ⟦ γ ⟧ (U , T) data U (γ : nonSP) : Set where intro : ⟦ γ ⟧ (U γ , _) -> U γ -- the positivity checker objects (as it should) if "(Set × ⊤)" is changed to "Set" -- in the type of ⟦_⟧ and "(U γ , _)" is changed accordingly to "U γ". bad : Set bad = U (δ ⊥ ι) -- constructor in : (bad -> ⊥) -> bad p : bad -> ⊥ p (intro (x , _)) = x (intro (x , _)) absurd : ⊥ absurd = p (intro (p , _))
Patches/dma_copy.asm
abitalive/SuperSmashBros
4
97710
<gh_stars>1-10 // Super Smash Bros. DMA copy demonstration arch n64.cpu endian msb //output "", create include "LIB/N64.inc" include "LIB/macros.inc" origin 0x0 insert "LIB/Super Smash Bros. (U) [!].z64" // DMA origin 0x001234 base 0x80000634 jal DMA origin 0x33204 base 0x80032604 scope DMA: { addiu sp, -0x18 sw ra, 0x14 (sp) jal 0x80002CA0 // Original instruction (DMA Copy) nop DMA: li a0, 0x00F5F4E0 // Source la a1, 0x80400000 // Destination li a2, 0x000A0B20 // Size jal 0x80002CA0 // DMA Copy nop lw ra, 0x14 (sp) jr ra addiu sp, 0x18 }
test/Succeed/Issue2792/Safe.agda
shlevy/agda
1,989
5568
{-# OPTIONS --safe #-} module Issue2792.Safe where
other.7z/NEWS.7z/NEWS/テープリストア/NEWS_05/NEWS_05.tar/home/kimura/kart/risc.lzh/risc/join/Driver-point-p.asm
prismotizm/gigaleak
0
245228
<filename>other.7z/NEWS.7z/NEWS/テープリストア/NEWS_05/NEWS_05.tar/home/kimura/kart/risc.lzh/risc/join/Driver-point-p.asm Name: Driver-point-p.asm Type: file Size: 40022 Last-Modified: '1992-07-20T04:24:16Z' SHA-1: F3C05327F077A37B9C2C311C06A26B81AD1B38A7 Description: null
citeproc-java/grammars/InternalNumber.g4
michel-kraemer/citeproc-java
63
7288
<reponame>michel-kraemer/citeproc-java grammar InternalNumber; @header { package de.undercouch.citeproc.csl.internal.helper; import de.undercouch.citeproc.csl.CSLLabel; import java.util.List; } @members { private void addElement(List<NumberElement> elements, NumberElement e) { if (elements.isEmpty()) { elements.add(e); return; } // Merge with previous element if it has the same label. Set 'plural' // flag if necessary. NumberElement lastElement = elements.get(elements.size() - 1); if (e.getLabel() == null || lastElement.getLabel() == e.getLabel()) { boolean plural = lastElement.isPlural() || (e.getLabel() != null && lastElement.getLabel() != null); lastElement = new NumberElement(lastElement.getText() + e.getText(), lastElement.getLabel(), plural); elements.set(elements.size() - 1, lastElement); } else { elements.add(e); } } } numbers returns [ List<NumberElement> elements = new ArrayList<>() ] : SPACE* e1=element { addElement($elements, $e1.el); } ( SPACE* ( ',' { addElement($elements, new NumberElement(", ")); } | ';' { addElement($elements, new NumberElement("; ")); } )+ SPACE* e2=element { addElement($elements, $e2.el); } )* ( SPACE | ',' | ';' )* EOF ; element returns [ NumberElement el ] : l=label SPACE* r1=range { $el = new NumberElement($r1.parsedText, $l.lbl, $r1.plural); } | r2=range ( SPACE+ ( label | range) )+ { $el = new NumberElement($text); } | r3=range { $el = new NumberElement($r3.parsedText, null, $r3.plural); } ; label returns [ CSLLabel lbl ] : sl=short_label { $lbl = $sl.lbl; } | ll=long_label { $lbl = $ll.lbl; } ; short_label returns [ CSLLabel lbl ] : ('bk.' | 'bks.' ) { $lbl = CSLLabel.BOOK; } | ('ch.' ) { $lbl = CSLLabel.CHAPTER; } | ('chap.' | 'chaps.' ) { $lbl = CSLLabel.CHAPTER; } | ('col.' | 'cols.' ) { $lbl = CSLLabel.COLUMN; } | ('fig.' | 'figs.' ) { $lbl = CSLLabel.FIGURE; } | ('fol.' | 'fols.' ) { $lbl = CSLLabel.FOLIO; } | ('no.' | 'nos.' ) { $lbl = CSLLabel.ISSUE; } | ('l.' | 'll.' ) { $lbl = CSLLabel.LINE; } | ('n.' | 'nn.' ) { $lbl = CSLLabel.NOTE; } | ('op.' | 'opp.' ) { $lbl = CSLLabel.OPUS; } | ('p.' | 'pp.' ) { $lbl = CSLLabel.PAGE; } | ('para.' | 'paras.' ) { $lbl = CSLLabel.PARAGRAPH; } | ('pt.' | 'pts.' ) { $lbl = CSLLabel.PART; } | ('sec.' | 'secs.' ) { $lbl = CSLLabel.SECTION; } | ('sv.' | 'svv.' ) { $lbl = CSLLabel.SUB_VERBO; } | ('s.v.' | 's.vv.' ) { $lbl = CSLLabel.SUB_VERBO; } | ('vrs.' ) { $lbl = CSLLabel.VERSE; } | ('v.' | 'vv.' ) { $lbl = CSLLabel.VERSE; } | ('vol.' | 'vols.' ) { $lbl = CSLLabel.VOLUME; } ; long_label returns [ CSLLabel lbl ] : ( 'book' | 'books' ) { $lbl = CSLLabel.BOOK; } | ( 'chapter' | 'chapters' ) { $lbl = CSLLabel.CHAPTER; } | ( 'column' | 'columns' ) { $lbl = CSLLabel.COLUMN; } | ( 'figure' | 'figures' ) { $lbl = CSLLabel.FIGURE; } | ( 'folio' | 'folios' ) { $lbl = CSLLabel.FOLIO; } | ( 'issue' | 'issues' ) { $lbl = CSLLabel.ISSUE; } | ( 'number' | 'numbers' ) { $lbl = CSLLabel.ISSUE; } | ( 'line' | 'lines' ) { $lbl = CSLLabel.LINE; } | ( 'note' | 'notes' ) { $lbl = CSLLabel.NOTE; } | ( 'opus' | 'opuses' ) { $lbl = CSLLabel.OPUS; } | ( 'opera' ) { $lbl = CSLLabel.OPUS; } | ( 'page' | 'pages' ) { $lbl = CSLLabel.PAGE; } | ( 'paragraph' | 'paragraphs' ) { $lbl = CSLLabel.PARAGRAPH; } | ( 'part' | 'parts' ) { $lbl = CSLLabel.PART; } | ( 'section' | 'sections' ) { $lbl = CSLLabel.SECTION; } | ( 'sub verbo' | 'sub verbis' ) { $lbl = CSLLabel.SUB_VERBO; } | ( 'sub-verbo' | 'sub-verbis' ) { $lbl = CSLLabel.SUB_VERBO; } | ( 'verse' | 'verses' ) { $lbl = CSLLabel.VERSE; } | ( 'volume' | 'volumes' ) { $lbl = CSLLabel.VOLUME; } ; range returns [ boolean plural = false, String parsedText ] : n1=NUMBER { $parsedText = $n1.text; } ( ( sep=( ';' | ',' | ':' | '-' | '\u2013' | '&' | 'and' | SPACE ) { $plural |= !Character.isWhitespace($sep.text.charAt(0)); boolean lastWhite = Character.isWhitespace($parsedText.charAt($parsedText.length() - 1)); switch ($sep.text) { case ";": $parsedText += "; "; break; case ",": $parsedText += ", "; break; case ":": $parsedText += ":"; break; case "-": case "\u2013": $parsedText += "\u2013"; break; case "&": if (!lastWhite) { $parsedText += " "; } $parsedText += "& "; break; case "and": if (!lastWhite) { $parsedText += " "; } $parsedText += "and "; break; case " ": if (!lastWhite) { $parsedText += " "; } break; default: break; } } )+ n2=NUMBER { $parsedText += $n2.text; } )* ; // Numbers such as 1, 2.3, 10a-b, 1.a, I.a, 1.I, I, and IV NUMBER : [0-9.]+[a-zA-Z]+[-:][a-zA-Z]+ | [0-9a-zA-Z.]+ ; SPACE : [\p{White_Space}] ;
Library/Text/UI/uiPointSize.asm
steakknife/pcgeos
504
166402
<reponame>steakknife/pcgeos COMMENT @----------------------------------------------------------------------- Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: Text Library FILE: uiPointSizeControl.asm ROUTINES: Name Description ---- ----------- GLB PointSizeControlClass Style menu object REVISION HISTORY: Name Date Description ---- ---- ----------- Doug 7/91 Initial version DESCRIPTION: This file contains routines to implement PointSizeControlClass $Id: uiPointSize.asm,v 1.1 97/04/07 11:16:46 newdeal Exp $ -------------------------------------------------------------------------------@ ;--------------------------------------------------- TextClassStructures segment resource PointSizeControlClass ;declare the class record TextClassStructures ends ;--------------------------------------------------- if not NO_CONTROLLERS TextControlCommon segment resource ;--------------------------------------------------- COMMENT @---------------------------------------------------------------------- MESSAGE: PointSizeControlGetInfo -- MSG_GEN_CONTROL_GET_INFO for PointSizeControlClass DESCRIPTION: Return group PASS: *ds:si - instance data es - segment of PointSizeControlClass ax - The message cx:dx - GenControlBuildInfo structure to fill in RETURN: none DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/31/91 Initial version ------------------------------------------------------------------------------@ PointSizeControlGetInfo method dynamic PointSizeControlClass, MSG_GEN_CONTROL_GET_INFO mov si, offset PSC_dupInfo GOTO CopyDupInfoCommon PointSizeControlGetInfo endm PSC_dupInfo GenControlBuildInfo < mask GCBF_SUSPEND_ON_APPLY, ; GCBI_flags PSC_IniFileKey, ; GCBI_initFileKey PSC_gcnList, ; GCBI_gcnList length PSC_gcnList, ; GCBI_gcnCount PSC_notifyTypeList, ; GCBI_notificationList length PSC_notifyTypeList, ; GCBI_notificationCount PSCName, ; GCBI_controllerName handle PointSizeControlUI, ; GCBI_dupBlock PSC_childList, ; GCBI_childList length PSC_childList, ; GCBI_childCount PSC_featuresList, ; GCBI_featuresList length PSC_featuresList, ; GCBI_featuresCount PSC_DEFAULT_FEATURES, ; GCBI_features handle PointSizeControlToolboxUI, ; GCBI_toolBlock PSC_toolList, ; GCBI_toolList length PSC_toolList, ; GCBI_toolCount PSC_toolFeaturesList, ; GCBI_toolFeaturesList length PSC_toolFeaturesList, ; GCBI_toolFeaturesCount PSC_DEFAULT_TOOLBOX_FEATURES> ; GCBI_toolFeatures ; Table used to build moniker string for the normal UI. These contain the ; keyboard mnemonic and the prefix (e.g., "1. ") for the moniker. PSC_namePrefixTable label lptr lptr SizeEntry1Moniker lptr SizeEntry2Moniker lptr SizeEntry3Moniker lptr SizeEntry4Moniker lptr SizeEntry5Moniker lptr SizeEntry6Moniker lptr SizeEntry7Moniker lptr SizeEntry8Moniker lptr SizeEntry9Moniker if FULL_EXECUTE_IN_PLACE ControlInfoXIP segment resource endif PSC_IniFileKey char "pointSize", 0 PSC_gcnList GCNListType \ <MANUFACTURER_ID_GEOWORKS, GAGCNLT_APP_TARGET_NOTIFY_TEXT_CHAR_ATTR_CHANGE>, <MANUFACTURER_ID_GEOWORKS, GAGCNLT_APP_TARGET_NOTIFY_POINT_SIZE_CHANGE> PSC_notifyTypeList NotificationType \ <MANUFACTURER_ID_GEOWORKS, GWNT_TEXT_CHAR_ATTR_CHANGE>, <MANUFACTURER_ID_GEOWORKS, GWNT_POINT_SIZE_CHANGE> ;--- PSC_childList GenControlChildInfo \ <offset SizesList, mask PSCF_9 or mask PSCF_10 or mask PSCF_12 or \ mask PSCF_14 or mask PSCF_18 or mask PSCF_24 or \ mask PSCF_36 or mask PSCF_54 or mask PSCF_72, 0>, <offset SmallerTrigger, mask PSCF_SMALLER, mask GCCF_IS_DIRECTLY_A_FEATURE>, <offset LargerTrigger, mask PSCF_LARGER, mask GCCF_IS_DIRECTLY_A_FEATURE>, <offset CustomSizeBox, mask PSCF_CUSTOM_SIZE, mask GCCF_IS_DIRECTLY_A_FEATURE> ; Careful, this table is in the *opposite* order as the record which ; it corresponds to. PSC_featuresList GenControlFeaturesInfo \ <offset CustomSizeBox, CustomSizeName, 0>, <offset LargerTrigger, LargerName, 0>, <offset SmallerTrigger, SmallerName, 0>, <offset Size72Entry, Size72Name, 0>, <offset Size54Entry, Size54Name, 0>, <offset Size36Entry, Size36Name, 0>, <offset Size24Entry, Size24Name, 0>, <offset Size18Entry, Size18Name, 0>, <offset Size14Entry, Size14Name, 0>, <offset Size12Entry, Size12Name, 0>, <offset Size10Entry, Size10Name, 0>, <offset Size9Entry, Size9Name, 0> ;--- PSC_toolList GenControlChildInfo \ <offset SizesToolList, mask PSCTF_9 or mask PSCTF_10 or \ mask PSCTF_12 or mask PSCTF_14 \ or mask PSCTF_18 or mask PSCTF_24 or mask PSCTF_36 \ or mask PSCTF_54 or mask PSCTF_72, 0>, <offset LargerToolTrigger, mask PSCTF_LARGER, mask GCCF_IS_DIRECTLY_A_FEATURE>, <offset SmallerToolTrigger, mask PSCTF_SMALLER, mask GCCF_IS_DIRECTLY_A_FEATURE> ; Careful, this table is in the *opposite* order as the record which ; it corresponds to. PSC_toolFeaturesList GenControlFeaturesInfo \ <offset LargerToolTrigger, LargerName, 0>, <offset SmallerToolTrigger, SmallerName, 0>, <offset Size72ToolEntry, Size72Name, 0>, <offset Size54ToolEntry, Size54Name, 0>, <offset Size36ToolEntry, Size36Name, 0>, <offset Size24ToolEntry, Size24Name, 0>, <offset Size18ToolEntry, Size18Name, 0>, <offset Size14ToolEntry, Size14Name, 0>, <offset Size12ToolEntry, Size12Name, 0>, <offset Size10ToolEntry, Size10Name, 0>, <offset Size9ToolEntry, Size9Name, 0> if FULL_EXECUTE_IN_PLACE ControlInfoXIP ends endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PointSizeControlTweakDuplicatedUI %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sets the monikers for the point sizes. Assigns the prefix (usually "1. ", "2. ", etc) dynamically so that no matter what point sizes are enabled, the item group is numbered sequentially (without any gaps). CALLED BY: MSG_GEN_CONTROL_TWEAK_DUPLICATED_UI PASS: *ds:si = PointSizeControlClass object ds:di = PointSizeControlClass instance data ds:bx = PointSizeControlClass object (same as *ds:si) es = segment of PointSizeControlClass ax = message # cx = duplicated block handle dx = features mask RETURN: Nothing DESTROYED: ax, cx SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 7/ 6/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PointSizeControlTweakDuplicatedUI method dynamic PointSizeControlClass, MSG_GEN_CONTROL_TWEAK_DUPLICATED_UI ; Check for trivial case.. no font sizes at all test dx, mask PSCF_9 or mask PSCF_10 or mask PSCF_12 or \ mask PSCF_14 or mask PSCF_18 or mask PSCF_24 or \ mask PSCF_36 or mask PSCF_54 or mask PSCF_72 jz noTweakingNecessary ; Define locals after code above because the "push cx" local will ; happen before the .enter and will then not be popped. duplicatedBlockHandle local hptr push cx stringSegment local word visMonikerChunk local lptr replaceFrame local ReplaceVisMonikerFrame featureListObject local lptr featureListName local lptr ; suffix of moniker ; inherited by called procedure ForceRef duplicatedBlockHandle ForceRef featureListObject ForceRef featureListName .enter ; Allocate an lmem block in the point size control object that ; will be used to copy vis moniker's from. Allocate it here for ; some arbitrary size and it will be resized inside the loop. mov al, mask OCF_IGNORE_DIRTY ; this is a temporary chunk mov cx, 32 call LMemAlloc mov ss:[visMonikerChunk], ax ; Set up ReplaceVisMonikerFrame mov ss:[replaceFrame].RVMF_source.offset, ax mov ax, ds:[LMBH_handle] mov ss:[replaceFrame].RVMF_source.handle, ax mov ss:[replaceFrame].RVMF_sourceType, VMST_OPTR mov ss:[replaceFrame].RVMF_dataType, VMDT_VIS_MONIKER clr ss:[replaceFrame].RVMF_length mov ss:[replaceFrame].RVMF_updateMode, VUM_MANUAL ; Lock down string block and store segment. mov bx, handle ControlStrings call MemLock mov ss:[stringSegment], ax ; Calculate offset to last item of interest in features table. ; Do byte multiply to not destroy dx mov al, offset PSCF_9 mov ah, size GenControlFeaturesInfo mul ah ; cs:ax = ptr to current element in features list ; (or, in FXIP, ControlInfoXIP:ax = ptr to current element in features ; list) ; cs:bx = ptr to current element in name prefix table ; cl = amount to shift features mask to the LEFT by to check sign bit ; ch = last feature bit to check add ax, offset PSC_featuresList mov bx, offset PSC_namePrefixTable mov cx, ((((size PSCFeatures) * 8 - 1) - offset PSCF_72) shl 8) \ or ((size PSCFeatures) * 8 - 1) - offset PSCF_9 featureLoop: mov di, dx shl di, cl jns continueLoop call PSCCreateAndReplaceMoniker continueLoop: inc cl ; change shift amount sub ax, size GenControlFeaturesInfo ; advance ax cmp cl, ch ; check to see if done jbe featureLoop ; Unlock strings block mov bx, handle ControlStrings call MemUnlock ; Free temporary LMem chunk mov ax, ss:[visMonikerChunk] call LMemFree .leave noTweakingNecessary: ret PointSizeControlTweakDuplicatedUI endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PSCCreateAndReplaceMoniker %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Utility routine used by PointSizeControlTweakDuplicatedUI. Actually creates the vis moniker and send a message to the object in the duplicated block that needs the new moniker. CALLED BY: PointSizeControlTweakDuplicatedUI PASS: *ds:si = PointSizeControlClass object ax = offset of current element in features list bx = offset of current element in name prefix table ss:bp = inherited local variables from PointSizeControlTweakDuplicatedUI RETURN: *ds:si = PointSizeControlClass object (may have been fixed) bx = updated offset into name prefix table DESTROYED: es, di SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 7/ 7/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PSCCreateAndReplaceMoniker proc near uses si, cx .enter inherit PointSizeControlTweakDuplicatedUI ; We need to ReAlloc our temporary chunk used in creating the vis ; moniker. To do this, we need the size of the prefix moniker and ; the size of the suffix (featureName) string. So, for this first ; part, we leave ds pointing to the controller object because that ; is where the new chunk is. After we ReAlloc, we exchange ds and ; es so that the movsw works correctly. ; load es:si with pointer to prefix moniker in string resource mov es, ss:[stringSegment] mov si, cs:[bx] ; get handle to prefix moniker mov si, es:[si] ; es:si = source (prefx monk) ChunkSizePtr es, si, cx ; cx = size of prefix moniker ; ReAlloc the lmem chunk used for the new moniker to the total of ; the prefix moniker size and the suffix string size push ax, bx, cx ; Get the size of the suffix string. To get this information, we ; need to go through the feature list table. While were there, ; might as well keep around the offset to the chunk of the string ; (we'll need it later) and keep the offset to the object. ; In both FXIP and non-FXIP, we set es to be the segment to ; reference for the table. This makes the code easier to read. NOFXIP< segmov es, cs, bx > NOFXIP< mov bx, ax > FXIP< push ax ; offset into features list> FXIP< mov bx, handle ControlInfoXIP ; lock down FXIP block > FXIP< call MemLock ; containing the list > FXIP< mov es, ax ; es=FXIP segment > FXIP< pop bx ; put offset into bx > mov di, es:[bx].GCFI_object mov ss:[featureListObject], di ; get the offset to the name of the feature (which is our suffix). ; We know that this is in the string resource so we don't need the ; handle. mov di, es:[bx].GCFI_name.offset mov ss:[featureListName], di FXIP< mov bx, handle ControlInfoXIP ; unlock FXIP block > FXIP< call MemUnlock > mov es, ss:[stringSegment] ; es = string segment > ; *es:di = suffix string (feature name string) ChunkSizeHandle es, di, bx ; bx = size of suffix string add cx, bx ; cx = total size ; ReAlloc the chunk mov ax, ss:[visMonikerChunk] call LMemReAlloc ; *ds:ax = the chunk pop ax, bx, cx ; load ds:di with pointer to our temporary chunk for creating the ; vis moniker. mov di, ss:[visMonikerChunk] mov di, ds:[di] ; ds:di = new chunk push di ; save beginning of new chunk ; Setup the segments for copying segxchg ds, es ; ds:si = source (prefix monikr) ; es:di = new chunk ; Copy the prefix moniker into our chunk. shr cx, 1 ; copy words rep movsw jnc doneWithPrefixCopy movsb ; copy odd byte, if any doneWithPrefixCopy: pop di ; es:di = start of new chunk ; which is now a VisMoniker clr es:[di].VM_width add di, VM_data + VMT_text ; es:di = text moniker ; We now need to append the suffix (featureName) string to our chunk. ; Search in moniker string to find zero byte/word. push ax clr ax mov cx, -1 SBCS < repne scasb ; find null byte > DBCS < repne scasw ; find null word > pop ax ; scasb/w finish one byte/word past the match.. back up to overwrite ; zero byte/word. dec di DBCS < dec di > ; Set ds:si to point to suffix string (which is the same as the name ; string stored in the GenControlFeaturesInfo list). mov si, ss:[featureListName] mov si, ds:[si] ; dereference chunk handle ; Copy the suffix string into the new vis moniker. push ax ; ds:si = suffix string ; es:di = end of the string in our new vis moniker LocalCopyString segmov ds, es, si ; ds to PointSizeControl block ; to be fixed up by ObjMessage ; Send a message to the actual item in the new object block that ; needs the moniker we just created. The replace frame argument for ; this message was set up in calling function. push bx, cx, dx, bp mov si, ss:[featureListObject] ; GCFI_object offset mov bx, ss:[duplicatedBlockHandle] lea bp, ss:[replaceFrame] mov dx, size ReplaceVisMonikerFrame mov ax, MSG_GEN_REPLACE_VIS_MONIKER mov di, mask MF_CALL or mask MF_STACK or mask MF_FIXUP_DS call ObjMessage pop bx, cx, dx, bp pop ax inc bx ; increment pointer to prefix inc bx ; monikers by 2 (size lptr) .leave ret PSCCreateAndReplaceMoniker endp COMMENT @---------------------------------------------------------------------- MESSAGE: PointSizeControlSetPointSize -- MSG_PSC_SET_POINT_SIZE for PointSizeControlClass DESCRIPTION: Handle a change in the point size PASS: *ds:si - instance data es - segment of PointSizeControlClass ax - The message MSG_PSC_SET_POINT_SIZE_FROM_LIST: cx - size MSG_PSC_SET_POINT_SIZE: dx.cx -- size RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 10/31/91 Initial version ------------------------------------------------------------------------------@ PointSizeControlSetPointSizeFromList method PointSizeControlClass, MSG_PSC_SET_POINT_SIZE_FROM_LIST mov dx, cx clr cx ;size in dx.cx FALL_THRU PointSizeControlSetPointSize PointSizeControlSetPointSizeFromList endm PointSizeControlSetPointSize method PointSizeControlClass, MSG_PSC_SET_POINT_SIZE mov ax, MSG_VIS_TEXT_SET_POINT_SIZE FALL_THRU SendMeta_AX_DXCX_Common PointSizeControlSetPointSize endm ;--- SendMeta_AX_DXCX_Common proc far pushdw dxcx ;point size clr dx push dx ;range.end.high push dx ;range.end.low mov bx, VIS_TEXT_RANGE_SELECTION push bx ;range.start.high push dx ;range.start.low mov bp, sp mov dx, size VisTextSetPointSizeParams clr bx clr di call GenControlOutputActionStack add sp, size VisTextSetPointSizeParams ret SendMeta_AX_DXCX_Common endp COMMENT @---------------------------------------------------------------------- MESSAGE: PointSizeControlSmallerPointSize -- MSG_PSC_SMALLER_POINT_SIZE for PointSizeControlClass DESCRIPTION: ... PASS: *ds:si - instance data es - segment of PointSizeControlClass ax - The message RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 12/ 5/91 Initial version ------------------------------------------------------------------------------@ PointSizeControlSmallerPointSize method dynamic PointSizeControlClass, MSG_PSC_SMALLER_POINT_SIZE mov ax, MSG_VIS_TEXT_SET_SMALLER_POINT_SIZE mov cx, MIN_POINT_SIZE GOTO SendAX_CX_Always_Common PointSizeControlSmallerPointSize endm ;--- PointSizeControlLargerPointSize method dynamic PointSizeControlClass, MSG_PSC_LARGER_POINT_SIZE mov ax, MSG_VIS_TEXT_SET_LARGER_POINT_SIZE mov cx, MAX_POINT_SIZE FALL_THRU SendAX_CX_Always_Common PointSizeControlLargerPointSize endm SendAX_CX_Always_Common proc far GOTO SendMeta_AX_CX_Common SendAX_CX_Always_Common endp COMMENT @---------------------------------------------------------------------- MESSAGE: PointSizeControlUpdateUI -- MSG_GEN_CONTROL_UPDATE_UI for PointSizeControlClass DESCRIPTION: Handle notification of attributes change PASS: *ds:si - instance data es - segment of PointSizeControlClass ax - The message ss:bp - GenControlUpdateUIParams RETURN: DESTROYED: bx, si, di, ds, es (message handler) REGISTER/STACK USAGE: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Tony 11/12/91 Initial version ------------------------------------------------------------------------------@ PointSizeControlUpdateUI method dynamic PointSizeControlClass, MSG_GEN_CONTROL_UPDATE_UI ; get notification data push ds mov bx, ss:[bp].GCUUIP_dataBlock call MemLock mov ds, ax cmp ss:[bp].GCUUIP_changeType, GWNT_TEXT_CHAR_ATTR_CHANGE jz textNotify movdw cxax, ds:NPSC_pointSize clr dx mov dl, ds:NPSC_diffs jmp common textNotify: clr al mov cx, ds:VTNCAC_charAttr.VTCA_pointSize.WBF_int mov ah, ds:VTNCAC_charAttr.VTCA_pointSize.WBF_frac mov dx, ds:VTNCAC_charAttrDiffs.VTCAD_diffs and dx, mask VTCAF_MULTIPLE_POINT_SIZES common: call MemUnlock pop ds ; cxax = size push ax mov ax, ss:[bp].GCUUIP_features mov bx, ss:[bp].GCUUIP_childBlock test ax, mask PSCF_9 or mask PSCF_10 or mask PSCF_12 or \ mask PSCF_14 \ or mask PSCF_18 or mask PSCF_24 or mask PSCF_36 \ or mask PSCF_54 or mask PSCF_72 jz noList mov si, offset SizesList call SendListSetExcl noList: ; set custom size box test ax, mask PSCF_CUSTOM_SIZE pop ax ;value to pass in cx.ax jz noCustom mov si, offset PointSizeDistance call SendRangeSetWWFixedValue noCustom: ; set toolbox test ss:[bp].GCUUIP_toolboxFeatures, mask PSCTF_9 or \ mask PSCTF_10 or mask PSCTF_12 or mask PSCTF_14 \ or mask PSCTF_18 or mask PSCTF_24 or mask PSCTF_36 \ or mask PSCTF_54 or mask PSCTF_72 jz noToolbox mov bx, ss:[bp].GCUUIP_toolBlock mov si, offset SizesToolList call SendListSetExcl noToolbox: ret PointSizeControlUpdateUI endm TextControlCommon ends endif ; not NO_CONTROLLERS
test/Succeed/Erasure-succeed-Issue3855.agda
hborum/agda
0
3607
-- Andreas, 2019-06-18, LAIM 2019, issue #3855: -- Successful tests for the erasure (@0) modality. module _ where open import Agda.Builtin.Bool open import Agda.Builtin.Nat open import Agda.Builtin.Equality open import Agda.Builtin.Coinduction open import Common.IO module WhereInErasedDeclaration where @0 n : Nat n = 4711 @0 m : Nat m = n' where n' = n module ErasedDeclarationInWhere where F : (G : @0 Set → Set) (@0 A : Set) → Set F G A = G B where @0 B : Set B = A module FlatErasure where @0 resurrect-λ : (A : Set) (@0 x : A) → A resurrect-λ A = λ x → x @0 resurrect-λ-where : (A : Set) (@0 x : A) → A resurrect-λ-where A = λ where x → x @0 resurrect-app : (A : Set) (@0 x : A) → A resurrect-app A x = x module ErasedEquality where -- Should maybe not work --without-K -- should definitely not work in --cubical cast : ∀{A B : Set} → @0 A ≡ B → A → B cast refl x = x J : ∀{A : Set} {a : A} (P : (x : A) → a ≡ x → Set) {b : A} (@0 eq : a ≡ b) → P a refl → P b eq J P refl p = p module ParametersAreErased where test : (@0 A : Set) → A ≡ A test A = refl {x = _} -- TODO: A instead of _ module Records where record R (A : Set) : Set where field el : A Par : Set Par = A -- record module parameters are NOT erased, so, this should be accepted proj : (A : Set) → R A → A -- TODO: @0 A instead of A proj A r = R.el {A = _} r MyPar : (A : Set) → R A → Set MyPar A = R.Par {A = A} record RB (b : Bool) : Set where bPar : Bool bPar = b myBPar : (b : Bool) → RB b → Bool myBPar b r = RB.bPar {b = b} r module CoinductionWithErasure (A : Set) where data Stream : Set where cons : (x : A) (xs : ∞ Stream) → Stream @0 repeat : (@0 a : A) → Stream repeat a = cons a (♯ (repeat a)) main = putStrLn "Hello, world!"
Library/GrObj/GrObj/grobjHandles.asm
steakknife/pcgeos
504
104675
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: GrObj MODULE: GrObj FILE: grobjHandles.asm AUTHOR: <NAME>, Aug 21, 1992 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Steve 8/21/92 Initial revision DESCRIPTION: $Id: grobjHandles.asm,v 1.1 97/04/04 18:07:35 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjRequiredExtInteractiveCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjHandleHitDetection %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Determines if point hits any of the objects handles PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass ss:bp - PointDWFixed in PARENT RETURN: al - EVALUATE_NONE ah - destroyed al - EVALUATE_HIGH ah - GrObjHandleSpecification of hit handle dx - 0 ( blank EvaluatePositionNotes) DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: This method should be optimized for SPEED over SMALL SIZE Common cases: GOTM_HANDLES_DRAWN will be set The CENTER RELATIVE point will fit in WWF The hit detection will fail. REVISION HISTORY: Name Date Description ---- ---- ----------- srs 12/ 6/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjHandleHitDetection method dynamic GrObjClass, MSG_GO_EVALUATE_PARENT_POINT_FOR_HANDLE, MSG_GO_EVALUATE_PARENT_POINT_FOR_HANDLE_MOVE_RESIZE, MSG_GO_EVALUATE_PARENT_POINT_FOR_HANDLE_MOVE_ROTATE uses cx,bp .enter test ds:[di].GOI_tempState, mask GOTM_HANDLES_DRAWN jz fail mov cx,mask GOL_MOVE or mask GOL_RESIZE cmp ax,MSG_GO_EVALUATE_PARENT_POINT_FOR_HANDLE_MOVE_RESIZE jne other hitDetect: call GrObjDoHitDetectionOnAllHandles jc success fail: mov al, EVALUATE_NONE done: clr dx ;EvaluatePositionNotes .leave ret success: mov al, EVALUATE_HIGH jmp short done other: mov cx,mask GOL_MOVE or mask GOL_ROTATE cmp ax,MSG_GO_EVALUATE_PARENT_POINT_FOR_HANDLE_MOVE_ROTATE je hitDetect clr cx jmp hitDetect GrObjHandleHitDetection endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjDrawHandles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draws handles to indicate object is selected. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass dx - BODY_GSTATE gstate or 0 RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: if not selected don't draw if handles are already drawn don't draw if in edit mode don't draw KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/16/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjDrawHandles method dynamic GrObjClass, MSG_GO_DRAW_HANDLES uses ax,cx,dx .enter call GrObjCanDrawHandles? jnc done ; Handles are being reset to their normal state, so clear ; the temp bit ; clr cl mov ch, mask GOTM_TEMP_HANDLES call GrObjChangeTempStateBits test ds:[di].GOI_tempState, mask GOTM_SELECTED jz done test ds:[di].GOI_tempState, mask GOTM_SYS_TARGET jz done ; if the object handles are already drawn then ; don't draw handles ; test ds:[di].GOI_tempState, mask GOTM_HANDLES_DRAWN jnz done ; Mark handles as being draw ; mov cl, mask GOTM_HANDLES_DRAWN clr ch call GrObjChangeTempStateBits ; Draw those handles ; mov di,dx ;passed gstate or 0 call GrObjGetBodyGStateStart mov dx,di ;gstate for handles mov ax,MSG_GO_INVERT_HANDLES call ObjCallInstanceNoLock call GrObjGetGStateEnd done: .leave ret GrObjDrawHandles endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjUnDrawHandles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Erases the handles that indicate the object is selected. Only erases the handles if the handlesDrawn flag IS set. PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass dx - gstate or 0 RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/16/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjUnDrawHandles method dynamic GrObjClass, MSG_GO_UNDRAW_HANDLES uses cx,dx .enter call GrObjCanDrawHandles? jnc done ; Handles are being reset to their normal state, so clear ; the temp bit ; clr cl mov ch, mask GOTM_TEMP_HANDLES call GrObjChangeTempStateBits call GrObjUnDrawHandlesLow done: .leave ret GrObjUnDrawHandles endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjUnDrawHandlesLow %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Erases the handles that indicate the object is selected. Only erases the handles if the handlesDrawn flag IS set. CALLED BY: INTERNAL GrObjUnDrawHandles PASS: *(ds:si) - instance data of object es - segment of GrObjClass dx - gstate or 0 RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/16/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjUnDrawHandlesLow proc near uses ax,bx,cx,di class GrObjClass .enter EC < call ECGrObjCheckLMemObject > ; If the handles are not drawn then don't erase them ; GrObjDeref di,ds,si test ds:[di].GOI_tempState, mask GOTM_HANDLES_DRAWN jz done ; Mark handles as not drawn ; clr cl mov ch, mask GOTM_HANDLES_DRAWN call GrObjChangeTempStateBits ; Erase those handles ; mov di,dx ;passed gstate or 0 call GrObjGetBodyGStateStart mov dx,di ;gstate mov ax,MSG_GO_INVERT_HANDLES call ObjCallInstanceNoLock call GrObjGetGStateEnd done: .leave ret GrObjUnDrawHandlesLow endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjDrawHandlesForce %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draws handles of object, reqardless of selected bit PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass dx - gstate or 0 RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: if handles are already drawn don't draw if in edit mode don't draw KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/16/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjDrawHandlesForce method dynamic GrObjClass, MSG_GO_DRAW_HANDLES_FORCE uses cx,dx .enter call GrObjCanDrawHandles? jnc done ; Having the handles forcibly drawn is a temporary state, ; mark it as such, so that we can find this object again. ; mov cl, mask GOTM_TEMP_HANDLES clr ch call GrObjChangeTempStateBits call DrawHandlesForce done: .leave ret GrObjDrawHandlesForce endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawHandlesForce %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draws handles of object, reqardless of selected bit PASS: *(ds:si) - instance data of object dx - gstate or 0 RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: if handles are already drawn don't draw if in edit mode don't draw This routine will draw the handles regardless of the state of the GOTM_SYS_TARGET bit because we can't count on that bit unless the GOTM_SELECTED bit is set. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/16/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DrawHandlesForce proc near class GrObjClass uses ax,bx,cx,di .enter EC < call ECGrObjCheckLMemObject > call GrObjCanDrawHandles? jnc done GrObjDeref di,ds,si test ds:[di].GOI_tempState, mask GOTM_HANDLES_DRAWN jnz done mov cl, mask GOTM_HANDLES_DRAWN clr ch call GrObjChangeTempStateBits mov di,dx ;passed gstate or 0 call GrObjGetBodyGStateStart mov dx,di ;gstate mov ax,MSG_GO_INVERT_HANDLES call ObjCallInstanceNoLock call GrObjGetGStateEnd done: .leave ret DrawHandlesForce endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjDrawHandlesOpposite %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draws or undraws the handles of the object to reflect the opposite of the selected bit PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass dx - gstate RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: if selected bit set call undraw handles if selected bit not set call force draw handles KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/16/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjDrawHandlesOpposite method dynamic GrObjClass, MSG_GO_DRAW_HANDLES_OPPOSITE uses cx,dx .enter ; Having the handles drawn opposite is a temporary state, ; mark it as such, so that we can find this object again. ; mov cl, mask GOTM_TEMP_HANDLES clr ch call GrObjChangeTempStateBits test ds:[di].GOI_tempState,mask GOTM_SELECTED jnz undraw call DrawHandlesForce done: .leave ret undraw: call GrObjUnDrawHandlesLow jmp short done GrObjDrawHandlesOpposite endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjDrawHandlesMatch %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draws or undraws the handles of the object to reflect the state of the selected bit PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass dx - gstate or 0 RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: if selected bit set call force draw handles if selected bit not set call undraw handles KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/16/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjDrawHandlesMatch method dynamic GrObjClass, MSG_GO_DRAW_HANDLES_MATCH uses cx,dx .enter ; Handles are being reset to their normal state, so clear ; the temp bit ; clr cl mov ch, mask GOTM_TEMP_HANDLES call GrObjChangeTempStateBits test ds:[di].GOI_tempState, mask GOTM_SELECTED jz undraw call DrawHandlesForce done: .leave ret undraw: call GrObjUnDrawHandlesLow jmp short done GrObjDrawHandlesMatch endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjInvertHandles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Inverts handles of selected object PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass dx - gstate RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: none KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/16/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjInvertHandles method dynamic GrObjClass, MSG_GO_INVERT_HANDLES uses ax .enter mov di,dx ;gstate EC < call ECCheckGStateHandle > mov al, MM_INVERT call GrSetMixMode mov al,SDM_100 call GrSetAreaMask ; See if the invisible bit is set ; call GrObjGetDesiredHandleSize tst bl ;if negative, invisible handles js justDrawMoveHandle CallMod GrObjDrawSelectedHandles done: .leave ret justDrawMoveHandle: neg bl mov cl,HANDLE_MOVE call GrObjDrawOneHandle jmp done GrObjInvertHandles endm GrObjRequiredExtInteractiveCode ends GrObjDrawCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GrObjDrawHandlesRaw %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Called to update the handles during an expose event. Draws the handles if the handlesDraw flag is set, otherwise does nothing PASS: *(ds:si) - instance data of object ds:[bx] - instance data of object ds:[di] - master part of object (if any) es - segment of GrObjClass dx - gstate RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: If the handles are drawn, draw them again because they may have been damaged. If the handles aren't drawn, do nothing, you'll only make it worse. KNOWN BUGS/SIDE EFFECTS/IDEAS: none REVISION HISTORY: Name Date Description ---- ---- ----------- srs 11/16/89 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GrObjDrawHandlesRaw method dynamic GrObjClass, MSG_GO_DRAW_HANDLES_RAW uses ax,cx .enter call GrObjCanDrawHandles? jnc done test ds:[di].GOI_tempState, mask GOTM_HANDLES_DRAWN jz done ;jmp if not drawn mov ax,MSG_GO_INVERT_HANDLES call ObjCallInstanceNoLock done: .leave ret GrObjDrawHandlesRaw endm GrObjDrawCode ends
programs/oeis/315/A315639.asm
neoneye/loda
22
83170
<reponame>neoneye/loda ; A315639: Coordination sequence Gal.4.74.4 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; 1,6,12,16,20,26,32,38,44,48,52,58,64,70,76,80,84,90,96,102,108,112,116,122,128,134,140,144,148,154,160,166,172,176,180,186,192,198,204,208,212,218,224,230,236,240,244,250,256,262 mov $1,1 mov $2,$0 lpb $0 sub $0,1 add $1,2 trn $0,$1 add $0,$1 sub $0,1 add $1,2 lpe mul $0,2 trn $0,1 lpb $2 add $0,4 sub $2,1 lpe add $0,1
extra/extra/Reasoning2.agda
manikdv/plfa.github.io
1,003
7704
import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; sym; trans) open Eq.≡-Reasoning open import Data.Nat using (ℕ; zero; suc; _+_) lift : ∀ {m n : ℕ} → m ≡ n → suc m ≡ suc n lift refl = refl +-assoc : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p) +-assoc zero n p = begin (zero + n) + p ≡⟨⟩ zero + (n + p) ∎ +-assoc (suc m) n p = begin (suc m + n) + p ≡⟨⟩ suc ((m + n) + p) ≡⟨ lift (+-assoc m n p) ⟩ suc (m + (n + p)) ≡⟨⟩ suc m + (n + p) ∎ +-identity : ∀ (m : ℕ) → m + zero ≡ m +-identity zero = begin zero + zero ≡⟨⟩ zero ∎ +-identity (suc m) = begin suc m + zero ≡⟨⟩ suc (m + zero) ≡⟨ lift (+-identity m) ⟩ suc m ∎ +-suc : ∀ (m n : ℕ) → m + suc n ≡ suc (m + n) +-suc zero n = begin zero + suc n ≡⟨⟩ suc n ≡⟨⟩ suc (zero + n) ∎ +-suc (suc m) n = begin suc m + suc n ≡⟨⟩ suc (m + suc n) ≡⟨ lift (+-suc m n) ⟩ suc (suc (m + n)) ≡⟨⟩ suc (suc m + n) ∎ +-comm : ∀ (m n : ℕ) → m + n ≡ n + m +-comm m zero = begin m + zero ≡⟨ +-identity m ⟩ m ≡⟨⟩ zero + m ∎ +-comm m (suc n) = begin m + suc n ≡⟨ +-suc m n ⟩ suc (m + n) ≡⟨ lift (+-comm m n) ⟩ suc (n + m) ≡⟨⟩ suc n + m ∎
bb-runtimes/runtimes/ravenscar-full-stm32g474/gnat/a-sttebu.ads
JCGobbi/Nucleo-STM32G474RE
0
650
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- ADA.STRINGS.TEXT_BUFFERS -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.UTF_Encoding; package Ada.Strings.Text_Buffers with Pure is type Text_Buffer_Count is range 0 .. Integer'Last; New_Line_Count : constant Text_Buffer_Count := 1; -- There is no support for two-character CR/LF line endings. type Root_Buffer_Type is abstract tagged limited private with Default_Initial_Condition => Current_Indent (Root_Buffer_Type) = 0; procedure Put (Buffer : in out Root_Buffer_Type; Item : String) is abstract; procedure Wide_Put (Buffer : in out Root_Buffer_Type; Item : Wide_String) is abstract; procedure Wide_Wide_Put (Buffer : in out Root_Buffer_Type; Item : Wide_Wide_String) is abstract; procedure Put_UTF_8 (Buffer : in out Root_Buffer_Type; Item : UTF_Encoding.UTF_8_String) is abstract; procedure Wide_Put_UTF_16 (Buffer : in out Root_Buffer_Type; Item : UTF_Encoding.UTF_16_Wide_String) is abstract; procedure New_Line (Buffer : in out Root_Buffer_Type) is abstract; Standard_Indent : constant Text_Buffer_Count := 3; function Current_Indent (Buffer : Root_Buffer_Type) return Text_Buffer_Count; procedure Increase_Indent (Buffer : in out Root_Buffer_Type; Amount : Text_Buffer_Count := Standard_Indent) with Post'Class => Current_Indent (Buffer) = Current_Indent (Buffer)'Old + Amount; procedure Decrease_Indent (Buffer : in out Root_Buffer_Type; Amount : Text_Buffer_Count := Standard_Indent) with Pre'Class => Current_Indent (Buffer) >= Amount -- or else raise Constraint_Error, or else Boolean'Val (Current_Indent (Buffer) - Amount), Post'Class => Current_Indent (Buffer) = Current_Indent (Buffer)'Old - Amount; private type Root_Buffer_Type is abstract tagged limited record Indentation : Natural := 0; -- Current indentation Indent_Pending : Boolean := True; -- Set by calls to New_Line, cleared when indentation emitted. UTF_8_Length : Natural := 0; -- Count of UTF_8 characters in the buffer UTF_8_Column : Positive := 1; -- Column in which next character will be written. -- Calling New_Line resets to 1. All_7_Bits : Boolean := True; -- True if all characters seen so far fit in 7 bits All_8_Bits : Boolean := True; -- True if all characters seen so far fit in 8 bits end record; generic -- This generic allows a client to extend Root_Buffer_Type without -- having to implement any of the abstract subprograms other than -- Put_UTF_8 (i.e., Put, Wide_Put, Wide_Wide_Put, Wide_Put_UTF_16, -- and New_Line). Without this generic, each client would have to -- duplicate the implementations of those 5 subprograms. -- This generic also takes care of handling indentation, thereby -- avoiding further code duplication. The name "Output_Mapping" isn't -- wonderful, but it refers to the idea that this package knows how -- to implement all the other output operations in terms of -- just Put_UTF_8. -- -- The classwide parameter type here is somewhat tricky; -- there are no dispatching calls associated with this parameter. -- It would be more accurate to say that the parameter is of type -- Output_Mapping.Buffer_Type'Class, but that type hasn't been declared -- yet. Instantiators will typically declare a non-abstract extension, -- B2, of the buffer type, B1, declared in their instantiation. The -- actual Put_UTF_8_Implementation parameter may then have a -- precondition "Buffer in B2'Class" and that subprogram can safely -- access components declared as part of the declaration of B2. with procedure Put_UTF_8_Implementation (Buffer : in out Root_Buffer_Type'Class; Item : UTF_Encoding.UTF_8_String); package Output_Mapping is type Buffer_Type is abstract new Root_Buffer_Type with null record; overriding procedure Put (Buffer : in out Buffer_Type; Item : String); overriding procedure Wide_Put (Buffer : in out Buffer_Type; Item : Wide_String); overriding procedure Wide_Wide_Put (Buffer : in out Buffer_Type; Item : Wide_Wide_String); overriding procedure Put_UTF_8 (Buffer : in out Buffer_Type; Item : UTF_Encoding.UTF_8_String); overriding procedure Wide_Put_UTF_16 (Buffer : in out Buffer_Type; Item : UTF_Encoding.UTF_16_Wide_String); overriding procedure New_Line (Buffer : in out Buffer_Type); end Output_Mapping; end Ada.Strings.Text_Buffers;
Transynther/x86/_processed/AVXALIGN/_ht_st_zr_/i9-9900K_12_0xca_notsx.log_21829_1764.asm
ljhsiun2/medusa
9
95558
<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r10 push %r14 push %r9 push %rcx push %rdi push %rsi lea addresses_D_ht+0x7eb5, %rsi lea addresses_D_ht+0x3e45, %rdi nop nop nop nop xor %r14, %r14 mov $61, %rcx rep movsq nop nop sub $20136, %r9 lea addresses_UC_ht+0x13ae5, %rsi lea addresses_WC_ht+0x18ee5, %rdi nop cmp $57181, %r10 mov $35, %rcx rep movsw nop nop nop nop nop and %rsi, %rsi pop %rsi pop %rdi pop %rcx pop %r9 pop %r14 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r8 push %rbx push %rcx push %rdi push %rsi // REPMOV lea addresses_RW+0x1ca5, %rsi lea addresses_D+0xee5, %rdi nop add %rbx, %rbx mov $107, %rcx rep movsq nop nop nop dec %rbx // Store lea addresses_PSE+0x1f1e5, %r8 nop nop nop nop add %r11, %r11 movb $0x51, (%r8) nop nop cmp %rbx, %rbx // Store lea addresses_WC+0x14ae5, %r11 cmp %rdi, %rdi movb $0x51, (%r11) xor $45065, %rdi // Faulty Load lea addresses_WC+0x1c6e5, %rsi nop nop nop and $9896, %rdi vmovntdqa (%rsi), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $1, %xmm1, %r13 lea oracles, %r8 and $0xff, %r13 shlq $12, %r13 mov (%r8,%r13,1), %r13 pop %rsi pop %rdi pop %rcx pop %rbx pop %r8 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_RW'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_D'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 8}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WC', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_D_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_WC_ht'}} {'46': 1025, '00': 85, '32': 20719} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 46 46 46 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 00 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 00 32 32 32 32 32 32 32 32 32 32 32 32 32 00 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 46 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 46 32 32 32 32 32 32 46 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 00 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 00 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 00 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 00 32 32 32 46 32 32 46 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 00 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 32 32 46 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 46 32 32 32 */
3-mid/physics/interface/source/physics-joint-hinge.ads
charlie5/lace
20
614
package physics.Joint.hinge -- -- An interface to a hinge joint. -- is type Item is limited interface and Joint.item; type View is access all Item'Class; procedure Limits_are (Self : in out Item; Low, High : in Real; Softness : in Real := 0.9; biasFactor : in Real := 0.3; relaxationFactor : in Real := 1.0) is abstract; function lower_Limit (Self : in Item) return Real is abstract; function upper_Limit (Self : in Item) return Real is abstract; function Angle (Self : in Item) return Real is abstract; end physics.Joint.hinge;
Rings/Examples/Examples.agda
Smaug123/agdaproofs
4
10287
<filename>Rings/Examples/Examples.agda<gh_stars>1-10 {-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Groups.Groups open import Functions.Definition open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Numbers.Integers.Integers open import Numbers.Modulo.Group open import Numbers.Modulo.Definition open import Rings.Examples.Proofs open import Numbers.Primes.PrimeNumbers open import Setoids.Setoids open import Rings.Definition open import Groups.Definition open import Groups.Lemmas open import Sets.EquivalenceRelations module Rings.Examples.Examples where multiplicationNotGroup : {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} (R : Ring S _+_ _*_) → (nontrivial : Setoid._∼_ S (Ring.1R R) (Ring.0R R) → False) → Group S _*_ → False multiplicationNotGroup {S = S} R 1!=0 gr = exFalso (1!=0 (groupsHaveLeftCancellation gr (Ring.0R R) (Ring.1R R) (Ring.0R R) (transitive (Ring.timesZero' R) (symmetric (Ring.timesZero' R))))) where open Setoid S open Equivalence eq nToZn : (n : ℕ) (pr : 0 <N n) (x : ℕ) → ℤn n pr nToZn n pr x = nToZn' n pr x mod : (n : ℕ) → (pr : 0 <N n) → ℤ → ℤn n pr mod n pr a = mod' n pr a modNExampleSurjective : (n : ℕ) → (pr : 0 <N n) → Surjection (mod n pr) modNExampleSurjective n pr = modNExampleSurjective' n pr {- modNExampleGroupHom : (n : ℕ) → (pr : 0 <N n) → GroupHom ℤGroup (ℤnGroup n pr) (mod n pr) modNExampleGroupHom n pr = modNExampleGroupHom' n pr embedZnInZ : {n : ℕ} {pr : 0 <N n} → (a : ℤn n pr) → ℤ embedZnInZ record { x = x } = nonneg x modNRoundTrip : (n : ℕ) → (pr : 0 <N n) → (a : ℤn n pr) → mod n pr (embedZnInZ a) ≡ a modNRoundTrip zero () modNRoundTrip (succ n) pr record { x = x ; xLess = xLess } with divisionAlg (succ n) x modNRoundTrip (succ n) _ record { x = x ; xLess = xLess } | record { quot = quot ; rem = rem ; pr = pr ; remIsSmall = inl remIsSmall ; quotSmall = quotSmall } = equalityZn _ _ p where p : rem ≡ x p = modIsUnique record { quot = quot ; rem = rem ; pr = pr ; remIsSmall = inl remIsSmall ; quotSmall = quotSmall } record { quot = 0 ; rem = x ; pr = identityOfIndiscernablesLeft _ _ _ _≡_ refl (applyEquality (λ i → i +N x) (multiplicationNIsCommutative 0 n)) ; remIsSmall = inl xLess ; quotSmall = inl (succIsPositive n) } modNRoundTrip (succ n) _ record { x = x ; xLess = xLess } | record { quot = quot ; rem = rem ; pr = pr ; remIsSmall = inr () } -}
src/audio-riff-wav-formats.adb
Ada-Audio/wavefiles
10
30413
------------------------------------------------------------------------------ -- -- -- AUDIO / RIFF / WAV -- -- -- -- RIFF format information for wavefiles -- -- -- -- The MIT License (MIT) -- -- -- -- Copyright (c) 2015 -- 2020 <NAME> -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining -- -- a copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, sublicense, and / or sell copies of the Software, and to -- -- permit persons to whom the Software is furnished to do so, subject to -- -- the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be -- -- included in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- ------------------------------------------------------------------------------ with Audio.RIFF.Wav.GUIDs; with Audio.RIFF.Wav.Formats.Standard_Channel_Configurations; package body Audio.RIFF.Wav.Formats is type Channel_Configuration_Integer is mod 2 ** Channel_Configuration_Size; ------------------------ -- To_RIFF_Identifier -- ------------------------ function To_RIFF_Identifier (FOURCC : FOURCC_String) return RIFF_Identifier is begin if FOURCC = "RIFF" then return RIFF_Identifier_Standard; elsif FOURCC = "RIFX" then return RIFF_Identifier_Big_Endian; elsif FOURCC = "LIST" then return RIFF_Identifier_List; elsif FOURCC = "RF64" then return RIFF_Identifier_RIFF_64; elsif FOURCC = "BW64" then return RIFF_Identifier_Broadcast_Wave_64; else return RIFF_Identifier_Unknown; end if; end To_RIFF_Identifier; -------------------- -- To_RIFF_Format -- -------------------- function To_RIFF_Format (FOURCC : FOURCC_String) return RIFF_Format is begin if FOURCC = "WAVE" then return RIFF_Format_Wave; elsif FOURCC = "AVI " then return RIFF_Format_AVI; elsif FOURCC = "MIDI" then return RIFF_Format_MIDI; elsif FOURCC = "PAL " then return RIFF_Format_Pallete; elsif FOURCC = "RDIB" then return RIFF_Format_DIB; elsif FOURCC = "RMMP" then return RIFF_Format_MMP; else return RIFF_Format_Unknown; end if; end To_RIFF_Format; ---------------------- -- To_Wav_Chunk_Tag -- ---------------------- function To_Wav_Chunk_Tag (FOURCC : FOURCC_String) return Wav_Chunk_Tag is begin if FOURCC = "fmt " then return Wav_Chunk_Fmt; elsif FOURCC = "data" then return Wav_Chunk_Data; elsif FOURCC = "INFO" then return Wav_Chunk_Info; elsif FOURCC = "JUNK" then return Wav_Chunk_Junk; elsif FOURCC = "PAD " then return Wav_Chunk_Pad; elsif FOURCC = "fact" then return Wav_Chunk_Fact; elsif FOURCC = "cue " then return Wav_Chunk_Cue; elsif FOURCC = "wavl" then return Wav_Chunk_Wave_List; elsif FOURCC = "slnt" then return Wav_Chunk_Silent; elsif FOURCC = "plst" then return Wav_Chunk_Playlist; elsif FOURCC = "list" then return Wav_Chunk_Associated_Data_List; elsif FOURCC = "labl" then return Wav_Chunk_Label; elsif FOURCC = "ltxt" then return Wav_Chunk_Labeled_Text; elsif FOURCC = "note" then return Wav_Chunk_Note; elsif FOURCC = "smpl" then return Wav_Chunk_Sample; elsif FOURCC = "inst" then return Wav_Chunk_Instrument; elsif FOURCC = "bext" then return Wav_Chunk_Broadcast_Extension; elsif FOURCC = "iXML" then return Wav_Chunk_IXML; elsif FOURCC = "axml" then return Wav_Chunk_AXML; elsif FOURCC = "qlty" then return Wav_Chunk_Quality; elsif FOURCC = "mext" then return Wav_Chunk_MPEG_Audio_Extension; elsif FOURCC = "levl" then return Wav_Chunk_Peak_Envelope; elsif FOURCC = "link" then return Wav_Chunk_Link; elsif FOURCC = "ds64" then return Wav_Chunk_Data_Size_64; elsif FOURCC = "bxml" then return Wav_Chunk_Compressed_Broadcast_Extension; elsif FOURCC = "sxml" then return Wav_Chunk_Sound_Related_XML; elsif FOURCC = "chna" then return Wav_Chunk_Channel_Info; else return Wav_Chunk_Unknown; end if; end To_Wav_Chunk_Tag; ------------- -- Default -- ------------- function Default return Wave_Format_16 is begin return W : Wave_Format_16 do W.Format_Tag := Wav_Format_PCM; W.Channels := 2; W.Samples_Per_Sec := Sample_Rate_44100; W.Bits_Per_Sample := Bit_Depth_16; W.Block_Align := ((To_Unsigned_16 (W.Bits_Per_Sample) + 7) / 8) * W.Channels; W.Avg_Bytes_Per_Sec := 0; end return; end Default; ------------- -- Default -- ------------- overriding function Default return Wave_Format_18 is begin return W : Wave_Format_18 do Wave_Format_16 (W) := Default; W.Size := 0; end return; end Default; ------------- -- Default -- ------------- overriding function Default return Wave_Format_Extensible is use Audio.RIFF.Wav.GUIDs; use Audio.RIFF.Wav.Formats.Standard_Channel_Configurations; begin return W : Wave_Format_Extensible do Wave_Format_18 (W) := Default; W.Size := 22; W.Valid_Bits_Per_Sample := To_Unsigned_16 (W.Bits_Per_Sample); W.Sub_Format := GUID_Undefined; W.Channel_Config := Channel_Config_2_0; end return; end Default; ------------------------------ -- Reset_For_Wave_Format_16 -- ------------------------------ procedure Reset_For_Wave_Format_16 (W : in out Wave_Format_Extensible) is begin W.Size := 0; Reset_For_Wave_Format_18 (W); end Reset_For_Wave_Format_16; ------------------------------ -- Reset_For_Wave_Format_18 -- ------------------------------ procedure Reset_For_Wave_Format_18 (W : in out Wave_Format_Extensible) is use Audio.RIFF.Wav.GUIDs; use Audio.RIFF.Wav.Formats.Standard_Channel_Configurations; begin W.Valid_Bits_Per_Sample := To_Unsigned_16 (W.Bits_Per_Sample); W.Sub_Format := GUID_Undefined; W.Channel_Config := Channel_Config_Empty; end Reset_For_Wave_Format_18; ------------- -- To_GUID -- ------------- function To_GUID (Format : Wav_Format_Tag) return GUID is use Audio.RIFF.Wav.GUIDs; begin case Format is when Wav_Format_PCM => return GUID_PCM; when Wav_Format_IEEE_Float => return GUID_IEEE_Float; when Wav_Format_A_Law => return GUID_ALAW; when Wav_Format_Mu_Law => return GUID_MULAW; when Wav_Format_ADPCM => return GUID_ADPCM; when Wav_Format_MPEG => return GUID_MPEG; when Wav_Format_Dolby_AC3_SPDIF => return GUID_DOLBY_AC3_SPDIF; when Wav_Format_MPEG_Layer_3 => return GUID_MPEG_LAYER_3; when others => return GUID_Undefined; end case; end To_GUID; ----------------------- -- To_Wav_Format_Tag -- ----------------------- function To_Wav_Format_Tag (ID : GUID) return Wav_Format_Tag is use Audio.RIFF.Wav.GUIDs; begin if ID = GUID_Undefined then return Wav_Format_Unknown; elsif ID = GUID_PCM then return Wav_Format_PCM; elsif ID = GUID_IEEE_Float then return Wav_Format_IEEE_Float; -- elsif ID = GUID_DRM then -- return Wav_Format_Unknown; elsif ID = GUID_ALAW then return Wav_Format_A_Law; elsif ID = GUID_MULAW then return Wav_Format_Mu_Law; elsif ID = GUID_ADPCM then return Wav_Format_ADPCM; elsif ID = GUID_MPEG then return Wav_Format_MPEG; elsif ID = GUID_DOLBY_AC3_SPDIF then return Wav_Format_Dolby_AC3_SPDIF; -- elsif ID = GUID_WMA_SPDIF then -- return Wav_Format_Unknown; -- elsif ID = GUID_DTS then -- return Wav_Format_Unknown; elsif ID = GUID_MPEG_LAYER_3 then return Wav_Format_MPEG_Layer_3; -- elsif ID = GUID_MPEG_HE_AAC then -- return Wav_Format_Unknown -- elsif ID = GUID_WMA_2 then -- return Wav_Format_Unknown; -- elsif ID = GUID_WMA_3 then -- return Wav_Format_Unknown; -- elsif ID = GUID_WMA_LOSSLESS then -- return Wav_Format_Unknown; else return Wav_Format_Unknown; end if; end To_Wav_Format_Tag; ------------------- -- Is_Consistent -- ------------------- function Is_Consistent (Channel_Config : Channel_Configuration; Number_Of_Channels : Positive) return Boolean is Counted_Channels : Natural := 0; begin for Channel_Is_Active of Channel_Config loop if Channel_Is_Active then Counted_Channels := Counted_Channels + 1; end if; end loop; return Number_Of_Channels = Counted_Channels; end Is_Consistent; ---------------------------------- -- Should_Use_Extensible_Format -- ---------------------------------- function Should_Use_Extensible_Format (Bit_Depth : Wav_Bit_Depth; Number_Of_Channels : Positive) return Boolean is begin if Bit_Depth not in Bit_Depth_8 | Bit_Depth_16 then return True; elsif Number_Of_Channels > 2 then return True; else return False; end if; end Should_Use_Extensible_Format; ----------------- -- Block_Align -- ----------------- function Block_Align (Bit_Depth : Wav_Bit_Depth; Number_Of_Channels : Positive) return Unsigned_16 is (((To_Unsigned_16 (Bit_Depth) + 7) / 8) * Unsigned_16 (Number_Of_Channels)); ------------------------------ -- Average_Bytes_Per_Second -- ------------------------------ function Average_Bytes_Per_Second (Block_Align : Unsigned_16; Sample_Rate : Wav_Sample_Rate) return Unsigned_32 is (Unsigned_32 (Block_Align) * To_Unsigned_32 (Sample_Rate)); ---------- -- Init -- ---------- function Init (Bit_Depth : Wav_Bit_Depth; Sample_Rate : Wav_Sample_Rate; Number_Of_Channels : Positive; Use_Float : Boolean := False) return Wave_Format_Extensible is Format : constant Wav_Format_Tag := (if Use_Float then Wav_Format_IEEE_Float else Wav_Format_PCM); Use_Wav_Extensible : constant Boolean := Should_Use_Extensible_Format (Bit_Depth, Number_Of_Channels); use Audio.RIFF.Wav.GUIDs; use Audio.RIFF.Wav.Formats.Standard_Channel_Configurations; begin return W : Wave_Format_Extensible do W.Channels := Unsigned_16 (Number_Of_Channels); W.Samples_Per_Sec := Sample_Rate; W.Bits_Per_Sample := Bit_Depth; W.Block_Align := Block_Align (Bit_Depth, Number_Of_Channels); W.Avg_Bytes_Per_Sec := Average_Bytes_Per_Second (W.Block_Align, Sample_Rate); if not Use_Wav_Extensible then W.Format_Tag := Format; W.Size := 0; W.Valid_Bits_Per_Sample := 0; W.Sub_Format := GUID_Undefined; W.Channel_Config := Channel_Config_Empty; else W.Size := 22; W.Valid_Bits_Per_Sample := To_Unsigned_16 (W.Bits_Per_Sample); W.Channel_Config := Channel_Config_Empty; Init_Formats : declare Sub_Format : constant GUID := To_GUID (Format); begin if Sub_Format /= GUID_Undefined then W.Format_Tag := Wav_Format_Extensible; W.Sub_Format := Sub_Format; else W.Format_Tag := Format; W.Sub_Format := GUID_Undefined; end if; end Init_Formats; end if; end return; end Init; --------------------- -- Is_Float_Format -- --------------------- function Is_Float_Format (W : Wave_Format_Extensible) return Boolean is use Audio.RIFF.Wav.GUIDs; begin return W.Format_Tag = Wav_Format_IEEE_Float or W.Sub_Format = GUID_IEEE_Float; end Is_Float_Format; -------------------------------- -- Read_Channel_Configuration -- -------------------------------- procedure Read_Channel_Configuration (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : out Channel_Configuration) is V : Channel_Configuration_Integer; X : Channel_Configuration; for X'Address use V'Address; begin Channel_Configuration_Integer'Read (Stream, V); Item := X; end Read_Channel_Configuration; --------------------------------- -- Write_Channel_Configuration -- --------------------------------- procedure Write_Channel_Configuration (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : Channel_Configuration) is V : Channel_Configuration_Integer; X : Channel_Configuration; for X'Address use V'Address; begin X := Item; Channel_Configuration_Integer'Write (Stream, V); end Write_Channel_Configuration; end Audio.RIFF.Wav.Formats;
source/coroutines-polling.ads
reznikmm/coroutines
3
27571
<filename>source/coroutines-polling.ads -- Copyright (c) 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- -- -- This package provides file descriptor polling events to yield. -- with Interfaces.C; package Coroutines.Polling is pragma Preelaborate; procedure Initialize; -- Call this before use subtype FD is Interfaces.C.int; type Polling_Kind is (Input, Output, Error, Close); type Polling_Kind_Set is array (Polling_Kind) of Boolean with Pack; function Watch (File : FD; Events : Polling_Kind_Set) return Event_Id; -- Wake the coroutine up as state of given file descriptor changed. end Coroutines.Polling;
courses/fundamentals_of_ada/labs/solar_system/adv_280_low_level_programming/question_3/src/stm32-rng.adb
AdaCore/training_material
15
11598
with STM32_SVD.RCC; use STM32_SVD.RCC; with STM32_SVD.RNG; use STM32_SVD.RNG; package body STM32.RNG is ---------------------- -- Enable_RNG_Clock -- ---------------------- procedure Enable_RNG_Clock is begin RCC_Periph.AHB2ENR.RNGEN := True; end Enable_RNG_Clock; ---------------- -- Enable_RNG -- ---------------- procedure Enable_RNG is begin RNG_Periph.CR.RNGEN := True; end Enable_RNG; ----------------- -- Disable_RNG -- ----------------- procedure Disable_RNG is begin RNG_Periph.CR.RNGEN := False; end Disable_RNG; --------------- -- Reset_RNG -- --------------- procedure Reset_RNG is begin RCC_Periph.AHB2RSTR.RNGRST := True; RCC_Periph.AHB2RSTR.RNGRST := False; end Reset_RNG; ----------------- -- RNG_Enabled -- ----------------- function RNG_Enabled return Boolean is (RNG_Periph.CR.RNGEN); -------------------------- -- Enable_RNG_Interrupt -- -------------------------- procedure Enable_RNG_Interrupt is begin RNG_Periph.CR.IE := True; end Enable_RNG_Interrupt; --------------------------- -- Disable_RNG_Interrupt -- --------------------------- procedure Disable_RNG_Interrupt is begin RNG_Periph.CR.IE := False; end Disable_RNG_Interrupt; --------------------------- -- RNG_Interrupt_Enabled -- --------------------------- function RNG_Interrupt_Enabled return Boolean is (RNG_Periph.CR.IE); -------------- -- RNG_Data -- -------------- function RNG_Data return UInt32 is (RNG_Periph.DR); -------------------- -- RNG_Data_Ready -- -------------------- function RNG_Data_Ready return Boolean is (RNG_Periph.SR.DRDY); --------------------------- -- RNG_Seed_Error_Status -- --------------------------- function RNG_Seed_Error_Status return Boolean is (RNG_Periph.SR.SECS); ---------------------------- -- RNG_Clock_Error_Status -- ---------------------------- function RNG_Clock_Error_Status return Boolean is (RNG_Periph.SR.CECS); --------------------------------- -- Clear_RNG_Seed_Error_Status -- --------------------------------- procedure Clear_RNG_Seed_Error_Status is begin RNG_Periph.SR.SECS := False; end Clear_RNG_Seed_Error_Status; ---------------------------------- -- Clear_RNG_Clock_Error_Status -- ---------------------------------- procedure Clear_RNG_Clock_Error_Status is begin RNG_Periph.SR.CECS := False; end Clear_RNG_Clock_Error_Status; end STM32.RNG;
test/succeed/IrrelevantRecordFields.agda
larrytheliquid/agda
1
819
-- 2010-09-24 -- example originally stolen from <NAME>'s post on the Agda list {-# OPTIONS --no-irrelevant-projections #-} module IrrelevantRecordFields where open import Common.Equality record SemiG : Set1 where constructor _,_,_,_,_,_ field M : Set unit : M _+_ : M -> M -> M .assoc : ∀ {x y z} -> x + (y + z) ≡ (x + y) + z .leftUnit : ∀ {x} -> unit + x ≡ x .rightUnit : ∀ {x} -> x + unit ≡ x dual : SemiG -> SemiG dual (M , e , _+_ , assoc , leftUnit , rightUnit) = M , e , (λ x y -> y + x) , sym assoc , rightUnit , leftUnit open SemiG -- trivId : ∀ (M : SemiG) -> M ≡ M -- trivId M = refl dual∘dual≡id : ∀ M -> dual (dual M) ≡ M dual∘dual≡id M = refl {x = M}
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0xca_notsx.log_21829_1627.asm
ljhsiun2/medusa
9
103483
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r15 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0x45eb, %rsi lea addresses_A_ht+0x1242b, %rdi nop nop nop nop nop add $37224, %r13 mov $77, %rcx rep movsw nop nop and $86, %r10 lea addresses_D_ht+0x10196, %rax nop inc %rdx mov $0x6162636465666768, %rcx movq %rcx, %xmm7 vmovups %ymm7, (%rax) nop dec %rsi lea addresses_D_ht+0xf42b, %rsi lea addresses_normal_ht+0xd87b, %rdi nop nop nop sub $44995, %r15 mov $81, %rcx rep movsq and $11764, %rax lea addresses_WT_ht+0x342b, %rsi lea addresses_normal_ht+0x1cb94, %rdi nop nop nop dec %r13 mov $38, %rcx rep movsl nop nop nop sub %rdx, %rdx lea addresses_D_ht+0x682b, %rdi nop nop nop xor $17947, %r13 mov $0x6162636465666768, %r10 movq %r10, %xmm7 movups %xmm7, (%rdi) xor %r10, %r10 lea addresses_normal_ht+0xf82b, %rdx nop dec %r13 movb $0x61, (%rdx) nop nop nop add $64353, %r10 lea addresses_normal_ht+0xf22b, %rdx xor $6756, %r10 mov $0x6162636465666768, %rdi movq %rdi, (%rdx) nop nop nop nop nop xor $55149, %rdi lea addresses_WT_ht+0x1b42b, %r13 nop inc %rax mov $0x6162636465666768, %r10 movq %r10, %xmm4 and $0xffffffffffffffc0, %r13 movaps %xmm4, (%r13) nop nop sub %r15, %r15 lea addresses_WT_ht+0x1682b, %rcx xor %r13, %r13 movups (%rcx), %xmm1 vpextrq $1, %xmm1, %rax nop nop nop add $21526, %rax lea addresses_normal_ht+0x13b2b, %r13 nop add $18495, %rax movb $0x61, (%r13) nop nop nop add $1789, %rdi lea addresses_UC_ht+0x1c7ab, %rax nop nop cmp %r10, %r10 movw $0x6162, (%rax) nop nop nop nop sub %rax, %rax pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r15 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r13 push %rbp push %rcx push %rsi // Store lea addresses_RW+0xca9b, %rsi nop nop nop nop cmp %rbp, %rbp movw $0x5152, (%rsi) cmp $60117, %rsi // Store lea addresses_PSE+0x1a51b, %r10 nop nop nop nop nop sub $29753, %r12 movl $0x51525354, (%r10) nop nop nop nop nop inc %r13 // Faulty Load lea addresses_RW+0xa02b, %rbp nop cmp $6085, %r10 movups (%rbp), %xmm2 vpextrq $0, %xmm2, %rsi lea oracles, %rcx and $0xff, %rsi shlq $12, %rsi mov (%rcx,%rsi,1), %rsi pop %rsi pop %rcx pop %rbp pop %r13 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_RW', 'size': 2, 'AVXalign': True}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_PSE', 'size': 4, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_D_ht', 'size': 32, 'AVXalign': False}} {'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': True}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': True}} {'src': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': True, 'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False}} {'32': 21829} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
oeis/038/A038674.asm
neoneye/loda-programs
11
10755
<gh_stars>10-100 ; A038674: A finite series from the lyrics of La Farolera, a Latin American traditional children's song. ; 2,2,4,4,2,6,6,2,8,8,16 lpb $0 add $2,$0 mul $0,2 mod $0,3 add $2,$0 pow $0,3 lpe mov $0,$2 div $0,3 mul $0,2 add $0,2
Transynther/x86/_processed/NONE/_xt_/i7-7700_9_0xca_notsx.log_21829_1190.asm
ljhsiun2/medusa
9
179261
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r14 push %r15 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x186b0, %rcx nop nop nop nop nop sub $43225, %rdx movb (%rcx), %r9b add $62665, %r11 lea addresses_normal_ht+0x191fc, %r15 nop nop nop nop and %r10, %r10 and $0xffffffffffffffc0, %r15 movntdqa (%r15), %xmm6 vpextrq $0, %xmm6, %r14 nop nop nop and %rdx, %rdx lea addresses_A_ht+0x166a2, %r9 nop nop nop nop add $41132, %r15 mov $0x6162636465666768, %rcx movq %rcx, (%r9) nop nop nop nop xor %rcx, %rcx lea addresses_D_ht+0x1ee24, %r10 nop nop nop xor $54086, %r14 mov (%r10), %edx add $12921, %rcx lea addresses_WT_ht+0xda44, %r11 cmp %rcx, %rcx movups (%r11), %xmm3 vpextrq $0, %xmm3, %r9 nop nop nop add %r15, %r15 lea addresses_WT_ht+0x9fc4, %rsi lea addresses_UC_ht+0x97c4, %rdi cmp %r9, %r9 mov $93, %rcx rep movsl nop nop nop nop nop cmp %r14, %r14 lea addresses_D_ht+0x48a4, %r14 nop nop nop cmp $18557, %rsi movups (%r14), %xmm5 vpextrq $0, %xmm5, %rcx cmp %r14, %r14 lea addresses_UC_ht+0x167c4, %r14 cmp %r9, %r9 mov $0x6162636465666768, %rcx movq %rcx, %xmm3 vmovups %ymm3, (%r14) nop nop cmp %r14, %r14 lea addresses_UC_ht+0x9fc4, %rdi nop nop nop and %rsi, %rsi and $0xffffffffffffffc0, %rdi vmovaps (%rdi), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $1, %xmm5, %r10 nop nop nop nop nop xor $17324, %r9 lea addresses_normal_ht+0x13ac4, %rsi lea addresses_normal_ht+0xe604, %rdi clflush (%rsi) clflush (%rdi) nop nop nop cmp $8881, %r15 mov $56, %rcx rep movsw nop nop nop sub $25647, %r10 lea addresses_A_ht+0x1c200, %rdi nop xor $59289, %r11 vmovups (%rdi), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $0, %xmm1, %rdx nop nop nop nop inc %r9 lea addresses_D_ht+0x10f84, %rsi lea addresses_D_ht+0x93c4, %rdi nop and %r10, %r10 mov $41, %rcx rep movsw nop nop nop nop xor $16510, %r11 lea addresses_D_ht+0xd7c4, %r10 nop nop nop sub %r11, %r11 movb (%r10), %r9b nop inc %r9 pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r15 pop %r14 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r15 push %r8 push %rcx push %rdi push %rsi // Store lea addresses_A+0x1881c, %rcx clflush (%rcx) nop nop nop add $45928, %rsi movl $0x51525354, (%rcx) nop nop nop nop nop inc %r15 // Faulty Load lea addresses_WC+0xc7c4, %r15 clflush (%r15) nop add $42939, %r11 mov (%r15), %rcx lea oracles, %rdi and $0xff, %rcx shlq $12, %rcx mov (%rdi,%rcx,1), %rcx pop %rsi pop %rdi pop %rcx pop %r8 pop %r15 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2, 'same': False, 'type': 'addresses_A'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': True, 'type': 'addresses_WC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 3, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 7, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 3, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 8, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2, 'same': True, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'38': 21829} 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 */
_incObj/sub ObjFloorDist.asm
kodishmediacenter/msu-md-sonic
9
82903
<reponame>kodishmediacenter/msu-md-sonic ; --------------------------------------------------------------------------- ; Subroutine to find the distance of an object to the floor ; input: ; d3 = x-pos. of object (ObjFloorDist2 only) ; output: ; d1 = distance to the floor ; d3 = floor angle ; a1 = address within 256x256 mappings where object is standing ; (refers to a 16x16 tile number) ; (a4) = floor angle ; --------------------------------------------------------------------------- ; ||||||||||||||| S U B R O U T I N E ||||||||||||||||||||||||||||||||||||||| ObjFloorDist: move.w obX(a0),d3 ObjFloorDist2: move.w obY(a0),d2 moveq #0,d0 move.b obHeight(a0),d0 ext.w d0 add.w d0,d2 lea (v_anglebuffer).w,a4 move.b #0,(a4) movea.w #$10,a3 ; height of a 16x16 tile move.w #0,d6 moveq #$D,d5 ; bit to test for solidness bsr.w FindFloor move.b (v_anglebuffer).w,d3 btst #0,d3 beq.s locret_14E4E move.b #0,d3 locret_14E4E: rts ; End of function ObjFloorDist2
arch/ARM/cortex_m/src/cm0/cortex_m_svd-nvic.ads
rocher/Ada_Drivers_Library
192
25886
<gh_stars>100-1000 -- This spec has been automatically generated from cm0.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; package Cortex_M_SVD.NVIC is pragma Preelaborate; --------------- -- Registers -- --------------- -- Interrupt Priority Register -- Interrupt Priority Register type NVIC_IPR_Registers is array (0 .. 7) of HAL.UInt32 with Volatile; ----------------- -- Peripherals -- ----------------- type NVIC_Peripheral is record -- Interrupt Set-Enable Registers NVIC_ISER : aliased HAL.UInt32; -- Interrupt Clear-Enable Registers NVIC_ICER : aliased HAL.UInt32; -- Interrupt Set-Pending Registers NVIC_ISPR : aliased HAL.UInt32; -- Interrupt Clear-Pending Registers NVIC_ICPR : aliased HAL.UInt32; -- Interrupt Priority Register NVIC_IPR : aliased NVIC_IPR_Registers; end record with Volatile; for NVIC_Peripheral use record NVIC_ISER at 16#0# range 0 .. 31; NVIC_ICER at 16#80# range 0 .. 31; NVIC_ISPR at 16#100# range 0 .. 31; NVIC_ICPR at 16#180# range 0 .. 31; NVIC_IPR at 16#300# range 0 .. 255; end record; NVIC_Periph : aliased NVIC_Peripheral with Import, Address => NVIC_Base; end Cortex_M_SVD.NVIC;
src/pygamer-audio.adb
Fabien-Chouteau/pygamer-bsp
0
12114
<reponame>Fabien-Chouteau/pygamer-bsp<filename>src/pygamer-audio.adb with System; with Interfaces; use Interfaces; with Interfaces.C; use Interfaces.C; with HAL.GPIO; with SAM.Clock_Generator.IDs; with SAM.Main_Clock; with SAM.DAC; use SAM.DAC; with SAM.Device; with SAM.DMAC; use SAM.DMAC; with SAM.DMAC.Sources; with SAM.TC; use SAM.TC; with SAM.Interrupt_Names; with Cortex_M.NVIC; with HAL; use HAL; package body PyGamer.Audio is User_Callback : Audio_Callback := null; Buffer_Size : constant := 64; Buffer_Left_0 : Data_Array (1 .. Buffer_Size); Buffer_Left_1 : Data_Array (1 .. Buffer_Size); Buffer_Right_0 : Data_Array (1 .. Buffer_Size); Buffer_Right_1 : Data_Array (1 .. Buffer_Size); Flip : Boolean := False; procedure DMA_Int_Handler; pragma Export (C, DMA_Int_Handler, "__dmac_tcmpl_0_handler"); --------------------- -- DMA_Int_Handler -- --------------------- procedure DMA_Int_Handler is Buffer_0 : System.Address := (if Flip then Buffer_Left_0'Address else Buffer_Left_1'Address); Buffer_1 : System.Address := (if Flip then Buffer_Right_0'Address else Buffer_Right_1'Address); begin Cortex_M.NVIC.Clear_Pending (SAM.Interrupt_Names.dmac_0_interrupt); Clear (DMA_DAC_0, Transfer_Complete); Clear (DMA_DAC_1, Transfer_Complete); Set_Data_Transfer (DMA_Descs (DMA_DAC_0), Block_Transfer_Count => Buffer_Left_0'Length, Src_Addr => Buffer_0, Dst_Addr => SAM.DAC.Data_Address (0)); Set_Data_Transfer (DMA_Descs (DMA_DAC_1), Block_Transfer_Count => Buffer_Right_0'Length, Src_Addr => Buffer_1, Dst_Addr => SAM.DAC.Data_Address (1)); Enable (DMA_DAC_0); Enable (DMA_DAC_1); if User_Callback /= null then if Flip then User_Callback (Buffer_Left_1, Buffer_Right_1); else User_Callback (Buffer_Left_0, Buffer_Right_0); end if; else if Flip then Buffer_Left_1 := (others => 0); Buffer_Right_1 := (others => 0); else Buffer_Left_0 := (others => 0); Buffer_Right_0 := (others => 0); end if; end if; Flip := not Flip; end DMA_Int_Handler; ------------------ -- Set_Callback -- ------------------ procedure Set_Callback (Callback : Audio_Callback; Sample_Rate : Sample_Rate_Kind) is begin User_Callback := Callback; -- Set the timer period coresponding to the requested sample rate SAM.Device.TC0.Set_Period (case Sample_Rate is when SR_11025 => UInt8 ((UInt32 (48000000) / 64) / 11025), when SR_22050 => UInt8 ((UInt32 (48000000) / 64) / 22050), when SR_44100 => UInt8 ((UInt32 (48000000) / 64) / 44100), when SR_96000 => UInt8 ((UInt32 (48000000) / 64) / 96000)); end Set_Callback; begin -- DAC -- SAM.Clock_Generator.Configure_Periph_Channel (SAM.Clock_Generator.IDs.DAC, Clk_48Mhz); SAM.Main_Clock.DAC_On; SAM.DAC.Configure (Single_Mode, VREFAB); Debug_Stop_Mode (False); Configure_Channel (Chan => 0, Oversampling => OSR_16, Refresh => 0, Enable_Dithering => True, Run_In_Standby => True, Standalone_Filter => False, Current => CC1M, Adjustement => Right_Adjusted, Enable_Filter_Result_Ready_Evt => False, Enable_Data_Buffer_Empty_Evt => False, Enable_Convert_On_Input_Evt => False, Invert_Input_Evt => False, Enable_Overrun_Int => False, Enable_Underrun_Int => False, Enable_Result_Ready_Int => False, Enable_Buffer_Empty_Int => False); Configure_Channel (Chan => 1, Oversampling => OSR_16, Refresh => 0, Enable_Dithering => True, Run_In_Standby => True, Standalone_Filter => False, Current => CC1M, Adjustement => Right_Adjusted, Enable_Filter_Result_Ready_Evt => False, Enable_Data_Buffer_Empty_Evt => False, Enable_Convert_On_Input_Evt => False, Invert_Input_Evt => False, Enable_Overrun_Int => False, Enable_Underrun_Int => False, Enable_Result_Ready_Int => False, Enable_Buffer_Empty_Int => False); Enable (Chan_0 => True, Chan_1 => True); -- Enable speaker -- SAM.Device.PA27.Set_Mode (HAL.GPIO.Output); SAM.Device.PA27.Set; -- DMA -- Configure (DMA_DAC_0, Trig_Src => SAM.DMAC.Sources.TC0_OVF, Trig_Action => Burst, Priority => 1, Burst_Len => 1, Threshold => BEAT_1, Run_In_Standby => False); -- Only enable the channel 0 interrupt Enable (DMA_DAC_0, Transfer_Complete); Cortex_M.NVIC.Enable_Interrupt (SAM.Interrupt_Names.dmac_0_interrupt); Configure (DMA_DAC_1, Trig_Src => SAM.DMAC.Sources.TC0_OVF, Trig_Action => Burst, Priority => 1, Burst_Len => 1, Threshold => BEAT_1, Run_In_Standby => False); Configure_Descriptor (DMA_Descs (DMA_DAC_0), Valid => True, Event_Output => Disable, Block_Action => Interrupt, Beat_Size => B_16bit, Src_Addr_Inc => True, Dst_Addr_Inc => False, Step_Selection => Source, Step_Size => X1); Configure_Descriptor (DMA_Descs (DMA_DAC_1), Valid => True, Event_Output => Disable, Block_Action => Interrupt, Beat_Size => B_16bit, Src_Addr_Inc => True, Dst_Addr_Inc => False, Step_Selection => Source, Step_Size => X1); -- Timer -- SAM.Clock_Generator.Configure_Periph_Channel (SAM.Clock_Generator.IDs.TC0, Clk_48Mhz); SAM.Main_Clock.TC0_On; SAM.Device.TC0.Configure (Mode => TC_8bit, Prescaler => DIV64, Run_In_Standby => True, Clock_On_Demand => False, Auto_Lock => False, Capture_0_Enable => False, Capture_1_Enable => False, Capture_0_On_Pin => False, Capture_1_On_Pin => False, Capture_0_Mode => Default, Capture_1_Mode => Default); -- Start the time with the longest period to have a reduced number of -- interrupt until the audio is actually used. SAM.Device.TC0.Set_Period (255); SAM.Device.TC0.Enable; -- Start the first DMA transfer DMA_Int_Handler; end PyGamer.Audio;
notes/thesis/report/LTC-PCF/Twice.agda
asr/fotc
11
11171
------------------------------------------------------------------------------ -- Twice funcion ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module LTC-PCF.Twice where open import LTC-PCF.Base ------------------------------------------------------------------------------ twice : (D → D) → D → D twice f x = f (f x) twice-succ : ∀ n → twice succ₁ n ≡ succ₁ (succ₁ n) twice-succ n = refl
example/example3.asm
Benni3D/MicroVM-8
1
16085
; Initialize register a and b mov %a, $1 mov %b, $3 ; Shift register a 4 bits to left (a <<= 4) lshf %a, $4 ; Bitwise xor to a with b (a ^= b) xor %a, %b ; Print the value of register a printi %a ; Exit the program exit ; Assemble it like in example1.asm and execute it
src/main/fragment/mos6502-common/vdsm1=pdsz2_derefidx_vbuc1_plus_pdsz2_derefidx_vbuc2.asm
jbrandwood/kickc
2
86277
<filename>src/main/fragment/mos6502-common/vdsm1=pdsz2_derefidx_vbuc1_plus_pdsz2_derefidx_vbuc2.asm<gh_stars>1-10 clc ldy #{c2} lda ({z2}),y ldy #{c1} adc ({z2}),y sta {m1} ldy #{c2}+1 lda ({z2}),y ldy #{c1}+1 adc ({z2}),y sta {m1}+1 ldy #{c2}+2 lda ({z2}),y ldy #{c1}+2 adc ({z2}),y sta {m1}+2 ldy #{c2}+3 lda ({z2}),y ldy #{c1}+3 adc ({z2}),y sta {m1}+3
programs/oeis/144/A144328.asm
jmorken/loda
1
176817
; A144328: A002260 preceded by a column of 1's: a (1, 1, 2, 3, 4, 5,...) crescendo triangle by rows. ; 1,1,1,1,1,2,1,1,2,3,1,1,2,3,4,1,1,2,3,4,5,1,1,2,3,4,5,6,1,1,2,3,4,5,6,7,1,1,2,3,4,5,6,7,8,1,1,2,3,4,5,6,7,8,9,1,1,2,3,4,5,6,7,8,9,10,1,1,2,3,4,5,6,7,8,9,10,11,1,1,2,3,4,5,6,7,8,9,10,11,12,1,1,2,3,4,5,6,7,8,9,10,11,12,13,1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 lpb $0 trn $0,2 mov $1,$0 trn $0,$2 add $2,1 lpe add $1,1
programs/oeis/115/A115141.asm
neoneye/loda
22
175601
; A115141: Convolution of A115140 with itself. ; 1,-2,-1,-2,-5,-14,-42,-132,-429,-1430,-4862,-16796,-58786,-208012,-742900,-2674440,-9694845,-35357670,-129644790,-477638700,-1767263190,-6564120420,-24466267020,-91482563640,-343059613650,-1289904147324,-4861946401452,-18367353072152,-69533550916004,-263747951750360,-1002242216651368,-3814986502092304,-14544636039226909,-55534064877048198,-212336130412243110,-812944042149730764,-3116285494907301262,-11959798385860453492,-45950804324621742364,-176733862787006701400,-680425371729975800390,-2622127042276492108820,-10113918591637898134020,-39044429911904443959240,-150853479205085351660700,-583300119592996693088040,-2257117854077248073253720,-8740328711533173390046320,-33868773757191046886429490,-131327898242169365477991900,-509552245179617138054608572,-1978261657756160653623774456,-7684785670514316385230816156,-29869166945772625950142417512,-116157871455782434250553845880,-451959718027953471447609509424,-1759414616608818870992479875972,-6852456927844873497549658464312,-26700952856774851904245220912664,-104088460289122304033498318812080,-405944995127576985730643443367112,-1583850964596120042686772779038896,-6182127958584855650487080847216336,-24139737743045626825711458546273312,-94295850558771979787935384946380125,-368479169875816659479009042713546950 mov $1,1 sub $1,$0 sub $1,$0 mov $2,$0 pow $0,$1 sub $0,$1 bin $0,$2 div $0,$1
oeis/123/A123938.asm
neoneye/loda-programs
11
98249
; A123938: Ramsey number r(K_{2,2}, K_{2,n}). ; Submitted by <NAME>(s4.) ; 4,6,8,9,11,12,14,15,16,17,18,20,22 mov $5,$0 add $5,1 mov $7,$0 lpb $5 mov $0,$7 sub $5,1 sub $0,$5 mov $1,1 mov $2,1 mov $3,3 lpb $0 mov $3,$0 lpb $3 add $2,1 mov $4,$1 add $1,4 gcd $4,$2 mov $2,1 cmp $4,1 cmp $4,0 sub $3,$4 lpe sub $0,1 mod $2,2 add $2,1 mul $1,$2 lpe mov $0,$3 add $0,1 add $6,$0 lpe mov $0,$6
src/main/ada/2019/aoc-aoc_2019-day08.adb
wooky/aoc.kt
0
24543
with Ada.Characters.Latin_1; with Ada.Text_IO; package body AOC.AOC_2019.Day08 is Width : Natural := 25; Height : Natural := 6; Image_Size : Natural := Width * Height; type Pixel is new Character range '0' .. '2'; type Layer is array (0 .. Image_Size-1) of Pixel; Checksum : Natural; Result : Layer := (others => '2'); procedure Init (D : in out Day_08; Root : String) is use Ada.Text_IO; File : File_Type; begin Open (File => File, Mode => In_File, Name => Root & "/input/2019/day08.txt"); declare Image : String := Get_Line (File); Offset : Natural := Image'First; Zero_Count : Natural := Natural'Last; begin while Offset < Image'Last loop declare type Pixel_Count_Array is array (Pixel) of Natural; Pixel_Count : Pixel_Count_Array := (others => 0); begin for I in Layer'Range loop declare Current_Pixel : Pixel := Pixel (Image (Offset + I)); begin Pixel_Count (Current_Pixel) := Pixel_Count (Current_Pixel) + 1; if Result (I) = '2' then Result (I) := Current_Pixel; end if; end; end loop; if Pixel_Count ('0') < Zero_Count then Zero_Count := Pixel_Count ('0'); Checksum := Pixel_Count ('1') * Pixel_Count ('2'); end if; end; Offset := Offset + Image_Size; end loop; end; Close (File); end Init; function Part_1 (D : Day_08) return String is begin return Checksum'Image; end Part_1; function Part_2 (D : Day_08) return String is Image : String (Result'First .. Result'Last + Height); Dest : Natural := Image'First; begin for I in Result'Range loop if I mod Width = 0 then Image (Dest) := Ada.Characters.Latin_1.LF; Dest := Dest + 1; end if; Image (Dest) := (if Result (I) = '1' then '#' else ' '); Dest := Dest + 1; end loop; return Image; end Part_2; end AOC.AOC_2019.Day08;
libsrc/_DEVELOPMENT/l/sccz80/crt0/l_pint.asm
jpoikela/z88dk
640
174856
<gh_stars>100-1000 ; Z88 Small C+ Run time Library ; Moved functions over to proper libdefs ; To make startup code smaller and neater! ; ; 6/9/98 djm SECTION code_clib SECTION code_l_sccz80 PUBLIC l_pint EXTERN l_pint_pop_pint defc l_pint = l_pint_pop_pint
third_party/antlr_grammars_v4/rfc3080/beep.g4
mikhan808/rsyntaxtextarea-antlr4-extension
2
2266
<filename>third_party/antlr_grammars_v4/rfc3080/beep.g4<gh_stars>1-10 /* BSD License Copyright (c) 2020, <NAME> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of <NAME> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ grammar beep; frame : data ; data : header payload_trailer ; header : msg | rpy | err | ans | nul ; msg : MSG SP common ; rpy : RPY SP common ; ans : ANS SP common SP ansno ; err : ERR SP common ; nul : NUL SP common ; common : channel SP msgno SP more SP seqno SP size ; channel : NUMBER ; msgno : NUMBER ; more : DOT | STAR ; seqno : NUMBER ; size : NUMBER ; ansno : NUMBER ; payload_trailer : PAYLOAD_TRAILER CRLF? ; DOT : '.' ; STAR : '*' ; NUL : 'NUL' ; ERR : 'ERR' ; ANS : 'ANS' ; RPY : 'RPY' ; MSG : 'MSG' ; NUMBER : [0-9]+ ; SP : ' ' ; CRLF : [\r\n]+ ; PAYLOAD_TRAILER : CRLF .*? 'END' ;
solutions/51 - Identify Yourselves/size-20_speed-16.asm
michaelgundlach/7billionhumans
45
240444
-- 7 Billion Humans (2145) -- -- 51: Identify Yourselves -- -- Author: landfillbaby -- Size: 20 -- Speed: 16 step s pickup c if w == nothing: write 1 jump a endif if e == nothing: write 10 jump b endif write 0 c: mem1 = set w if mem1 > 0: mem1 = calc mem1 + 1 jump d endif mem1 = set e if mem1 > 0: mem1 = calc mem1 - 1 jump e endif jump c d: e: write mem1 a: b: drop
Cubical/ZCohomology/Properties.agda
maxdore/cubical
0
10943
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.ZCohomology.Properties where {- This module contains: 1. direct proofs of connectedness of Kn and ΩKn 2. Induction principles for cohomology groups of pointed types 3. Equivalence between cohomology of A and reduced cohomology of (A + 1) 4. Equivalence between cohomology and reduced cohomology for dimension ≥ 1 5. Encode-decode proof of Kₙ ≃ ΩKₙ₊₁ and proofs that this equivalence and its inverse are morphisms 6. A proof of coHomGr ≅ coHomGrΩ 7. A locked (non-reducing) version of Kₙ ≃ ΩKₙ₊₁ -} open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.GroupStructure open import Cubical.HITs.S1 hiding (encode ; decode) open import Cubical.HITs.Sn open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.Pointed.Homogeneous open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws renaming (assoc to assoc∙) open import Cubical.Foundations.Univalence open import Cubical.HITs.Susp open import Cubical.HITs.SetTruncation renaming (rec to sRec ; rec2 to sRec2 ; elim to sElim ; elim2 to sElim2 ; setTruncIsSet to §) open import Cubical.Data.Int renaming (_+_ to _ℤ+_) hiding (-_) open import Cubical.Data.Nat open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; map2 to trMap2; rec to trRec ; elim3 to trElim3) open import Cubical.Homotopy.Loopspace open import Cubical.Homotopy.Connected open import Cubical.Algebra.Group hiding (Unit ; Int) open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Data.Sum.Base hiding (map) open import Cubical.Functions.Morphism open import Cubical.Data.Sigma open Iso renaming (inv to inv') private variable ℓ ℓ' : Level ------------------- Connectedness --------------------- is2ConnectedKn : (n : ℕ) → isConnected 2 (coHomK (suc n)) is2ConnectedKn zero = ∣ ∣ base ∣ ∣ , trElim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _) (trElim (λ _ → isOfHLevelPath 3 (isOfHLevelSuc 2 (isOfHLevelTrunc 2)) _ _) (toPropElim (λ _ → isOfHLevelTrunc 2 _ _) refl)) is2ConnectedKn (suc n) = ∣ ∣ north ∣ ∣ , trElim (λ _ → isOfHLevelPath 2 (isOfHLevelTrunc 2) _ _) (trElim (λ _ → isProp→isOfHLevelSuc (3 + n) (isOfHLevelTrunc 2 _ _)) (suspToPropElim (ptSn (suc n)) (λ _ → isOfHLevelTrunc 2 _ _) refl)) isConnectedKn : (n : ℕ) → isConnected (2 + n) (coHomK (suc n)) isConnectedKn n = isOfHLevelRetractFromIso 0 (invIso (truncOfTruncIso (2 + n) 1)) (sphereConnected (suc n)) -- direct proof of connectedness of ΩKₙ₊₁ not relying on the equivalence ∥ a ≡ b ∥ₙ ≃ (∣ a ∣ₙ₊₁ ≡ ∣ b ∣ₙ₊₁) isConnectedPathKn : (n : ℕ) (x y : (coHomK (suc n))) → isConnected (suc n) (x ≡ y) isConnectedPathKn n = trElim (λ _ → isProp→isOfHLevelSuc (2 + n) (isPropΠ λ _ → isPropIsContr)) (sphereElim _ (λ _ → isProp→isOfHLevelSuc n (isPropΠ λ _ → isPropIsContr)) λ y → isContrRetractOfConstFun {B = (hLevelTrunc (suc n) (ptSn (suc n) ≡ ptSn (suc n)))} ∣ refl ∣ (fun⁻ n y , trElim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) (J (λ y p → fun⁻ n y _ ≡ _) (funExt⁻ (fun⁻Id n) ∣ refl ∣)))) where fun⁻ : (n : ℕ) → (y : coHomK (suc n)) → hLevelTrunc (suc n) (ptSn (suc n) ≡ ptSn (suc n)) → hLevelTrunc (suc n) (∣ ptSn (suc n) ∣ ≡ y) fun⁻ n = trElim (λ _ → isOfHLevelΠ (3 + n) λ _ → isOfHLevelSuc (2 + n) (isOfHLevelSuc (suc n) (isOfHLevelTrunc (suc n)))) (sphereElim n (λ _ → isOfHLevelΠ (suc n) λ _ → isOfHLevelTrunc (suc n)) λ _ → ∣ refl ∣) fun⁻Id : (n : ℕ) → fun⁻ n ∣ ptSn (suc n) ∣ ≡ λ _ → ∣ refl ∣ fun⁻Id zero = refl fun⁻Id (suc n) = refl ------------------- -- Induction principles for cohomology groups (n ≥ 1) -- If we want to show a proposition about some x : Hⁿ(A), it suffices to show it under the -- assumption that x = ∣ f ∣₂ for some f : A → Kₙ and that f is pointed coHomPointedElim : {A : Type ℓ} (n : ℕ) (a : A) {B : coHom (suc n) A → Type ℓ'} → ((x : coHom (suc n) A) → isProp (B x)) → ((f : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → B ∣ f ∣₂) → (x : coHom (suc n) A) → B x coHomPointedElim {ℓ' = ℓ'} {A = A} n a isprop indp = sElim (λ _ → isOfHLevelSuc 1 (isprop _)) λ f → helper n isprop indp f (f a) refl where helper : (n : ℕ) {B : coHom (suc n) A → Type ℓ'} → ((x : coHom (suc n) A) → isProp (B x)) → ((f : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → B ∣ f ∣₂) → (f : A → coHomK (suc n)) → (x : coHomK (suc n)) → f a ≡ x → B ∣ f ∣₂ -- pattern matching a bit extra to avoid isOfHLevelPlus' helper zero isprop ind f = trElim (λ _ → isOfHLevelPlus {n = 1} 2 (isPropΠ λ _ → isprop _)) (toPropElim (λ _ → isPropΠ λ _ → isprop _) (ind f)) helper (suc zero) isprop ind f = trElim (λ _ → isOfHLevelPlus {n = 1} 3 (isPropΠ λ _ → isprop _)) (suspToPropElim base (λ _ → isPropΠ λ _ → isprop _) (ind f)) helper (suc (suc zero)) isprop ind f = trElim (λ _ → isOfHLevelPlus {n = 1} 4 (isPropΠ λ _ → isprop _)) (suspToPropElim north (λ _ → isPropΠ λ _ → isprop _) (ind f)) helper (suc (suc (suc n))) isprop ind f = trElim (λ _ → isOfHLevelPlus' {n = 5 + n} 1 (isPropΠ λ _ → isprop _)) (suspToPropElim north (λ _ → isPropΠ λ _ → isprop _) (ind f)) coHomPointedElim2 : {A : Type ℓ} (n : ℕ) (a : A) {B : coHom (suc n) A → coHom (suc n) A → Type ℓ'} → ((x y : coHom (suc n) A) → isProp (B x y)) → ((f g : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → g a ≡ coHom-pt (suc n) → B ∣ f ∣₂ ∣ g ∣₂) → (x y : coHom (suc n) A) → B x y coHomPointedElim2 {ℓ' = ℓ'} {A = A} n a isprop indp = sElim2 (λ _ _ → isOfHLevelSuc 1 (isprop _ _)) λ f g → helper n a isprop indp f g (f a) (g a) refl refl where helper : (n : ℕ) (a : A) {B : coHom (suc n) A → coHom (suc n) A → Type ℓ'} → ((x y : coHom (suc n) A) → isProp (B x y)) → ((f g : A → coHomK (suc n)) → f a ≡ coHom-pt (suc n) → g a ≡ coHom-pt (suc n) → B ∣ f ∣₂ ∣ g ∣₂) → (f g : A → coHomK (suc n)) → (x y : coHomK (suc n)) → f a ≡ x → g a ≡ y → B ∣ f ∣₂ ∣ g ∣₂ helper zero a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus {n = 1} 2 (isPropΠ2 λ _ _ → isprop _ _)) (toPropElim2 (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) helper (suc zero) a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus {n = 1} 3 (isPropΠ2 λ _ _ → isprop _ _)) (suspToPropElim2 base (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) helper (suc (suc zero)) a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus {n = 1} 4 (isPropΠ2 λ _ _ → isprop _ _)) (suspToPropElim2 north (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) helper (suc (suc (suc n))) a isprop indp f g = elim2 (λ _ _ → isOfHLevelPlus' {n = 5 + n} 1 (isPropΠ2 λ _ _ → isprop _ _)) (suspToPropElim2 north (λ _ _ → isPropΠ2 λ _ _ → isprop _ _) (indp f g)) coHomK-elim : ∀ {ℓ} (n : ℕ) {B : coHomK (suc n) → Type ℓ} → ((x : _) → isOfHLevel (suc n) (B x)) → B (0ₖ (suc n)) → (x : _) → B x coHomK-elim n {B = B } hlev b = trElim (λ _ → isOfHLevelPlus {n = (suc n)} 2 (hlev _)) (sphereElim _ (hlev ∘ ∣_∣) b) {- Equivalence between cohomology of A and reduced cohomology of (A + 1) -} coHomRed+1Equiv : (n : ℕ) → (A : Type ℓ) → (coHom n A) ≡ (coHomRed n ((A ⊎ Unit , inr (tt)))) coHomRed+1Equiv zero A i = ∥ helpLemma {C = (Int , pos 0)} i ∥₂ module coHomRed+1 where helpLemma : {C : Pointed ℓ} → ( (A → (typ C)) ≡ ((((A ⊎ Unit) , inr (tt)) →∙ C))) helpLemma {C = C} = isoToPath (iso map1 map2 (λ b → linvPf b) (λ _ → refl)) where map1 : (A → typ C) → ((((A ⊎ Unit) , inr (tt)) →∙ C)) map1 f = map1' , refl module helpmap where map1' : A ⊎ Unit → fst C map1' (inl x) = f x map1' (inr x) = pt C map2 : ((((A ⊎ Unit) , inr (tt)) →∙ C)) → (A → typ C) map2 (g , pf) x = g (inl x) linvPf : (b :((((A ⊎ Unit) , inr (tt)) →∙ C))) → map1 (map2 b) ≡ b linvPf (f , snd) i = (λ x → helper x i) , λ j → snd ((~ i) ∨ j) where helper : (x : A ⊎ Unit) → ((helpmap.map1') (map2 (f , snd)) x) ≡ f x helper (inl x) = refl helper (inr tt) = sym snd coHomRed+1Equiv (suc zero) A i = ∥ coHomRed+1.helpLemma A i {C = (coHomK 1 , ∣ base ∣)} i ∥₂ coHomRed+1Equiv (suc (suc n)) A i = ∥ coHomRed+1.helpLemma A i {C = (coHomK (2 + n) , ∣ north ∣)} i ∥₂ Iso-coHom-coHomRed : ∀ {ℓ} {A : Pointed ℓ} (n : ℕ) → Iso (coHomRed (suc n) A) (coHom (suc n) (typ A)) fun (Iso-coHom-coHomRed {A = A , a} n) = map fst inv' (Iso-coHom-coHomRed {A = A , a} n) = map λ f → (λ x → f x -ₖ f a) , rCancelₖ _ _ rightInv (Iso-coHom-coHomRed {A = A , a} n) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ f → trRec (isProp→isOfHLevelSuc _ (§ _ _)) (λ p → cong ∣_∣₂ (funExt λ x → cong (λ y → f x +ₖ y) (cong -ₖ_ p ∙ -0ₖ) ∙ rUnitₖ _ (f x))) (Iso.fun (PathIdTruncIso (suc n)) (isContr→isProp (isConnectedKn n) ∣ f a ∣ ∣ 0ₖ _ ∣)) leftInv (Iso-coHom-coHomRed {A = A , a} n) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ {(f , p) → cong ∣_∣₂ (ΣPathP (((funExt λ x → (cong (λ y → f x -ₖ y) p ∙∙ cong (λ y → f x +ₖ y) -0ₖ ∙∙ rUnitₖ _ (f x)) ∙ refl)) , helper n (f a) (sym p)))} where path : (n : ℕ) (x : coHomK (suc n)) (p : 0ₖ _ ≡ x) → _ path n x p = (cong (λ y → x -ₖ y) (sym p) ∙∙ cong (λ y → x +ₖ y) -0ₖ ∙∙ rUnitₖ _ x) ∙ refl helper : (n : ℕ) (x : coHomK (suc n)) (p : 0ₖ _ ≡ x) → PathP (λ i → path n x p i ≡ 0ₖ _) (rCancelₖ _ x) (sym p) helper zero x = J (λ x p → PathP (λ i → path 0 x p i ≡ 0ₖ _) (rCancelₖ _ x) (sym p)) λ i j → rUnit (rUnit (λ _ → 0ₖ 1) (~ j)) (~ j) i helper (suc n) x = J (λ x p → PathP (λ i → path (suc n) x p i ≡ 0ₖ _) (rCancelₖ _ x) (sym p)) λ i j → rCancelₖ (suc (suc n)) (0ₖ (suc (suc n))) (~ i ∧ ~ j) +∙≡+ : (n : ℕ) {A : Pointed ℓ} (x y : coHomRed (suc n) A) → Iso.fun (Iso-coHom-coHomRed n) (x +ₕ∙ y) ≡ Iso.fun (Iso-coHom-coHomRed n) x +ₕ Iso.fun (Iso-coHom-coHomRed n) y +∙≡+ zero = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ _ _ → refl +∙≡+ (suc n) = sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ _ _ → refl private homhelp : ∀ {ℓ} (n : ℕ) (A : Pointed ℓ) (x y : coHom (suc n) (typ A)) → Iso.inv (Iso-coHom-coHomRed {A = A} n) (x +ₕ y) ≡ Iso.inv (Iso-coHom-coHomRed n) x +ₕ∙ Iso.inv (Iso-coHom-coHomRed n) y homhelp n A = morphLemmas.isMorphInv _+ₕ∙_ _+ₕ_ (Iso.fun (Iso-coHom-coHomRed n)) (+∙≡+ n) _ (Iso.rightInv (Iso-coHom-coHomRed n)) (Iso.leftInv (Iso-coHom-coHomRed n)) coHomGr≅coHomRedGr : ∀ {ℓ} (n : ℕ) (A : Pointed ℓ) → GroupEquiv (coHomRedGrDir (suc n) A) (coHomGr (suc n) (typ A)) fst (coHomGr≅coHomRedGr n A) = isoToEquiv (Iso-coHom-coHomRed n) snd (coHomGr≅coHomRedGr n A) = makeIsGroupHom (+∙≡+ n) coHomRedGroup : ∀ {ℓ} (n : ℕ) (A : Pointed ℓ) → AbGroup ℓ coHomRedGroup zero A = coHomRedGroupDir zero A coHomRedGroup (suc n) A = InducedAbGroup (coHomGroup (suc n) (typ A)) _+ₕ∙_ (isoToEquiv (invIso (Iso-coHom-coHomRed n))) (homhelp n A) abstract coHomGroup≡coHomRedGroup : ∀ {ℓ} (n : ℕ) (A : Pointed ℓ) → coHomGroup (suc n) (typ A) ≡ coHomRedGroup (suc n) A coHomGroup≡coHomRedGroup n A = InducedAbGroupPath (coHomGroup (suc n) (typ A)) _+ₕ∙_ (isoToEquiv (invIso (Iso-coHom-coHomRed n))) (homhelp n A) ------------------- Kₙ ≃ ΩKₙ₊₁ --------------------- -- This proof uses the encode-decode method rather than Freudenthal -- We define the map σ : Kₙ → ΩKₙ₊₁ and prove that it is a morphism private module _ (n : ℕ) where σ : {n : ℕ} → coHomK (suc n) → Path (coHomK (2 + n)) ∣ north ∣ ∣ north ∣ σ {n = n} = trRec (isOfHLevelTrunc (4 + n) _ _) λ a → cong ∣_∣ (merid a ∙ sym (merid (ptSn (suc n)))) σ-hom-helper : ∀ {ℓ} {A : Type ℓ} {a : A} (p : a ≡ a) (r : refl ≡ p) → lUnit p ∙ cong (_∙ p) r ≡ rUnit p ∙ cong (p ∙_) r σ-hom-helper p = J (λ p r → lUnit p ∙ cong (_∙ p) r ≡ rUnit p ∙ cong (p ∙_) r) refl σ-hom : {n : ℕ} (x y : coHomK (suc n)) → σ (x +ₖ y) ≡ σ x ∙ σ y σ-hom {n = zero} = elim2 (λ _ _ → isOfHLevelPath 3 (isOfHLevelTrunc 4 _ _) _ _) (wedgeconFun _ _ (λ _ _ → isOfHLevelTrunc 4 _ _ _ _) (λ x → lUnit _ ∙ cong (_∙ σ ∣ x ∣) (cong (cong ∣_∣) (sym (rCancel (merid base))))) (λ y → cong σ (rUnitₖ 1 ∣ y ∣) ∙∙ rUnit _ ∙∙ cong (σ ∣ y ∣ ∙_) (cong (cong ∣_∣) (sym (rCancel (merid base))))) (sym (σ-hom-helper (σ ∣ base ∣) (cong (cong ∣_∣) (sym (rCancel (merid base))))))) σ-hom {n = suc n} = elim2 (λ _ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (5 + n) _ _) _ _) (wedgeconFun _ _ (λ _ _ → isOfHLevelPath ((2 + n) + (2 + n)) (wedgeConHLev' n) _ _) (λ x → lUnit _ ∙ cong (_∙ σ ∣ x ∣) (cong (cong ∣_∣) (sym (rCancel (merid north))))) (λ y → cong σ (rUnitₖ (2 + n) ∣ y ∣) ∙∙ rUnit _ ∙∙ cong (σ ∣ y ∣ ∙_) (cong (cong ∣_∣) (sym (rCancel (merid north))))) (sym (σ-hom-helper (σ ∣ north ∣) (cong (cong ∣_∣) (sym (rCancel (merid north))))))) -- We will need to following lemma σ-minusDistr : {n : ℕ} (x y : coHomK (suc n)) → σ (x -ₖ y) ≡ σ x ∙ sym (σ y) σ-minusDistr {n = n} = morphLemmas.distrMinus' _+ₖ_ _∙_ σ σ-hom ∣ (ptSn (suc n)) ∣ refl -ₖ_ sym (λ x → sym (lUnit x)) (λ x → sym (rUnit x)) (rUnitₖ (suc n)) (lCancelₖ (suc n)) rCancel (assocₖ (suc n)) assoc∙ (cong (cong ∣_∣) (rCancel (merid (ptSn (suc n))))) -- we define the code using addIso Code : (n : ℕ) → coHomK (2 + n) → Type₀ Code n x = (trRec {B = TypeOfHLevel ℓ-zero (3 + n)} (isOfHLevelTypeOfHLevel (3 + n)) λ a → Code' a , hLevCode' a) x .fst where Code' : (S₊ (2 + n)) → Type₀ Code' north = coHomK (suc n) Code' south = coHomK (suc n) Code' (merid a i) = isoToPath (addIso (suc n) ∣ a ∣) i hLevCode' : (x : S₊ (2 + n)) → isOfHLevel (3 + n) (Code' x) hLevCode' = suspToPropElim (ptSn (suc n)) (λ _ → isPropIsOfHLevel (3 + n)) (isOfHLevelTrunc (3 + n)) symMeridLem : (n : ℕ) → (x : S₊ (suc n)) (y : coHomK (suc n)) → subst (Code n) (cong ∣_∣ (sym (merid x))) y ≡ y -ₖ ∣ x ∣ symMeridLem n x = trElim (λ _ → isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _) (λ y → cong (_-ₖ ∣ x ∣) (transportRefl ∣ y ∣)) decode : {n : ℕ} (x : coHomK (2 + n)) → Code n x → ∣ north ∣ ≡ x decode {n = n} = trElim (λ _ → isOfHLevelΠ (4 + n) λ _ → isOfHLevelPath (4 + n) (isOfHLevelTrunc (4 + n)) _ _) decode-elim where north≡merid : (a : S₊ (suc n)) → Path (coHomK (2 + n)) ∣ north ∣ ∣ north ∣ ≡ (Path (coHomK (2 + n)) ∣ north ∣ ∣ south ∣) north≡merid a i = Path (coHomK (2 + n)) ∣ north ∣ ∣ merid a i ∣ decode-elim : (a : S₊ (2 + n)) → Code n ∣ a ∣ → Path (coHomK (2 + n)) ∣ north ∣ ∣ a ∣ decode-elim north = σ decode-elim south = trRec (isOfHLevelTrunc (4 + n) _ _) λ a → cong ∣_∣ (merid a) decode-elim (merid a i) = hcomp (λ k → λ { (i = i0) → σ ; (i = i1) → mainPath a k}) (funTypeTransp (Code n) (λ x → ∣ north ∣ ≡ x) (cong ∣_∣ (merid a)) σ i) where mainPath : (a : (S₊ (suc n))) → transport (north≡merid a) ∘ σ ∘ transport (λ i → Code n ∣ merid a (~ i) ∣) ≡ trRec (isOfHLevelTrunc (4 + n) _ _) λ a → cong ∣_∣ (merid a) mainPath a = funExt (trElim (λ _ → isOfHLevelPath (3 + n) (isOfHLevelTrunc (4 + n) _ _) _ _) (λ x → (λ i → transport (north≡merid a) (σ (symMeridLem n a ∣ x ∣ i))) ∙∙ cong (transport (north≡merid a)) (-distrHelp x) ∙∙ (substAbove x))) where -distrHelp : (x : S₊ (suc n)) → σ (∣ x ∣ -ₖ ∣ a ∣) ≡ cong ∣_∣ (merid x) ∙ cong ∣_∣ (sym (merid a)) -distrHelp x = σ-minusDistr ∣ x ∣ ∣ a ∣ ∙ (λ i → (cong ∣_∣ (compPath-filler (merid x) (λ j → merid (ptSn (suc n)) (~ j ∨ i)) (~ i))) ∙ (cong ∣_∣ (sym (compPath-filler (merid a) (λ j → merid (ptSn (suc n)) (~ j ∨ i)) (~ i))))) substAbove : (x : S₊ (suc n)) → transport (north≡merid a) (cong ∣_∣ (merid x) ∙ cong ∣_∣ (sym (merid a))) ≡ cong ∣_∣ (merid x) substAbove x i = transp (λ j → north≡merid a (i ∨ j)) i (compPath-filler (cong ∣_∣ (merid x)) (λ j → ∣ merid a (~ j ∨ i) ∣) (~ i)) encode : {n : ℕ} {x : coHomK (2 + n)} → Path (coHomK (2 + n)) ∣ north ∣ x → Code n x encode {n = n} p = transport (cong (Code n) p) ∣ (ptSn (suc n)) ∣ decode-encode : {n : ℕ} {x : coHomK (2 + n)} (p : Path (coHomK (2 + n)) ∣ north ∣ x) → decode _ (encode p) ≡ p decode-encode {n = n} = J (λ y p → decode _ (encode p) ≡ p) (cong (decode ∣ north ∣) (transportRefl ∣ ptSn (suc n) ∣) ∙ cong (cong ∣_∣) (rCancel (merid (ptSn (suc n))))) -- We define an addition operation on Code which we can use in order to show that encode is a -- morphism (in a very loose sense) hLevCode : {n : ℕ} (x : coHomK (2 + n)) → isOfHLevel (3 + n) (Code n x) hLevCode {n = n} = trElim (λ _ → isProp→isOfHLevelSuc (3 + n) (isPropIsOfHLevel (3 + n))) (sphereToPropElim _ (λ _ → (isPropIsOfHLevel (3 + n))) (isOfHLevelTrunc (3 + n))) Code-add' : {n : ℕ} (x : _) → Code n ∣ north ∣ → Code n ∣ x ∣ → Code n ∣ x ∣ Code-add' {n = n} north = _+ₖ_ Code-add' {n = n} south = _+ₖ_ Code-add' {n = n} (merid a i) = helper n a i where help : (n : ℕ) → (x y a : S₊ (suc n)) → transport (λ i → Code n ∣ north ∣ → Code n ∣ merid a i ∣ → Code n ∣ merid a i ∣) (_+ₖ_) ∣ x ∣ ∣ y ∣ ≡ ∣ x ∣ +ₖ ∣ y ∣ help n x y a = (λ i → transportRefl ((∣ transportRefl x i ∣ +ₖ (∣ transportRefl y i ∣ -ₖ ∣ a ∣)) +ₖ ∣ a ∣) i) ∙∙ cong (_+ₖ ∣ a ∣) (assocₖ _ ∣ x ∣ ∣ y ∣ (-ₖ ∣ a ∣)) ∙∙ sym (assocₖ _ (∣ x ∣ +ₖ ∣ y ∣) (-ₖ ∣ a ∣) ∣ a ∣) ∙∙ cong ((∣ x ∣ +ₖ ∣ y ∣) +ₖ_) (lCancelₖ _ ∣ a ∣) ∙∙ rUnitₖ _ _ helper : (n : ℕ) (a : S₊ (suc n)) → PathP (λ i → Code n ∣ north ∣ → Code n ∣ merid a i ∣ → Code n ∣ merid a i ∣) _+ₖ_ _+ₖ_ helper n a = toPathP (funExt (trElim (λ _ → isOfHLevelPath (3 + n) (isOfHLevelΠ (3 + n) (λ _ → isOfHLevelTrunc (3 + n))) _ _) λ x → funExt (trElim (λ _ → isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _) λ y → help n x y a))) Code-add : {n : ℕ} (x : _) → Code n ∣ north ∣ → Code n x → Code n x Code-add {n = n} = trElim (λ x → isOfHLevelΠ (4 + n) λ _ → isOfHLevelΠ (4 + n) λ _ → isOfHLevelSuc (3 + n) (hLevCode {n = n} x)) Code-add' encode-hom : {n : ℕ} {x : _} (q : 0ₖ _ ≡ 0ₖ _) (p : 0ₖ _ ≡ x) → encode (q ∙ p) ≡ Code-add {n = n} x (encode q) (encode p) encode-hom {n = n} q = J (λ x p → encode (q ∙ p) ≡ Code-add {n = n} x (encode q) (encode p)) (cong encode (sym (rUnit q)) ∙∙ sym (rUnitₖ _ (encode q)) ∙∙ cong (encode q +ₖ_) (cong ∣_∣ (sym (transportRefl _)))) stabSpheres : (n : ℕ) → Iso (coHomK (suc n)) (typ (Ω (coHomK-ptd (2 + n)))) fun (stabSpheres n) = decode _ inv' (stabSpheres n) = encode rightInv (stabSpheres n) p = decode-encode p leftInv (stabSpheres n) = trElim (λ _ → isOfHLevelPath (3 + n) (isOfHLevelTrunc (3 + n)) _ _) λ a → cong encode (congFunct ∣_∣ (merid a) (sym (merid (ptSn (suc n))))) ∙∙ (λ i → transport (congFunct (Code n) (cong ∣_∣ (merid a)) (cong ∣_∣ (sym (merid (ptSn (suc n))))) i) ∣ ptSn (suc n) ∣) ∙∙ (substComposite (λ x → x) (cong (Code n) (cong ∣_∣ (merid a))) (cong (Code n) (cong ∣_∣ (sym (merid (ptSn (suc n)))))) ∣ ptSn (suc n) ∣ ∙∙ cong (transport (λ i → Code n ∣ merid (ptSn (suc n)) (~ i) ∣)) (transportRefl (∣ (ptSn (suc n)) ∣ +ₖ ∣ a ∣) ∙ lUnitₖ (suc n) ∣ a ∣) ∙∙ symMeridLem n (ptSn (suc n)) ∣ a ∣ ∙∙ cong (∣ a ∣ +ₖ_) -0ₖ ∙∙ rUnitₖ (suc n) ∣ a ∣) Iso-Kn-ΩKn+1 : (n : HLevel) → Iso (coHomK n) (typ (Ω (coHomK-ptd (suc n)))) Iso-Kn-ΩKn+1 zero = invIso (compIso (congIso (truncIdempotentIso _ isGroupoidS¹)) ΩS¹IsoInt) Iso-Kn-ΩKn+1 (suc n) = stabSpheres n Kn≃ΩKn+1 : {n : ℕ} → coHomK n ≃ typ (Ω (coHomK-ptd (suc n))) Kn≃ΩKn+1 {n = n} = isoToEquiv (Iso-Kn-ΩKn+1 n) -- Some properties of the Iso Kn→ΩKn+1 : (n : ℕ) → coHomK n → typ (Ω (coHomK-ptd (suc n))) Kn→ΩKn+1 n = Iso.fun (Iso-Kn-ΩKn+1 n) ΩKn+1→Kn : (n : ℕ) → typ (Ω (coHomK-ptd (suc n))) → coHomK n ΩKn+1→Kn n = Iso.inv (Iso-Kn-ΩKn+1 n) Kn→ΩKn+10ₖ : (n : ℕ) → Kn→ΩKn+1 n (0ₖ n) ≡ refl Kn→ΩKn+10ₖ zero = sym (rUnit refl) Kn→ΩKn+10ₖ (suc n) i j = ∣ (rCancel (merid (ptSn (suc n))) i j) ∣ ΩKn+1→Kn-refl : (n : ℕ) → ΩKn+1→Kn n refl ≡ 0ₖ n ΩKn+1→Kn-refl zero = refl ΩKn+1→Kn-refl (suc zero) = refl ΩKn+1→Kn-refl (suc (suc n)) = refl Kn→ΩKn+1-hom : (n : ℕ) (x y : coHomK n) → Kn→ΩKn+1 n (x +[ n ]ₖ y) ≡ Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y Kn→ΩKn+1-hom zero x y = (λ j i → hfill (doubleComp-faces (λ i₁ → ∣ base ∣) (λ _ → ∣ base ∣) i) (inS (∣ intLoop (x ℤ+ y) i ∣)) (~ j)) ∙∙ (λ j i → ∣ intLoop-hom x y (~ j) i ∣) ∙∙ (congFunct ∣_∣ (intLoop x) (intLoop y) ∙ cong₂ _∙_ (λ j i → hfill (doubleComp-faces (λ i₁ → ∣ base ∣) (λ _ → ∣ base ∣) i) (inS (∣ intLoop x i ∣)) j) λ j i → hfill (doubleComp-faces (λ i₁ → ∣ base ∣) (λ _ → ∣ base ∣) i) (inS (∣ intLoop y i ∣)) j) Kn→ΩKn+1-hom (suc n) = σ-hom ΩKn+1→Kn-hom : (n : ℕ) (x y : Path (coHomK (suc n)) (0ₖ _) (0ₖ _)) → ΩKn+1→Kn n (x ∙ y) ≡ ΩKn+1→Kn n x +[ n ]ₖ ΩKn+1→Kn n y ΩKn+1→Kn-hom zero p q = cong winding (congFunct (trRec isGroupoidS¹ (λ x → x)) p q) ∙ winding-hom (cong (trRec isGroupoidS¹ (λ x → x)) p) (cong (trRec isGroupoidS¹ (λ x → x)) q) ΩKn+1→Kn-hom (suc n) = encode-hom isHomogeneousKn : (n : HLevel) → isHomogeneous (coHomK-ptd n) isHomogeneousKn n = subst isHomogeneous (sym (ΣPathP (ua Kn≃ΩKn+1 , ua-gluePath _ (Kn→ΩKn+10ₖ n)))) (isHomogeneousPath _ _) -- With the equivalence Kn≃ΩKn+1, we get that the two definitions of cohomology groups agree open IsGroupHom coHom≅coHomΩ : ∀ {ℓ} (n : ℕ) (A : Type ℓ) → GroupIso (coHomGr n A) (coHomGrΩ n A) fun (fst (coHom≅coHomΩ n A)) = map λ f a → Kn→ΩKn+1 n (f a) inv' (fst (coHom≅coHomΩ n A)) = map λ f a → ΩKn+1→Kn n (f a) rightInv (fst (coHom≅coHomΩ n A)) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ f → cong ∣_∣₂ (funExt λ x → rightInv (Iso-Kn-ΩKn+1 n) (f x)) leftInv (fst (coHom≅coHomΩ n A)) = sElim (λ _ → isOfHLevelPath 2 § _ _) λ f → cong ∣_∣₂ (funExt λ x → leftInv (Iso-Kn-ΩKn+1 n) (f x)) snd (coHom≅coHomΩ n A) = makeIsGroupHom (sElim2 (λ _ _ → isOfHLevelPath 2 § _ _) λ f g → cong ∣_∣₂ (funExt λ x → Kn→ΩKn+1-hom n (f x) (g x))) module lockedKnIso (key : Unit') where Kn→ΩKn+1' : (n : ℕ) → coHomK n → typ (Ω (coHomK-ptd (suc n))) Kn→ΩKn+1' n = lock key (Iso.fun (Iso-Kn-ΩKn+1 n)) ΩKn+1→Kn' : (n : ℕ) → typ (Ω (coHomK-ptd (suc n))) → coHomK n ΩKn+1→Kn' n = lock key (Iso.inv (Iso-Kn-ΩKn+1 n)) ΩKn+1→Kn→ΩKn+1 : (n : ℕ) → (x : typ (Ω (coHomK-ptd (suc n)))) → Kn→ΩKn+1' n (ΩKn+1→Kn' n x) ≡ x ΩKn+1→Kn→ΩKn+1 n x = pm key where pm : (key : Unit') → lock key (Iso.fun (Iso-Kn-ΩKn+1 n)) (lock key (Iso.inv (Iso-Kn-ΩKn+1 n)) x) ≡ x pm unlock = Iso.rightInv (Iso-Kn-ΩKn+1 n) x Kn→ΩKn+1→Kn : (n : ℕ) → (x : coHomK n) → ΩKn+1→Kn' n (Kn→ΩKn+1' n x) ≡ x Kn→ΩKn+1→Kn n x = pm key where pm : (key : Unit') → lock key (Iso.inv (Iso-Kn-ΩKn+1 n)) (lock key (Iso.fun (Iso-Kn-ΩKn+1 n)) x) ≡ x pm unlock = Iso.leftInv (Iso-Kn-ΩKn+1 n) x -distrLemma : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n m : ℕ) (f : GroupHom (coHomGr n A) (coHomGr m B)) (x y : coHom n A) → fst f (x -[ n ]ₕ y) ≡ fst f x -[ m ]ₕ fst f y -distrLemma n m f' x y = sym (-cancelRₕ m (f y) (f (x -[ n ]ₕ y))) ∙∙ cong (λ x → x -[ m ]ₕ f y) (sym (f' .snd .pres· (x -[ n ]ₕ y) y)) ∙∙ cong (λ x → x -[ m ]ₕ f y) ( cong f (-+cancelₕ n _ _)) where f = fst f'
regtests/ado-sequences-tests.adb
My-Colaborations/ada-ado
0
8396
<reponame>My-Colaborations/ada-ado ----------------------------------------------------------------------- -- ado-sequences-tests -- Test sequences factories -- Copyright (C) 2011, 2012, 2015, 2017, 2018 <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 ADO.Configs; with ADO.Sessions; with ADO.SQL; with ADO.Statements; with Regtests.Simple.Model; with ADO.Sequences.Hilo; with ADO.Sessions.Sources; with ADO.Sessions.Factory; with ADO.Schemas; package body ADO.Sequences.Tests is type Test_Impl is new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER, Of_Class => Regtests.Simple.Model.ALLOCATE_TABLE) with record Version : Integer; Value : ADO.Identifier; Name : Ada.Strings.Unbounded.Unbounded_String; Select_Name : Ada.Strings.Unbounded.Unbounded_String; end record; overriding procedure Destroy (Object : access Test_Impl); overriding procedure Find (Object : in out Test_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); overriding procedure Load (Object : in out Test_Impl; Session : in out ADO.Sessions.Session'Class); overriding procedure Save (Object : in out Test_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Delete (Object : in out Test_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Create (Object : in out Test_Impl; Session : in out ADO.Sessions.Master_Session'Class); package Caller is new Util.Test_Caller (Test, "ADO.Sequences"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test ADO.Sequences.Create", Test_Create_Factory'Access); end Add_Tests; SEQUENCE_NAME : aliased constant String := "sequence"; Sequence_Table : aliased ADO.Schemas.Class_Mapping := ADO.Schemas.Class_Mapping '(Count => 0, Table => SEQUENCE_NAME'Access, Members => <>); -- Test creation of the sequence factory. -- This test revealed a memory leak if we failed to create a database connection. procedure Test_Create_Factory (T : in out Test) is Seq_Factory : ADO.Sequences.Factory; Obj : Test_Impl; Factory : aliased ADO.Sessions.Factory.Session_Factory; Controller : aliased ADO.Sessions.Sources.Data_Source; Prev_Id : Identifier := ADO.NO_IDENTIFIER; begin Seq_Factory.Set_Default_Generator (ADO.Sequences.Hilo.Create_HiLo_Generator'Access, Factory'Unchecked_Access); begin Seq_Factory.Allocate (Obj); T.Assert (False, "No exception raised."); exception when ADO.Sessions.Connection_Error => null; -- Good! An exception is expected because the session factory is empty. end; -- Make a real connection. Controller.Set_Connection (ADO.Configs.Get_Config ("test.database")); Factory.Create (Controller); for I in 1 .. 1_000 loop Seq_Factory.Allocate (Obj); T.Assert (Obj.Get_Key_Value /= Prev_Id, "Invalid id was allocated"); Prev_Id := Obj.Get_Key_Value; end loop; -- Erase the sequence entry used for the allocate entity table. declare S : constant ADO.Sessions.Master_Session := Regtests.Get_Master_Database; D : ADO.Statements.Delete_Statement := S.Create_Statement (Sequence_Table'Access); begin D.Set_Filter ("name = :name"); D.Bind_Param ("name", String '("allocate")); D.Execute; -- Also delete all allocate items. D := S.Create_Statement (Regtests.Simple.Model.ALLOCATE_TABLE); D.Execute; end; -- Create new objects. This forces the creation of a new entry in the sequence table. for I in 1 .. 1_00 loop Seq_Factory.Allocate (Obj); T.Assert (Obj.Get_Key_Value /= Prev_Id, "Invalid id was allocated"); Prev_Id := Obj.Get_Key_Value; end loop; end Test_Create_Factory; overriding procedure Destroy (Object : access Test_Impl) is begin null; end Destroy; overriding procedure Find (Object : in out Test_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is pragma Unreferenced (Object, Session, Query); begin Found := False; end Find; overriding procedure Load (Object : in out Test_Impl; Session : in out ADO.Sessions.Session'Class) is begin null; end Load; overriding procedure Save (Object : in out Test_Impl; Session : in out ADO.Sessions.Master_Session'Class) is begin null; end Save; overriding procedure Delete (Object : in out Test_Impl; Session : in out ADO.Sessions.Master_Session'Class) is begin null; end Delete; overriding procedure Create (Object : in out Test_Impl; Session : in out ADO.Sessions.Master_Session'Class) is begin null; end Create; end ADO.Sequences.Tests;
Lang/Irrelevance.agda
Lolirofle/stuff-in-agda
6
3578
module Lang.Irrelevance where open import Type postulate .axiom : ∀{ℓ}{T : Type{ℓ}} -> .T -> T
Transynther/x86/_processed/US/_zr_/i7-7700_9_0x48.log_21829_2647.asm
ljhsiun2/medusa
9
12836
<filename>Transynther/x86/_processed/US/_zr_/i7-7700_9_0x48.log_21829_2647.asm .global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r14 push %r8 push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x1bb48, %r14 nop sub %rsi, %rsi vmovups (%r14), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $1, %xmm0, %r10 nop nop xor $64085, %r11 lea addresses_WC_ht+0x7c48, %r14 nop nop nop nop nop xor %rdx, %rdx mov (%r14), %r8 nop nop nop and $38284, %r10 lea addresses_UC_ht+0x12608, %rsi lea addresses_WT_ht+0x730c, %rdi nop inc %r11 mov $47, %rcx rep movsw nop nop nop nop nop sub $9041, %r8 lea addresses_normal_ht+0x185d8, %rsi lea addresses_WC_ht+0x1b48, %rdi clflush (%rdi) nop nop nop nop nop xor %r14, %r14 mov $81, %rcx rep movsq nop nop nop nop dec %rsi lea addresses_normal_ht+0x7348, %rsi lea addresses_D_ht+0x9e2c, %rdi nop nop nop nop nop cmp $56452, %r11 mov $66, %rcx rep movsb nop nop nop nop add $16727, %r10 lea addresses_A_ht+0x115c8, %r8 nop inc %rcx and $0xffffffffffffffc0, %r8 movaps (%r8), %xmm0 vpextrq $1, %xmm0, %r11 nop nop nop nop nop and %rdi, %rdi lea addresses_A_ht+0x8f48, %rsi lea addresses_UC_ht+0x15f08, %rdi nop nop nop nop nop cmp $40030, %r8 mov $74, %rcx rep movsl nop nop and $52641, %rdi lea addresses_normal_ht+0x170cc, %rsi lea addresses_D_ht+0x12748, %rdi nop nop nop nop dec %r8 mov $122, %rcx rep movsb nop nop nop add %rcx, %rcx lea addresses_WT_ht+0x1b848, %rsi nop nop nop nop nop sub %rdi, %rdi movl $0x61626364, (%rsi) nop nop lfence lea addresses_A_ht+0x13a68, %rdi nop nop nop xor $35014, %r14 mov $0x6162636465666768, %rdx movq %rdx, %xmm5 vmovups %ymm5, (%rdi) xor $24117, %rdi lea addresses_D_ht+0x119b8, %rdx sub %r10, %r10 movl $0x61626364, (%rdx) nop nop nop and $4974, %rsi lea addresses_UC_ht+0x119c8, %rcx nop nop nop nop cmp %r11, %r11 mov (%rcx), %r8d inc %rsi lea addresses_normal_ht+0xeac8, %rsi lea addresses_A_ht+0xa590, %rdi nop nop nop and %r11, %r11 mov $104, %rcx rep movsq nop nop nop and %rdx, %rdx lea addresses_normal_ht+0x11f48, %r10 nop nop nop cmp %rdx, %rdx movb (%r10), %r14b nop nop nop nop xor $4450, %r11 pop %rsi pop %rdx pop %rdi pop %rcx pop %r8 pop %r14 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r15 push %rbp push %rcx push %rdx push %rsi // Load lea addresses_UC+0x3248, %rdx nop and $37615, %rcx mov (%rdx), %rbp nop nop inc %rcx // Store mov $0xec8, %rsi cmp $44066, %r15 movw $0x5152, (%rsi) nop nop sub $21334, %rcx // Faulty Load lea addresses_US+0x18f48, %rbp nop nop dec %r11 movb (%rbp), %r13b lea oracles, %r11 and $0xff, %r13 shlq $12, %r13 mov (%r11,%r13,1), %r13 pop %rsi pop %rdx pop %rcx pop %rbp pop %r15 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 8, 'size': 8, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 1, 'size': 2, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 10, 'size': 32, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 7, 'size': 8, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 10, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': True, 'congruent': 5, 'size': 16, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'AVXalign': False, 'congruent': 7, 'size': 4, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 5, 'size': 32, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 4, 'size': 4, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 5, 'size': 4, 'same': True, 'NT': True}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 9, 'size': 1, 'same': False, 'NT': False}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
programs/oeis/183/A183409.asm
karttu/loda
0
22164
<gh_stars>0 ; A183409: Number of n X 2 binary arrays with each sum of a(1..i,1..j) no greater than i*j/2 and rows and columns in nondecreasing order. ; 2,5,8,15,21,34,44,65,80,111,132,175,203,260,296,369,414,505,560,671,737,870,948,1105,1196,1379,1484,1695,1815,2056,2192,2465,2618,2925,3096,3439,3629,4010,4220,4641,4872,5335,5588,6095,6371,6924,7224,7825,8150,8801,9152,9855,10233,10990,11396,12209,12644,13515,13980,14911,15407,16400,16928,17985,18546,19669,20264,21455,22085,23346,24012,25345,26048,27455,28196,29679,30459,32020,32840,34481,35342,37065,37968,39775,40721,42614,43604,45585,46620,48691,49772,51935,53063,55320,56496,58849,60074,62525,63800,66351,67677,70330,71708,74465,75896,78759,80244,83215,84755,87836,89432,92625,94278,97585,99296,102719,104489,108030,109860,113521,115412,119195,121148,125055,127071,131104,133184,137345,139490,143781,145992,150415,152693,157250,159596,164289,166704,171535,174020,178991,181547,186660,189288,194545,197246,202649,205424,210975,213825,219526,222452,228305,231308,237315,240396,246559,249719,256040,259280,265761,269082,275725,279128,285935,289421,296394,299964,307105,310760,318071,321812,329295,333123,340780,344696,352529,356534,364545,368640,376831,381017,389390,393668,402225,406596,415339,419804,428735,433295,442416,447072,456385,461138,470645,475496,485199,490149,500050,505100,515201 add $0,2 mov $1,$0 mov $2,$0 div $0,2 add $1,1 sub $1,$0 sub $2,$0 mul $2,$0 add $2,2 mul $1,$2 sub $1,6 div $1,2 add $1,2
src/main/java/sparksoniq/jsoniq/compiler/parser/Jsoniq.g4
AndreaRinaldi1/rumble
0
3286
<reponame>AndreaRinaldi1/rumble<filename>src/main/java/sparksoniq/jsoniq/compiler/parser/Jsoniq.g4<gh_stars>0 grammar Jsoniq; // parser grammar, parses streams of tokens @header { // Java header package sparksoniq.jsoniq.compiler.parser; } module : (Kjsoniq Kversion vers=stringLiteral ';')? (libraryModule | main=mainModule); mainModule: prolog expr;//hack (expr)*; libraryModule: 'module' 'namespace' NCName '=' uriLiteral ';' prolog; prolog: ((defaultCollationDecl | orderingModeDecl | emptyOrderDecl | decimalFormatDecl | moduleImport) ';')* ((functionDecl | varDecl ) ';')* ; defaultCollationDecl: 'declare' Kdefault Kcollation uriLiteral; orderingModeDecl: 'declare' 'ordering' ('ordered' | 'unordered'); emptyOrderDecl: 'declare' Kdefault 'order' Kempty (Kgreatest | Kleast); decimalFormatDecl : 'declare' (('decimal-format' (NCName ':')? NCName) | (Kdefault 'decimal-format')) (dfPropertyName '=' stringLiteral)*; dfPropertyName : 'decimal-separator' | 'grouping-separator' | 'infinity' | 'minus-sign' | 'NaN' | 'percent' | 'per-mille' | 'zero-digit' | 'digit' | 'pattern-separator'; moduleImport : 'import' 'module' ('namespace' NCName '=')? uriLiteral (Kat uriLiteral (',' uriLiteral)*)?; varDecl : 'declare' 'variable' varRef (Kas sequenceType)? ((':=' exprSingle) | ('external' (':=' exprSingle)?)); functionDecl : 'declare' 'function' (NCName ':')? NCName '(' paramList? ')' (Kas sequenceType)? ('{' expr '}' | 'external'); paramList : '$' NCName (Kas sequenceType)? (',' '$' NCName (Kas sequenceType)?)*; ///////////////////////////////////////////////////////constructs, expression expr : exprSingle (',' exprSingle)*; exprSingle : flowrExpr | quantifiedExpr | switchExpr | typeSwitchExpr | ifExpr | tryCatchExpr | orExpr; flowrExpr : (start_for=forClause| start_let=letClause) (forClause | whereClause | letClause | groupByClause | orderByClause | countClause)* Kreturn return_Expr=exprSingle; forClause :Kfor vars+=forVar (',' vars+=forVar)*; forVar : var_ref=varRef (Kas seq=sequenceType)? (flag=Kallowing Kempty)? (Kat at=varRef)? Kin ex=exprSingle; letClause : Klet vars+=letVar (',' vars+=letVar)*; letVar: var_ref=varRef (Kas seq=sequenceType)? ':=' ex=exprSingle ; whereClause : Kwhere exprSingle; groupByClause : Kgroup Kby vars+=groupByVar (',' vars+=groupByVar)*; groupByVar: var_ref=varRef ((Kas seq=sequenceType)? decl=':=' ex=exprSingle)? (Kcollation uri=uriLiteral)?; orderByClause : ((Korder Kby) | (stb=Kstable Korder Kby)) orderByExpr (',' orderByExpr)*; orderByExpr: ex=exprSingle (Kascending | desc=Kdescending)? (Kempty (gr=Kgreatest | ls=Kleast))? (Kcollation uril=uriLiteral)?; countClause : Kcount varRef; quantifiedExpr : (so=Ksome | ev=Kevery) vars+=quantifiedExprVar (',' vars+=quantifiedExprVar)* Ksatisfies exprSingle; quantifiedExprVar : varRef (Kas sequenceType)? Kin exprSingle; switchExpr : Kswitch '(' cond=expr ')' cses+=switchCaseClause+ Kdefault Kreturn def=exprSingle; switchCaseClause : (Kcase cond+=exprSingle)+ Kreturn ret=exprSingle; typeSwitchExpr : Ktypeswitch '(' expr ')' caseClause+ Kdefault (varRef)? Kreturn exprSingle; caseClause : Kcase (varRef Kas)? sequenceType ('|' sequenceType)* Kreturn exprSingle; ifExpr : Kif '(' testCondition=expr ')' Kthen branch=exprSingle Kelse elseBranch=exprSingle; tryCatchExpr : Ktry '{' expr '}' Kcatch '*' '{' expr '}'; /////////////////////////////////////expression orExpr : mainExpr=andExpr ( Kor rhs+=andExpr )*; andExpr : mainExpr=notExpr ( Kand rhs+=notExpr )*; notExpr : op+=Knot ? mainExpr=comparisonExpr; comparisonExpr : mainExpr=stringConcatExpr ( op+=('eq' | 'ne' | 'lt' | 'le' | 'gt' | 'ge' | '=' | '!=' | '<' | '<=' | '>' | '>=') rhs+=stringConcatExpr )?; stringConcatExpr : mainExpr=rangeExpr ( '||' rhs+=rangeExpr )* ; rangeExpr : mainExpr=additiveExpr ( Kto rhs+=additiveExpr )?; additiveExpr : mainExpr=multiplicativeExpr ( op+=('+' | '-') rhs+=multiplicativeExpr )*; multiplicativeExpr : mainExpr=instanceOfExpr ( op+=('*' | 'div' | 'idiv' | 'mod') rhs+=instanceOfExpr )*; instanceOfExpr : mainExpr=treatExpr ( Kinstance Kof seq=sequenceType)?; treatExpr : mainExpr=castableExpr ( Ktreat Kas sequenceType )?; castableExpr : mainExpr=castExpr ( Kcastable Kas atomicType '?'? )?; castExpr : mainExpr=unaryExpr ( Kcast Kas atomicType '?'? )?; unaryExpr: op+=('-' | '+')* mainExpr=simpleMapExpr; simpleMapExpr: mainExpr=postFixExpr ('!' postFixExpr)*; postFixExpr: mainExpr=primaryExpr (al=arrayLookup | pr=predicate | ol=objectLookup | au=arrayUnboxing)*; arrayLookup: '[' '[' expr ']' ']'; arrayUnboxing: '[' ']'; predicate: '[' expr ']'; objectLookup: '.' ( kw=keyWords | lt=stringLiteral | nc=NCName | pe=parenthesizedExpr | vr=varRef | ci=contextItemExpr ); primaryExpr: Literal | stringLiteral | varRef | parenthesizedExpr | contextItemExpr | objectConstructor | functionCall | orderedExpr | unorderedExpr | arrayConstructor; Literal : NumericLiteral | BooleanLiteral | NullLiteral; NumericLiteral : IntegerLiteral | DecimalLiteral | DoubleLiteral; BooleanLiteral : 'true' | 'false'; NullLiteral : 'null'; varRef : '$' (ns=NCName ':')? name=NCName; parenthesizedExpr: '(' expr? ')'; contextItemExpr: '$$'; orderedExpr : 'ordered' '{' expr '}'; unorderedExpr : 'unordered' '{' expr '}'; functionCall : ((ns=NCName | kw=keyWords | )':')? (fcnName=nCNameOrKeyWordBoolean | kw = keyWords) argumentList; argumentList : '(' (args+=argument ','?)* ')'; argument : exprSingle | '?'; //////////////////////////////////////////////////// sequenceType : '(' ')' | item=itemType (question+='?' | star+='*' | plus+='+')?; objectConstructor : '{' ( pairConstructor (',' pairConstructor)* )? '}' | mergeOperator+='{|' expr '|}'; itemType : 'item' | jSONItemTest | atomicType; jSONItemTest : 'object' | 'array' | Kjson; keyWordBoolean : 'boolean'; atomicType : 'atomic' | 'string' | 'integer' | 'decimal' | 'double' | keyWordBoolean | 'null'; nCNameOrKeyWordBoolean : NCName | keyWordBoolean; pairConstructor : ( lhs=exprSingle | name=NCName ) (':' | '?') rhs=exprSingle; arrayConstructor : '[' expr? ']'; uriLiteral: stringLiteral; ///////////////////////////////////////////////////////literals keyWords: Kjsoniq | Kjson | Kversion | Ktypeswitch | Kor | Kand | Knot | Kto | Kinstance | Kof | Ktreat | Kcast | Kcastable | Kdefault | Kthen | Kelse | Kcollation | Kgreatest | Kleast | Kswitch | Kcase | Ktry | Kcatch | Ksome | Kevery | Ksatisfies | Kstable | Kascending | Kdescending | Kempty | Kallowing | Kas | Kat | Kin | Kif | Kfor | Klet | Kwhere | Kgroup | Kby | Korder | Kcount | Kreturn ; Kfor : 'for'; Klet : 'let'; Kwhere : 'where'; Kgroup : 'group'; Kby : 'by'; Korder : 'order'; Kreturn : 'return'; Kif : 'if'; Kin : 'in'; Kas : 'as'; Kat : 'at'; Kallowing : 'allowing'; Kempty : 'empty'; Kcount : 'count'; Kstable : 'stable'; Kascending : 'ascending'; Kdescending : 'descending'; Ksome : 'some'; Kevery : 'every'; Ksatisfies : 'satisfies'; Kcollation : 'collation'; Kgreatest : 'greatest'; Kleast : 'least'; Kswitch : 'switch'; Kcase : 'case'; Ktry : 'try'; Kcatch : 'catch'; Kdefault : 'default'; Kthen : 'then'; Kelse : 'else'; Ktypeswitch : 'typeswitch'; Kor : 'or'; Kand : 'and'; Knot : 'not' ; Kto : 'to' ; Kinstance : 'instance' ; Kof : 'of' ; Ktreat : 'treat'; Kcast : 'cast'; Kcastable : 'castable'; Kversion : 'version'; Kjsoniq : 'jsoniq'; Kjson : 'json-item'; stringLiteral: STRING; STRING : '"' (ESC | ~ ["\\])* '"' ; fragment ESC : '\\' (["\\/bfnrt] | UNICODE) ; fragment UNICODE : 'u' HEX HEX HEX HEX ; fragment HEX : [0-9a-fA-F] ; IntegerLiteral: Digits ; DecimalLiteral: '.' Digits | Digits '.' [0-9]* ; DoubleLiteral: ('.' Digits | Digits ('.' [0-9]*)?) [eE] [+-]? Digits ; fragment Digits: [0-9]+ ; WS: (' '|'\r'|'\t'|'\n') -> channel(HIDDEN); NCName: NameStartChar NameChar*; fragment NameStartChar: [_a-zA-Z] | '\u00C0'..'\u00D6' | '\u00D8'..'\u00F6' | '\u00F8'..'\u02FF' | '\u0370'..'\u037D' | '\u037F'..'\u1FFF' | '\u200C'..'\u200D' | '\u2070'..'\u218F' | '\u2C00'..'\u2FEF' | '\u3001'..'\uD7FF' | '\uF900'..'\uFDCF' | '\uFDF0'..'\uFFFD' ; fragment NameChar: NameStartChar | '-' // no . in JSONIQ names | '.' | [0-9] | '\u00B7' | '\u0300'..'\u036F' | '\u203F'..'\u2040' ; XQComment: '(' ':' (XQComment | '(' ~[:] | ':' ~[)] | ~[:(])* ':'+ ')' -> channel(HIDDEN); ContentChar: ~["'{}<&] ;
Library/Math/Float/floatC.asm
HubertHuckevoll/pcgeos
504
84663
COMMENT @---------------------------------------------------------------------- Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: PC GEOS MODULE: Float FILE: floatC.asm REVISION HISTORY: Name Date Description ---- ---- ----------- Anna 2/92 Initial version DESCRIPTION: This file contains C interface routines for the float library routines $Id: floatC.asm,v 1.1 97/04/05 01:23:04 newdeal Exp $ ------------------------------------------------------------------------------@ SetGeosConvention C_Float segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FLOATINIT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% C FUNCTION: FloatInit C DECLARATION: extern void _far_pascal FloatInit(word stackSize, FloatStackType stackType); PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 2/28/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FLOATINIT proc far ;stackSize:word C_GetTwoWordArgs ax, bx, dx, cx ;ax <- size ; bx <- type call FloatInit ret FLOATINIT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatAsciiToGeos80 C DECLARATION: extern void Boolean _far _pascal FloatAsciiToGeos80 (word floatAtoFflags, word stringLength, void *string, void *resultLocation); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Anna 2/92 Initial version ------------------------------------------------------------------------------@ FLOATASCIITOGEOS80 proc far floatAtoFflags:word, stringLength:word, string:fptr, resultLocation:fptr uses ds,di,si .enter lds si, string les di, resultLocation mov ax, floatAtoFflags mov cx, stringLength call FloatAsciiToFloat mov ax, 0 ; Leave this as a mov, so the carry is left ; alone. jnc done dec ax done: .leave ret FLOATASCIITOGEOS80 endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatComp C DECLARATION: extern word _far FloatComp() Returns: 0 if X1 = X2 1 if X1 > X2 -1 if X1 < X2 KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Anna 3/92 Initial version ------------------------------------------------------------------------------@ FLOATCOMP proc far call FloatCompFar pushf mov ax, 0 ; assume equal jz done mov ax, -1 ; X1 < X2 jc done mov ax, 1 ; X1 > X2 done: popf ret FLOATCOMP endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatCompAndDrop C DECLARATION: extern word _far FloatCompAndDrop() Returns: 0 if X1 = X2 1 if X1 > X2 -1 if X1 < X2 KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Anna 3/92 Initial version ------------------------------------------------------------------------------@ FLOATCOMPANDDROP proc far call FloatCompFar pushf mov ax, 0 ; assume equal jz done mov ax, -1 ; X1 < X2 jc done mov ax, 1 ; X1 > X2 done: call FLOATDROP call FLOATDROP popf ret FLOATCOMPANDDROP endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatCompGeos80ESDI C DECLARATION: extern word _far FloatCompGeos80ESDI() Returns: 0 if X1 = X2 1 if X1 > X2 -1 if X1 < X2 KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Anna 3/92 Initial version ------------------------------------------------------------------------------@ FLOATCOMPGEOS80ESDI proc far floatPtr:fptr uses es, di .enter les di, floatPtr call FloatCompESDIFar pushf mov ax, 0 ; assume equal jz done mov ax, -1 ; X1 < X2 jc done mov ax, 1 ; X1 > X2 done: popf .leave ret FLOATCOMPGEOS80ESDI endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatEq0 C DECLARATION: extern word _far FloatEq0() Returns: 0 if X <> 0 1 if X = 0 KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jeremy 5/27/92 Initial version ------------------------------------------------------------------------------@ FLOATEQ0 proc far call FloatEq0Far mov ax, 1 ; assume X = 0 jc done mov ax, 0 ; X <> 0 done: ret FLOATEQ0 endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatLt0 C DECLARATION: extern word _far FloatLt0() Returns: 0 if X >= 0 1 if X < 0 KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jeremy 5/27/92 Initial version ------------------------------------------------------------------------------@ FLOATLT0 proc far call FloatLt0Far mov ax, 1 ; assume X < 0 jc done mov ax, 0 ; X <> 0 done: ret FLOATLT0 endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatGt0 C DECLARATION: extern word _far FloatGt0() Returns: 0 if X <= 0 1 if X > 0 KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jeremy 5/27/92 Initial version ------------------------------------------------------------------------------@ FLOATGT0 proc far call FloatGt0Far mov ax, 1 ; assume X > 0 jc done mov ax, 0 ; X <= 0 done: ret FLOATGT0 endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatPushGeos80Number C DECLARATION: extern word _far FloatPushGeos80Number(FloatNum *number) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Anna 3/92 Initial version ------------------------------------------------------------------------------@ FLOATPUSHGEOS80NUMBER proc far number:fptr uses ds, si, es .enter lds si, number call FloatPushNumberFar mov ax, 0 ;assume no error jnc done mov ax, -1 done: .leave ret FLOATPUSHGEOS80NUMBER endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatPopGeos80Number C DECLARATION: extern word _far FloatPopGeos80Number(FloatNum *number) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Anna 3/92 Initial version ------------------------------------------------------------------------------@ FLOATPOPGEOS80NUMBER proc far number:fptr uses di, es .enter les di, number call FloatPopNumberFar mov ax, 0 ;assume no error jnc done mov ax, -1 done: .leave ret FLOATPOPGEOS80NUMBER endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatRound C DECLARATION: extern void _far FloatRound(numDecimalPlaces) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Jeremy 6/23/92 Initial version ------------------------------------------------------------------------------@ FLOATROUND proc far numDecimalPlaces:word .enter mov al, numDecimalPlaces.low call FloatRoundFar .leave ret FLOATROUND endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatStringGetDateNumber C DECLARATION: extern word _far FloatStringGetDateNumber(char *dateString) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Anna 3/92 Initial version ------------------------------------------------------------------------------@ FLOATSTRINGGETDATENUMBER proc far dateString:fptr uses di, es .enter les di, dateString call FloatStringGetDateNumber mov ax, 0 ;assume no error jnc done mov ax, -1 done: .leave ret FLOATSTRINGGETDATENUMBER endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatGeos80ToAscii_StdFormat C DECLARATION: extern word _far _pascal FloatGeos80ToAscii_StdFormat (char *string, FloatNum *number, FloatFloatToAsciiFormatFlags format, word numDigits, word numFractionalDigits) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- anna 4/22/92 Initial version ------------------------------------------------------------------------------@ FLOATGEOS80TOASCII_STDFORMAT proc far string:fptr, number:fptr, format:word, numDigits:word, numFractionalDigits:word uses es, ds, si, di .enter les di, string lds si, number mov ax, format mov bh, numDigits.low mov bl, numFractionalDigits.low call FloatFloatToAscii_StdFormat mov ax, cx ; put number of digits in ax .leave ret FLOATGEOS80TOASCII_STDFORMAT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatGeos80ToAscii C DECLARATION: extern word _far _pascal FloatGeos80ToAscii_StdFormat (FFA_stackFrame *stackFrame, char *resultString, FloatNum *number) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- anna 4/27/92 Initial version jeremy 11/10/93 Removed ax from the "uses" line. D'ohh! ------------------------------------------------------------------------------@ ; ; Exported as a placeholder for the old FLOATFLOATTOASCII ; global FLOATFLOATTOASCII_OLD:far FLOATFLOATTOASCII_OLD proc far FALL_THRU FLOATGEOS80TOASCII FLOATFLOATTOASCII_OLD endp FLOATGEOS80TOASCII proc far stackFrame:fptr, resultString:fptr, number:fptr uses es, ds, si, di .enter EC < mov ax, ss > EC < cmp ax, stackFrame.high > EC < ERROR_NE POINTER_SEGMENT_NOT_SAME_AS_STACK_FRAME > les di, resultString lds si, number push bp mov bp, stackFrame.low add bp, (size FFA_stackFrame) ; add size of variable call FloatFloatToAscii pop bp mov ax, cx ; put number of digits in ax .leave ret FLOATGEOS80TOASCII endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatFloatIEEE64ToAscii_StdFormat C DECLARATION: extern word _far _pascal FloatIEEE64ToAscii_StdFormat (char *string, IEEE64FloatNum number, FloatFloatToAsciiFormatFlags format, word numDigits, word numFractionalDigits) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 2/92 Initial version ------------------------------------------------------------------------------@ FLOATFLOATIEEE64TOASCII_STDFORMAT proc far string:fptr, number:IEEE64, format:word, numDigits:word, numFractionalDigits:word bigfloat local FloatNum uses ds, si, di .enter segmov ds, ss lea si, number ; ds:si <- IEEE64 number call FloatIEEE64ToGeos80Far ; puts a Geos80 float of FP stack lea di, bigfloat segmov es, ss call FloatEnter ; ds <- seg addr of fp stack call FloatPopNumber ; put Geos80 float in local variable call FloatOpDone ; unlock fp stack ; ; Added 9/99 CHR to properly set up ds:si with our Geos80 number! segmov ds, es mov si, di mov ax, ss:[string].segment mov es, ax mov ax, ss:[string].offset mov di, ax mov ax, ss:[numDigits] mov bx, ss:[numFractionalDigits] mov bh, al mov ax, ss:[format] call FloatFloatToAscii_StdFormat mov ax, cx ; put number of digits in ax .leave ret FLOATFLOATIEEE64TOASCII_STDFORMAT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatStringGetTimeNumber C DECLARATION: extern word _far FloatStringGetTimeNumber(char *timeString) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Anna 3/92 Initial version ------------------------------------------------------------------------------@ FLOATSTRINGGETTIMENUMBER proc far timeString:fptr uses di, es .enter les di, timeString call FloatStringGetTimeNumber mov ax, 0 ;assume no error jnc done mov ax, -1 done: .leave ret FLOATSTRINGGETTIMENUMBER endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatSetStackSize C DECLARATION: extern word _far FloatSetStackSize(int size) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATSETSTACKSIZE proc far stacksize:word .enter mov ax, stacksize call FloatSetStackSizeFar .leave ret FLOATSETSTACKSIZE endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatGeos80ToIEEE64 C DECLARATION: extern void _far FloatGeos80ToIEEE64(double *num) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: take top number of floating point stack and pops it into the num double pointer passed as a parameter REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATGEOS80TOIEEE64 proc far numPtr:fptr uses es, di .enter les di, numPtr call FloatGeos80ToIEEE64Far .leave ret FLOATGEOS80TOIEEE64 endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatGeos80ToIEEE32 C DECLARATION: extern void _far FloatGeos80ToIEEE32(float *num) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: take top number of floating point stack and pops it into the num float pointer passed as a parameter REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATGEOS80TOIEEE32 proc far numPtr:fptr uses es, di .enter call FloatGeos80ToIEEE32Far ; dx:ax = value les di, numPtr mov es:[di].low, ax mov es:[di].high, dx .leave ret FLOATGEOS80TOIEEE32 endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatIEEE32ToGeos80 C DECLARATION: extern void _far FloatIEEE32ToGeos80(float *num) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: take top number of floating point stack and pops it into the num double pointer passed as a parameter REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATIEEE32TOGEOS80 proc far numPtr:fptr uses es, di .enter les di, numPtr mov ax, es:[di].low mov dx, es:[di].high call FloatIEEE32ToGeos80Far .leave ret FLOATIEEE32TOGEOS80 endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatIEEE64ToGeos80 C DECLARATION: extern void _far FloatIEEE64ToGeos80(float *num) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: take top number of floating point stack and pops it into the num double pointer passed as a parameter REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATIEEE64TOGEOS80 proc far numPtr:fptr uses ds, si .enter lds si, numPtr call FloatIEEE64ToGeos80Far .leave ret FLOATIEEE64TOGEOS80 endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatWordToFloat C DECLARATION: extern void _far FloatWordToFloat(word num) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: convert the long number passed in to an 80 bit floating point number on the top of the stack REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATWORDTOFLOAT proc far num:word .enter mov ax, num call FloatWordToFloatFar .leave ret FLOATWORDTOFLOAT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatDwordToFloat C DECLARATION: extern void _far FloatDwordToFloat(long num) KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: convert the long number passed in to an 80 bit floating point number on the top of the stack REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATDWORDTOFLOAT proc far num:dword .enter mov dx, num.high mov ax, num.low call FloatDwordToFloatFar .leave ret FLOATDWORDTOFLOAT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatGetDaysInMonth C DECLARATION: extern word _far FloatGetDaysInMonth(word year, byte month); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: take top number of floating point stack and pops it into the num double pointer passed as a parameter REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATGETDAYSINMONTH proc far year:word, month:word ; actually byte .enter mov ax, year mov bx, month ; don't care about bh call FloatGetDaysInMonth clr ah mov al, bh ; ax = # of days in month .leave ret FLOATGETDAYSINMONTH endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatGetDateNumber C DECLARATION: extern FloatErrorType _far FloatGetDateNumber(word year, byte month, byte day); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: take top number of floating point stack and pops it into the num double pointer passed as a parameter REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATGETDATENUMBER proc far year:word, month:word, ; actually byte day:word ; actually byte .enter mov bl, {byte}month mov bh, {byte}day mov ax, year call FloatGetDateNumber .leave ret FLOATGETDATENUMBER endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatGetTimeNumber C DECLARATION: extern FloatErrorType _far FloatGetTimeNumber(byte hours, byte minutes, byte seconds); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATGETTIMENUMBER proc far hours:word, ; actually word minutes:word, ; actually byte seconds:word ; actually byte .enter mov ch, {byte}hours mov dl, {byte}minutes mov dh, {byte}seconds call FloatGetTimeNumber .leave ret FLOATGETTIMENUMBER endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatDateNumberGetMonthAndDay C DECLARATION: extern void _far FloatDateNumberGetMonthAndDay(byte *month, byte *day); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATDATENUMBERGETMONTHANDDAY proc far monthPtr:fptr, dayPtr:fptr uses es, di .enter call FloatDateNumberGetMonthAndDay les di, monthPtr mov {byte}es:[di], bl les di, dayPtr mov {byte}es:[di], bh .leave ret FLOATDATENUMBERGETMONTHANDDAY endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatSetStackPointer C DECLARATION: extern void _far FloatSetStackPointer(word newValue); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: Primarily for use by applications for error recovery. Applications can bail out of involved operations by saving the stack pointer prior to commencing operations and restoring the stack pointer in the event of an error. NOTE: ----- If you set the stack pointer, the current stack pointer must be less than or equal to the value you pass. Ie. you must be throwing something (or nothing) away. REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATSETSTACKPOINTER proc far newValue:word .enter mov ax, newValue call FloatSetStackPointer .leave ret FLOATSETSTACKPOINTER endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatRoll C DECLARATION: extern void _far FloatRoll(word N); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATROLL proc far num:word .enter mov bx, num call FloatRollFar .leave ret FLOATROLL endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatRollDown C DECLARATION: extern void _far FloatRollDown(word N); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATROLLDOWN proc far num:word .enter mov bx, num call FloatRollDownFar .leave ret FLOATROLLDOWN endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatPick C DECLARATION: extern void _far FloatPick(word N); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATPICK proc far num:word .enter mov bx, num call FloatPickFar .leave ret FLOATPICK endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatRandomize C DECLARATION: extern void _far FloatRandomize(RandomGenInitFlag randominitflag, dword seed); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jimmy 8/92 Initial version ------------------------------------------------------------------------------@ FLOATRANDOMIZE proc far initFlag:word, seed:dword .enter mov ax, initFlag mov cx, seed.high mov dx, seed.low call FloatRandomizeFar .leave ret FLOATRANDOMIZE endp COMMENT @---------------------------------------------------------------------- C FUNCTION: FloatFormatGeos80Number C DECLARATION: extern void Boolean _far _pascal FloatFormatGeos80Number (word formatToken, word userDefBlkHan, word userDefFileHan, void *floatNum, void *resultLocation); Pass VM block handle of array containing user defined formats in userDefBlkHan. If (userDefBlkHan == 0), userDefFileHan will not be used. KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Anna 3/92 Initial version ------------------------------------------------------------------------------@ FLOATFORMATGEOS80NUMBER proc far formatToken:word, userDefBlkHan:word, userDefFileHan:word, floatNum:fptr, resultLocation:fptr uses ds,di,si .enter lds si, floatNum les di, resultLocation mov ax, formatToken mov cx, userDefBlkHan mov bx, userDefFileHan call FloatFormatNumber mov ax, 0 ; Leave this as a mov, so the carry is left ; alone. jc done dec ax done: .leave ret FLOATFORMATGEOS80NUMBER endp C_Float ends SetDefaultConvention
extra/KovacsSTLCnorm.agda
andorp/plfa.github.io
1,003
16103
<gh_stars>1000+ {-# OPTIONS --without-K #-} open import Relation.Binary.PropositionalEquality open import Data.Product open import Data.Unit open import Data.Empty open import Function -- some HoTT-inspired combinators _&_ = cong _⁻¹ = sym _◾_ = trans coe : {A B : Set} → A ≡ B → A → B coe refl a = a _⊗_ : ∀ {A B : Set}{f g : A → B}{a a'} → f ≡ g → a ≡ a' → f a ≡ g a' refl ⊗ refl = refl infix 6 _⁻¹ infixr 4 _◾_ infixl 9 _&_ infixl 8 _⊗_ -- Syntax -------------------------------------------------------------------------------- infixr 4 _⇒_ infixr 4 _,_ data Ty : Set where ι : Ty _⇒_ : Ty → Ty → Ty data Con : Set where ∙ : Con _,_ : Con → Ty → Con data _∈_ (A : Ty) : Con → Set where vz : ∀ {Γ} → A ∈ (Γ , A) vs : ∀ {B Γ} → A ∈ Γ → A ∈ (Γ , B) data Tm Γ : Ty → Set where var : ∀ {A} → A ∈ Γ → Tm Γ A lam : ∀ {A B} → Tm (Γ , A) B → Tm Γ (A ⇒ B) app : ∀ {A B} → Tm Γ (A ⇒ B) → Tm Γ A → Tm Γ B -- Embedding -------------------------------------------------------------------------------- -- Order-preserving embedding data OPE : Con → Con → Set where ∙ : OPE ∙ ∙ drop : ∀ {A Γ Δ} → OPE Γ Δ → OPE (Γ , A) Δ keep : ∀ {A Γ Δ} → OPE Γ Δ → OPE (Γ , A) (Δ , A) -- OPE is a category idₑ : ∀ {Γ} → OPE Γ Γ idₑ {∙} = ∙ idₑ {Γ , A} = keep (idₑ {Γ}) wk : ∀ {A Γ} → OPE (Γ , A) Γ wk = drop idₑ _∘ₑ_ : ∀ {Γ Δ Σ} → OPE Δ Σ → OPE Γ Δ → OPE Γ Σ σ ∘ₑ ∙ = σ σ ∘ₑ drop δ = drop (σ ∘ₑ δ) drop σ ∘ₑ keep δ = drop (σ ∘ₑ δ) keep σ ∘ₑ keep δ = keep (σ ∘ₑ δ) idlₑ : ∀ {Γ Δ}(σ : OPE Γ Δ) → idₑ ∘ₑ σ ≡ σ idlₑ ∙ = refl idlₑ (drop σ) = drop & idlₑ σ idlₑ (keep σ) = keep & idlₑ σ idrₑ : ∀ {Γ Δ}(σ : OPE Γ Δ) → σ ∘ₑ idₑ ≡ σ idrₑ ∙ = refl idrₑ (drop σ) = drop & idrₑ σ idrₑ (keep σ) = keep & idrₑ σ assₑ : ∀ {Γ Δ Σ Ξ}(σ : OPE Σ Ξ)(δ : OPE Δ Σ)(ν : OPE Γ Δ) → (σ ∘ₑ δ) ∘ₑ ν ≡ σ ∘ₑ (δ ∘ₑ ν) assₑ σ δ ∙ = refl assₑ σ δ (drop ν) = drop & assₑ σ δ ν assₑ σ (drop δ) (keep ν) = drop & assₑ σ δ ν assₑ (drop σ) (keep δ) (keep ν) = drop & assₑ σ δ ν assₑ (keep σ) (keep δ) (keep ν) = keep & assₑ σ δ ν ∈ₑ : ∀ {A Γ Δ} → OPE Γ Δ → A ∈ Δ → A ∈ Γ ∈ₑ ∙ v = v ∈ₑ (drop σ) v = vs (∈ₑ σ v) ∈ₑ (keep σ) vz = vz ∈ₑ (keep σ) (vs v) = vs (∈ₑ σ v) ∈-idₑ : ∀ {A Γ}(v : A ∈ Γ) → ∈ₑ idₑ v ≡ v ∈-idₑ vz = refl ∈-idₑ (vs v) = vs & ∈-idₑ v ∈-∘ₑ : ∀ {A Γ Δ Σ}(σ : OPE Δ Σ)(δ : OPE Γ Δ)(v : A ∈ Σ) → ∈ₑ (σ ∘ₑ δ) v ≡ ∈ₑ δ (∈ₑ σ v) ∈-∘ₑ ∙ ∙ v = refl ∈-∘ₑ σ (drop δ) v = vs & ∈-∘ₑ σ δ v ∈-∘ₑ (drop σ) (keep δ) v = vs & ∈-∘ₑ σ δ v ∈-∘ₑ (keep σ) (keep δ) vz = refl ∈-∘ₑ (keep σ) (keep δ) (vs v) = vs & ∈-∘ₑ σ δ v Tmₑ : ∀ {A Γ Δ} → OPE Γ Δ → Tm Δ A → Tm Γ A Tmₑ σ (var v) = var (∈ₑ σ v) Tmₑ σ (lam t) = lam (Tmₑ (keep σ) t) Tmₑ σ (app f a) = app (Tmₑ σ f) (Tmₑ σ a) Tm-idₑ : ∀ {A Γ}(t : Tm Γ A) → Tmₑ idₑ t ≡ t Tm-idₑ (var v) = var & ∈-idₑ v Tm-idₑ (lam t) = lam & Tm-idₑ t Tm-idₑ (app f a) = app & Tm-idₑ f ⊗ Tm-idₑ a Tm-∘ₑ : ∀ {A Γ Δ Σ}(σ : OPE Δ Σ)(δ : OPE Γ Δ)(t : Tm Σ A) → Tmₑ (σ ∘ₑ δ) t ≡ Tmₑ δ (Tmₑ σ t) Tm-∘ₑ σ δ (var v) = var & ∈-∘ₑ σ δ v Tm-∘ₑ σ δ (lam t) = lam & Tm-∘ₑ (keep σ) (keep δ) t Tm-∘ₑ σ δ (app f a) = app & Tm-∘ₑ σ δ f ⊗ Tm-∘ₑ σ δ a -- Theory of substitution & embedding -------------------------------------------------------------------------------- infixr 6 _ₑ∘ₛ_ _ₛ∘ₑ_ _∘ₛ_ data Sub (Γ : Con) : Con → Set where ∙ : Sub Γ ∙ _,_ : ∀ {A : Ty}{Δ : Con} → Sub Γ Δ → Tm Γ A → Sub Γ (Δ , A) _ₛ∘ₑ_ : ∀ {Γ Δ Σ} → Sub Δ Σ → OPE Γ Δ → Sub Γ Σ ∙ ₛ∘ₑ δ = ∙ (σ , t) ₛ∘ₑ δ = σ ₛ∘ₑ δ , Tmₑ δ t _ₑ∘ₛ_ : ∀ {Γ Δ Σ} → OPE Δ Σ → Sub Γ Δ → Sub Γ Σ ∙ ₑ∘ₛ δ = δ drop σ ₑ∘ₛ (δ , t) = σ ₑ∘ₛ δ keep σ ₑ∘ₛ (δ , t) = σ ₑ∘ₛ δ , t dropₛ : ∀ {A Γ Δ} → Sub Γ Δ → Sub (Γ , A) Δ dropₛ σ = σ ₛ∘ₑ wk keepₛ : ∀ {A Γ Δ} → Sub Γ Δ → Sub (Γ , A) (Δ , A) keepₛ σ = dropₛ σ , var vz ⌜_⌝ᵒᵖᵉ : ∀ {Γ Δ} → OPE Γ Δ → Sub Γ Δ ⌜ ∙ ⌝ᵒᵖᵉ = ∙ ⌜ drop σ ⌝ᵒᵖᵉ = dropₛ ⌜ σ ⌝ᵒᵖᵉ ⌜ keep σ ⌝ᵒᵖᵉ = keepₛ ⌜ σ ⌝ᵒᵖᵉ ∈ₛ : ∀ {A Γ Δ} → Sub Γ Δ → A ∈ Δ → Tm Γ A ∈ₛ (σ , t) vz = t ∈ₛ (σ , t)(vs v) = ∈ₛ σ v Tmₛ : ∀ {A Γ Δ} → Sub Γ Δ → Tm Δ A → Tm Γ A Tmₛ σ (var v) = ∈ₛ σ v Tmₛ σ (lam t) = lam (Tmₛ (keepₛ σ) t) Tmₛ σ (app f a) = app (Tmₛ σ f) (Tmₛ σ a) idₛ : ∀ {Γ} → Sub Γ Γ idₛ {∙} = ∙ idₛ {Γ , A} = (idₛ {Γ} ₛ∘ₑ drop idₑ) , var vz _∘ₛ_ : ∀ {Γ Δ Σ} → Sub Δ Σ → Sub Γ Δ → Sub Γ Σ ∙ ∘ₛ δ = ∙ (σ , t) ∘ₛ δ = σ ∘ₛ δ , Tmₛ δ t assₛₑₑ : ∀ {Γ Δ Σ Ξ}(σ : Sub Σ Ξ)(δ : OPE Δ Σ)(ν : OPE Γ Δ) → (σ ₛ∘ₑ δ) ₛ∘ₑ ν ≡ σ ₛ∘ₑ (δ ∘ₑ ν) assₛₑₑ ∙ δ ν = refl assₛₑₑ (σ , t) δ ν = _,_ & assₛₑₑ σ δ ν ⊗ (Tm-∘ₑ δ ν t ⁻¹) assₑₛₑ : ∀ {Γ Δ Σ Ξ}(σ : OPE Σ Ξ)(δ : Sub Δ Σ)(ν : OPE Γ Δ) → (σ ₑ∘ₛ δ) ₛ∘ₑ ν ≡ σ ₑ∘ₛ (δ ₛ∘ₑ ν) assₑₛₑ ∙ δ ν = refl assₑₛₑ (drop σ) (δ , t) ν = assₑₛₑ σ δ ν assₑₛₑ (keep σ) (δ , t) ν = (_, Tmₑ ν t) & assₑₛₑ σ δ ν idlₑₛ : ∀ {Γ Δ}(σ : Sub Γ Δ) → idₑ ₑ∘ₛ σ ≡ σ idlₑₛ ∙ = refl idlₑₛ (σ , t) = (_, t) & idlₑₛ σ idlₛₑ : ∀ {Γ Δ}(σ : OPE Γ Δ) → idₛ ₛ∘ₑ σ ≡ ⌜ σ ⌝ᵒᵖᵉ idlₛₑ ∙ = refl idlₛₑ (drop σ) = ((idₛ ₛ∘ₑ_) ∘ drop) & idrₑ σ ⁻¹ ◾ assₛₑₑ idₛ σ wk ⁻¹ ◾ dropₛ & idlₛₑ σ idlₛₑ (keep σ) = (_, var vz) & (assₛₑₑ idₛ wk (keep σ) ◾ ((idₛ ₛ∘ₑ_) ∘ drop) & (idlₑ σ ◾ idrₑ σ ⁻¹) ◾ assₛₑₑ idₛ σ wk ⁻¹ ◾ (_ₛ∘ₑ wk) & idlₛₑ σ ) idrₑₛ : ∀ {Γ Δ}(σ : OPE Γ Δ) → σ ₑ∘ₛ idₛ ≡ ⌜ σ ⌝ᵒᵖᵉ idrₑₛ ∙ = refl idrₑₛ (drop σ) = assₑₛₑ σ idₛ wk ⁻¹ ◾ dropₛ & idrₑₛ σ idrₑₛ (keep σ) = (_, var vz) & (assₑₛₑ σ idₛ wk ⁻¹ ◾ (_ₛ∘ₑ wk) & idrₑₛ σ) ∈-ₑ∘ₛ : ∀ {A Γ Δ Σ}(σ : OPE Δ Σ)(δ : Sub Γ Δ)(v : A ∈ Σ) → ∈ₛ (σ ₑ∘ₛ δ) v ≡ ∈ₛ δ (∈ₑ σ v) ∈-ₑ∘ₛ ∙ δ v = refl ∈-ₑ∘ₛ (drop σ) (δ , t) v = ∈-ₑ∘ₛ σ δ v ∈-ₑ∘ₛ (keep σ) (δ , t) vz = refl ∈-ₑ∘ₛ (keep σ) (δ , t) (vs v) = ∈-ₑ∘ₛ σ δ v Tm-ₑ∘ₛ : ∀ {A Γ Δ Σ}(σ : OPE Δ Σ)(δ : Sub Γ Δ)(t : Tm Σ A) → Tmₛ (σ ₑ∘ₛ δ) t ≡ Tmₛ δ (Tmₑ σ t) Tm-ₑ∘ₛ σ δ (var v) = ∈-ₑ∘ₛ σ δ v Tm-ₑ∘ₛ σ δ (lam t) = lam & ((λ x → Tmₛ (x , var vz) t) & assₑₛₑ σ δ wk ◾ Tm-ₑ∘ₛ (keep σ) (keepₛ δ) t) Tm-ₑ∘ₛ σ δ (app f a) = app & Tm-ₑ∘ₛ σ δ f ⊗ Tm-ₑ∘ₛ σ δ a ∈-ₛ∘ₑ : ∀ {A Γ Δ Σ}(σ : Sub Δ Σ)(δ : OPE Γ Δ)(v : A ∈ Σ) → ∈ₛ (σ ₛ∘ₑ δ) v ≡ Tmₑ δ (∈ₛ σ v) ∈-ₛ∘ₑ (σ , _) δ vz = refl ∈-ₛ∘ₑ (σ , _) δ (vs v) = ∈-ₛ∘ₑ σ δ v Tm-ₛ∘ₑ : ∀ {A Γ Δ Σ}(σ : Sub Δ Σ)(δ : OPE Γ Δ)(t : Tm Σ A) → Tmₛ (σ ₛ∘ₑ δ) t ≡ Tmₑ δ (Tmₛ σ t) Tm-ₛ∘ₑ σ δ (var v) = ∈-ₛ∘ₑ σ δ v Tm-ₛ∘ₑ σ δ (lam t) = lam & ((λ x → Tmₛ (x , var vz) t) & (assₛₑₑ σ δ wk ◾ (σ ₛ∘ₑ_) & (drop & (idrₑ δ ◾ idlₑ δ ⁻¹)) ◾ assₛₑₑ σ wk (keep δ) ⁻¹) ◾ Tm-ₛ∘ₑ (keepₛ σ) (keep δ) t) Tm-ₛ∘ₑ σ δ (app f a) = app & Tm-ₛ∘ₑ σ δ f ⊗ Tm-ₛ∘ₑ σ δ a assₛₑₛ : ∀ {Γ Δ Σ Ξ}(σ : Sub Σ Ξ)(δ : OPE Δ Σ)(ν : Sub Γ Δ) → (σ ₛ∘ₑ δ) ∘ₛ ν ≡ σ ∘ₛ (δ ₑ∘ₛ ν) assₛₑₛ ∙ δ ν = refl assₛₑₛ (σ , t) δ ν = _,_ & assₛₑₛ σ δ ν ⊗ (Tm-ₑ∘ₛ δ ν t ⁻¹) assₛₛₑ : ∀ {Γ Δ Σ Ξ}(σ : Sub Σ Ξ)(δ : Sub Δ Σ)(ν : OPE Γ Δ) → (σ ∘ₛ δ) ₛ∘ₑ ν ≡ σ ∘ₛ (δ ₛ∘ₑ ν) assₛₛₑ ∙ δ ν = refl assₛₛₑ (σ , t) δ ν = _,_ & assₛₛₑ σ δ ν ⊗ (Tm-ₛ∘ₑ δ ν t ⁻¹) ∈-idₛ : ∀ {A Γ}(v : A ∈ Γ) → ∈ₛ idₛ v ≡ var v ∈-idₛ vz = refl ∈-idₛ (vs v) = ∈-ₛ∘ₑ idₛ wk v ◾ Tmₑ wk & ∈-idₛ v ◾ (var ∘ vs) & ∈-idₑ v ∈-∘ₛ : ∀ {A Γ Δ Σ}(σ : Sub Δ Σ)(δ : Sub Γ Δ)(v : A ∈ Σ) → ∈ₛ (σ ∘ₛ δ) v ≡ Tmₛ δ (∈ₛ σ v) ∈-∘ₛ (σ , _) δ vz = refl ∈-∘ₛ (σ , _) δ (vs v) = ∈-∘ₛ σ δ v Tm-idₛ : ∀ {A Γ}(t : Tm Γ A) → Tmₛ idₛ t ≡ t Tm-idₛ (var v) = ∈-idₛ v Tm-idₛ (lam t) = lam & Tm-idₛ t Tm-idₛ (app f a) = app & Tm-idₛ f ⊗ Tm-idₛ a Tm-∘ₛ : ∀ {A Γ Δ Σ}(σ : Sub Δ Σ)(δ : Sub Γ Δ)(t : Tm Σ A) → Tmₛ (σ ∘ₛ δ) t ≡ Tmₛ δ (Tmₛ σ t) Tm-∘ₛ σ δ (var v) = ∈-∘ₛ σ δ v Tm-∘ₛ σ δ (lam t) = lam & ((λ x → Tmₛ (x , var vz) t) & (assₛₛₑ σ δ wk ◾ (σ ∘ₛ_) & (idlₑₛ (dropₛ δ) ⁻¹) ◾ assₛₑₛ σ wk (keepₛ δ) ⁻¹) ◾ Tm-∘ₛ (keepₛ σ) (keepₛ δ) t) Tm-∘ₛ σ δ (app f a) = app & Tm-∘ₛ σ δ f ⊗ Tm-∘ₛ σ δ a idrₛ : ∀ {Γ Δ}(σ : Sub Γ Δ) → σ ∘ₛ idₛ ≡ σ idrₛ ∙ = refl idrₛ (σ , t) = _,_ & idrₛ σ ⊗ Tm-idₛ t idlₛ : ∀ {Γ Δ}(σ : Sub Γ Δ) → idₛ ∘ₛ σ ≡ σ idlₛ ∙ = refl idlₛ (σ , t) = (_, t) & (assₛₑₛ idₛ wk (σ , t) ◾ (idₛ ∘ₛ_) & idlₑₛ σ ◾ idlₛ σ) -- Reduction -------------------------------------------------------------------------------- data _~>_ {Γ} : ∀ {A} → Tm Γ A → Tm Γ A → Set where β : ∀ {A B}(t : Tm (Γ , A) B) t' → app (lam t) t' ~> Tmₛ (idₛ , t') t lam : ∀ {A B}{t t' : Tm (Γ , A) B} → t ~> t' → lam t ~> lam t' app₁ : ∀ {A B}{f}{f' : Tm Γ (A ⇒ B)}{a} → f ~> f' → app f a ~> app f' a app₂ : ∀ {A B}{f : Tm Γ (A ⇒ B)} {a a'} → a ~> a' → app f a ~> app f a' infix 3 _~>_ ~>ₛ : ∀ {Γ Δ A}{t t' : Tm Γ A}(σ : Sub Δ Γ) → t ~> t' → Tmₛ σ t ~> Tmₛ σ t' ~>ₛ σ (β t t') = coe ((app (lam (Tmₛ (keepₛ σ) t)) (Tmₛ σ t') ~>_) & (Tm-∘ₛ (keepₛ σ) (idₛ , Tmₛ σ t') t ⁻¹ ◾ (λ x → Tmₛ (x , Tmₛ σ t') t) & (assₛₑₛ σ wk (idₛ , Tmₛ σ t') ◾ ((σ ∘ₛ_) & idlₑₛ idₛ ◾ idrₛ σ) ◾ idlₛ σ ⁻¹) ◾ Tm-∘ₛ (idₛ , t') σ t)) (β (Tmₛ (keepₛ σ) t) (Tmₛ σ t')) ~>ₛ σ (lam step) = lam (~>ₛ (keepₛ σ) step) ~>ₛ σ (app₁ step) = app₁ (~>ₛ σ step) ~>ₛ σ (app₂ step) = app₂ (~>ₛ σ step) ~>ₑ : ∀ {Γ Δ A}{t t' : Tm Γ A}(σ : OPE Δ Γ) → t ~> t' → Tmₑ σ t ~> Tmₑ σ t' ~>ₑ σ (β t t') = coe ((app (lam (Tmₑ (keep σ) t)) (Tmₑ σ t') ~>_) & (Tm-ₑ∘ₛ (keep σ) (idₛ , Tmₑ σ t') t ⁻¹ ◾ (λ x → Tmₛ (x , Tmₑ σ t') t) & (idrₑₛ σ ◾ idlₛₑ σ ⁻¹) ◾ Tm-ₛ∘ₑ (idₛ , t') σ t)) (β (Tmₑ (keep σ) t) (Tmₑ σ t')) ~>ₑ σ (lam step) = lam (~>ₑ (keep σ) step) ~>ₑ σ (app₁ step) = app₁ (~>ₑ σ step) ~>ₑ σ (app₂ step) = app₂ (~>ₑ σ step) Tmₑ~> : ∀ {Γ Δ A}{t : Tm Γ A}{σ : OPE Δ Γ}{t'} → Tmₑ σ t ~> t' → ∃ λ t'' → (t ~> t'') × (Tmₑ σ t'' ≡ t') Tmₑ~> {t = var x} () Tmₑ~> {t = lam t} (lam step) with Tmₑ~> step ... | t'' , (p , refl) = lam t'' , lam p , refl Tmₑ~> {t = app (var v) a} (app₁ ()) Tmₑ~> {t = app (var v) a} (app₂ step) with Tmₑ~> step ... | t'' , (p , refl) = app (var v) t'' , app₂ p , refl Tmₑ~> {t = app (lam f) a} {σ} (β _ _) = Tmₛ (idₛ , a) f , β _ _ , Tm-ₛ∘ₑ (idₛ , a) σ f ⁻¹ ◾ (λ x → Tmₛ (x , Tmₑ σ a) f) & (idlₛₑ σ ◾ idrₑₛ σ ⁻¹) ◾ Tm-ₑ∘ₛ (keep σ) (idₛ , Tmₑ σ a) f Tmₑ~> {t = app (lam f) a} (app₁ (lam step)) with Tmₑ~> step ... | t'' , (p , refl) = app (lam t'') a , app₁ (lam p) , refl Tmₑ~> {t = app (lam f) a} (app₂ step) with Tmₑ~> step ... | t'' , (p , refl) = app (lam f) t'' , app₂ p , refl Tmₑ~> {t = app (app f a) a'} (app₁ step) with Tmₑ~> step ... | t'' , (p , refl) = app t'' a' , app₁ p , refl Tmₑ~> {t = app (app f a) a''} (app₂ step) with Tmₑ~> step ... | t'' , (p , refl) = app (app f a) t'' , app₂ p , refl -- Strong normalization/neutrality definition -------------------------------------------------------------------------------- data SN {Γ A} (t : Tm Γ A) : Set where sn : (∀ {t'} → t ~> t' → SN t') → SN t SNₑ→ : ∀ {Γ Δ A}{t : Tm Γ A}(σ : OPE Δ Γ) → SN t → SN (Tmₑ σ t) SNₑ→ σ (sn s) = sn λ {t'} step → let (t'' , (p , q)) = Tmₑ~> step in coe (SN & q) (SNₑ→ σ (s p)) SNₑ← : ∀ {Γ Δ A}{t : Tm Γ A}(σ : OPE Δ Γ) → SN (Tmₑ σ t) → SN t SNₑ← σ (sn s) = sn λ step → SNₑ← σ (s (~>ₑ σ step)) SN-app₁ : ∀ {Γ A B}{f : Tm Γ (A ⇒ B)}{a} → SN (app f a) → SN f SN-app₁ (sn s) = sn λ f~>f' → SN-app₁ (s (app₁ f~>f')) neu : ∀ {Γ A} → Tm Γ A → Set neu (lam _) = ⊥ neu _ = ⊤ neuₑ : ∀ {Γ Δ A}(σ : OPE Δ Γ)(t : Tm Γ A) → neu t → neu (Tmₑ σ t) neuₑ σ (lam t) nt = nt neuₑ σ (var v) nt = tt neuₑ σ (app f a) nt = tt -- The actual proof, by Kripke logical predicate -------------------------------------------------------------------------------- Tmᴾ : ∀ {Γ A} → Tm Γ A → Set Tmᴾ {Γ}{ι} t = SN t Tmᴾ {Γ}{A ⇒ B} t = ∀ {Δ}(σ : OPE Δ Γ){a} → Tmᴾ a → Tmᴾ (app (Tmₑ σ t) a) data Subᴾ {Γ} : ∀ {Δ} → Sub Γ Δ → Set where ∙ : Subᴾ ∙ _,_ : ∀ {A Δ}{σ : Sub Γ Δ}{t : Tm Γ A}(σᴾ : Subᴾ σ)(tᴾ : Tmᴾ t) → Subᴾ (σ , t) Tmᴾₑ : ∀ {Γ Δ A}{t : Tm Γ A}(σ : OPE Δ Γ) → Tmᴾ t → Tmᴾ (Tmₑ σ t) Tmᴾₑ {A = ι} σ tᴾ = SNₑ→ σ tᴾ Tmᴾₑ {A = A ⇒ B}{t} σ tᴾ δ aᴾ rewrite Tm-∘ₑ σ δ t ⁻¹ = tᴾ (σ ∘ₑ δ) aᴾ Subᴾₑ : ∀ {Γ Δ Σ}{σ : Sub Δ Σ}(δ : OPE Γ Δ) → Subᴾ σ → Subᴾ (σ ₛ∘ₑ δ) Subᴾₑ σ ∙ = ∙ Subᴾₑ σ (δ , tᴾ) = Subᴾₑ σ δ , Tmᴾₑ σ tᴾ ~>ᴾ : ∀ {Γ A}{t t' : Tm Γ A} → t ~> t' → Tmᴾ t → Tmᴾ t' ~>ᴾ {A = ι} t~>t' (sn tˢⁿ) = tˢⁿ t~>t' ~>ᴾ {A = A ⇒ B} t~>t' tᴾ = λ σ aᴾ → ~>ᴾ (app₁ (~>ₑ σ t~>t')) (tᴾ σ aᴾ) mutual -- quote qᴾ : ∀ {Γ A}{t : Tm Γ A} → Tmᴾ t → SN t qᴾ {A = ι} tᴾ = tᴾ qᴾ {A = A ⇒ B} tᴾ = SNₑ← wk $ SN-app₁ (qᴾ $ tᴾ wk (uᴾ (var vz) (λ ()))) -- unquote uᴾ : ∀ {Γ A}(t : Tm Γ A){nt : neu t} → (∀ {t'} → t ~> t' → Tmᴾ t') → Tmᴾ t uᴾ {Γ} {A = ι} t f = sn f uᴾ {Γ} {A ⇒ B} t {nt} f {Δ} σ {a} aᴾ = uᴾ (app (Tmₑ σ t) a) (go (Tmₑ σ t) (neuₑ σ t nt) f' a aᴾ (qᴾ aᴾ)) where f' : ∀ {t'} → Tmₑ σ t ~> t' → Tmᴾ t' f' step δ aᴾ with Tmₑ~> step ... | t'' , step' , refl rewrite Tm-∘ₑ σ δ t'' ⁻¹ = f step' (σ ∘ₑ δ) aᴾ go : ∀ {Γ A B}(t : Tm Γ (A ⇒ B)) → neu t → (∀ {t'} → t ~> t' → Tmᴾ t') → ∀ a → Tmᴾ a → SN a → ∀ {t'} → app t a ~> t' → Tmᴾ t' go _ () _ _ _ _ (β _ _) go t nt f a aᴾ sna (app₁ {f' = f'} step) = coe ((λ x → Tmᴾ (app x a)) & Tm-idₑ f') (f step idₑ aᴾ) go t nt f a aᴾ (sn aˢⁿ) (app₂ {a' = a'} step) = uᴾ (app t a') (go t nt f a' (~>ᴾ step aᴾ) (aˢⁿ step)) fundThm-∈ : ∀ {Γ A}(v : A ∈ Γ) → ∀ {Δ}{σ : Sub Δ Γ} → Subᴾ σ → Tmᴾ (∈ₛ σ v) fundThm-∈ vz (σᴾ , tᴾ) = tᴾ fundThm-∈ (vs v) (σᴾ , tᴾ) = fundThm-∈ v σᴾ fundThm-lam : ∀ {Γ A B} (t : Tm (Γ , A) B) → SN t → (∀ {a} → Tmᴾ a → Tmᴾ (Tmₛ (idₛ , a) t)) → ∀ a → SN a → Tmᴾ a → Tmᴾ (app (lam t) a) fundThm-lam {Γ} t (sn tˢⁿ) hyp a (sn aˢⁿ) aᴾ = uᴾ (app (lam t) a) λ {(β _ _) → hyp aᴾ; (app₁ (lam {t' = t'} t~>t')) → fundThm-lam t' (tˢⁿ t~>t') (λ aᴾ → ~>ᴾ (~>ₛ _ t~>t') (hyp aᴾ)) a (sn aˢⁿ) aᴾ; (app₂ a~>a') → fundThm-lam t (sn tˢⁿ) hyp _ (aˢⁿ a~>a') (~>ᴾ a~>a' aᴾ)} fundThm : ∀ {Γ A}(t : Tm Γ A) → ∀ {Δ}{σ : Sub Δ Γ} → Subᴾ σ → Tmᴾ (Tmₛ σ t) fundThm (var v) σᴾ = fundThm-∈ v σᴾ fundThm (lam {A} t) {σ = σ} σᴾ δ {a} aᴾ rewrite Tm-ₛ∘ₑ (keepₛ σ) (keep δ) t ⁻¹ | assₛₑₑ σ (wk {A}) (keep δ) | idlₑ δ = fundThm-lam (Tmₛ (σ ₛ∘ₑ drop δ , var vz) t) (qᴾ (fundThm t (Subᴾₑ (drop δ) σᴾ , uᴾ (var vz) (λ ())))) (λ aᴾ → coe (Tmᴾ & sub-sub-lem) (fundThm t (Subᴾₑ δ σᴾ , aᴾ))) a (qᴾ aᴾ) aᴾ where sub-sub-lem : ∀ {a} → Tmₛ (σ ₛ∘ₑ δ , a) t ≡ Tmₛ (idₛ , a) (Tmₛ (σ ₛ∘ₑ drop δ , var vz) t) sub-sub-lem {a} = (λ x → Tmₛ (x , a) t) & (idrₛ (σ ₛ∘ₑ δ) ⁻¹ ◾ assₛₑₛ σ δ idₛ ◾ assₛₑₛ σ (drop δ) (idₛ , a) ⁻¹) ◾ Tm-∘ₛ (σ ₛ∘ₑ drop δ , var vz) (idₛ , a) t fundThm (app f a) {σ = σ} σᴾ rewrite Tm-idₑ (Tmₛ σ f) ⁻¹ = fundThm f σᴾ idₑ (fundThm a σᴾ) idₛᴾ : ∀ {Γ} → Subᴾ (idₛ {Γ}) idₛᴾ {∙} = ∙ idₛᴾ {Γ , A} = Subᴾₑ wk idₛᴾ , uᴾ (var vz) (λ ()) strongNorm : ∀ {Γ A}(t : Tm Γ A) → SN t strongNorm t = qᴾ (coe (Tmᴾ & Tm-idₛ t) (fundThm t idₛᴾ))
Objective-C/dis.asm
yuxiqian/assembly-inject
0
241069
(__TEXT,__text) section _main: 0000000100000f00 pushq %rbp 0000000100000f01 movq %rsp, %rbp 0000000100000f04 subq $0x20, %rsp 0000000100000f08 movl $0x0, -0x4(%rbp) 0000000100000f0f leaq 0x7a(%rip), %rdi 0000000100000f16 movb $0x0, %al 0000000100000f18 callq 0x100000f60 0000000100000f1d leaq 0x7e(%rip), %rdi 0000000100000f24 leaq -0x8(%rbp), %rsi 0000000100000f28 leaq -0xc(%rbp), %rdx 0000000100000f2c movl %eax, -0x14(%rbp) 0000000100000f2f movb $0x0, %al 0000000100000f31 callq 0x100000f66 0000000100000f36 movl -0x8(%rbp), %ecx 0000000100000f39 addl -0xc(%rbp), %ecx 0000000100000f3c movl %ecx, -0x10(%rbp) 0000000100000f3f movl -0x10(%rbp), %esi 0000000100000f42 leaq 0x5f(%rip), %rdi 0000000100000f49 movl %eax, -0x18(%rbp) 0000000100000f4c movb $0x0, %al 0000000100000f4e callq 0x100000f60 0000000100000f53 xorl %ecx, %ecx 0000000100000f55 movl %eax, -0x1c(%rbp) 0000000100000f58 movl %ecx, %eax 0000000100000f5a addq $0x20, %rsp 0000000100000f5e popq %rbp 0000000100000f5f retq
awa/src/awa-users-servlets.adb
Letractively/ada-awa
0
6296
<gh_stars>0 ----------------------------------------------------------------------- -- awa-users-servlets -- OpenID verification servlet for user authentication -- Copyright (C) 2011, 2012, 2013, 2014 <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.Beans.Objects; with Util.Beans.Objects.Records; with Util.Log.Loggers; with ASF.Servlets; with ASF.Sessions; with AWA.Users.Services; with AWA.Users.Modules; with AWA.Users.Principals; package body AWA.Users.Servlets is -- Name of the session attribute which holds the URI to redirect after authentication. REDIRECT_ATTRIBUTE : constant String := "awa-redirect"; -- Name of the request attribute that contains the URI to redirect after authentication. REDIRECT_PARAM : constant String := "redirect"; -- Name of the session attribute which holds information about the active authentication. OPENID_ASSOC_ATTRIBUTE : constant String := "openid-assoc"; -- The logger Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Security.Servlets"); -- Make a package to store the Association in the session. package Association_Bean is new Util.Beans.Objects.Records (Security.Auth.Association); subtype Association_Access is Association_Bean.Element_Type_Access; function Get_Provider_URL (Server : in Request_Auth_Servlet; Request : in ASF.Requests.Request'Class) return String; function Get_Provider_URL (Server : in Request_Auth_Servlet; Request : in ASF.Requests.Request'Class) return String is pragma Unreferenced (Server); URI : constant String := Request.Get_Path_Info; begin if URI'Length = 0 then return ""; end if; Log.Info ("OpenID authentication with {0}", URI); return URI (URI'First + 1 .. URI'Last); end Get_Provider_URL; -- ------------------------------ -- Proceed to the OpenID authentication with an OpenID provider. -- Find the OpenID provider URL and starts the discovery, association phases -- during which a private key is obtained from the OpenID provider. -- After OpenID discovery and association, the user will be redirected to -- the OpenID provider. -- ------------------------------ overriding procedure Do_Get (Server : in Request_Auth_Servlet; Request : in out ASF.Requests.Request'Class; Response : in out ASF.Responses.Response'Class) is Ctx : constant ASF.Servlets.Servlet_Registry_Access := Server.Get_Servlet_Context; Name : constant String := Get_Provider_URL (Server, Request); URL : constant String := Ctx.Get_Init_Parameter ("auth.url." & Name); begin Log.Info ("Request OpenId authentication to {0} - {1}", Name, URL); if Name'Length = 0 or URL'Length = 0 then Response.Set_Status (ASF.Responses.SC_NOT_FOUND); return; end if; declare Mgr : Security.Auth.Manager; OP : Security.Auth.End_Point; Bean : constant Util.Beans.Objects.Object := Association_Bean.Create; Assoc : constant Association_Access := Association_Bean.To_Element_Access (Bean); Redirect : constant String := Request.Get_Parameter (REDIRECT_PARAM); begin Server.Initialize (Name, Mgr); -- Yadis discovery (get the XRDS file). This step does nothing for OAuth. Mgr.Discover (URL, OP); -- Associate to the OpenID provider and get an end-point with a key. Mgr.Associate (OP, Assoc.all); -- Save the association in the HTTP session and -- redirect the user to the OpenID provider. declare Auth_URL : constant String := Mgr.Get_Authentication_URL (OP, Assoc.all); Session : ASF.Sessions.Session := Request.Get_Session (Create => True); begin Log.Info ("Redirect to auth URL: {0}", Auth_URL); Response.Send_Redirect (Location => Auth_URL); Session.Set_Attribute (Name => OPENID_ASSOC_ATTRIBUTE, Value => Bean); Session.Set_Attribute (Name => REDIRECT_ATTRIBUTE, Value => Util.Beans.Objects.To_Object (Redirect)); end; end; end Do_Get; -- ------------------------------ -- Create a principal object that correspond to the authenticated user identified -- by the <b>Auth</b> information. The principal will be attached to the session -- and will be destroyed when the session is closed. -- ------------------------------ overriding procedure Create_Principal (Server : in Verify_Auth_Servlet; Auth : in Security.Auth.Authentication; Result : out ASF.Principals.Principal_Access) is pragma Unreferenced (Server); use AWA.Users.Modules; use AWA.Users.Services; Manager : constant User_Service_Access := AWA.Users.Modules.Get_User_Manager; Principal : AWA.Users.Principals.Principal_Access; begin Manager.Authenticate (Auth => Auth, IpAddr => "", Principal => Principal); Result := Principal.all'Access; end Create_Principal; -- ------------------------------ -- Verify the authentication result that was returned by the OpenID provider. -- If the authentication succeeded and the signature was correct, sets a -- user principals on the session. -- ------------------------------ procedure Do_Get (Server : in Verify_Auth_Servlet; Request : in out ASF.Requests.Request'Class; Response : in out ASF.Responses.Response'Class) is use type Security.Auth.Auth_Result; type Auth_Params is new Security.Auth.Parameters with null record; overriding function Get_Parameter (Params : in Auth_Params; Name : in String) return String; overriding function Get_Parameter (Params : in Auth_Params; Name : in String) return String is pragma Unreferenced (Params); begin return Request.Get_Parameter (Name); end Get_Parameter; Session : ASF.Sessions.Session := Request.Get_Session (Create => False); Bean : Util.Beans.Objects.Object; Mgr : Security.Auth.Manager; Assoc : Association_Access; Credential : Security.Auth.Authentication; Params : Auth_Params; Ctx : constant ASF.Servlets.Servlet_Registry_Access := Server.Get_Servlet_Context; begin Log.Info ("Verify openid authentication"); if not Session.Is_Valid then Log.Warn ("Session has expired during OpenID authentication process"); Response.Set_Status (ASF.Responses.SC_FORBIDDEN); return; end if; Bean := Session.Get_Attribute (OPENID_ASSOC_ATTRIBUTE); -- Cleanup the session and drop the association end point. Session.Remove_Attribute (OPENID_ASSOC_ATTRIBUTE); if Util.Beans.Objects.Is_Null (Bean) then Log.Warn ("Verify openid request without active session"); Response.Set_Status (ASF.Responses.SC_FORBIDDEN); return; end if; Assoc := Association_Bean.To_Element_Access (Bean); Server.Initialize (Security.Auth.Get_Provider (Assoc.all), Mgr); -- Verify that what we receive through the callback matches the association key. Mgr.Verify (Assoc.all, Params, Credential); if Security.Auth.Get_Status (Credential) /= Security.Auth.AUTHENTICATED then Log.Info ("Authentication has failed"); Response.Set_Status (ASF.Responses.SC_FORBIDDEN); return; end if; Log.Info ("Authentication succeeded for {0}", Security.Auth.Get_Email (Credential)); -- Get a user principal and set it on the session. declare User : ASF.Principals.Principal_Access; Redirect : constant String := Util.Beans.Objects.To_String (Session.Get_Attribute (REDIRECT_ATTRIBUTE)); URL : constant String := Ctx.Get_Init_Parameter ("openid.success_url"); begin Verify_Auth_Servlet'Class (Server).Create_Principal (Credential, User); Session.Set_Principal (User); Session.Remove_Attribute (REDIRECT_ATTRIBUTE); if Redirect'Length > 0 then Log.Info ("Redirect user to saved redirect URL: {0}", Redirect); Response.Send_Redirect (Redirect); else Log.Info ("Redirect user to success URL: {0}", URL); Response.Send_Redirect (URL); end if; end; end Do_Get; end AWA.Users.Servlets;
Projetos/F-Assembly/src/nasm/abs.nasm
arthurolga/Z01-Ingenheiros
0
90426
; Arquivo: Abs.nasm ; Curso: Elementos de Sistemas ; Criado por: <NAME> ; Data: 27/03/2017 ; Copia o valor de RAM[1] para RAM[0] deixando o valor sempre positivo. leaw $R1,%A movw (%A),%D WHILE: negw %D leaw $WHILE, %A jl %D nop leaw $R0, %A movw %D, (%A)
ch10_3.asm
ChanJLee/easy-asm
0
160449
<gh_stars>0 assume cs:code stack segment db 'ABCDEFGH' stack ends code segment start: mov ax, stack mov ds, ax mov si, 0 mov cx, 8 call func mov ax, 4200h int 21h func: mov ax, [si] add ax, 32 mov [si], ax inc si loop func ret code ends end start
crt_zxn_init.asm
imneme/spectrum-minilib
1
81120
include "romdefs.inc" SECTION data_clib GLOBAL _zxn_window_channel _zxn_window_channel: defw 0 SECTION code_clib GLOBAL crt_zxn_init err_die: rst $08 db ERR_J_INVIO crt_zxn_init: ld de, IDE_MODE ld a,1 exx ld bc, $0102 exx ld c, 7 rst $08 db M_P3DOS jr nc, err_die exx ld (_zxn_window_channel), hl exx ret
oeis/054/A054431.asm
neoneye/loda-programs
11
102276
<filename>oeis/054/A054431.asm ; A054431: Array read by antidiagonals: T(x, y) tells whether (x, y) are coprime (1) or not (0). ; Submitted by <NAME> ; 1,1,1,1,0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,0,1,0,1,0,1,1,1,0,1,1,0,1,1,1,0,1,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,1,0,1,0,1,1,1,0,1,0,0,1,1,0 add $0,1 seq $0,300294 ; Irregular triangle giving the GCD characteristic: t(n, m) = 1 if gcd(n, m) = 1 and zero otherwise, with t(1, 1) = 1 and t(n, m) for n >= 2 and m = 1..(n-1).