max_stars_repo_path
stringlengths
4
261
max_stars_repo_name
stringlengths
6
106
max_stars_count
int64
0
38.8k
id
stringlengths
1
6
text
stringlengths
7
1.05M
src/cfg.agda
shinji-kono/automaton-in-agda
0
2292
<gh_stars>0 module cfg where open import Level renaming ( suc to succ ; zero to Zero ) open import Data.Nat hiding ( _≟_ ) open import Data.Fin open import Data.Product open import Data.List open import Data.Maybe open import Data.Bool using ( Bool ; true ; false ; _∧_ ; _∨_ ) open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Relation.Nullary using (¬_; Dec; yes; no) -- open import Data.String data IsTerm (Token : Set) : Set (succ Zero) where isTerm : Token → IsTerm Token noTerm : IsTerm Token record CFGGrammer (Token Node : Set) : Set (succ Zero) where field cfg : Node → List ( List ( Node ) ) cfgtop : Node term? : Node → IsTerm Token tokensz : ℕ tokenid : Token → Fin tokensz open CFGGrammer ----------------- -- -- CGF language -- ----------------- split : {Σ : Set} → (List Σ → Bool) → ( List Σ → Bool) → List Σ → Bool split x y [] = x [] ∧ y [] split x y (h ∷ t) = (x [] ∧ y (h ∷ t)) ∨ split (λ t1 → x ( h ∷ t1 )) (λ t2 → y t2 ) t cfg-language0 : {Node Token : Set} → CFGGrammer Token Node → List (List Node ) → List Token → Bool {-# TERMINATING #-} cfg-language2 : {Node Token : Set} → CFGGrammer Token Node → Node → List Token → Bool cfg-language2 cg _ [] = false cfg-language2 cg x (h1 ∷ [] ) with term? cg x cfg-language2 cg x (h1 ∷ []) | isTerm t with tokenid cg h1 ≟ tokenid cg t cfg-language2 cg x (h1 ∷ []) | isTerm t | yes p = true cfg-language2 cg x (h1 ∷ []) | isTerm t | no ¬p = false cfg-language2 cg x (h1 ∷ []) | noTerm = cfg-language0 cg (cfg cg x) ( h1 ∷ [] ) cfg-language2 cg x In with term? cg x cfg-language2 cg x In | isTerm t = false cfg-language2 cg x In | noTerm = cfg-language0 cg (cfg cg x ) In cfg-language1 : {Node Token : Set} → CFGGrammer Token Node → List Node → List Token → Bool cfg-language1 cg [] [] = true cfg-language1 cg [] _ = false cfg-language1 cg (node ∷ T) = split ( cfg-language2 cg node ) ( cfg-language1 cg T ) cfg-language0 cg [] [] = true cfg-language0 cg [] _ = false cfg-language0 cg (node ∷ T) In = cfg-language1 cg node In ∨ cfg-language0 cg T In cfg-language : {Node Token : Set} → CFGGrammer Token Node → List Token → Bool cfg-language cg = cfg-language0 cg (cfg cg (cfgtop cg)) ----------------- data IFToken : Set where t:EA : IFToken t:EB : IFToken t:EC : IFToken t:IF : IFToken t:THEN : IFToken t:ELSE : IFToken t:SA : IFToken t:SB : IFToken t:SC : IFToken IFtokenid : IFToken → Fin 9 IFtokenid t:EA = # 0 IFtokenid t:EB = # 1 IFtokenid t:EC = # 2 IFtokenid t:IF = # 3 IFtokenid t:THEN = # 4 IFtokenid t:ELSE = # 5 IFtokenid t:SA = # 6 IFtokenid t:SB = # 7 IFtokenid t:SC = # 8 data IFNode (T : Set) : Set where Token : T → IFNode T expr : IFNode T statement : IFNode T IFGrammer : CFGGrammer IFToken (IFNode IFToken) IFGrammer = record { cfg = cfg' ; cfgtop = statement ; term? = term?' ; tokensz = 9 ; tokenid = IFtokenid } where term?' : IFNode IFToken → IsTerm IFToken term?' (Token x) = isTerm x term?' _ = noTerm cfg' : IFNode IFToken → List ( List (IFNode IFToken) ) cfg' (Token t) = ( (Token t) ∷ [] ) ∷ [] cfg' expr = ( Token t:EA ∷ [] ) ∷ ( Token t:EB ∷ [] ) ∷ ( Token t:EC ∷ [] ) ∷ [] cfg' statement = ( Token t:SA ∷ [] ) ∷ ( Token t:SB ∷ [] ) ∷ ( Token t:SC ∷ [] ) ∷ ( Token t:IF ∷ expr ∷ statement ∷ [] ) ∷ ( Token t:IF ∷ expr ∷ statement ∷ Token t:ELSE ∷ statement ∷ [] ) ∷ [] cfgtest1 = cfg-language IFGrammer ( t:SA ∷ [] ) cfgtest2 = cfg-language2 IFGrammer (Token t:SA) ( t:SA ∷ [] ) cfgtest3 = cfg-language1 IFGrammer (Token t:SA ∷ [] ) ( t:SA ∷ [] ) cfgtest4 = cfg-language IFGrammer (t:IF ∷ t:EA ∷ t:SA ∷ [] ) cfgtest5 = cfg-language1 IFGrammer (Token t:IF ∷ expr ∷ statement ∷ []) (t:IF ∷ t:EA ∷ t:EA ∷ [] ) cfgtest6 = cfg-language2 IFGrammer statement (t:IF ∷ t:EA ∷ t:SA ∷ [] ) cfgtest7 = cfg-language1 IFGrammer (Token t:IF ∷ expr ∷ statement ∷ Token t:ELSE ∷ statement ∷ []) (t:IF ∷ t:EA ∷ t:SA ∷ t:ELSE ∷ t:SB ∷ [] ) cfgtest8 = cfg-language IFGrammer (t:IF ∷ t:EA ∷ t:IF ∷ t:EB ∷ t:SA ∷ t:ELSE ∷ t:SB ∷ [] )
oeis/072/A072762.asm
neoneye/loda-programs
11
12270
<reponame>neoneye/loda-programs ; A072762: n coded as binary word of length=n with k-th bit set iff k is prime (1<=k<=n), decimal value. ; Submitted by <NAME>(s2) ; 0,1,3,6,13,26,53,106,212,424,849,1698,3397,6794,13588,27176,54353,108706,217413,434826,869652,1739304,3478609,6957218,13914436,27828872,55657744,111315488,222630977,445261954,890523909,1781047818,3562095636,7124191272,14248382544,28496765088,56993530177,113987060354,227974120708,455948241416,911896482833,1823792965666,3647585931333,7295171862666,14590343725332,29180687450664,58361374901329,116722749802658,233445499605316,466890999210632,933781998421264,1867563996842528,3735127993685057 mov $2,$0 mov $4,$0 lpb $4 mov $0,$2 sub $4,1 sub $0,$4 seq $0,10051 ; Characteristic function of primes: 1 if n is prime, else 0. mul $3,2 add $3,$0 lpe mov $0,$3
Userland/asm/interrupts.asm
lipusal/tpe_arqui
0
27530
<filename>Userland/asm/interrupts.asm GLOBAL _int20 GLOBAL _int21 GLOBAL _int80 _int20: int 0x20 _int21: int 0x21 _int80: int 0x80 ret
programs/oeis/108/A108568.asm
jmorken/loda
1
23951
<gh_stars>1-10 ; A108568: a(n) = prime(n) + prime(n+1) - 2n - 1. ; 2,3,5,9,13,17,21,25,33,39,45,53,57,61,69,79,85,91,99,103,109,117,125,137,147,151,155,159,163,179,195,203,209,219,229,235,245,253,261,271,277,287,297,301,305,317,339,353,357,361,369,375,385,399,409,419,425 mov $1,$0 mul $1,2 mov $4,4 mov $6,$0 cmp $6,0 cal $0,92949 ; Numbers of the form prime(n+1) + prime(n) + 1. add $1,3 mov $3,1 sub $4,$0 add $0,8 mul $0,2 add $1,1 mul $1,2 mov $2,2 add $3,$1 mov $1,1 mov $4,1 sub $4,$3 add $0,$4 add $0,7099 add $1,$3 sub $1,2 mov $1,$0 sub $1,7119 div $1,2 add $1,2 mov $2,2 mul $2,$3 pow $2,2 add $2,5 mov $4,1 mov $5,3 mov $5,$3 mov $3,$0 mov $5,0
intellij/src/paidia/Paidia.g4
jakobehmsen/midmod
0
2281
grammar Paidia; block: selector | (blockPart*); blockPart: expression; expression: assignment | ifExpression | logicalOrExpression; assignment: ID EQUALS expression; ifExpression: KW_IF condition=expression KW_THEN trueExpression=expression KW_ELSE falseExpression=expression; logicalOrExpression: lhs=logicalAndExpression logicalOrExpressionOp*; logicalOrExpressionOp: OR_OP logicalAndExpression; logicalAndExpression: lhs=equalityExpression logicalAndExpressionOp*; logicalAndExpressionOp: AND_OP equalityExpression; equalityExpression: lhs=relationalExpression equalityExpressionOp*; equalityExpressionOp: EQ_OP relationalExpression; relationalExpression: lhs=addExpression relationalExpressionOp*; relationalExpressionOp: REL_OP addExpression; addExpression: lhs=mulExpression addExpressionOp*; addExpressionOp: ADD_OP mulExpression; mulExpression: lhs=raiseExpression mulExpressionOp*; mulExpressionOp: MUL_OP raiseExpression; raiseExpression: lhs=chainedExpression raiseExpressionOp*; raiseExpressionOp: RAISE_OP chainedExpression; chainedExpression: atomExpression; atomExpression: string | number | identifier | parameter | classLiteral | embeddedExpression; string: STRING; number: NUMBER; identifier: ID; parameter: QUESTION_MARK; classLiteral: '{' '}'; embeddedExpression: '(' embeddedExpressionContent? ')'; embeddedExpressionContent: selector | expression; selector: binaryOperator | KW_IF; binaryOperator: OR_OP | AND_OP | EQ_OP | REL_OP | ADD_OP | MUL_OP | RAISE_OP; KW_IF: 'if'; KW_THEN: 'then'; KW_ELSE: 'else'; KW_VAR: 'var'; EQUALS: '='; fragment DIGIT: [0-9]; fragment LETTER: [A-Z]|[a-z]; OR_OP: '||'; AND_OP: '&&'; EQ_OP: '==' | '!='; REL_OP: '<'|'>'|'<='|'>='; ADD_OP: '+'|'-'; MUL_OP: '*'|'/'; RAISE_OP: '^'; QUESTION_MARK: '?'; SELECTOR : '\'' ~['\\]* '\''; ID: (LETTER | '_') (LETTER | '_' | DIGIT)*; STRING : '"' (ESC | ~["\\])* '"' ; fragment ESC : '\\' (["\\/bfnrt] | UNICODE) ; fragment UNICODE : 'u' HEX HEX HEX HEX ; fragment HEX : [0-9a-fA-F] ; NUMBER : '-'? INT '.' [0-9]+ EXP? // 1.35, 1.35E-9, 0.3, -4.5 | '-'? INT EXP // 1e10 -3e4 | '-'? INT // -3, 45 ; fragment INT : '0' | [1-9] [0-9]* ; // no leading zeros fragment EXP : [Ee] [+\-]? INT ; // \- since - means "range" inside [...] WS : [ \t\n\r]+ -> skip ; SINGLE_LINE_COMMENT: '//' ~('\r' | '\n')* -> skip; MULTI_LINE_COMMENT: '/*' .*? '*/' -> skip;
test/Fail/RewriteRuleUnboundVars.agda
cruhland/agda
1,989
13809
<gh_stars>1000+ {-# OPTIONS --rewriting #-} open import Common.Prelude open import Common.Equality {-# BUILTIN REWRITE _≡_ #-} postulate f : Bool → Bool boolTrivial : ∀ (b c : Bool) → f b ≡ c {-# REWRITE boolTrivial #-} -- Should trigger an error that c is not bound on the lhs.
src/Types/Tail1.agda
peterthiemann/dual-session
1
2421
<gh_stars>1-10 module Types.Tail1 where open import Data.Fin open import Data.Nat open import Function using (_∘_) open import Types.Direction import Types.IND1 as IND private variable n : ℕ -- session types restricted to tail recursion -- can be recognized by type of TChan constructor data Type : Set data SType (n : ℕ) : Set data GType (n : ℕ) : Set data Type where TUnit TInt : Type TPair : (t₁ t₂ : Type) → Type TChan : (s : IND.SType 0) → Type data SType n where gdd : (g : GType n) → SType n rec : (g : GType (suc n)) → SType n var : (x : Fin n) → SType n data GType n where transmit : (d : Dir) (t : Type) (s : SType n) → GType n choice : (d : Dir) (m : ℕ) (alt : Fin m → SType n) → GType n end : GType n -- naive definition of duality for tail recursive session types -- message types are ignored as they are closed dualS : SType n → SType n dualG : GType n → GType n dualS (gdd g) = gdd (dualG g) dualS (rec g) = rec (dualG g) dualS (var x) = var x dualG (transmit d t s) = transmit (dual-dir d) t (dualS s) dualG (choice d m alt) = choice (dual-dir d) m (dualS ∘ alt) dualG end = end
tools/xml2ayacc/encoding/encodings-classes.adb
faelys/gela-asis
4
11294
<reponame>faelys/gela-asis -------------------------------------------------------- -- E n c o d i n g s -- -- -- -- Tools for convertion strings between Unicode and -- -- national/vendor character sets. -- -- - - - - - - - - - -- -- Read copyright and license at the end of this file -- -------------------------------------------------------- package body Encodings.Classes is function Get_Class (Object : in Coder; C : in Wide_Character) return Character_Class; pragma Inline (Get_Class); ------------ -- Decode -- ------------ procedure Decode (Text : in Raw_String; Text_Last : out Natural; Result : out Wide_String; Result_Last : out Natural; Classes : out Character_Classes; Object : in out Coder) is Index : Cache_Index; X : Positive; begin Decode (Text, Text_Last, Result, Result_Last, Object.Map); if Object.Map = UTF_8 then for J in Result'First .. Result_Last loop Index := Wide_Character'Pos (Result (J)) mod Cache_Index'Last + 1; if Object.Wide (Index) = Result (J) and Object.Cache (Index) /= Unknown then Classes (J) := Object.Cache (Index); else Classes (J) := Get_Class (Object, Result (J)); Object.Cache (Index) := Classes (J); Object.Wide (Index) := Result (J); if Classes (J) = Unknown then Object.Prefix := Result (J); else Object.Prefix := ' '; end if; end if; end loop; else X := Result'First; for J in Text'First .. Text_Last loop if Object.Classes (Text (J)) /= Unknown then Classes (X) := Object.Classes (Text (J)); else Classes (X) := Get_Class (Object, Result (X)); Object.Classes (Text (J)) := Classes (X); if Classes (X) = Unknown then Object.Prefix := Result (X); else Object.Prefix := ' '; end if; end if; X := X + 1; end loop; end if; end Decode; --------------- -- Get_Class -- --------------- function Get_Class (Object : in Coder; C : in Wide_Character) return Character_Class is begin if Object.Prefix = ' ' then return Get_Class ((1 => C)); else return Get_Class (Object.Prefix & C); end if; end Get_Class; end Encodings.Classes; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, <NAME> -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * Neither the name of the <NAME>, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------
3-mid/opengl/source/lean/model/opengl-model-sphere.adb
charlie5/lace-alire
1
544
package body openGL.Model.sphere is --------- --- Forge -- procedure define (Self : out Item; Radius : Real) is begin Self.Radius := Radius; end define; -------------- --- Attributes -- overriding function Bounds (Self : in Item) return openGL.Bounds is begin return (Ball => Self.Radius, Box => (Lower => (-Self.Radius, -Self.Radius, -Self.Radius), Upper => ( Self.Radius, Self.Radius, Self.Radius))); end Bounds; end openGL.Model.sphere;
OldBasicILP/UntypedSyntax/ClosedHilbertSequential.agda
mietek/hilbert-gentzen
29
15842
<reponame>mietek/hilbert-gentzen -- Hilbert-style formalisation of closed syntax. -- Sequences of terms. module OldBasicILP.UntypedSyntax.ClosedHilbertSequential where open import OldBasicILP.UntypedSyntax.Common public -- Closed, untyped representations. data Rep : ℕ → Set where NIL : Rep zero MP : ∀ {n} → Fin n → Fin n → Rep n → Rep (suc n) CI : ∀ {n} → Rep n → Rep (suc n) CK : ∀ {n} → Rep n → Rep (suc n) CS : ∀ {n} → Rep n → Rep (suc n) NEC : ∀ {n} → ∀ {`n} → Rep (suc `n) → Rep n → Rep (suc n) CDIST : ∀ {n} → Rep n → Rep (suc n) CUP : ∀ {n} → Rep n → Rep (suc n) CDOWN : ∀ {n} → Rep n → Rep (suc n) CPAIR : ∀ {n} → Rep n → Rep (suc n) CFST : ∀ {n} → Rep n → Rep (suc n) CSND : ∀ {n} → Rep n → Rep (suc n) UNIT : ∀ {n} → Rep n → Rep (suc n) -- Anti-bug wrappers. record Proof : Set where constructor [_] field {len} : ℕ rep : Rep (suc len) open ClosedSyntax (Proof) public -- Concatenation of representations. _⧺ᴿ_ : ∀ {n₁ n₂} → Rep n₁ → Rep n₂ → Rep (n₁ + n₂) r₁ ⧺ᴿ NIL = r₁ r₁ ⧺ᴿ MP i j r₂ = MP (monoFin weak≤+₂ i) (monoFin weak≤+₂ j) (r₁ ⧺ᴿ r₂) r₁ ⧺ᴿ CI r₂ = CI (r₁ ⧺ᴿ r₂) r₁ ⧺ᴿ CK r₂ = CK (r₁ ⧺ᴿ r₂) r₁ ⧺ᴿ CS r₂ = CS (r₁ ⧺ᴿ r₂) r₁ ⧺ᴿ NEC `r r₂ = NEC `r (r₁ ⧺ᴿ r₂) r₁ ⧺ᴿ CDIST r₂ = CDIST (r₁ ⧺ᴿ r₂) r₁ ⧺ᴿ CUP r₂ = CUP (r₁ ⧺ᴿ r₂) r₁ ⧺ᴿ CDOWN r₂ = CDOWN (r₁ ⧺ᴿ r₂) r₁ ⧺ᴿ CPAIR r₂ = CPAIR (r₁ ⧺ᴿ r₂) r₁ ⧺ᴿ CFST r₂ = CFST (r₁ ⧺ᴿ r₂) r₁ ⧺ᴿ CSND r₂ = CSND (r₁ ⧺ᴿ r₂) r₁ ⧺ᴿ UNIT r₂ = UNIT (r₁ ⧺ᴿ r₂) -- Modus ponens and necessitation in nested form. APP : ∀ {n₁ n₂} → Rep (suc n₁) → Rep (suc n₂) → Rep (suc (suc n₂ + suc n₁)) APP {n₁} {n₂} r₁ r₂ = MP zero (monoFin (weak≤+₁ (suc n₁)) zero) (r₂ ⧺ᴿ r₁) BOX : ∀ {n} → Rep (suc n) → Rep (suc zero) BOX {n} r = NEC r NIL -- Derivations. mutual infix 3 ⊢ᴰ_ data ⊢ᴰ_ : Cx Ty → Set where nil : ⊢ᴰ ∅ mp : ∀ {Ξ A B} → A ▻ B ∈ Ξ → A ∈ Ξ → ⊢ᴰ Ξ → ⊢ᴰ Ξ , B ci : ∀ {Ξ A} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ▻ A ck : ∀ {Ξ A B} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ▻ B ▻ A cs : ∀ {Ξ A B C} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C nec : ∀ {Ξ A} → ∀ {`Ξ} → (d : ⊢ᴰ `Ξ , A) → ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ ᴿ⌊ d ⌋ ] ⦂ A cdist : ∀ {Ξ A B} → ∀ {n₁ n₂} → {r₁ : Rep (suc n₁)} → {r₂ : Rep (suc n₂)} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ r₁ ] ⦂ (A ▻ B) ▻ [ r₂ ] ⦂ A ▻ [ APP r₁ r₂ ] ⦂ B cup : ∀ {Ξ A} → ∀ {n} → {r : Rep (suc n)} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ r ] ⦂ A ▻ [ BOX r ] ⦂ [ r ] ⦂ A cdown : ∀ {Ξ A} → ∀ {n} → {r : Rep (suc n)} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , [ r ] ⦂ A ▻ A cpair : ∀ {Ξ A B} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ▻ B ▻ A ∧ B cfst : ∀ {Ξ A B} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ∧ B ▻ A csnd : ∀ {Ξ A B} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , A ∧ B ▻ B unit : ∀ {Ξ} → ⊢ᴰ Ξ → ⊢ᴰ Ξ , ⊤ -- Projection from derivations to representations. ᴿ⌊_⌋ : ∀ {Ξ} → ⊢ᴰ Ξ → Rep ᴺ⌊ Ξ ⌋ ᴿ⌊ nil ⌋ = NIL ᴿ⌊ mp i j d ⌋ = MP ⁱ⌊ i ⌋ ⁱ⌊ j ⌋ ᴿ⌊ d ⌋ ᴿ⌊ ci d ⌋ = CI ᴿ⌊ d ⌋ ᴿ⌊ ck d ⌋ = CK ᴿ⌊ d ⌋ ᴿ⌊ cs d ⌋ = CS ᴿ⌊ d ⌋ ᴿ⌊ nec `d d ⌋ = NEC ᴿ⌊ `d ⌋ ᴿ⌊ d ⌋ ᴿ⌊ cdist d ⌋ = CDIST ᴿ⌊ d ⌋ ᴿ⌊ cup d ⌋ = CUP ᴿ⌊ d ⌋ ᴿ⌊ cdown d ⌋ = CDOWN ᴿ⌊ d ⌋ ᴿ⌊ cpair d ⌋ = CPAIR ᴿ⌊ d ⌋ ᴿ⌊ cfst d ⌋ = CFST ᴿ⌊ d ⌋ ᴿ⌊ csnd d ⌋ = CSND ᴿ⌊ d ⌋ ᴿ⌊ unit d ⌋ = UNIT ᴿ⌊ d ⌋ -- Anti-bug wrappers. infix 3 ⊢_ ⊢_ : Ty → Set ⊢ A = ∃ (λ Ξ → ⊢ᴰ Ξ , A) -- Concatenation of derivations. _⧺ᴰ_ : ∀ {Ξ₁ Ξ₂} → ⊢ᴰ Ξ₁ → ⊢ᴰ Ξ₂ → ⊢ᴰ Ξ₁ ⧺ Ξ₂ d₁ ⧺ᴰ nil = d₁ d₁ ⧺ᴰ mp i j d₂ = mp (mono∈ weak⊆⧺₂ i) (mono∈ weak⊆⧺₂ j) (d₁ ⧺ᴰ d₂) d₁ ⧺ᴰ ci d₂ = ci (d₁ ⧺ᴰ d₂) d₁ ⧺ᴰ ck d₂ = ck (d₁ ⧺ᴰ d₂) d₁ ⧺ᴰ cs d₂ = cs (d₁ ⧺ᴰ d₂) d₁ ⧺ᴰ nec `d d₂ = nec `d (d₁ ⧺ᴰ d₂) d₁ ⧺ᴰ cdist d₂ = cdist (d₁ ⧺ᴰ d₂) d₁ ⧺ᴰ cup d₂ = cup (d₁ ⧺ᴰ d₂) d₁ ⧺ᴰ cdown d₂ = cdown (d₁ ⧺ᴰ d₂) d₁ ⧺ᴰ cpair d₂ = cpair (d₁ ⧺ᴰ d₂) d₁ ⧺ᴰ cfst d₂ = cfst (d₁ ⧺ᴰ d₂) d₁ ⧺ᴰ csnd d₂ = csnd (d₁ ⧺ᴰ d₂) d₁ ⧺ᴰ unit d₂ = unit (d₁ ⧺ᴰ d₂) -- Modus ponens and necessitation in nested form. app : ∀ {A B} → ⊢ A ▻ B → ⊢ A → ⊢ B app {A} {B} (Ξ₁ , d₁) (Ξ₂ , d₂) = Ξ₃ , d₃ where Ξ₃ = (Ξ₂ , A) ⧺ (Ξ₁ , A ▻ B) d₃ = mp top (mono∈ (weak⊆⧺₁ (Ξ₁ , A ▻ B)) top) (d₂ ⧺ᴰ d₁) box : ∀ {A} → (t : ⊢ A) → ⊢ [ ᴿ⌊ π₂ t ⌋ ] ⦂ A box (Ξ , d) = ∅ , nec d nil
programs/oeis/073/A073555.asm
neoneye/loda
22
98835
<reponame>neoneye/loda<filename>programs/oeis/073/A073555.asm<gh_stars>10-100 ; A073555: Number of Fibonacci numbers F(k), k <= 10^n, which end in 8. ; 1,8,68,668,6668,66668,666668,6666668,66666668,666666668,6666666668,66666666668,666666666668,6666666666668,66666666666668,666666666666668,6666666666666668,66666666666666668,666666666666666668,6666666666666666668,66666666666666666668,666666666666666666668,6666666666666666666668,66666666666666666666668 lpb $0 mov $1,$0 mov $0,0 seq $1,73553 ; Number of Fibonacci numbers F(k), k <= 10^n, which end in 5. lpe div $1,2 add $1,1 mov $0,$1
test/Fail/Issue3292b.agda
cruhland/agda
1,989
5246
<filename>test/Fail/Issue3292b.agda module _ where open import Agda.Builtin.Equality open import Agda.Builtin.Nat module Vars (A : Set) where variable x : A -- Was -- An internal error has occurred. Please report this as a bug. -- Location of the error: src/full/Agda/TypeChecking/Reduce/Fast.hs:148 -- Should be -- Cannot use generalized variable from let-opened module record R : Set₁ where field A : Set open Vars A field f : x ≡ x
test/zero.asm
kspalaiologos/asmbf
67
81992
out .0
src/gen/gstreamer-gst_low_level-gstreamer_0_10_gst_pbutils_pbutils_enumtypes_h.ads
persan/A-gst
1
18244
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with glib; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_pbutils_pbutils_enumtypes_h is -- unsupported macro: GST_TYPE_INSTALL_PLUGINS_RETURN (gst_install_plugins_return_get_type()) -- unsupported macro: GST_TYPE_DISCOVERER_RESULT (gst_discoverer_result_get_type()) -- enumerations from "install-plugins.h" function gst_install_plugins_return_get_type return GLIB.GType; -- gst/pbutils/pbutils-enumtypes.h:12 pragma Import (C, gst_install_plugins_return_get_type, "gst_install_plugins_return_get_type"); -- enumerations from "gstdiscoverer.h" function gst_discoverer_result_get_type return GLIB.GType; -- gst/pbutils/pbutils-enumtypes.h:16 pragma Import (C, gst_discoverer_result_get_type, "gst_discoverer_result_get_type"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_pbutils_pbutils_enumtypes_h;
oeis/010/A010971.asm
neoneye/loda-programs
11
95044
<reponame>neoneye/loda-programs ; A010971: a(n) = binomial(n,18). ; 1,19,190,1330,7315,33649,134596,480700,1562275,4686825,13123110,34597290,86493225,206253075,471435600,1037158320,2203961430,4537567650,9075135300,17672631900,33578000610,62359143990,113380261800,202112640600,353697121050,608359048206,1029530696964,1715884494940,2818953098830,4568648125690,7309837001104,11554258485616,18053528883775,27900908274925,42671977361650,64617565719070,96926348578605,144079707346575,212327989773900,310325523515700,449972009097765,647520696018735,925029565741050 add $0,18 bin $0,18
regtests/expect/ada/concat.adb
stcarrez/resource-embedder
7
28701
<gh_stars>1-10 -- Advanced Resource Embedder 1.2.0 with Interfaces; use Interfaces; package body Concat is function Hash (S : String) return Natural; P : constant array (0 .. 0) of Natural := (0 .. 0 => 1); T1 : constant array (0 .. 0) of Unsigned_8 := (0 .. 0 => 0); T2 : constant array (0 .. 0) of Unsigned_8 := (0 .. 0 => 1); G : constant array (0 .. 4) of Unsigned_8 := (0, 1, 0, 0, 0); function Hash (S : String) return Natural is F : constant Natural := S'First - 1; L : constant Natural := S'Length; F1, F2 : Natural := 0; J : Natural; begin for K in P'Range loop exit when L < P (K); J := Character'Pos (S (P (K) + F)); F1 := (F1 + Natural (T1 (K)) * J) mod 5; F2 := (F2 + Natural (T2 (K)) * J) mod 5; end loop; return (Natural (G (F1)) + Natural (G (F2))) mod 2; end Hash; C_0 : aliased constant Ada.Streams.Stream_Element_Array := (98, 111, 100, 121, 32, 123, 10, 32, 32, 32, 32, 98, 97, 99, 107, 103, 114, 111, 117, 110, 100, 58, 32, 35, 101, 101, 101, 59, 32, 32, 10, 125, 10, 112, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 97, 50, 97, 50, 97, 59, 32, 32, 10, 125, 98, 111, 100, 121, 32, 123, 10, 32, 32, 32, 32, 98, 97, 99, 107, 103, 114, 111, 117, 110, 100, 58, 32, 35, 101, 101, 101, 59, 32, 32, 10, 125, 10, 112, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 97, 50, 97, 50, 97, 59, 32, 32, 10, 125, 10, 112, 114, 101, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 52, 97, 52, 97, 52, 97, 59, 32, 32, 10, 125, 10, 98, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 48, 97, 48, 97, 48, 97, 59, 32, 32, 10, 125, 10, 100, 105, 118, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 48, 50, 48, 50, 48, 59, 32, 32, 10, 125, 10, 98, 111, 100, 121, 32, 123, 10, 32, 32, 32, 32, 98, 97, 99, 107, 103, 114, 111, 117, 110, 100, 58, 32, 35, 101, 101, 101, 59, 32, 32, 10, 125, 10, 112, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 97, 50, 97, 50, 97, 59, 32, 32, 10, 125, 10, 112, 114, 101, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 52, 97, 52, 97, 52, 97, 59, 32, 32, 10, 125, 10, 98, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 48, 97, 48, 97, 48, 97, 59, 32, 32, 10, 125, 10, 100, 105, 118, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 48, 50, 48, 50, 48, 59, 32, 32, 10, 125, 10, 98, 111, 100, 121, 32, 123, 10, 32, 32, 32, 32, 98, 97, 99, 107, 103, 114, 111, 117, 110, 100, 58, 32, 35, 101, 101, 101, 59, 32, 32, 10, 125, 10, 112, 32, 123, 10, 32, 32, 32, 32, 99, 111, 108, 111, 114, 58, 32, 35, 50, 97, 50, 97, 50, 97, 59, 32, 32, 10, 125); C_1 : aliased constant Ada.Streams.Stream_Element_Array := (118, 97, 114, 32, 101, 108, 101, 99, 32, 61, 32, 123, 10, 32, 32, 32, 32, 101, 49, 50, 58, 32, 91, 32, 49, 46, 48, 44, 32, 49, 46, 50, 44, 32, 49, 46, 53, 44, 32, 49, 46, 56, 44, 32, 50, 46, 50, 44, 32, 50, 46, 55, 44, 32, 51, 46, 51, 44, 32, 51, 46, 57, 44, 32, 52, 46, 55, 44, 32, 53, 46, 54, 44, 32, 54, 46, 56, 44, 32, 56, 46, 50, 32, 93, 10, 125, 10, 118, 97, 114, 32, 101, 108, 101, 99, 32, 61, 32, 123, 10, 32, 32, 32, 32, 101, 49, 50, 58, 32, 91, 32, 49, 46, 48, 44, 32, 49, 46, 50, 44, 32, 49, 46, 53, 44, 32, 49, 46, 56, 44, 32, 50, 46, 50, 44, 32, 50, 46, 55, 44, 32, 51, 46, 51, 44, 32, 51, 46, 57, 44, 32, 52, 46, 55, 44, 32, 53, 46, 54, 44, 32, 54, 46, 56, 44, 32, 56, 46, 50, 32, 93, 10, 125, 10, 118, 97, 114, 32, 101, 108, 101, 99, 32, 61, 32, 123, 10, 32, 32, 32, 32, 101, 49, 50, 58, 32, 91, 32, 49, 46, 48, 44, 32, 49, 46, 50, 44, 32, 49, 46, 53, 44, 32, 49, 46, 56, 44, 32, 50, 46, 50, 44, 32, 50, 46, 55, 44, 32, 51, 46, 51, 44, 32, 51, 46, 57, 44, 32, 52, 46, 55, 44, 32, 53, 46, 54, 44, 32, 54, 46, 56, 44, 32, 56, 46, 50, 32, 93, 10, 125, 10, 118, 97, 114, 32, 101, 108, 101, 99, 32, 61, 32, 123, 10, 32, 32, 32, 32, 101, 49, 50, 58, 32, 91, 32, 49, 46, 48, 44, 32, 49, 46, 50, 44, 32, 49, 46, 53, 44, 32, 49, 46, 56, 44, 32, 50, 46, 50, 44, 32, 50, 46, 55, 44, 32, 51, 46, 51, 44, 32, 51, 46, 57, 44, 32, 52, 46, 55, 44, 32, 53, 46, 54, 44, 32, 54, 46, 56, 44, 32, 56, 46, 50, 32, 93, 10, 125, 10); type Name_Access is access constant String; type Name_Array is array (Natural range <>) of Name_Access; K_0 : aliased constant String := "css/css/main.css"; K_1 : aliased constant String := "js/js/main.js"; Names : constant Name_Array := ( K_0'Access, K_1'Access); type Content_List_Array is array (Natural range <>) of Content_Access; Contents : constant Content_List_Array := ( C_0'Access, C_1'Access); function Get_Content (Name : String) return Content_Access is H : constant Natural := Hash (Name); begin return (if Names (H).all = Name then Contents (H) else null); end Get_Content; end Concat;
src/ado-sequences.adb
My-Colaborations/ada-ado
0
23477
----------------------------------------------------------------------- -- ADO Sequences -- Database sequence generator -- Copyright (C) 2009, 2010, 2011, 2012 <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.Log; with Util.Log.Loggers; with Util.Strings; with ADO.Sessions.Factory; with Ada.Unchecked_Deallocation; package body ADO.Sequences is use Util.Log; use Sequence_Maps; Log : constant Loggers.Logger := Loggers.Create ("ADO.Sequences"); procedure Free is new Ada.Unchecked_Deallocation (Object => ADO.Sequences.Sequence_Generator, Name => ADO.Sequences.Sequence_Generator_Access); procedure Free is new Ada.Unchecked_Deallocation (Object => Generator'Class, Name => Generator_Access); -- ------------------------------ -- Get the name of the sequence. -- ------------------------------ function Get_Sequence_Name (Gen : in Generator'Class) return String is begin return To_String (Gen.Name); end Get_Sequence_Name; -- ------------------------------ -- Get a session to connect to the database. -- ------------------------------ function Get_Session (Gen : in Generator) return ADO.Sessions.Master_Session'Class is begin return Gen.Factory.Get_Master_Session; end Get_Session; protected body Sequence_Generator is -- ------------------------------ -- Allocate a unique identifier for the given sequence. -- ------------------------------ procedure Allocate (Id : in out Objects.Object_Record'Class) is begin Generator.Allocate (Id); end Allocate; procedure Set_Generator (Name : in Unbounded_String; Gen : in Generator_Access) is begin Gen.Name := Name; Generator := Gen; end Set_Generator; procedure Clear is begin Free (Generator); end Clear; end Sequence_Generator; -- ------------------------------ -- Allocate a unique identifier for the given table. -- ------------------------------ procedure Allocate (Manager : in out Factory; Id : in out ADO.Objects.Object_Record'Class) is Gen : Sequence_Generator_Access; Name : constant Util.Strings.Name_Access := Id.Get_Table_Name; begin Manager.Map.Get_Generator (To_Unbounded_String (Name.all), Gen); Gen.Allocate (Id); end Allocate; -- ------------------------------ -- Set a generator to be used for the given sequence. -- ------------------------------ procedure Set_Generator (Manager : in out Factory; Name : in String; Gen : in Generator_Access) is N : constant Unbounded_String := To_Unbounded_String (Name); G : constant Sequence_Generator_Access := new Sequence_Generator; begin G.Set_Generator (N, Gen); Manager.Map.Set_Generator (N, G); end Set_Generator; -- ------------------------------ -- Set the default factory for creating generators. -- The default factory is the HiLo generator. -- ------------------------------ procedure Set_Default_Generator (Manager : in out Factory; Factory : in Generator_Factory; Sess_Factory : in Session_Factory_Access) is begin Manager.Map.Set_Default_Generator (Factory, Sess_Factory); end Set_Default_Generator; -- The sequence factory map is also accessed through a protected type. protected body Factory_Map is -- ------------------------------ -- Get the sequence generator associated with the name. -- If there is no such generator, an entry is created by using -- the default generator. -- ------------------------------ procedure Get_Generator (Name : in Unbounded_String; Gen : out Sequence_Generator_Access) is Pos : constant Cursor := Find (Map, Name); begin if not Has_Element (Pos) then Log.Info ("Creating sequence generator for {0}", To_String (Name)); Gen := new Sequence_Generator; Gen.Set_Generator (Name, Create_Generator.all (Sess_Factory)); Insert (Map, Name, Gen); else Gen := Element (Pos); end if; end Get_Generator; -- ------------------------------ -- Set the sequence generator associated with the name. -- ------------------------------ procedure Set_Generator (Name : in Unbounded_String; Gen : in Sequence_Generator_Access) is Pos : constant Cursor := Find (Map, Name); begin Log.Info ("Setting sequence generator for {0}", To_String (Name)); if not Has_Element (Pos) then Insert (Map, Name, Gen); else declare Node : Sequence_Generator_Access := Element (Pos); begin Node.Clear; Free (Node); end; Replace_Element (Map, Pos, Gen); end if; end Set_Generator; -- ------------------------------ -- Set the default sequence generator. -- ------------------------------ procedure Set_Default_Generator (Gen : in Generator_Factory; Factory : in Session_Factory_Access) is begin Create_Generator := Gen; Sess_Factory := Factory; end Set_Default_Generator; -- ------------------------------ -- Clear the factory map. -- ------------------------------ procedure Clear is begin Log.Info ("Clearing the sequence factory"); loop declare Pos : Cursor := Map.First; Node : Sequence_Generator_Access; begin exit when not Has_Element (Pos); Node := Element (Pos); Map.Delete (Pos); Node.all.Clear; Free (Node); end; end loop; end Clear; end Factory_Map; procedure Finalize (Manager : in out Factory) is begin Manager.Map.Clear; end Finalize; end ADO.Sequences;
Transynther/x86/_processed/NC/_zr_/i3-7100_9_0x84_notsx.log_136_2416.asm
ljhsiun2/medusa
9
165240
<filename>Transynther/x86/_processed/NC/_zr_/i3-7100_9_0x84_notsx.log_136_2416.asm<gh_stars>1-10 .global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r14 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_D_ht+0x1e6db, %rcx nop sub $35953, %rax mov $0x6162636465666768, %r11 movq %r11, (%rcx) nop nop nop nop nop xor %r11, %r11 lea addresses_normal_ht+0x11a3b, %rsi lea addresses_A_ht+0x17e8e, %rdi clflush (%rsi) add $3451, %r10 mov $70, %rcx rep movsb add $28247, %rcx lea addresses_D_ht+0x16bdb, %rdi nop nop sub %r14, %r14 mov $0x6162636465666768, %r10 movq %r10, (%rdi) nop nop nop xor $59703, %r11 lea addresses_UC_ht+0x178db, %rdi nop nop add %r14, %r14 movw $0x6162, (%rdi) nop nop nop nop dec %rcx lea addresses_WT_ht+0x124db, %rsi lea addresses_WC_ht+0x120db, %rdi nop add %rbp, %rbp mov $99, %rcx rep movsw nop nop nop nop add $46631, %r10 lea addresses_normal_ht+0x7d0b, %rdi nop lfence movl $0x61626364, (%rdi) nop add $63566, %r11 pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r14 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r8 push %r9 push %rbp push %rcx push %rdi push %rsi // Load lea addresses_WT+0x1fc5b, %rbp nop nop nop and $30372, %r8 mov (%rbp), %r9 sub %r10, %r10 // REPMOV lea addresses_WT+0xa13b, %rsi lea addresses_RW+0x17edb, %rdi nop nop nop nop nop xor %rbp, %rbp mov $32, %rcx rep movsw nop nop nop xor %r8, %r8 // Faulty Load mov $0x3f146c0000000adb, %r13 nop and %rdi, %rdi mov (%r13), %cx lea oracles, %r12 and $0xff, %rcx shlq $12, %rcx mov (%r12,%rcx,1), %rcx pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r8 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_NC', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT', 'same': False, 'size': 8, 'congruent': 7, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_RW', 'congruent': 10, 'same': False}, 'OP': 'REPM'} [Faulty Load] {'src': {'type': 'addresses_NC', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 10, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 2, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'00': 136} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
tests/inputs/test_single_inst/test_sub_one_inst/sub_single.asm
danielstumpp/tomasulo-simulator
0
241511
sub, R3, R1, R2
programs/oeis/024/A024215.asm
jmorken/loda
1
96324
<gh_stars>1-10 ; A024215: Sum of squares of first n positive integers congruent to 1 mod 3. ; 1,17,66,166,335,591,952,1436,2061,2845,3806,4962,6331,7931,9780,11896,14297,17001,20026,23390,27111,31207,35696,40596,45925,51701,57942,64666,71891,79635,87916,96752,106161,116161,126770,138006,149887,162431,175656,189580,204221,219597,235726,252626,270315,288811,308132,328296,349321,371225,394026,417742,442391,467991,494560,522116,550677,580261,610886,642570,675331,709187,744156,780256,817505,855921,895522,936326,978351,1021615,1066136,1111932,1159021,1207421,1257150,1308226,1360667,1414491,1469716,1526360,1584441,1643977,1704986,1767486,1831495,1897031,1964112,2032756,2102981,2174805,2248246,2323322,2400051,2478451,2558540,2640336,2723857,2809121,2896146,2984950,3075551,3167967,3262216,3358316,3456285,3556141,3657902,3761586,3867211,3974795,4084356,4195912,4309481,4425081,4542730,4662446,4784247,4908151,5034176,5162340,5292661,5425157,5559846,5696746,5835875,5977251,6120892,6266816,6415041,6565585,6718466,6873702,7031311,7191311,7353720,7518556,7685837,7855581,8027806,8202530,8379771,8559547,8741876,8926776,9114265,9304361,9497082,9692446,9890471,10091175,10294576,10500692,10709541,10921141,11135510,11352666,11572627,11795411,12021036,12249520,12480881,12715137,12952306,13192406,13435455,13681471,13930472,14182476,14437501,14695565,14956686,15220882,15488171,15758571,16032100,16308776,16588617,16871641,17157866,17447310,17739991,18035927,18335136,18637636,18943445,19252581,19565062,19880906,20200131,20522755,20848796,21178272,21511201,21847601,22187490,22530886,22877807,23228271,23582296,23939900,24301101,24665917,25034366,25406466,25782235,26161691,26544852,26931736,27322361,27716745,28114906,28516862,28922631,29332231,29745680,30162996,30584197,31009301,31438326,31871290,32308211,32749107,33193996,33642896,34095825,34552801,35013842,35478966,35948191,36421535,36899016,37380652,37866461,38356461,38850670,39349106,39851787,40358731,40869956,41385480,41905321,42429497,42958026,43490926,44028215,44569911,45116032,45666596,46221621,46781125 mov $3,$0 lpb $3 mov $2,2 add $4,2 add $2,$4 pow $2,2 add $1,$2 sub $3,1 add $4,1 lpe add $1,1
agda/examples-that-run/fizzbuzz/src-agda/fizzbuzz.agda
haroldcarr/learn-haskell-coq-ml-etc
36
741
<reponame>haroldcarr/learn-haskell-coq-ml-etc module fizzbuzz where import Data.Nat as N import Data.Nat.DivMod as N import Data.Nat.Show as N import Data.Bool as B import Data.Fin as F import Data.Unit as U import Data.String as S open import Data.Product using (_,_ ; _×_) open import IO open import Agda.Builtin.Coinduction open import Relation.Nullary open import Function congruent : N.ℕ → N.ℕ → B.Bool congruent n N.zero = B.false congruent n (N.suc m) with N._≟_ 0 $ F.toℕ (N._mod_ n (N.suc m) {U.tt}) ... | yes _ = B.true ... | no _ = B.false _and_ : {A B : Set} → A → B → A × B _and_ = _,_ fizzbuzz : N.ℕ → S.String fizzbuzz N.zero = "fizzbuzz" fizzbuzz n with congruent n 3 and congruent n 5 ... | B.true , B.true = "fizzbuzz" ... | B.true , B.false = "fizz" ... | B.false , B.true = "buzz" ... | B.false , B.false = N.show n worker : N.ℕ → IO U.⊤ worker N.zero = putStrLn $ fizzbuzz N.zero worker (N.suc n) = ♯ worker n >> ♯ putStrLn (fizzbuzz $ N.suc n) main = run $ worker 100
src/unittests/unittest_grow.asm
lawrimon/SnakeV
2
17009
.data .include "../global_constants.asm" .text #initialization la s4,snake #Vector of snake li t0,3 #inital size of snake sw t0,0(s4) #store size li t0, 0x0014000F #first element of the snake sw t0, 4(s4) li t0, 0x0015000F #second element of the snake sw t0, 8(s4) li t0, 0x0016000F #third element of the snake sw t0, 12(s4) jal draw_snake li s0, 0x00000061 # Value of a li s1, 0x00000064 # Value of d li s2, 0x00000073 # Value of s li s3, 0x00000077 # Value of w li a0,0x0017000F #dummy address of fruit addi s9,a0,0 #load coordinate to s9 jal convert_coord li a3, 0xFFFFFF jal draw_point jal turn_right lw t0, 0(s4) #snake size li t1, 4 bne t0,t1,error_test #snake size successfully increased to 4 li a0, 5 #if program finishes with code 5 the unittest was successfully li a7,93 ecall error_test: li a0, 10 #if program finishes with code 10 the unittest was error li a7,93 ecall game_start: field_init: # labels are needed for inclusion of ui_controller.asm, but won't affect the outcome of this unittest .include "../draw_functions/draw_pixel.asm" .include "../draw_functions/draw_point.asm" .include "../draw_functions/draw_snake.asm" .include "../game_logic/turn.asm" .include "../game_logic/convert_coord.asm" .include "../game_logic/grow_snake.asm" .include "../game_logic/verification.asm" .include "../game_logic/selfverification.asm" .include "../game_logic/fruit.asm" .include "../game_logic/keyboard.asm" .include "../user_interface/ui_controller.asm"
src/settings.asm
fcard/AllStatTabs
2
27952
!Chr_0 = "\0" !Chr_9 = "\t" !Chr_10 = "\n" !Chr_11 = "\v" !Chr_12 = "\f" !Chr_28 = "\e" !Chr_32 = " " !Chr_33 = "!" !Chr_35 = "#" !Chr_36 = "$" !Chr_37 = "%" !Chr_38 = "&" !Chr_39 = "'" !Chr_40 = "(" !Chr_41 = ")" !Chr_42 = "*" !Chr_43 = "+" !Chr_44 = "," !Chr_45 = "-" !Chr_46 = "." !Chr_47 = "/" !Chr_48 = "0" !Chr_49 = "1" !Chr_50 = "2" !Chr_51 = "3" !Chr_52 = "4" !Chr_53 = "5" !Chr_54 = "6" !Chr_55 = "7" !Chr_56 = "8" !Chr_57 = "9" !Chr_58 = ":" !Chr_59 = ";" !Chr_60 = "<" !Chr_61 = "=" !Chr_62 = ">" !Chr_63 = "?" !Chr_64 = "@" !Chr_65 = "A" !Chr_66 = "B" !Chr_67 = "C" !Chr_68 = "D" !Chr_69 = "E" !Chr_70 = "F" !Chr_71 = "G" !Chr_72 = "H" !Chr_73 = "I" !Chr_74 = "J" !Chr_75 = "K" !Chr_76 = "L" !Chr_77 = "M" !Chr_78 = "N" !Chr_79 = "O" !Chr_80 = "P" !Chr_81 = "Q" !Chr_82 = "R" !Chr_83 = "S" !Chr_84 = "T" !Chr_85 = "U" !Chr_86 = "V" !Chr_87 = "W" !Chr_88 = "X" !Chr_89 = "Y" !Chr_90 = "Z" !Chr_91 = "[" !Chr_92 = "\\" !Chr_93 = "]" !Chr_94 = "^" !Chr_95 = "_" !Chr_96 = "`" !Chr_97 = "a" !Chr_98 = "b" !Chr_99 = "c" !Chr_100 = "d" !Chr_101 = "e" !Chr_102 = "f" !Chr_103 = "g" !Chr_104 = "h" !Chr_105 = "i" !Chr_106 = "j" !Chr_107 = "k" !Chr_108 = "l" !Chr_109 = "m" !Chr_110 = "n" !Chr_111 = "o" !Chr_112 = "p" !Chr_113 = "q" !Chr_114 = "r" !Chr_115 = "s" !Chr_116 = "t" !Chr_117 = "u" !Chr_118 = "v" !Chr_119 = "w" !Chr_120 = "x" !Chr_121 = "y" !Chr_122 = "z" !Chr_123 = "{" !Chr_124 = "|" !Chr_125 = "|" !Chr_126 = "}" !Chr_127 = "~" macro Chr(byte, result) !Chr_byte #= <byte> !<result> = !{Chr_!{Chr_byte}} endmacro macro SettingsIgnoreSpaces(file, memory) !byte #= readfile1("<file>", !<memory>, 0) while !byte == $20 || !byte == $09 !<memory> #= !<memory>+1 !byte #= readfile1("<file>", !<memory>, 0) endif endmacro function keypart(byte) = or(and(greaterequal(byte, $30), lessequal(byte, $39)), or(and(greaterequal(byte, $41), lessequal(byte, $5A)), or(and(greaterequal(byte, $61), lessequal(byte, $7A)), equal(byte, $5F)))) macro SettingsReadKey(file, memory, key) !<key> := "" !byte #= readfile1("<file>", !<memory>, 0) while keypart(!byte) %Chr(!byte, chr) !<key> := "!<key>!chr" !<memory> #= !<memory>+1 !byte #= readfile1("<file>", !<memory>, 0) endif endmacro macro SettingsReadEquals(file, memory) !byte #= readfile1("<file>", !<memory>, 0) if !byte == $3D !<memory> #= !<memory>+1 else error "!byte : Expected '=' between key and value, in settings.conf file" endif endmacro macro SettingsReadValue(file, memory, value) !<value> := "" !byte #= readfile1("<file>", !<memory>, 0) if !byte == $2D !<value> = "-" !<memory> #= !<memory>+1 !byte #= readfile1("<file>", !<memory>, 0) elseif !byte == $2B !<memory> #= !<memory>+1 !byte #= readfile1("<file>", !<memory>, 0) endif while !byte >= $30 && !byte <= $39 !num #= !byte-$30 !<value> := "!<value>!num" !<memory> #= !<memory>+1 !byte #= readfile1("<file>", !<memory>, 0) endif if stringsequal("!<value>", "") || stringsequal("!<value>", "-") error "Expected a number after 'key = ', in settings.conf file" endif endmacro macro SettingsReadKeyValueEnd(file, memory) !byte #= readfile1("<file>", !<memory>, 0) if !byte == $0A || !byte == $00 !<memory> #= !<memory>+1 else error "Expected newline or EOF after 'key = value', in settings.conf file, found byte !byte" endif endmacro macro SettingsReadKeyValue(file, memory) %SettingsIgnoreSpaces(<file>, <memory>) %SettingsReadKey(<file>, <memory>, key) %SettingsIgnoreSpaces(<file>, <memory>) %SettingsReadEquals(<file>, <memory>) %SettingsIgnoreSpaces(<file>, <memory>) %SettingsReadValue(<file>, <memory>, value) %SettingsIgnoreSpaces(<file>, <memory>) %SettingsReadKeyValueEnd(<file>, <memory>) !{Setting_!{key}} #= !value endmacro macro SettingsReadAll(file) !SettingsReadAll_memory #= 0 while !SettingsReadAll_memory < filesize("<file>") %SettingsReadKeyValue(<file>, SettingsReadAll_memory) endif endmacro if canreadfile("settings.conf", 0, 0) %SettingsReadAll("settings.conf") !SettingsDefault = 0 else !SettingsDefault = 1 endif macro typecheck(value, type, min, max) if <value> < <min> || <value> > <max> error "<value> is not a valid <type>" endif endmacro macro typecheck2(value, type, min, max) if <value> < <min> || <value> > <max> error "<value> is neither a valid signed nor unsigned <type>" endif endmacro macro Setting(var, default, type) if !SettingsDefault != 0 || not(defined("Setting_<var>")) !<var> = <default> else !value := !Setting_<var> if stringsequal("<type>", "bool") if !value != 0 !value = 1 endif elseif stringsequal("<type>", "byte") %typecheck2(!value, byte, -$7F, $FF) elseif stringsequal("<type>", "sbyte") %typecheck(!value, sbyte, -$7F, $7F) elseif stringsequal("<type>", "ubyte") %typecheck(!value, ubyte, 0, $FF) elseif stringsequal("<type>", "word") %typecheck2(!value, word, -$7FFF, $FFFF) elseif stringsequal("<type>", "sword") %typecheck(!value, sword, -$7FFF, $7FFF) elseif stringsequal("<type>", "uword") %typecheck(!value, uword, 0, $FFFF) elseif stringsequal("<type>", "long") %typecheck2(!value, long, -$7FFFFF, $FFFFFF) elseif stringsequal("<type>", "slong") %typecheck(!value, slong, -$7FFFFF, $7FFFFF) elseif stringsequal("<type>", "ulong") %typecheck(!value, ulong, 0, $FFFFFF) endif !<var> := !value endif endmacro
programs/oeis/042/A042964.asm
neoneye/loda
22
163071
<gh_stars>10-100 ; A042964: Numbers congruent to 2 or 3 mod 4. ; 2,3,6,7,10,11,14,15,18,19,22,23,26,27,30,31,34,35,38,39,42,43,46,47,50,51,54,55,58,59,62,63,66,67,70,71,74,75,78,79,82,83,86,87,90,91,94,95,98,99,102,103,106,107,110,111,114,115,118,119,122,123,126,127 mov $1,2 mul $1,$0 gcd $0,2 add $1,$0 mov $0,$1
src/altrom.asm
maziac/dezogif
2
92506
<reponame>maziac/dezogif ;=========================================================================== ; altrom.asm ; ; Code to modify the alternative ROM. ;=========================================================================== ;=========================================================================== ; Copies the ROM to AltROM and modifies ; 8 bytes at address 0 and 14 bytes at address 66h. ; As the ROM banks (0xFF) can't be paged to other slots than 0 and 1 ; the contents is first copied to SWAP_SLOT/B, then the altrom is paged in ; and the SWAP_SLOT contents is copied to slot 0/1. ;=========================================================================== copy_altrom: nextreg REG_MEMORY_MAPPING,011b ; ROM3 = 48k Basic jp copy_modify_altrom ;=========================================================================== ; Copies the ROM to AltROM and modifies ; 8 bytes at address 0 and 14 bytes at address 66h. ; Multiface is not allowed to be enabled here. ;=========================================================================== copy_modify_altrom: ; Disable ALTROM nextreg REG_ALTROM,0 ; Copy ROM to SWAP_SLOT nextreg REG_MMU+SWAP_SLOT,TMP_BANK nextreg REG_MMU,ROM_BANK MEMCOPY SWAP_ADDR, 0x0000, 0x2000 nextreg REG_MMU+SWAP_SLOT,TMP_BANKB nextreg REG_MMU+1,ROM_BANK MEMCOPY SWAP_ADDR, 0x2000, 0x2000 ; Restore MAIN_BANK ;nextreg REG_MMU,MAIN_BANK ; Modify nextreg REG_MMU+MAIN_SLOT,MAIN_BANK nextreg REG_MMU+SWAP_SLOT,TMP_BANK ld a,ROM_BANK call modify_bank ; Enable AltRom and make it writable nextreg REG_ALTROM,11000000b nextreg REG_MMU,ROM_BANK nextreg REG_MMU+1,ROM_BANK ; Copy modified ROM in SWAP_SLOT to AltROM: nextreg REG_MMU+SWAP_SLOT,TMP_BANK MEMCOPY 0x0000, SWAP_ADDR, 0x2000 nextreg REG_MMU+SWAP_SLOT,TMP_BANKB MEMCOPY 0x2000, SWAP_ADDR, 0x2000 ; Enable AltRom nextreg REG_ALTROM,10000000b ret
libsrc/games/mc1000/bit_close.asm
jpoikela/z88dk
640
2698
<reponame>jpoikela/z88dk ; $Id: bit_close.asm,v 1.3 2016-06-16 20:23:51 dom Exp $ ; ; CCE MC-1000 bit sound functions ; ; void bit_close(); ; ; Ensjo - 2013 ; SECTION code_clib PUBLIC bit_close PUBLIC _bit_close .bit_close ._bit_close ld a,$07 ; Select PSG's mixer register. out ($20),a ld a,$7f ; All channels "silent" ; (and MC-1000's specific settings ; for IOA [output] and IOB [input]). out ($60),a ret
alloy4fun_models/trashltl/models/10/5ARiCeiTvtSba9gn4.als
Kaixi26/org.alloytools.alloy
0
4201
<gh_stars>0 open main pred id5ARiCeiTvtSba9gn4_prop11 { all f:File-Protected | after f in Protected } pred __repair { id5ARiCeiTvtSba9gn4_prop11 } check __repair { id5ARiCeiTvtSba9gn4_prop11 <=> prop11o }
src/sensors.adb
Ada-bindings-project/a-lmsensors
0
8460
with Interfaces.C.Strings; with Interfaces.C_Streams; with Sensors.Conversions; with Sensors.LibSensors.Sensors_Sensors_H; with Sensors.LibSensors.Sensors_Error_H; with Ada.IO_Exceptions; package body Sensors is API_VERSION : constant := 16#500#; pragma Compile_Time_Error (API_VERSION /= Sensors.LibSensors.Sensors_Sensors_H.SENSORS_API_VERSION, "Incompatible APIs"); use all type Interfaces.C.int; use Sensors.LibSensors.Sensors_Sensors_H; function Error_Image (Code : Interfaces.C.int) return String is begin return "[" & Code'Img & "] : " & Interfaces.C.Strings.Value (Sensors.LibSensors.Sensors_Error_H.Sensors_Strerror (Code)); end; function Get_Instance (Config_Path : String := "") return Instance is Ret : Interfaces.C.int; Mode : String := "r" & ASCII.NUL; L_Config_Path : constant String := Config_Path & ASCII.NUL; F : aliased Interfaces.C_Streams.FILEs := Interfaces.C_Streams.NULL_Stream; use all type Interfaces.C_Streams.FILEs; begin return Object : Instance do if Config_Path /= "" then F := Interfaces.C_Streams.Fopen (Filename => L_Config_Path'Address, Mode => Mode'Address); if F = Interfaces.C_Streams.NULL_Stream then raise Ada.IO_Exceptions.Name_Error with "Unable to open:" & Config_Path; end if; end if; Ret := Sensors_Init (F); if F /= Interfaces.C_Streams.NULL_Stream then if Interfaces.C_Streams.Fclose (F) /= 0 then null; end if; end if; if Ret /= 0 then raise Sensors_Error with Error_Image (Ret); end if; end return; end; ------------------ -- First_Cursor -- ------------------ function First_Cursor (Cont : Chips_Iterator) return Chips_Cursor is begin return Chips_Cursor'(Cont'Unrestricted_Access, 0); end First_Cursor; ------------- -- Advance -- ------------- function Advance (Cont : Chips_Iterator; Position : Chips_Cursor) return Chips_Cursor is begin return Chips_Cursor'(Position.Ref, Position.I + 1); end; ------------------------ -- Cursor_Has_Element -- ------------------------ function Cursor_Has_Element (Cont : Chips_Iterator; Position : Chips_Cursor) return Boolean is C : aliased Interfaces.C.int := Position.I; Ret : access constant Sensors_Chip_Name; begin Ret := Sensors_Get_Detected_Chips (null, C'Access); return Ret /= null; end Cursor_Has_Element; ----------------- -- Get_Element -- ----------------- function Get_Element (Cont : Chips_Iterator; Position : Chips_Cursor) return Chip_Name'Class is pragma Unreferenced (Cont); C : aliased Interfaces.C.int := Position.I; begin return Conversions.Convert_Up (Sensors_Get_Detected_Chips (null, C'Access).all); end Get_Element; ------------------------ -- Get_Detected_Chips -- ------------------------ function Detected_Chips (Self : Instance) return Chips_Iterator'Class is begin return Ret : Chips_Iterator do null; end return; end Detected_Chips; -------------- -- Finalize -- -------------- procedure Finalize (Object : in out Instance) is pragma Unreferenced (Object); begin Sensors.LibSensors.Sensors_Sensors_H.Sensors_Cleanup; end Finalize; function Version return String is begin return Interfaces.C.Strings.Value (Sensors.LibSensors.Sensors_Sensors_H.Libsensors_Version); end; -- begin -- if Binding_Version /= Version then -- raise Program_Error with "Binding version missmatch"; -- end if; end Sensors;
RadixProject/program.asm
techwiz24/EECS2110
0
23707
; <NAME> ; EECS 2110 - Computer Architecture and Organization ; Spring 2016 at the University of Toledo ; ; Description: Given an input radix, output radix, and two numbers in the ; specified input radix, perform the following operations: ; A+B ; A-B ; A*B ; A/B if b != 0, otherwise display an error ; A^abs(b) ; ============================================================================== ; | Include libraries and macros | ; ============================================================================== include ..\lib\pcmac.inc include .\functions.inc ; ============================================================================== ; | Constants used in this file | ; ============================================================================== TAB EQU 09 ; Horizontal Tab CR EQU 13 ; Carriage Return LF EQU 10 ; Line Feed EOS EQU '$' ; DOS End of string terminator MIN_RADIX EQU 2 MAX_RADIX EQU 36 RET_OK EQU 00h ; Return code for OK ; =========================== Start of Setup ============================ .model small ; Small Memory MODEL .586 ; Pentium Instruction Set .stack 100h ; Stack area - 256 bytes ; =========================== End of Setup =========================== ; =========================== Start of Data Segment =========================== .data ; Include message definitions. This needs to be done in the data segment include .\strings.inc ; --------------------------- Variables --------------------------- inputRadix DB ? outputRadix DB ? inputA DW ? inputB DW ? mathscratch DW ? ; ------------------------------------------------------------------------------ ; =========================== End of Data Segment =========================== .code EXTRN PutDec:NEAR start: main PROC _LdSeg ds, @data ; Load the data segment PROMPT: _PutStr inputRadixPrompt _PickRadix inputRadix, EXIT, INVALID_RADIX _PutStr blank _PutStr outputRadixPrompt _PickRadix outputRadix, EXIT, INVALID_RADIX _PutStr blank _PutStr numberPrompt_A mov al, inputRadix cbw mov dx, ax _PutRadix dx, 10, radixTable _PutStr numberPrompt_Radix _GetRadix inputA, inputRadix, radixTable, radixTableLength, INVALID_RADIX_SYMBOL _PutStr numberPrompt_B mov al, inputRadix cbw mov dx, ax _PutRadix dx, 10, radixTable _PutStr numberPrompt_Radix _GetRadix inputB, inputRadix, radixTable, radixTableLength, INVALID_RADIX_SYMBOL _PutStr outAdd mov ax, inputA mov mathscratch, ax mov bx, inputB add mathscratch, bx _PutRadix mathscratch, outputRadix, radixTable _PutStr blank _PutStr outSub mov ax, inputA mov mathscratch, ax mov bx, inputB sub mathscratch, bx _PutRadix mathscratch, outputRadix, radixTable _PutStr blank _PutStr outMul xor dx, dx mov ax, inputA imul inputB mov mathscratch, ax _PutRadix mathscratch, outputRadix, radixTable _PutStr blank _PutStr outDiv cmp inputB, 0 jne OUT_DIV _PutStr errDivByZero jmp OUT_DIV_DONE OUT_DIV: mov ax, inputA cwd idiv inputB push dx mov mathscratch, ax _PutRadix mathscratch, outputRadix, radixTable _PutStr outRemainder pop dx mov mathscratch, dx _PutRadix mathscratch, outputRadix, radixTable _PutStr blank OUT_DIV_DONE: _PutStr outPow mov ax, inputB cwd ; Fill dx with the sign bit of ax xor ax, dx ; And compute the absolute value sub ax, dx ; of inputB first _Pow inputA, ax, mathscratch _PutRadix mathscratch, outputRadix, radixTable _PutStr blank jmp PROMPT INVALID_RADIX: _PutStr blank _PutStr errBadRadix jmp PROMPT INVALID_RADIX_SYMBOL: _PutStr blank _PutStr errBadSymbol jmp PROMPT EXIT: _Exit RET_OK main ENDP END main
src/Data/QuadTree/Implementation/PropDepthRelation.agda
JonathanBrouwer/research-project
1
14353
<filename>src/Data/QuadTree/Implementation/PropDepthRelation.agda module Data.QuadTree.Implementation.PropDepthRelation where open import Haskell.Prelude open import Data.Logic ---- Properties of depth lteTransitiveWeird : (x y d : Nat) -> IsTrue (x < y) -> (y <= d) ≡ ((x <= d) && (y <= d)) lteTransitiveWeird zero zero zero xlty = refl lteTransitiveWeird zero zero (suc d) xlty = refl lteTransitiveWeird zero (suc y) zero xlty = refl lteTransitiveWeird zero (suc y) (suc d) xlty = refl lteTransitiveWeird (suc x) (suc y) zero xlty = refl lteTransitiveWeird (suc x) (suc y) (suc d) xlty = lteTransitiveWeird x y d xlty lteTransitiveWeirdInv : (x y d : Nat) -> IsFalse (x < y) -> (x <= d) ≡ ((x <= d) && (y <= d)) lteTransitiveWeirdInv zero zero zero xnlty = refl lteTransitiveWeirdInv zero zero (suc d) xnlty = refl lteTransitiveWeirdInv (suc x) zero zero xnlty = refl lteTransitiveWeirdInv (suc x) zero (suc d) xnlty = begin (suc x <= suc d) =⟨ sym $ boolAndTrue (suc x <= suc d) ⟩ (suc x <= suc d) && true =⟨⟩ ((suc x <= suc d) && (zero <= suc d)) end lteTransitiveWeirdInv (suc x) (suc y) zero xnlty = refl lteTransitiveWeirdInv (suc x) (suc y) (suc d) xnlty = lteTransitiveWeirdInv x y d xnlty ifComparisonMap : (x y d : Nat) -> ((x <= d) && (y <= d)) ≡ (if x < y then (y <= d) else (x <= d)) ifComparisonMap x y d = ifc x < y then (λ {{xlty}} -> begin (x <= d) && (y <= d) =⟨ sym $ lteTransitiveWeird x y d xlty ⟩ y <= d =⟨ sym $ ifTrue (x < y) xlty ⟩ (if x < y then (y <= d) else (x <= d)) end ) else (λ {{xnlty}} -> begin (x <= d) && (y <= d) =⟨ sym $ lteTransitiveWeirdInv x y d xnlty ⟩ x <= d =⟨ sym $ ifFalse (x < y) xnlty ⟩ (if x < y then (y <= d) else (x <= d)) end ) propMaxLte : (x y d : Nat) -> ((x <= d) && (y <= d)) ≡ (max x y <= d) propMaxLte x y d = begin (x <= d) && (y <= d) =⟨ ifComparisonMap x y d ⟩ (if x < y then (y <= d) else (x <= d)) =⟨ propFnIf (λ v -> v <= d) ⟩ (if x < y then y else x) <= d =⟨⟩ max x y <= d end propAndMap : (a b c d : Bool) -> a ≡ c -> b ≡ d -> (a && b) ≡ (c && d) propAndMap false false false false ac bd = refl propAndMap false true false true ac bd = refl propAndMap true false true false ac bd = refl propAndMap true true true true ac bd = refl propMaxLte4 : (w x y z d : Nat) -> (((w <= d) && (x <= d)) && ((y <= d) && (z <= d))) ≡ (max (max w x) (max y z) <= d) propMaxLte4 w x y z d = begin ((w <= d) && (x <= d)) && ((y <= d) && (z <= d)) =⟨ propAndMap ((w <= d) && (x <= d)) ((y <= d) && (z <= d)) (max w x <= d) (max y z <= d) (propMaxLte w x d) (propMaxLte y z d) ⟩ (max w x <= d) && (max y z <= d) =⟨ propMaxLte (if w < x then x else w) (if y < z then z else y) d ⟩ (max (max w x) (max y z) <= d) end
lib/TrinketHidCombo/usbdrv/usbdrvasm.asm
debsahu/A85_KeyBoard_HID
0
18842
/* Name: usbdrvasm.asm * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers * Author: <NAME> * Creation Date: 2006-03-01 * Tabsize: 4 * Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) */ /* General Description: The IAR compiler/assembler system prefers assembler files with file extension ".asm". We simply provide this file as an alias for usbdrvasm.S. Thanks to <NAME> for his help with the IAR tools port! */ #include "usbdrvasm.S" //end
newitems/jump/warp.asm
fcard/z3randomizer
0
88811
; Handle jumping over dungeon warp tiles CheckDungeonWarpCollision: LDA !IsJumping : BNE + LDA $4D : BNE + JML CheckDungeonWarpCollision.ReturnPoint + JML CheckDungeonWarpCollision.BranchPoint
Transynther/x86/_processed/NONE/_xt_/i3-7100_9_0x84_notsx.log_21829_649.asm
ljhsiun2/medusa
9
98801
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %rdi push %rsi lea addresses_WC_ht+0x153d6, %r11 nop nop xor $47830, %rdi and $0xffffffffffffffc0, %r11 vmovntdqa (%r11), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $0, %xmm1, %rsi nop nop nop xor $42440, %r14 pop %rsi pop %rdi pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r14 push %r15 push %rbx push %rdx push %rsi // Faulty Load lea addresses_WT+0x19bd6, %rbx nop add %rsi, %rsi mov (%rbx), %dx lea oracles, %rbx and $0xff, %rdx shlq $12, %rdx mov (%rbx,%rdx,1), %rdx pop %rsi pop %rdx pop %rbx pop %r15 pop %r14 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_WT', 'same': False, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_WT', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 32, 'congruent': 11, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'39': 21829} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
applet/aide/source/editors/aide-editor-of_subtype_indication.adb
charlie5/aIDE
3
5610
with aIDE.GUI, aIDE.Editor.of_enumeration_literal, AdaM.a_Type.enumeration_literal, glib.Error, gtk.Builder, gtk.Handlers; with Ada.Text_IO; use Ada.Text_IO; package body aIDE.Editor.of_subtype_indication is use Gtk.Builder, Glib, glib.Error; function on_first_Entry_leave (the_Entry : access Gtk_Entry_Record'Class; Target : in AdaM.subtype_Indication.view) return Boolean is the_Text : constant String := the_Entry.Get_Text; begin Target.First_is (the_Text); return False; end on_first_Entry_leave; function on_last_Entry_leave (the_Entry : access Gtk_Entry_Record'Class; Target : in AdaM.subtype_Indication.view) return Boolean is the_Text : constant String := the_Entry.Get_Text; begin Target.Last_is (the_Text); return False; end on_last_Entry_leave; procedure on_index_type_Button_clicked (the_Entry : access Gtk_Button_Record'Class; the_Editor : in aIDE.Editor.of_subtype_Indication.view) is begin aIDE.GUI.show_types_Palette (Invoked_by => the_Entry.all'Access, Target => the_Editor.Target.main_Type); end on_index_type_Button_clicked; procedure on_rid_Button_clicked (the_Button : access Gtk_Button_Record'Class; the_Editor : in aIDE.Editor.of_subtype_Indication.view) is pragma Unreferenced (the_Editor); begin the_Button.get_Parent.destroy; end on_rid_Button_clicked; package Entry_return_Callbacks is new Gtk.Handlers.User_Return_Callback (Gtk_Entry_Record, Boolean, AdaM.subtype_Indication.view); package Button_Callbacks is new Gtk.Handlers.User_Callback (Gtk_Button_Record, aIDE.Editor.of_subtype_Indication.view); function on_unconstrained_Label_clicked (the_Label : access Gtk_Label_Record'Class; Self : in aIDE.Editor.of_subtype_Indication.view) return Boolean is pragma Unreferenced (the_Label); begin -- Self.Target.is_Constrained; Self.freshen; return False; end on_unconstrained_Label_clicked; function on_constrained_Label_clicked (the_Label : access Gtk_Label_Record'Class; Self : in aIDE.Editor.of_subtype_Indication.view) return Boolean is pragma Unreferenced (the_Label); begin -- Self.Target.is_Constrained (Now => False); Self.freshen; return False; end on_constrained_Label_clicked; package Label_return_Callbacks is new Gtk.Handlers.User_Return_Callback (Gtk_Label_Record, Boolean, aIDE.Editor.of_subtype_Indication.view); package body Forge is function to_Editor (the_Target : in AdaM.subtype_Indication.view; is_in_unconstrained_Array : in Boolean) return View is use AdaM, Glib; Self : constant Editor.of_subtype_Indication.view := new Editor.of_subtype_Indication.item; the_Builder : Gtk_Builder; Error : aliased GError; Result : Guint; pragma Unreferenced (Result); begin Self.Target := the_Target; Self.is_in_unconstrained_Array := is_in_unconstrained_Array; Gtk_New (the_Builder); Result := the_Builder.Add_From_File ("glade/editor/subtype_indication_editor.glade", Error'Access); if Error /= null then raise Program_Error with "Error: adam.Editor.of_enumeration_type ~ " & Get_Message (Error); end if; Self.top_Box := gtk_Box (the_Builder.get_Object ("top_Box")); Self.type_Button := Gtk_Button (the_Builder.get_Object ("index_type_Button")); Self.range_Label := Gtk_Label (the_Builder.get_Object ("range_Label")); Self.unconstrained_Label := Gtk_Label (the_Builder.get_Object ("unconstrained_Label")); Self. constrained_Label := Gtk_Label (the_Builder.get_Object ( "constrained_Label")); Self.first_Entry := Gtk_Entry (the_Builder.get_Object ("first_Entry")); Self. last_Entry := Gtk_Entry (the_Builder.get_Object ( "last_Entry")); -- Self.rid_Button := gtk_Button (the_Builder.get_Object ("rid_Button")); Self.first_Entry.set_Text (Self.Target.First); Entry_return_Callbacks.connect (Self.first_Entry, "focus-out-event", on_first_Entry_leave'Access, the_Target); Self.last_Entry.set_Text (Self.Target.Last); Entry_return_Callbacks.connect (Self.last_Entry, "focus-out-event", on_last_Entry_leave'Access, the_Target); Self.type_Button.set_Label (+Self.Target.main_Type.Name); button_Callbacks.connect (Self.type_Button, "clicked", on_index_type_Button_clicked'Access, Self); -- Button_Callbacks.Connect (Self.rid_Button, -- "clicked", -- on_rid_Button_clicked'Access, -- Self); Label_return_Callbacks.Connect (Self.unconstrained_Label, "button-release-event", on_unconstrained_Label_clicked'Access, Self); Label_return_Callbacks.Connect (Self.constrained_Label, "button-release-event", on_constrained_Label_clicked'Access, Self); Self.freshen; return Self; end to_Editor; end Forge; procedure destroy_Callback (Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class) is begin Widget.destroy; end destroy_Callback; overriding procedure freshen (Self : in out Item) is use gtk.Widget; -- the_Literals : AdaM.a_Type.enumeration_literal.vector renames Self.Target.Literals; -- literal_Editor : aIDE.Editor.of_enumeration_literal.view; begin -- if Self.is_in_unconstrained_Array -- then -- Self.unconstrained_Label.show; -- -- Self.first_Entry.hide; -- Self.last_Entry.hide; -- Self.range_Label.show; -- Self. constrained_Label.hide; -- else -- Self.unconstrained_Label.hide; if Self.Target.is_Constrained then if Self.Target.First = "" then Self.range_Label.hide; Self. constrained_Label.hide; Self.unconstrained_Label.hide; Self.first_Entry.hide; Self.last_Entry.hide; else Self.range_Label.show; Self. constrained_Label.show; Self.unconstrained_Label.hide; Self.first_Entry.show; Self.last_Entry.show; end if; else Self.range_Label.show; Self.first_Entry.hide; Self.last_Entry.hide; Self. constrained_Label.hide; Self.unconstrained_Label.show; end if; -- end if; -- if Self.is_in_unconstrained_Array -- then -- Self.unconstrained_Label.show; -- -- Self.first_Entry.hide; -- Self.last_Entry.hide; -- Self.range_Label.show; -- Self. constrained_Label.hide; -- else -- Self.unconstrained_Label.hide; -- -- if Self.Target.is_Constrained -- then -- Self.range_Label.show; -- Self. constrained_Label.show; -- Self.first_Entry.show; -- Self.last_Entry.show; -- else -- Self.range_Label.hide; -- Self.first_Entry.hide; -- Self.last_Entry.hide; -- Self. constrained_Label.hide; -- Self.unconstrained_Label.hide; -- end if; -- end if; -- Self.first_Entry.set_Text (Self.Target.First); -- Self.last_Entry .set_Text (Self.Target.Last); -- Self.literals_Box.Foreach (destroy_Callback'Access); -- for Each of the_Literals -- loop -- literal_Editor := Editor.of_enumeration_literal.Forge.to_Editor (Each, -- targets_Parent => Self.Target.all'Access); -- Self.literals_Box.pack_Start (literal_Editor.top_Widget); -- end loop; end freshen; overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget is begin return gtk.Widget.Gtk_Widget (Self.top_Box); end top_Widget; end aIDE.Editor.of_subtype_indication;
oeis/138/A138631.asm
neoneye/loda-programs
11
16560
<filename>oeis/138/A138631.asm ; A138631: Primes of the form 17*k + 9. ; Submitted by <NAME> ; 43,179,281,349,383,587,757,859,1063,1097,1301,1471,1607,1709,1777,1811,1879,1913,2083,2287,2389,2423,2593,2729,2797,3001,3137,3307,3511,3613,3851,3919,4021,4157,4259,4327,4463,4871,4973,5279,5347,5381,5449,5483,5653,5857,6163,6197,6299,6367,6469,6571,6673,6911,7013,7489,7523,7591,7727,7829,8101,8237,8543,8713,8747,8849,8951,9257,9461,9631,9733,9767,10039,10141,10243,10651,10753,10889,10957,11059,11093,11161,11399,11467,11807,11909,12011,12113,12487,12589,13099,13337,13711,14051,14153,14221 mov $2,$0 add $2,6 pow $2,2 mov $4,8 lpb $2 mov $3,$4 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 mov $1,$0 max $1,0 cmp $1,$0 mul $2,$1 sub $2,1 add $4,34 lpe mov $0,$4 add $0,1
codec/encoder/core/asm/score.asm
TechSmith/openh264
1
179598
<gh_stars>1-10 ;*! ;* \copy ;* Copyright (c) 2009-2013, Cisco Systems ;* All rights reserved. ;* ;* Redistribution and use in source and binary forms, with or without ;* modification, are permitted provided that the following conditions ;* are met: ;* ;* * Redistributions of source code must retain the above copyright ;* notice, this list of conditions and the following disclaimer. ;* ;* * Redistributions in binary form must reproduce the above copyright ;* notice, this list of conditions and the following disclaimer in ;* the documentation and/or other materials provided with the ;* distribution. ;* ;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ;* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ;* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ;* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ;* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ;* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ;* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ;* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;* POSSIBILITY OF SUCH DAMAGE. ;* ;* ;* score.asm ;* ;* Abstract ;* scan/score/count of sse2 ;* ;* History ;* 8/21/2009 Created ;* ;* ;*************************************************************************/ %include "asm_inc.asm" bits 32 ;*********************************************************************** ; Macros ;*********************************************************************** ;*********************************************************************** ; Local Data (Read Only) ;*********************************************************************** SECTION .rodata align=16 ;align 16 ;se2_2 dw 2, 2, 2, 2, 2, 2, 2, 2 align 16 sse2_1: dw 1, 1, 1, 1, 1, 1, 1, 1 align 16 sse2_b1: db 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 i_ds_table: db 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 align 16 sse2_plane_inc_minus: dw -7, -6, -5, -4, -3, -2, -1, 0 align 16 sse2_plane_inc: dw 1, 2, 3, 4, 5, 6, 7, 8 align 16 sse2_plane_dec: dw 8, 7, 6, 5, 4, 3, 2, 1 align 16 pb_scanacdc_maska:db 0,1,2,3,8,9,14,15,10,11,4,5,6,7,12,13 align 16 pb_scanacdc_maskb:db 2,3,8,9,10,11,4,5,0,1,6,7,12,13,14,15 align 16 pb_scandc_maska:db 2,3,8,9,14,15,10,11,4,5,6,7,12,13,0,1 align 16 pb_scandc_maskb:db 8,9,10,11,4,5,0,1,6,7,12,13,14,15,128,128 align 16 nozero_count_table: db 0,1,1,2,1,2,2,3,1,2 db 2,3,2,3,3,4,1,2,2,3 db 2,3,3,4,2,3,3,4,3,4 db 4,5,1,2,2,3,2,3,3,4 db 2,3,3,4,3,4,4,5,2,3 db 3,4,3,4,4,5,3,4,4,5 db 4,5,5,6,1,2,2,3,2,3 db 3,4,2,3,3,4,3,4,4,5 db 2,3,3,4,3,4,4,5,3,4 db 4,5,4,5,5,6,2,3,3,4 db 3,4,4,5,3,4,4,5,4,5 db 5,6,3,4,4,5,4,5,5,6 db 4,5,5,6,5,6,6,7,1,2 db 2,3,2,3,3,4,2,3,3,4 db 3,4,4,5,2,3,3,4,3,4 db 4,5,3,4,4,5,4,5,5,6 db 2,3,3,4,3,4,4,5,3,4 db 4,5,4,5,5,6,3,4,4,5 db 4,5,5,6,4,5,5,6,5,6 db 6,7,2,3,3,4,3,4,4,5 db 3,4,4,5,4,5,5,6,3,4 db 4,5,4,5,5,6,4,5,5,6 db 5,6,6,7,3,4,4,5,4,5 db 5,6,4,5,5,6,5,6,6,7 db 4,5,5,6,5,6,6,7,5,6 db 6,7,6,7,7,8 align 16 high_mask_table: db 0, 0, 0, 3, 0, 2, 3, 6, 0, 2 db 2, 5, 3, 5, 6, 9, 0, 1, 2, 5 db 2, 4, 5, 8, 3, 5, 5, 8, 6, 8 db 9,12, 0, 1, 1, 4, 2, 4, 5, 8 db 2, 4, 4, 7, 5, 7, 8,11, 3, 4 db 5, 8, 5, 7, 8,11, 6, 8, 8,11 db 9,11,12,15, 0, 1, 1, 4, 1, 3 db 4, 7, 2, 4, 4, 7, 5, 7, 8,11 db 2, 3, 4, 7, 4, 6, 7,10, 5, 7 db 7,10, 8,10,11,14, 3, 4, 4, 7 db 5, 7, 8,11, 5, 7, 7,10, 8,10 db 11,14, 6, 7, 8,11, 8,10,11,14 db 9,11,11,14,12,14,15,18, 0, 0 db 1, 4, 1, 3, 4, 7, 1, 3, 3, 6 db 4, 6, 7,10, 2, 3, 4, 7, 4, 6 db 7,10, 5, 7, 7,10, 8,10,11,14 db 2, 3, 3, 6, 4, 6, 7,10, 4, 6 db 6, 9, 7, 9,10,13, 5, 6, 7,10 db 7, 9,10,13, 8,10,10,13,11,13 db 14,17, 3, 4, 4, 7, 4, 6, 7,10 db 5, 7, 7,10, 8,10,11,14, 5, 6 db 7,10, 7, 9,10,13, 8,10,10,13 db 11,13,14,17, 6, 7, 7,10, 8,10 db 11,14, 8,10,10,13,11,13,14,17 db 9,10,11,14,11,13,14,17,12,14 db 14,17,15,17,18,21 align 16 low_mask_table: db 0, 3, 2, 6, 2, 5, 5, 9, 1, 5 db 4, 8, 5, 8, 8,12, 1, 4, 4, 8 db 4, 7, 7,11, 4, 8, 7,11, 8,11 db 11,15, 1, 4, 3, 7, 4, 7, 7,11 db 3, 7, 6,10, 7,10,10,14, 4, 7 db 7,11, 7,10,10,14, 7,11,10,14 db 11,14,14,18, 0, 4, 3, 7, 3, 6 db 6,10, 3, 7, 6,10, 7,10,10,14 db 3, 6, 6,10, 6, 9, 9,13, 6,10 db 9,13,10,13,13,17, 4, 7, 6,10 db 7,10,10,14, 6,10, 9,13,10,13 db 13,17, 7,10,10,14,10,13,13,17 db 10,14,13,17,14,17,17,21, 0, 3 db 3, 7, 3, 6, 6,10, 2, 6, 5, 9 db 6, 9, 9,13, 3, 6, 6,10, 6, 9 db 9,13, 6,10, 9,13,10,13,13,17 db 3, 6, 5, 9, 6, 9, 9,13, 5, 9 db 8,12, 9,12,12,16, 6, 9, 9,13 db 9,12,12,16, 9,13,12,16,13,16 db 16,20, 3, 7, 6,10, 6, 9, 9,13 db 6,10, 9,13,10,13,13,17, 6, 9 db 9,13, 9,12,12,16, 9,13,12,16 db 13,16,16,20, 7,10, 9,13,10,13 db 13,17, 9,13,12,16,13,16,16,20 db 10,13,13,17,13,16,16,20,13,17 db 16,20,17,20,20,24 SECTION .text ;*********************************************************************** ;void WelsScan4x4DcAc_sse2( int16_t level[16], int16_t *pDct ) ;*********************************************************************** ALIGN 16 WELS_EXTERN WelsScan4x4DcAc_sse2 WelsScan4x4DcAc_sse2: mov eax, [esp+8] movdqa xmm0, [eax] ; 7 6 5 4 3 2 1 0 movdqa xmm1, [eax+16] ; f e d c b a 9 8 pextrw ecx, xmm0, 7 ; ecx = 7 pextrw edx, xmm1, 2 ; edx = a pextrw eax, xmm0, 5 ; eax = 5 pinsrw xmm1, ecx, 2 ; f e d c b 7 9 8 pinsrw xmm0, eax, 7 ; 5 6 5 4 3 2 1 0 pextrw ecx, xmm1, 0 ; ecx = 8 pinsrw xmm0, ecx, 5 ; 5 6 8 4 3 2 1 0 pinsrw xmm1, edx, 0 ; f e d c b 7 9 a pshufd xmm2, xmm0, 0xd8 ; 5 6 3 2 8 4 1 0 pshufd xmm3, xmm1, 0xd8 ; f e b 7 d c 9 a pshufhw xmm0, xmm2, 0x93 ; 6 3 2 5 8 4 1 0 pshuflw xmm1, xmm3, 0x39 ; f e b 7 a d c 9 mov eax, [esp+4] movdqa [eax],xmm0 movdqa [eax+16], xmm1 ret ;*********************************************************************** ;void WelsScan4x4DcAc_ssse3( int16_t level[16], int16_t *pDct ) ;*********************************************************************** ALIGN 16 WELS_EXTERN WelsScan4x4DcAc_ssse3 WelsScan4x4DcAc_ssse3: mov eax, [esp+8] movdqa xmm0, [eax] movdqa xmm1, [eax+16] pextrw ecx, xmm0, 7 ; ecx = [7] pextrw eax, xmm1, 0 ; eax = [8] pinsrw xmm0, eax, 7 ; xmm0[7] = [8] pinsrw xmm1, ecx, 0 ; xmm1[0] = [7] pshufb xmm1, [pb_scanacdc_maskb] pshufb xmm0, [pb_scanacdc_maska] mov eax, [esp+4] movdqa [eax],xmm0 movdqa [eax+16], xmm1 ret ;*********************************************************************** ;void WelsScan4x4Ac_sse2( int16_t* zig_value, int16_t* pDct ) ;*********************************************************************** ALIGN 16 WELS_EXTERN WelsScan4x4Ac_sse2 WelsScan4x4Ac_sse2: mov eax, [esp+8] movdqa xmm0, [eax] movdqa xmm1, [eax+16] movdqa xmm2, xmm0 punpcklqdq xmm0, xmm1 punpckhqdq xmm2, xmm1 movdqa xmm3, xmm0 punpckldq xmm0, xmm2 punpckhdq xmm3, xmm2 pextrw eax , xmm0, 3 pextrw edx , xmm0, 7 pinsrw xmm0, eax, 7 pextrw eax, xmm3, 4 pinsrw xmm3, edx, 4 pextrw edx, xmm3, 0 pinsrw xmm3, eax, 0 pinsrw xmm0, edx, 3 pshufhw xmm1, xmm0, 0x93 pshuflw xmm2, xmm3, 0x39 movdqa xmm3, xmm2 psrldq xmm1, 2 pslldq xmm3, 14 por xmm1, xmm3 psrldq xmm2, 2 mov eax, [esp+4] movdqa [eax],xmm1 movdqa [eax+16], xmm2 ret ;*********************************************************************** ;void int32_t WelsCalculateSingleCtr4x4_sse2( int16_t *pDct ); ;*********************************************************************** ALIGN 16 WELS_EXTERN WelsCalculateSingleCtr4x4_sse2 WelsCalculateSingleCtr4x4_sse2: push ebx mov eax, [esp+8] movdqa xmm0, [eax] movdqa xmm1, [eax+16] packsswb xmm0, xmm1 pxor xmm3, xmm3 pcmpeqb xmm0, xmm3 pmovmskb edx, xmm0 xor edx, 0xffff xor eax, eax mov ecx, 7 mov ebx, 8 .loop_low8_find1: bt edx, ecx jc .loop_high8_find1 loop .loop_low8_find1 .loop_high8_find1: bt edx, ebx jc .find1end inc ebx cmp ebx,16 jb .loop_high8_find1 .find1end: sub ebx, ecx sub ebx, 1 add al, [i_ds_table+ebx] mov ebx, edx and edx, 0xff shr ebx, 8 and ebx, 0xff add al, [low_mask_table +edx] add al, [high_mask_table+ebx] pop ebx ret ;*********************************************************************** ; int32_t WelsGetNoneZeroCount_sse2(int16_t* level); ;*********************************************************************** ALIGN 16 WELS_EXTERN WelsGetNoneZeroCount_sse2 WelsGetNoneZeroCount_sse2: mov eax, [esp+4] movdqa xmm0, [eax] movdqa xmm1, [eax+16] pxor xmm2, xmm2 pcmpeqw xmm0, xmm2 pcmpeqw xmm1, xmm2 packsswb xmm1, xmm0 pmovmskb edx, xmm1 xor edx, 0xffff mov ecx, edx and edx, 0xff shr ecx, 8 ; and ecx, 0xff ; we do not need this due to high 16bits equal to 0 yet xor eax, eax add al, [nozero_count_table+ecx] add al, [nozero_count_table+edx] ret
asm/mips/tests/bad_syntax.asm
TomRegan/synedoche
1
81035
<filename>asm/mips/tests/bad_syntax.asm<gh_stars>1-10 # Author : <NAME> <<EMAIL>> # Last modified : 2011-08-12 # Description : Does an O(n^2) sort on an unsorted list. # Modifies : registers : $t(0..9) # memory : Stack(40b) Main: addi $t0, $zero, 7 # Store some values to be sorted addi $t1, $zero, 5 addi $t2, $zero, 2 addi $t3, $zero, 8 addi $t4, $zero, 4 addi $t5, $zero, 9 addi $t6, $zero, 0 addi $t7, $zero, 1 addi $t8, $zero, 6 addi $t9, $zero, 3 addi $s0, $zero, 10 # Outer loop counter for the sort jal Stack addi $v0, $zero, 10 syscall Stack: addi $sp, $sp, -40 sw $t0, 0($sp) sw $t1, 4($sp) sw $t2, 8($sp) sw $t3, 12($sp) sw $t4, 16($sp) sw $t5, 20($sp) sw $t6, 24($sp) sw $t7, 28($sp) sw $t8, 32($sp) sw $t9, 36($sp) Sort: add $fp, $zero, $sp # Set the fp to the current sp addi $s1, $zero, 10 # Inner loop counter for the sort # Todo: Discovered a bug in the system here. No comma after rs led to # crash in linker with nul object. More strict checking needed? # Possibly reject based on regex? bgtz $s0 Loop # Continue if s0 > 0 addi $s0, $s0, -1 # This is executed each time jr $ra nop Loop: addi $s1, $s1, -2 # Decrement inner loop counter beq $s1, $s5, Sort lw $s2, 0($fp) lw $s3, 4($fp) slt $s4, $s2, $s3 beq $s4, $zero, Swap nop addi $fp, $fp, 4 j Loop Swap: add $s4, $zero, $s2 # This is the temp value for a swap add $s2, $zero, $s3 add $s3, $zero, $s4 sw $s2, 0($fp) sw $s3, 4($fp) addi $s1, $s1, -2 j Loop addi $fp, $fp, 4
oeis/041/A041133.asm
neoneye/loda-programs
11
89416
<gh_stars>10-100 ; A041133: Denominators of continued fraction convergents to sqrt(75). ; Submitted by <NAME> ; 1,1,2,3,50,53,103,156,2599,2755,5354,8109,135098,143207,278305,421512,7022497,7444009,14466506,21910515,365034746,386945261,751980007,1138925268,18974784295,20113709563,39088493858,59202203421,986323748594,1045525952015,2031849700609,3077375652624,51269860142593,54347235795217,105617095937810,159964331733027,2665046403666242,2825010735399269,5490057139065511,8315067874464780,138531143130501991,146846211004966771,285377354135468762,432223565140435533,7200954396382437290,7633177961522872823 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 mov $3,$1 mov $1,$2 dif $2,3 mod $2,$1 mul $2,45 add $3,$2 mov $2,$1 lpe mov $0,$1
src/statements/adabase-statement-base.adb
jrmarino/AdaBase
30
25705
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../../License.txt package body AdaBase.Statement.Base is ------------------ -- successful -- ------------------ overriding function successful (Stmt : Base_Statement) return Boolean is begin return Stmt.successful_execution; end successful; ---------------------- -- data_discarded -- ---------------------- overriding function data_discarded (Stmt : Base_Statement) return Boolean is begin return Stmt.rows_leftover; end data_discarded; --------------------- -- rows_affected -- --------------------- overriding function rows_affected (Stmt : Base_Statement) return Affected_Rows is begin if not Stmt.successful_execution then raise PRIOR_EXECUTION_FAILED with "Has query been executed yet?"; end if; if Stmt.result_present then raise INVALID_FOR_RESULT_SET with "Result set found; use rows_returned"; else return Stmt.impacted; end if; end rows_affected; --------------------- -- transform_sql -- --------------------- function transform_sql (Stmt : out Base_Statement; sql : String) return String is procedure reserve_marker; sql_mask : String := CT.redact_quotes (sql); procedure reserve_marker is brec : bindrec; begin brec.v00 := False; Stmt.realmccoy.Append (New_Item => brec); end reserve_marker; begin Stmt.alpha_markers.Clear; Stmt.realmccoy.Clear; if CT.IsBlank (sql) then return ""; end if; declare -- This block does two things: -- 1) finds "?" and increments the replacement index -- 2) finds ":[A-Za-z0-9_]*", replaces with "?", increments the -- replacement index, and pushes the string into alpha markers -- Avoid replacing "::" which is casting on postgresql (in redact) -- Normally ? and : aren't mixed but we will support it. procedure replace_alias; procedure lock_and_advance (symbol : Character); start : Natural := 0; final : Natural := 0; arrow : Positive := 1; polaris : Natural := 0; scanning : Boolean := False; product : String (1 .. sql'Length) := (others => ' '); adjacent_error : constant String := "Bindings are not separated; they are touching: "; procedure lock_and_advance (symbol : Character) is begin polaris := polaris + 1; product (polaris) := symbol; end lock_and_advance; procedure replace_alias is len : Natural := final - start; alias : String (1 .. len) := sql_mask (start + 1 .. final); begin if Stmt.alpha_markers.Contains (Key => alias) then raise ILLEGAL_BIND_SQL with "multiple instances of " & alias; end if; reserve_marker; Stmt.alpha_markers.Insert (alias, Stmt.realmccoy.Last_Index); scanning := False; end replace_alias; begin loop case sql_mask (arrow) is when ASCII.Query => if scanning then raise ILLEGAL_BIND_SQL with adjacent_error & sql_mask (start .. arrow); end if; reserve_marker; lock_and_advance (ASCII.Query); when ASCII.Colon => if scanning then raise ILLEGAL_BIND_SQL with adjacent_error & sql_mask (start .. arrow); end if; scanning := True; start := arrow; when others => if scanning then case sql_mask (arrow) is when 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '_' => final := arrow; when others => replace_alias; lock_and_advance (ASCII.Query); lock_and_advance (sql (arrow)); end case; else lock_and_advance (sql (arrow)); end if; end case; if scanning and then arrow = sql_mask'Length then replace_alias; lock_and_advance (ASCII.Query); end if; exit when arrow = sql_mask'Length; arrow := arrow + 1; end loop; return product (1 .. polaris); end; end transform_sql; ---------------------------------- -- convert string to textwide -- ---------------------------------- function convert (nv : String) return AR.Textwide is begin return SUW.To_Unbounded_Wide_String (ACC.To_Wide_String (nv)); end convert; ----------------------------------- -- convert string to textsuper -- ----------------------------------- function convert (nv : String) return AR.Textsuper is begin return SWW.To_Unbounded_Wide_Wide_String (ACC.To_Wide_Wide_String (nv)); end convert; -------------------- -- Same_Strings -- -------------------- function Same_Strings (S, T : String) return Boolean is begin return S = T; end Same_Strings; ------------------- -- log_nominal -- ------------------- procedure log_nominal (statement : Base_Statement; category : Log_Category; message : String) is begin logger_access.all.log_nominal (driver => statement.dialect, category => category, message => CT.SUS (message)); end log_nominal; -------------------- -- bind_proceed -- -------------------- function bind_proceed (Stmt : Base_Statement; index : Positive) return Boolean is begin if not Stmt.successful_execution then raise PRIOR_EXECUTION_FAILED with "Use bind after 'execute' but before 'fetch_next'"; end if; if index > Stmt.crate.Last_Index then raise BINDING_COLUMN_NOT_FOUND with "Index" & index'Img & " is too high; only" & Stmt.crate.Last_Index'Img & " columns exist."; end if; return True; end bind_proceed; ------------------ -- bind_index -- ------------------ function bind_index (Stmt : Base_Statement; heading : String) return Positive is use type Markers.Cursor; cursor : Markers.Cursor; begin cursor := Stmt.headings_map.Find (Key => heading); if cursor = Markers.No_Element then raise BINDING_COLUMN_NOT_FOUND with "There is no column named '" & heading & "'."; end if; return Markers.Element (Position => cursor); end bind_index; --------------------------------- -- check_bound_column_access -- --------------------------------- procedure check_bound_column_access (absent : Boolean) is begin if absent then raise ILLEGAL_BIND_SQL with "Binding column with null access is illegal"; end if; end check_bound_column_access; ------------------------------------------------------ -- 23 bind functions (impossible to make generic) -- ------------------------------------------------------ procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte0_Access) is use type AR.NByte0_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte0, a00 => vaxx, v00 => False, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte1_Access) is use type AR.NByte1_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte1, a01 => vaxx, v01 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte2_Access) is use type AR.NByte2_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte2, a02 => vaxx, v02 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte3_Access) is use type AR.NByte3_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte3, a03 => vaxx, v03 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte4_Access) is use type AR.NByte4_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte4, a04 => vaxx, v04 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte8_Access) is use type AR.NByte8_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte8, a05 => vaxx, v05 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte1_Access) is use type AR.Byte1_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_byte1, a06 => vaxx, v06 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte2_Access) is use type AR.Byte2_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_byte2, a07 => vaxx, v07 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte3_Access) is use type AR.Byte3_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_byte3, a08 => vaxx, v08 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte4_Access) is use type AR.Byte4_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_byte4, a09 => vaxx, v09 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte8_Access) is use type AR.Byte8_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_byte8, a10 => vaxx, v10 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real9_Access) is use type AR.Real9_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_real9, a11 => vaxx, v11 => 0.0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real18_Access) is use type AR.Real18_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_real18, a12 => vaxx, v12 => 0.0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str1_Access) is use type AR.Str1_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_textual, a13 => vaxx, v13 => CT.blank, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str2_Access) is use type AR.Str2_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_widetext, a14 => vaxx, bound => True, v14 => AR.Blank_WString, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str4_Access) is use type AR.Str4_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_supertext, a15 => vaxx, bound => True, v15 => AR.Blank_WWString, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Time_Access) is use type AR.Time_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_timestamp, a16 => vaxx, v16 => CAL.Clock, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Chain_Access) is use type AR.Chain_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_chain, a17 => vaxx, v17 => CT.blank, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Enum_Access) is use type AR.Enum_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_enumtype, a18 => vaxx, bound => True, v18 => AR.PARAM_IS_ENUM, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Settype_Access) is use type AR.Settype_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_settype, a19 => vaxx, v19 => CT.blank, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Bits_Access) is use type AR.Bits_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_bits, a20 => vaxx, v20 => CT.blank, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.S_UTF8_Access) is use type AR.S_UTF8_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_utf8, a21 => vaxx, v21 => CT.blank, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Geometry_Access) is use type AR.Geometry_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_geometry, a22 => vaxx, v22 => CT.blank, bound => True, null_data => False)); end if; end bind; ------------------------------------------------------------------ -- bind via headings (believe me, generics are not possible) -- ------------------------------------------------------------------ procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte0_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte1_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte2_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte3_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte4_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte8_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Byte1_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Byte2_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Byte3_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Byte4_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Byte8_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Real9_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Real18_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Str1_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Str2_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Str4_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Time_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Chain_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Enum_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Settype_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Bits_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.S_UTF8_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Geometry_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; -------------------- -- assign_index -- -------------------- function assign_index (Stmt : Base_Statement; moniker : String) return Positive is use type Markers.Cursor; cursor : Markers.Cursor; begin cursor := Stmt.alpha_markers.Find (Key => moniker); if cursor = Markers.No_Element then raise MARKER_NOT_FOUND with "There is no marker known as '" & moniker & "'."; end if; return Markers.Element (Position => cursor); end assign_index; ------------------------------------------------------------------ -- assign via moniker (Access, 23) -- ------------------------------------------------------------------ procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte0_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte1_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte2_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte3_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte4_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte8_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte1_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte2_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte3_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte4_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte8_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Real9_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Real18_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Str1_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Str2_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Str4_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Time_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Chain_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Enum_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Settype_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Bits_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.S_UTF8_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Geometry_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; ------------------------------------------------------------------ -- assign via moniker (Value, 23) -- ------------------------------------------------------------------ procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte0) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte1) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte2) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte3) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte4) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte8) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte1) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte2) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte3) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte4) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte8) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Real9) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Real18) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Textual) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Textwide) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Textsuper) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : CAL.Time) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Chain) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Enumtype) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Settype) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Bits) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Text_UTF8) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : Spatial_Data.Geometry) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; ------------------------------------------------------ -- 23 + 23 = 46 assign functions -- ------------------------------------------------------ procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte0_Access) is use type AR.NByte0_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte0, a00 => vaxx, v00 => False, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte0) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte0, a00 => null, v00 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte1_Access) is use type AR.NByte1_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte1, a01 => vaxx, v01 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte1) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte1, a01 => null, v01 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte2_Access) is use type AR.NByte2_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte2, a02 => vaxx, v02 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte2) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte2, a02 => null, v02 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte3_Access) is use type AR.NByte3_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte3, a03 => vaxx, v03 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte3) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte3, a03 => null, v03 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte4_Access) is use type AR.NByte4_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte4, a04 => vaxx, v04 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte4) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte4, a04 => null, v04 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte8_Access) is use type AR.NByte8_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte8, a05 => vaxx, v05 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte8) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte8, a05 => null, v05 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte1_Access) is use type AR.Byte1_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte1, a06 => vaxx, v06 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte1) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte1, a06 => null, v06 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte2_Access) is use type AR.Byte2_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte2, a07 => vaxx, v07 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte2) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte2, a07 => null, v07 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte3_Access) is use type AR.Byte3_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte3, a08 => vaxx, v08 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte3) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte3, a08 => null, v08 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte4_Access) is use type AR.Byte4_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte4, a09 => vaxx, v09 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte4) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte4, a09 => null, v09 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte8_Access) is use type AR.Byte8_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte8, a10 => vaxx, v10 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte8) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte8, a10 => null, v10 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real9_Access) is use type AR.Real9_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_real9, a11 => vaxx, v11 => 0.0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real9) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_real9, a11 => null, v11 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real18_Access) is use type AR.Real18_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_real18, a12 => vaxx, v12 => 0.0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real18) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_real18, a12 => null, v12 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str1_Access) is use type AR.Str1_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_textual, a13 => vaxx, v13 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Textual) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_textual, a13 => null, v13 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str2_Access) is use type AR.Str2_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_widetext, a14 => vaxx, v14 => AR.Blank_WString, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Textwide) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_widetext, a14 => null, v14 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str4_Access) is use type AR.Str4_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_supertext, a15 => vaxx, bound => True, v15 => AR.Blank_WWString, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Textsuper) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_supertext, a15 => null, v15 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Time_Access) is use type AR.Time_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_timestamp, a16 => vaxx, v16 => CAL.Clock, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : CAL.Time) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_timestamp, a16 => null, v16 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Chain_Access) is use type AR.Chain_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_chain, a17 => vaxx, v17 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Chain) is payload : constant String := ARC.convert (vaxx); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_chain, a17 => null, v17 => CT.SUS (payload), bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Enum_Access) is use type AR.Enum_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_enumtype, a18 => vaxx, v18 => AR.PARAM_IS_ENUM, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Enumtype) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_enumtype, a18 => null, v18 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Settype_Access) is use type AR.Settype_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_settype, a19 => vaxx, v19 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Settype) is payload : AR.Textual := CT.blank; begin for x in vaxx'Range loop if x /= vaxx'First then CT.SU.Append (payload, ","); end if; CT.SU.Append (payload, vaxx (x).enumeration); end loop; Stmt.realmccoy.Replace_Element (index, (output_type => ft_settype, a19 => null, v19 => payload, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Bits_Access) is use type AR.Bits_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_bits, a20 => vaxx, v20 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Bits) is payload : constant String := ARC.convert (vaxx); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_bits, a20 => null, v20 => CT.SUS (payload), bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.S_UTF8_Access) is use type AR.S_UTF8_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_utf8, a21 => vaxx, v21 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Text_UTF8) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_utf8, a21 => null, v21 => CT.SUS (vaxx), bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Geometry_Access) is use type AR.Geometry_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_geometry, a22 => vaxx, v22 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : Spatial_Data.Geometry) is shape : String := Spatial_Data.Well_Known_Text (vaxx); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_geometry, a22 => null, v22 => CT.SUS (shape), bound => True, null_data => False)); end assign; ------------------ -- iterate #1 -- ------------------ overriding procedure iterate (Stmt : out Base_Statement; process : not null access procedure) is begin loop exit when not fetch_bound (Stmt => Base_Statement'Class (Stmt)); process.all; end loop; end iterate; ------------------ -- iterate #2 -- ------------------ overriding procedure iterate (Stmt : out Base_Statement; process : not null access procedure (row : ARS.Datarow)) is begin loop declare local_row : ARS.Datarow := fetch_next (Stmt => Base_Statement'Class (Stmt)); begin exit when local_row.data_exhausted; process.all (row => local_row); end; end loop; end iterate; ------------------- -- auto_assign -- ------------------- procedure auto_assign (Stmt : out Base_Statement; index : Positive; value : String) is zone : bindrec renames Stmt.realmccoy.Element (index); ST : AR.Textual; STW : AR.Textwide; STS : AR.Textsuper; hold : ARF.Variant; begin case zone.output_type is when ft_widetext => ST := CT.SUS (value); STW := SUW.To_Unbounded_Wide_String (ARC.convert (ST)); when ft_supertext => ST := CT.SUS (value); STS := SWW.To_Unbounded_Wide_Wide_String (ARC.convert (ST)); when ft_timestamp | ft_settype | ft_chain => null; when others => ST := CT.SUS (value); end case; case zone.output_type is when ft_nbyte0 => hold := (ft_nbyte0, ARC.convert (ST)); when ft_nbyte1 => hold := (ft_nbyte1, ARC.convert (ST)); when ft_nbyte2 => hold := (ft_nbyte2, ARC.convert (ST)); when ft_nbyte3 => hold := (ft_nbyte3, ARC.convert (ST)); when ft_nbyte4 => hold := (ft_nbyte4, ARC.convert (ST)); when ft_nbyte8 => hold := (ft_nbyte8, ARC.convert (ST)); when ft_byte1 => hold := (ft_byte1, ARC.convert (ST)); when ft_byte2 => hold := (ft_byte2, ARC.convert (ST)); when ft_byte3 => hold := (ft_byte3, ARC.convert (ST)); when ft_byte4 => hold := (ft_byte4, ARC.convert (ST)); when ft_byte8 => hold := (ft_byte8, ARC.convert (ST)); when ft_real9 => hold := (ft_real9, ARC.convert (ST)); when ft_real18 => hold := (ft_real18, ARC.convert (ST)); when ft_textual => hold := (ft_textual, ST); when ft_widetext => hold := (ft_widetext, STW); when ft_supertext => hold := (ft_supertext, STS); when ft_timestamp => hold := (ft_timestamp, (ARC.convert (value))); when ft_chain => null; when ft_enumtype => hold := (ft_enumtype, (ARC.convert (ST))); when ft_settype => null; when ft_bits => null; when ft_utf8 => hold := (ft_utf8, ST); when ft_geometry => hold := (ft_geometry, ST); -- ST=WKB end case; case zone.output_type is when ft_nbyte0 => Stmt.assign (index, hold.v00); when ft_nbyte1 => Stmt.assign (index, hold.v01); when ft_nbyte2 => Stmt.assign (index, hold.v02); when ft_nbyte3 => Stmt.assign (index, hold.v03); when ft_nbyte4 => Stmt.assign (index, hold.v04); when ft_nbyte8 => Stmt.assign (index, hold.v05); when ft_byte1 => Stmt.assign (index, hold.v06); when ft_byte2 => Stmt.assign (index, hold.v07); when ft_byte3 => Stmt.assign (index, hold.v08); when ft_byte4 => Stmt.assign (index, hold.v09); when ft_byte8 => Stmt.assign (index, hold.v10); when ft_real9 => Stmt.assign (index, hold.v11); when ft_real18 => Stmt.assign (index, hold.v12); when ft_textual => Stmt.assign (index, hold.v13); when ft_widetext => Stmt.assign (index, hold.v14); when ft_supertext => Stmt.assign (index, hold.v15); when ft_timestamp => Stmt.assign (index, hold.v16); when ft_enumtype => Stmt.assign (index, hold.v18); when ft_utf8 => Stmt.assign (index, hold.v21); when ft_geometry => Stmt.assign (index, hold.v22); when ft_chain => declare my_chain : AR.Chain := ARC.convert (value); begin Stmt.assign (index, my_chain); end; when ft_settype => declare set : AR.Settype := ARC.convert (value); begin Stmt.assign (index, set); end; when ft_bits => declare bitchain : AR.Bits := ARC.convert (value); begin Stmt.assign (index, bitchain); end; end case; end auto_assign; ------------------ -- set_as_null -- ------------------- procedure set_as_null (param : bindrec) is data_type : field_types := param.output_type; begin case data_type is when ft_nbyte0 => param.a00.all := AR.PARAM_IS_BOOLEAN; when ft_nbyte1 => param.a01.all := AR.PARAM_IS_NBYTE_1; when ft_nbyte2 => param.a02.all := AR.PARAM_IS_NBYTE_2; when ft_nbyte3 => param.a03.all := AR.PARAM_IS_NBYTE_3; when ft_nbyte4 => param.a04.all := AR.PARAM_IS_NBYTE_4; when ft_nbyte8 => param.a05.all := AR.PARAM_IS_NBYTE_8; when ft_byte1 => param.a06.all := AR.PARAM_IS_BYTE_1; when ft_byte2 => param.a07.all := AR.PARAM_IS_BYTE_2; when ft_byte3 => param.a08.all := AR.PARAM_IS_BYTE_3; when ft_byte4 => param.a09.all := AR.PARAM_IS_BYTE_4; when ft_byte8 => param.a10.all := AR.PARAM_IS_BYTE_8; when ft_real9 => param.a11.all := AR.PARAM_IS_REAL_9; when ft_real18 => param.a12.all := AR.PARAM_IS_REAL_18; when ft_textual => param.a13.all := AR.PARAM_IS_TEXTUAL; when ft_widetext => param.a14.all := AR.PARAM_IS_TEXTWIDE; when ft_supertext => param.a15.all := AR.PARAM_IS_TEXTSUPER; when ft_timestamp => param.a16.all := AR.PARAM_IS_TIMESTAMP; when ft_enumtype => param.a18.all := AR.PARAM_IS_ENUM; when ft_chain => param.a17.all := ARC.convert ("", param.a17.all'Length); when ft_settype => param.a19.all := ARC.convert ("", param.a19.all'Length); when ft_bits => param.a20.all := ARC.convert ("", param.a20.all'Length); when ft_utf8 => param.a21.all := AR.PARAM_IS_TEXT_UTF8; when ft_geometry => param.a22.all := GEO.initialize_as_point (GEO.Origin_Point); end case; end set_as_null; end AdaBase.Statement.Base;
src/Tactic/Reflection/DeBruijn.agda
lclem/agda-prelude
0
1246
module Tactic.Reflection.DeBruijn where open import Prelude hiding (abs) open import Builtin.Reflection open import Container.Traversable record DeBruijn {a} (A : Set a) : Set a where field strengthenFrom : (from n : Nat) → A → Maybe A weakenFrom : (from n : Nat) → A → A strengthen : Nat → A → Maybe A strengthen 0 = just strengthen n = strengthenFrom 0 n weaken : Nat → A → A weaken zero = id weaken n = weakenFrom 0 n open DeBruijn {{...}} public patternBindings : List (Arg Pattern) → Nat patternBindings = binds where binds : List (Arg Pattern) → Nat bind : Pattern → Nat binds [] = 0 binds (arg _ a ∷ as) = bind a + binds as bind (con c ps) = binds ps bind dot = 1 bind (var _) = 1 bind (lit l) = 0 bind (proj x) = 0 bind absurd = 0 private Str : Set → Set Str A = Nat → Nat → A → Maybe A strVar : Str Nat strVar lo n x = if x <? lo then just x else if x <? lo + n then nothing else just (x - n) strArgs : Str (List (Arg Term)) strArg : Str (Arg Term) strSort : Str Sort strClauses : Str (List Clause) strClause : Str Clause strAbsTerm : Str (Abs Term) strAbsType : Str (Abs Type) strTerm : Str Term strTerm lo n (var x args) = var <$> strVar lo n x <*> strArgs lo n args strTerm lo n (con c args) = con c <$> strArgs lo n args strTerm lo n (def f args) = def f <$> strArgs lo n args strTerm lo n (meta x args) = meta x <$> strArgs lo n args strTerm lo n (lam v t) = lam v <$> strAbsTerm lo n t strTerm lo n (pi a b) = pi <$> strArg lo n a <*> strAbsType lo n b strTerm lo n (agda-sort s) = agda-sort <$> strSort lo n s strTerm lo n (lit l) = just (lit l) strTerm lo n (pat-lam _ _) = just unknown -- todo strTerm lo n unknown = just unknown strAbsTerm lo n (abs s t) = abs s <$> strTerm (suc lo) n t strAbsType lo n (abs s t) = abs s <$> strTerm (suc lo) n t strArgs lo n [] = just [] strArgs lo n (x ∷ args) = _∷_ <$> strArg lo n x <*> strArgs lo n args strArg lo n (arg i v) = arg i <$> strTerm lo n v strSort lo n (set t) = set <$> strTerm lo n t strSort lo n (lit l) = just (lit l) strSort lo n unknown = just unknown strClauses lo k [] = just [] strClauses lo k (c ∷ cs) = _∷_ <$> strClause lo k c <*> strClauses lo k cs strClause lo k (clause ps b) = clause ps <$> strTerm (lo + patternBindings ps) k b strClause lo k (absurd-clause ps) = just (absurd-clause ps) private Wk : Set → Set Wk A = Nat → Nat → A → A wkVar : Wk Nat wkVar lo k x = if x <? lo then x else x + k wkArgs : Wk (List (Arg Term)) wkArg : Wk (Arg Term) wkSort : Wk Sort wkClauses : Wk (List Clause) wkClause : Wk Clause wkAbsTerm : Wk (Abs Term) wk : Wk Term wk lo k (var x args) = var (wkVar lo k x) (wkArgs lo k args) wk lo k (con c args) = con c (wkArgs lo k args) wk lo k (def f args) = def f (wkArgs lo k args) wk lo k (meta x args) = meta x (wkArgs lo k args) wk lo k (lam v t) = lam v (wkAbsTerm lo k t) wk lo k (pi a b) = pi (wkArg lo k a) (wkAbsTerm lo k b) wk lo k (agda-sort s) = agda-sort (wkSort lo k s) wk lo k (lit l) = lit l wk lo k (pat-lam cs args) = pat-lam (wkClauses lo k cs) (wkArgs lo k args) wk lo k unknown = unknown wkAbsTerm lo k (abs s t) = abs s (wk (suc lo) k t) wkArgs lo k [] = [] wkArgs lo k (x ∷ args) = wkArg lo k x ∷ wkArgs lo k args wkArg lo k (arg i v) = arg i (wk lo k v) wkSort lo k (set t) = set (wk lo k t) wkSort lo k (lit n) = lit n wkSort lo k unknown = unknown wkClauses lo k [] = [] wkClauses lo k (c ∷ cs) = wkClause lo k c ∷ wkClauses lo k cs wkClause lo k (clause ps b) = clause ps (wk (lo + patternBindings ps) k b) wkClause lo k (absurd-clause ps) = absurd-clause ps -- Instances -- DeBruijnTraversable : ∀ {a} {F : Set a → Set a} {{_ : Traversable F}} {A : Set a} {{_ : DeBruijn A}} → DeBruijn (F A) strengthenFrom {{DeBruijnTraversable}} lo k = traverse (strengthenFrom lo k) weakenFrom {{DeBruijnTraversable}} lo k = fmap (weakenFrom lo k) instance DeBruijnNat : DeBruijn Nat strengthenFrom {{DeBruijnNat}} = strVar weakenFrom {{DeBruijnNat}} = wkVar DeBruijnTerm : DeBruijn Term strengthenFrom {{DeBruijnTerm}} = strTerm weakenFrom {{DeBruijnTerm}} = wk DeBruijnList : ∀ {a} {A : Set a} {{_ : DeBruijn A}} → DeBruijn (List A) DeBruijnList = DeBruijnTraversable DeBruijnVec : ∀ {a} {A : Set a} {{_ : DeBruijn A}} {n : Nat} → DeBruijn (Vec A n) DeBruijnVec = DeBruijnTraversable DeBruijnArg : {A : Set} {{_ : DeBruijn A}} → DeBruijn (Arg A) DeBruijnArg = DeBruijnTraversable DeBruijnMaybe : {A : Set} {{_ : DeBruijn A}} → DeBruijn (Maybe A) DeBruijnMaybe = DeBruijnTraversable -- Strip bound names (to ensure _==_ checks α-equality) -- Doesn't touch pattern variables in pattern lambdas. mutual stripBoundNames : Term → Term stripBoundNames (var x args) = var x (stripArgs args) stripBoundNames (con c args) = con c (stripArgs args) stripBoundNames (def f args) = def f (stripArgs args) stripBoundNames (lam v t) = lam v (stripAbs t) stripBoundNames (pat-lam cs args) = pat-lam (stripClauses cs) (stripArgs args) stripBoundNames (pi a b) = pi (stripArg a) (stripAbs b) stripBoundNames (agda-sort s) = agda-sort (stripSort s) stripBoundNames (lit l) = lit l stripBoundNames (meta x args) = meta x (stripArgs args) stripBoundNames unknown = unknown private stripArgs : List (Arg Term) → List (Arg Term) stripArgs [] = [] stripArgs (x ∷ xs) = stripArg x ∷ stripArgs xs stripArg : Arg Term → Arg Term stripArg (arg i t) = arg i (stripBoundNames t) stripAbs : Abs Term → Abs Term stripAbs (abs _ t) = abs "" (stripBoundNames t) stripClauses : List Clause → List Clause stripClauses [] = [] stripClauses (x ∷ xs) = stripClause x ∷ stripClauses xs stripClause : Clause → Clause stripClause (clause ps t) = clause ps (stripBoundNames t) stripClause (absurd-clause ps) = absurd-clause ps stripSort : Sort → Sort stripSort (set t) = set (stripBoundNames t) stripSort (lit n) = lit n stripSort unknown = unknown
src/test/resources/BetaLexer.g4
google/polymorphicDSL
3
2799
lexer grammar BetaLexer; HELLO : 'Hello, ' ; WORLD : 'world!' ; END_OF_LINE : EOF -> skip;
programs/oeis/047/A047453.asm
neoneye/loda
22
171783
; A047453: Numbers that are congruent to {0, 1, 2, 3, 4} mod 8. ; 0,1,2,3,4,8,9,10,11,12,16,17,18,19,20,24,25,26,27,28,32,33,34,35,36,40,41,42,43,44,48,49,50,51,52,56,57,58,59,60,64,65,66,67,68,72,73,74,75,76,80,81,82,83,84,88,89,90,91,92,96,97,98,99,100,104,105,106,107,108,112,113,114,115,116,120,121,122,123,124,128,129,130,131,132,136,137,138,139,140,144,145,146,147,148,152,153,154,155,156 mov $1,$0 div $1,5 mul $1,3 add $0,$1
programs/oeis/099/A099925.asm
jmorken/loda
1
242852
; A099925: a(n) = Lucas(n) + (-1)^n. ; 3,0,4,3,8,10,19,28,48,75,124,198,323,520,844,1363,2208,3570,5779,9348,15128,24475,39604,64078,103683,167760,271444,439203,710648,1149850,1860499,3010348,4870848,7881195,12752044,20633238,33385283,54018520,87403804,141422323,228826128,370248450,599074579,969323028,1568397608,2537720635,4106118244,6643838878,10749957123,17393796000,28143753124,45537549123,73681302248,119218851370,192900153619,312119004988,505019158608,817138163595,1322157322204,2139295485798,3461452808003,5600748293800,9062201101804,14662949395603,23725150497408,38388099893010,62113250390419,100501350283428,162614600673848,263115950957275,425730551631124,688846502588398,1114577054219523,1803423556807920,2918000611027444,4721424167835363,7639424778862808 mov $1,$0 mov $2,$0 gcd $0,2 mod $2,2 cal $1,32 ; Lucas numbers beginning at 2: L(n) = L(n-1) + L(n-2), L(0) = 2, L(1) = 1. sub $2,8 sub $2,$0 sub $1,$2 sub $1,9
src/Native/Runtime/amd64/AllocFast.asm
ZZHGit/corert
0
7994
<reponame>ZZHGit/corert ;; ;; Copyright (c) Microsoft. All rights reserved. ;; Licensed under the MIT license. See LICENSE file in the project root for full license information. ;; include asmmacros.inc ;; Allocate non-array, non-finalizable object. If the allocation doesn't fit into the current thread's ;; allocation context then automatically fallback to the slow allocation path. ;; RCX == EEType LEAF_ENTRY RhpNewFast, _TEXT ;; rdx = GetThread(), TRASHES rax INLINE_GETTHREAD rdx, rax ;; ;; rcx contains EEType pointer ;; mov eax, [rcx + OFFSETOF__EEType__m_uBaseSize] ;; ;; eax: base size ;; rcx: EEType pointer ;; rdx: Thread pointer ;; add rax, [rdx + OFFSETOF__Thread__m_alloc_context__alloc_ptr] cmp rax, [rdx + OFFSETOF__Thread__m_alloc_context__alloc_limit] ja RhpNewFast_RarePath ;; set the new alloc pointer mov [rdx + OFFSETOF__Thread__m_alloc_context__alloc_ptr], rax ;; calc the new object pointer mov edx, dword ptr [rcx + OFFSETOF__EEType__m_uBaseSize] sub rax, rdx ;; set the new object's EEType pointer mov [rax], rcx ret RhpNewFast_RarePath: xor edx, edx jmp RhpNewObject LEAF_END RhpNewFast, _TEXT ;; Allocate non-array object with finalizer ;; RCX == EEType LEAF_ENTRY RhpNewFinalizable, _TEXT mov edx, GC_ALLOC_FINALIZE jmp RhpNewObject LEAF_END RhpNewFinalizable, _TEXT ;; Allocate non-array object ;; RCX == EEType ;; EDX == alloc flags NESTED_ENTRY RhpNewObject, _TEXT INLINE_GETTHREAD rax, r10 ; rax <- Thread pointer, r10 <- trashed mov r11, rax ; r11 <- Thread pointer PUSH_COOP_PINVOKE_FRAME rax, r10, no_extraStack ; rax <- in: Thread, out: trashed, r10 <- trashed END_PROLOGUE ; RCX: EEType ; EDX: alloc flags ; R11: Thread * ;; Preserve the EEType in RSI mov rsi, rcx mov r9, rcx ; pEEType mov r8d, edx ; uFlags mov edx, [rsi + OFFSETOF__EEType__m_uBaseSize] ; cbSize mov rcx, r11 ; pThread ;; Call the rest of the allocation helper. ;; void* RedhawkGCInterface::Alloc(Thread *pThread, UIntNative cbSize, UInt32 uFlags, EEType *pEEType) call REDHAWKGCINTERFACE__ALLOC ;; Set the new object's EEType pointer on success. test rax, rax jz NewOutOfMemory mov [rax + OFFSETOF__Object__m_pEEType], rsi ;; If the object is bigger than RH_LARGE_OBJECT_SIZE, we must publish it to the BGC mov edx, [rsi + OFFSETOF__EEType__m_uBaseSize] cmp rdx, RH_LARGE_OBJECT_SIZE jb New_SkipPublish mov rcx, rax ;; rcx: object ;; rdx: already contains object size call RhpPublishObject ;; rax: this function returns the object that was passed-in New_SkipPublish: POP_COOP_PINVOKE_FRAME no_extraStack ret NewOutOfMemory: ;; This is the OOM failure path. We're going to tail-call to a managed helper that will throw ;; an out of memory exception that the caller of this allocator understands. mov rcx, r9 ; EEType pointer xor edx, edx ; Indicate that we should throw OOM. POP_COOP_PINVOKE_FRAME no_extraStack jmp RhExceptionHandling_FailedAllocation NESTED_END RhpNewObject, _TEXT ;; Allocate one dimensional, zero based array (SZARRAY). ;; RCX == EEType ;; EDX == element count LEAF_ENTRY RhpNewArray, _TEXT ; we want to limit the element count to the non-negative 32-bit int range cmp rdx, 07fffffffh ja ArraySizeOverflow ; save element count mov r8, rdx ; Compute overall allocation size (align(base size + (element size * elements), 8)). movzx eax, word ptr [rcx + OFFSETOF__EEType__m_usComponentSize] mul rdx mov edx, [rcx + OFFSETOF__EEType__m_uBaseSize] add rax, rdx add rax, 7 and rax, -8 ; rax == array size ; rcx == EEType ; rdx == scratch ; r8 == element count INLINE_GETTHREAD rdx, r9 mov r9, rax add rax, [rdx + OFFSETOF__Thread__m_alloc_context__alloc_ptr] jc RhpNewArrayRare ; rax == new alloc ptr ; rcx == EEType ; rdx == thread ; r8 == element count ; r9 == array size cmp rax, [rdx + OFFSETOF__Thread__m_alloc_context__alloc_limit] ja RhpNewArrayRare mov [rdx + OFFSETOF__Thread__m_alloc_context__alloc_ptr], rax ; calc the new object pointer sub rax, r9 mov [rax + OFFSETOF__Object__m_pEEType], rcx mov [rax + OFFSETOF__Array__m_Length], r8d ret ArraySizeOverflow: ; We get here if the size of the final array object can't be represented as an unsigned ; 32-bit value. We're going to tail-call to a managed helper that will throw ; an overflow exception that the caller of this allocator understands. ; rcx holds EEType pointer already mov edx, 1 ; Indicate that we should throw OverflowException jmp RhExceptionHandling_FailedAllocation LEAF_END RhpNewArray, _TEXT NESTED_ENTRY RhpNewArrayRare, _TEXT ; rcx == EEType ; rdx == thread ; r8 == element count ; r9 == array size mov r11, rdx ; r11 <- Thread pointer PUSH_COOP_PINVOKE_FRAME rdx, r10, no_extraStack ; rdx <- in: Thread, out: trashed, r10 <- trashed END_PROLOGUE ; R11: Thread * ; Preserve the EEType in RSI mov rsi, rcx ; Preserve the size in RDI mov rdi, r9 ; Preserve the element count in RBX mov rbx, r8 mov rcx, r11 ; pThread mov rdx, r9 ; cbSize xor r8d, r8d ; uFlags mov r9, rsi ; pEEType ; Call the rest of the allocation helper. ; void* RedhawkGCInterface::Alloc(Thread *pThread, UIntNative cbSize, UInt32 uFlags, EEType *pEEType) call REDHAWKGCINTERFACE__ALLOC ; Set the new object's EEType pointer and length on success. test rax, rax jz ArrayOutOfMemory mov [rax + OFFSETOF__Object__m_pEEType], rsi mov [rax + OFFSETOF__Array__m_Length], ebx ;; If the object is bigger than RH_LARGE_OBJECT_SIZE, we must publish it to the BGC cmp rdi, RH_LARGE_OBJECT_SIZE jb NewArray_SkipPublish mov rcx, rax ;; rcx: object mov rdx, rdi ;; rdx: object size call RhpPublishObject ;; rax: this function returns the object that was passed-in NewArray_SkipPublish: POP_COOP_PINVOKE_FRAME no_extraStack ret ArrayOutOfMemory: ;; This is the OOM failure path. We're going to tail-call to a managed helper that will throw ;; an out of memory exception that the caller of this allocator understands. mov rcx, rsi ; EEType pointer xor edx, edx ; Indicate that we should throw OOM. POP_COOP_PINVOKE_FRAME no_extraStack jmp RhExceptionHandling_FailedAllocation NESTED_END RhpNewArrayRare, _TEXT END
data/pokemon/dex_entries/weavile.asm
AtmaBuster/pokeplat-gen2
6
14792
db "SHARP CLAW@" ; species name db "It lives in snowy" next "regions. It carves" next "patterns in trees" page "with its claws to" next "serve as a signal" next "to other #MON.@"
programs/oeis/056/A056021.asm
jmorken/loda
1
13659
<filename>programs/oeis/056/A056021.asm ; A056021: Numbers k such that k^4 == 1 (mod 5^2). ; 1,7,18,24,26,32,43,49,51,57,68,74,76,82,93,99,101,107,118,124,126,132,143,149,151,157,168,174,176,182,193,199,201,207,218,224,226,232,243,249,251,257,268,274,276,282,293,299,301,307,318,324,326,332,343,349,351,357,368,374,376,382,393,399,401,407,418,424,426,432,443,449,451,457,468,474,476,482,493,499,501,507,518,524,526,532,543,549,551,557,568,574,576,582,593,599,601,607,618,624,626,632,643,649,651,657,668,674,676,682,693,699,701,707,718,724,726,732,743,749,751,757,768,774,776,782,793,799,801,807,818,824,826,832,843,849,851,857,868,874,876,882,893,899,901,907,918,924,926,932,943,949,951,957,968,974,976,982,993,999,1001,1007,1018,1024,1026,1032,1043,1049,1051,1057,1068,1074,1076,1082,1093,1099,1101,1107,1118,1124,1126,1132,1143,1149,1151,1157,1168,1174,1176,1182,1193,1199,1201,1207,1218,1224,1226,1232,1243,1249,1251,1257,1268,1274,1276,1282,1293,1299,1301,1307,1318,1324,1326,1332,1343,1349,1351,1357,1368,1374,1376,1382,1393,1399,1401,1407,1418,1424,1426,1432,1443,1449,1451,1457,1468,1474,1476,1482,1493,1499,1501,1507,1518,1524,1526,1532,1543,1549,1551,1557 mov $2,$0 add $2,2 mov $3,5 mov $6,$0 mov $0,$2 add $0,1 lpb $0 add $0,1 trn $0,3 add $1,$4 sub $1,$3 mov $5,$1 mov $1,$3 trn $1,1 add $1,2 mov $3,$5 mov $4,$5 lpe lpb $6 add $1,6 sub $6,1 lpe sub $1,1
repository/src/main/java/org/apache/atlas/query/antlr4/AtlasDSLParser.g4
kirankumardg/apache-atlas-sources-1.1.0
0
4023
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ parser grammar AtlasDSLParser; options { tokenVocab=AtlasDSLLexer; } // Core rules identifier: ID ; operator: (K_LT | K_LTE | K_EQ | K_NEQ | K_GT | K_GTE | K_LIKE) ; sortOrder: K_ASC | K_DESC ; valueArray: K_LBRACKET ID (K_COMMA ID)* K_RBRACKET ; literal: BOOL | NUMBER | FLOATING_NUMBER | (ID | valueArray) ; // Composite rules limitClause: K_LIMIT NUMBER ; offsetClause: K_OFFSET NUMBER ; atomE: (identifier | literal) | K_LPAREN expr K_RPAREN ; multiERight: (K_STAR | K_DIV) atomE ; multiE: atomE multiERight* ; arithERight: (K_PLUS | K_MINUS) multiE ; arithE: multiE arithERight* ; comparisonClause: arithE operator arithE ; isClause: arithE (K_ISA | K_IS) identifier ; hasClause: arithE K_HAS identifier ; countClause: K_COUNT K_LPAREN K_RPAREN ; maxClause: K_MAX K_LPAREN expr K_RPAREN ; minClause: K_MIN K_LPAREN expr K_RPAREN ; sumClause: K_SUM K_LPAREN expr K_RPAREN ; exprRight: (K_AND | K_OR) compE ; hasRClause: K_HASR identifier; compE: comparisonClause | isClause | hasClause | arithE | countClause | maxClause | minClause | sumClause ; expr: compE exprRight* ; limitOffset: limitClause offsetClause? ; selectExpression: expr (K_AS identifier)? ; selectExpr: selectExpression (K_COMMA selectExpression)* ; aliasExpr: (identifier | literal) K_AS identifier ; orderByExpr: K_ORDERBY expr sortOrder? ; fromSrc: aliasExpr | (identifier | literal) ; whereClause: K_WHERE expr ; fromExpression: fromSrc whereClause? ; fromClause: K_FROM fromExpression ; selectClause: K_SELECT selectExpr ; hasRExpression: hasRClause (K_AS identifier)? ; singleQrySrc: fromClause | hasRExpression | whereClause | fromExpression | expr ; groupByExpression: K_GROUPBY K_LPAREN selectExpr K_RPAREN ; commaDelimitedQueries: singleQrySrc (K_COMMA singleQrySrc)* ; spaceDelimitedQueries: singleQrySrc singleQrySrc* ; querySrc: commaDelimitedQueries | spaceDelimitedQueries ; query: querySrc groupByExpression? selectClause? orderByExpr? limitOffset? EOF;
Function/Equivalence/Reasoning.agda
splintah/combinatory-logic
1
4087
------------------------------------------------------------------------ -- Reasoning about _⇔_ -- -- NOTE: we don’t use Relation.Binary.IsEquivalence here, since we’re reasoning -- about a heterogeneous equivalence relation (i.e., the types of the operands -- of _⇔_, which are themselves types, can be of different levels). In the proof -- of Chapter₁₅.problem₁, the fact that _⇔_ is heterogeneous is actually used, -- so we cannot use a homogeneous version of _⇔_. ------------------------------------------------------------------------ module Function.Equivalence.Reasoning where open import Function using (_⇔_) open import Function.Construct.Composition using (_∘-⇔_) public open import Function.Construct.Identity using (id-⇔) public open import Function.Construct.Symmetry using (sym-⇔) public open import Level using (Level) private variable a b c : Level infix 1 begin_ infixr 2 _⇔⟨⟩_ step-⇔ step-⇔˘ infix 3 _∎ begin_ : {A : Set a} {B : Set b} → A ⇔ B → A ⇔ B begin A⇔B = A⇔B _∎ : (A : Set a) → A ⇔ A _∎ = id-⇔ _⇔⟨⟩_ : (A : Set a) {B : Set b} → A ⇔ B → A ⇔ B A ⇔⟨⟩ A⇔B = A⇔B step-⇔ : (A : Set a) {B : Set b} {C : Set c} → A ⇔ B → B ⇔ C → A ⇔ C step-⇔ A = _∘-⇔_ syntax step-⇔ A A⇔B B⇔C = A ⇔⟨ A⇔B ⟩ B⇔C step-⇔˘ : (A : Set a) {B : Set b} {C : Set c} → B ⇔ A → B ⇔ C → A ⇔ C step-⇔˘ A B⇔A B⇔C = A ⇔⟨ sym-⇔ B⇔A ⟩ B⇔C syntax step-⇔˘ A B⇔A B⇔C = A ⇔˘⟨ B⇔A ⟩ B⇔C
Working Disassembly/General/Sprites/Corkey/Map - Corkey.asm
TeamASM-Blur/Sonic-3-Blue-Balls-Edition
5
85598
<gh_stars>1-10 Map_3605C2: dc.w Frame_3605D2-Map_3605C2 ; ... dc.w Frame_3605E0-Map_3605C2 dc.w Frame_3605E8-Map_3605C2 dc.w Frame_3605F0-Map_3605C2 dc.w Frame_3605F8-Map_3605C2 dc.w Frame_360618-Map_3605C2 dc.w Frame_360638-Map_3605C2 dc.w Frame_360658-Map_3605C2 Frame_3605D2: dc.w 2 dc.b $F8, 5, 0, 0,$FF,$F0 dc.b $F8, 5, 8, 0, 0, 0 Frame_3605E0: dc.w 1 dc.b $FC, 4, 0, 4,$FF,$F8 Frame_3605E8: dc.w 1 dc.b $FC, 4, 0, 6,$FF,$F8 Frame_3605F0: dc.w 1 dc.b $FC, 4, 0, 8,$FF,$F8 Frame_3605F8: dc.w 5 dc.b $B0, 3, 0, $A,$FF,$FC dc.b $D0, 3, 0, $A,$FF,$FC dc.b $F0, 3, 0, $A,$FF,$FC dc.b $10, 3, 0, $A,$FF,$FC dc.b $30, 3, 0, $A,$FF,$FC Frame_360618: dc.w 5 dc.b $B0, 3, 0, $E,$FF,$FC dc.b $D0, 3, 0, $E,$FF,$FC dc.b $F0, 3, 0, $E,$FF,$FC dc.b $10, 3, 0, $E,$FF,$FC dc.b $30, 3, 0, $E,$FF,$FC Frame_360638: dc.w 5 dc.b $B0, 3, 0,$12,$FF,$FC dc.b $D0, 3, 0,$12,$FF,$FC dc.b $F0, 3, 0,$12,$FF,$FC dc.b $10, 3, 0,$12,$FF,$FC dc.b $30, 3, 0,$12,$FF,$FC Frame_360658: dc.w 0
musiced/keys.asm
nanoflite/victracker
1
173269
<reponame>nanoflite/victracker ;************************************************************************** ;* ;* FILE keys.asm ;* Copyright (c) 1994, 2001, 2003 <NAME> <<EMAIL>> ;* Written by <NAME> <<EMAIL>> ;* $Id: keys.asm,v 1.19 2003/08/04 23:22:36 tlr Exp $ ;* ;* DESCRIPTION ;* Handle keys global to the editor. ;* ;****** IFCONST HAVEDOCS ;************************************************************************** ;* ;* Docs ;* ;****** CheckDocKeys: cmp #"H" beq cdk_ShowDoc cmp #0 rts cdk_ShowDoc: jsr ViewDocs jsr ShowScreen jsr StartEdit lda #0 rts ENDIF ;HAVEDOCS ;************************************************************************** ;* ;* PlayerStuff ;* ;****** CheckPlayKeys: cmp #"M" beq cpk_InitMusic cmp #"P" beq cpk_ToggleMusic cmp #"V" beq cpk_ToggleColorFlag cmp #171 ; C= Q beq cpk_Mute1 cmp #179 ; C= W beq cpk_Mute2 cmp #177 ; C= E beq cpk_Mute3 cmp #178 ; C= R beq cpk_Mute4 jmp CheckSongConfKeys ;Start music from the beginning, reset mutes. cpk_InitMusic: lda #0 sta pl_Mute sta pl_Mute+1 sta pl_Mute+2 sta pl_Mute+3 jsr pl_Init jmp cpk_ex1 ;Toggle music on/off, do not change mutes. cpk_ToggleMusic: lda pl_PlayFlag eor #$ff pha jsr pl_Init pla sta pl_PlayFlag cpk_ex1: lda #0 rts ;Toggle ColorFlag on/off. cpk_ToggleColorFlag: lda Int_ColorFlag eor #$ff sta Int_ColorFlag jmp cpk_ex1 ;Toggle mute for voice 1 cpk_Mute1: ldy #0 dc.b $2c ; bit $xxxx ;Toggle mute for voice 2 cpk_Mute2: ldy #1 dc.b $2c ; bit $xxxx ;Toggle mute for voice 3 cpk_Mute3: ldy #2 dc.b $2c ; bit $xxxx ;Toggle mute for voice 3 cpk_Mute4: ldy #3 lda pl_Mute,y eor #$ff sta pl_Mute,y jmp cpk_ex1 CheckSongConfKeys: cmp #176 ; C= A beq cpk_SongUp cmp #174 ; C= S beq cpk_SongDown cmp #172 ; C= D beq cpk_NumUp cmp #187 ; C= F beq cpk_NumDown cmp #165 ; C= G bne cpk_skp7 jmp cpk_PlayModeUp cpk_skp7: cmp #180 ; C= H bne cpk_skp8 jmp cpk_PlayModeDown cpk_skp8: IFCONST HAVESCALE cmp #181 ; C= J bne cpk_skp9 jmp cpk_ScaleUp cpk_skp9: cmp #181 ; C= J bne cpk_skp10 jmp cpk_ScaleDown cpk_skp10: ENDIF ;HAVESCALE cmp #0 rts ;Increase the current Song Number (cycle 0..pl_SongNum-1) cpk_SongUp: inc pl_ThisSong lda pl_ThisSong cmp pl_SongNum bne cpk_ex1 lda #0 sta pl_ThisSong jmp cpk_ex1 ;Decrease the current Song Number (cycle 0..pl_SongNum-1) cpk_SongDown: lda pl_ThisSong beq cpk_skp1 dec pl_ThisSong jmp cpk_ex1 cpk_skp1: lda pl_SongNum sta pl_ThisSong dec pl_ThisSong jmp cpk_ex1 ;Increase the Number of songs (cycle 1..14) cpk_NumUp: inc pl_SongNum lda pl_SongNum cmp #14+1 bne cpk_ex3 lda #1 sta pl_SongNum jmp cpk_ex3 ;Decrease the Number of songs (cycle 1..14) cpk_NumDown: dec pl_SongNum bne cpk_ex3 lda #14 sta pl_SongNum jmp cpk_ex3 ;Increase the playmode (cycle 0..NUMPLAYMODES-1) cpk_PlayModeUp: inc pl_PlayMode lda pl_PlayMode cmp #NUMPLAYMODES bne cpk_ex2 lda #0 sta pl_PlayMode jmp cpk_ex2 ;Decrease the playmode (cycle 0..NUMPLAYMODES-1) cpk_PlayModeDown: dec pl_PlayMode bpl cpk_ex2 lda #NUMPLAYMODES-1 sta pl_PlayMode jmp cpk_ex2 IFCONST HAVESCALE ;Increase the scale (cycle 0..NUMSCALES-1) cpk_ScaleUp: inc pl_Scale lda pl_Scale cmp #NUMSCALES bne cpk_ex2 lda #0 sta pl_Scale ENDIF ;HAVESCALE cpk_ex2: jsr InterruptInit cpk_ex3: jmp cpk_ex1 ;************************************************************************** ;* ;* DiskStuff ;* ;****** CheckDiskKeys: cmp #204 ;Shift L beq cdk_LoadTune cmp #211 ;Shift S beq cdk_SaveTune cmp #196 ;Shift D beq cdk_Directory cmp #201 ;Shift I beq cdk_InitTune cmp #0 rts cdk_LoadTune: jsr pl_UnInit jsr InterruptUnInit jsr LoadTune jmp cdk_ex2 cdk_SaveTune: jsr pl_UnInit jsr InterruptUnInit jsr SaveTune jmp cdk_ex2 cdk_Directory: jsr pl_UnInit jsr InterruptUnInit jsr ShowDir lda #147 jsr $ffd2 jmp cdk_ex1 cdk_InitTune: jsr pl_UnInit jsr InterruptUnInit jsr InitTune cdk_ex1: jsr ShowScreen cdk_ex2: jsr PrintPlayer jsr StartEdit jsr InterruptInit lda #0 rts ;************************************************************************** ;* ;* Function keys ;* ;****** CheckEditKeys: pha lda pl_ThisSong ;X=pl_ThisSong*4 asl asl tax pla cmp #133 ;F1 beq cek_SetStep cmp #134 ;F3 beq cek_SetStartStep cmp #138 ;F4 beq cek_SetRepeatStep cmp #135 ;F5 beq cek_SetEndStep cmp #139 ;F6 beq cek_ToggleRepeatMode cmp #136 ;F7 beq cek_IncSpeed cmp #140 ;F8 beq cek_DecSpeed cmp #0 rts cek_SetStep: lda pl_StartStep,x pha lda LastPattListLine sta pl_StartStep,x txa pha jsr pl_Init pla tax pla sta pl_StartStep,x sta pl_ThisStartStep jmp cek_ex1 cek_SetStartStep: lda LastPattListLine sta pl_StartStep,x sta pl_ThisStartStep jmp cek_ex1 cek_SetRepeatStep: lda LastPattListLine sta pl_RepeatStep,x sta pl_ThisRepeatStep jmp cek_ex1 cek_SetEndStep: lda LastPattListLine sta pl_EndStep,x sta pl_ThisEndStep jmp cek_ex1 cek_ToggleRepeatMode: jsr cek_SpeedPrepare lda cek_SpeedTmp2 clc adc #$40 cmp #$80 ; $c0 if halt is implied! bne cek_skp2 lda #$00 cek_skp2: sta cek_SpeedTmp2 jmp cek_ex2 cek_IncSpeed: jsr cek_SpeedPrepare inc cek_SpeedTmp1 jmp cek_ex2 cek_DecSpeed: jsr cek_SpeedPrepare dec cek_SpeedTmp1 cek_ex2: lda cek_SpeedTmp1 and #$3f ora cek_SpeedTmp2 sta pl_StartSpeed,x sta pl_ThisStartSpeed cek_ex1: lda #0 rts cek_SpeedPrepare: lda pl_StartSpeed,x pha and #$3f sta cek_SpeedTmp1 pla and #$c0 sta cek_SpeedTmp2 rts cek_SpeedTmp1: dc.b 0 cek_SpeedTmp2: dc.b 0 ; eof
compsci courses/CPSC355 - Computing Machinery/misc/otherresources/week5/Separate Compilation/compsec.asm
q-omar/UofC
1
18830
<reponame>q-omar/UofC .balign 4 .data .global a_m a_m: .word 404 // global constant .text .global myfunc myfunc: stp x29, x30, [sp, -16]! mov x29, sp add w0, w0, 10 ldp x29, x30, [sp], 16 ret
Sources/Globe_3d/gl/gl-math.ads
ForYouEyesOnly/Space-Convoy
1
16954
with Ada.Numerics.Generic_Elementary_Functions; with Ada.Text_IO; package GL.Math is package REF is new Ada.Numerics.Generic_Elementary_Functions (Double); package RIO is new Ada.Text_IO.Float_IO (Double); ------------- -- Vectors -- ------------- function "*" (l : Double; v : Double_Vector_3D) return Double_Vector_3D; pragma Inline ("*"); function "*" (v : Double_Vector_3D; l : Double) return Double_Vector_3D; pragma Inline ("*"); function "+" (a, b : Double_Vector_3D) return Double_Vector_3D; pragma Inline ("+"); function "-" (a : Double_Vector_3D) return Double_Vector_3D; pragma Inline ("-"); function "-" (a, b : Double_Vector_3D) return Double_Vector_3D; pragma Inline ("-"); function "*" (a, b : Double_Vector_3D) return Double; -- dot product pragma Inline ("*"); function "*" (a, b : Double_Vector_3D) return Double_Vector_3D; -- cross product pragma Inline ("*"); function Norm (a : Double_Vector_3D) return Double; pragma Inline (Norm); function Norm2 (a : Double_Vector_3D) return Double; pragma Inline (Norm2); function Normalized (a : Double_Vector_3D) return Double_Vector_3D; type Vector_4D is array (0 .. 3) of Double; -- Angles -- function Angle (Point_1, Point_2, Point_3 : Double_Vector_3D) return Double; -- -- returns the angle between the vector Point_1 to Point_2 and the vector Point_3 to Point_2. function to_Degrees (Radians : Double) return Double; function to_Radians (Degrees : Double) return Double; -------------- -- Matrices -- -------------- type Matrix is array (Positive range <>, Positive range <>) of aliased Double; type Matrix_33 is new Matrix (1 .. 3, 1 .. 3); type Matrix_44 is new Matrix (1 .. 4, 1 .. 4); -- type Matrix_44 is array (0 .. 3, 0 .. 3) of aliased Double; -- for GL.MultMatrix pragma Convention (Fortran, Matrix_44); -- GL stores matrices columnwise -- tbd : use same convention for other matrices ? Id_33 : constant Matrix_33 := ((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)); function "*" (A, B : Matrix_33) return Matrix_33; function "*" (A : Matrix_33; x : Double_Vector_3D) return Double_Vector_3D; function "*" (A : Matrix_44; x : Double_Vector_3D) return Double_Vector_3D; function "*" (A : Matrix_44; x : Double_Vector_3D) return Vector_4D; function Transpose (A : Matrix_33) return Matrix_33; function Transpose (A : Matrix_44) return Matrix_44; function Det (A : Matrix_33) return Double; function XYZ_rotation (ax, ay, az : Double) return Matrix_33; function XYZ_rotation (v : Double_Vector_3D) return Matrix_33; -- Gives a rotation matrix that corresponds to look into a certain -- direction. Camera swing rotation is arbitrary. -- Left - multiply by XYZ_Rotation (0.0, 0.0, az) to correct it. function Look_at (direction : Double_Vector_3D) return Matrix_33; function Look_at (eye, center, up : Double_Vector_3D) return Matrix_33; -- This is for correcting cumulation of small computational -- errors, making the rotation matrix no more orthogonal procedure Re_Orthonormalize (M : in out Matrix_33); -- Right - multiply current matrix by A procedure Multiply_GL_Matrix (A : Matrix_33); -- Impose A as current matrix procedure Set_GL_Matrix (A : Matrix_33); -- For replacing the " = 0.0" test which is a Bad Thing function Almost_zero (x : Double) return Boolean; pragma Inline (Almost_zero); function Almost_zero (x : GL.C_Float) return Boolean; pragma Inline (Almost_zero); function Sub_Matrix (Self : Matrix; start_Row, end_Row : Positive; start_Col, end_Col : Positive) return Matrix; end GL.Math;
src/pp/block6/cc/pascal/SimplePascal6.g4
Pieterjaninfo/PP
0
3191
<filename>src/pp/block6/cc/pascal/SimplePascal6.g4 grammar SimplePascal6; //@header{package pp.block6.cc.pascal;} /** Pascal program. */ program : PROGRAM ID SEMI body DOT EOF ; /** Body of a program. */ body : varDecl* block ; /** Variable declaration block. */ varDecl : VAR (var SEMI)+ ; /** Variable declaration. */ var : ID (COMMA ID)* COLON type ; /** Grouped sequence of statements. */ block : BEGIN stat (SEMI stat)* END ; /** Statement. */ stat: target ASS expr #assStat | IF expr THEN stat (ELSE stat)? #ifStat | WHILE expr DO stat #whileStat | block #blockStat | IN LPAR STR COMMA target RPAR #inStat // auxiliary, not Pascal | OUT LPAR STR COMMA expr RPAR #outStat // auxiliary, not Pascal ; /** Target of an assignment. */ target : ID #idTarget ; /** Expression. */ expr: prfOp expr #prfExpr | expr multOp expr #multExpr | expr plusOp expr #plusExpr | expr compOp expr #compExpr | expr boolOp expr #boolExpr | LPAR expr RPAR #parExpr | ID #idExpr | NUM #numExpr | TRUE #trueExpr | FALSE #falseExpr ; /** Prefix operator. */ prfOp: MINUS | NOT; /** Multiplicative operator. */ multOp: STAR | SLASH | MOD; /** Additive operator. */ plusOp: PLUS | MINUS; /** Boolean operator. */ boolOp: AND | OR; /** Comparison operator. */ compOp: LE | LT | GE | GT | EQ | NE; /** Data type. */ type: INTEGER #intType | BOOLEAN #boolType ; // Keywords AND: A N D; BEGIN: B E G I N ; BOOLEAN: B O O L E A N ; DO: D O ; ELSE: E L S E ; END: E N D ; EXIT: E X I T ; FALSE: F A L S E ; FUNC: F U N C T I O N ; IN: I N ; INTEGER: I N T E G E R ; IF: I F ; MOD: M O D ; NOT: N O T ; OR: O R ; OUT: O U T ; THEN: T H E N ; PROC: P R O C E D U R E ; PROGRAM: P R O G R A M ; TRUE: T R U E ; VAR: V A R ; WHILE: W H I L E ; ASS: ':='; COLON: ':'; COMMA: ','; DOT: '.'; DQUOTE: '"'; EQ: '='; GE: '>='; GT: '>'; LE: '<='; LBRACE: '{'; LPAR: '('; LT: '<'; MINUS: '-'; NE: '<>'; PLUS: '+'; RBRACE: '}'; RPAR: ')'; SEMI: ';'; SLASH: '/'; STAR: '*'; // Content-bearing token types ID: LETTER (LETTER | DIGIT)*; NUM: DIGIT (DIGIT)*; STR: DQUOTE .*? DQUOTE; fragment LETTER: [a-zA-Z]; fragment DIGIT: [0-9]; // Skipped token types COMMENT: LBRACE .*? RBRACE -> skip; WS: [ \t\r\n]+ -> skip; fragment A: [aA]; fragment B: [bB]; fragment C: [cC]; fragment D: [dD]; fragment E: [eE]; fragment F: [fF]; fragment G: [gG]; fragment H: [hH]; fragment I: [iI]; fragment J: [jJ]; fragment K: [kK]; fragment L: [lL]; fragment M: [mM]; fragment N: [nN]; fragment O: [oO]; fragment P: [pP]; fragment Q: [qQ]; fragment R: [rR]; fragment S: [sS]; fragment T: [tT]; fragment U: [uU]; fragment V: [vV]; fragment W: [wW]; fragment X: [xX]; fragment Y: [yY]; fragment Z: [zZ];
1-base/math/source/precision/float/pure/float_math-arithmetic.ads
charlie5/lace
20
15260
<gh_stars>10-100 with any_Math.any_Arithmetic; package float_Math.Arithmetic is new float_Math.any_Arithmetic; pragma Pure (float_Math.Arithmetic);
Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_21829_1651.asm
ljhsiun2/medusa
9
6530
<reponame>ljhsiun2/medusa<filename>Transynther/x86/_processed/NONE/_xt_/i7-8650U_0xd2_notsx.log_21829_1651.asm .global s_prepare_buffers s_prepare_buffers: push %r15 push %r8 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x996b, %rsi lea addresses_D_ht+0x90eb, %rdi nop nop nop nop xor $57468, %r15 mov $26, %rcx rep movsw nop nop nop nop nop sub %rbx, %rbx lea addresses_A_ht+0x19aeb, %rsi lea addresses_WT_ht+0x1b56b, %rdi nop nop nop and %rdx, %rdx mov $7, %rcx rep movsw nop and $49473, %rbx lea addresses_D_ht+0xcb6b, %r15 nop nop nop nop sub %r8, %r8 mov (%r15), %rsi nop nop nop and $17349, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r8 pop %r15 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r9 push %rdi push %rsi // Faulty Load lea addresses_WT+0xcd6b, %rsi clflush (%rsi) nop add $56617, %rdi vmovups (%rsi), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $1, %xmm7, %r11 lea oracles, %rsi and $0xff, %r11 shlq $12, %r11 mov (%rsi,%r11,1), %r11 pop %rsi pop %rdi pop %r9 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 8, 'AVXalign': True, 'NT': True, 'congruent': 9, 'same': False}} {'39': 21829} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
test/Fail/Issue2993.agda
shlevy/agda
1,989
11190
<gh_stars>1000+ id : forall {k}{X : Set k} -> X -> X id x = x _o_ : forall {i j k} {A : Set i}{B : A -> Set j}{C : (a : A) -> B a -> Set k} -> (f : {a : A}(b : B a) -> C a b) -> (g : (a : A) -> B a) -> (a : A) -> C a (g a) f o g = \ a -> f (g a) data List (X : Set) : Set where [] : List X _,_ : X → List X → List X data Nat : Set where zero : Nat suc : Nat → Nat {-# BUILTIN NATURAL Nat #-} data Vec (X : Set) : Nat -> Set where [] : Vec X 0 _,_ : { n : Nat } → X → Vec X n → Vec X (suc n) vec : forall { n X } → X → Vec X n vec {zero} a = [] vec {suc n} a = a , vec a vapp : forall { n S T } → Vec (S → T) n → Vec S n → Vec T n vapp [] [] = [] vapp (x , st) (x₁ , s) = x x₁ , vapp st s record Applicative (F : Set → Set) : Set₁ where infixl 2 _⊛_ field pure : forall { X } → X → F X _⊛_ : forall { S T } → F (S → T) → F S → F T open Applicative {{...}} public instance applicativeVec : forall { n } → Applicative (λ X → Vec X n) applicativeVec = record { pure = vec; _⊛_ = vapp } instance applicativeComp : forall {F G} {{_ : Applicative F}} {{_ : Applicative G}} → Applicative (F o G) applicativeComp {{af}} {{ag}} = record { pure = λ z → Applicative.pure af (Applicative.pure ag z) ; _⊛_ = λ z → {!!} } record Traversable (T : Set → Set) : Set1 where field traverse : forall { F A B } {{ AF : Applicative F }} → (A → F B) → T A → F (T B) open Traversable {{...}} public instance traversableVec : forall {n} → Traversable (\X → Vec X n) traversableVec = record { traverse = vtr } where vtr : forall { n F A B } {{ AF : Applicative F }} → (A → F B) → Vec A n → F (Vec B n) vtr {{AF}} f [] = Applicative.pure AF [] vtr {{AF}} f (x , v) = Applicative._⊛_ AF (Applicative._⊛_ AF (Applicative.pure AF _,_) (f x)) (vtr f v)
programs/oeis/078/A078181.asm
neoneye/loda
22
243409
<reponame>neoneye/loda ; A078181: Sum_{d|n, d=1 mod 3} d. ; 1,1,1,5,1,1,8,5,1,11,1,5,14,8,1,21,1,1,20,15,8,23,1,5,26,14,1,40,1,11,32,21,1,35,8,5,38,20,14,55,1,8,44,27,1,47,1,21,57,36,1,70,1,1,56,40,20,59,1,15,62,32,8,85,14,23,68,39,1,88,1,5,74,38,26,100,8,14,80,71,1,83,1,40,86,44,1,115,1,11,112,51,32,95,20,21,98,57,1,140 add $0,1 mul $0,3 mov $2,$0 lpb $0 sub $0,2 mov $3,$2 dif $3,$0 cmp $3,$2 cmp $3,0 mul $3,$0 sub $0,1 add $1,$3 mov $4,1 lpe lpb $4 add $1,1 trn $4,6 lpe mov $0,$1
programs/oeis/066/A066827.asm
karttu/loda
1
88449
; A066827: a(n) = gcd(2^((n*(n+1)/2)) + 1, 2^n + 1). ; 3,1,1,1,33,1,1,1,513,1,1,1,8193,1,1,1,131073,1,1,1,2097153,1,1,1,33554433,1,1,1,536870913,1,1,1,8589934593,1,1,1,137438953473,1,1,1,2199023255553,1,1,1,35184372088833,1,1,1,562949953421313,1,1,1,9007199254740993,1,1,1 mov $1,2 pow $1,$0 gcd $0,4 div $0,4 mul $0,$1 mov $1,$0 mul $1,2 add $1,1
shardingsphere-sql-parser/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/PostgreSQLKeyword.g4
rohithbalaji123/incubator-shardingsphere
0
5587
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ lexer grammar PostgreSQLKeyword; import Alphabet; ADMIN : A D M I N ; BINARY : B I N A R Y ; ESCAPE : E S C A P E ; EXISTS : E X I S T S ; EXCLUDE : E X C L U D E ; MOD : M O D ; PARTITION : P A R T I T I O N ; ROW : R O W ; UNKNOWN : U N K N O W N ; ALWAYS : A L W A Y S ; CASCADE : C A S C A D E ; CHECK : C H E C K ; GENERATED : G E N E R A T E D ; ISOLATION : I S O L A T I O N ; LEVEL : L E V E L ; NO : N O ; OPTION : O P T I O N ; PRIVILEGES : P R I V I L E G E S ; READ : R E A D ; REFERENCES : R E F E R E N C E S ; ROLE : R O L E ; ROWS : R O W S ; START : S T A R T ; TRANSACTION : T R A N S A C T I O N ; USER : U S E R ; ACTION : A C T I O N ; CACHE : C A C H E ; CHARACTERISTICS : C H A R A C T E R I S T I C S ; CLUSTER : C L U S T E R ; COLLATE : C O L L A T E ; COMMENTS : C O M M E N T S ; CONCURRENTLY : C O N C U R R E N T L Y ; CONNECT : C O N N E C T ; CONSTRAINTS : C O N S T R A I N T S ; CURRENT_TIMESTAMP : C U R R E N T UL_ T I M E S T A M P ; CYCLE : C Y C L E ; DATA : D A T A ; DATABASE : D A T A B A S E ; DEFAULTS : D E F A U L T S ; DEFERRABLE : D E F E R R A B L E ; DEFERRED : D E F E R R E D ; DEPENDS : D E P E N D S ; DOMAIN : D O M A I N ; EXCLUDING : E X C L U D I N G ; EXECUTE : E X E C U T E ; EXTENDED : E X T E N D E D ; EXTENSION : E X T E N S I O N ; EXTERNAL : E X T E R N A L ; EXTRACT : E X T R A C T ; FILTER : F I L T E R ; FIRST : F I R S T ; FOLLOWING : F O L L O W I N G ; FORCE : F O R C E ; GLOBAL : G L O B A L ; IDENTITY : I D E N T I T Y ; IMMEDIATE : I M M E D I A T E ; INCLUDING : I N C L U D I N G ; INCREMENT : I N C R E M E N T ; INDEXES : I N D E X E S ; INHERIT : I N H E R I T ; INHERITS : I N H E R I T S ; INITIALLY : I N I T I A L L Y ; INCLUDE : I N C L U D E ; LANGUAGE : L A N G U A G E ; LARGE : L A R G E ; LAST : L A S T ; LOGGED : L O G G E D ; MAIN : M A I N ; MATCH : M A T C H ; MAXVALUE : M A X V A L U E ; MINVALUE : M I N V A L U E ; NOTHING : N O T H I N G ; NULLS : N U L L S ; OBJECT : O B J E C T ; OIDS : O I D S ; ONLY : O N L Y ; OVER : O V E R ; OWNED : O W N E D ; OWNER : O W N E R ; PARTIAL : P A R T I A L ; PLAIN : P L A I N ; PRECEDING : P R E C E D I N G ; RANGE : R A N G E ; RENAME : R E N A M E ; REPLICA : R E P L I C A ; RESET : R E S E T ; RESTART : R E S T A R T ; RESTRICT : R E S T R I C T ; ROUTINE : R O U T I N E ; RULE : R U L E ; SECURITY : S E C U R I T Y ; SEQUENCE : S E Q U E N C E ; SESSION : S E S S I O N ; SESSION_USER : S E S S I O N UL_ U S E R ; SHOW : S H O W ; SIMPLE : S I M P L E ; STATISTICS : S T A T I S T I C S ; STORAGE : S T O R A G E ; TABLESPACE : T A B L E S P A C E ; TEMP : T E M P ; TEMPORARY : T E M P O R A R Y ; UNBOUNDED : U N B O U N D E D ; UNLOGGED : U N L O G G E D ; USAGE : U S A G E ; VALID : V A L I D ; VALIDATE : V A L I D A T E ; WITHIN : W I T H I N ; WITHOUT : W I T H O U T ; ZONE : Z O N E ; OF : O F ; UESCAPE : U E S C A P E ; GROUPS : G R O U P S ; RECURSIVE : R E C U R S I V E ; INT : I N T [248]? ; FLOAT : F L O A T [48]? ; SMALLSERIAL : S M A L L S E R I A L ; SERIAL : S E R I A L ; BIGSERIAL : B I G S E R I A L ; MONEY : M O N E Y ; VARCHAR : V A R C H A R ; BYTEA : B Y T E A ; ENUM : E N U M ; POINT : P O I N T ; LINE : L I N E ; LSEG : L S E G ; BOX : B O X ; PATH : P A T H ; POLYGON : P O L Y G O N ; CIRCLE : C I R C L E ; CIDR : C I D R ; INET : I N E T ; MACADDR : M A C A D D R [8]? ; BIT : B I T ; VARBIT : V A R B I T ; TSVECTOR : T S V E C T O R ; TSQUERY : T S Q U E R Y ; UUID : U U I D ; XML : X M L ; JSON : J S O N ; INTRANGE : I N T [48] R A N G E ; NUMRANGE : N U M R A N G E ; TSRANGE : T S R A N G E ; TSTZRANGE : T S T Z R A N G E ; DATERANGE : D A T E R A N G E ; DOUBLE_PRECISION : D O U B L E [ ]+ P R E C I S I O N ;
src/dnscatcher/network/udp/dnscatcher-network-udp-sender.adb
DNSCatcher/DNSCatcher
4
11654
-- Copyright 2019 <NAME> <<EMAIL>> -- -- 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 Ada.Exceptions; use Ada.Exceptions; with Ada.Streams; use Ada.Streams; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with DNSCatcher.Types; use DNSCatcher.Types; with DNSCatcher.Utils.Logger; use DNSCatcher.Utils.Logger; package body DNSCatcher.Network.UDP.Sender is task body Send_Packet_Task is DNS_Socket : Socket_Type; DNS_Packet : Raw_Packet_Record; Outbound_Packet_Queue : DNS_Raw_Packet_Queue_Ptr := null; Outgoing_Address : Inet_Addr_Type; Outgoing_Port : Port_Type; Length : Stream_Element_Offset; Process_Packets : Boolean := False; Packet_Count : Integer := 0; Logger_Packet : Logger_Message_Packet_Ptr; begin loop -- Either just started or stopping, we're terminatable in this state if Outbound_Packet_Queue /= null then Outbound_Packet_Queue.Count (Packet_Count); end if; while Process_Packets = False and Packet_Count = 0 loop select accept Initialize (Socket : Socket_Type; Packet_Queue : DNS_Raw_Packet_Queue_Ptr) do DNS_Socket := Socket; Outbound_Packet_Queue := Packet_Queue; end Initialize; or accept Start do Logger_Packet := new Logger_Message_Packet; Logger_Packet.Push_Component ("UDP Sender"); Process_Packets := True; Logger_Packet.Log_Message (INFO, "Sender startup"); Logger_Queue.Add_Packet (Logger_Packet); end Start; or accept Stop do null; end Stop; or terminate; end select; end loop; -- We're actively processing packets while Process_Packets or Packet_Count > 0 loop Logger_Packet := new Logger_Message_Packet; Logger_Packet.Push_Component ("UDP Sender"); select accept Start do null; end Start; or accept Stop do Process_Packets := False; end Stop; else Outbound_Packet_Queue.Count (Packet_Count); if Packet_Count > 0 then Outbound_Packet_Queue.Get (DNS_Packet); declare Buffer : Stream_Element_Array (1 .. DNS_Packet.Raw_Data_Length); Header : SEA_DNS_Packet_Header; begin Outgoing_Address := Inet_Addr (To_String (DNS_Packet.To_Address)); Outgoing_Port := DNS_Packet.To_Port; -- And send the damn thing Logger_Packet.Log_Message (DEBUG, "Sent packet to " & Image (Outgoing_Address)); -- Create the outbound message Header := DNS_Packet_Header_To_SEA (DNS_Packet.Raw_Data.Header); Buffer := Header & DNS_Packet.Raw_Data.Data.all; Send_Socket (Socket => DNS_Socket, Item => Buffer, Last => Length, To => (Family => Family_Inet, Addr => Outgoing_Address, Port => Outgoing_Port)); exception when Exp_Error : others => begin Logger_Packet.Log_Message (ERROR, "Unknown error: " & Exception_Information (Exp_Error)); end; end; else delay 0.1; end if; end select; -- Send the logs on their way Logger_Queue.Add_Packet (Logger_Packet); end loop; end loop; end Send_Packet_Task; procedure Initialize (This : in out UDP_Sender_Interface; Socket : Socket_Type) is begin -- Save our config for good measure This.Sender_Socket := Socket; This.Sender_Task := new Send_Packet_Task; This.Packet_Queue := new Raw_Packet_Record_Queue; This.Sender_Task.Initialize (This.Sender_Socket, This.Packet_Queue); end Initialize; procedure Start (This : in out UDP_Sender_Interface) is begin This.Sender_Task.Start; end Start; procedure Shutdown (This : in out UDP_Sender_Interface) is begin -- Cleanly shuts down the interface if This.Sender_Task /= null then This.Sender_Task.Stop; end if; end Shutdown; function Get_Packet_Queue_Ptr (This : in out UDP_Sender_Interface) return DNS_Raw_Packet_Queue_Ptr is begin return This.Packet_Queue; end Get_Packet_Queue_Ptr; end DNSCatcher.Network.UDP.Sender;
C++/Stack Calculator (Antlr v4)/grammar/Generator.g4
bajwa10/Projects-Assignments
0
7160
grammar Generator; file: stat+ EOF; stat: '[' st=ID 'in' start=INT '..' finish=INT '|' expr ']' ';' ; expr: <assoc=right> expr ('^') expr #exp | expr op=('*'|'/'|'%') expr #mul | expr op=('+'|'-') expr #addSub | '(' expr ')' #bracket | INT #intAtom | ID #identifier ; INT: DIGIT+; ID: CHAR+ | (CHAR+ DIGIT* CHAR*)+ ; fragment DIGIT: [0-9]; fragment CHAR: [a-zA-Z]; WS : (' '|'\t'|'\r'|'\n')+ -> skip ;
src/libraries/Rewriters_Lib/src/placeholder_relations.adb
Fabien-Chouteau/Renaissance-Ada
0
26520
with Ada.Assertions; use Ada.Assertions; with Ada.Text_IO; use Ada.Text_IO; with Langkit_Support.Text; use Langkit_Support.Text; with Libadalang.Common; use Libadalang.Common; with Rejuvenation; use Rejuvenation; with Rejuvenation.Finder; use Rejuvenation.Finder; with Rejuvenation.Utils; use Rejuvenation.Utils; package body Placeholder_Relations is function Get_Expression_Type (Match : Match_Pattern; Expression : String) return Base_Type_Decl is E : constant Expr := Match.Get_Single_As_Node (Expression).As_Expr; begin return E.P_Expression_Type; end Get_Expression_Type; function Is_Referenced_In (D_N : Defining_Name; Node : Ada_Node) return Boolean; function Is_Referenced_In (D_N : Defining_Name; Node : Ada_Node) return Boolean is Identifiers : constant Node_List.Vector := Find (Node, Ada_Identifier); begin return (for some Identifier of Identifiers => Identifier.As_Identifier.P_Referenced_Defining_Name = D_N); end Is_Referenced_In; function Is_Referenced_In (Match : Match_Pattern; Definition, Context : String) return Boolean is D_N : constant Defining_Name := Match.Get_Single_As_Node (Definition).As_Defining_Name; Context_Nodes : constant Node_List.Vector := Match.Get_Placeholder_As_Nodes (Context); begin return (for some Context_Node of Context_Nodes => Is_Referenced_In (D_N, Context_Node)); end Is_Referenced_In; function Is_Constant_Expression (E : Expr) return Boolean; function Is_Constant_Expression (E : Expr) return Boolean is begin case E.Kind is when Ada_String_Literal | Ada_Char_Literal | Ada_Int_Literal | Ada_Real_Literal | Ada_Null_Literal => return True; when Ada_Identifier => return False; when Ada_Un_Op => declare U_O : constant Un_Op := E.As_Un_Op; begin return Is_Constant_Expression (U_O.F_Expr); end; when Ada_Bin_Op => declare B_O : constant Bin_Op := E.As_Bin_Op; begin return Is_Constant_Expression (B_O.F_Left) and then Is_Constant_Expression (B_O.F_Right); end; when Ada_Relation_Op => declare R_O : constant Relation_Op := E.As_Relation_Op; begin return Is_Constant_Expression (R_O.F_Left) and then Is_Constant_Expression (R_O.F_Right); end; when Ada_Paren_Expr => return Is_Constant_Expression (E.As_Paren_Expr.F_Expr); when others => Put_Line (Image (E.Full_Sloc_Image) & "Is_Constant_Expression: Unhandled kind - " & E.Kind'Image); return False; end case; end Is_Constant_Expression; function Is_Constant_Expression (Match : Match_Pattern; Expression : String) return Boolean is E : constant Expr := Match.Get_Single_As_Node (Expression).As_Expr; begin return Is_Constant_Expression (E); end Is_Constant_Expression; function Has_Side_Effect (E : Expr) return Boolean; function Has_Side_Effect (E : Expr) return Boolean is -- conservative implementation, see details in code. begin case E.Kind is -- TODO: add Ada_Attribute_Ref when it is clear -- whether users can define their own attribute function (in Ada2022) when Ada_String_Literal | Ada_Char_Literal | Ada_Int_Literal | Ada_Real_Literal | Ada_Null_Literal => return False; when Ada_Identifier | Ada_Dotted_Name => declare N : constant Libadalang.Analysis.Name := E.As_Name; begin -- conservative assumption: a function call has a side effect. return N.P_Is_Call; end; when Ada_Attribute_Ref => -- conservative assumption: -- In Ada 2022, using Put_Image a user defined function -- with a possible side effect can be defined -- for the 'Image attribute return True; when Ada_Allocator => -- TODO: find out whether allocator can have side effects! -- F_Subpool -- F_Type_Or_Expr return True; when Ada_Box_Expr => -- Can occur in aggregates: -- The meaning is that the component of the aggregate takes -- the default value if there is one. return False; when Ada_If_Expr => declare I_E : constant If_Expr := E.As_If_Expr; begin return Has_Side_Effect (I_E.F_Cond_Expr) or else Has_Side_Effect (I_E.F_Then_Expr) or else Has_Side_Effect (I_E.F_Else_Expr); end; when Ada_Case_Expr => declare C_E : constant Case_Expr := E.As_Case_Expr; begin return Has_Side_Effect (C_E.F_Expr) or else (for some C of C_E.F_Cases.Children => Has_Side_Effect (C.As_Expr)); end; when Ada_Case_Expr_Alternative => declare C_E_A : constant Case_Expr_Alternative := E.As_Case_Expr_Alternative; begin return Has_Side_Effect (C_E_A.F_Expr) or else (for some C of C_E_A.F_Choices.Children => Has_Side_Effect (C.As_Expr)); end; when Ada_Call_Expr => declare C_E : constant Call_Expr := E.As_Call_Expr; begin -- conservative assumption: a function call has a side effect. -- TODO: analyse function call (out and in/out arguments) -- analyse function to have side effect -- * change variable not local to function -- * write to file / screen if C_E.P_Is_Call then return True; else -- array access Assert (Check => C_E.F_Suffix.Kind = Ada_Assoc_List, Message => "Has_Side_Effects unexpected kind for Suffix: " & C_E.F_Suffix.Kind'Image); declare A_L : constant Assoc_List := C_E.F_Suffix.As_Assoc_List; begin return (for some A of A_L.Children => Has_Side_Effect (A.As_Param_Assoc.F_R_Expr)); end; end if; end; when Ada_Paren_Expr => return Has_Side_Effect (E.As_Paren_Expr.F_Expr); when Ada_Un_Op => declare U_O : constant Un_Op := E.As_Un_Op; begin return Has_Side_Effect (U_O.F_Expr); end; when Ada_Bin_Op => declare B_O : constant Bin_Op := E.As_Bin_Op; begin return Has_Side_Effect (B_O.F_Left) or else Has_Side_Effect (B_O.F_Right); end; when Ada_Relation_Op => declare R_O : constant Relation_Op := E.As_Relation_Op; begin return Has_Side_Effect (R_O.F_Left) or else Has_Side_Effect (R_O.F_Right); end; when Ada_Aggregate => declare A : constant Aggregate := E.As_Aggregate; begin return (not A.F_Ancestor_Expr.Is_Null and then Has_Side_Effect (A.F_Ancestor_Expr)) or else (for some Assoc of A.F_Assocs.Children => Has_Side_Effect (Assoc.As_Aggregate_Assoc.F_R_Expr)); end; when Ada_Membership_Expr => declare M_E : constant Membership_Expr := E.As_Membership_Expr; begin return Has_Side_Effect (M_E.F_Expr) or else (for some Alternative of M_E.F_Membership_Exprs.Children => Has_Side_Effect (Alternative.As_Expr)); end; when Ada_Explicit_Deref => declare E_D : constant Explicit_Deref := E.As_Explicit_Deref; begin return Has_Side_Effect (E_D.F_Prefix.As_Expr); end; when others => Put_Line (Image (E.Full_Sloc_Image) & " - Has_Side_Effect: Unhandled kind - " & E.Kind'Image); -- conservative assumption: unknown kind has a side effect. return True; end case; end Has_Side_Effect; function Has_Side_Effect (Match : Match_Pattern; Placeholder_Name : String) return Boolean is -- basic implementation: -- statement and declarations always have side effects -- e.g. change variable and introduce definition Nodes : constant Node_List.Vector := Match.Get_Placeholder_As_Nodes (Placeholder_Name); begin return (for some Node of Nodes => Node.Kind not in Ada_Expr or else Has_Side_Effect (Node.As_Expr)); end Has_Side_Effect; function Has_Effect_On (A, B : Ada_Node) return Boolean; function Has_Effect_On (A : Ada_Node; B : Ada_Node with Unreferenced) return Boolean is -- Basic implementation -- When an expression has no side effects, -- it has no effect on B -- -- All Nodes A that effect Node B are reported as True -- Yet not all nodes A that do not effect node B are reported as False -- -- TODO: use the variables that written by A and -- read by B -- to make it more accurate -- -- Note: dependent effects include -- * output parameter of a function -- used in the other placeholder -- * side effect of a function (i.e. state change) -- used in the other placeholder begin return A.Kind not in Ada_Expr or else Has_Side_Effect (A.As_Expr); end Has_Effect_On; function Has_Effect_On (Match : Match_Pattern; Placeholder_A, Placeholder_B : String) return Boolean is Nodes_A : constant Node_List.Vector := Match.Get_Placeholder_As_Nodes (Placeholder_A); Nodes_B : constant Node_List.Vector := Match.Get_Placeholder_As_Nodes (Placeholder_B); begin return (for some Node_A of Nodes_A => (for some Node_B of Nodes_B => Has_Effect_On (Node_A, Node_B))); end Has_Effect_On; function Are_Independent (Match : Match_Pattern; Placeholder_1, Placeholder_2 : String) return Boolean is begin return not Has_Effect_On (Match, Placeholder_1, Placeholder_2) and then not Has_Effect_On (Match, Placeholder_2, Placeholder_1); end Are_Independent; function Is_Within_Base_Subp_Body (Match : Match_Pattern; Subp_Name : String) return Boolean is Nodes : constant Node_List.Vector := Get_Nodes (Match); begin -- Since Nodes are part of a sublist - checking a single node is enough return (for some Parent of Nodes.First_Element.Parents => Parent.Kind in Ada_Base_Subp_Body and then Subp_Name = Raw_Signature (Parent.As_Base_Subp_Body.F_Subp_Spec.F_Subp_Name)); end Is_Within_Base_Subp_Body; end Placeholder_Relations;
practical01/ex4.asm
DoStini/FEUP-sope
1
161011
<reponame>DoStini/FEUP-sope ex4: file format elf64-x86-64 Disassembly of section .init: 0000000000001000 <_init>: 1000: f3 0f 1e fa endbr64 1004: 48 83 ec 08 sub $0x8,%rsp 1008: 48 8b 05 d9 2f 00 00 mov 0x2fd9(%rip),%rax # 3fe8 <__gmon_start__> 100f: 48 85 c0 test %rax,%rax 1012: 74 02 je 1016 <_init+0x16> 1014: ff d0 callq *%rax 1016: 48 83 c4 08 add $0x8,%rsp 101a: c3 retq Disassembly of section .plt: 0000000000001020 <.plt>: 1020: ff 35 e2 2f 00 00 pushq 0x2fe2(%rip) # 4008 <_GLOBAL_OFFSET_TABLE_+0x8> 1026: ff 25 e4 2f 00 00 jmpq *0x2fe4(%rip) # 4010 <_GLOBAL_OFFSET_TABLE_+0x10> 102c: 0f 1f 40 00 nopl 0x0(%rax) 0000000000001030 <putchar@plt>: 1030: ff 25 e2 2f 00 00 jmpq *0x2fe2(%rip) # 4018 <putchar@GLIBC_2.2.5> 1036: 68 00 00 00 00 pushq $0x0 103b: e9 e0 ff ff ff jmpq 1020 <.plt> 0000000000001040 <__errno_location@plt>: 1040: ff 25 da 2f 00 00 jmpq *0x2fda(%rip) # 4020 <__errno_location@GLIBC_2.2.5> 1046: 68 01 00 00 00 pushq $0x1 104b: e9 d0 ff ff ff jmpq 1020 <.plt> 0000000000001050 <printf@plt>: 1050: ff 25 d2 2f 00 00 jmpq *0x2fd2(%rip) # 4028 <printf@GLIBC_2.2.5> 1056: 68 02 00 00 00 pushq $0x2 105b: e9 c0 ff ff ff jmpq 1020 <.plt> 0000000000001060 <read@plt>: 1060: ff 25 ca 2f 00 00 jmpq *0x2fca(%rip) # 4030 <read@GLIBC_2.2.5> 1066: 68 03 00 00 00 pushq $0x3 106b: e9 b0 ff ff ff jmpq 1020 <.plt> 0000000000001070 <fprintf@plt>: 1070: ff 25 c2 2f 00 00 jmpq *0x2fc2(%rip) # 4038 <fprintf@GLIBC_<EMAIL>> 1076: 68 04 00 00 00 pushq $0x4 107b: e9 a0 ff ff ff jmpq 1020 <.plt> 0000000000001080 <malloc@plt>: 1080: ff 25 ba 2f 00 00 jmpq *0x2fba(%rip) # 4040 <malloc@GLIBC_2.2.5> 1086: 68 05 00 00 00 pushq $0x5 108b: e9 90 ff ff ff jmpq 1020 <.plt> 0000000000001090 <open@plt>: 1090: ff 25 b2 2f 00 00 jmpq *0x2fb2(%rip) # 4048 <open@GLIBC_2.2.5> 1096: 68 06 00 00 00 pushq $0x6 109b: e9 80 ff ff ff jmpq 1020 <.plt> 00000000000010a0 <perror@plt>: 10a0: ff 25 aa 2f 00 00 jmpq *0x2faa(%rip) # 4050 <perror@GLIBC_2.2.5> 10a6: 68 07 00 00 00 pushq $0x7 10ab: e9 70 ff ff ff jmpq 1020 <.plt> 00000000000010b0 <atoi@plt>: 10b0: ff 25 a2 2f 00 00 jmpq *0x2fa2(%rip) # 4058 <atoi@GLIBC_2.2.5> 10b6: 68 08 00 00 00 pushq $0x8 10bb: e9 60 ff ff ff jmpq 1020 <.plt> Disassembly of section .text: 00000000000010c0 <_start>: 10c0: f3 0f 1e fa endbr64 10c4: 31 ed xor %ebp,%ebp 10c6: 49 89 d1 mov %rdx,%r9 10c9: 5e pop %rsi 10ca: 48 89 e2 mov %rsp,%rdx 10cd: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp 10d1: 50 push %rax 10d2: 54 push %rsp 10d3: 4c 8d 05 96 02 00 00 lea 0x296(%rip),%r8 # 1370 <__libc_csu_fini> 10da: 48 8d 0d 1f 02 00 00 lea 0x21f(%rip),%rcx # 1300 <__libc_csu_init> 10e1: 48 8d 3d d1 00 00 00 lea 0xd1(%rip),%rdi # 11b9 <main> 10e8: ff 15 f2 2e 00 00 callq *0x2ef2(%rip) # 3fe0 <__libc_start_main@GLIBC_2.2.5> 10ee: f4 hlt 10ef: 90 nop 00000000000010f0 <deregister_tm_clones>: 10f0: 48 8d 3d 79 2f 00 00 lea 0x2f79(%rip),%rdi # 4070 <__TMC_END__> 10f7: 48 8d 05 72 2f 00 00 lea 0x2f72(%rip),%rax # 4070 <__TMC_END__> 10fe: 48 39 f8 cmp %rdi,%rax 1101: 74 15 je 1118 <deregister_tm_clones+0x28> 1103: 48 8b 05 ce 2e 00 00 mov 0x2ece(%rip),%rax # 3fd8 <_ITM_deregisterTMCloneTable> 110a: 48 85 c0 test %rax,%rax 110d: 74 09 je 1118 <deregister_tm_clones+0x28> 110f: ff e0 jmpq *%rax 1111: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 1118: c3 retq 1119: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 0000000000001120 <register_tm_clones>: 1120: 48 8d 3d 49 2f 00 00 lea 0x2f49(%rip),%rdi # 4070 <__TMC_END__> 1127: 48 8d 35 42 2f 00 00 lea 0x2f42(%rip),%rsi # 4070 <__TMC_END__> 112e: 48 29 fe sub %rdi,%rsi 1131: 48 89 f0 mov %rsi,%rax 1134: 48 c1 ee 3f shr $0x3f,%rsi 1138: 48 c1 f8 03 sar $0x3,%rax 113c: 48 01 c6 add %rax,%rsi 113f: 48 d1 fe sar %rsi 1142: 74 14 je 1158 <register_tm_clones+0x38> 1144: 48 8b 05 a5 2e 00 00 mov 0x2ea5(%rip),%rax # 3ff0 <_ITM_registerTMCloneTable> 114b: 48 85 c0 test %rax,%rax 114e: 74 08 je 1158 <register_tm_clones+0x38> 1150: ff e0 jmpq *%rax 1152: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) 1158: c3 retq 1159: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 0000000000001160 <__do_global_dtors_aux>: 1160: f3 0f 1e fa endbr64 1164: 80 3d 1d 2f 00 00 00 cmpb $0x0,0x2f1d(%rip) # 4088 <completed.0> 116b: 75 33 jne 11a0 <__do_global_dtors_aux+0x40> 116d: 55 push %rbp 116e: 48 83 3d 82 2e 00 00 cmpq $0x0,0x2e82(%rip) # 3ff8 <__cxa_finalize@GLIBC_2.2.5> 1175: 00 1176: 48 89 e5 mov %rsp,%rbp 1179: 74 0d je 1188 <__do_global_dtors_aux+0x28> 117b: 48 8b 3d e6 2e 00 00 mov 0x2ee6(%rip),%rdi # 4068 <__dso_handle> 1182: ff 15 70 2e 00 00 callq *0x2e70(%rip) # 3ff8 <__cxa_finalize@GLIBC_2.2.5> 1188: e8 63 ff ff ff callq 10f0 <deregister_tm_clones> 118d: c6 05 f4 2e 00 00 01 movb $0x1,0x2ef4(%rip) # 4088 <completed.0> 1194: 5d pop %rbp 1195: c3 retq 1196: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1) 119d: 00 00 00 11a0: c3 retq 11a1: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) 11a8: 00 00 00 00 11ac: 0f 1f 40 00 nopl 0x0(%rax) 00000000000011b0 <frame_dummy>: 11b0: f3 0f 1e fa endbr64 11b4: e9 67 ff ff ff jmpq 1120 <register_tm_clones> 00000000000011b9 <main>: 11b9: 55 push %rbp 11ba: 48 89 e5 mov %rsp,%rbp 11bd: 48 83 ec 50 sub $0x50,%rsp 11c1: 89 7d cc mov %edi,-0x34(%rbp) 11c4: 48 89 75 c0 mov %rsi,-0x40(%rbp) 11c8: 48 89 55 b8 mov %rdx,-0x48(%rbp) 11cc: 83 7d cc 03 cmpl $0x3,-0x34(%rbp) 11d0: 74 1b je 11ed <main+0x34> 11d2: 48 8d 3d 2b 0e 00 00 lea 0xe2b(%rip),%rdi # 2004 <_IO_stdin_used+0x4> 11d9: b8 00 00 00 00 mov $0x0,%eax 11de: e8 6d fe ff ff callq 1050 <printf@plt> 11e3: b8 01 00 00 00 mov $0x1,%eax 11e8: e9 09 01 00 00 jmpq 12f6 <main+0x13d> 11ed: 48 8b 45 c0 mov -0x40(%rbp),%rax 11f1: 48 83 c0 08 add $0x8,%rax 11f5: 48 8b 00 mov (%rax),%rax 11f8: be 00 00 00 00 mov $0x0,%esi 11fd: 48 89 c7 mov %rax,%rdi 1200: b8 00 00 00 00 mov $0x0,%eax 1205: e8 86 fe ff ff callq 1090 <open@plt> 120a: 89 45 dc mov %eax,-0x24(%rbp) 120d: 83 7d dc ff cmpl $0xffffffff,-0x24(%rbp) 1211: 75 54 jne 1267 <main+0xae> 1213: e8 28 fe ff ff callq 1040 <__errno_location@plt> 1218: 8b 00 mov (%rax),%eax 121a: 89 c6 mov %eax,%esi 121c: 48 8d 3d ff 0d 00 00 lea 0xdff(%rip),%rdi # 2022 <_IO_stdin_used+0x22> 1223: b8 00 00 00 00 mov $0x0,%eax 1228: e8 23 fe ff ff callq 1050 <printf@plt> 122d: e8 0e fe ff ff callq 1040 <__errno_location@plt> 1232: 8b 10 mov (%rax),%edx 1234: 48 8b 05 45 2e 00 00 mov 0x2e45(%rip),%rax # 4080 <stderr@@GLIBC_2.2.5> 123b: 48 8d 35 e0 0d 00 00 lea 0xde0(%rip),%rsi # 2022 <_IO_stdin_used+0x22> 1242: 48 89 c7 mov %rax,%rdi 1245: b8 00 00 00 00 mov $0x0,%eax 124a: e8 21 fe ff ff callq 1070 <fprintf@plt> 124f: 48 8d 3d dc 0d 00 00 lea 0xddc(%rip),%rdi # 2032 <_IO_stdin_used+0x32> 1256: e8 45 fe ff ff callq 10a0 <perror@plt> 125b: e8 e0 fd ff ff callq 1040 <__errno_location@plt> 1260: 8b 00 mov (%rax),%eax 1262: e9 8f 00 00 00 jmpq 12f6 <main+0x13d> 1267: 48 8b 45 c0 mov -0x40(%rbp),%rax 126b: 48 83 c0 10 add $0x10,%rax 126f: 48 8b 00 mov (%rax),%rax 1272: 48 89 c7 mov %rax,%rdi 1275: e8 36 fe ff ff callq 10b0 <atoi@plt> 127a: 48 98 cltq 127c: 48 89 45 e8 mov %rax,-0x18(%rbp) 1280: 48 8b 45 e8 mov -0x18(%rbp),%rax 1284: 89 c6 mov %eax,%esi 1286: 48 8d 3d ab 0d 00 00 lea 0xdab(%rip),%rdi # 2038 <_IO_stdin_used+0x38> 128d: b8 00 00 00 00 mov $0x0,%eax 1292: e8 b9 fd ff ff callq 1050 <printf@plt> 1297: 48 8b 45 e8 mov -0x18(%rbp),%rax 129b: 48 89 c7 mov %rax,%rdi 129e: e8 dd fd ff ff callq 1080 <malloc@plt> 12a3: 48 89 45 f0 mov %rax,-0x10(%rbp) 12a7: 48 8b 55 e8 mov -0x18(%rbp),%rdx 12ab: 48 8b 4d f0 mov -0x10(%rbp),%rcx 12af: 8b 45 dc mov -0x24(%rbp),%eax 12b2: 48 89 ce mov %rcx,%rsi 12b5: 89 c7 mov %eax,%edi 12b7: e8 a4 fd ff ff callq 1060 <read@plt> 12bc: 48 89 45 f8 mov %rax,-0x8(%rbp) 12c0: 48 c7 45 e0 00 00 00 movq $0x0,-0x20(%rbp) 12c7: 00 12c8: eb 1d jmp 12e7 <main+0x12e> 12ca: 48 8b 55 f0 mov -0x10(%rbp),%rdx 12ce: 48 8b 45 e0 mov -0x20(%rbp),%rax 12d2: 48 01 d0 add %rdx,%rax 12d5: 0f b6 00 movzbl (%rax),%eax 12d8: 0f be c0 movsbl %al,%eax 12db: 89 c7 mov %eax,%edi 12dd: e8 4e fd ff ff callq 1030 <putchar@plt> 12e2: 48 83 45 e0 01 addq $0x1,-0x20(%rbp) 12e7: 48 8b 45 e0 mov -0x20(%rbp),%rax 12eb: 48 3b 45 f8 cmp -0x8(%rbp),%rax 12ef: 72 d9 jb 12ca <main+0x111> 12f1: b8 00 00 00 00 mov $0x0,%eax 12f6: c9 leaveq 12f7: c3 retq 12f8: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) 12ff: 00 0000000000001300 <__libc_csu_init>: 1300: f3 0f 1e fa endbr64 1304: 41 57 push %r15 1306: 4c 8d 3d db 2a 00 00 lea 0x2adb(%rip),%r15 # 3de8 <__frame_dummy_init_array_entry> 130d: 41 56 push %r14 130f: 49 89 d6 mov %rdx,%r14 1312: 41 55 push %r13 1314: 49 89 f5 mov %rsi,%r13 1317: 41 54 push %r12 1319: 41 89 fc mov %edi,%r12d 131c: 55 push %rbp 131d: 48 8d 2d cc 2a 00 00 lea 0x2acc(%rip),%rbp # 3df0 <__do_global_dtors_aux_fini_array_entry> 1324: 53 push %rbx 1325: 4c 29 fd sub %r15,%rbp 1328: 48 83 ec 08 sub $0x8,%rsp 132c: e8 cf fc ff ff callq 1000 <_init> 1331: 48 c1 fd 03 sar $0x3,%rbp 1335: 74 1f je 1356 <__libc_csu_init+0x56> 1337: 31 db xor %ebx,%ebx 1339: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 1340: 4c 89 f2 mov %r14,%rdx 1343: 4c 89 ee mov %r13,%rsi 1346: 44 89 e7 mov %r12d,%edi 1349: 41 ff 14 df callq *(%r15,%rbx,8) 134d: 48 83 c3 01 add $0x1,%rbx 1351: 48 39 dd cmp %rbx,%rbp 1354: 75 ea jne 1340 <__libc_csu_init+0x40> 1356: 48 83 c4 08 add $0x8,%rsp 135a: 5b pop %rbx 135b: 5d pop %rbp 135c: 41 5c pop %r12 135e: 41 5d pop %r13 1360: 41 5e pop %r14 1362: 41 5f pop %r15 1364: c3 retq 1365: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1) 136c: 00 00 00 00 0000000000001370 <__libc_csu_fini>: 1370: f3 0f 1e fa endbr64 1374: c3 retq Disassembly of section .fini: 0000000000001378 <_fini>: 1378: f3 0f 1e fa endbr64 137c: 48 83 ec 08 sub $0x8,%rsp 1380: 48 83 c4 08 add $0x8,%rsp 1384: c3 retq
Task/Function-prototype/Ada/function-prototype-3.ada
LaudateCorpus1/RosettaCodeData
1
26055
<filename>Task/Function-prototype/Ada/function-prototype-3.ada package Stack is procedure Push(Object:Integer); function Pull return Integer; end Stack;
src/app.adb
jklmnn/esp32c3-ada
1
13518
package body App is procedure Main is separate; begin Main; end App;
programs/oeis/045/A045929.asm
karttu/loda
0
240505
; A045929: Generalized Connell sequence C_{5,3}. ; 1,2,7,12,17,18,23,28,33,38,43,48,49,54,59,64,69,74,79,84,89,94,95,100,105,110,115,120,125,130,135,140,145,150,155,156,161,166,171,176,181,186,191,196,201,206,211,216,221,226,231,232,237,242,247,252,257,262,267,272,277 mov $2,$0 mov $3,$0 add $3,$0 mov $4,$0 add $4,$0 add $4,$3 lpb $0,1 sub $0,1 add $1,3 trn $0,$1 sub $4,4 lpe mov $1,$4 add $1,2 lpb $2,1 add $1,1 sub $2,1 lpe sub $1,1
src/skill-containers-vectors.ads
skill-lang/adaCommon
0
4192
-- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ skills vector container implementation -- -- |___/_|\_\_|_|____| by: <NAME>, <NAME> -- -- -- pragma Ada_2012; with Ada.Finalization; -- vector, can also be used as a stack -- vector element operation is total, i.e. it will never raise an exception -- instead of exception, Err_Val will be returned generic type Index_Type is range <>; type Element_Type is private; -- Err_Val : Element_Type; package Skill.Containers.Vectors is type Vector_T is tagged limited private; type Vector is access Vector_T; function Empty_Vector return Vector; procedure Free (This : access Vector_T); -- applies F for each element in this procedure Foreach (This : not null access Vector_T'Class; F : not null access procedure (I : Element_Type)); -- appends element to the vector procedure Append (This : not null access Vector_T'Class; New_Element : Element_Type); -- appends element to the vector and assumes that the vector has a spare slot procedure Append_Unsafe (This : not null access Vector_T'Class; New_Element : Element_Type); -- apppends all elements stored in argument vector procedure Append_All (This : access Vector_T'Class; Other : Vector); -- prepends all elements stored in argument vector procedure Prepend_All (This : access Vector_T'Class; Other : Vector); -- prepends a number of undefined elements to this vector procedure Append_Undefined (This : access Vector_T'Class; Count : Natural); -- prepends a number of undefined elements to this vector procedure Prepend_Undefined (This : access Vector_T'Class; Count : Natural); -- remove the last element function Pop (This : access Vector_T'Class) return Element_Type; -- get element at argument index function Element (This : access Vector_T'Class; Index : Index_Type) return Element_Type with Pre => Check_Index (This, Index); -- returns the last element in the vector or raises constraint error if empty function Last_Element (This : access Vector_T'Class) return Element_Type; -- returns the first element in the vector or raises constraint error if empty function First_Element (This : access Vector_T'Class) return Element_Type; -- ensures that an index can be allocated procedure Ensure_Index (This : access Vector_T'Class; New_Index : Index_Type); -- allocates an index, filling previous elements with random garbage! procedure Ensure_Allocation (This : access Vector_T'Class; New_Index : Index_Type); -- length of the container function Length (This : access Vector_T'Class) return Natural; -- true iff empty function Is_Empty (This : access Vector_T'Class) return Boolean; -- remove all elements procedure Clear (This : access Vector_T'Class); -- checks if an index is used function Check_Index (This : access Vector_T'Class; Index : Index_Type) return Boolean; -- replace element at given index procedure Replace_Element (This : access Vector_T'Class; Index : Index_Type; Element : Element_Type); pragma Inline (Foreach); -- pragma Inline (Append); pragma Inline (Append_Unsafe); pragma Inline (Pop); pragma Inline (Element); pragma Inline (Last_Element); pragma Inline (Ensure_Index); pragma Inline (Ensure_Allocation); pragma Inline (Length); pragma Inline (Is_Empty); pragma Inline (Clear); pragma Inline (Check_Index); pragma Inline (Replace_Element); private subtype Index_Base is Index_Type'Base; type Element_Array_T is array (Index_Type range <>) of Element_Type; type Element_Array is not null access Element_Array_T; type Element_Array_Access is access all Element_Array_T; type Vector_T is tagged limited record -- access to the actual data stored in the vector Data : Element_Array; -- the next index to be used, i.e. an exclusive border Next_Index : Index_Base; end record; end Skill.Containers.Vectors;
source/shell-directory_iteration.adb
charlie5/aShell
11
20237
<filename>source/shell-directory_iteration.adb with POSIX.File_Status, Ada.Unchecked_Deallocation, Ada.IO_Exceptions; package body Shell.Directory_Iteration is -- Cursor -- function Has_Element (Pos : in Cursor) return Boolean is begin return Pos.Directory_Entry /= null; end Has_Element; -- Directory -- function To_Directory (Path : in String; Recurse : in Boolean := False) return Directory is begin return Directory' (Path => +Path, Recurse => Recurse); end To_Directory; function Path (Container : in Directory) return String is begin return +Container.Path; end Path; function Iterate (Container : in Directory) return Directory_Iterators.Forward_Iterator'Class is use Ada.Directories, Ada.Finalization; V : constant Directory_Access := Container'Unrestricted_Access; begin return It : constant Iterator := (Controlled with Container => V, Search => new Search_Type, State => new Iterator_State) do Start_Search (Search => It.Search.all, Directory => Path (Container), Pattern => ""); end return; end Iterate; function Element_Value (Container : in Directory; Pos : in Cursor) return Constant_Reference_Type is pragma Unreferenced (Container); begin return (Element => Pos.Directory_Entry); end Element_Value; procedure Get_Next_Directory_Entry (Object : in Iterator; Directory_Entry : in Directory_Entry_Access) is use Ada.Directories, POSIX, POSIX.File_Status; Status : POSIX.File_Status.Status; begin Get_Next_Entry (Search => Object.Search.all, Directory_Entry => Directory_Entry.all); Status := Get_Link_Status (To_POSIX_String (Full_Name (Directory_Entry.all))); if Object.Container.Recurse and Kind (Directory_Entry.all) = Ada.Directories.Directory and Simple_Name (Directory_Entry.all) /= "." and Simple_Name (Directory_Entry.all) /= ".." and not Is_Symbolic_Link (Status) then Object.State.Subdirs.Append (+Full_Name (Directory_Entry.all)); end if; end Get_Next_Directory_Entry; overriding function First (Object : in Iterator) return Cursor is C : Cursor; begin C := Cursor' (Container => Object.Container, Directory_Entry => new Directory_Entry_Type); Get_Next_Directory_Entry (Object, C.Directory_Entry); Object.State.Prior := C.Directory_Entry; return C; end First; overriding function Next (Object : in Iterator; Position : in Cursor) return Cursor is use Ada.Directories; procedure Free is new Ada.Unchecked_Deallocation (Directory_Entry_Type, Directory_Entry_Access); function new_Cursor return Cursor is C : constant Cursor := Cursor' (Container => Position.Container, Directory_Entry => new Ada.Directories.Directory_Entry_Type); begin Get_Next_Directory_Entry (Object, C.Directory_Entry); Free (Object.State.Prior); Object.State.Prior := C.Directory_Entry; return C; end new_Cursor; begin if Position.Container = null then return No_Element; end if; if Position.Container /= Object.Container then raise Program_Error with "Position cursor of Next designates wrong directory"; end if; begin if More_Entries (Object.Search.all) then return new_Cursor; end if; exception when Ada.IO_Exceptions.Use_Error => null; -- The next entry cannot be accessed, so end this directories search. end; End_Search (Object.Search.all); -- No more entries left, so start a new search, if any subdirs remain. --- while not Object.State.Subdirs.Is_Empty loop declare Subdir : constant String := +Object.State.Subdirs.Last_Element; begin Object.State.Subdirs.Delete_Last; Start_Search (Search => Object.Search.all, Directory => Subdir, Pattern => ""); if More_Entries (Object.Search.all) then return new_Cursor; end if; exception when Ada.IO_Exceptions.Use_Error => null; -- A forbidden directory, so ignore. end; end loop; Free (Object.State.Prior); return No_Element; end Next; overriding procedure Finalize (Object : in out Iterator) is procedure Free is new Ada.Unchecked_Deallocation (Search_Type, Search_Access); procedure Free is new Ada.Unchecked_Deallocation (Iterator_State, Iterator_State_Access); begin Free (Object.Search); Free (Object.State); end Finalize; end Shell.Directory_Iteration;
Dave/Algebra/Naturals/Monus.agda
DavidStahl97/formal-proofs
0
8080
<gh_stars>0 module Dave.Algebra.Naturals.Monus where open import Dave.Algebra.Naturals.Definition open import Dave.Algebra.Naturals.Addition _∸_ : ℕ → ℕ → ℕ m ∸ zero = m zero ∸ suc n = zero suc m ∸ suc n = m ∸ n infixl 6 _∸_ ∸-zero : ∀ (n : ℕ) → 0 ∸ n ≡ 0 ∸-zero zero = refl ∸-zero (suc n) = refl ∸-assoc-+ : ∀ (m n p : ℕ) → m ∸ n ∸ p ≡ m ∸ (n + p) ∸-assoc-+ m zero p = refl ∸-assoc-+ zero (suc n) p = ∸-zero p ∸-assoc-+ (suc m) (suc n) p = begin suc m ∸ suc n ∸ p ≡⟨⟩ m ∸ n ∸ p ≡⟨ ∸-assoc-+ m n p ⟩ m ∸ (n + p) ≡⟨⟩ suc m ∸ suc (n + p) ≡⟨⟩ suc m ∸ (suc n + p) ∎
testcode.asm
furkansahinfs/Assembly-BST-with-MIPS
0
247457
.data # -9999 marks the end of the list firstList: .word 8, 3, 6, 10, 13, 7, 4, 5, -9999 # other examples for testing your code secondList: .word 8, 3, 6, 6, 10, 13, 7, 4, 5, -9999 thirdList: .word 8, 3, 6, 10, 13, -9999, 7, 4, 5, -9999 # assertEquals data failf: .asciiz " failed\n" passf: .asciiz " passed\n" buildTest: .asciiz " Build test" insertTest: .asciiz " Insert test" findTest: .asciiz " Find test" asertNumber: .word 0 .text main: # The test code assumes your root node's address is stored at $s0 and at tree argument at all times # Although it's not needed, you can: # - modify the test cases if you must # - add code between test cases # la $s0, tree # build a tree using the firstList jal build # Start of the test cases---------------------------------------------------- # check build procedure lw $t0, 4($s0) # address of the left child of the root lw $a0, 0($t0) # real value of the left child of the root li $a1, 3 # expected value of the left child of the root la $a2, buildTest # the name of the test # if left child != 3 then print failed jal assertEquals # check insert procedure li $a0, 11 # new value to be inserted move $a1, $s0 # address of the root jal insert # no need to reload 11 to $a0 lw $a1, 0($v0) # value from the returned address la $a2, insertTest # the name of the test # if returned address's value != 11 print failed jal assertEquals # check find procedure li $a0, 11 # search value move $a1, $s0 # adress of the root jal find # no need to reload 11 to $a0 lw $a1, 0($v1) # value from the found adress la $a2, findTest # the name of the test # if returned address's value != 11 print failed jal assertEquals # check find procedure 2 # 44 should not be on the list # v0 should return 1 li $a0, 44 # search value move $a1, $s0 # adress of the root jal find move $a0, $v0 # result of the search li $a1, 1 # expected result of the search la $a2, findTest # the name of the test # if returned value of $v0 != 0 print failed jal assertEquals move $a0, $s0 jal printTree # print tree for visual inspection # End of the test cases---------------------------------------------------- # End program li $v0, 10 syscall assertEquals: move $t2, $a0 # increment count of total assertions. la $t0, asertNumber lw $t1, 0($t0) addi $t1, $t1, 1 sw $t1, 0($t0) # print the test number add $a0, $t1, $zero li $v0, 1 syscall # print the test name move $a0, $a2 li $v0, 4 syscall # print passed or failed. beq $t2, $a1, passed la $a0, failf li $v0, 4 syscall j $ra passed: la $a0, passf li $v0, 4 syscall j $ra
kv-avm-symbol_tables.ads
davidkristola/vole
4
8378
with kv.avm.Registers; package kv.avm.Symbol_Tables is Missing_Element_Error : exception; type Symbol_Table is tagged limited private; type Symbol_Table_Access is access all Symbol_Table; procedure Initialize (Self : in out Symbol_Table); function Count(Self : Symbol_Table) return Natural; procedure Add (Self : in out Symbol_Table; Name : in String; Kind : in kv.avm.Registers.Data_Kind := kv.avm.Registers.Unset; Init : in String := ""); procedure Set_Kind (Self : in out Symbol_Table; Name : in String; Kind : in kv.avm.Registers.Data_Kind); procedure Set_Init (Self : in out Symbol_Table; Name : in String; Init : in String); function Get_Kind(Self : Symbol_Table; Name : String) return kv.avm.Registers.Data_Kind; function Get_Index(Self : Symbol_Table; Name : String) return Natural; function Has(Self : Symbol_Table; Name : String) return Boolean; procedure Set_All_Indexes (Self : in out Symbol_Table; Starting : in Natural := 1); procedure For_Each (Self : in out Symbol_Table; Proc : not null access procedure (Name : in String; Kind : in kv.avm.Registers.Data_Kind; Indx : in Natural; Init : in String)); procedure Link_Superclass_Table (Self : in out Symbol_Table; Super : in Symbol_Table_Access); private type Table_Type; type Table_Pointer is access Table_Type; type Symbol_Table is tagged limited record Table : Table_Pointer; end record; end kv.avm.Symbol_Tables;
ADL/devices/stm32-device.adb
JCGobbi/Nucleo-STM32H743ZI
0
17401
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with System; use System; with STM32_SVD.RCC; use STM32_SVD.RCC; with STM32_SVD.CRC; use STM32_SVD.CRC; with STM32.RCC; use STM32.RCC; package body STM32.Device is HPRE_Presc_Table : constant array (UInt4) of UInt32 := (1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 8, 16, 64, 128, 256, 512); PPRE_Presc_Table : constant array (UInt3) of UInt32 := (1, 1, 1, 1, 2, 4, 8, 16); ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased GPIO_Port) is begin if This'Address = GPIOA_Base then RCC_Periph.AHB4ENR.GPIOAEN := True; elsif This'Address = GPIOB_Base then RCC_Periph.AHB4ENR.GPIOBEN := True; elsif This'Address = GPIOC_Base then RCC_Periph.AHB4ENR.GPIOCEN := True; elsif This'Address = GPIOD_Base then RCC_Periph.AHB4ENR.GPIODEN := True; elsif This'Address = GPIOE_Base then RCC_Periph.AHB4ENR.GPIOEEN := True; elsif This'Address = GPIOF_Base then RCC_Periph.AHB4ENR.GPIOFEN := True; elsif This'Address = GPIOG_Base then RCC_Periph.AHB4ENR.GPIOGEN := True; elsif This'Address = GPIOH_Base then RCC_Periph.AHB4ENR.GPIOHEN := True; elsif This'Address = GPIOI_Base then RCC_Periph.AHB4ENR.GPIOIEN := True; elsif This'Address = GPIOJ_Base then RCC_Periph.AHB4ENR.GPIOJEN := True; elsif This'Address = GPIOK_Base then RCC_Periph.AHB4ENR.GPIOKEN := True; else raise Unknown_Device; end if; end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (Point : GPIO_Point) is begin Enable_Clock (Point.Periph.all); end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (Points : GPIO_Points) is begin for Point of Points loop Enable_Clock (Point.Periph.all); end loop; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased GPIO_Port) is begin if This'Address = GPIOA_Base then RCC_Periph.AHB4RSTR.GPIOARST := True; RCC_Periph.AHB4RSTR.GPIOARST := False; elsif This'Address = GPIOB_Base then RCC_Periph.AHB4RSTR.GPIOBRST := True; RCC_Periph.AHB4RSTR.GPIOBRST := False; elsif This'Address = GPIOC_Base then RCC_Periph.AHB4RSTR.GPIOCRST := True; RCC_Periph.AHB4RSTR.GPIOCRST := False; elsif This'Address = GPIOD_Base then RCC_Periph.AHB4RSTR.GPIODRST := True; RCC_Periph.AHB4RSTR.GPIODRST := False; elsif This'Address = GPIOE_Base then RCC_Periph.AHB4RSTR.GPIOERST := True; RCC_Periph.AHB4RSTR.GPIOERST := False; elsif This'Address = GPIOF_Base then RCC_Periph.AHB4RSTR.GPIOFRST := True; RCC_Periph.AHB4RSTR.GPIOFRST := False; elsif This'Address = GPIOG_Base then RCC_Periph.AHB4RSTR.GPIOGRST := True; RCC_Periph.AHB4RSTR.GPIOGRST := False; elsif This'Address = GPIOH_Base then RCC_Periph.AHB4RSTR.GPIOHRST := True; RCC_Periph.AHB4RSTR.GPIOHRST := False; elsif This'Address = GPIOI_Base then RCC_Periph.AHB4RSTR.GPIOIRST := True; RCC_Periph.AHB4RSTR.GPIOIRST := False; elsif This'Address = GPIOJ_Base then RCC_Periph.AHB4RSTR.GPIOJRST := True; RCC_Periph.AHB4RSTR.GPIOJRST := False; elsif This'Address = GPIOK_Base then RCC_Periph.AHB4RSTR.GPIOKRST := True; RCC_Periph.AHB4RSTR.GPIOKRST := False; else raise Unknown_Device; end if; end Reset; ----------- -- Reset -- ----------- procedure Reset (Point : GPIO_Point) is begin Reset (Point.Periph.all); end Reset; ----------- -- Reset -- ----------- procedure Reset (Points : GPIO_Points) is Do_Reset : Boolean; begin for J in Points'Range loop Do_Reset := True; for K in Points'First .. J - 1 loop if Points (K).Periph = Points (J).Periph then Do_Reset := False; exit; end if; end loop; if Do_Reset then Reset (Points (J).Periph.all); end if; end loop; end Reset; ------------------------------ -- GPIO_Port_Representation -- ------------------------------ function GPIO_Port_Representation (Port : GPIO_Port) return UInt4 is begin -- TODO: rather ugly to have this board-specific range here if Port'Address = GPIOA_Base then return 0; elsif Port'Address = GPIOB_Base then return 1; elsif Port'Address = GPIOC_Base then return 2; elsif Port'Address = GPIOD_Base then return 3; elsif Port'Address = GPIOE_Base then return 4; elsif Port'Address = GPIOF_Base then return 5; elsif Port'Address = GPIOG_Base then return 6; elsif Port'Address = GPIOH_Base then return 7; elsif Port'Address = GPIOI_Base then return 8; elsif Port'Address = GPIOJ_Base then return 9; elsif Port'Address = GPIOK_Base then return 10; else raise Program_Error; end if; end GPIO_Port_Representation; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased Analog_To_Digital_Converter) is begin if This'Address = ADC1_Base then RCC_Periph.AHB1ENR.ADC12EN := True; elsif This'Address = ADC2_Base then RCC_Periph.AHB1ENR.ADC12EN := True; elsif This'Address = ADC3_Base then RCC_Periph.AHB4ENR.ADC3EN := True; else raise Unknown_Device; end if; end Enable_Clock; ------------------------- -- Reset_All_ADC_Units -- ------------------------- procedure Reset_All_ADC_Units is begin RCC_Periph.AHB1RSTR.ADC12RST := True; RCC_Periph.AHB1RSTR.ADC12RST := False; RCC_Periph.AHB4RSTR.ADC3RST := True; RCC_Periph.AHB4RSTR.ADC3RST := False; end Reset_All_ADC_Units; ------------------------- -- Select_Clock_Source -- ------------------------- procedure Select_Clock_Source (This : Analog_To_Digital_Converter; Source : ADC_Clock_Source) is begin if This'Address = ADC1_Base or This'Address = ADC2_Base or This'Address = ADC3_Base then RCC_Periph.D3CCIPR.ADCSEL := Source'Enum_Rep; else raise Unknown_Device; end if; end Select_Clock_Source; ----------------------- -- Read_Clock_Source -- ----------------------- function Read_Clock_Source (This : Analog_To_Digital_Converter) return ADC_Clock_Source is begin if This'Address = ADC1_Base or This'Address = ADC2_Base or This'Address = ADC3_Base then return ADC_Clock_Source'Val (RCC_Periph.D3CCIPR.ADCSEL); else raise Unknown_Device; end if; end Read_Clock_Source; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased Digital_To_Analog_Converter) is begin if This'Address = DAC_Base then RCC_Periph.APB1LENR.DAC12EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased Digital_To_Analog_Converter) is begin if This'Address = DAC_Base then RCC_Periph.APB1LRSTR.DAC12RST := True; RCC_Periph.APB1LRSTR.DAC12RST := False; else raise Unknown_Device; end if; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : SAI_Port) is begin if This'Address = SAI1_Base then RCC_Periph.APB2ENR.SAI1EN := True; elsif This'Address = SAI2_Base then RCC_Periph.APB2ENR.SAI2EN := True; elsif This'Address = SAI3_Base then RCC_Periph.APB2ENR.SAI3EN := True; elsif This'Address = SAI4_Base then RCC_Periph.APB4ENR.SAI4EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : SAI_Port) is begin if This'Address = SAI1_Base then RCC_Periph.APB2RSTR.SAI1RST := True; RCC_Periph.APB2RSTR.SAI1RST := False; elsif This'Address = SAI2_Base then RCC_Periph.APB2RSTR.SAI2RST := True; RCC_Periph.APB2RSTR.SAI2RST := False; elsif This'Address = SAI3_Base then RCC_Periph.APB2RSTR.SAI3RST := True; RCC_Periph.APB2RSTR.SAI3RST := False; elsif This'Address = SAI4_Base then RCC_Periph.APB4RSTR.SAI4RST := True; RCC_Periph.APB4RSTR.SAI4RST := False; else raise Unknown_Device; end if; end Reset; ------------------------- -- Select_Clock_Source -- ------------------------- procedure Select_Clock_Source (This : SAI_Port; Source : SAI_Clock_Source) is begin if This'Address = SAI1_Base then RCC_Periph.D2CCIP1R.SAI1SEL := Source'Enum_Rep; elsif This'Address = SAI2_Base or This'Address = SAI3_Base then RCC_Periph.D2CCIP1R.SAI23SEL := Source'Enum_Rep; elsif This'Address = SAI4_Base then RCC_Periph.D3CCIPR.SAI4ASEL := Source'Enum_Rep; RCC_Periph.D3CCIPR.SAI4BSEL := Source'Enum_Rep; else raise Unknown_Device; end if; end Select_Clock_Source; ------------------------ -- Read_Clock_Source -- ------------------------ function Read_Clock_Source (This : SAI_Port) return SAI_Clock_Source is begin if This'Address = SAI1_Base then return SAI_Clock_Source'Val (RCC_Periph.D2CCIP1R.SAI1SEL); elsif This'Address = SAI2_Base or This'Address = SAI3_Base then return SAI_Clock_Source'Val (RCC_Periph.D2CCIP1R.SAI23SEL); elsif This'Address = SAI4_Base then return SAI_Clock_Source'Val (RCC_Periph.D3CCIPR.SAI4ASEL); else raise Unknown_Device; end if; end Read_Clock_Source; ------------------------- -- Get_Clock_Frequency -- ------------------------- function Get_Clock_Frequency (This : SAI_Port) return UInt32 is Input_Selector : SAI_Clock_Source; VCO_Input : UInt32; begin if This'Address = SAI1_Base then Input_Selector := SAI_Clock_Source'Val (RCC_Periph.D2CCIP1R.SAI1SEL); elsif This'Address = SAI2_Base or This'Address = SAI3_Base then Input_Selector := SAI_Clock_Source'Val (RCC_Periph.D2CCIP1R.SAI23SEL); elsif This'Address = SAI4_Base then Input_Selector := SAI_Clock_Source'Val (RCC_Periph.D3CCIPR.SAI4ASEL); else raise Unknown_Device; end if; case Input_Selector is when PLL1Q => VCO_Input := System_Clock_Frequencies.PCLK1; -- PLL1Q; when PLL2P => VCO_Input := System_Clock_Frequencies.PCLK1; -- PLL2P; when PLL3P => VCO_Input := System_Clock_Frequencies.PCLK1; -- PLL3P; when I2S_CKIN => VCO_Input := I2SCLK; when PER => VCO_Input := System_Clock_Frequencies.PERCLK; end case; return VCO_Input; end Get_Clock_Frequency; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : CRC_32) is pragma Unreferenced (This); begin RCC_Periph.AHB4ENR.CRCEN := True; end Enable_Clock; ------------------- -- Disable_Clock -- ------------------- procedure Disable_Clock (This : CRC_32) is pragma Unreferenced (This); begin RCC_Periph.AHB4ENR.CRCEN := False; end Disable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : CRC_32) is pragma Unreferenced (This); begin RCC_Periph.AHB4RSTR.CRCRST := True; RCC_Periph.AHB4RSTR.CRCRST := False; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : RNG_Generator) is pragma Unreferenced (This); begin RCC_Periph.AHB2ENR.RNGEN := True; end Enable_Clock; ------------------- -- Disable_Clock -- ------------------- procedure Disable_Clock (This : RNG_Generator) is pragma Unreferenced (This); begin RCC_Periph.AHB2ENR.RNGEN := False; end Disable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : RNG_Generator) is pragma Unreferenced (This); begin RCC_Periph.AHB2RSTR.RNGRST := True; RCC_Periph.AHB2RSTR.RNGRST := False; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased DMA_Controller) is begin if This'Address = STM32_SVD.DMA1_Base then RCC_Periph.AHB1ENR.DMA1EN := True; elsif This'Address = STM32_SVD.DMA2_Base then RCC_Periph.AHB1ENR.DMA2EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased DMA_Controller) is begin if This'Address = STM32_SVD.DMA1_Base then RCC_Periph.AHB1RSTR.DMA1RST := True; RCC_Periph.AHB1RSTR.DMA1RST := False; elsif This'Address = STM32_SVD.DMA2_Base then RCC_Periph.AHB1RSTR.DMA2RST := True; RCC_Periph.AHB1RSTR.DMA2RST := False; else raise Unknown_Device; end if; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased USART) is begin if This.Periph.all'Address = USART1_Base then RCC_Periph.APB2ENR.USART1EN := True; elsif This.Periph.all'Address = USART2_Base then RCC_Periph.APB1LENR.USART2EN := True; elsif This.Periph.all'Address = USART3_Base then RCC_Periph.APB1LENR.USART3EN := True; elsif This.Periph.all'Address = UART4_Base then RCC_Periph.APB1LENR.UART4EN := True; elsif This.Periph.all'Address = UART5_Base then RCC_Periph.APB1LENR.UART5EN := True; elsif This.Periph.all'Address = USART6_Base then RCC_Periph.APB2ENR.USART6EN := True; elsif This.Periph.all'Address = UART7_Base then RCC_Periph.APB1LENR.UART7EN := True; elsif This.Periph.all'Address = UART8_Base then RCC_Periph.APB1LENR.UART8EN := True; elsif This.Periph.all'Address = LPUART1_Base then RCC_Periph.APB4ENR.LPUART1EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased USART) is begin if This.Periph.all'Address = USART1_Base then RCC_Periph.APB2RSTR.USART1RST := True; RCC_Periph.APB2RSTR.USART1RST := False; elsif This.Periph.all'Address = USART2_Base then RCC_Periph.APB1LRSTR.USART2RST := True; RCC_Periph.APB1LRSTR.USART2RST := False; elsif This.Periph.all'Address = USART3_Base then RCC_Periph.APB1LRSTR.USART3RST := True; RCC_Periph.APB1LRSTR.USART3RST := False; elsif This.Periph.all'Address = UART4_Base then RCC_Periph.APB1LRSTR.UART4RST := True; RCC_Periph.APB1LRSTR.UART4RST := False; elsif This.Periph.all'Address = UART5_Base then RCC_Periph.APB1LRSTR.UART5RST := True; RCC_Periph.APB1LRSTR.UART5RST := False; elsif This.Periph.all'Address = USART6_Base then RCC_Periph.APB2RSTR.USART6RST := True; RCC_Periph.APB2RSTR.USART6RST := False; elsif This.Periph.all'Address = UART7_Base then RCC_Periph.APB1LRSTR.UART7RST := True; RCC_Periph.APB1LRSTR.UART7RST := False; elsif This.Periph.all'Address = UART8_Base then RCC_Periph.APB1LRSTR.UART8RST := True; RCC_Periph.APB1LRSTR.UART8RST := False; elsif This.Periph.all'Address = LPUART1_Base then RCC_Periph.APB4RSTR.LPUART1RST := True; RCC_Periph.APB4RSTR.LPUART1RST := False; else raise Unknown_Device; end if; end Reset; ------------------------- -- Select_Clock_Source -- ------------------------- procedure Select_Clock_Source (This : aliased USART; Source : USART_Clock_Source) is begin if This'Address = USART1_Base or This'Address = USART6_Base then RCC_Periph.D2CCIP2R.USART16SEL := Source'Enum_Rep; elsif This'Address = USART2_Base or This'Address = USART3_Base or This'Address = UART4_Base or This'Address = UART5_Base or This'Address = UART7_Base or This'Address = UART8_Base then RCC_Periph.D2CCIP2R.USART234578SEL := Source'Enum_Rep; elsif This'Address = LPUART1_Base then RCC_Periph.D3CCIPR.LPUART1SEL := Source'Enum_Rep; else raise Unknown_Device; end if; end Select_Clock_Source; ----------------------- -- Read_Clock_Source -- ----------------------- function Read_Clock_Source (This : aliased USART) return USART_Clock_Source is begin if This'Address = USART1_Base or This'Address = USART6_Base then return USART_Clock_Source'Val (RCC_Periph.D2CCIP2R.USART16SEL); elsif This'Address = USART2_Base or This'Address = USART3_Base or This'Address = UART4_Base or This'Address = UART5_Base or This'Address = UART7_Base or This'Address = UART8_Base then return USART_Clock_Source'Val (RCC_Periph.D2CCIP2R.USART234578SEL); elsif This'Address = LPUART1_Base then return USART_Clock_Source'Val (RCC_Periph.D3CCIPR.LPUART1SEL); else raise Unknown_Device; end if; end Read_Clock_Source; ------------------------- -- Get_Clock_Frequency -- ------------------------- function Get_Clock_Frequency (This : USART) return UInt32 is Input_Selector : USART_Clock_Source; Clock_Input : UInt32; begin if This'Address = USART1_Base or This'Address = USART6_Base then Input_Selector := USART_Clock_Source'Val (RCC_Periph.D2CCIP2R.USART16SEL); elsif This'Address = USART2_Base or This'Address = USART3_Base or This'Address = UART4_Base or This'Address = UART5_Base or This'Address = UART7_Base or This'Address = UART8_Base then Input_Selector := USART_Clock_Source'Val (RCC_Periph.D2CCIP2R.USART234578SEL); elsif This'Address = LPUART1_Base then Input_Selector := USART_Clock_Source'Val (RCC_Periph.D3CCIPR.LPUART1SEL); else raise Unknown_Device; end if; case Input_Selector is when Option_1 => if This'Address = USART1_Base or This'Address = USART6_Base then Clock_Input := System_Clock_Frequencies.PCLK2; elsif This'Address = USART2_Base or This'Address = USART3_Base or This'Address = UART4_Base or This'Address = UART5_Base or This'Address = UART7_Base or This'Address = UART8_Base then Clock_Input := System_Clock_Frequencies.PCLK1; else -- LPUART1 Clock_Input := System_Clock_Frequencies.PCLK3; end if; when PLL2Q => Clock_Input := System_Clock_Frequencies.PCLK1; when PLL3Q => Clock_Input := System_Clock_Frequencies.PCLK1; when HSI => Clock_Input := HSI_VALUE; when CSI => Clock_Input := CSI_VALUE; when LSE => Clock_Input := LSE_VALUE; end case; return Clock_Input; end Get_Clock_Frequency; ---------------- -- As_Port_Id -- ---------------- function As_Port_Id (Port : I2C_Port'Class) return I2C_Port_Id is begin if Port.Periph.all'Address = I2C1_Base then return I2C_Id_1; elsif Port.Periph.all'Address = I2C2_Base then return I2C_Id_2; elsif Port.Periph.all'Address = I2C3_Base then return I2C_Id_3; elsif Port.Periph.all'Address = I2C4_Base then return I2C_Id_4; else raise Unknown_Device; end if; end As_Port_Id; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased I2C_Port'Class) is begin Enable_Clock (As_Port_Id (This)); end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : I2C_Port_Id) is begin case This is when I2C_Id_1 => RCC_Periph.APB1LENR.I2C1EN := True; when I2C_Id_2 => RCC_Periph.APB1LENR.I2C2EN := True; when I2C_Id_3 => RCC_Periph.APB1LENR.I2C3EN := True; when I2C_Id_4 => RCC_Periph.APB4ENR.I2C4EN := True; end case; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : I2C_Port'Class) is begin Reset (As_Port_Id (This)); end Reset; ----------- -- Reset -- ----------- procedure Reset (This : I2C_Port_Id) is begin case This is when I2C_Id_1 => RCC_Periph.APB1LRSTR.I2C1RST := True; RCC_Periph.APB1LRSTR.I2C1RST := False; when I2C_Id_2 => RCC_Periph.APB1LRSTR.I2C2RST := True; RCC_Periph.APB1LRSTR.I2C2RST := False; when I2C_Id_3 => RCC_Periph.APB1LRSTR.I2C3RST := True; RCC_Periph.APB1LRSTR.I2C3RST := False; when I2C_Id_4 => RCC_Periph.APB4RSTR.I2C4RST := True; RCC_Periph.APB4RSTR.I2C4RST := False; end case; end Reset; ------------------------- -- Select_Clock_Source -- ------------------------- procedure Select_Clock_Source (This : I2C_Port'Class; Source : I2C_Clock_Source) is begin Select_Clock_Source (As_Port_Id (This), Source); end Select_Clock_Source; ------------------------- -- Select_Clock_Source -- ------------------------- procedure Select_Clock_Source (This : I2C_Port_Id; Source : I2C_Clock_Source) is begin case This is when I2C_Id_1 | I2C_Id_2 | I2C_Id_3 => RCC_Periph.D2CCIP2R.I2C123SEL := Source'Enum_Rep; when I2C_Id_4 => RCC_Periph.D3CCIPR.I2C4SEL := Source'Enum_Rep; end case; end Select_Clock_Source; ----------------------- -- Read_Clock_Source -- ----------------------- function Read_Clock_Source (This : I2C_Port'Class) return I2C_Clock_Source is begin return Read_Clock_Source (As_Port_Id (This)); end Read_Clock_Source; ------------------------ -- Read_Clock_Source -- ------------------------ function Read_Clock_Source (This : I2C_Port_Id) return I2C_Clock_Source is begin case This is when I2C_Id_1 | I2C_Id_2 | I2C_Id_3 => return I2C_Clock_Source'Val (RCC_Periph.D2CCIP2R.I2C123SEL); when I2C_Id_4 => return I2C_Clock_Source'Val (RCC_Periph.D3CCIPR.I2C4SEL); end case; end Read_Clock_Source; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : SPI_Port'Class) is begin if This.Periph.all'Address = SPI1_Base then RCC_Periph.APB2ENR.SPI1EN := True; elsif This.Periph.all'Address = SPI2_Base then RCC_Periph.APB1LENR.SPI2EN := True; elsif This.Periph.all'Address = SPI3_Base then RCC_Periph.APB1LENR.SPI3EN := True; elsif This.Periph.all'Address = SPI4_Base then RCC_Periph.APB2ENR.SPI4EN := True; elsif This.Periph.all'Address = SPI5_Base then RCC_Periph.APB2ENR.SPI5EN := True; elsif This.Periph.all'Address = SPI6_Base then RCC_Periph.APB4ENR.SPI6EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : SPI_Port'Class) is begin if This.Periph.all'Address = SPI1_Base then RCC_Periph.APB2RSTR.SPI1RST := True; RCC_Periph.APB2RSTR.SPI1RST := False; elsif This.Periph.all'Address = SPI2_Base then RCC_Periph.APB1LRSTR.SPI2RST := True; RCC_Periph.APB1LRSTR.SPI2RST := False; elsif This.Periph.all'Address = SPI3_Base then RCC_Periph.APB1LRSTR.SPI3RST := True; RCC_Periph.APB1LRSTR.SPI3RST := False; elsif This.Periph.all'Address = SPI4_Base then RCC_Periph.APB2RSTR.SPI4RST := True; RCC_Periph.APB2RSTR.SPI4RST := False; elsif This.Periph.all'Address = SPI5_Base then RCC_Periph.APB2RSTR.SPI5RST := True; RCC_Periph.APB2RSTR.SPI5RST := False; elsif This.Periph.all'Address = SPI6_Base then RCC_Periph.APB4RSTR.SPI6RST := True; RCC_Periph.APB4RSTR.SPI6RST := False; else raise Unknown_Device; end if; end Reset; ------------------------- -- Select_Clock_Source -- ------------------------- procedure Select_Clock_Source (This : SPI_Port'Class; Source : SPI_Clock_Source) is begin if This.Periph.all'Address = SPI1_Base or This.Periph.all'Address = SPI2_Base or This.Periph.all'Address = SPI3_Base then RCC_Periph.D2CCIP1R.SPI123SEL := Source'Enum_Rep; elsif This.Periph.all'Address = SPI4_Base or This.Periph.all'Address = SPI5_Base then RCC_Periph.D2CCIP1R.SPI45SEL := Source'Enum_Rep; elsif This.Periph.all'Address = SPI6_Base then RCC_Periph.D3CCIPR.SPI6SEL := Source'Enum_Rep; else raise Unknown_Device; end if; end Select_Clock_Source; ------------------------ -- Read_Clock_Source -- ------------------------ function Read_Clock_Source (This : SPI_Port'Class) return SPI_Clock_Source is begin if This.Periph.all'Address = SPI1_Base or This.Periph.all'Address = SPI2_Base or This.Periph.all'Address = SPI3_Base then return SPI_Clock_Source'Val (RCC_Periph.D2CCIP1R.SPI123SEL); elsif This.Periph.all'Address = SPI4_Base or This.Periph.all'Address = SPI5_Base then return SPI_Clock_Source'Val (RCC_Periph.D2CCIP1R.SPI45SEL); elsif This.Periph.all'Address = SPI6_Base then return SPI_Clock_Source'Val (RCC_Periph.D3CCIPR.SPI6SEL); else raise Unknown_Device; end if; end Read_Clock_Source; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : I2S_Port) is begin if This.Periph.all'Address = SPI1_Base then RCC_Periph.APB2ENR.SPI1EN := True; elsif This.Periph.all'Address = SPI2_Base then RCC_Periph.APB1LENR.SPI2EN := True; elsif This.Periph.all'Address = SPI3_Base then RCC_Periph.APB1LENR.SPI3EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : I2S_Port) is begin if This.Periph.all'Address = SPI1_Base then RCC_Periph.APB2RSTR.SPI1RST := True; RCC_Periph.APB2RSTR.SPI1RST := False; elsif This.Periph.all'Address = SPI2_Base then RCC_Periph.APB1LRSTR.SPI2RST := True; RCC_Periph.APB1LRSTR.SPI2RST := False; elsif This.Periph.all'Address = SPI3_Base then RCC_Periph.APB1LRSTR.SPI3RST := True; RCC_Periph.APB1LRSTR.SPI3RST := False; else raise Unknown_Device; end if; end Reset; ------------------------- -- Select_Clock_Source -- ------------------------- procedure Select_Clock_Source (This : I2S_Port'Class; Source : I2S_Clock_Source) is begin if This.Periph.all'Address = SPI1_Base or This.Periph.all'Address = SPI2_Base or This.Periph.all'Address = SPI3_Base then RCC_Periph.D2CCIP1R.SPI123SEL := Source'Enum_Rep; else raise Unknown_Device; end if; end Select_Clock_Source; ----------------------- -- Read_Clock_Source -- ----------------------- function Read_Clock_Source (This : I2S_Port'Class) return I2S_Clock_Source is begin if This.Periph.all'Address = SPI1_Base or This.Periph.all'Address = SPI2_Base or This.Periph.all'Address = SPI3_Base then return I2S_Clock_Source'Val (RCC_Periph.D2CCIP1R.SPI123SEL); else raise Unknown_Device; end if; end Read_Clock_Source; ------------------------- -- Get_Clock_Frequency -- ------------------------- function Get_Clock_Frequency (This : I2S_Port) return UInt32 is Source : constant I2S_Clock_Source := I2S_Clock_Source'Val (RCC_Periph.D2CCIP1R.SPI123SEL); begin if This.Periph.all'Address = SPI1_Base or This.Periph.all'Address = SPI2_Base or This.Periph.all'Address = SPI3_Base then case Source is when PLL1Q => return System_Clock_Frequencies.PCLK1; when PLL2P => return System_Clock_Frequencies.PCLK1; when PLL3P => return System_Clock_Frequencies.PCLK1; when I2S_CKIN => return I2SCLK; when PER => return System_Clock_Frequencies.PERCLK; end case; else raise Unknown_Device; end if; end Get_Clock_Frequency; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : RTC_Device) is pragma Unreferenced (This); begin RCC_Periph.BDCR.RTCEN := True; end Enable_Clock; ------------------------- -- Select_Clock_Source -- ------------------------- procedure Select_Clock_Source (This : RTC_Device; Source : RTC_Clock_Source; HSE_Pre : RTC_HSE_Prescaler_Range := RTC_HSE_Prescaler_Range'First) is pragma Unreferenced (This); begin RCC_Periph.BDCR.RTCSEL := Source'Enum_Rep; if Source = HSE then RCC_Periph.CFGR.RTCPRE := UInt6 (HSE_Pre); end if; end Select_Clock_Source; ------------------------ -- Read_Clock_Source -- ------------------------ function Read_Clock_Source (This : RTC_Device) return RTC_Clock_Source is pragma Unreferenced (This); begin return RTC_Clock_Source'Val (RCC_Periph.BDCR.RTCSEL); end Read_Clock_Source; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : Timer) is begin if This'Address = TIM1_Base then RCC_Periph.APB2ENR.TIM1EN := True; elsif This'Address = TIM2_Base then RCC_Periph.APB1LENR.TIM2EN := True; elsif This'Address = TIM3_Base then RCC_Periph.APB1LENR.TIM3EN := True; elsif This'Address = TIM4_Base then RCC_Periph.APB1LENR.TIM4EN := True; elsif This'Address = TIM5_Base then RCC_Periph.APB1LENR.TIM5EN := True; elsif This'Address = TIM6_Base then RCC_Periph.APB1LENR.TIM6EN := True; elsif This'Address = TIM7_Base then RCC_Periph.APB1LENR.TIM7EN := True; elsif This'Address = TIM8_Base then RCC_Periph.APB2ENR.TIM8EN := True; elsif This'Address = TIM12_Base then RCC_Periph.APB1LENR.TIM12EN := True; elsif This'Address = TIM13_Base then RCC_Periph.APB1LENR.TIM13EN := True; elsif This'Address = TIM14_Base then RCC_Periph.APB1LENR.TIM14EN := True; elsif This'Address = TIM15_Base then RCC_Periph.APB2ENR.TIM15EN := True; elsif This'Address = TIM16_Base then RCC_Periph.APB2ENR.TIM16EN := True; elsif This'Address = TIM17_Base then RCC_Periph.APB2ENR.TIM17EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : Timer) is begin if This'Address = TIM1_Base then RCC_Periph.APB2RSTR.TIM1RST := True; RCC_Periph.APB2RSTR.TIM1RST := False; elsif This'Address = TIM2_Base then RCC_Periph.APB1LRSTR.TIM2RST := True; RCC_Periph.APB1LRSTR.TIM2RST := False; elsif This'Address = TIM3_Base then RCC_Periph.APB1LRSTR.TIM3RST := True; RCC_Periph.APB1LRSTR.TIM3RST := False; elsif This'Address = TIM4_Base then RCC_Periph.APB1LRSTR.TIM4RST := True; RCC_Periph.APB1LRSTR.TIM4RST := False; elsif This'Address = TIM5_Base then RCC_Periph.APB1LRSTR.TIM5RST := True; RCC_Periph.APB1LRSTR.TIM5RST := False; elsif This'Address = TIM6_Base then RCC_Periph.APB1LRSTR.TIM6RST := True; RCC_Periph.APB1LRSTR.TIM6RST := False; elsif This'Address = TIM7_Base then RCC_Periph.APB1LRSTR.TIM7RST := True; RCC_Periph.APB1LRSTR.TIM7RST := False; elsif This'Address = TIM8_Base then RCC_Periph.APB2RSTR.TIM8RST := True; RCC_Periph.APB2RSTR.TIM8RST := False; elsif This'Address = TIM12_Base then RCC_Periph.APB1LRSTR.TIM12RST := True; RCC_Periph.APB1LRSTR.TIM12RST := False; elsif This'Address = TIM13_Base then RCC_Periph.APB1LRSTR.TIM13RST := True; RCC_Periph.APB1LRSTR.TIM13RST := False; elsif This'Address = TIM14_Base then RCC_Periph.APB1LRSTR.TIM14RST := True; RCC_Periph.APB1LRSTR.TIM14RST := False; elsif This'Address = TIM15_Base then RCC_Periph.APB2RSTR.TIM15RST := True; RCC_Periph.APB2RSTR.TIM15RST := False; elsif This'Address = TIM16_Base then RCC_Periph.APB2RSTR.TIM16RST := True; RCC_Periph.APB2RSTR.TIM16RST := False; elsif This'Address = TIM17_Base then RCC_Periph.APB2RSTR.TIM17RST := True; RCC_Periph.APB2RSTR.TIM17RST := False; else raise Unknown_Device; end if; end Reset; ------------------------- -- Get_Clock_Frequency -- ------------------------- function Get_Clock_Frequency (This : Timer) return UInt32 is begin -- TIMs 2 .. 7, 12 .. 14 if This'Address = TIM2_Base or This'Address = TIM3_Base or This'Address = TIM4_Base or This'Address = TIM5_Base or This'Address = TIM6_Base or This'Address = TIM7_Base or This'Address = TIM12_Base or This'Address = TIM13_Base or This'Address = TIM14_Base then return System_Clock_Frequencies.TIMCLK1; -- TIMs 1, 8, 15 .. 17 elsif This'Address = TIM1_Base or This'Address = TIM8_Base or This'Address = TIM15_Base or This'Address = TIM16_Base or This'Address = TIM17_Base then return System_Clock_Frequencies.TIMCLK2; else raise Unknown_Device; end if; end Get_Clock_Frequency; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : LPTimer) is begin if This'Address = LPTIM1_Base then RCC_Periph.APB1LENR.LPTIM1EN := True; elsif This'Address = LPTIM2_Base then RCC_Periph.APB4ENR.LPTIM2EN := True; elsif This'Address = LPTIM3_Base then RCC_Periph.APB4ENR.LPTIM3EN := True; elsif This'Address = LPTIM4_Base then RCC_Periph.APB4ENR.LPTIM4EN := True; elsif This'Address = LPTIM5_Base then RCC_Periph.APB4ENR.LPTIM5EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : LPTimer) is begin if This'Address = LPTIM1_Base then RCC_Periph.APB1LRSTR.LPTIM1RST := True; RCC_Periph.APB1LRSTR.LPTIM1RST := False; elsif This'Address = LPTIM2_Base then RCC_Periph.APB4RSTR.LPTIM2RST := True; RCC_Periph.APB4RSTR.LPTIM2RST := False; elsif This'Address = LPTIM3_Base then RCC_Periph.APB4RSTR.LPTIM3RST := True; RCC_Periph.APB4RSTR.LPTIM3RST := False; elsif This'Address = LPTIM4_Base then RCC_Periph.APB4RSTR.LPTIM4RST := True; RCC_Periph.APB4RSTR.LPTIM4RST := False; elsif This'Address = LPTIM5_Base then RCC_Periph.APB4RSTR.LPTIM5RST := True; RCC_Periph.APB4RSTR.LPTIM5RST := False; else raise Unknown_Device; end if; end Reset; ------------------------- -- Select_Clock_Source -- ------------------------- procedure Select_Clock_Source (This : LPTimer; Source : LPTimer_Clock_Source) is begin if This'Address = LPTIM1_Base then RCC_Periph.D2CCIP2R.LPTIM1SEL := Source'Enum_Rep; elsif This'Address = LPTIM2_Base then RCC_Periph.D3CCIPR.LPTIM2SEL := Source'Enum_Rep; elsif This'Address = LPTIM3_Base or This'Address = LPTIM4_Base or This'Address = LPTIM5_Base then RCC_Periph.D3CCIPR.LPTIM345SEL := Source'Enum_Rep; else raise Unknown_Device; end if; end Select_Clock_Source; ----------------------- -- Read_Clock_Source -- ----------------------- function Read_Clock_Source (This : LPTimer) return LPTimer_Clock_Source is begin if This'Address = LPTIM1_Base then return LPTimer_Clock_Source'Val (RCC_Periph.D2CCIP2R.LPTIM1SEL); elsif This'Address = LPTIM2_Base then return LPTimer_Clock_Source'Val (RCC_Periph.D3CCIPR.LPTIM2SEL); elsif This'Address = LPTIM3_Base or This'Address = LPTIM4_Base or This'Address = LPTIM5_Base then return LPTimer_Clock_Source'Val (RCC_Periph.D3CCIPR.LPTIM345SEL); else raise Unknown_Device; end if; end Read_Clock_Source; ------------------------- -- Get_Clock_Frequency -- ------------------------- function Get_Clock_Frequency (This : LPTimer) return UInt32 is begin if This'Address = LPTIM1_Base then return System_Clock_Frequencies.PCLK1; elsif This'Address = LPTIM2_Base or This'Address = LPTIM3_Base or This'Address = LPTIM4_Base or This'Address = LPTIM5_Base then return System_Clock_Frequencies.PCLK4; else raise Unknown_Device; end if; end Get_Clock_Frequency; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : HRTimer_Master) is begin if This'Address = HRTIM_Master_Base then RCC_Periph.APB2ENR.HRTIMEN := True; else raise Unknown_Device; end if; end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : HRTimer_Channel) is begin if This'Address = HRTIM_TIMA_Base or This'Address = HRTIM_TIMB_Base or This'Address = HRTIM_TIMC_Base or This'Address = HRTIM_TIMD_Base or This'Address = HRTIM_TIME_Base then RCC_Periph.APB2ENR.HRTIMEN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : HRTimer_Master) is begin if This'Address = HRTIM_Master_Base then RCC_Periph.APB2RSTR.HRTIMRST := True; RCC_Periph.APB2RSTR.HRTIMRST := False; else raise Unknown_Device; end if; end Reset; ----------- -- Reset -- ----------- procedure Reset (This : HRTimer_Channel) is begin if This'Address = HRTIM_TIMA_Base or This'Address = HRTIM_TIMB_Base or This'Address = HRTIM_TIMC_Base or This'Address = HRTIM_TIMD_Base or This'Address = HRTIM_TIME_Base then RCC_Periph.APB2RSTR.HRTIMRST := True; RCC_Periph.APB2RSTR.HRTIMRST := False; else raise Unknown_Device; end if; end Reset; ---------------------------- -- Select_Clock_Frequency -- ---------------------------- procedure Select_Clock_Source (This : HRTimer_Master; Source : HRTimer_Clock_Source) is pragma Unreferenced (This); begin RCC_Periph.CFGR.HRTIMSEL := Source = CPUCLK; end Select_Clock_Source; ------------------------- -- Get_Clock_Frequency -- ------------------------- function Read_Clock_Source (This : HRTimer_Master) return HRTimer_Clock_Source is pragma Unreferenced (This); begin if RCC_Periph.CFGR.HRTIMSEL then return CPUCLK; else return TIMCLK; end if; end Read_Clock_Source; ------------------------- -- Get_Clock_Frequency -- ------------------------- function Get_Clock_Frequency (This : HRTimer_Master) return UInt32 is pragma Unreferenced (This); begin return System_Clock_Frequencies.TIMCLK3; end Get_Clock_Frequency; ------------------------- -- Get_Clock_Frequency -- ------------------------- function Get_Clock_Frequency (This : HRTimer_Channel) return UInt32 is pragma Unreferenced (This); begin return System_Clock_Frequencies.TIMCLK3; end Get_Clock_Frequency; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased Comparator) is begin if This'Address = Comp_1'Address or This'Address = Comp_2'Address then RCC_Periph.APB4ENR.COMP12EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased Comparator) is begin if This'Address = Comp_1'Address or This'Address = Comp_2'Address then RCC_Periph.APB4RSTR.COMP12RST := True; RCC_Periph.APB4RSTR.COMP12RST := False; else raise Unknown_Device; end if; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased Operational_Amplifier) is begin if This'Address = Opamp_1'Address or This'Address = Opamp_2'Address then RCC_Periph.APB1HENR.OPAMPEN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased Operational_Amplifier) is begin if This'Address = Opamp_1'Address or This'Address = Opamp_2'Address then RCC_Periph.APB1HRSTR.OPAMPRST := True; RCC_Periph.APB1HRSTR.OPAMPRST := False; else raise Unknown_Device; end if; end Reset; ------------------------------ -- System_Clock_Frequencies -- ------------------------------ function System_Clock_Frequencies return RCC_System_Clocks is Source : constant SYSCLK_Clock_Source := SYSCLK_Clock_Source'Val (RCC_Periph.CFGR.SWS); -- Get System_Clock_Mux selection Result : RCC_System_Clocks; begin -- System clock Mux case Source is -- HSE as source when SYSCLK_SRC_HSE => Result.SYSCLK := HSE_VALUE; -- HSI as source when SYSCLK_SRC_HSI => Result.SYSCLK := HSI_VALUE / (2 ** Natural (RCC_Periph.CR.HSIDIV)); -- CSI as source when SYSCLK_SRC_CSI => Result.SYSCLK := CSI_VALUE; -- PLL1 as source when SYSCLK_SRC_PLL1 => declare Pllm : constant UInt32 := UInt32 (RCC_Periph.PLLCKSELR.DIVM1); -- Get the correct value of Pll M divisor Plln : constant UInt32 := UInt32 (RCC_Periph.PLL1DIVR.DIVN1 + 1); -- Get the correct value of Pll N multiplier Pllp : constant UInt32 := UInt32 (RCC_Periph.PLL1DIVR.DIVR1 + 1); -- Get the correct value of Pll R divisor PLLSRC : constant PLL_Clock_Source := PLL_Clock_Source'Val (RCC_Periph.PLLCKSELR.PLLSRC); -- Get PLL Source Mux PLLCLK : UInt32; begin case PLLSRC is when PLL_SRC_HSE => -- HSE as source PLLCLK := ((HSE_VALUE / Pllm) * Plln) / Pllp; when PLL_SRC_HSI => -- HSI as source PLLCLK := ((HSI_VALUE / Pllm) * Plln) / Pllp; when PLL_SRC_CSI => -- CSI as source PLLCLK := ((CSI_VALUE / Pllm) * Plln) / Pllp; end case; Result.SYSCLK := PLLCLK; end; end case; declare HPRE1 : constant UInt4 := RCC_Periph.D1CFGR.D1CPRE; HPRE2 : constant UInt4 := RCC_Periph.D1CFGR.HPRE; PPRE1 : constant UInt3 := RCC_Periph.D2CFGR.D2PPRE1; PPRE2 : constant UInt3 := RCC_Periph.D2CFGR.D2PPRE2; PPRE3 : constant UInt3 := RCC_Periph.D1CFGR.D1PPRE; PPRE4 : constant UInt3 := RCC_Periph.D3CFGR.D3PPRE; begin Result.HCLK1 := Result.SYSCLK / HPRE_Presc_Table (HPRE1); Result.HCLK2 := Result.HCLK1 / HPRE_Presc_Table (HPRE2); Result.PCLK1 := Result.HCLK2 / PPRE_Presc_Table (PPRE1); Result.PCLK2 := Result.HCLK2 / PPRE_Presc_Table (PPRE2); Result.PCLK3 := Result.HCLK2 / PPRE_Presc_Table (PPRE3); Result.PCLK4 := Result.HCLK2 / PPRE_Presc_Table (PPRE4); -- Timer clocks -- If APB1 (D2PPRE1) and APB2 (D2PPRE2) prescaler (D2PPRE1, D2PPRE2 -- in the RCC_D2CFGR register) are configured to a division factor of -- 1 or 2 with RCC_CFGR.TIMPRE = 0 (or also 4 with RCC_CFGR.TIMPRE -- = 1), then TIMxCLK = PCLKx. -- Otherwise, the timer clock frequencies are set to twice to the -- frequency of the APB domain to which the timers are connected with -- RCC_CFGR.TIMPRE = 0, so TIMxCLK = 2 x PCLKx (or TIMxCLK = -- 4 x PCLKx with RCC_CFGR.TIMPRE = 1). if not RCC_Periph.CFGR.TIMPRE then -- TIMs 2 .. 7, 12 .. 14 if PPRE1 <= 2 then Result.TIMCLK1 := Result.PCLK1; else Result.TIMCLK1 := Result.PCLK1 * 2; end if; -- TIMs TIMs 1, 8, 15 .. 17 if PPRE2 <= 2 then Result.TIMCLK2 := Result.PCLK2; else Result.TIMCLK2 := Result.PCLK2 * 2; end if; else -- TIMs 2 .. 7, 12 .. 14 if PPRE1 <= 4 then Result.TIMCLK1 := Result.PCLK1; else Result.TIMCLK1 := Result.PCLK1 * 4; end if; -- TIMs 1, 8, 15 .. 17 if PPRE2 <= 4 then Result.TIMCLK2 := Result.PCLK2; else Result.TIMCLK2 := Result.PCLK2 * 4; end if; end if; -- HRTIM clock -- If RCC_CFGR.HRTIMSEL = 0, HRTIM prescaler clock cource is the same -- as timer 2 (TIMCLK1), otherwise it is the CPU clock (HCLK2). if not RCC_Periph.CFGR.HRTIMSEL then Result.TIMCLK3 := Result.TIMCLK1; else Result.TIMCLK3 := Result.HCLK1; end if; end; declare Source : constant PER_Clock_Source := PER_Clock_Source'Val (RCC_Periph.D1CCIPR.CKPERSEL); -- Get PER_Clock_Mux selection begin case Source is -- HSE as source when PER_SRC_HSE => Result.PERCLK := HSE_VALUE; -- HSI as source when PER_SRC_HSI => Result.SYSCLK := HSI_VALUE / (2 ** Natural (RCC_Periph.CR.HSIDIV)); -- CSI as source when PER_SRC_CSI => Result.PERCLK := CSI_VALUE; end case; end; return Result; end System_Clock_Frequencies; end STM32.Device;
test/epic/Prelude/IO.agda
asr/agda-kanso
0
14053
<reponame>asr/agda-kanso module Prelude.IO where open import Prelude.Bool open import Prelude.Char open import Prelude.Nat open import Prelude.String open import Prelude.Unit open import Prelude.Vec open import Prelude.Float postulate IO : Set → Set {-# COMPILED_TYPE IO IO #-} infixl 1 _>>=_ postulate return : ∀ {A} → A → IO A _>>=_ : ∀ {A B} → IO A → (A → IO B) → IO B numArgs : Nat getArg : Nat -> String args : Vec String numArgs args = buildArgs numArgs where buildArgs : (n : Nat) -> Vec String n buildArgs Z = [] buildArgs (S n) = snoc (buildArgs n) (getArg n) {-# COMPILED_EPIC return (u1 : Unit, a : Any) -> Any = ioreturn(a) #-} {-# COMPILED_EPIC _>>=_ (u1 : Unit, u2 : Unit, x : Any, f : Any) -> Any = iobind(x,f) #-} {-# COMPILED_EPIC numArgs () -> BigInt = foreign BigInt "numArgsBig" () #-} {-# COMPILED_EPIC getArg (n : BigInt) -> Any = foreign Any "getArgBig" (n : BigInt) #-} postulate natToString : Nat -> String readNat : IO Nat readStr : IO String putStr : String -> IO Unit printChar : Char -> IO Unit putStrLn : String -> IO Unit putStrLn s = putStr s >>= \_ -> putStr "\n" printFloat : Float -> IO Unit printFloat f = putStr (floatToString f) printNat : Nat -> IO Unit printNat n = putStr (natToString n) printBool : Bool -> IO Unit printBool true = putStr "true" printBool false = putStr "false" {-# COMPILED_EPIC natToString (n : Any) -> String = bigToStr(n) #-} {-# COMPILED_EPIC readNat (u : Unit) -> Any = strToBig(readStr(u)) #-} {-# COMPILED_EPIC putStr (a : String, u : Unit) -> Unit = foreign Int "wputStr" (mkString(a) : String); primUnit #-} -- {-# COMPILED_EPIC putStrLn (a : String, u : Unit) -> Unit = putStrLn (a) #-} {-# COMPILED_EPIC readStr (u : Unit) -> Data = readStr(u) #-} {-# COMPILED_EPIC printChar (c : Int, u : Unit) -> Unit = printChar(c) #-} infixr 2 _<$>_ _<$>_ : {A B : Set}(f : A -> B)(m : IO A) -> IO B f <$> x = x >>= λ y -> return (f y) infixr 0 bind bind : ∀ {A B} → IO A → (A → IO B) → IO B bind m f = m >>= f infixr 0 then then : ∀ {A B} -> IO A -> IO B -> IO B then m f = m >>= λ _ -> f syntax bind e (\ x -> f) = x <- e , f syntax then e f = e ,, f
README/DependentlyTyped/NBE/Value.agda
nad/dependently-typed-syntax
5
4672
<filename>README/DependentlyTyped/NBE/Value.agda ------------------------------------------------------------------------ -- The values that are used by the NBE algorithm ------------------------------------------------------------------------ import Level open import Data.Universe module README.DependentlyTyped.NBE.Value (Uni₀ : Universe Level.zero Level.zero) where import Axiom.Extensionality.Propositional as E open import Data.Product renaming (curry to c; uncurry to uc) open import deBruijn.Substitution.Data open import Function using (id; _ˢ_; _$_) renaming (const to k) import README.DependentlyTyped.NormalForm as NF; open NF Uni₀ import README.DependentlyTyped.NormalForm.Substitution as NFS open NFS Uni₀ import README.DependentlyTyped.Term as Term; open Term Uni₀ open import Relation.Binary.PropositionalEquality as P using (_≡_) import Relation.Binary.PropositionalEquality.WithK as P open P.≡-Reasoning -- A wrapper which is used to make V̌alue "constructor-headed", which -- in turn makes Agda infer more types for us. infix 3 _⊢_⟨ne⟩ record _⊢_⟨ne⟩ (Γ : Ctxt) (σ : Type Γ) : Set where constructor [_]el field t : Γ ⊢ σ ⟨ ne ⟩ mutual -- The values. V̌alue′ : ∀ Γ sp (σ : IType Γ sp) → Set V̌alue′ Γ ⋆ σ = Γ ⊢ ⋆ , σ ⟨ ne ⟩ V̌alue′ Γ el σ = Γ ⊢ el , σ ⟨ne⟩ V̌alue′ Γ (π sp₁ sp₂) σ = Σ (V̌alue-π Γ sp₁ sp₂ σ) (W̌ell-behaved sp₁ sp₂ σ) V̌alue : (Γ : Ctxt) (σ : Type Γ) → Set V̌alue Γ (sp , σ) = V̌alue′ Γ sp σ V̌alue-π : ∀ Γ sp₁ sp₂ → IType Γ (π sp₁ sp₂) → Set V̌alue-π Γ sp₁ sp₂ σ = (Γ₊ : Ctxt₊ Γ) (v : V̌alue′ (Γ ++₊ Γ₊) sp₁ (ifst σ /̂I ŵk₊ Γ₊)) → V̌alue′ (Γ ++₊ Γ₊) sp₂ (isnd σ /̂I ŵk₊ Γ₊ ↑̂ ∘̂ ŝub ⟦̌ v ⟧) -- The use of Ctxt₊ rather than Ctxt⁺ in V̌alue-π is important: it -- seems to make it much easier to define weakening for V̌alue. W̌ell-behaved : ∀ {Γ} sp₁ sp₂ σ → V̌alue-π Γ sp₁ sp₂ σ → Set W̌ell-behaved {Γ} sp₁ sp₂ σ f = ∀ Γ₊ v → (⟦̌ σ ∣ f ⟧-π /̂Val ŵk₊ Γ₊) ˢ ⟦̌ v ⟧ ≅-Value ⟦̌ f Γ₊ v ⟧ -- The semantics of a value. ⟦̌_⟧ : ∀ {Γ sp σ} → V̌alue′ Γ sp σ → Value Γ (sp , σ) ⟦̌ v ⟧ = ⟦ řeify _ v ⟧n ⟦̌_∣_⟧-π : ∀ {Γ sp₁ sp₂} σ → V̌alue-π Γ sp₁ sp₂ σ → Value Γ (π sp₁ sp₂ , σ) ⟦̌ _ ∣ f ⟧-π = ⟦ řeify-π _ _ _ f ⟧n -- Neutral terms can be turned into normal terms using reflection -- followed by reification. ňeutral-to-normal : ∀ {Γ} sp {σ} → Γ ⊢ sp , σ ⟨ ne ⟩ → Γ ⊢ sp , σ ⟨ no ⟩ ňeutral-to-normal sp t = řeify sp (řeflect sp t) -- A normal term corresponding to variable zero. žero : ∀ {Γ} sp σ → Γ ▻ (sp , σ) ⊢ sp , σ /̂I ŵk ⟨ no ⟩ žero sp σ = ňeutral-to-normal sp (var zero[ -, σ ]) -- Reification. řeify : ∀ {Γ} sp {σ} → V̌alue′ Γ sp σ → Γ ⊢ sp , σ ⟨ no ⟩ řeify ⋆ t = ne ⋆ t řeify el [ t ]el = ne el t řeify (π sp₁ sp₂) f = řeify-π sp₁ sp₂ _ (proj₁ f) řeify-π : ∀ {Γ} sp₁ sp₂ σ → V̌alue-π Γ sp₁ sp₂ σ → Γ ⊢ π sp₁ sp₂ , σ ⟨ no ⟩ řeify-π {Γ} sp₁ sp₂ σ f = čast sp₁ σ $ ƛ (řeify sp₂ (f (fst σ ◅ ε) (řeflect sp₁ (var zero)))) čast : ∀ {Γ} sp₁ {sp₂} (σ : IType Γ (π sp₁ sp₂)) → let ρ̂ = ŵk ↑̂ ∘̂ ŝub ⟦ žero sp₁ (ifst σ) ⟧n in Γ ⊢ Type-π (fst σ) (snd σ /̂ ρ̂) ⟨ no ⟩ → Γ ⊢ -, σ ⟨ no ⟩ čast {Γ} sp₁ σ = P.subst (λ σ → Γ ⊢ σ ⟨ no ⟩) (≅-Type-⇒-≡ $ π-fst-snd-ŵk-ŝub-žero sp₁ σ) -- Reflection. řeflect : ∀ {Γ} sp {σ} → Γ ⊢ sp , σ ⟨ ne ⟩ → V̌alue Γ (sp , σ) řeflect ⋆ t = t řeflect el t = [ t ]el řeflect (π sp₁ sp₂) t = (λ Γ₊ v → řeflect sp₂ ((t /⊢n Renaming.wk₊ Γ₊) · řeify sp₁ v)) , řeflect-π-well-behaved sp₁ sp₂ t abstract řeflect-π-well-behaved : ∀ {Γ} sp₁ sp₂ {σ} (t : Γ ⊢ π sp₁ sp₂ , σ ⟨ ne ⟩) Γ₊ v → let t′ = ňeutral-to-normal sp₂ ((t /⊢n Renaming.wk) · žero sp₁ (ifst σ)) in (⟦ čast sp₁ σ (ƛ t′) ⟧n /̂Val ŵk₊ Γ₊) ˢ ⟦̌ v ⟧ ≅-Value ⟦ ňeutral-to-normal sp₂ ((t /⊢n Renaming.wk₊ Γ₊) · řeify sp₁ v) ⟧n řeflect-π-well-behaved sp₁ sp₂ {σ} t Γ₊ v = let t′ = ňeutral-to-normal sp₂ ((t /⊢n Renaming.wk) · žero sp₁ (ifst σ)) v′ = řeify sp₁ v lemma′ = begin [ ⟦ čast sp₁ σ (ƛ t′) ⟧n /̂Val ŵk₊ Γ₊ ] ≡⟨ /̂Val-cong (ňeutral-to-normal-identity-π sp₁ sp₂ t) P.refl ⟩ [ ⟦ t ⟧n /̂Val ŵk₊ Γ₊ ] ≡⟨ t /⊢n-lemma Renaming.wk₊ Γ₊ ⟩ [ ⟦ t /⊢n Renaming.wk₊ Γ₊ ⟧n ] ∎ in begin [ (⟦ čast sp₁ σ (ƛ t′) ⟧n /̂Val ŵk₊ Γ₊) ˢ ⟦ v′ ⟧n ] ≡⟨ ˢ-cong lemma′ P.refl ⟩ [ ⟦ t /⊢n Renaming.wk₊ Γ₊ ⟧n ˢ ⟦ v′ ⟧n ] ≡⟨ P.refl ⟩ [ ⟦ (t /⊢n Renaming.wk₊ Γ₊) · v′ ⟧n ] ≡⟨ P.sym $ ňeutral-to-normal-identity sp₂ _ ⟩ [ ⟦ ňeutral-to-normal sp₂ ((t /⊢n Renaming.wk₊ Γ₊) · v′) ⟧n ] ∎ -- A given context morphism is equal to the identity. ŵk-ŝub-žero : ∀ {Γ} sp₁ {sp₂} (σ : IType Γ (π sp₁ sp₂)) → ŵk ↑̂ fst σ ∘̂ ŝub ⟦ žero sp₁ (ifst σ) ⟧n ≅-⇨̂ îd[ Γ ▻ fst σ ] ŵk-ŝub-žero sp₁ σ = begin [ ŵk ↑̂ ∘̂ ŝub ⟦ žero sp₁ (ifst σ) ⟧n ] ≡⟨ ∘̂-cong (P.refl {x = [ ŵk ↑̂ ]}) (ŝub-cong (ňeutral-to-normal-identity sp₁ (var zero))) ⟩ [ ŵk ↑̂ ∘̂ ŝub ⟦ var zero ⟧n ] ≡⟨ P.refl ⟩ [ îd ] ∎ -- A corollary of the lemma above. π-fst-snd-ŵk-ŝub-žero : ∀ {Γ} sp₁ {sp₂} (σ : IType Γ (π sp₁ sp₂)) → Type-π (fst σ) (snd σ /̂ ŵk ↑̂ ∘̂ ŝub ⟦ žero sp₁ (ifst σ) ⟧n) ≅-Type (-, σ) π-fst-snd-ŵk-ŝub-žero sp₁ σ = begin [ Type-π (fst σ) (snd σ /̂ ŵk ↑̂ ∘̂ ŝub ⟦ žero sp₁ (ifst σ) ⟧n) ] ≡⟨ Type-π-cong $ /̂-cong (P.refl {x = [ snd σ ]}) (ŵk-ŝub-žero sp₁ σ) ⟩ [ Type-π (fst σ) (snd σ) ] ≡⟨ P.refl ⟩ [ -, σ ] ∎ -- In the semantics řeify is a left inverse of řeflect. ňeutral-to-normal-identity : ∀ {Γ} sp {σ} (t : Γ ⊢ sp , σ ⟨ ne ⟩) → ⟦ ňeutral-to-normal sp t ⟧n ≅-Value ⟦ t ⟧n ňeutral-to-normal-identity ⋆ t = P.refl ňeutral-to-normal-identity el t = P.refl ňeutral-to-normal-identity (π sp₁ sp₂) t = ňeutral-to-normal-identity-π sp₁ sp₂ t ňeutral-to-normal-identity-π : ∀ {Γ} sp₁ sp₂ {σ} (t : Γ ⊢ π sp₁ sp₂ , σ ⟨ ne ⟩) → let t′ = ňeutral-to-normal sp₂ ((t /⊢n Renaming.wk) · žero sp₁ (ifst σ)) in ⟦ čast sp₁ σ (ƛ t′) ⟧n ≅-Value ⟦ t ⟧n ňeutral-to-normal-identity-π sp₁ sp₂ {σ} t = let t′ = (t /⊢n Renaming.wk) · žero sp₁ (ifst σ) lemma = begin [ ⟦ ňeutral-to-normal sp₂ t′ ⟧n ] ≡⟨ ňeutral-to-normal-identity sp₂ t′ ⟩ [ ⟦ t′ ⟧n ] ≡⟨ P.refl ⟩ [ ⟦ t /⊢n Renaming.wk ⟧n ˢ ⟦ žero sp₁ (ifst σ) ⟧n ] ≡⟨ ˢ-cong (P.sym $ t /⊢n-lemma Renaming.wk) (ňeutral-to-normal-identity sp₁ (var zero)) ⟩ [ (⟦ t ⟧n /̂Val ŵk) ˢ lookup zero ] ≡⟨ P.refl ⟩ [ uc ⟦ t ⟧n ] ∎ in begin [ ⟦ čast sp₁ σ (ƛ (ňeutral-to-normal sp₂ t′)) ⟧n ] ≡⟨ ⟦⟧n-cong $ drop-subst-⊢n id (≅-Type-⇒-≡ $ π-fst-snd-ŵk-ŝub-žero sp₁ σ) ⟩ [ c ⟦ ňeutral-to-normal sp₂ t′ ⟧n ] ≡⟨ curry-cong lemma ⟩ [ c {C = k El ˢ isnd σ} (uc ⟦ t ⟧n) ] ≡⟨ P.refl ⟩ [ ⟦ t ⟧n ] ∎ -- An immediate consequence of the somewhat roundabout definition -- above. w̌ell-behaved : ∀ {Γ sp₁ sp₂ σ} (f : V̌alue Γ (π sp₁ sp₂ , σ)) → ∀ Γ₊ v → (⟦̌_⟧ {σ = σ} f /̂Val ŵk₊ Γ₊) ˢ ⟦̌ v ⟧ ≅-Value ⟦̌ proj₁ f Γ₊ v ⟧ w̌ell-behaved = proj₂ -- Values are term-like. V̌al : Term-like _ V̌al = record { _⊢_ = V̌alue ; ⟦_⟧ = ⟦̌_⟧ } open Term-like V̌al public using ([_]) renaming ( _≅-⊢_ to _≅-V̌alue_ ; drop-subst-⊢ to drop-subst-V̌alue; ⟦⟧-cong to ⟦̌⟧-cong ) abstract -- Unfolding lemma for ⟦̌_∣_⟧-π. unfold-⟦̌∣⟧-π : ∀ {Γ sp₁ sp₂} σ (f : V̌alue-π Γ sp₁ sp₂ σ) → ⟦̌ σ ∣ f ⟧-π ≅-Value c ⟦̌ f (fst σ ◅ ε) (řeflect sp₁ (var zero)) ⟧ unfold-⟦̌∣⟧-π σ _ = ⟦⟧n-cong $ drop-subst-⊢n id (≅-Type-⇒-≡ $ π-fst-snd-ŵk-ŝub-žero _ σ) -- Some congruence/conversion lemmas. ≅-⊢n-⇒-≅-Value-⋆ : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ ⋆ , σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ ⋆ , σ₂ ⟨ ne ⟩} → t₁ ≅-⊢n t₂ → t₁ ≅-V̌alue t₂ ≅-⊢n-⇒-≅-Value-⋆ P.refl = P.refl ≅-Value-⋆-⇒-≅-⊢n : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ ⋆ , σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ ⋆ , σ₂ ⟨ ne ⟩} → t₁ ≅-V̌alue t₂ → t₁ ≅-⊢n t₂ ≅-Value-⋆-⇒-≅-⊢n P.refl = P.refl ≅-⊢n-⇒-≅-Value-el : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ el , σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ el , σ₂ ⟨ ne ⟩} → t₁ ≅-⊢n t₂ → [ t₁ ]el ≅-V̌alue [ t₂ ]el ≅-⊢n-⇒-≅-Value-el P.refl = P.refl ≅-Value-el-⇒-≅-⊢n : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ el , σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ el , σ₂ ⟨ ne ⟩} → [ t₁ ]el ≅-V̌alue [ t₂ ]el → t₁ ≅-⊢n t₂ ≅-Value-el-⇒-≅-⊢n P.refl = P.refl abstract ,-cong : E.Extensionality Level.zero Level.zero → ∀ {Γ sp₁ sp₂ σ} {f₁ f₂ : V̌alue Γ (π sp₁ sp₂ , σ)} → (∀ Γ₊ v → proj₁ f₁ Γ₊ v ≅-V̌alue proj₁ f₂ Γ₊ v) → _≅-V̌alue_ {σ₁ = (π sp₁ sp₂ , σ)} f₁ {σ₂ = (π sp₁ sp₂ , σ)} f₂ ,-cong ext hyp = P.cong (Term-like.[_] {_} {V̌al}) $ ,-cong′ (ext λ Γ₊ → ext λ v → Term-like.≅-⊢-⇒-≡ V̌al $ hyp Γ₊ v) (ext λ _ → ext λ _ → P.≡-irrelevant _ _) where ,-cong′ : {A : Set} {B : A → Set} {x₁ x₂ : A} {y₁ : B x₁} {y₂ : B x₂} → (eq : x₁ ≡ x₂) → P.subst B eq y₁ ≡ y₂ → _≡_ {A = Σ A B} (x₁ , y₁) (x₂ , y₂) ,-cong′ P.refl P.refl = P.refl ňeutral-to-normal-cong : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ σ₂ ⟨ ne ⟩} → t₁ ≅-⊢n t₂ → ňeutral-to-normal _ t₁ ≅-⊢n ňeutral-to-normal _ t₂ ňeutral-to-normal-cong P.refl = P.refl žero-cong : ∀ {Γ₁} {σ₁ : Type Γ₁} {Γ₂} {σ₂ : Type Γ₂} → σ₁ ≅-Type σ₂ → žero _ (proj₂ σ₁) ≅-⊢n žero _ (proj₂ σ₂) žero-cong P.refl = P.refl řeify-cong : ∀ {Γ₁ σ₁} {v₁ : V̌alue Γ₁ σ₁} {Γ₂ σ₂} {v₂ : V̌alue Γ₂ σ₂} → v₁ ≅-V̌alue v₂ → řeify _ v₁ ≅-⊢n řeify _ v₂ řeify-cong P.refl = P.refl řeflect-cong : ∀ {Γ₁ σ₁} {t₁ : Γ₁ ⊢ σ₁ ⟨ ne ⟩} {Γ₂ σ₂} {t₂ : Γ₂ ⊢ σ₂ ⟨ ne ⟩} → t₁ ≅-⊢n t₂ → řeflect _ t₁ ≅-V̌alue řeflect _ t₂ řeflect-cong P.refl = P.refl
oeis/001/A001607.asm
neoneye/loda-programs
11
81750
; A001607: a(n) = -a(n-1) - 2*a(n-2). ; Submitted by <NAME> ; 0,1,-1,-1,3,-1,-5,7,3,-17,11,23,-45,-1,91,-89,-93,271,-85,-457,627,287,-1541,967,2115,-4049,-181,8279,-7917,-8641,24475,-7193,-41757,56143,27371,-139657,84915,194399,-364229,-24569,753027,-703889,-802165,2209943,-605613,-3814273,5025499,2603047,-12654045,7447951,17860139,-32756041,-2964237,68476319,-62547845,-74404793,199500483,-50690897,-348310069,449691863,246928275,-1146312001,652455451,1640168551,-2945079453,-335257649,6225416555,-5554901257,-6895931853,18005734367,-4213870661,-31797598073 mov $1,1 lpb $0 sub $0,1 sub $1,$2 add $2,$1 sub $1,$2 add $2,$1 mul $1,2 lpe mov $0,$2
picoctf/EasyRsa/gmp-ecm/x86_64/mulredc3.asm
beninato8/ctfs
0
25184
<filename>picoctf/EasyRsa/gmp-ecm/x86_64/mulredc3.asm<gh_stars>0 # mp_limb_t mulredc3(mp_limb_t * z, const mp_limb_t * x, const mp_limb_t * y, # const mp_limb_t *m, mp_limb_t inv_m); # # Linux: z: %rdi, x: %rsi, y: %rdx, m: %rcx, inv_m: %r8 # Needs %rbx, %rsp, %rbp, %r12-%r15 restored # Windows: z: %rcx, x: %rdx, y: %r8, m: %r9, inv_m: 28(%rsp) # Needs %rbx, %rbp, %rdi, %rsi, %r12...%15 restored # This stuff is run through M4 twice, first when generating the # mulredc*.asm files from the mulredc.m4 file (when preparing the distro) # and again when generating the mulredc*.s files from the mulredc*.asm files # when the user compiles the program. # We used to substitute XP etc. by register names in the first pass, # but now with switching between Linux and Windows ABI, we do it in # the second pass instead when we know which ABI we have, as that # allows us to assign registers differently for the two ABIs. # That means that the defines for XP etc., need to be quoted once to be # protected in the first M4 pass, so that they are processed and # occurrences of XP etc. happen only in the second pass. include(`config.m4') TEXT .p2align 6 # x86_64 L1 code cache line is 64 bytes long GLOBL GSYM_PREFIX`'mulredc3 TYPE(GSYM_PREFIX`'mulredc`'3,`function') # Implements multiplication and REDC for two input numbers of LENGTH words ifdef(`WINDOWS64_ABI', `# Uses Windows ABI', `# Uses Linux ABI') # tmp[0 ... len+1] = 0 # for (i = 0; i < len; i++) # { # t = x[i] * y[0]; /* Keep and reuse this product */ # u = ((t + tmp[0]) * invm) % 2^64 # tmp[0] += (t + m[0]*u) / 2^64; /* put carry in cy. */ # for (j = 1; j < len; j++) # { # tmp[j-1 ... j] += x[i]*y[j] + m[j]*u + (cy << BITS_PER_WORD); # /* put new carry in cy */ # } # tmp[len] = cy; # } # z[0 ... len-1] = tmp[0 ... len-1] # return (tmp[len]) # Values that are referenced only once in the loop over j go into r8 .. r14, # In the inner loop (over j), tmp, x[i], y, m, and u are constant. # tmp[j], tmp[j+1], tmp[j+2] are updated frequently. These 8 values # stay in registers and are referenced as # TP = tmp, YP = y, MP = m, # XI = x[i], T0 = tmp[j], T1 = tmp[j+1], CY = carry define(`T0', `rsi')dnl define(`T0l', `esi')dnl define(`T1', `rbx')dnl define(`T1l', `ebx')dnl define(`CY', `rcx')dnl define(`CYl', `ecx')dnl define(`CYb', `cl')dnl define(`XI', `r14')dnl # register that holds x[i] value define(`U', `r11')dnl define(`XP', `r13')dnl # register that points to the x arraz define(`TP', `rbp')dnl # register that points to t + i define(`I', `r12')dnl # register that holds loop counter i define(`Il', `r12d')dnl # register that holds loop counter i define(`ZP', `rdi')dnl # register that holds z. Same as passed in ifdef(`WINDOWS64_ABI', `define(`YP', `r8')dnl # points to y array, same as passed in define(`MP', `r9')dnl # points to m array, same as passed in define(`INVM', `r10')dnl # register that holds invm. Same as passed in' , `define(`YP', `r9')dnl # register that points to the y array define(`MP', `r10')dnl # register that points to the m array define(`INVM', `r8')dnl # register that holds invm. Same as passed in' )dnl `#' Register vars: `T0' = T0, `T1' = T1, `CY' = CY, `XI' = XI, `U' = U `#' `YP' = YP, `MP' = MP, `TP' = TP # local variables: tmp[0 ... LENGTH] array, having LENGTH+1 8-byte words # The tmp array needs LENGTH+1 entries, the last one is so that we can # store CY at tmp[j+1] for j == len-1 GSYM_PREFIX`'mulredc3: pushq %rbx pushq %rbp pushq %r12 pushq %r13 pushq %r14 ifdef(`WINDOWS64_ABI', ` pushq %rsi pushq %rdi ') dnl ifdef(`WINDOWS64_ABI', ` movq %rdx, %XP movq %rcx, %ZP movq 96(%rsp), %INVM # 7 push, ret addr, 4 reg vars = 96 bytes' , ` movq %rsi, %XP # store x in XP movq %rdx, %YP # store y in YP movq %rcx, %MP # store m in MP' ) dnl subq $32, %rsp # subtract size of local vars ######################################################################### # i = 0 pass ######################################################################### # register values at loop entry: %TP = tmp, %I = i, %YP = y, %MP = m # %CY < 255 (i.e. only low byte may be != 0) # Pass for j = 0. We need to fetch x[i] from memory and compute the new u movq (%XP), %XI # XI = x[0] movq (%YP), %rax # rax = y[0] xorl %CYl, %CYl # set %CY to 0 lea (%rsp), %TP # store addr of tmp array in TP movl %CYl, %Il # Set %I to 0 mulq %XI # rdx:rax = y[0] * x[i] addq $1, %I movq %rax, %T0 # Move low word of product to T0 movq %rdx, %T1 # Move high word of product to T1 ifdef(`MULREDC_SVOBODA', , `' ` imulq %INVM, %rax # %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64' ) movq %rax, %U # this is the new u value mulq (%MP) # multipy u*m[0] addq %rax, %T0 # Now %T0 = 0, need not be stored movq 8(%YP), %rax # Fetch y[1] adcq %rdx, %T1 # setc %CYb # CY:T1:T0 <= 2*(2^64-1)^2 <= 2^2*128 - 4*2^64 + 2, hence # CY:T1 <= 2*2^64 - 4 define(`TT', defn(`T0'))dnl define(`TTl', defn(`T0l'))dnl define(`T0', defn(`T1'))dnl define(`T0l', defn(`T1l'))dnl define(`T1', defn(`TT'))dnl define(`T1l', defn(`TTl'))dnl undefine(`TT')dnl undefine(`TTl')dnl `#' Now `T0' = T0, `T1' = T1 `#' Pass for j = 1 `#' Register values at entry: `#' %rax = y[j], %XI = x[i], %U = u `#' %TP = tmp, %T0 = value to store in tmp[j], %T1 undefined `#' %CY = carry into T1 (is <= 2) # We have %CY:%T1 <= 2 * 2^64 - 2 movl %CYl, %T1l # T1 = CY <= 1 # Here, T1:T0 <= 2*2^64 - 2 mulq %XI # y[j] * x[i] # rdx:rax <= (2^64-1)^2 <= 2^128 - 2*2^64 + 1 addq %rax, %T0 # Add low word to T0 movq 8(%MP), %rax # Fetch m[j] into %rax adcq %rdx, %T1 # Add high word with carry to T1 # T1:T0 <= 2^128 - 2*2^64 + 1 + 2*2^64 - 2 <= 2^128 - 1, no carry! mulq %U # m[j]*u # rdx:rax <= 2^128 - 2*2^64 + 1, T1:T0 <= 2^128 - 1 addq %T0, %rax # Add T0 and low word movq %rax, 0(%TP) `#' Store T0 in tmp[1-1] movq 16(%YP), %rax `#' Fetch y[j+1] = y[2] into %rax adcq %rdx, %T1 # Add high word with carry to T1 setc %CYb # %CY <= 1 # CY:T1:T0 <= 2^128 - 1 + 2^128 - 2*2^64 + 1 <= # 2 * 2^128 - 2*2^64 ==> CY:T1 <= 2 * 2^64 - 2 define(`TT', defn(`T0'))dnl define(`TTl', defn(`T0l'))dnl define(`T0', defn(`T1'))dnl define(`T0l', defn(`T1l'))dnl define(`T1', defn(`TT'))dnl define(`T1l', defn(`TTl'))dnl undefine(`TT')dnl undefine(`TTl')dnl `#' Now `T0' = T0, `T1' = T1 `#' Pass for j = 2. Don't fetch new data from y[j+1]. movl %CYl, %T1l # T1 = CY <= 1 mulq %XI # y[j] * x[i] addq %rax, %T0 # Add low word to T0 movq 16(%MP), %rax # Fetch m[j] into %rax adcq %rdx, %T1 # Add high word with carry to T1 mulq %U # m[j]*u addq %rax, %T0 # Add low word to T0 movq %T0, 8(%TP) # Store T0 in tmp[j-1] adcq %rdx, %T1 # Add high word with carry to T1 movq %T1, 16(%TP) # Store T1 in tmp[j] setc %CYb # %CY <= 1 movq %CY, 24(%TP) # Store CY in tmp[j+1] ######################################################################### # i > 0 passes ######################################################################### .p2align 5,,4 LABEL_SUFFIX(1) # register values at loop entry: %TP = tmp, %I = i, %YP = y, %MP = m # %CY < 255 (i.e. only low byte may be > 0) # Pass for j = 0. We need to fetch x[i], tmp[i] and tmp[i+1] from memory # and compute the new u movq (%XP,%I,8), %XI # XI = x[i] movq (%YP), %rax # rax = y[0] #init the register tmp ring buffer movq (%TP), %T0 # Load tmp[0] into T0 movq 8(%TP), %T1 # Load tmp[1] into T1 mulq %XI # rdx:rax = y[0] * x[i] addq $1, %I addq %T0, %rax # Add T0 to low word adcq %rdx, %T1 # Add high word with carry to T1 setc %CYb # %CY <= 1 movq %rax, %T0 # Save sum of low words in T0 imulq %INVM, %rax # %rax = ((x[i]*y[0]+tmp[0])*invm)%2^64 movq %rax, %U # this is the new u value mulq (%MP) # multipy u*m[0] addq %rax, %T0 # Now %T0 = 0, need not be stored adcq %rdx, %T1 # movq 8(%YP), %rax # Fetch y[1] define(`TT', defn(`T0'))dnl define(`TTl', defn(`T0l'))dnl define(`T0', defn(`T1'))dnl define(`T0l', defn(`T1l'))dnl define(`T1', defn(`TT'))dnl define(`T1l', defn(`TTl'))dnl undefine(`TT')dnl undefine(`TTl')dnl `#' Now `T0' = T0, `T1' = T1 `#' Pass for j = 1 `#' Register values at entry: `#' %rax = y[j], %XI = x[i], %U = u `#' %TP = tmp, %T0 = value to store in tmp[j], %T1 value to store in `#' tmp[j+1], %CY = carry into T1, carry flag: also carry into T1 movq 16(%TP), %T1 adcq %CY, %T1 # T1 = CY + tmp[j+1] setc %CYb # %CY <= 1 mulq %XI # y[j] * x[i] addq %rax, %T0 # Add low word to T0 movq %U, %rax adcq %rdx, %T1 # Add high word with carry to T1 adcb $0, %CYb # %CY <= 2 mulq 8(%MP) # m[j]*u addq %rax, %T0 # Add T0 and low word movq 16(%YP), %rax `#' Fetch y[j+1] = y[2] into %rax adcq %rdx, %T1 # Add high word with carry to T1 movq %T0, 0(%TP) `#' Store T0 in tmp[1-1] define(`TT', defn(`T0'))dnl define(`TTl', defn(`T0l'))dnl define(`T0', defn(`T1'))dnl define(`T0l', defn(`T1l'))dnl define(`T1', defn(`TT'))dnl define(`T1l', defn(`TTl'))dnl undefine(`TT')dnl undefine(`TTl')dnl `#' Now `T0' = T0, `T1' = T1 `#' Pass for j = 2. Don't fetch new data from y[j+1]. movq 24(%TP), %T1 adcq %CY, %T1 # T1 = CY + tmp[j+1] mulq %XI # y[j] * x[i] addq %rax, %T0 # Add low word to T0 movq 16(%MP), %rax # Fetch m[j] into %rax adcq %rdx, %T1 # Add high word with carry to T1 setc %CYb # %CY <= 1 mulq %U # m[j]*u addq %rax, %T0 # Add low word to T0 movq %T0, 8(%TP) # Store T0 in tmp[j-1] adcq %rdx, %T1 # Add high word with carry to T1 movq %T1, 16(%TP) # Store T1 in tmp[j] adcb $0, %CYb # %CY <= 2 movq %CY, 24(%TP) # Store CY in tmp[j+1] cmpq $3, %I jb 1b # Copy result from tmp memory to z movq (%TP), %rax movq 8(%TP), %rdx movq %rax, (%ZP) movq %rdx, 8(%ZP) movq 16(%TP), %rax movq %rax, 16(%ZP) movl %CYl, %eax # use carry as return value addq $32, %rsp ifdef(`WINDOWS64_ABI', ` popq %rdi popq %rsi ') dnl popq %r14 popq %r13 popq %r12 popq %rbp popq %rbx ret
examples/add2.asm
tuna-arch/school
0
83213
bits 16 mov 0x2, r0 addp out, r0
programs/oeis/018/A018227.asm
jmorken/loda
1
10095
<reponame>jmorken/loda ; A018227: Magic numbers: atoms with full shells containing any of these numbers of electrons are considered electronically stable. ; 2,10,18,36,54,86,118,168,218,290,362,460,558,686,814,976,1138,1338,1538,1780,2022,2310,2598,2936,3274,3666,4058,4508,4958,5470,5982,6560,7138,7786,8434,9156,9878,10678,11478,12360,13242,14210,15178,16236,17294,18446,19598,20848,22098,23450,24802,26260,27718,29286,30854,32536,34218,36018,37818,39740,41662,43710,45758,47936,50114,52426,54738,57188,59638,62230,64822,67560,70298,73186,76074,79116,82158,85358,88558,91920,95282,98810,102338,106036,109734,113606,117478,121528,125578,129810,134042,138460,142878,147486,152094,156896,161698,166698,171698,176900,182102,187510,192918,198536,204154,209986,215818,221868,227918,234190,240462,246960,253458,260186,266914,273876,280838,288038,295238,302680,310122,317810,325498,333436,341374,349566,357758,366208,374658,383370,392082,401060,410038,419286,428534,438056,447578,457378,467178,477260,487342,497710,508078,518736,529394,540346,551298,562548,573798,585350,596902,608760,620618,632786,644954,657436,669918,682718,695518,708640,721762,735210,748658,762436,776214,790326,804438,818888,833338,848130,862922,878060,893198,908686,924174,940016,955858,972058,988258,1004820,1021382,1038310,1055238,1072536,1089834,1107506,1125178,1143228,1161278,1179710,1198142,1216960,1235778,1254986,1274194,1293796,1313398,1333398,1353398,1373800,1394202,1415010,1435818,1457036,1478254,1499886,1521518,1543568,1565618,1588090,1610562,1633460,1656358,1679686,1703014,1726776,1750538,1774738,1798938,1823580,1848222,1873310,1898398,1923936,1949474,1975466,2001458,2027908,2054358,2081270,2108182,2135560,2162938,2190786,2218634,2246956,2275278,2304078,2332878,2362160,2391442,2421210,2450978,2481236,2511494,2542246,2572998,2604248,2635498,2667250 mov $16,$0 mov $18,$0 add $18,1 lpb $18 clr $0,16 mov $0,$16 sub $18,1 sub $0,$18 mov $13,$0 mov $15,$0 add $15,1 lpb $15 mov $0,$13 sub $15,1 sub $0,$15 mov $9,$0 mov $11,2 lpb $11 sub $11,1 add $0,$11 sub $0,1 mov $4,$0 add $4,$0 add $4,2 div $4,4 add $4,1 mov $1,$4 pow $1,2 mov $12,$11 lpb $12 mov $10,$1 sub $12,1 lpe lpe lpb $9 mov $9,0 sub $10,$1 lpe mov $1,$10 mul $1,2 add $14,$1 lpe add $17,$14 lpe mov $1,$17
source/findReferencesTitle.applescript
465499642/bookends-tools
76
812
<gh_stars>10-100 #!/usr/bin/osascript -------------------------------------------------------------------- -- SCRIPT FOR EXTRACTING REFERENCES FROM BOOKENDS -------------------------------------------------------------------- on run argv set query to (do shell script "echo " & argv & " | iconv -s -f UTF-8-Mac -t UTF-8") as Unicode text set searchLength to 1 if length of query is 1 --check if character is higher unicode character set queryid to id of query if queryid is greater than 1514 -- up to hebrew codepoint set searchLength to 0 -- so we can search for chinese names end if end if tell application "Bookends" -- Extract UUID from Bookends set refList to {} if length of query is greater than searchLength then --no point in searching for <=2 letter fragments set AppleScript's text item delimiters to {return} set refList to text items of («event ToySSQLS» "title REGEX '(?i)" & query as string & "'") set AppleScript's text item delimiters to {","} end if set json to "{\"items\": [ " & linefeed repeat with refItem in refList set refItem to contents of refItem -- Extract first Author set refAuthorList to («event ToySRFLD» refItem given string:"authors") set AppleScript's text item delimiters to {","} set refAuthors to text items of refAuthorList set AppleScript's text item delimiters to {"'"} set refAuthor to first item of refAuthors set AppleScript's text item delimiters to {""} -- Extract and clean (escape " and remove newlines) title for JSON set refTitle to («event ToySRFLD» refItem given string:"title") set refTitle to my fixString(refTitle) -- Extract date set refDateRaw to («event ToySRFLD» refItem given string:"thedate") --ruby is a bit too slow here, use sed --set cmd to "ruby -e 'puts $1 if \"" & refDateRaw & "\" =~ /([12][0-9]{3})/'" set cmd to "echo '" & refDateRaw & "' | sed 's/\\([0-9]*\\)\\(.*\\)/\\1/g'" set refDate to (do shell script cmd) set refDate to my fixString(refDate) -- json formatting -- Set json header set json to json & linefeed & "{" & linefeed set json to json & tab & "\"uid\": \"" & refItem & "\"," & linefeed set json to json & tab & "\"arg\": \"" & refItem & "\"," & linefeed set json to json & tab & "\"title\": \"" & refAuthor & " - " & refDate & "\"," & linefeed set json to json & tab & "\"subtitle\": \"" & refTitle & "\"," & linefeed set json to json & tab & "\"icon\": {\"path\": \"file.png\"}" & linefeed set json to json & "}," & linefeed end repeat set json to text 1 thru -3 of json set json to json & linefeed & "]}" & linefeed return json end tell end run on fixString(theText) set findChars to {linefeed, return, tab, "\""} set replaceChars to {" ", " ", " ", "\\\""} repeat with i from 1 to length of findChars if (item i of findChars) is in theText then set AppleScript's text item delimiters to {item i of findChars} set theText to text items of theText set AppleScript's text item delimiters to {item i of replaceChars} set theText to theText as text set AppleScript's text item delimiters to {""} end if end repeat return theText end fixString
Etapa 02/Aula 12 - SSE/codes/a12e01.asm
bellorini/unioeste
0
164293
<reponame>bellorini/unioeste ; Aula 12 - SSE ; a12e01.asm ; Transferência de Inteiros entre MEM e Y|XMMi ; nasm -f elf64 a12e01.asm ; gcc -m64 -no-pie a12e01.o -o a12e01.x %define _exit 60 section .data align 32, db 0 ; alinhar memória ou SIGSEGV durante MOVDQA! vetInt1 : dd 10, 20, 30, 40, 50, 60, 70, 80 section .bss vetIntR1 : resd 2 vetIntR2 : resd 2 alignb 16 vetIntR3 : resd 4 ; alinhado em 16 vetIntR4 : resd 4 ; pode ser desalinhado alignb 32 vetIntR5 : resd 8 ; alinhado em 32 vetIntR6 : resd 8 section .text global main main: ; stack-frame push rbp mov rbp, rsp ; Transferência INT mem -> xmm ===================== ; 32bits MOVD xmm1, [vetInt1] ; gdb_tip: p $xmm1.v4_int32 ; 2*32bits -> 64bits MOVQ xmm2, [vetInt1] ; gdb_tip: p $xmm2.v4_int32 ; 4*32bits -> 128bits alinhado em 16 ; -> caso contrário, SIGSEGV! MOVDQA xmm3, [vetInt1] ; gdb_tip: p $xmm3.v4_int32 ; 4*32bits -> 128bits desalinhado -> não precisa de align 16 MOVDQU xmm4, [vetInt1] ; gdb_tip: p $xmm4.v4_int32 ; 8*32bits -> 256bits alinhado em 32 VMOVDQA ymm5, [vetInt1] ; gdb_tip: p $ymm5.v8_int32 ; 8*32bits -> 256bits desalinhado VMOVDQU ymm6, [vetInt1] ; gdb_tip: p $ymm6.v8_int32 ; Transferência xmm -> INT mem ===================== ; 32bits MOVD [vetIntR1], xmm1 ; gdb_tip: x /2d &vetIntR1 ; 2*32bits -> 64bits MOVQ [vetIntR2], xmm2 ; gdb_tip: x /2d &vetIntR2 ; 4*32bits -> 128bits alinhado em 16 MOVDQA [vetIntR3], xmm3 ; gdb_tip: x /4d &vetIntR3 ; 4*32bits -> 128bits desalinhado -> não precisa de alignb 16 MOVDQU [vetIntR4], xmm4 ; gdb_tip: x /4d &vetIntR4 ; 8*32bits -> 256bits alinhado em 32 VMOVDQA [vetIntR5], ymm5 ; gdb_tip: x /8d &vetIntR6 ; 8*32bits -> 256bits desalinhado VMOVDQU [vetIntR6], ymm6 ; gdb_tip: x /8d &vetIntR6 fim: ; "destack-frame!" mov rsp, rbp pop rbp mov rax, _exit mov rdi, 0 syscall
oeis/184/A184033.asm
neoneye/loda-programs
11
162463
; A184033: 1/16 the number of (n+1) X 4 0..3 arrays with all 2 X 2 subblocks having the same four values. ; Submitted by <NAME> ; 49,61,82,124,202,358,658,1258,2434,4786,9442,18754,37282,74338,148258,296098,591394,1181986,2362402,4723234,9443362,18883618,37761058,75515938,151019554,302026786,604028962,1208033314,2416017442,4831985698,9663873058,19327647778,38655098914,77310001186,154619609122,309238824994,618476863522,1236952940578,2473904308258,4947807043618,9895610941474,19791218737186,39582431182882,79164856074274,158329699565602,316659386548258,633318747930658,1266637470695458,2533274891059234,5066549731786786 mov $3,$0 seq $0,209726 ; 1/4 the number of (n+1) X 8 0..2 arrays with every 2 X 2 subblock having distinct clockwise edge differences. mov $2,2 add $3,1 pow $2,$3 add $0,$2 sub $0,18 mul $0,2 add $0,$2 sub $0,2 div $0,2 mul $0,3 add $0,49
tests/nonsmoke/functional/CompileTests/experimental_ada_tests/dot_asis_tests/test_units/task_with_abort.adb
passlab/rexompiler
0
15698
<reponame>passlab/rexompiler -- Note: This test does not yet work due to problems with -- declaring tasks. We can't abort without a task --with Ada.Text_IO; procedure Task_With_Abort is task AbortMe is entry Go; end AbortMe; task body AbortMe is begin accept Go; loop delay 1.0; --Ada.Text_IO.Put_Line("I'm not dead yet!"); end loop; end AbortMe; begin AbortMe.Go; delay 10.0; abort AbortMe; --Ada.Text_IO.Put_Line("Aborted AbortMe"); delay 2.0; end Task_With_Abort;
buildTools/win32-x64/gbdk/libc/_divulong.asm
asiekierka/gb-studio
6,433
87666
;-------------------------------------------------------- ; File Created by SDCC : FreeWare ANSI-C Compiler ; Version 2.3.1 Wed Sep 04 21:56:22 2019 ;-------------------------------------------------------- .module _divulong ;-------------------------------------------------------- ; Public variables in this module ;-------------------------------------------------------- .globl __divulong ;-------------------------------------------------------- ; special function registers ;-------------------------------------------------------- ;-------------------------------------------------------- ; special function bits ;-------------------------------------------------------- ;-------------------------------------------------------- ; internal ram data ;-------------------------------------------------------- .area _DATA ;-------------------------------------------------------- ; overlayable items in internal ram ;-------------------------------------------------------- .area _OVERLAY ;-------------------------------------------------------- ; indirectly addressable internal ram data ;-------------------------------------------------------- .area _ISEG ;-------------------------------------------------------- ; bit data ;-------------------------------------------------------- .area _BSEG ;-------------------------------------------------------- ; external ram data ;-------------------------------------------------------- .area _XSEG ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- .area _GSINIT .area _GSFINAL .area _GSINIT ;-------------------------------------------------------- ; Home ;-------------------------------------------------------- .area _HOME .area _CODE ;-------------------------------------------------------- ; code ;-------------------------------------------------------- .area _CODE ; _divulong.c 321 ; genLabel ; genFunction ; --------------------------------- ; Function _divulong ; --------------------------------- ____divulong_start: __divulong: lda sp,-10(sp) ; _divulong.c 323 ; genAssign ; AOP_STK for __divulong_reste_1_1 xor a,a lda hl,6(sp) ld (hl+),a ld (hl+),a ld (hl+),a ld (hl),a ; _divulong.c 331 ; genAssign ; AOP_STK for __divulong_count_1_1 lda hl,5(sp) ld (hl),#0x20 ; genLabel 00105$: ; _divulong.c 334 ; genGetHBIT ; AOP_STK for lda hl,15(sp) ld a,(hl) rlc a and a,#1 ld b,a ; genAssign ; AOP_STK for __divulong_c_1_1 lda hl,4(sp) ld (hl),b ; _divulong.c 335 ; genIpush ; _saveRegsForCall: sendSetSize: 0 deInUse: 0 bcInUse: 0 deSending: 0 ld a,#0x01 push af inc sp ; genIpush ; AOP_STK for lda hl,15(sp) ld a,(hl+) ld h,(hl) ld l,a push hl lda hl,15(sp) ld a,(hl+) ld h,(hl) ld l,a push hl ; genCall call __rlulong_rrx_s ; AOP_STK for push hl lda hl,19(sp) ld (hl),e inc hl ld (hl),d pop de inc hl ld (hl),e inc hl ld (hl),d lda sp,5(sp) ; genAssign ; (operands are equal 4) ; _divulong.c 336 ; genIpush ; _saveRegsForCall: sendSetSize: 0 deInUse: 0 bcInUse: 0 deSending: 0 ld a,#0x01 push af inc sp ; genIpush ; AOP_STK for __divulong_reste_1_1 lda hl,9(sp) ld a,(hl+) ld h,(hl) ld l,a push hl lda hl,9(sp) ld a,(hl+) ld h,(hl) ld l,a push hl ; genCall call __rlulong_rrx_s ; AOP_STK for __divulong_sloc0_1_0 push hl lda hl,7(sp) ld (hl),e inc hl ld (hl),d pop de inc hl ld (hl),e inc hl ld (hl),d lda sp,5(sp) ; genAssign ; AOP_STK for __divulong_sloc0_1_0 ; AOP_STK for __divulong_reste_1_1 lda hl,0(sp) ld d,h ld e,l lda hl,6(sp) ld a,(de) ld (hl+),a inc de ld a,(de) ld (hl+),a inc de ld a,(de) ld (hl+),a inc de ld a,(de) ld (hl),a ; _divulong.c 337 ; genIfx ; AOP_STK for __divulong_c_1_1 xor a,a lda hl,4(sp) or a,(hl) jp z,00102$ ; _divulong.c 338 ; genOr ; AOP_STK for __divulong_reste_1_1 inc hl inc hl ld a,(hl) or a,#0x01 ld (hl),a ; genLabel 00102$: ; _divulong.c 340 ; genCmpLt ; AOP_STK for __divulong_reste_1_1 ; AOP_STK for lda hl,6(sp) ld d,h ld e,l lda hl,16(sp) ld a,(de) sub a,(hl) inc hl inc de ld a,(de) sbc a,(hl) inc hl inc de ld a,(de) sbc a,(hl) inc hl inc de ld a,(de) sbc a,(hl) jp c,00106$ ; _divulong.c 342 ; genMinus ; AOP_STK for __divulong_reste_1_1 ; AOP_STK for lda hl,6(sp) ld e,(hl) inc hl ld d,(hl) ld a,e lda hl,16(sp) sub a,(hl) ld e,a ld a,d inc hl sbc a,(hl) push af lda hl,9(sp) ld (hl-),a ld (hl),e inc hl inc hl ld e,(hl) inc hl ld d,(hl) lda hl,20(sp) pop af ld a,e sbc a,(hl) ld e,a ld a,d inc hl sbc a,(hl) lda hl,9(sp) ld (hl-),a ld (hl),e ; _divulong.c 344 ; genOr ; AOP_STK for lda hl,12(sp) ld a,(hl) or a,#0x01 ld (hl),a ; genLabel 00106$: ; _divulong.c 347 ; genMinus ; AOP_STK for __divulong_count_1_1 lda hl,5(sp) dec (hl) ; genIfx ; AOP_STK for __divulong_count_1_1 xor a,a or a,(hl) jp nz,00105$ ; _divulong.c 348 ; genRet ; AOP_STK for lda hl,12(sp) ld e,(hl) inc hl ld d,(hl) inc hl ld a,(hl+) ld h,(hl) ld l,a ; genLabel 00108$: ; genEndFunction lda sp,10(sp) ret ____divulong_end: .area _CODE
src/gl/implementation/gl-objects-shaders.adb
Roldak/OpenGLAda
79
20709
<reponame>Roldak/OpenGLAda -- part of OpenGLAda, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "COPYING" with GL.API; with GL.Enums; package body GL.Objects.Shaders is procedure Set_Source (Subject : Shader; Source : String) is C_Source : C.char_array := C.To_C (Source); begin API.Shader_Source (Subject.Reference.GL_Id, 1, (1 => C_Source (0)'Unchecked_Access), (1 => Source'Length)); Raise_Exception_On_OpenGL_Error; end Set_Source; function Source (Subject : Shader) return String is Source_Length : Size := 0; begin API.Get_Shader_Param (Subject.Reference.GL_Id, Enums.Shader_Source_Length, Source_Length); Raise_Exception_On_OpenGL_Error; if Source_Length = 0 then return ""; else declare Shader_Source : String (1 .. Integer (Source_Length)); begin API.Get_Shader_Source (Subject.Reference.GL_Id, Source_Length, Source_Length, Shader_Source); Raise_Exception_On_OpenGL_Error; return Shader_Source (1 .. Integer (Source_Length)); end; end if; end Source; procedure Compile (Subject : Shader) is begin API.Compile_Shader (Subject.Reference.GL_Id); Raise_Exception_On_OpenGL_Error; end Compile; procedure Release_Shader_Compiler is begin API.Release_Shader_Compiler.all; end Release_Shader_Compiler; function Compile_Status (Subject : Shader) return Boolean is Value : Int := 0; begin API.Get_Shader_Param (Subject.Reference.GL_Id, Enums.Compile_Status, Value); Raise_Exception_On_OpenGL_Error; return Value /= 0; end Compile_Status; function Info_Log (Subject : Shader) return String is Log_Length : Size := 0; begin API.Get_Shader_Param (Subject.Reference.GL_Id, Enums.Info_Log_Length, Log_Length); Raise_Exception_On_OpenGL_Error; if Log_Length = 0 then return ""; else declare Info_Log : String (1 .. Integer (Log_Length)); begin API.Get_Shader_Info_Log (Subject.Reference.GL_Id, Log_Length, Log_Length, Info_Log); Raise_Exception_On_OpenGL_Error; return Info_Log (1 .. Integer (Log_Length)); end; end if; end Info_Log; overriding procedure Internal_Create_Id (Object : Shader; Id : out UInt) is begin Id := API.Create_Shader (Object.Kind); Raise_Exception_On_OpenGL_Error; end Internal_Create_Id; overriding procedure Internal_Release_Id (Object : Shader; Id : UInt) is pragma Unreferenced (Object); begin API.Delete_Shader (Id); Raise_Exception_On_OpenGL_Error; end Internal_Release_Id; function Create_From_Id (Id : UInt) return Shader is Kind : Shader_Type := Shader_Type'First; begin API.Get_Shader_Type (Id, Enums.Shader_Type, Kind); Raise_Exception_On_OpenGL_Error; return Object : Shader (Kind) do Object.Set_Raw_Id (Id, False); end return; end Create_From_Id; end GL.Objects.Shaders;
agda-aplas14/SN.agda
ryanakca/strong-normalization
32
14181
module SN where open import Relation.Unary using (_∈_; _⊆_) open import Library open import Terms open import Substitution open import TermShape public -- Inductive definition of strong normalization. infix 7 _⟨_⟩⇒_ _⇒ˢ_ mutual -- Strongly normalizing evaluation contexts SNhole : ∀ {i : Size} {Γ : Cxt} {a b : Ty} → Tm Γ b → ECxt Γ a b → Tm Γ a → Set SNhole {i} = PCxt (SN {i}) -- Strongly neutral terms. SNe : ∀ {i : Size} {Γ} {b} → Tm Γ b → Set SNe {i} = PNe (SN {i}) -- Strongly normalizing terms. data SN {i : Size}{Γ} : ∀ {a} → Tm Γ a → Set where ne : ∀ {j : Size< i} {a t} → (𝒏 : SNe {j} t) → SN {a = a} t abs : ∀ {j : Size< i} {a b}{t : Tm (a ∷ Γ) b} → (𝒕 : SN {j} t) → SN (abs t) exp : ∀ {j₁ j₂ : Size< i} {a t t′} → (t⇒ : t ⟨ j₁ ⟩⇒ t′) (𝒕′ : SN {j₂} t′) → SN {a = a} t _⟨_⟩⇒_ : ∀ {Γ a} → Tm Γ a → Size → Tm Γ a → Set t ⟨ i ⟩⇒ t′ = SN {i} / t ⇒ t′ -- Strong head reduction _⇒ˢ_ : ∀ {i : Size} {Γ} {a} → Tm Γ a → Tm Γ a → Set _⇒ˢ_ {i} t t' = (SN {i}) / t ⇒ t' -- -- Inductive definition of strong normalization. -- mutual -- -- Strongly normalizing evaluation contexts -- data SNhole {i : Size} (n : ℕ) {Γ : Cxt} : {a b : Ty} → Tm Γ b → ECxt Γ a b → Tm Γ a → Set where -- appl : ∀ {a b t u} -- → (𝒖 : SN {i} n u) -- → SNhole n (app t u) (appl u) (t ∶ (a →̂ b)) -- -- Strongly neutral terms. -- data SNe {i : Size} (n : ℕ) {Γ} {b} : Tm Γ b → Set where -- var : ∀ x → SNe n (var x) -- elim : ∀ {a} {t : Tm Γ a} {E Et} -- → (𝒏 : SNe {i} n t) (𝑬𝒕 : SNhole {i} n Et E t) → SNe n Et -- -- elim : ∀ {j₁ j₂ : Size< i}{a} {t : Tm Γ a} {E Et} -- -- → (𝒏 : SNe {j₁} n t) (𝑬𝒕 : SNhole {j₂} n Et E t) → SNe n Et -- -- Strongly normalizing terms. -- data SN {i : Size}{Γ} : ℕ → ∀ {a} → Tm Γ a → Set where -- ne : ∀ {j : Size< i} {a n t} -- → (𝒏 : SNe {j} n t) -- → SN n {a} t -- abs : ∀ {j : Size< i} {a b n}{t : Tm (a ∷ Γ) b} -- → (𝒕 : SN {j} n t) -- → SN n (abs t) -- exp : ∀ {j₁ j₂ : Size< i} {a n t t′} -- → (t⇒ : j₁ size t ⟨ n ⟩⇒ t′) (𝒕′ : SN {j₂} n t′) -- → SN n {a} t -- _size_⟨_⟩⇒_ : ∀ (i : Size) {Γ}{a} → Tm Γ a → ℕ → Tm Γ a → Set -- i size t ⟨ n ⟩⇒ t′ = _⟨_⟩⇒_ {i} t n t′ -- -- Strong head reduction -- data _⟨_⟩⇒_ {i : Size} {Γ} : ∀ {a} → Tm Γ a → ℕ → Tm Γ a → Set where -- β : ∀ {a b}{t : Tm (a ∷ Γ) b}{u} -- → (𝒖 : SN {i} n u) -- → (app (abs t) u) ⟨ n ⟩⇒ subst0 u t -- cong : ∀ {a b t t' Et Et'}{E : ECxt Γ a b} -- → (𝑬𝒕 : Ehole Et E t) -- → (𝑬𝒕' : Ehole Et' E t') -- → (t⇒ : i size t ⟨ n ⟩⇒ t') -- → Et ⟨ n ⟩⇒ Et' -- β : ∀ {j : Size< i} {a b}{t : Tm (a ∷ Γ) b}{u} -- → (𝒖 : SN {j} n u) -- → (app (abs t) u) ⟨ n ⟩⇒ subst0 u t -- cong : ∀ {j : Size< i} {a b t t' Et Et'}{E : ECxt Γ a b} -- → (𝑬𝒕 : Ehole Et E t) -- → (𝑬𝒕' : Ehole Et' E t') -- → (t⇒ : j size t ⟨ n ⟩⇒ t') -- → Et ⟨ n ⟩⇒ Et' -- Strong head reduction is deterministic. det⇒ : ∀ {a Γ} {t t₁ t₂ : Tm Γ a} → (t⇒₁ : t ⟨ _ ⟩⇒ t₁) (t⇒₂ : t ⟨ _ ⟩⇒ t₂) → t₁ ≡ t₂ det⇒ (β _) (β _) = ≡.refl det⇒ (β _) (cong (appl u) (appl .u) (cong () _ _)) det⇒ (cong (appl u) (appl .u) (cong () _ _)) (β _) det⇒ (cong (appl u) (appl .u) x) (cong (appl .u) (appl .u) y) = ≡.cong (λ t → app t u) (det⇒ x y) -- Strongly neutrals are closed under application. sneApp : ∀{Γ a b}{t : Tm Γ (a →̂ b)}{u : Tm Γ a} → SNe t → SN u → SNe (app t u) sneApp 𝒏 𝒖 = elim 𝒏 (appl 𝒖) -- Substituting strongly neutral terms record RenSubSNe {i} (vt : VarTm i) (Γ Δ : Cxt) : Set where constructor _,_ field theSubst : RenSub vt Γ Δ isSNe : ∀ {a} (x : Var Γ a) → SNe (vt2tm _ (theSubst x)) open RenSubSNe RenSN = RenSubSNe `Var SubstSNe = RenSubSNe `Tm -- The singleton SNe substitution. -- Replaces the first variable by another variable. sgs-varSNe : ∀ {Γ a} → Var Γ a → SubstSNe (a ∷ Γ) Γ theSubst (sgs-varSNe x) = sgs (var x) isSNe (sgs-varSNe x) (zero) = (var x) isSNe (sgs-varSNe x) (suc y) = var y -- The SN-notions are closed under SNe substitution. mutual substSNh : ∀ {i vt Γ Δ a b} → (σ : RenSubSNe {i} vt Γ Δ) → ∀ {E : ECxt Γ a b}{Et t} → (SNh : SNhole Et E t) → SNhole (subst (theSubst σ) Et) (substEC (theSubst σ) E) (subst (theSubst σ) t) substSNh σ (appl u) = appl (substSN σ u) subst⇒ : ∀ {i vt Γ Δ a} (σ : RenSubSNe {i} vt Γ Δ) {t t' : Tm Γ a} → t ⟨ _ ⟩⇒ t' → subst (theSubst σ) t ⟨ _ ⟩⇒ subst (theSubst σ) t' subst⇒ (σ , σ∈Ne) (β {t = t} {u = u} x) = ≡.subst (λ t' → app (abs (subst (lifts σ) t)) (subst σ u) ⟨ _ ⟩⇒ t') (sgs-lifts-term {σ = σ} {u} {t}) (β {t = subst (lifts σ) t} (substSN (σ , σ∈Ne) x)) subst⇒ σ (cong Eh Eh' t→t') = cong (substEh (theSubst σ) Eh) (substEh (theSubst σ) Eh') (subst⇒ σ t→t') -- Lifting a SNe substitution. liftsSNe : ∀ {i vt Γ Δ a} → RenSubSNe {i} vt Γ Δ → RenSubSNe {i} vt (a ∷ Γ) (a ∷ Δ) theSubst (liftsSNe σ) = lifts (theSubst σ) isSNe (liftsSNe {vt = `Var} (σ , σ∈SNe)) (zero) = var (zero) isSNe (liftsSNe {vt = `Var} (σ , σ∈SNe)) (suc y) = var (suc (σ y)) isSNe (liftsSNe {vt = `Tm } (σ , σ∈SNe)) (zero) = var (zero) isSNe (liftsSNe {vt = `Tm } (σ , σ∈SNe)) (suc y) = substSNe {vt = `Var} (suc , (λ x → var (suc x))) (σ∈SNe y) substSNe : ∀ {i vt Γ Δ τ} → (σ : RenSubSNe {i} vt Γ Δ) → ∀ {t : Tm Γ τ} → SNe t → SNe (subst (theSubst σ) t) substSNe σ (var x) = isSNe σ x substSNe σ (elim t∈SNe E∈SNh) = elim (substSNe σ t∈SNe) (substSNh σ E∈SNh) substSN : ∀ {i vt Γ Δ τ} → (σ : RenSubSNe {i} vt Γ Δ) → ∀ {t : Tm Γ τ} → SN t → SN (subst (theSubst σ) t) substSN σ (ne t∈SNe) = ne (substSNe σ t∈SNe) substSN σ (abs t∈SN) = abs (substSN (liftsSNe σ) t∈SN) substSN σ (exp t→t' t'∈SN) = exp (subst⇒ σ t→t') (substSN σ t'∈SN) -- SN is closed under renaming. renSN : ∀{Γ Δ} (ρ : Γ ≤ Δ) → RenSN Δ Γ renSN ρ = (ρ , λ x → var (ρ x)) renameSNe : ∀{a Γ Δ} (ρ : Γ ≤ Δ) {t : Tm Δ a} → SNe t → SNe (rename ρ t) renameSNe ρ = substSNe (renSN ρ) renameSN : ∀{a Γ Δ} (ρ : Γ ≤ Δ) {t : Tm Δ a} → SN t → SN (rename ρ t) renameSN ρ = substSN (renSN ρ) -- Variables are SN. varSN : ∀{Γ a x} → var x ∈ SN {Γ = Γ} {a} varSN = ne (var _) -- SN is closed under application to variables. appVarSN : ∀{Γ a b}{t : Tm Γ (a →̂ b)}{x} → t ∈ SN → app t (var x) ∈ SN appVarSN (ne t∈SNe) = ne (elim t∈SNe (appl varSN)) appVarSN (abs t∈SN) = exp (β varSN) (substSN (sgs-varSNe _) t∈SN) appVarSN (exp t→t' t'∈SN) = exp (cong (appl (var _)) (appl (var _)) t→t') (appVarSN t'∈SN) -- Subterm properties of SN -- If app t u ∈ SN then u ∈ SN. apprSN : ∀{i a b Γ}{t : Tm Γ (a →̂ b)}{u : Tm Γ a} → SN {i} (app t u) → SN {i} u apprSN (ne (elim 𝒏 (appl 𝒖))) = 𝒖 apprSN (exp (β 𝒖) 𝒕) = 𝒖 apprSN (exp (cong (appl u) (appl .u) t⇒) 𝒕) = apprSN 𝒕
objc/two-step-processing/ObjectiveCPreprocessorParser.g4
ChristianWulf/grammars-v4
0
2253
/* Objective-C Preprocessor grammar. The MIT License (MIT). Copyright (c) 2016, <NAME> (<EMAIL>). 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. */ parser grammar ObjectiveCPreprocessorParser; options { tokenVocab=ObjectiveCPreprocessorLexer; } objectiveCDocument : text* EOF ; text : code | SHARP directive (NEW_LINE | EOF) ; code : CODE+ ; directive : (IMPORT | INCLUDE) directive_text #preprocessorImport | IF preprocessor_expression #preprocessorConditional | ELIF preprocessor_expression #preprocessorConditional | ELSE #preprocessorConditional | ENDIF #preprocessorConditional | IFDEF CONDITIONAL_SYMBOL #preprocessorDef | IFNDEF CONDITIONAL_SYMBOL #preprocessorDef | UNDEF CONDITIONAL_SYMBOL #preprocessorDef | PRAGMA directive_text #preprocessorPragma | ERROR directive_text #preprocessorError | DEFINE CONDITIONAL_SYMBOL directive_text? #preprocessorDefine ; directive_text : TEXT+ ; preprocessor_expression : TRUE #preprocessorConstant | FALSE #preprocessorConstant | DECIMAL_LITERAL #preprocessorConstant | DIRECTIVE_STRING #preprocessorConstant | CONDITIONAL_SYMBOL (LPAREN preprocessor_expression RPAREN)? #preprocessorConditionalSymbol | LPAREN preprocessor_expression RPAREN #preprocessorParenthesis | BANG preprocessor_expression #preprocessorNot | preprocessor_expression op=(EQUAL | NOTEQUAL) preprocessor_expression #preprocessorBinary | preprocessor_expression op=AND preprocessor_expression #preprocessorBinary | preprocessor_expression op=OR preprocessor_expression #preprocessorBinary | preprocessor_expression op=(LT | GT | LE | GE) preprocessor_expression #preprocessorBinary | DEFINED (CONDITIONAL_SYMBOL | LPAREN CONDITIONAL_SYMBOL RPAREN) #preprocessorDefined ;
utils/proto_grammar/proto_grammar.g4
THofstee/hdlConvertor
0
1552
/* * Grammar for parsing of grammar defined in PDFs with Verilog/VHDL standard **/ grammar proto_grammar; proto_file: (proto_rule)* EOF; proto_rule: NAME WS? IS element END WS; element: element_sequence | element_selection ; element_block: element_text // | element_in_parenthesis | element_iteration | element_optional ; element_selection: element_sequence ('|' element_sequence)+; element_sequence: WS? element_block (WS element_block)* WS?; element_iteration: '{' element '}'; //element_in_parenthesis: '(' element ')'; element_optional: '[' element ']'; element_text: NAME | TERMINAL; //----------------- LEXER -------------- TERMINAL: '<b>' .*? '</b>' ('-' '<b>' .*? '</b>')*; IS: '::='; WS: [ \n]+; NAME: [a-zA-Z0-9_$]+; QUESTIONMARK: '?'; END: '</br>';
programs/oeis/216/A216097.asm
karttu/loda
0
9274
; A216097: 3^n mod 10000. ; 1,3,9,27,81,243,729,2187,6561,9683,9049,7147,1441,4323,2969,8907,6721,163,489,1467,4401,3203,9609,8827,6481,9443,8329,4987,4961,4883,4649,3947,1841,5523,6569,9707,9121,7363,2089,6267,8801,6403,9209,7627,2881,8643,5929,7787,3361,83,249,747,2241,6723,169,507,1521,4563,3689,1067,3201,9603,8809,6427,9281,7843,3529,587,1761,5283,5849,7547,2641,7923,3769,1307,3921,1763,5289,5867,7601,2803,8409,5227,5681,7043,1129,3387,161,483,1449,4347,3041,9123,7369,2107,6321,8963,6889,667,2001,6003,8009,4027,2081,6243,8729,6187,8561,5683,7049,1147,3441,323,969,2907,8721,6163,8489,5467,6401,9203,7609,2827,8481,5443,6329,8987,6961,883,2649,7947,3841,1523,4569,3707,1121,3363,89,267,801,2403,7209,1627,4881,4643,3929,1787,5361,6083,8249,4747,4241,2723,8169,4507,3521,563,1689,5067,5201,5603,6809,427,1281,3843,1529,4587,3761,1283,3849,1547,4641,3923,1769,5307,5921,7763,3289,9867,9601,8803,6409,9227,7681,3043,9129,7387,2161,6483,9449,8347,5041,5123,5369,6107,8321,4963,4889,4667,4001,2003,6009,8027,4081,2243,6729,187,561,1683,5049,5147,5441,6323,8969,6907,721,2163,6489,9467,8401,5203,5609,6827,481,1443,4329,2987,8961,6883,649,1947,5841,7523,2569,7707,3121,9363,8089,4267,2801,8403,5209,5627,6881,643,1929,5787,7361,2083 mov $2,$0 mov $0,1 mov $3,10000 lpb $2,1 mul $0,3 mod $0,$3 sub $2,1 lpe add $0,1 mov $1,$0 sub $1,2 div $1,2 mul $1,2 add $1,1
source/calendar/a-catizo.ads
ytomino/drake
33
21937
<reponame>ytomino/drake pragma License (Unrestricted); package Ada.Calendar.Time_Zones is -- Time zone manipulation: type Time_Offset is range -28 * 60 .. 28 * 60; Unknown_Zone_Error : exception; function UTC_Time_Offset (Date : Time := Clock) return Time_Offset; pragma Pure_Function (UTC_Time_Offset); pragma Inline (UTC_Time_Offset); end Ada.Calendar.Time_Zones;
libsrc/math/daimath32/c/asm/___dai32_xload.asm
ahjelm/z88dk
640
91622
SECTION code_fp_dai32 PUBLIC ___dai32_xload EXTERN xload defc ___dai32_xload = xload
projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.asm
skatsuta/nand2tetris
1
8677
// projects/08/ProgramFlow/FibonacciSeries/FibonacciSeries.vm @1 D=A @ARG AD=D+M D=M @SP A=M M=D @SP AM=M+1 @1 D=A @R3 AD=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @0 D=A @SP A=M M=D @SP AM=M+1 @0 D=A @THAT AD=D+M @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @1 D=A @SP A=M M=D @SP AM=M+1 @1 D=A @THAT AD=D+M @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @0 D=A @ARG AD=D+M D=M @SP A=M M=D @SP AM=M+1 @2 D=A @SP A=M M=D @SP AM=M+1 @SP AM=M-1 D=M @SP AM=M-1 M=M-D @SP AM=M+1 @0 D=A @ARG AD=D+M @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D (MAIN_LOOP_START) @0 D=A @ARG AD=D+M D=M @SP A=M M=D @SP AM=M+1 @SP AM=M-1 D=M @COMPUTE_ELEMENT D;JNE @END_PROGRAM 0;JMP (COMPUTE_ELEMENT) @0 D=A @THAT AD=D+M D=M @SP A=M M=D @SP AM=M+1 @1 D=A @THAT AD=D+M D=M @SP A=M M=D @SP AM=M+1 @SP AM=M-1 D=M @SP AM=M-1 M=D+M @SP AM=M+1 @2 D=A @THAT AD=D+M @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @1 D=A @R3 AD=D+A D=M @SP A=M M=D @SP AM=M+1 @1 D=A @SP A=M M=D @SP AM=M+1 @SP AM=M-1 D=M @SP AM=M-1 M=D+M @SP AM=M+1 @1 D=A @R3 AD=D+A @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @0 D=A @ARG AD=D+M D=M @SP A=M M=D @SP AM=M+1 @1 D=A @SP A=M M=D @SP AM=M+1 @SP AM=M-1 D=M @SP AM=M-1 M=M-D @SP AM=M+1 @0 D=A @ARG AD=D+M @R13 M=D @SP AM=M-1 D=M @R13 A=M M=D @MAIN_LOOP_START 0;JMP (END_PROGRAM) (END) @END 0;JMP
source/xml/catalogs/matreshka-xml_catalogs-resolver.adb
svn2github/matreshka
24
8867
<gh_stars>10-100 ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Containers.Vectors; with Matreshka.XML_Catalogs.Loader; with Matreshka.XML_Catalogs.Normalization; package body Matreshka.XML_Catalogs.Resolver is use Matreshka.XML_Catalogs.Entry_Files; use type League.Strings.Universal_String; package Next_Catalog_Vectors is new Ada.Containers.Vectors (Positive, Next_Catalog_Entry_Vectors.Cursor, Next_Catalog_Entry_Vectors."="); procedure Resolve_External_Identifier (File : not null Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_Access; Public_Id : in out League.Strings.Universal_String; System_Id : in out League.Strings.Universal_String; Resolved_URI : out League.Strings.Universal_String; Delegate : out Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List_Access); -- Attempts to resolve external identifier using specified catalog entry -- file. procedure Resolve_URI (File : not null Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_Access; URI : League.Strings.Universal_String; Resolved_URI : out League.Strings.Universal_String; Delegate : out Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List_Access); -- Attempts to resolve URI using specified catalog entry file. --------------------------------- -- Resolve_External_Identifier -- --------------------------------- procedure Resolve_External_Identifier (List : not null Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List_Access; Public_Id : League.Strings.Universal_String; System_Id : League.Strings.Universal_String; Resolved_URI : out League.Strings.Universal_String; Success : out Boolean) is Current_List : Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List_Access := List; Current_Public_Id : League.Strings.Universal_String := Public_Id; Current_System_Id : League.Strings.Universal_String := System_Id; Delegate : Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List_Access; Identifier : League.Strings.Universal_String; Unwrapped : Boolean; begin Success := False; Resolved_URI := League.Strings.Empty_Universal_String; -- Normalization and unwrapping. -- [XML Catalogs] 7.1.1. Input to the Resolver -- -- "If the public identifier is a URN in the publicid namespace ([RFC -- 3151]), it is converted into another public identifier by -- "unwrapping" the URN (Section 6.4, “URN "Unwrapping"”). This may be -- done, for example, so that a URN can be specified as the public -- identifier and a URL as the system identifier, in the absence of -- widely deployed URN-resolution facilities." Matreshka.XML_Catalogs.Normalization.Unwrap_URN (Current_Public_Id, Identifier, Unwrapped); if Unwrapped then Current_Public_Id := Identifier; end if; -- [XML Catalogs] 7.1.1. Input to the Resolver -- -- "If the system identifier is a URN in the publicid namespace, it is -- converted into a public identifier by "unwrapping" the URN. In this -- case, one of the following must apply: -- -- 1. No public identifier was provided. Resolution continues as if the -- public identifier constructed by unwrapping the URN was supplied as -- the original public identifier and no system identifier was provided. -- -- 2. The normalized public identifier provided is lexically identical -- to the public identifier constructed by unwrapping the URN. -- Resolution continues as if the system identifier had not been -- supplied. -- -- 3. The normalized public identifier provided is different from the -- public identifier constructed by unwrapping the URN. This is an -- error. Applications may recover from this error by discarding the -- system identifier and proceeding with the original public -- identifier." Matreshka.XML_Catalogs.Normalization.Unwrap_URN (Current_System_Id, Identifier, Unwrapped); if Unwrapped then Current_System_Id.Clear; if Current_Public_Id.Is_Empty then Current_Public_Id := Identifier; else Current_Public_Id := Matreshka.XML_Catalogs.Normalization.Normalize_Public_Identifier (Current_Public_Id); if Current_Public_Id /= Identifier then -- XXX Error reporting is not implemented yet. KDE's test from -- XmlCatConf require to return empty URI and report resolution -- failure. Resolved_URI.Clear; Success := False; return; end if; end if; else Current_Public_Id := Matreshka.XML_Catalogs.Normalization.Normalize_Public_Identifier (Current_Public_Id); Current_System_Id := Matreshka.XML_Catalogs.Normalization.Normalize_System_Identifier (Current_System_Id); end if; -- External loop handles delegation processing. Delegation : loop -- [XML Catalogs] 7.1.2. Resolution of External Identifiers -- -- "1. Resolution begins in the first catalog entry file in the -- current catalog entry file list." for J in Current_List.Catalog_Entry_Files.First_Index .. Current_List.Catalog_Entry_Files.Last_Index loop Resolve_External_Identifier (Current_List.Catalog_Entry_Files.Element (J), Current_Public_Id, Current_System_Id, Resolved_URI, Delegate); if Delegate /= null then exit; elsif not Resolved_URI.Is_Empty then Success := True; return; end if; -- [XML Catalogs] 7.1.2. Resolution of External Identifiers -- -- "9. If there are one or more catalog entry files remaining on -- the current catalog entry file list, load the next catalog -- entry file and continue resolution efforts: return to step 2." end loop; exit when Delegate = null; -- External identifier not resolved and there is no delegation -- requested, return. -- Make requested delegation list to be current list. Current_List := Delegate; Delegate := null; end loop Delegation; Resolved_URI := System_Id; end Resolve_External_Identifier; --------------------------------- -- Resolve_External_Identifier -- --------------------------------- procedure Resolve_External_Identifier (File : not null Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_Access; Public_Id : in out League.Strings.Universal_String; System_Id : in out League.Strings.Universal_String; Resolved_URI : out League.Strings.Universal_String; Delegate : out Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List_Access) is Length : Natural; Inserted : Boolean; Current_File : Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_Access; Rewrite_System : Matreshka.XML_Catalogs.Entry_Files.Rewrite_System_Entry_Access; System_Suffix : Matreshka.XML_Catalogs.Entry_Files.System_Suffix_Entry_Access; Next_Catalog : Matreshka.XML_Catalogs.Entry_Files.Next_Catalog_Entry_Access; Delegate_System : Matreshka.XML_Catalogs.Entry_Files.Delegate_System_Entry_Vectors.Vector; Delegate_Public : Matreshka.XML_Catalogs.Entry_Files.Delegate_Public_Entry_Vectors.Vector; Next : Matreshka.XML_Catalogs.Entry_Files.Next_Catalog_Entry_Vectors.Cursor; Stack : Next_Catalog_Vectors.Vector; begin Current_File := File; loop if not System_Id.Is_Empty then -- [XML Catalogs] 7.1.2. Resolution of External Identifiers -- -- "2. If a system identifier is provided, and at least one -- matching system entry exists, the (absolutized) value of the -- uri attribute of the first matching system entry is returned." for J in Current_File.System_Entries.First_Index .. Current_File.System_Entries.Last_Index loop if System_Id = Current_File.System_Entries.Element (J).System_Id then Resolved_URI := Current_File.System_Entries.Element (J).URI; return; end if; end loop; -- [XML Catalogs] 7.1.2. Resolution of External Identifiers -- -- "3. If a system identifier is provided, and at least one -- matching rewriteSystem entry exists, rewriting is performed. -- -- If more than one rewriteSystem entry matches, the matching -- entry with the longest normalized systemIdStartString value is -- used. -- -- Rewriting removes the matching prefix and replaces it with the -- rewrite prefix identified by the matching rewriteSystem entry. -- The rewritten string is returned." Length := 0; for J in Current_File.Rewrite_System_Entries.First_Index .. Current_File.Rewrite_System_Entries.Last_Index loop if System_Id.Starts_With (Current_File.Rewrite_System_Entries.Element (J).System_Id) then if Length < Current_File.Rewrite_System_Entries.Element (J).System_Id.Length then Rewrite_System := Current_File.Rewrite_System_Entries.Element (J); Length := Current_File.Rewrite_System_Entries.Element (J).System_Id.Length; end if; end if; end loop; if Rewrite_System /= null then Resolved_URI := Rewrite_System.Prefix & System_Id.Slice (Rewrite_System.System_Id.Length + 1, System_Id.Length); return; end if; -- [XML Catalogs] 7.1.2. Resolution of External Identifiers -- -- "4. If a system identifier is provided, and at least one -- matching systemSuffix entry exists, the (absolutized) value of -- the uri attribute of the matching entry with the longest -- normalized systemIdSuffix value is returned." Length := 0; for J in Current_File.System_Suffix_Entries.First_Index .. Current_File.System_Suffix_Entries.Last_Index loop if System_Id.Ends_With (Current_File.System_Suffix_Entries.Element (J).System_Id) then if Length < Current_File.System_Suffix_Entries.Element (J).System_Id.Length then System_Suffix := Current_File.System_Suffix_Entries.Element (J); Length := Current_File.System_Suffix_Entries.Element (J).System_Id.Length; end if; end if; end loop; if System_Suffix /= null then Resolved_URI := System_Suffix.URI; return; end if; -- [XML Catalogs] 7.1.2. Resolution of External Identifiers -- -- "5. If a system identifier is provided, and one or more -- delegateSystem entries match, delegation is performed. -- -- If delegation is to be performed, a new catalog entry file list -- is generated from the set of all matching delegateSystem -- entries. The (absolutized) value of the catalog attribute of -- each matching delegateSystem entry is inserted into the new -- catalog entry file list such that the delegate entry with the -- longest matching systemIdStartString is first on the list, the -- entry with the second longest match is second, etc. -- -- These are the only catalog entry files on the list, the current -- list is not considered for the purpose of delegation. If -- delegation fails to find a match, resolution for this entity -- does not resume with the current list. (A subsequent resolution -- attempt for a different entity begins with the original list; -- in other words the catalog entry file list used for delegation -- is distinct and unrelated to the "normal" catalog entry file -- list.) -- -- Catalog resolution restarts using exclusively the catalog entry -- files in this new list and the given system identifier; any -- originally given public identifier is ignored during the -- remainder of the resolution of this external identifier: return -- to step 1." for J in Current_File.Delegate_System_Entries.First_Index .. Current_File.Delegate_System_Entries.Last_Index loop if System_Id.Starts_With (Current_File.Delegate_System_Entries.Element (J).System_Id) then Inserted := False; for K in Delegate_System.First_Index .. Delegate_System.Last_Index loop if Current_File.Delegate_System_Entries.Element (J).System_Id.Length > Delegate_System.Element (K).System_Id.Length then Delegate_System.Insert (K, Current_File.Delegate_System_Entries.Element (J)); Inserted := True; exit; end if; end loop; if not Inserted then Delegate_System.Append (Current_File.Delegate_System_Entries.Element (J)); end if; end if; end loop; if not Delegate_System.Is_Empty then Delegate := new Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List; for J in Delegate_System.First_Index .. Delegate_System.Last_Index loop Delegate.Catalog_Entry_Files.Append (Matreshka.XML_Catalogs.Loader.Load (Delegate_System.Element (J).Catalog, Current_File.Default_Prefer_Mode)); end loop; Public_Id.Clear; return; end if; end if; if not Public_Id.Is_Empty then -- [XML Catalogs] 7.1.2. Resolution of External Identifiers -- -- "6. If a public identifier is provided, and at least one -- matching public entry exists, the (absolutized) value of the -- uri attribute of the first matching public entry is returned. -- If a system identifier is also provided as part of the input to -- this catalog lookup, only public entries that occur where the -- prefer setting is public are considered for matching." for J in Current_File.Public_Entries.First_Index .. Current_File.Public_Entries.Last_Index loop if Public_Id = Current_File.Public_Entries.Element (J).Public_Id and then (System_Id.Is_Empty or else Current_File.Public_Entries.Element (J).Prefer = Public) then Resolved_URI := Current_File.Public_Entries.Element (J).URI; return; end if; end loop; -- [XML Catalogs] 7.1.2. Resolution of External Identifiers -- -- "7. If a public identifier is provided, and one or more -- delegatePublic entries match, delegation is performed. If a -- system identifier is also provided as part of the input to this -- catalog lookup, only delegatePublic entries that occur where -- the prefer setting is public are considered for matching. -- -- If delegation is to be performed, a new catalog entry file list -- is generated from the set of all matching delegatePublic -- entries. The value of the catalog attribute of each matching -- delegatePublic entry is inserted into the new catalog entry -- file list such that the delegate entry with the longest -- matching publicIdStartString is first on the list, the entry -- with the second longest match is second, etc. -- -- These are the only catalog entry files on the list, the current -- list is not considered for the purpose of delegation. If -- delegation fails to find a match, resolution for this entity -- does not resume with the current list. (A subsequent resolution -- attempt for a different entity begins with the original list; -- in other words the catalog entry file list used for delegation -- is distinct and unrelated to the "normal" catalog entry file -- list.) -- -- Catalog resolution restarts using exclusively the catalog entry -- files in this new list and the given public identifier; any -- originally given system identifier is ignored during the -- remainder of the resolution of this external identifier: return -- to step 1." for J in Current_File.Delegate_Public_Entries.First_Index .. Current_File.Delegate_Public_Entries.Last_Index loop if Public_Id.Starts_With (Current_File.Delegate_Public_Entries.Element (J).Public_Id) and then (System_Id.Is_Empty or else Current_File.Delegate_Public_Entries.Element (J).Prefer = Public) then Inserted := False; for K in Delegate_Public.First_Index .. Delegate_Public.Last_Index loop if Current_File.Delegate_Public_Entries.Element (J).Public_Id.Length > Delegate_Public.Element (K).Public_Id.Length then Delegate_Public.Insert (K, Current_File.Delegate_Public_Entries.Element (J)); Inserted := True; exit; end if; end loop; if not Inserted then Delegate_Public.Append (Current_File.Delegate_Public_Entries.Element (J)); end if; end if; end loop; if not Delegate_Public.Is_Empty then Delegate := new Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List; for J in Delegate_Public.First_Index .. Delegate_Public.Last_Index loop Delegate.Catalog_Entry_Files.Append (Matreshka.XML_Catalogs.Loader.Load (Delegate_Public.Element (J).Catalog, Current_File.Default_Prefer_Mode)); end loop; System_Id.Clear; return; end if; end if; -- [XML Catalogs] 7.1.2. Resolution of External Identifiers -- -- "8. If the current catalog entry file contains one or more -- nextCatalog entries, the catalog entry files referenced by each -- nextCatalog entry's "catalog" attribute are inserted, in the order -- that they appear in this catalog entry file, onto the current -- catalog entry file list, immediately after the current catalog -- entry file. Next := Current_File.Next_Catalog_Entries.First; if Next_Catalog_Entry_Vectors.Has_Element (Next) then Stack.Append (Next); end if; exit when Stack.Is_Empty; -- Take next catalog entry file from the stack. Next := Stack.Last_Element; Stack.Delete_Last; Next_Catalog := Next_Catalog_Entry_Vectors.Element (Next); if Next_Catalog.File = null then Next_Catalog.File := Matreshka.XML_Catalogs.Loader.Load (Next_Catalog.Catalog, File.Default_Prefer_Mode); end if; Current_File := Next_Catalog.File; Next_Catalog_Entry_Vectors.Next (Next); if Next_Catalog_Entry_Vectors.Has_Element (Next) then Stack.Append (Next); end if; end loop; end Resolve_External_Identifier; ----------------- -- Resolve_URI -- ----------------- procedure Resolve_URI (List : not null Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List_Access; URI : League.Strings.Universal_String; Resolved_URI : out League.Strings.Universal_String; Success : out Boolean) is Current_List : Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List_Access := List; Delegate : Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List_Access; Current_URI : League.Strings.Universal_String; Identifier : League.Strings.Universal_String; Unwrapped : Boolean; begin Success := False; Resolved_URI := League.Strings.Empty_Universal_String; -- [XML Catalogs] 7.2.1. Input to the Resolver -- -- "If the URI reference is a URN in the publicid namespace ([RFC -- 3151]), it is converted into a public identifier by "unwrapping" the -- URN (Section 6.4, “URN "Unwrapping"”). Resolution continues by -- following the semantics of external identifier resolution (Section -- 7.1, “External Identifier Resolution”) as if the public identifier -- constructed by unwrapping the URN had been provided and no system -- identifier had been provided. Otherwise, resolution of the URI -- reference proceeds according to the steps below." Matreshka.XML_Catalogs.Normalization.Unwrap_URN (URI, Identifier, Unwrapped); if Unwrapped then Resolve_External_Identifier (List, Identifier, League.Strings.Empty_Universal_String, Resolved_URI, Success); return; end if; Current_URI := Matreshka.XML_Catalogs.Normalization.Normalize_URI (URI); -- External loop handles delegation processing. Delegation : loop -- [XML Catalogs] 7.2.2. Resolution of URI references -- -- "1. Resolution begins in the first catalog entry file in the -- current catalog list." for J in Current_List.Catalog_Entry_Files.First_Index .. Current_List.Catalog_Entry_Files.Last_Index loop Resolve_URI (Current_List.Catalog_Entry_Files.Element (J), Current_URI, Resolved_URI, Delegate); if Delegate /= null then exit; elsif not Resolved_URI.Is_Empty then Success := True; return; end if; -- [XML Catalogs] 7.2.2. Resolution of URI references -- -- "7. If there are one or more catalog entry files remaining on -- the current catalog entry file list, load the next catalog -- entry file and continue resolution efforts: return to step 2." end loop; exit when Delegate = null; -- URI is not resolved and there is no delegation requested, return. -- Make requested delegation list to be current list. Current_List := Delegate; Delegate := null; end loop Delegation; Resolved_URI := Current_URI; end Resolve_URI; ----------------- -- Resolve_URI -- ----------------- procedure Resolve_URI (File : not null Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_Access; URI : League.Strings.Universal_String; Resolved_URI : out League.Strings.Universal_String; Delegate : out Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List_Access) is Length : Natural; Inserted : Boolean; Rewrite_URI : Matreshka.XML_Catalogs.Entry_Files.Rewrite_URI_Entry_Access; URI_Suffix : Matreshka.XML_Catalogs.Entry_Files.URI_Suffix_Entry_Access; Delegate_URI : Matreshka.XML_Catalogs.Entry_Files.Delegate_URI_Entry_Vectors.Vector; begin -- [XML Catalogs] 7.2.2. Resolution of URI references -- -- "2. If at least one matching uri entry exists, the (absolutized) -- value of the uri attribute of the first matching uri entry is -- returned." for J in File.URI_Entries.First_Index .. File.URI_Entries.Last_Index loop if URI = File.URI_Entries.Element (J).Name then Resolved_URI := File.URI_Entries.Element (J).URI; return; end if; end loop; -- [XML Catalogs] 7.2.2. Resolution of URI references -- -- "3. If at least one matching rewriteURI entry exists, rewriting is -- performed. -- -- If more than one rewriteURI entry matches, the matching entry with -- the longest normalized uriStartString value is used. -- -- Rewriting removes the matching prefix and replaces it with the -- rewrite prefix identified by the matching rewriteURI entry. The -- rewritten string is returned." Length := 0; for J in File.Rewrite_URI_Entries.First_Index .. File.Rewrite_URI_Entries.Last_Index loop if URI.Starts_With (File.Rewrite_URI_Entries.Element (J).Prefix) then if Length < File.Rewrite_URI_Entries.Element (J).Prefix.Length then Rewrite_URI := File.Rewrite_URI_Entries.Element (J); Length := File.Rewrite_URI_Entries.Element (J).Prefix.Length; end if; end if; end loop; if Rewrite_URI /= null then Resolved_URI := Rewrite_URI.Rewrite & URI.Slice (Rewrite_URI.Prefix.Length + 1, URI.Length); return; end if; -- [XML Catalogs] 7.2.2. Resolution of URI references -- -- "4. If at least one matching uriSuffix entry exists, the -- (absolutized) value of the uri attribute of the matching entry with -- the longest normalized uriSuffix value is returned." Length := 0; for J in File.URI_Suffix_Entries.First_Index .. File.URI_Suffix_Entries.Last_Index loop if URI.Ends_With (File.URI_Suffix_Entries.Element (J).Suffix) then if Length < File.URI_Suffix_Entries.Element (J).Suffix.Length then URI_Suffix := File.URI_Suffix_Entries.Element (J); Length := File.URI_Suffix_Entries.Element (J).Suffix.Length; end if; end if; end loop; if URI_Suffix /= null then Resolved_URI := URI_Suffix.URI; return; end if; -- [XML Catalogs] 7.2.2. Resolution of URI references -- -- "5. If one or more delegateURI entries match, delegation is -- performed. -- -- If delegation is to be performed, a new catalog entry file list is -- generated from the set of all matching delegateURI entries. The -- (absolutized) value of the catalog attribute of each matching -- delegateURI entry is inserted into the new catalog entry file list -- such that the delegate entry with the longest matching uriStartString -- is first on the list, the entry with the second longest match is -- second, etc. -- -- These are the only catalog entry files on the list, the current list -- is not considered for the purpose of delegation. If delegation fails -- to find a match, resolution for this entity does not resume with the -- current list. (A subsequent resolution attempt for a different entity -- begins with the original list; in other words the catalog entry file -- list used for delegation is distinct and unrelated to the "normal" -- catalog entry file list.) -- -- Catalog resolution restarts using exclusively the catalog entry files -- in this new list and the given URI reference: return to step 1. for J in File.Delegate_URI_Entries.First_Index .. File.Delegate_URI_Entries.Last_Index loop if URI.Starts_With (File.Delegate_URI_Entries.Element (J).Prefix) then Inserted := False; for K in Delegate_URI.First_Index .. Delegate_URI.Last_Index loop if File.Delegate_URI_Entries.Element (J).Prefix.Length > Delegate_URI.Element (K).Prefix.Length then Delegate_URI.Insert (K, File.Delegate_URI_Entries.Element (J)); Inserted := True; exit; end if; end loop; if not Inserted then Delegate_URI.Append (File.Delegate_URI_Entries.Element (J)); end if; end if; end loop; if not Delegate_URI.Is_Empty then Delegate := new Matreshka.XML_Catalogs.Entry_Files.Catalog_Entry_File_List; for J in Delegate_URI.First_Index .. Delegate_URI.Last_Index loop Delegate.Catalog_Entry_Files.Append (Matreshka.XML_Catalogs.Loader.Load (Delegate_URI.Element (J).Catalog, File.Default_Prefer_Mode)); end loop; return; end if; end Resolve_URI; end Matreshka.XML_Catalogs.Resolver;
oeis/144/A144109.asm
neoneye/loda-programs
11
25834
; A144109: INVERT transform of the cubes A000578. ; Submitted by <NAME> ; 1,9,44,207,991,4752,22769,109089,522676,2504295,11998799,57489696,275449681,1319758713,6323343884,30296960703,145161459631,695510337456,3332390227649,15966440800785,76499813776276,366532628080599,1756163326626719,8414284005052992,40315256698638241,193161999488138217,925494740742052844,4434311704222125999,21246063780368577151,101796007197620759760,487733972207735221649,2336873853841055348481,11196635296997541520756,53646302631146652255303,257034877858735719755759,1231528086662531946523488 add $0,1 mov $5,1 lpb $0 sub $0,1 add $4,$3 add $4,$1 add $4,$1 add $1,$3 add $5,$2 add $1,$5 add $4,$1 add $2,$4 mov $3,$5 lpe mov $0,$2
02_asm/num_to_string.asm
Kris030/lowlew-basics
0
21504
; number in ebx, buffer in ecx, returns result's length num_to_string: ; count the length in esi push esi mov esi, 0 ; argument N push ebx ; save ecx, edx push ecx push edx .loop: ; count++ inc esi ; --- DIVIDE --- ; divide eax, result in eax mov eax, ebx ; by 10 mov ebx, 10 ; remainder in edx mov edx, 0 ; run division div ebx ; --- DIVIDE END --- ; add '0' to remainder to get current digit add edx, '0' ; move it to buffer mov [ecx], edx ; advance buffer inc ecx ; restore N into ebx mov ebx, eax ; while (N > 0) cmp eax, 0 jg .loop mov [ecx], word 0 ; return length mov eax, esi ; restore registers pop edx pop ecx pop ebx ; setup reverse buffer call mov ebx, ecx add ecx, esi dec ecx ; save return value push eax call reverse_buffer ; restore esi and return value pop eax pop esi ret %include "reverse_buffer.asm"
usbm.g4
NormanDunbar/USBMParser
0
1038
grammar usbm ; //-------------------------------------------------------------- // P A R S E R R U L E S //-------------------------------------------------------------- //-------------------------------------------------------------- // START RULE: File is where we would normally start parsing and // it should start with a toolkit name and the location to be // used for all keywords in the toolkit. //-------------------------------------------------------------- file : toolkit location (keyword)+ ; //-------------------------------------------------------------- // Toolkit - just a descriptive name. //-------------------------------------------------------------- toolkit : TOOLKIT string ; //-------------------------------------------------------------- // Location - just a descriptive name. //-------------------------------------------------------------- location : LOCATION string ; //-------------------------------------------------------------- // Keywords, one per keyword, surprisingly. These are a title or // name (ie, the actual keyword itself), followed by one or more // syntax entries, a description, notes, examples and a cross- // reference, all as appropriate. Only the title, at least one // syntax and the description are mandatory. Regardless, any // entries that appear must be in the following order. //-------------------------------------------------------------- keyword : title (syntax)+ description (example)* (kw_notes)* (xref)* ; //-------------------------------------------------------------- // Title is 'kw:' or 'keyword:' and the keyword name. //-------------------------------------------------------------- title : (KW | KEYWORD) title_id ; title_id : TITLE_ID ; //-------------------------------------------------------------- // Each syntax entry is 'syntax:' and a string. //-------------------------------------------------------------- syntax : SYNTAX string ; //-------------------------------------------------------------- // Description starts with 'description:' followed by free // format text. Text will have to be delimited though. There // must be at least one text section though. //-------------------------------------------------------------- description : DESCRIPTION (text)+ ; //-------------------------------------------------------------- // Example starts with 'example:' followed by multiple free // format text or code listings. Text will have to be delimited // though. //-------------------------------------------------------------- example : EXAMPLE (text | listing)+ ; //-------------------------------------------------------------- // Notes can be 'note:' and one note, or 'notes:' followed by a // list of numbers, a colon, and the note itself. The notes are // delimited text and/or listings. //-------------------------------------------------------------- kw_notes : note | notes ; note : NOTE (notelist)+ ; notes : NOTES (noteheader (notelist)+ )+ ; noteheader : NUMBER ':' ; notelist : (text | listing) ; //-------------------------------------------------------------- // Listings are delimited code lines. //-------------------------------------------------------------- listing : CODE LISTING ; //-------------------------------------------------------------- // The cross reference is 'xref:' followed by a list of one or // more keywords separated by comma (and optional space). //-------------------------------------------------------------- xref : XREF title_id (KW_SEP title_id)* ; //-------------------------------------------------------------- // Strings are either single or double quote delimited. //-------------------------------------------------------------- string : SQ_STRING | DQ_STRING ; //-------------------------------------------------------------- // Text is just a paragraph of text. I need this as a separate // parser rule to make the parser write out text and listing in // the corrrect order for Examples. //-------------------------------------------------------------- text : TEXT ; //-------------------------------------------------------------- // L E X E R R U L E S //-------------------------------------------------------------- TITLE : T I T L E ':' ; TOOLKIT : T O O L K I T ':' ; SYNTAX : S Y N T A X ':' ; LOCATION : L O C A T I O N ':' ; DESCRIPTION : D E S C R I P T I O N ':' ; KW : K W ':' ; KEYWORD : K E Y W O R D ':' ; KW_SEP : ',' ' '? ; XREF : X R E F ':' ; EXAMPLE : E X A M P L E ':' ; NOTE : N O T E ':' ; NOTES : N O T E S ':' ; CODE : C O D E ':' ; //-------------------------------------------------------------- // TEXT delimiters. // We need to delimit chunks of text and to do this we define an // opening and closing delimiter, like strings. In this case it // could be possible for the delimiter to appear in the text, so // each chunk of text is delimited by one of a number of pairs // of delimiters. //-------------------------------------------------------------- OPEN_1 : '{{' ; CLOSE_1 : '}}' ; OPEN_3 : '((' ; CLOSE_3 : '))' ; OPEN_4 : '<<' ; CLOSE_4 : '>>' ; TEXT : OPEN_1 (.)*? CLOSE_1 | OPEN_3 (.)*? CLOSE_3 | OPEN_4 (.)*? CLOSE_4 ; //-------------------------------------------------------------- // TEXT delimiters. // We need to delimit chunks of text and to do this we define an // opening and closing delimiter, like strings. In this case it // could be possible for the delimiter to appear in the text, so // each chunk of text is delimited by one of a number of pairs // of delimiters. //-------------------------------------------------------------- OPEN_2 : '[[' ; CLOSE_2 : ']]' ; LISTING : OPEN_2 (.)*? CLOSE_2 ; //-------------------------------------------------------------- // STRINGS //-------------------------------------------------------------- // These will have to be handled in the parser. As the // escape character is retained. Escaping is by doubling // up the quote that is embedded, or preceding it with // a backslash. // // 'This ''works'' so does \'this\'.' // 'But this doesn''t work with different escapes of \' quotes.' // // CR/LF is not allowed in strings. //-------------------------------------------------------------- DQ_STRING : D_QUOTE (~[\r\n"] | '""')* D_QUOTE | D_QUOTE (~[\r\n"] | '\\"')* D_QUOTE ; SQ_STRING : S_QUOTE (~[\r\n'] | '\'\'')* S_QUOTE | S_QUOTE (~[\r\n'] | '\\\'')* S_QUOTE ; //-------------------------------------------------------------- // COMMENTS //-------------------------------------------------------------- // For single line comments, anything from the '#' to the end of // the line is ignored. // For multi-line comments, it's pretty much the same, anything // between '/*' and '*/' is ignored. //-------------------------------------------------------------- COMMENT_SL : '#' ~('\n')*? '\n' -> skip; COMMENT_ML : '/*' .*? '*/' -> skip; // These have to be at the end. // Ids are a letter or underscore, any number of letters, digits or underscores // and a final, optional percent or dollar. TITLE_ID : [A-Za-z_][A-Za-z0-9_]*[%$]? ; NUMBER : DIGIT (DIGIT)* ; //-------------------------------------------------------------- // TEXT really stuffs things up, if it goes before // TITLE_ID, we get errors, likewise, after TITLE_ID. Sigh. // // BASICALLY, don't use it. //-------------------------------------------------------------- //TEXT : ~('\n')*? '\n'; WS : [ \t\r\n]+ -> skip ; // ---------- // Fragments. // ---------- fragment S_QUOTE : '\'' ; fragment D_QUOTE : '"' ; fragment A : [Aa] ; fragment B : [Bb] ; fragment C : [Cc] ; fragment D : [Dd] ; fragment E : [Ee] ; fragment F : [Ff] ; fragment G : [Gg] ; fragment H : [Hh] ; fragment I : [Ii] ; fragment J : [Jj] ; fragment K : [Kk] ; fragment L : [Ll] ; fragment M : [Mm] ; fragment N : [Nn] ; fragment O : [Oo] ; fragment P : [Pp] ; fragment Q : [Qq] ; fragment R : [Rr] ; fragment S : [Ss] ; fragment T : [Tt] ; fragment U : [Uu] ; fragment V : [Vv] ; fragment W : [Ww] ; fragment X : [Xx] ; fragment Y : [Yy] ; fragment Z : [Zz] ; fragment DIGIT : [0-9] ; fragment LETTER : [A-Za-z] ;
src/main/antlr/FulibClass.g4
fujaba/foolib
12
3067
<filename>src/main/antlr/FulibClass.g4<gh_stars>10-100 // tested against // https://github.com/antlr/grammars-v4/blob/b47fc22a9853d1565d1d0f53b283d46c89fc30e5/java/examples/AllInOne7.java // and // https://github.com/antlr/grammars-v4/blob/b47fc22a9853d1565d1d0f53b283d46c89fc30e5/java/examples/AllInOne8.java grammar FulibClass; // =============== Parser =============== file: packageDecl? (importDecl | SEMI)* (classDecl | SEMI)* EOF; // --------------- Top-Level Declarations --------------- packageDecl: PACKAGE qualifiedName SEMI; importDecl: IMPORT STATIC? qualifiedName (DOT STAR)? SEMI; classDecl: (modifier | annotation)* classMember; classMember: (CLASS | ENUM | AT? INTERFACE) IDENTIFIER typeParamList? (EXTENDS extendsTypes=annotatedTypeList)? (IMPLEMENTS implementsTypes=annotatedTypeList)? classBody; classBody: LBRACE (enumConstants (SEMI (member | SEMI)*)? | (member | SEMI)*) RBRACE; // --------------- Members --------------- member: initializer | (modifier | annotation)* (constructorMember | fieldMember | methodMember | classMember); initializer: STATIC? balancedBraces; // constructor: (modifier | annotation)* constructorMember; constructorMember: typeParamList? IDENTIFIER parameterList (THROWS annotatedTypeList)? balancedBraces; enumConstants: enumConstant (COMMA enumConstant)*; enumConstant: annotation* IDENTIFIER balancedParens? balancedBraces?; field: (modifier | annotation)* fieldMember; fieldMember: type fieldNamePart (COMMA fieldNamePart)* SEMI; fieldNamePart: IDENTIFIER arraySuffix* (EQ expr)?; method: (modifier | annotation)* methodMember; methodMember: (typeParamList annotatedType | type) IDENTIFIER parameterList arraySuffix* (THROWS annotatedType (COMMA annotatedType)*)? (DEFAULT expr)? (balancedBraces | SEMI); parameterList: LPAREN (parameter (COMMA parameter)*)? RPAREN; parameter: (modifier | annotation)* type ELLIPSIS? (IDENTIFIER arraySuffix* | (IDENTIFIER DOT)? THIS); // --------------- Types --------------- typeParamList: LANGLE (typeParam (COMMA typeParam)*)? RANGLE; typeParam: annotation* IDENTIFIER (EXTENDS annotatedType (AMP annotatedType)*)?; typeArg: annotation* (QMARK (EXTENDS annotatedType | SUPER annotatedType)? | type); type: (primitiveType | referenceType | importType) arraySuffix*; arraySuffix: annotation* LBRACKET RBRACKET; annotatedType: annotation* type; annotatedTypeList: annotatedType (COMMA annotatedType)*; primitiveType: VOID | BOOLEAN | BYTE | SHORT | CHAR | INT | LONG | FLOAT | DOUBLE; referenceType: referenceTypePart (DOT annotation* referenceTypePart)*; referenceTypePart: IDENTIFIER typeArgList?; importTypeName: IMPORT LPAREN qualifiedName RPAREN; importType: importTypeName typeArgList?; typeArgList: LANGLE (typeArg (COMMA typeArg)*)? RANGLE; // --------------- Misc. --------------- modifier: PUBLIC | PROTECTED | PRIVATE | ABSTRACT | STATIC | FINAL | TRANSIENT | VOLATILE | SYNCHRONIZED | NATIVE | STRICTFP | DEFAULT; annotation: AT (qualifiedName | importTypeName) balancedParens?; expr: (balancedBraces | balancedParens | NEW type balancedParens balancedBraces? // constructor | DOT IDENTIFIER // field access | DOT typeArgList? IDENTIFIER balancedParens // method call | ~(SEMI | COMMA) )*; qualifiedName: IDENTIFIER (DOT IDENTIFIER)*; balancedParens: LPAREN (~(LPAREN | RPAREN) | balancedParens)*? RPAREN; balancedBraces: LBRACE (~(LBRACE | RBRACE) | balancedBraces)*? RBRACE; // =============== Lexer =============== // --------------- Symbols --------------- DOT: '.'; STAR: '*'; COMMA: ','; SEMI: ';'; AT: '@'; AMP: '&'; QMARK: '?'; EQ: '='; ELLIPSIS: '...'; LPAREN: '('; RPAREN: ')'; LBRACE: '{'; RBRACE: '}'; LANGLE: '<'; RANGLE: '>'; LBRACKET: '['; RBRACKET: ']'; // --------------- Keywords --------------- PACKAGE: 'package'; IMPORT: 'import'; CLASS: 'class'; ENUM: 'enum'; INTERFACE: 'interface'; EXTENDS: 'extends'; IMPLEMENTS: 'implements'; SUPER: 'super'; THROWS: 'throws'; DEFAULT: 'default'; PUBLIC: 'public'; PROTECTED: 'protected'; PRIVATE: 'private'; ABSTRACT: 'abstract'; STATIC: 'static'; FINAL: 'final'; TRANSIENT: 'transient'; VOLATILE: 'volatile'; SYNCHRONIZED: 'synchronized'; NATIVE: 'native'; STRICTFP: 'strictfp'; VOID: 'void'; BOOLEAN: 'boolean'; BYTE: 'byte'; SHORT: 'short'; CHAR: 'char'; INT: 'int'; LONG: 'long'; FLOAT: 'float'; DOUBLE: 'double'; THIS: 'this'; NEW: 'new'; DOC_COMMENT: '/**' .*? '*/' -> channel(3); // TODO named JAVADOC channel (requires separate lexer + parser grammars) BLOCK_COMMENT: '/*' .*? '*/' -> channel(2); LINE_COMMENT: '//' .*? '\n' -> channel(2); IDENTIFIER: JavaLetter JavaLetterOrDigit*; // from https://github.com/antlr/grammars-v4/blob/b47fc22a9853d1565d1d0f53b283d46c89fc30e5/java8/Java8Lexer.g4#L450 fragment JavaLetter: // these are the "java letters" below 0xFF [a-zA-Z$_] | // covers all characters above 0xFF which are not a surrogate ~[\u0000-\u00FF\uD800-\uDBFF] {Character.isJavaIdentifierStart(_input.LA(-1))}? | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF [\uD800-\uDBFF] [\uDC00-\uDFFF] {Character.isJavaIdentifierStart(Character.toCodePoint((char) _input.LA(-2), (char) _input.LA(-1)))}? ; fragment JavaLetterOrDigit: // these are the "java letters or digits" below 0xFF [a-zA-Z0-9$_] | // covers all characters above 0xFF which are not a surrogate ~[\u0000-\u00FF\uD800-\uDBFF] {Character.isJavaIdentifierPart(_input.LA(-1))}? | // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF [\uD800-\uDBFF] [\uDC00-\uDFFF] {Character.isJavaIdentifierPart(Character.toCodePoint((char) _input.LA(-2), (char) _input.LA(-1)))}? ; // --------------- Char and String Literals --------------- // the main reason for them being here is that we properly handle cases like '{' or " ) " in code blocks. CharacterLiteral: '\'' SingleCharacter '\'' | '\'' EscapeSequence '\''; fragment SingleCharacter: ~['\\\r\n]; StringLiteral: '"' StringCharacters? '"'; fragment StringCharacters: StringCharacter+; fragment StringCharacter: ~["\\\r\n] | EscapeSequence; fragment EscapeSequence: '\\' [btnfr"'\\] | OctalEscape | UnicodeEscape; fragment OctalEscape: '\\' OctalDigit | '\\' OctalDigit OctalDigit | '\\' ZeroToThree OctalDigit OctalDigit; fragment OctalDigit: [0-7]; fragment ZeroToThree: [0-3]; fragment UnicodeEscape: '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit; fragment HexDigit: [0-9a-fA-F]; // --------------- Whitespace --------------- WS: [ \n\r\t\p{White_Space}] -> skip; OTHER: .+?;
src/autogenerated/textBank12.asm
jannone/westen
49
179599
<reponame>jannone/westen ; line: 'I rubbed the stake with the garlic.' ; size in bytes: 36 line_0: db #23,#3b,#00,#8a,#90,#6b,#6b,#71,#6f,#00,#8e,#77,#71,#00,#8c,#8e db #69,#7c,#71,#00,#95,#79,#8e,#77,#00,#8e,#77,#71,#00,#75,#69,#8a db #7e,#79,#6d,#14 end_line_0: ; line: 'A wooden stake.' ; size in bytes: 16 line_1: db #0f,#2b,#00,#95,#84,#84,#6f,#71,#82,#00,#8c,#8e,#69,#7c,#71,#14 end_line_1: ; line: 'A wooden stake rubbed in garlic.' ; size in bytes: 33 line_2: db #20,#2b,#00,#95,#84,#84,#6f,#71,#82,#00,#8c,#8e,#69,#7c,#71,#00 db #8a,#90,#6b,#6b,#71,#6f,#00,#79,#82,#00,#75,#69,#8a,#7e,#79,#6d db #14 end_line_2: ; line: 'there. Rub them with garlic before they' ; size in bytes: 40 line_3: db #27,#8e,#77,#71,#8a,#71,#14,#00,#51,#90,#6b,#00,#8e,#77,#71,#7f db #00,#95,#79,#8e,#77,#00,#75,#69,#8a,#7e,#79,#6d,#00,#6b,#71,#73 db #84,#8a,#71,#00,#8e,#77,#71,#9b end_line_3: ; line: 'There is nothing behind this painting.' ; size in bytes: 39 line_4: db #26,#55,#77,#71,#8a,#71,#00,#79,#8c,#00,#82,#84,#8e,#77,#79,#82 db #75,#00,#6b,#71,#77,#79,#82,#6f,#00,#8e,#77,#79,#8c,#00,#86,#69 db #79,#82,#8e,#79,#82,#75,#14 end_line_4: ; line: 'a key inside.' ; size in bytes: 14 line_5: db #0d,#69,#00,#7c,#71,#9b,#00,#79,#82,#8c,#79,#6f,#71,#14 end_line_5: ; line: 'I will need to use the stakes...' ; size in bytes: 33 line_6: db #20,#3b,#00,#95,#79,#7e,#7e,#00,#82,#71,#71,#6f,#00,#8e,#84,#00 db #90,#8c,#71,#00,#8e,#77,#71,#00,#8c,#8e,#69,#7c,#71,#8c,#14,#14 db #14 end_line_6: ; line: 'There is nothing else inside.' ; size in bytes: 30 line_7: db #1d,#55,#77,#71,#8a,#71,#00,#79,#8c,#00,#82,#84,#8e,#77,#79,#82 db #75,#00,#71,#7e,#8c,#71,#00,#79,#82,#8c,#79,#6f,#71,#14 end_line_7: ; line: 'Look! A safe behind this painting!' ; size in bytes: 35 line_8: db #22,#42,#84,#84,#7c,#02,#00,#2b,#00,#8c,#69,#73,#71,#00,#6b,#71 db #77,#79,#82,#6f,#00,#8e,#77,#79,#8c,#00,#86,#69,#79,#82,#8e,#79 db #82,#75,#02 end_line_8: ; line: 'Nothing else in this chest.' ; size in bytes: 28 line_9: db #1b,#47,#84,#8e,#77,#79,#82,#75,#00,#71,#7e,#8c,#71,#00,#79,#82 db #00,#8e,#77,#79,#8c,#00,#6d,#77,#71,#8c,#8e,#14 end_line_9: ; line: 'I'll leave the stools behind.' ; size in bytes: 30 line_10: db #1d,#3b,#08,#7e,#7e,#00,#7e,#71,#69,#92,#71,#00,#8e,#77,#71,#00 db #8c,#8e,#84,#84,#7e,#8c,#00,#6b,#71,#77,#79,#82,#6f,#14 end_line_10: ; line: 'Ding Dong!' ; size in bytes: 11 line_11: db #0a,#31,#79,#82,#75,#00,#31,#84,#82,#75,#02 end_line_11: ; line: 'There is a loose page.' ; size in bytes: 23 line_12: db #16,#55,#77,#71,#8a,#71,#00,#79,#8c,#00,#69,#00,#7e,#84,#84,#8c db #71,#00,#86,#69,#75,#71,#14 end_line_12: ; line: 'There was a revolver inside!' ; size in bytes: 29 line_13: db #1c,#55,#77,#71,#8a,#71,#00,#95,#69,#8c,#00,#69,#00,#8a,#71,#92 db #84,#7e,#92,#71,#8a,#00,#79,#82,#8c,#79,#6f,#71,#02 end_line_13: ; line: 'Nothing here to use or pick up.' ; size in bytes: 32 line_14: db #1f,#47,#84,#8e,#77,#79,#82,#75,#00,#77,#71,#8a,#71,#00,#8e,#84 db #00,#90,#8c,#71,#00,#84,#8a,#00,#86,#79,#6d,#7c,#00,#90,#86,#14 end_line_14: ; line: 'You will need to drive a stake rubbed' ; size in bytes: 38 line_15: db #25,#63,#84,#90,#00,#95,#79,#7e,#7e,#00,#82,#71,#71,#6f,#00,#8e db #84,#00,#6f,#8a,#79,#92,#71,#00,#69,#00,#8c,#8e,#69,#7c,#71,#00 db #8a,#90,#6b,#6b,#71,#6f end_line_15: ; line: 'Work quickly! Prepare it before they arrive!' ; size in bytes: 45 line_16: db #2c,#5d,#84,#8a,#7c,#00,#88,#90,#79,#6d,#7c,#7e,#9b,#02,#00,#4c db #8a,#71,#86,#69,#8a,#71,#00,#79,#8e,#00,#6b,#71,#73,#84,#8a,#71 db #00,#8e,#77,#71,#9b,#00,#69,#8a,#8a,#79,#92,#71,#02 end_line_16:
courses/spark_for_ada_programmers/labs/answers/120_depends_contract_and_information_flow_analysis/swapping.adb
AdaCore/training_material
15
7350
<filename>courses/spark_for_ada_programmers/labs/answers/120_depends_contract_and_information_flow_analysis/swapping.adb<gh_stars>10-100 package body Swapping is procedure Swap (X, Y: in out Positive) is Tmp: Positive; begin Tmp := X; X := Y; Y := Tmp; end Swap; procedure Identity (X, Y: in out Positive) is begin Swap (X, Y); Swap (Y, X); end Identity; end Swapping;
src/servlet-core-rest.ads
My-Colaborations/ada-servlet
6
16413
----------------------------------------------------------------------- -- servlet-servlets-rest -- REST servlet -- Copyright (C) 2016, 2017, 2018, 2019 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Servlet.Rest; with Servlet.Routes.Servlets.Rest; use Servlet.Rest; package Servlet.Core.Rest is -- The <b>Servlet</b> represents the component that will handle -- an HTTP request received by the server. type Rest_Servlet is new Servlet with private; -- Called by the servlet container to indicate to a servlet that the servlet -- is being placed into service. overriding procedure Initialize (Server : in out Rest_Servlet; Context : in Servlet_Registry'Class); -- Receives standard HTTP requests from the public service method and dispatches -- them to the Do_XXX methods defined in this class. This method is an HTTP-specific -- version of the Servlet.service(Request, Response) method. There's no need -- to override this method. overriding procedure Service (Server : in Rest_Servlet; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class); -- Create a route for the REST API. function Create_Route (Registry : in Servlet_Registry; Name : in String) return Routes.Servlets.Rest.API_Route_Type_Access; function Create_Route (Servlet : in Servlet_Access) return Routes.Servlets.Rest.API_Route_Type_Access; procedure Dispatch (Server : in Rest_Servlet; Method : in Method_Type; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class); private type Rest_Servlet is new Servlet with null record; end Servlet.Core.Rest;
src/cupcake-primitives.ads
skordal/cupcake
2
23099
<filename>src/cupcake-primitives.ads<gh_stars>1-10 -- The Cupcake GUI Toolkit -- (c) <NAME> 2012 <<EMAIL>> -- Report bugs and issues on <http://github.com/skordal/cupcake/issues> -- vim:ts=3:sw=3:et:si:sta package Cupcake.Primitives is -- Simple point type: type Point is record X, Y : Integer; end record; -- Point operators: function "+" (Left, Right : in Point) return Point with Inline, Pure_Function; function "-" (Left, Right : in Point) return Point with Inline, Pure_Function; function "=" (Left, Right : in Point) return Boolean with Inline, Pure_Function; -- Type for specifying dimensions: type Dimension is record Width, Height : Natural; end record; -- Dimension operators: function "<" (Left, Right : in Dimension) return Boolean with Inline, Pure_Function; function ">" (Left, Right : in Dimension) return Boolean with Inline, Pure_Function; function "=" (Left, Right : in Dimension) return Boolean with Inline, Pure_Function; -- Rectangle type: type Rectangle is record Origin : Point; Size : Dimension; end record; -- Line type: type Line is record Start : Point; Endpoint : Point; end record; end Cupcake.Primitives;